Exemple #1
0
 /**
  * Checks the number of entries of given login name
  *
  * @param  string $login        Loginname
  * @param  array  $optionslData Optional data
  * @return integer
  */
 public function checkLogin($login, array $optionalData = null)
 {
     $check = sprintf("\n            SELECT\n                login\n            FROM\n                %sfaquserlogin\n            WHERE\n                login = '******'", SQLPREFIX, $this->db->escape_string($login));
     $check = $this->db->query($check);
     $error = $this->db->error();
     if (strlen($error) > 0) {
         $this->errors[] = $error;
         return 0;
     }
     return $this->db->num_rows($check);
 }
Exemple #2
0
 /**
  * Counting the views of a FAQ record
  *
  * @param  integer $id id
  * @return void
  */
 public function logViews($id)
 {
     $nVisits = 0;
     $query = sprintf("\n            SELECT\n                visits\n            FROM\n                %sfaqvisits\n            WHERE\n                id = %d\n            AND\n                lang = '%s'", SQLPREFIX, $id, $this->language);
     $result = $this->db->query($query);
     if ($this->db->num_rows($result)) {
         $row = $this->db->fetch_object($result);
         $nVisits = $row->visits;
     }
     if ($nVisits == 0) {
         $this->add($id);
     } else {
         $this->update($id);
     }
 }
Exemple #3
0
 /**
  * Loads the user-data from the database and returns an
  * associative array with the fields and values.
  *
  * @param  integer $user_id User ID
  * @return bool
  */
 public function load($user_id)
 {
     $user_id = (int) $user_id;
     if ($user_id <= 0 && $user_id != -1) {
         return false;
     }
     $this->user_id = $user_id;
     $select = sprintf("\n            SELECT\n                last_modified, \n                display_name, \n                email\n            FROM\n                %sfaquserdata\n            WHERE\n                user_id = %d", SQLPREFIX, $this->user_id);
     $res = $this->db->query($select);
     if ($this->db->num_rows($res) != 1) {
         return false;
     }
     $this->data = $this->db->fetch_assoc($res);
     return true;
 }
Exemple #4
0
 /**
  * Save the Captcha
  *
  * @return   boolean
  */
 private function saveCaptcha()
 {
     $select = sprintf("\n    \t   SELECT \n    \t       id \n    \t   FROM \n    \t       %sfaqcaptcha \n    \t   WHERE \n    \t       id = '%s'", SQLPREFIX, $this->code);
     $result = $this->db->query($select);
     if ($result) {
         $num = $this->db->num_rows($result);
         if ($num > 0) {
             return false;
         } else {
             $insert = sprintf("\n                    INSERT INTO \n                        %sfaqcaptcha \n                    (id, useragent, language, ip, captcha_time) \n                        VALUES \n                    ('%s', '%s', '%s', '%s', %d)", SQLPREFIX, $this->code, $this->userAgent, $this->language, $this->ip, $this->timestamp);
             $this->db->query($insert);
             return true;
         }
     }
     return false;
 }
Exemple #5
0
 /**
  * loads basic user information from the database selecting the user with
  * specified login.
  *
  * @param  string $login       Login name
  * @param  bool   $raise_error Raise error?
  * @return bool
  */
 public function getUserByLogin($login, $raise_error = true)
 {
     $select = sprintf("\n            SELECT\n                user_id,\n                login,\n                account_status\n            FROM\n                %sfaquser\n            WHERE\n                login = '******'", SQLPREFIX, $this->db->escape_string($login));
     $res = $this->db->query($select);
     if ($this->db->num_rows($res) !== 1) {
         if ($raise_error) {
             $this->errors[] = self::ERROR_USER_INCORRECT_LOGIN;
         }
         return false;
     }
     $user = $this->db->fetch_assoc($res);
     $this->user_id = (int) $user['user_id'];
     $this->login = (string) $user['login'];
     $this->status = (string) $user['account_status'];
     // get user-data
     if (!$this->userdata instanceof PMF_User_UserData) {
         $this->userdata = new PMF_User_UserData();
     }
     $this->userdata->load($this->getUserId());
     return true;
 }