예제 #1
0
 function Collections()
 {
     $array = array();
     $query = "select * from library where on_shelf = 1 order by title ASC";
     $link = UserUtility::getDefaultDBConnection();
     $result = mysqli_query($link, $query);
     if ($result) {
         while ($row = mysqli_fetch_array($result)) {
             array_push($array, $row);
         }
     } else {
         //Log error
         UserUtility::logMySQLError($link);
     }
     $this->books = $array;
 }
예제 #2
0
function isClassRep($regno)
{
    $query = "select * from admins where username = '******'";
    $link = UserUtility::getDefaultDBConnection();
    $result = mysqli_query($link, $query);
    if ($result) {
        return mysqli_num_rows($result) > 0;
    } else {
        return false;
    }
}
예제 #3
0
 /**
  * Verifies and changes User's password (This is supported on php version >= 5.5.0)
  * @param type $oldPassword
  * @param type $newPassword1
  * @param type $newPassword2
  * @return type
  * @throws Exception
  */
 public function changePassword($oldPassword, $newPassword1, $newPassword2)
 {
     if ($this->verifyPassword($oldPassword, $this->getUserPassword())) {
         //Check password
         $this->validatePassword($newPassword1);
         $ok = strcmp($newPassword1, $newPassword2) === 0;
         if ($ok) {
             $link = UserUtility::getDefaultDBConnection();
             $pwd = crypt($newPassword1);
             $query = "update users set password='******' where regno='" . $this->getUserID() . "'";
             mysqli_query($link, $query);
             //Log error
             UserUtility::logMySQLError($link);
             //Reload
             $this->userInfo = $this->getUserData();
             $ok = $this->setUserCookies($this->userInfo['regno'], $this->userInfo['password']);
             return $ok;
         } else {
             throw new Exception("Passwords do not match");
         }
     } else {
         throw new Exception("Wrong password");
     }
 }
예제 #4
0
 public function plusOneHit($id)
 {
     $query = "update news set hits = hits + 1 where id = '{$id}'";
     $link = UserUtility::getDefaultDBConnection();
     $result = mysqli_query($link, $query);
     //Log error
     UserUtility::logMySQLError($link);
     return $result;
 }
예제 #5
0
 function storeFeedBack()
 {
     $link = UserUtility::getDefaultDBConnection();
     $query = "insert INTO feedbacks(ip,message,img,browser,page,is_mobile_browser) VALUES('{$this->ip}','{$this->message}','{$this->img}','{$this->browser}','{$this->url}','{$this->isBrowserMobile}')";
     $result = mysqli_query($link, $query);
     if ($result) {
         return 1;
     } else {
         return 0;
     }
 }
예제 #6
0
 public static function getExecutives($session = "")
 {
     $executives = array();
     $query = "select e.id, u.regno, u.first_name, u.last_name, u.other_names, u.department, u.pic_url, e.post, e.session " . "from users u join executives e " . "on (u.regno = e.user_id) ";
     if (!empty($session)) {
         $query .= "where e.session = '{$session}' ";
     }
     $query .= "order by session desc";
     $link = UserUtility::getDefaultDBConnection();
     $result = mysqli_query($link, $query);
     if ($result) {
         while ($row = mysqli_fetch_array($result)) {
             $executives[] = $row;
         }
     }
     //Log error
     UserUtility::logMySQLError($link);
     return $executives;
 }