/** * Resets user password, requires UserUtility to be included * @param type $regno * @param type $newPassword */ function resetUserPassword($regno, $newPassword) { //Check password $link = UserUtility::getDefaultDBConnection(); $pwd = crypt($newPassword); $query = "update users set password='******' where regno='{$regno}'"; mysqli_query($link, $query); //Log error UserUtility::logMySQLError($link); }
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; }
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; }
/** * 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"); } }
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; }