row() static public method

Returns a single row from a table
static public row ( string $table, mixed $select = '*', mixed $where = null, string $order = null ) : mixed
$table string The table name
$select mixed Either an array of fields or a MySQL string of fields
$where mixed Either a key/value array as AND connected where clause or a simple MySQL where clause string
$order string Order clause without the order keyword. ie: "added desc"
return mixed
Exemplo n.º 1
0
 public function execute()
 {
     if (Session::get_state() != Session::ST_LIFE) {
         self::set_client_command('refresh', array('url' => 'self'));
         self::set_result(FALSE);
         return;
     }
     $additionally = Buffer::get(Identification_strategy::USER_TYPE) == User::T_ALL ? '' : 'AND `type` = "' . Buffer::get(Identification_strategy::USER_TYPE) . '"';
     $pass_hash_lib = Loader::get_library('pass_hash');
     $captcha_lib = Loader::get_library('captcha');
     $login = db::escape_string($this->login);
     $row = db::row(self::Q_GET_USER_BY_NAME, array('%login' => $login, '%additionally' => $additionally));
     $this->remember = (bool) $this->remember;
     if (empty($row)) {
         Security::set_ip_violation();
         throw new Command_exception(NULL, 'Введённый логин - не существует!');
     }
     if (!$captcha_lib->check($this->captcha)) {
         Security::set_ip_violation();
         throw new Command_exception(NULL, 'Введён неправильный проверочный код!');
     }
     if (!$pass_hash_lib->check_password($row['password'], $this->password)) {
         Security::set_ip_violation();
         throw new Command_exception(NULL, 'Введён неправильный пароль!');
     }
     //SELECT DATA_FREE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='db_test' AND TABLE_NAME = 'log_error'
     Session::set_user($row['id'], $this->remember);
     $user = Loader::get_user();
     $secret_key = $user->get_module('secret_key')->regenerate_secret_key();
     self::set_client_command('set_secret_key', array('secretKey' => $secret_key));
     self::set_client_command('refresh', array('url' => 'self'));
 }
Exemplo n.º 2
0
 public function row()
 {
     $escape = !empty($this->query['escape']);
     $query = $this->__build_a_query();
     $this->query = array();
     return db::row(self::Q_GET_BY_ATTR, $query, $escape);
 }
Exemplo n.º 3
0
 public static function analysis()
 {
     self::$_lifetime = config('session', 'lifetime');
     self::$_short_lifetime = config('session', 'short_lifetime');
     self::$_cache_sid = NULL;
     $session_id = NULL;
     //Клиенские куки пустые?
     if (empty($_COOKIE) or !isset($_COOKIE[self::SESSION_KEY])) {
         self::$_session_state = self::ST_NOT_SET;
         return FALSE;
     }
     //Данные в клиенских куках повреждены?
     $session_client = Format::converter($_COOKIE[self::SESSION_KEY], config('session', 'web_format'), TRUE);
     if (empty($session_client) or empty($session_client[self::COOKIE_ID])) {
         self::$_session_state = self::ST_INCORRECT;
         return FALSE;
     }
     $session_id = substr($session_client[self::COOKIE_ID], 0, 32);
     $session_server = db::row(self::Q_GET_SID, array('%sid' => $session_id), TRUE);
     //сессия есть в базе данных?
     if (empty($session_server)) {
         self::$_session_state = self::ST_INCORRECT;
         setcookie(self::SESSION_KEY, '', get_time() - 31500000);
         return FALSE;
     }
     $session_server['user_data'] = Format::converter($session_server['user_data'], config('settings', 'db_format'), TRUE);
     self::$_session_options = $session_server;
     self::$_session_client = $session_client;
     //Проверяем ip сессии и агент пользователя
     if (config(URL_AP, 'access', 'zone') != Z_PUBLIC and ($session_server['ip_address'] != ip2long(get_ip()) or $session_server['user_agent'] != trim(substr($_SERVER['HTTP_USER_AGENT'], 0, 120)))) {
         self::$_session_state = self::ST_INCORRECT;
         self::destroy($session_id);
         return FALSE;
     }
     //Проверяем время жизни сессии
     if (strtotime($session_server['life_time']) < get_time()) {
         self::$_session_state = self::ST_OUTDATED;
         self::destroy($session_id);
         return FALSE;
     }
     //Все проверки прошли успешно, сессия рабочая
     db::simple_query(self::Q_UPDATE_ACT, array('%sid' => $session_id, '%last_activity' => get_time()));
     self::$_cache_sid = $session_id;
     self::$_session_state = self::ST_LIFE;
     return TRUE;
 }
Exemplo n.º 4
0
 public function testUpdate()
 {
     db::update('users', array('email' => '*****@*****.**'), array('username' => 'john'));
     $this->assertEquals('*****@*****.**', db::row('users', '*', array('username' => 'john'))->email());
 }
Exemplo n.º 5
0
 public function reset($uid = NULL)
 {
     if ($uid === NULL) {
         $uid = Session::get_uid();
     }
     if ($uid) {
         $row = db::row(self::Q_GET_USER, array('%uid' => $uid));
         //если пользователь есть в базе, то загружаем его
         if (!empty($row)) {
             foreach ($row as $field => $value) {
                 $this->_set_field($field, $value);
             }
             return;
         }
     }
     //если попали сюда, значит пользователь - посетитель
     $this->_type = self::T_VISITOR;
     $this->_id = 0;
     $this->_group_list = array();
     $this->_secret_key = '';
 }
Exemplo n.º 6
0
 public static function join($fields = array('*'), $join = array(), $where = array(), $single = false, $sort = array(), $order = "DESC", $offset = 0, $limit = 0)
 {
     if ($single) {
         return parent::row(self::join_str($fields, $join, $where, $sort, $order, $offset, $limit));
     } else {
         return parent::rows(self::join_str($fields, $join, $where, $sort, $order, $offset, $limit));
     }
 }
Exemplo n.º 7
0
//define('USER','root');
//define('PASS','admin');
//define('DBNAME','2015_etc');
define('HOST', 'localhost');
define('USER', 'root');
define('PASS', '');
define('DBNAME', 'admin_masterapk');
include "inc/db.php";
include "inc/lib.php";
include "inc/simple_html_dom.php";
include "inc/function_string.php";
include "inc/resize-class.php";
$lib = new lib();
$db = new db();
$sql = "SELECT ID, file, post_name FROM wp_posts as p, wp_downloads as d  WHERE p.ID = d.post_id AND is_update = 0 ORDER BY ID DESC";
$item_row = $db->row($sql);
$link = $item_row->file;
$itemdatas = _curl($link);
$itemhtml = str_get_html($itemdatas);
$title = $item_row->post_name;
$root_year = ROOT . '../wp-content/uploads/' . date("Y") . '/';
if (!is_dir($root_year)) {
    mkdir($root_year, 777);
}
$root_month = ROOT . '../wp-content/uploads/' . date("Y") . '/' . date("m") . '/';
$dir_root = date("Y") . '/' . date("m") . '/';
if (!is_dir($root_month)) {
    mkdir($root_month, 777);
}
$find_list_img = $itemhtml->find("img[class=screenshot]");
if (count($find_list_img) > 3) {