예제 #1
0
 public function register($email, $pass, $status, $uname, $acceptterms)
 {
     $site = new Site();
     if ($site->get_setting('registration_on') == 0) {
         return '-99';
     }
     // Currently not accepting registrations
     $emailext = explode("@", $email);
     $emailext = $emailext[1];
     $emailexte = explode(".", $emailext);
     $emailext = $emailexte[count($emailexte) - 2] . "." . $emailexte[count($emailexte) - 1];
     if ($emailext == "ac.uk") {
         $emailext = $emailexte[count($emailexte) - 3] . "." . $emailext;
     }
     //echo $emailext;
     $db = new Database();
     $db->connect();
     $validation = new validation();
     if (!$validation->Email($email)) {
         return '-10';
         // Not a valid email address
     }
     if (!$validation->FormalName($uname)) {
         return '-11';
         // Not a valid name
     }
     if (!$validation->Number($status) || $status < 1 && $status > 4) {
         return '-12';
         // Not a valid status
     }
     if ($acceptterms != 1) {
         return '-13';
     }
     // Did not accept terms
     if (strlen($pass) < 3) {
         return '-14';
     }
     // Password not valid
     $where = "`email`='" . $email . "'";
     $db->select('`user`', '`id`', $where);
     $result = $db->getresult();
     extract($result);
     if ($id > 0) {
         return '-4';
     }
     //Email already in database
     $id = NULL;
     $where = "`emailextension`='" . $emailext . "'";
     $db->select('`school`', '`id`, `name`', $where);
     $result = $db->getresult();
     //print_r($result);
     extract($result);
     //echo "$id - $name";
     if ($id < 1 && $emailext != 'harvardconnection.co') {
         return '-2';
         //School extension not valid
     }
     $schoolname = $name;
     $schoolid = $id;
     $id = NULL;
     $name = NULL;
     return $schoolid;
     //Check your email yo
 }