$res = $dbo->delete(array('where' => 'userid = ' . $dbo->quote($userdata['userid']) . ' and token like ' . $dbo->quote(System_Auth::get_token())));
    System_Auth::clear_token();
}
// user not logged in but token is exist, try to force logout
if (!System_Auth::islogin() && System_Auth::get_token() != '') {
    try {
        include 'logout.php';
    } catch (Exception $e) {
    }
}
// validate username and password
Alt_Validation::instance()->rule(Alt_Validation::not_empty($username), 'Username harus diisi!')->rule(Alt_Validation::not_empty($password), 'Password harus diisi!')->check();
// check is exist within database
$user = new System_User();
$res = $user->get(array('where' => 'username = '******'User tidak ditemukan!');
}
// set userdata
$userdata = $res[0];
// checking if password correct
if (md5($password) != $userdata['password']) {
    throw new Alt_Exception('Password tidak cocok!');
}
unset($userdata['password']);
$token = System_Auth::generate_token($userdata);
System_Auth::save_token($token);
$session = new System_Session();
$session->insert(array('userid' => $userdata['userid'], 'token' => $token));
return $token;
<?php

defined('ALT_PATH') or exit('No direct script access allowed');
if (!System_Auth::islogin() && System_Auth::get_token() == '') {
    throw new Alt_Exception('Anda belum login atau sesi anda telah habis');
}
$userdata = System_Auth::get_user_data();
$dbo = new System_Session();
$res = $dbo->delete(array('where' => 'userid = ' . $dbo->quote($userdata['userid']) . ' and token like ' . $dbo->quote(System_Auth::get_token())));
System_Auth::clear_token();
return $res;
<?php

defined('ALT_PATH') or exit('No direct script access allowed');
return System_Auth::islogin();
Exemple #4
0
 /**
  * delete the data
  * @return int num of deleted data
  */
 public function delete($data, $returnsql = false)
 {
     if (isset($data[$this->pkey])) {
         $data['where'] = $this->pkey . " = " . $this->quote($data[$this->pkey]);
         unset($data[$this->pkey]);
     } else {
         if ($this->get_where($data) == ' where ' && !isset($data['where'])) {
             return -1;
         }
     }
     // add modified time and modified user if exist
     $fields = $this->get_fields(false);
     if ($fields['isdeleted'] !== null) {
         if ($fields['deletedtime'] !== null) {
             $data['deletedtime'] = $data['deletedtime'] != '' ? $data['deletedtime'] : time();
         }
         if ($fields['modifieduser'] !== null) {
             $userdata = System_Auth::get_user_data();
             $data['deleteduser'] = $data['deleteduser'] != '' ? $data['deleteduser'] : $userdata['username'];
         }
         if ($fields['isdeleted'] !== null) {
             $data['isdeleted'] = 1;
         }
         return $this->update($data, $returnsql);
     }
     // return sql
     $sql = "delete from " . $this->table_name . $this->get_where($data);
     if ($returnsql) {
         return $sql;
     }
     // execute
     $res = $this->query($sql);
     return $res;
 }