示例#1
0
 /**
  * getUsers()
  * Get information from all users or if an id is specified just get the information from that user
  *
  * @param(int) if none specified just get all the users
  * @param(slug) if slug given in we get the user by its slug
  * @return(array) or (false) return a array with all the users information in it
  */
 public function getUsers($idFromSlug = null, $sSlug = NULL)
 {
     # if there is a slug escape it
     if ($sSlug) {
         $sSlug = $this->mysqli->real_escape_string($sSlug);
     }
     # query
     $query = 'SELECT users.id, users.username, users.access, users.processed, users.active, users.deleted,users.last_active,users.delete_date,users.admin,
             users_info.firstname, users_info.lastname, users_info.email, users_info.lang,users_info.img,users_info.register_date,users_info.job_title,users_info.mobile,
               users_info.about,users_info.page_slug,users_social.facebook,users_social.instagram,users_social.twitter,users_social.website,users_social.linkedin, files.new_name, 
                 files_extensions.extension FROM users
                 LEFT JOIN users_info on users_info.users_id = users.id
                 LEFT JOIN users_social on users_social.users_id = users.id
                 LEFT JOIN files on files.id = users_info.img
                 LEFT JOIN files_extensions on files_extensions.id = files.extension ';
     # if id is set we want a specific user
     if ($idFromSlug) {
         $query .= 'WHERE users.id = ' . $idFromSlug;
     }
     # only use slug if slug is specified but no id is given in
     if ($sSlug && !$idFromSlug) {
         $query .= 'Where users_info.page_slug = "' . $sSlug . '"';
     }
     # execute the query
     $oResult = $this->mysqli->query($query);
     # fetch the result associative
     $aResult = parent::fetchResultAssoc($oResult);
     # return the result
     return $aResult;
 }
示例#2
0
 /**
  * count all the files a user have
  * if and id is givin in it will get them from a specific user otherwise it will get them from the current user
  * if we also want to count the deleted files we can assign true to also get them
  * @param(int)
  * @return(int)
  */
 public function countFiles($idFromSlug = null, $deleted = false)
 {
     $oUser = singleton::getInstance('User');
     # the query
     $query = 'SELECT count(*) as countFiles FROM 
               files LEFT JOIN users on users.id = files.users_id ';
     # if idFromSlug specified get them from the user id
     if ($idFromSlug) {
         $query .= ' WHERE users.id = ' . $idFromSlug;
     } else {
         $query .= ' WHERE users.id = ' . $oUser->getUserId();
     }
     # get deleted files?
     if ($deleted) {
         $query .= ' and files.deleted = 0 ';
     }
     echo $query;
     exit;
     # execute
     $oResult = $this->mysqli->query($query);
     # fetch it
     $result = parent::fetchResultAssoc($oResult);
     # and return
     return $result[0]['countFiles'];
 }
示例#3
0
 public function countSessions()
 {
     # the query
     $query = $this->mysqli->query('SELECT count(*) as amount FROM `sessions` WHERE `remote_ip` != \'localhost\'');
     # the result
     $result = parent::fetchResultAssoc($query);
     # return result
     return $result;
 }