-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadIDs.php
More file actions
executable file
·33 lines (30 loc) · 930 Bytes
/
readIDs.php
File metadata and controls
executable file
·33 lines (30 loc) · 930 Bytes
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
<?php
if ( foundID("IDs.cgi",217075) == "true" )
echo "ID WAS FOUND!!";
else
header('Location: invalidIDPage.html');
function foundID($fileName, $studID)
{
//echo "fileName: $fileName , studentID: $studID <br>";
$lines = file ( $fileName /*"IDs.cgi"*/);
$numLines = count($lines);
$studentID = $studID;//"217075";
$found = 0;
for ($i = 0; $i < $numLines; $i++){
//echo "<pre>line $i: $lines[$i] </pre>";
// split by any number of spaces
$thingsPerLine = preg_split('#\s+#', $lines[$i], null, PREG_SPLIT_NO_EMPTY);
//echo "thingsPerLine:".count($thingsPerLine);
$aStudentID = $thingsPerLine[count($thingsPerLine)-1];
//echo "<pre>Student ID: $aStudentID <pre> ";
if ($studentID == $aStudentID){
$found++;//echo "M A T C H ! ! ! ! <br>";
break;
}
}
if ($found == 0)
return "false";//header('Location: invalidIDPage.html');
else
return "true";//echo "ID WAS FOUND!!";
}
?>