Esempio n. 1
0
 public function loadRelatedRow($table, $field = '')
 {
     if (!$field) {
         $field = $table . '_id';
     }
     return DBTable::get($table)->loadRow($this->get($field));
 }
Esempio n. 2
0
 public function delete($args)
 {
     $users_id = get($args, 'users_id');
     if ($users_id) {
         if ($user = DBTable::get('users')->loadRow($users_id)) {
             DBTable::deleteRow($user);
             return data::success($user->export());
         }
         return data::error('invalid user id');
     }
     return data::error('user id required');
 }
Esempio n. 3
0
 public function logout($args)
 {
     extract(extractable(array('users_id', 'key'), $args));
     $users_id = intval($users_id);
     if ($users_id) {
         if ($session = DBTable::get('session')->loadRowsWhere(array('key' => $key))) {
             $session = $session[0];
             $session->logged_in = 0;
             $session->save();
             return data::success($session->export());
         }
         return data::error('unable to locate session');
     }
     return data::error('user_id required');
 }
Esempio n. 4
0
 private function save($code)
 {
     $session_id = sessionCookie::$session['session_id'];
     $captcha = DBTable::get('captcha');
     $rows = $captcha->loadRowsWhere(array('session_id' => $session_id));
     if (!count($rows)) {
         $new = $captcha->loadNewRow();
         $new->session_id = $session_id;
     } else {
         $new = $rows[0];
     }
     $new->code = $code;
     $new->created = time();
     $new->save();
     $gc = loadBalance(10);
     if ($gc >= 8) {
         $halfhour = time() - 60 * 30;
         $captcha->deleteRowsWhere(array('created' => array('<', $halfhour)));
     }
 }