datetime() 공개 정적인 메소드

Returns a datetime string in sql datetime format (Y-m-d H:i:s) using the given timestamp or the current time if no timestamp (or null) is given.
public static datetime ( integer | null $timestamp = null ) : string
$timestamp integer | null
리턴 string
예제 #1
0
파일: form.php 프로젝트: DECAF/redaxo
 protected function save()
 {
     $nexttime = $this->getElement($this->mainFieldset, 'nexttime');
     $timestamp = rex_cronjob_manager_sql::calculateNextTime($this->intervalField->getValue());
     $nexttime->setValue($timestamp ? rex_sql::datetime($timestamp) : null);
     $return = parent::save();
     rex_cronjob_manager_sql::factory()->saveNextTime();
     return $return;
 }
예제 #2
0
파일: form.php 프로젝트: skerbis/redaxo
 protected function save()
 {
     if ($this->isEditMode()) {
         $nexttime = $this->getElement($this->mainFieldset, 'nexttime');
         if (strtotime($nexttime->getValue()) > 0) {
             $interval = $this->getElement($this->mainFieldset, 'interval');
             $nexttime->setValue(rex_sql::datetime(rex_cronjob_manager_sql::calculateNextTime($interval->getValue())));
         }
     }
     $return = parent::save();
     rex_cronjob_manager_sql::factory()->saveNextTime();
     return $return;
 }
예제 #3
0
 public function checkLogin()
 {
     $sql = rex_sql::factory();
     $userId = $this->getSessionVar('UID');
     $cookiename = 'rex_user_' . sha1(rex::getProperty('instname'));
     if ($cookiekey = rex_cookie($cookiename, 'string')) {
         if (!$userId) {
             $sql->setQuery('SELECT id FROM ' . rex::getTable('user') . ' WHERE cookiekey = ? LIMIT 1', [$cookiekey]);
             if ($sql->getRows() == 1) {
                 $this->setSessionVar('UID', $sql->getValue('id'));
                 setcookie($cookiename, $cookiekey, time() + 60 * 60 * 24 * 365);
             } else {
                 setcookie($cookiename, '', time() - 3600);
             }
         }
         $this->setSessionVar('STAMP', time());
     }
     $check = parent::checkLogin();
     if ($check) {
         // gelungenen versuch speichern | login_tries = 0
         if ($this->userLogin != '' || !$userId) {
             $this->regenerateSessionId();
             $params = [];
             $add = '';
             if ($this->stayLoggedIn || $cookiekey) {
                 $cookiekey = sha1($this->systemId . time() . $this->userLogin);
                 $add = 'cookiekey = ?, ';
                 $params[] = $cookiekey;
                 setcookie($cookiename, $cookiekey, time() + 60 * 60 * 24 * 365);
             }
             if (self::passwordNeedsRehash($this->user->getValue('password'))) {
                 $add .= 'password = ?, ';
                 $params[] = self::passwordHash($this->userPassword, true);
             }
             array_push($params, rex_sql::datetime(), session_id(), $this->userLogin);
             $sql->setQuery('UPDATE ' . $this->tableName . ' SET ' . $add . 'login_tries=0, lasttrydate=?, session_id=? WHERE login=? LIMIT 1', $params);
         }
         $this->user = new rex_user($this->user);
     } else {
         // fehlversuch speichern | login_tries++
         if ($this->userLogin != '') {
             $sql->setQuery('SELECT login_tries FROM ' . $this->tableName . ' WHERE login=? LIMIT 1', [$this->userLogin]);
             if ($sql->getRows() > 0) {
                 $login_tries = $sql->getValue('login_tries');
                 $sql->setQuery('UPDATE ' . $this->tableName . ' SET login_tries=login_tries+1,session_id="",cookiekey="",lasttrydate=? WHERE login=? LIMIT 1', [rex_sql::datetime(), $this->userLogin]);
                 if ($login_tries >= self::LOGIN_TRIES_1 - 1) {
                     $time = $login_tries < self::LOGIN_TRIES_2 ? self::RELOGIN_DELAY_1 : self::RELOGIN_DELAY_2;
                     $hours = floor($time / 3600);
                     $mins = floor(($time - $hours * 3600) / 60);
                     $secs = $time % 60;
                     $formatted = ($hours ? $hours . 'h ' : '') . ($hours || $mins ? $mins . 'min ' : '') . $secs . 's';
                     $this->message .= ' ' . rex_i18n::msg('login_wait', '<strong data-time="' . $time . '">' . $formatted . '</strong>');
                 }
             }
         }
     }
     if ($this->isLoggedOut() && $userId != '') {
         $sql->setQuery('UPDATE ' . $this->tableName . ' SET session_id="", cookiekey="" WHERE id=? LIMIT 1', [$userId]);
         setcookie($cookiename, '', time() - 3600);
     }
     return $check;
 }
예제 #4
0
 public function setNextTime($id, $interval, $resetExecutionStart = false)
 {
     $nexttime = self::calculateNextTime($interval);
     $add = $resetExecutionStart ? ', execution_start = 0' : '';
     try {
         $this->sql->setQuery('
             UPDATE  ' . REX_CRONJOB_TABLE . '
             SET     nexttime = ?' . $add . '
             WHERE   id = ?
         ', [rex_sql::datetime($nexttime), $id]);
         $success = true;
     } catch (rex_sql_exception $e) {
         $success = false;
     }
     $this->saveNextTime();
     return $success;
 }