protected static function loginPost() { $email = type::post('email', 'string'); $password = type::post('password', 'string'); $remember = type::post('remember', 'int'); if (is_null($email) || is_null($password) || $email == '' || $password == '') { echo message::info(lang::get('fill_out_both')); return; } $sql = new sql(); $sql->query('SELECT password, salt, id FROM ' . sql::table('user') . ' WHERE `email` = "' . $sql->escape($email) . '"'); if (!$sql->num()) { echo message::danger(sprintf(lang::get('email_not_found'), htmlspecialchars($email)), true); $shake = 1; return; } $sql->result(); if (!self::checkPassword($password, $sql->get('salt'), $sql->get('password'))) { echo message::danger(lang::get('wrong_pw')); $shake = 1; return; } self::loginSession(); self::$userID = $sql->get('id'); $_SESSION['login'] = $sql->get('id'); if ($remember) { setcookie("remember", $sql->get('id'), time() + 3600 * 24 * 7); } }
public static function getAll() { if (!count(self::$all)) { $sql = new sql(); $sql->query('SELECT name FROM ' . sql::table('addons') . ' WHERE `install` = 1 AND `active` = 1')->result(); while ($sql->isNext()) { self::$all[] = $sql->get('name'); $sql->next(); } } return self::$all; }
<?php /** * Created by PhpStorm. * User: Alex Sandiyarov * Date: 13.12.15 * Time: 12:17 */ $news = new News(); $a = $news->getAll(); var_dump($a); //$news->add($data); //$news->update($title2, $id); $a = new sql(); $a->get('*', 'news', 'ORDER BY date DESC'); print_r($a->packToArray()); print_r($a->get('*', 'news', 'WHERE id = 4')); $a->insert('news', 'id, title', '"34543435434534353453455", "sadsadas"'); $a->update('news', 'title = "KUKU"', '4');
public function getOne($id) { $sql = new sql(); return $sql->get('*', 'news', 'WHERE id = ' . $id); }
foreach ($perms as $key => $val) { foreach ($val as $var) { $rights[] = $key . '[' . $var . ']'; } } $sql = new sql(); $sql->setTable('user'); $sql->setWhere('id=' . $id); $admin = isset($_POST['admin']) ? 1 : 0; $sql->addPost('perms', implode('|', $rights)); $sql->addPost('firstname', type::post('firstname')); $sql->addPost('name', type::post('name')); $sql->addPost('email', type::post('email')); $sql->addPost('admin', $admin); $sql->addPost('username', type::post('username')); if (type::post('password') && type::post('password') != $sqlUser->get('password')) { $sql->addPost('password', userLogin::hash(type::post('password'), $sqlUser->get('salt'))); } $sql->update(); echo message::success(lang::get('user_edited')); } $sql = new sql(); $sql->result("SELECT * FROM " . sql::table('user') . " WHERE id = '" . $sql->escape($id) . "'"); $permTypes = ['server', 'games', 'user']; $perms = explode('|', $sql->get('perms')); $permsSplit = []; foreach ($perms as $value) { preg_match("~^(\\w+)\\[(\\w+)\\]\$~", $value, $matches); if (count($matches)) { $key = $matches[1]; if (!isset($permsSplit[$key])) {
public static function sortTable($table, $sort, $where = '', $select = ['id', 'sort']) { if ($where) { $where = ' WHERE ' . $where; } $update = new sql(); $update->setTable($table); $i = 1; $sql = new sql(); $sql->query('SELECT `' . $select[0] . '`, `' . $select[1] . '` FROM ' . self::table($table) . $where . ' ORDER BY `' . $select[1] . '` ASC')->result(); while ($sql->isNext()) { if ($sort == $i) { $i++; } $update->addPost($select[1], $i); $update->setWhere($select[0] . '=' . $sql->get($select[0])); $update->update(); $sql->next(); $i++; } }