Esempio n. 1
0
 /**
  * stops a timer
  */
 public static function stop($tid)
 {
     if (!($tid = VarUid::sanitize($tid, $err))) {
         return false;
     }
     $filter = "task_id='{$tid}' AND stop='0000-00-00 00:00:00'";
     $obj = new TimerModel();
     $obj->connectDb();
     if (!$obj->load($filter)) {
         return false;
     }
     $obj->set('stop', APP_SQL_NOW);
     $obj->set('spent', strtotime($obj->get('stop')) - strtotime($obj->get('start')));
     $obj->fields('stop,spent');
     return $obj->update($filter);
 }
Esempio n. 2
0
 /**
  * Is there a cookie for AutoLogin ??
  */
 public function checkAutoLogin($forReal = true)
 {
     if (empty($_COOKIE['auto_login'])) {
         return false;
     }
     $arrVal = explode(":", $_COOKIE['auto_login']);
     $id = VarUid::sanitize($arrVal[0]);
     $salt = VarStr::sanitize($arrVal[1]);
     if (!$id || !$salt) {
         return false;
     }
     if ($this->obj->load($this->dbUid(true) . "='" . $id . "' AND " . $this->dbField('salt', $salt) . " AND " . $this->dbField('auto_login', 1) . " AND " . $this->dbField('enabled', 1))) {
         if (!$forReal) {
             return true;
         }
         setCookie('auto_login', $this->obj->getUid() . ":" . $this->obj->get('salt'), time() + 3600 * 24 * 30);
         $this->activateLogin();
         return true;
     } else {
         return false;
     }
 }