-
Notifications
You must be signed in to change notification settings - Fork 2
/
attestationTool.php
208 lines (160 loc) · 5.91 KB
/
attestationTool.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>IMPACT Attestation Tool v2015.03.17</title>
<link rel="shortcut icon" type="image/ico" href="./favicon.ico" />
<link rel="stylesheet" type="text/css" href="./styles/attestationTool.css">
</link>
<script type="text/javascript" src="./js/globals.js">
</script>
<script type="text/javascript" src="./js/color.js">
</script>
<script type="text/javascript" src="./js/keyFunctions.js">
</script>
<script type="text/javascript" src="./js/ajaxFunctions.js">
</script>
<script type="text/javascript" src="./js/attestationTool.js">
</script>
<?php
require_once('./php/attestationToolBox.php');
$aBackgroundColors; # Global variable
# three things can happen here:
# 1. user logs in to export data (export box is checked)
# 2. user logs in to work on annotations (export box is NOT checked)
# 3. default, show inlog form
# possibility #1
if (isset($_REQUEST['sDatabase']) && isset($_REQUEST['bExport']) && isset($_REQUEST['sUser'])){ # this will be 'on' or an empty string
$sHost = $_SERVER['HTTP_HOST'];
$sExportType = $_REQUEST['sExportType'];
header('Location: ./php/'.$sExportType.'?sDatabase='.$_REQUEST['sDatabase']);
}
# possibility #2
# user logs in so as to annotate
else if( isset($_REQUEST['sUser']) ) {
$sUser = get_magic_quotes_gpc() ? $_REQUEST['sUser']
: addslashes ($_REQUEST['sUser']);
$sDatabase = (isset($_REQUEST['sDatabase'])) ? $_REQUEST['sDatabase']
: false;
chooseDb($sDatabase);
$sJavascriptArrayDeclarations = getBackgroundColorInfo($sDatabase);
// make sure double attestations will never be added
// (see: http://dba.stackexchange.com/questions/24531/mysql-create-index-if-not-exists)
$oResult = mysql_query("SELECT COUNT(1) IndexIsThere ".
"FROM INFORMATION_SCHEMA.STATISTICS ".
"WHERE table_schema=DATABASE() ".
"AND `COLUMN_NAME` in ('quotationId', 'onset') ".
"AND `TABLE_NAME` = 'attestations' ".
"AND `NON_UNIQUE` = 0;");
if ($oRow = mysql_fetch_assoc ($oResult)) {
if ($oRow['IndexIsThere'] != '2')
{
mysql_query("ALTER TABLE attestations ADD UNIQUE INDEX quotationIdOnsetUnique (quotationId, onset);");
}
}
// User check
$oResult= mysql_query("SELECT id, name FROM revisors WHERE name = '$sUser'");
echo mysql_error();
$iUserId = 0;
if ($oRow = mysql_fetch_assoc ($oResult)) {
// Set the user name to the version in the database (so the user can type
// in 'kAtrIEN', but it will always be displayed as 'Katrien'...)
$sUser = $oRow['name'];
$iUserId = $oRow['id'];
print '<script type="text/javascript">' .
" var sDatabase = '$sDatabase';\n" .
" var sUser = '$sUser';\n" .
" var iUserId = $iUserId;\n" .
" var bUseCtrlKey = ". ($GLOBALS['bUseCtrlKey'] ? "true":"false") .";";
if( $sJavascriptArrayDeclarations ) // Only if the database has a types table (required since 2014 version)
print $sJavascriptArrayDeclarations;
print "</script>\n";
?>
</head>
<!-- NOTE that we update the totals column every 10 seconds -->
<body onLoad="javascript: document.onkeydown = keyDown; document.onkeyup = keyUp; document.onmouseup = endSelection; fillAttestationsDiv(false, false, false, false); addClickEventListener();"> <!-- onClick="javascript: hideTypeMenu();"> -->
<!-- Div for the messages -->
<div id=ajaxDiv></div>
<!-- For the numbers -->
<table width=100% border=0>
<tr>
<td align=left valign=top height=12px><span id=userStats> </span></td>
<td align=center valign=top><span id=lastEdited> </span></td>
<td align=right valign=top><span id=totalStats> </span></td>
</tr>
</table>
<!-- This is the main div that the headword and its quotes are in -->
<div id=attestationsDiv></div>
<?php
// NOTE that the file menu simple isn't there when we are not in multi types
// mode. This fact is used in the Javascript file.
if( $sJavascriptArrayDeclarations )
print "<!-- Div for showing the different types one can choose from -->\n" .
"<div id=typeMenu style='visibility: hidden'></div>\n";
mysql_free_result($oResult);
} // End of: User check
else // If there is no user called like this
print "Oops! User <b>$sUser</b> is not known. Please try again...\n";
}
# possibility #3
# Print inlog form
else {
?>
</head>
<body onLoad="javascript: document.loginForm.sUser.focus(); if(navigator.userAgent.indexOf('Firefox')<0) {alert('This piece of software only works in Firefox. Please close your current browser and start again in Firefox. Thank you!');};" class=withBackground>
<center>
<h1>IMPACT Attestation Tool</h1>
<table>
<tr>
<td align=left>
<form action="./attestationTool.php" method="post" name="loginForm" target="_self">
<table>
<tr>
<td style="padding: 0px 30px 0px 30px">
<?php
// Display the projects list
// This list must be set in /php/globals.php
$iProjectListCounter = 1;
$aProjectList = $GLOBALS['asProject'];
$iProjectListLength = count($aProjectList);
foreach ($aProjectList as $sProjectCode => $sProjectDescription) {
print '<p>'.
'<input type="radio" name="sDatabase" value="'.$sProjectCode.'"';
if ($sProjectCode == $GLOBALS['sChecked'])
print ' checked';
print '>'.$sProjectDescription.
'<br>';
if ($iProjectListCounter >= 5 )
{
$iProjectListCounter = 1;
print '</td><td style="padding: 0px 30px 0px 30px">';
}
else
$iProjectListCounter++;
}
?>
</td>
</tr>
</table>
<br>
User name <input id=sUser name=sUser type="text" autocomplete="on" size="15" maxlength="25" value="">
<br>
<br>
Export data <input id=bExport name=bExport type="checkbox"><br>
<select name=sExportType>
<option value="export2alto.php" selected>Alto</option>
<option value="export2mnw.php">MNW</option>
</select>
</form>
</td>
</tr>
</table>
</center>
<div class=instructions>
<a href="./pages/instructions.html"><u>>> Instructions</u></a>
<p>
</div>
<?php
} // End of: else { // Print inlog form
?>
</body>
</html>