Ejemplo n.º 1
0
 function __construct($id)
 {
     $sql = new sql();
     $sql->result("SELECT * FROM " . sql::table('server') . " WHERE id = '" . $id . "'");
     $this->sql = $sql;
     $this->id = $this->sql->get('id');
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 public function num($query = false)
 {
     if (!$query) {
         return $this->query ? $this->query->num_rows : 0;
     }
     $sql = new sql();
     $sql->result($query);
     return $sql->num();
 }
Ejemplo n.º 4
0
</a>
        <button type="submit" name="sendNew"><?php 
    echo lang::get('add');
    ?>
</button>
        
        </form>
        
    </div>
</div>

<?php 
} elseif ($action == 'edit' && $id) {
    if (isset($_POST['send'])) {
        $sqlUser = new sql();
        $sqlUser->result("SELECT * FROM " . sql::table('user') . " WHERE id = '" . $sqlUser->escape($id) . "'");
        $perms = json_decode(type::post('rights'));
        $rights = [];
        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'));