Official registration is over. Only walk-in registrations are now being accepted, pending approval from the local site coordinator. No new sites may be opened."; //die("Registration is closed. It will be up again Feb. 5 at 8 a.m. EST for walk-in registrations. Walk-in registrations may only participate at a site that is already established (i.e. no new sites may be created) and must have the permission of the site facilitator. They must register through this site before the end of the contest."); } $link = mysql_connect('localhost', 'naclo', 'MalEMEWi') or die('Could not connect: ' . mysql_error()); mysql_select_db('NACLO') or die('Could not select database'); $leavethis = "variable as it is"; if (!function_exists("htmlspecialchars_decode")) { function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT) { return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style))); } } // ========================= // = Convenience functions = // ========================= function getName($info, $cutoff=-1) { $title = $info['title']; $first = $info['first']; $last = $info['last']; $name = "$first $last"; if($title) $name = "$title $name"; if($cutoff > 0 && strlen($name) > $cutoff) $name = substr($name, 0, $cutoff) . "..."; return $name; } function getTeacherEmail($teacher_id, $pretty=FALSE) { $query = mysql_query("SELECT first, last, email FROM teacher WHERE teacher_id = '$teacher_id'"); $row = mysql_fetch_row($query); $name = $row[0] . " " . $row[1]; $email = $row[2]; $ret = $pretty? premail($name, $email) : $email; return $ret; } //returns MySQL result string. orderby is optional, as is second/sval. function query($table, $field, $value, $orderby="", $second="", $sval="") { $query = ""; if($second && $sval){ $query = sprintf("SELECT * FROM %s WHERE %s='%s' AND %s='%s' %s", mysql_real_escape_string($table), mysql_real_escape_string($field), mysql_real_escape_string($value), mysql_real_escape_string($second), mysql_real_escape_string($sval), mysql_real_escape_string($orderby)); }else{ $query = sprintf("SELECT * FROM %s WHERE %s='%s'%s", mysql_real_escape_string($table), mysql_real_escape_string($field), mysql_real_escape_string($value), mysql_real_escape_string($orderby)); } $result = mysql_query($query); return $result; } // ===================== // = DB Read functions = // ===================== //returns an array of Key => Value :: school_id => "School Name [Zip]" function getSchool($state) { $school = array("NOSCHOOL" => "Select a School..."); $query = sprintf("SELECT * FROM %s WHERE %s='%s' ORDER BY name", mysql_real_escape_string("school"), mysql_real_escape_string("state"), mysql_real_escape_string($state)); $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $school[$row['school_id']] = $row['name'] . " [" . $row['zip'] . "]"; } return $school; } //returns an array of Key => Value :: teacher_id => Title First Last function getTeacher($school) { $school_id = strtolower($school); if($school_id == "homeschool" || $school_id == "newschool"){ return ""; } $teacher = array("NOSCHOOL" => "Select a Teacher..."); $query = sprintf("SELECT * FROM %s WHERE %s='%s' AND is_second='0' ORDER BY last", mysql_real_escape_string("teacher"), mysql_real_escape_string("school_id"), mysql_real_escape_string($school)); $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $teacher[$row['teacher_id']] = getName($row); } return $teacher; } function getSchoolInfo($school) { $result = query("school","school_id",$school); $row = mysql_fetch_assoc($result); // $schoolInfo['name'] = $row['name']; // $schoolInfo['street'] = $row['street']; // $schoolInfo['city'] = $row['city']; // $schoolInfo['zip'] = $row['zip']; return $row; } function getTeacherInfo($teacher) { $result = query("teacher","teacher_id",$teacher); $row = mysql_fetch_assoc($result); // $teacherInfo['title'] = $row['title']; // $teacherInfo['first'] = $row['first']; // $teacherInfo['last'] = $row['last']; // $teacherInfo['email'] = $row['email']; // $teacherInfo['phone_num'] = $row['phone_num']; // $teacherInfo['phone_ext'] = $row['phone_ext']; // $teacherInfo['site_id'] = $row['site_id']; return $row; } function getSiteInfo($site_id) { if($site_id==6){ $row = Array(); $row['name'] = 'High School Site'; $row['site_id'] = 6; return $row; } if($site_id==0){ $row = Array(); $row['name'] = "No Site Selected"; $row['site_id'] = 0; return $row; } $result = query("site","site_id",$site_id); $row = mysql_fetch_assoc($result); return $row; } //returns an array site_id => sitename for all the sites (sorted alphabetically) function getSites() { $siteList = array(); $result = mysql_query("SELECT * FROM site ORDER BY name"); //so it puts this at the front of the list $siteList["6"] = "Select Site (Leave this field alone if you are registered at a high school)."; while($row = mysql_fetch_assoc($result)){ if(!$row['full']) $siteList[$row['site_id']] = $row['name'] . " (" . $row['city'] . ", " . $row['state'] . ")"; else $siteList[$row['site_id']] = $row['name'] . " (" . $row['city'] . ", " . $row['state'] . ")     [full]"; } //There is no city or state //$siteList["6"] = "High School Site"; return $siteList; } //returns an array site_id => sitename for all the sites (sorted alphabetically) // Does not alter name if full function getSites_stable() { $siteList = array(); $result = mysql_query("SELECT * FROM site ORDER BY name"); //so it puts this at the front of the list $siteList["6"] = "High School Site"; while($row = mysql_fetch_assoc($result)){ $siteList[$row['site_id']] = $row['name'] . " (" . $row['city'] . ", " . $row['state'] . ")"; } return $siteList; } function getFullSites() { $result = mysql_query("SELECT * from site where full = '1'"); while($row = mysql_fetch_assoc($result)) { $sites[] = $row['name']; } return $sites; } function getSiteName($site_id, $where=TRUE, $cutoff=-1) { //if it's at a high school if($site_id == "6") return "High School Site"; if(!$site_id) return "No site selected"; $result = mysql_query("SELECT * FROM site WHERE site_id = '$site_id'"); $row = mysql_fetch_assoc($result); $name = ($cutoff >= 0 && strlen($row['name']) > $cutoff) ? substr($row['name'], 0, $cutoff) . "..." : $row['name']; if($where) $name = $name . " (" . $row['city'] . ", " . $row['state'] . ")"; return $name; } function getSitePlace($site_id, $cutoff=-1) { if(!$site_id) return "No site selected"; //if it's online if($site_id == "6") return "High School Site"; $result = mysql_query("SELECT city, state FROM site WHERE site_id = '$site_id'"); $row = mysql_fetch_assoc($result); $name = $row['city'] . ", " . $row['state']; $name = ($cutoff >= 0 && strlen($name) > $cutoff) ? substr($name, 0, $cutoff) . "..." : $name; return $name; } function getSchoolName($school_id, $where=TRUE, $cutoff=-1) { $result = mysql_query("SELECT name, city, state FROM school WHERE school_id = '" . $school_id . "'"); $school = mysql_fetch_assoc($result); $name = ($cutoff >= 0 && strlen($school['name']) > $cutoff) ? substr($school['name'], 0, $cutoff) . "..." : $school['name']; if($where) $name = $name . " (" . $school['city'] . ", " . $school['state'] . ")"; return $name; } //returns an array of contactInfo arrays... able to handle multiple contacts per site function getContactInfo($site_id) { $result = mysql_query("SELECT * FROM contact WHERE site_id = '".$site_id."'"); $contacts = array(); $info = array(); while($row = mysql_fetch_assoc($result)) { $info['title'] = $row['title']; $info['first'] = $row['first']; $info['last'] = $row['last']; $info['email'] = $row['email']; $contacts[] = $info; } return $contacts; } function showHS(){ $schools = mysql_query("SELECT * FROM school"); echo ""; while($sch = mysql_fetch_assoc($schools)){ echo ""; } echo "
SchoolCityState
" . $sch['name'] . "" . $sch['city'] . "".$sch['state']."
"; } function showSiteList($contacts=FALSE) { $sites = mysql_query("SELECT * FROM site ORDER BY name"); if($contacts) echo '
'; else echo '
'; echo "

United States

\n"; $canada = Array("ON","BC", "AB", "NS", "QC"); $ca_univ = Array(); while($site = mysql_fetch_assoc($sites)) { $site_id = $site['site_id']; $site_web = $site['website']; $usite = $site['univ_URL']; $siteName = getSiteName($site_id); if($site_id != 6) { if(in_array($site['state'], $canada)){ $ca_univ[($site['site_id'])] = $site; continue; } $full = ""; if($site['full']) $full= "* "; if ($site_web != "") echo "
".$full."$siteName     [ local NACLO page]
\n"; elseif ($usite) echo "
$full$siteName
\n"; else echo "
$full$siteName
\n"; if($contacts) { $contact = getContactInfo($site_id); foreach($contact as $info) { $email = $info['email']; $email = str_replace("@", " [at] ", $email); $email = str_replace(".", " [dot] ", $email); $name = $info['first'] . " " . $info['last']; echo "
$name - $email
\n"; } } } else { $onsite_web = $site_web; $onsite_name = $siteName; $onsite_id = $site_id; } } echo "

Canada

\n"; foreach($ca_univ as $site){ $site_id = $site['site_id']; $site_web = $site['website']; $usite = $site['univ_URL']; $siteName = getSiteName($site_id); $full = ""; if($site['full']) $full = "* "; if ($site_web != "") echo "
".$full."$siteName     [ local NACLO page]
\n"; elseif ($usite) echo "
$full$siteName
\n"; else echo "
$full$siteName
\n"; } echo "
$onsite_name
\n"; if($contacts) { $contact = getContactInfo($onsite_id); foreach($contact as $info) { $email = $info['email']; $email = str_replace("@", " [at] ", $email); $email = str_replace(".", " [dot] ", $email); $name = $info['first'] . " " . $info['last']; echo "
$name - $email
\n"; } } echo '
'; echo "
* This site is full"; } // =================== // = write functions = // =================== //schoolInfo is an array of info Key => Value //returns the new school_id function writeSchool($schoolInfo) { global $link; //must do this to make our "mysql_insert_id" trick work $teacher_id = 0; $school_query = sprintf("INSERT INTO school (name, street, city, state, zip, time_zone) VALUES('%s', '%s', '%s', '%s', '%s', '%s');", mysql_real_escape_string($schoolInfo['name']), mysql_real_escape_string($schoolInfo['street']), mysql_real_escape_string($schoolInfo['city']), mysql_real_escape_string($schoolInfo['state']), mysql_real_escape_string($schoolInfo['zip']), mysql_real_escape_string($schoolInfo['time_zone'])); if(!mysql_query($school_query)){ $errmsg=mysql_error(); die("school query was not completed sucessfully: $school_query: $errmsg"); } $school_id = mysql_insert_id($link); if($schoolInfo['homeschool']) { $school_name = "HS_" . $schoolInfo['name']; $update_school_query = sprintf("UPDATE school SET name='%s' WHERE school_id='%s'", mysql_real_escape_string($school_name), mysql_real_escape_string($school_id)); if(!mysql_query($update_school_query)) die("update school1 query was not completed successfully: $update_school_query"); } return $school_id; } //used for teacher and secondary //teacherInfo is an array of info Key => Value //returns the new teacher_id function writeTeacher($teacherInfo) { global $link; $teacher_query = sprintf("INSERT INTO teacher VALUES('%s', '%s', '%s', '%s', DEFAULT, NOW(), '%s', '%s', '%s', '%s', '%s', '%s', DEFAULT, DEFAULT, '%s', '%s', '%s', '%s')", mysql_real_escape_string($teacherInfo['title']), mysql_real_escape_string($teacherInfo['first']), mysql_real_escape_string($teacherInfo['last']), mysql_real_escape_string($teacherInfo['email']), //mysql_real_escape_string($password), //mysql_real_escape_string($last_login), mysql_real_escape_string($teacherInfo['phone_num']), mysql_real_escape_string($teacherInfo['phone_ext']), mysql_real_escape_string($teacherInfo['street']), mysql_real_escape_string($teacherInfo['city']), mysql_real_escape_string($teacherInfo['state']), mysql_real_escape_string($teacherInfo['zip']), //mysql_real_escape_string($referral), //mysql_real_escape_string($teacher_id), mysql_real_escape_string($teacherInfo['school_id']), mysql_real_escape_string($teacherInfo['is_second']), mysql_real_escape_string($teacherInfo['is_hs']), mysql_real_escape_string($teacherInfo['site_id']) ); if(!mysql_query($teacher_query)) die("teacher query was not completed sucessfully: $teacher_query
" . mysql_error()); $teacher_id = mysql_insert_id($link); return $teacher_id; } function writeStudent($studentInfo) { global $link; $referral = $studentInfo['referral']; $referral_explain = $studentInfo['referral_explain']; if($referral == "other") $referral = $referral . ": " . $referral_explain; $p7 = $studentInfo['part2007']; if($p7 == "on" || $p7 == "yes" || $p7 == "1") $p7 = "1"; else $p7 = "0"; $studentInfo['part2007'] = $p7; //take care of values that are too long $special = substr($studentInfo['special'], 0, 1001); $languages = substr($studentInfo['languages'],0, 501); $student_query = sprintf("INSERT INTO student (first, last, email, last_login, gender, grad_year, special, part2007, languages, referral, teacher_id, school_id, phone_num, street, city, state, zip, second_id) VALUES('%s', '%s', '%s', NOW(), '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", mysql_real_escape_string($studentInfo['first']), mysql_real_escape_string($studentInfo['last']), mysql_real_escape_string($studentInfo['email']), mysql_real_escape_string($studentInfo['gender']), mysql_real_escape_string($studentInfo['grad_year']), mysql_real_escape_string($special), mysql_real_escape_string($studentInfo['part2007']), mysql_real_escape_string($languages), mysql_real_escape_string($referral), mysql_real_escape_string($studentInfo['teacher']), mysql_real_escape_string($studentInfo['school']), mysql_real_escape_string($studentInfo['phone_num']), mysql_real_escape_string($studentInfo['street']), mysql_real_escape_string($studentInfo['city']), mysql_real_escape_string($studentInfo['state']), mysql_real_escape_string($studentInfo['zip']), mysql_real_escape_string($studentInfo['sec_id'])); if(!mysql_query($student_query)) { $errmsg=mysql_error(); die("student query was not completed sucessfully: $student_query: $errmsg"); } $student_id = mysql_insert_id($link); return $student_id; } // ======================== // = VALIDATION FUNCTIONS = // ======================== function checkEmail($email) { // if (filter_var($email, FILTER_VALIDATE_EMAIL)) return true; global $dupReg; if(!$email)return false; if(preg_match('/^\w[-.\w]*@(\w[-._\w]*\.[a-zA-Z]{2,}.*)$/', $email, $matches)) { if($dupReg) return true; if(function_exists('checkdnsrr')) { return true; if(checkdnsrr($matches[1] . '.', 'MX')) return true; if(checkdnsrr($matches[1] . '.', 'A')) return true; }else{ if(!empty($hostName)) { if( $recType == '' ) $recType = "MX"; exec("nslookup -type=$recType $hostName", $result); foreach ($result as $line) { if(eregi("^$hostName",$line))return true; } return false; } return false; } } return false; } //strip non-number chars function stripToNum($string) { return preg_replace("/[^0-9]/", "", $string); } //strips non-number characters and then strips off any leading ones function stripPhone($phoneString) { $phoneString = stripToNum($phoneString); if(substr($phoneString, 0, 1) == "1") $phoneString = substr($phoneString, 1); return $phoneString; } function checkPhone(&$phoneString) { if(!$phoneString)return false; $phoneString = stripPhone($phoneString); $truth = (strlen($phoneString) > 9); if(strlen($phoneString) == 10) { $area = substr($phoneString, 0, 3); $f3 = substr($phoneString, 3, 3); $l4 = substr($phoneString, 6, 4); $phoneString = "($area) $f3-$l4"; } return $truth; } function checkZip($zip) { // thank you, Canada return (strlen($zip) >= 5); if(!$zip)return false; $zip = stripToNum($zip); return (strlen($zip) == 5); } //if it's not a homeschool, it needs a name function checkSchool($name, $id) { if($id != "HOMESCHOOL") return $name; else return true; } //cond: if $value is empty, return true, else check it function cond($type, &$value) { if(!$value) return true; switch($type) { case "phone": return checkPhone(&$value); case "email": return checkEmail($value); case "zip": return checkZip($value); default: return true; } } // ================== // = Hash functions = // ================== function hashThis($firstName, $lastName, $contact, $imageName) { return sha1($firstName . $contact . "4kicks" . $lastName . $imageName . "arefor kids"); } function hashImg($firstName, $lastName, $contact, $imageName) { global $phpSec; $imageName = strtoupper($imageName); $imageName = "$imageName.PNG"; $otherInfo = "$lastName $contact kja $firstName akjlsaf $lastName"; $returnString; if(file_exists($imageName)) { $returnString = md5(file_get_contents("$imageName") . $otherInfo); } else { $imageName = "$phpSec/actual/$imageName"; if(file_exists($imageName)) { $returnString = md5(file_get_contents("$imageName") . $otherInfo); } else { return FALSE; } } return $returnString; } function checkHash($firstName, $lastName, $contact, $textEntered, $info) { $imageName = hashImg($firstName, $lastName, $contact, $textEntered); if(!$imageName) return FALSE; $realHash = hashThis($firstName, $lastName, $contact, $imageName); return $realHash == $info; } // ====================== // = Pictures functions = // ====================== // should call delPicture after this function returns and picture is displayed // returns image name, without the .jpg function getPicture($firstName, $lastName, $contact) { global $phpSec, $contact; $result = mysql_query("SELECT name FROM secret ORDER BY RAND() LIMIT 1"); $row = mysql_fetch_assoc($result); $name = $row['name']; $hashName = hashImg($firstName, $lastName, $contact, $name); $fromFile = "$phpSec/actual/$name.PNG"; $toFile = "$phpSec/tmp/$hashName.PNG"; for($i=0; $i<7; $i++) { if(copy($fromFile,$toFile)){ return $hashName; } } echo "There was an error producing a captcha. Please contact $contact.
"; return FALSE; } function delPicture($fileName) { global $phpSec; $path = "$phpSec/tmp"; //to make it safe, just in case $fileName = preg_replace("/[^0-9a-zA-Z]/", "", $fileName); $fileName = "$path/$fileName.PNG"; if(!file_exists($fileName)) { return FALSE; } unlink($fileName); //clean up old files (that weren't deleted for whatever reason) $handle=opendir($path); while (false!==($file = readdir($handle))) { if ($file != "." && $file != "..") { //the file's age in seconds $Diff = (time() - filectime("$path/$file")); //if it's older than 70 seconds if ($Diff > 70) unlink("$path/$file"); } } closedir($handle); return TRUE; } // ======================== // = Teacher Registration = // ======================== // create "unique" hash password for a teacher (doesn't actually // have to be unique) function create_teacher_password($teacher_email, $lower=TRUE) { if($lower) $teacher_email = strtolower($teacher_email); $hashMD5 = md5($teacher_email . "self- explanatory"); $hash = substr($hashMD5, 0, 2) . substr($hashMD5, 5, 3) . substr($hashMD5, 9, 2) . substr($hashMD5, 13, 3); return $hash; } // check password against real password function teacher_pass($teacher_email, $password) { $whateverCase = create_teacher_password($teacher_email) == $password ? TRUE : FALSE; $lowerCase = create_teacher_password(strtolower($teacher_email)) == $password ? TRUE : FALSE; return $whateverCase || $lowerCase; } function getStudentInfo($student_id) { $result = mysql_query("SELECT * FROM student WHERE student_id = '$student_id'"); $row = mysql_fetch_assoc($result); return $row; } function getSecInfo($sec_id) { $result = mysql_query("SELECT * FROM teacher WHERE teacher_id = '$sec_id' AND is_second = '1'"); $row = mysql_fetch_assoc($result); return $row; } // see all students from school // update student info // update teacher info // add multiple students /*function printFeatureMenu($teacher_id, $pass) { $school_id = ""; $school_name = ""; $teacher_name = ""; $teacherInfo = getTRegInfo($teacher_id); echo "
Welcome, {$teacherInfo['name']}, what would you like to do?
". "
  • all your students
  • your information
  • student(s)
"; } */ function printFeatureMenu($teacher_id, $pass) { $school_id = ""; $school_name = ""; $teacher_name = ""; $teacherInfo = getTRegInfo($teacher_id); $extra_options = ""; if($teacherInfo['site_id']==6 && $teacherInfo['is_second']==0){ $extra_options = "
  • site coordinator checklist (Certify)
  • time recording and student checklist
  • "; } echo "
    Welcome, {$teacherInfo['name']}, what would you like to do?
    ". "
    • all your students
    • your information
    • $extra_options
    "; } // THIS LINE WAS IN THE ABOVE SECTION //
  • student(s)
  • // print link to return to cpanel function printRetLink($teacher_id, $pass, $message = "Click here to return to main menu") { echo "$message"; } function printRetDiv($teacher_id, $pass, $message="Click here to return to main menu") { echo "
    "; printRetLink($teacher_id, $pass, $message); echo "
    "; } // return assoc array teacherInfo("name", "email", "school_id", "school_name") function getTRegInfo($teacher_id) { if(!$teacher_id) return array(); $result = mysql_query("SELECT title, first, last, school_id, email, site_id FROM teacher WHERE teacher_id = '$teacher_id'"); $row = mysql_fetch_array($result); $teacher_name = $row[0] . " " . $row[1] . " " . $row[2]; $school_id = $row[3]; $result_school = mysql_query("SELECT name FROM school WHERE school_id = '$school_id'"); $school_name = mysql_fetch_assoc($result_school); $school_name = $school_name['name']; $teacher_email = $row[4]; $site_id = $row[5]; return array( "name" => $teacher_name, "email" => $teacher_email, "school_id" => $school_id, "school_name" => $school_name, "site_id" => $site_id ); } function getTInfoByEmail($email) { if(!$email) return false; $email = strtolower($email); $result = mysql_query("SELECT title, first, last, school_id, teacher_id, site_id FROM teacher WHERE email = '$email'"); $row = mysql_fetch_array($result); if(!$row[4]) return false; $teacher_name = $row[0] . " " . $row[1] . " " . $row[2]; $school_id = $row[3]; $result_school = mysql_query("SELECT name FROM school WHERE school_id = '$school_id'"); $school_name = mysql_fetch_assoc($result_school); $school_name = $school_name['name']; $teacher_id = $row[4]; $site_id = $row[5]; return array( "name" => $teacher_name, "teacher_id" => $teacher_id, "school_id" => $school_id, "school_name" => $school_name, "site_id" => $site_id ); } function showAllStudentsFromSchool($school_id) { $result1 = mysql_query("SELECT * FROM teacher WHERE school_id = $school_id"); echo ""; $numStudents = 0; $stu_emails = ""; $stu_emails2 = ""; while($r = mysql_fetch_assoc($result1)){ $teacher_id = $r['teacher_id']; $result = mysql_query("SELECT * FROM student WHERE teacher_id = $teacher_id ORDER BY last"); // $schoolName = getTRegInfo($teacher_id); // $schoolName = $schoolName['school_name']; while($row = mysql_fetch_assoc($result)) { $tinfo = getTRegInfo($row['teacher_id']); $grade = getGrade($row['grad_year']); $teacherName = $tinfo['name']; $teacherEmail = $tinfo['email']; $score = $row['score']; if(!$score) $score = ""; $stu_emails = $stu_emails.$row['email'].", \n"; $stu_emails2 = $stu_emails2.$row['email']."; \n"; echo ""; $numStudents++; // $stu_emails = $stu_emails . getAllStudentEmailsByTeacher($teacher_id); } } echo "
    NameID NumberGradeTeacherScoreUpdate Information
    {$row['first']} {$row['last']} {$row['student_id']} $grade $teacherName $score [update]
    Total: $numStudents students registered at your school.
    All student e-mail addresses:
    "; } function showAllStudentsFromTea($teacher_id) { global $pass; $result = mysql_query("SELECT * FROM student WHERE teacher_id = '$teacher_id' ORDER BY last"); // $schoolName = getTRegInfo($teacher_id); // $schoolName = $schoolName['school_name']; $numStudents = 0; $student_emails; echo ""; while($row = mysql_fetch_assoc($result)) { $tinfo = getTRegInfo($row['teacher_id']); $grade = getGrade($row['grad_year']); $teacherName = $tinfo['name']; $teacherEmail = $tinfo['email']; $score = $row['score']; if(!$score) $score=""; echo ""; $student_emails = $student_emails . $row['email']. ";"; $numStudents++; } echo "
    NameID NumberGradeTeacherScoreUpdate Information
    {$row['first']} {$row['last']} {$row['student_id']} $grade $teacherName $score [update]
    Total: $numStudents students registered under you.
    All student e-mail addresses:

                  Click here to e-mail all students listed
    "; } // check if student is already registered // returns FALSE if not, TRUE if it is function isDupe($ask) { global $dupReg; $query = sprintf("SELECT * FROM %s WHERE phone_num='%s' OR email='%s'", mysql_real_escape_string("student"), mysql_real_escape_string($ask['phone_num']), mysql_real_escape_string($ask['email'])); $result = mysql_query($query); while($stu = mysql_fetch_assoc($result)) { if((stripAll($ask['first']) == stripAll($stu['first'])) && (stripAll($ask['last']) == stripAll($stu['last'])) && (stripAll($ask['street']) == stripAll($stu['street'])) && (stripAll($ask['city']) == stripAll($stu['city'])) && ($ask['state'] == $stu['state']) && ($ask['zip'] == $stu['zip']) ){ if($dupReg){ echo "Duplicate registrations allowed. This is a duplicate.
    "; return FALSE;} return TRUE; } } return FALSE; } // given array of required student information, write it to database // check email and pass just to make sure function writeTStudent($studentInfo, $teacher_id, $pass) { global $allInfo, $contact; $teacherInfo = getTRegInfo($teacher_id); if(!teacher_pass($teacherInfo['email'], $pass)) { die("to complete writing info, please click here."); } if(isDupe($studentInfo)) { echo ""; return -1; } if($allInfo['sec_last']) { $secInfo['title'] = $allInfo['sec_title']; $secInfo['first'] = $allInfo['sec_first']; $secInfo['last'] = $allInfo['sec_last']; $secInfo['email'] = $allInfo['sec_email']; $secInfo['phone_num'] = $allInfo['sec_phone_num']; $secInfo['phone_ext'] = $allInfo['sec_phone_ext']; $secInfo['street'] = $allInfo['sec_addr_street']; $secInfo['city'] = $allInfo['sec_addr_city']; $secInfo['state'] = $allInfo['sec_addr_state']; $secInfo['zip'] = $allInfo['sec_addr_zip']; $secInfo['is_second'] = 1; $secInfo['is_hs'] = 0; $secInfo['school_id'] = $teacherInfo['school_id']; $secInfo['site_id'] = $teacherInfo['site_id']; $sec_id = writeTeacher($secInfo); $studentInfo['sec_id'] = $sec_id; } $studentInfo['referral'] = "teacher"; return writeStudent($studentInfo); } function showTStudent($student_id) { $studentInfo = getStudentInfo($student_id); $studentName = $studentInfo['first'] . " " . $studentInfo['last']; $studentEmail = $studentInfo['email']; echo ""; } function showStudentFields($teacher_id, $toPage=7, $buttonText="Register Student") { global $teacher_email, $teacher_id, $pass, $required_student; global $allInfo; include 'student_fields.php'; } function showSecondFields() { global $allInfo; include 'second_fields.php'; } function showTeacherFields($teacher_id, $toPage=5, $buttonText="Update Teacher Information") { global $teacher_email, $teacher_id, $pass, $required_teacher; global $allInfo, $contact; include 'teacher_fields.php'; } function editTStudent($student_id) { global $allInfo, $teacher_email, $teacher_id, $pass; if(!teacher_pass($teacher_email, $pass)) die("MySQL error: wrong identification number."); $studentInfo = getStudentInfo($student_id); $sec_id = $studentInfo['second_id']; $secInfo = getSecInfo($sec_id); foreach($studentInfo as $key => $info){ $allInfo[$key] = $info; } // $allInfo[''] = $secInfo['']; $allInfo['sec_title'] = $secInfo['title']; $allInfo['sec_first'] = $secInfo['first']; $allInfo['sec_last'] = $secInfo['last']; $allInfo['sec_email'] = $secInfo['email']; $allInfo['sec_phone_num'] = $secInfo['phone_num']; $allInfo['sec_phone_ext'] = $secInfo['phone_ext']; $allInfo['sec_addr_street'] = $secInfo['street']; $allInfo['sec_addr_city'] = $secInfo['city']; $allInfo['sec_addr_state'] = $secInfo['state']; $allInfo['sec_addr_zip'] = $secInfo['zip']; echo "
    "; showStudentFields($teacher_id, 4, "Update Info"); echo "
    "; showSecondFields(); } function editTTeacher() { global $allInfo, $teacher_email, $teacher_id, $pass; if(!teacher_pass($teacher_email, $pass)) die("MySQL error: wrong identification number."); $teacherInfo = getTeacherInfo($teacher_id); foreach($teacherInfo as $key => $info){ $allInfo[$key] = $allInfo[$key] ? $allInfo[$key] : $info; } echo " "; showTeacherFields($teacher_id, 5, "Update Info"); } function updateTeacher($teacherInfo) { $title = $teacherInfo['title']; $first = $teacherInfo['first']; $last = $teacherInfo['last']; $email = $teacherInfo['email']; $phone_num = $teacherInfo['phone_num']; $phone_ext = $teacherInfo['phone_ext']; $sec = $teacherInfo['is_second']; $site = $teacherInfo['site']; $school = $teacherInfo['school_id']; $teacher_id = $teacherInfo['teacher_id']; // $site_id = $query = "UPDATE teacher SET title = '$title' , first = '$first' , last = '$last' , email = '$email' , phone_num = '$phone_num' , phone_ext = '$phone_ext' , site_id = '$site', is_second = '$sec', school_id = '$school' WHERE teacher_id = '$teacher_id'"; $result = mysql_query($query); return $result; } function updateTStudent($studentInfo, $student_id, $teacher_id, $pass) { global $allInfo, $contact; $teacherInfo = getTRegInfo($teacher_id); if(!teacher_pass($teacherInfo['email'], $pass)) { die("to complete writing info, please click here."); } $oldInfo = getStudentInfo($student_id); $sec_id = $oldInfo['second_id']; if($allInfo['sec_last']) { $secInfo['title'] = $allInfo['sec_title']; $secInfo['first'] = $allInfo['sec_first']; $secInfo['last'] = $allInfo['sec_last']; $secInfo['email'] = $allInfo['sec_email']; $secInfo['phone_num'] = $allInfo['sec_phone_num']; $secInfo['phone_ext'] = $allInfo['sec_phone_ext']; $secInfo['street'] = $allInfo['sec_addr_street']; $secInfo['city'] = $allInfo['sec_addr_city']; $secInfo['state'] = $allInfo['sec_addr_state']; $secInfo['zip'] = $allInfo['sec_addr_zip']; $secInfo['is_second'] = 1; $secInfo['is_hs'] = 0; $secInfo['site_id'] = $teacherInfo['site_id']; if(!$sec_id) { $sec_id = writeTeacher($secInfo); $studentInfo['sec_id'] = $sec_id; if($sec_id > 0) $secUpdate = 1; } else { $secInfo['teacher_id'] = $sec_id; $secUpdate = updateTeacher($secInfo); } } else $secUpdate = 1; $first = $allInfo['first']; $last = $allInfo['last']; $email = $allInfo['email']; $street = $allInfo['street']; $city = $allInfo['city']; $state = $allInfo['state']; $zip = $allInfo['zip']; $phone_num = $allInfo['phone_num']; $gender = $allInfo['gender']; $grad_year = $allInfo['grad_year']; $part2007 = $allInfo['part2007']; $languages = $allInfo['languages']; $special = $allInfo['special']; $query = "UPDATE student SET first = '$first' , last = '$last' , email = '$email' , street = '$street' , city = '$city' , state = '$state' , zip = '$zip' , phone_num = '$phone_num' , gender = '$gender' , grad_year = '$grad_year' , part2007 = '$part2007' , languages = '$languages' , special = '$special' , second_id = '$sec_id' WHERE student_id = '$student_id'"; $result = mysql_query($query); return $result && $secUpdate; } // ========================== // = Current List functions = // ========================== function getAllSchools() { $result = mysql_query("SELECT * FROM school ORDER BY name"); while ($school = mysql_fetch_assoc($result)) { $teachers = getAllTeachers($school['school_id']); if($teachers) { $newSchool = new School($school); $newSchool->addTeachers($teachers); $schools[] = $newSchool; } } return $schools; } function getAllSchoolsBoth() { $result = mysql_query("SELECT * FROM school ORDER BY name"); while ($school = mysql_fetch_assoc($result)) { $teachers = getAllTeachers($school['school_id']); if($teachers) { $newSchool = new School($school); $newSchool->addTeachers($teachers); $schools[] = $newSchool; } } $result = mysql_query("SELECT * FROM site ORDER BY name"); while ($site = mysql_fetch_assoc($result)) { $teachers = getAllTeachers_site($site['site_id']); if($teachers) { $newSchool = new School($site); $newSchool->addTeachers($teachers); $schools[] = $newSchool; } } return $schools; } // get all teachers for a certain school_id and return an array function getAllTeachers($school_id) { $result = mysql_query("SELECT * FROM teacher WHERE school_id = '$school_id' ORDER BY last"); while($teacher = mysql_fetch_assoc($result)) { $students = getAllStudents($teacher['teacher_id']); if($students) { $newTeacher = new Teacher($teacher); $newTeacher->addStudents($students); $teachers[] = $newTeacher; ++$i; } } if($i <= 0) { return FALSE; } return $teachers; } function getAllTeachers_site($site_id) { if(!$site_id) return false; $result = mysql_query("SELECT * FROM teacher WHERE site_id = '$site_id' ORDER BY last"); while($teacher = mysql_fetch_assoc($result)) { $students = getAllStudents($teacher['teacher_id']); if($students) { $newTeacher = new Teacher($teacher); $newTeacher->addStudents($students); $teachers[] = $newTeacher; ++$i; } } if($i <= 0) { return FALSE; } return $teachers; } function getAllStudents($teacher_id) { if(!$teacher_id) return false; $result = mysql_query("SELECT * FROM student WHERE teacher_id = '$teacher_id' ORDER BY last"); while($student = mysql_fetch_assoc($result)) { $newStudent = new Student($student); $students[] = $newStudent; ++$i; } if($i <= 0) { return FALSE; } return $students; } function getAllChildren($second_id) { if(!$second_id) return false; $result = mysql_query("SELECT * FROM student WHERE second_id = '$second_id' ORDER BY last"); while($student = mysql_fetch_assoc($result)) { $newStudent = new Student($student); $students[] = $newStudent; ++$i; } if($i <= 0) { return FALSE; } return $students; } function getAllSites() { $result = mysql_query("SELECT * FROM site ORDER BY state"); while($site = mysql_fetch_assoc($result)) { $i=0; $site_id = $site['site_id']; $numTeachers = mysql_query("SELECT COUNT(*) FROM teacher WHERE site_id = '$site_id'"); $numStudents = mysql_query("SELECT COUNT(*) FROM student LEFT JOIN teacher ON student.teacher_id = teacher.teacher_id WHERE teacher.site_id = '$site_id'"); $numStudents = mysql_fetch_row($numStudents); $numTeachers = mysql_fetch_row($numTeachers); //echo "{$site['name']}: $numStudents
    "; $site['numStudents'] = $numStudents[0]; $site['numTeachers'] = $numTeachers[0]; $sites[] = $site; } unset($site); $site['site_id']=0; $site['name'] = "No Site Selected"; $numTeachers = mysql_query("SELECT COUNT(*) FROM teacher WHERE site_id = '0'"); $numStudents = mysql_query("SELECT COUNT(*) FROM student LEFT JOIN teacher ON student.teacher_id = teacher.teacher_id WHERE teacher.site_id = '0'"); $numStudents = mysql_fetch_row($numStudents); $numTeachers = mysql_fetch_row($numTeachers); //echo "{$site['name']}: $numStudents
    "; $site['numStudents'] = $numStudents[0]; $site['numTeachers'] = $numTeachers[0]; $sites[] = $site; unset($site); $site['site_id'] = 6; $site['name'] = "High School Site"; $numTeachers = mysql_query("SELECT COUNT(*) FROM teacher WHERE site_id = '6'"); $numStudents = mysql_query("SELECT COUNT(*) FROM student LEFT JOIN teacher ON student.teacher_id = teacher.teacher_id WHERE teacher.site_id = '6'"); $numStudents = mysql_fetch_row($numStudents); $numTeachers = mysql_fetch_row($numTeachers); //echo "{$site['name']}: $numStudents
    "; $site['numStudents'] = $numStudents[0]; $site['numTeachers'] = $numTeachers[0]; $sites[] = $site; usort($sites, 'numStudents_cmp'); $len = count($sites); for($i=0; $i<$len; $i++) { $sites[$i] = new Site($sites[$i]); } return $sites; } function numStudents_cmp($a, $b) { $adist = intval($a['numStudents']); $bdist = intval($b['numStudents']); if ($adist == $bdist) { return 0; } return ($adist < $bdist) ? 1 : -1; } function numStudentsAtSite($site_id) { $numStudents = mysql_query("SELECT COUNT(*) FROM student LEFT JOIN teacher ON student.teacher_id = teacher.teacher_id WHERE teacher.site_id = '$site_id'"); $numStudents = mysql_fetch_row($numStudents); return $numStudents[0]; } function numStudentsAtTeacher($teacher_id) { $numStudents = mysql_query("SELECT COUNT(*) FROM student LEFT JOIN teacher ON student.teacher_id = teacher.teacher_id WHERE teacher.teacher_id = '$teacher_id'"); $numStudents = mysql_fetch_row($numStudents); return $numStudents[0]; } function getStudentFields($student) { global $contact; $teacher = buildTeacher($student->teacher_id); $school = buildSchool($student->school_id); $site = buildSite($student->site_id); $part2007 = yesno($student->part2007); $string = " ".$student->student_id." ".$student->last_login." ".$teacher->email." ".$teacher->detailLink()." ".$site->detailLink()." ".$school->detailLink()." ".$student->detailLink()." ". $student->email ." ". $student->grade ." ". $student->address->city ." ". $student->address->state ." ". $student->address->zip ." ". $part2007 ." "; return $string; } function getTeacherFields($teacher) { $string = " ". getName($teacher) ." ". $teacher['email'] ." ". $teacher['phone_num'] . " " . $teacher['phone_ext'] ." "; return $string; } //formats an e-mail like First Last function premail($name, $email) { return "$name <$email>"; } function getAllTeacherEmails($site_id, $continue=', ') { $query = mysql_query("SELECT first, last, email FROM teacher WHERE site_id = '$site_id' AND is_second = '0'"); while($row = mysql_fetch_array($query)) { $emails .= formatEmail($row[2], $row[0] . ' ' . $row[1]) . $continue; } $cont_size = -strlen(strip_tags($continue)); if($cont_size) { $emails = substr($emails, 0, $cont_size); } return $emails; } function getAllStudentEmails($site_id, $continue=', ') { $query = mysql_query("SELECT student.first, student.last, student.email FROM NACLO.student LEFT JOIN NACLO.teacher ON student.teacher_id = teacher.teacher_id WHERE teacher.site_id = '$site_id'"); while($row = mysql_fetch_array($query)) { $emails .= formatEmail($row[2], $row[0] . ' ' . $row[1]) . "$continue"; } $cont_size = -strlen(strip_tags($continue)); if($cont_size) { $emails = substr($emails, 0, $cont_size); } return $emails; } function getAllStudentEmails2($site_id, $continue=', ') { $query = mysql_query("SELECT distinct(student.email) FROM NACLO.student LEFT JOIN NACLO.teacher ON (student.teacher_id = teacher.teacher_id) WHERE teacher.site_id = '$site_id'"); while($row = mysql_fetch_array($query)) { $emails .= $row[0] . $continue; // $emails .= formatEmail($row[2], $row[0] . ' ' . $row[1]) . "$continue"; } $cont_size = -strlen(strip_tags($continue)); if($cont_size) { $emails = substr($emails, 0, $cont_size); } return $emails; } function getAllStudentInfoBySite($site_id) { $query = mysql_query("SELECT student.first, student.last, student.student_id, student.email, concat(teacher.title, ' ', teacher.first, ' ', teacher.last) as teacher_name FROM NACLO.student LEFT JOIN NACLO.teacher ON (student.teacher_id = teacher.teacher_id) WHERE teacher.site_id = '$site_id' order by student.last ASC"); while($row = mysql_fetch_assoc($query)) { $students[] = new Student($row); } return $students; } function getAllStudentInfoByTeacher($teacher_id) { $query = mysql_query("SELECT student.first, student.last, student.student_id, student.email FROM NACLO.student LEFT JOIN NACLO.teacher ON (student.teacher_id = teacher.teacher_id) WHERE teacher.teacher_id = '$teacher_id' order by student.last ASC"); while($row = mysql_fetch_assoc($query)) { $students[] = new Student($row); } return $students; } function getAllStudentEmailsBySchool($school_id) { $query = mysql_query("SELECT student.first, student.last, student.email FROM NACLO.student LEFT JOIN NACLO.teacher ON student.teacher_id = teacher.teacher_id WHERE teacher.school_id = '$school_id'"); while($row = mysql_fetch_array($query)) { $emails .= formatEmail($row[2], $row[0] . ' ' . $row[1]); } $emails = substr($emails, 0, -2); return $emails; } function getAllStudentEmailsByTeacher($teacher_id, $continue=', ') { $query = mysql_query("SELECT distinct(student.email) FROM NACLO.student LEFT JOIN NACLO.teacher ON (student.teacher_id = teacher.teacher_id) WHERE teacher.teacher_id = '$teacher_id'"); while($row = mysql_fetch_array($query)) { $emails .= $row[0] . $continue; // $emails .= formatEmail($row[2], $row[0] . ' ' . $row[1]) . "$continue"; } $cont_size = -strlen(strip_tags($continue)); if($cont_size) { $emails = substr($emails, 0, $cont_size); } return $emails; } function contactIsAtSite($email, $my_site_id) { $query = mysql_query("Select site_id from contact where email = '$email'"); $site_id = mysql_fetch_row($query); $site_id = $site_id[0]; return $my_site_id == $site_id; } ?> NACLO 2014: Round 1 Score Retrieval

    NACLO 2014: Round 1 Score Retrieval

    Results will be available around March 1 or 2

    To retrieve your Round 1 scores you must have participated in the open round of the NACLO 2014, the email address you provided must be valid, and you must know your registration number. To receive a mailed report of your scores, please enter your registration number below.

    Student ID: