/**
  * check user login
  * @input post data
  * @return mixed  [0] 1:success | 2:login failed | 3:spamer [max|try|time] 
  */
 public function Check()
 {
     $registry = TRegistry::GetInstance();
     $trylog = new TTryLog();
     $time = $registry->GetValue(ROOT_SYSTEM, 'login_ignore_time');
     // check login try
     $try = $trylog->Check(TRY_LOGIN, $time);
     // get max try ;
     $max_try = $registry->GetValue(ROOT_SYSTEM, 'login_max_try');
     // check is try more than max try
     if ($try <= $max_try) {
         // can login
         // log try
         $trylog->Log(TRY_LOGIN);
         // check input length
         if (strlen($_POST['manager_username']) < 3 || empty($_POST['manager_password'])) {
             // take access
             TMAC::TakeAccess();
             $ret[0] = 2;
             return $ret;
         }
         $sql = "SELECT * FROM %table% WHERE \n                manager_username = :username AND manager_password = :password ;";
         $result = $this->db->Select($sql, array('manager'), array('type' => 'ss', ":username" => $_POST['manager_username'], ":password" => Password($_POST['manager_password'])));
         //manager access control init
         TMAC::Init();
         if (count($result) == 1) {
             //login
             // update last login
             $this->db->Update('manager', array('type' => 'i', "manager_lastlogin" => time()), "manager_id = '{$result[0]['manager_id']}'");
             // make remenber
             isset($_POST['remenber']) ? $remenber = TRUE : ($remenber = FALSE);
             // give access
             TMAC::GiveAccess($result[0], $remenber);
             $ret[0] = 1;
             return $ret;
         } else {
             //not login
             // take access
             TMAC::TakeAccess();
             $ret[0] = 2;
             return $ret;
         }
     } else {
         // can't login
         $ret[0] = 3;
         $ret['max'] = $max_try;
         $ret['time'] = $time;
         // and show error
         return $ret;
     }
 }
 public function Logout()
 {
     TMAC::TakeAccess();
     Redirect(UR_MP . 'Access/Login');
 }