public function login($u = NULL, $p = NULL) { $this->Connect(); // 1. valid // TODO: read view try { $r = $this->_u_rd($u); } catch (Exception $e) { throw new c2Ex("Invalid user!" . (C2_SYS_ERR ? "\n" . $e->getMessage() : "")); } // 3. login tries try { $this->_u_cltr($r); } catch (Exception $e) { throw new c2Ex("Login tries exceeded!" . (C2_SYS_ERR ? "\n" . $e->getMessage() : "")); } // 2. online if (c2Str::tof($r['o'])) { // online, within grace if ($this->_u_cgt($r)) { throw new c2Ex("Online!"); } } // 2. login try { $this->_u_login($u, $p); } catch (Exception $e) { $this->_u_iltr($u); throw new c2Ex("Invalid password!" . (C2_SYS_ERR ? "\n" . $e->getMessage() : "")); } return $this->save('u', $u); }
public static function req($id = NULL, $def = NULL, $c = true, $s = true, $l = C2_REQ_LENGTH) { $t = "_" . C2_REQ_TYPE; global ${$t}; $v = (!isset(${$t}[$id]) or ${$t}[$id] == '') ? $def : ${$t}[$id]; if ($c) { unset(${$t}[$id]); } if ($s && !empty($v)) { $v = c2Str::trunc(c2Str::alnum($v), $l); } return $v; }
public function ProcSelect($p = NULL, $a = NULL, $f = NULL, $l = C2_PDB_LIMIT, $o = 0) { if (empty($p)) { throw new c2Ex(__METHOD__); } $p = __k_str($p, C2_PDB_LENGTH); $q = 'SELECT ' . c2Str::a2f($f) . ' FROM ' . $p; $q .= '(' . c2Str::a2f($a, '', true) . ')'; return $this->Select($q, $l, $o); }