当前位置: 首页>>代码示例>>PHP>>正文


PHP format::now方法代码示例

本文整理汇总了PHP中format::now方法的典型用法代码示例。如果您正苦于以下问题:PHP format::now方法的具体用法?PHP format::now怎么用?PHP format::now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在format的用法示例。


在下文中一共展示了format::now方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_index

 public function action_index()
 {
     // clear buffer
     helper_ob::clean_all();
     // validating
     do {
         $options = application::get('flag.numbers.backend.cron.base');
         // token
         if (!empty($options['token']) && request::input('token') != $options['token']) {
             break;
         }
         // ip
         if (!empty($options['ip']) && !in_array(request::ip(), $options['ip'])) {
             break;
         }
         // get date parts
         $date_parts = format::now('parts');
         print_r($date_parts);
         echo "GOOD\n";
     } while (0);
     // we need to validate token
     //$token = request::input('token');
     echo "OK\n";
     // exit
     exit;
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:26,代码来源:execute.php

示例2: next_run_date

 /**
  * Next run datetime
  *
  * @param mixed $datetime
  * @return string
  */
 public function next_run_date($datetime = null)
 {
     $result = null;
     if (empty($datetime)) {
         $datetime = format::now('unix');
     } else {
         if (!is_numeric($datetime)) {
             $datetime = strtotime($datetime);
         }
     }
     $parts = format::datetime_parts($datetime);
     for ($year = $parts['year']; $year <= self::$slot_stats[6]['max']; $year++) {
         // check if we are in range
         if (!(in_array('*', $this->parsed_expression['year']) || in_array($year, $this->parsed_expression['year']))) {
             continue;
         }
         for ($month = 1; $month <= 12; $month++) {
             // check if we are in range
             if (!(in_array('*', $this->parsed_expression['month']) || in_array($month, $this->parsed_expression['month']))) {
                 continue;
             }
             for ($day = 1; $day <= 31; $day++) {
                 // check if we are in range
                 if (!(in_array('*', $this->parsed_expression['day']) || in_array($day, $this->parsed_expression['day']))) {
                     continue;
                 }
                 // check weekday
                 $weekday = date('w', mktime(0, 0, 0, $month, $day, $year));
                 if (!(in_array('*', $this->parsed_expression['weekday']) || in_array($weekday, $this->parsed_expression['weekday']))) {
                     continue;
                 }
                 // loop through hours
                 for ($hour = 0; $hour <= 23; $hour++) {
                     // check if we are in range
                     if (!(in_array('*', $this->parsed_expression['hour']) || in_array($hour, $this->parsed_expression['hour']))) {
                         continue;
                     }
                     // loop though minutes
                     for ($minute = 0; $minute <= 59; $minute++) {
                         $date = mktime($hour, $minute, 0, $month, $day, $year);
                         if ($date < $datetime) {
                             continue;
                         } else {
                             // check if we are in range
                             if (!(in_array('*', $this->parsed_expression['minute']) || in_array($minute, $this->parsed_expression['minute']))) {
                                 continue;
                             }
                             // check the rest
                             $result = format::datetime($date);
                             goto exit1;
                         }
                     }
                 }
             }
         }
     }
     exit1:
     return $result;
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:65,代码来源:expression.php

示例3: set

 /**
  * see tinyurl::set();
  */
 public static function set($url, $options = [])
 {
     // insert new row into the table
     $object = new numbers_backend_misc_tinyurl_db_model_tinyurls();
     $result = $object->insert(['sm_tinyurl_inserted' => format::now('datetime'), 'sm_tinyurl_url' => $url . '', 'sm_tinyurl_expires' => $options['expires'] ?? null]);
     if ($result['success']) {
         $result['data']['id'] = $result['last_insert_id'];
         $result['data']['hash'] = base_convert($result['last_insert_id'] . '', 10, 36);
     } else {
         $result['data'] = [];
     }
     array_key_unset($result, ['success', 'error', 'data'], ['preserve' => true]);
     return $result;
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:17,代码来源:base.php

示例4: save

 public function save(&$form)
 {
     $model = factory::model($form->options['other']['model']);
     $save = [$model->column_prefix . 'important' => !empty($form->values['important']) ? 1 : 0, $model->column_prefix . 'comment_value' => $form->values['comment'] . '', $model->column_prefix . 'who_entity_id' => session::get('numbers.entity.em_entity_id'), $model->column_prefix . 'inserted' => format::now('timestamp')];
     foreach ($form->options['other']['map'] as $k => $v) {
         $save[$v] = $form->options['other']['pk'][$k];
     }
     $save_result = $model->save($save, ['ignore_not_set_fields' => true]);
     if ($save_result['success']) {
         $form->error('success', 'Comment has been added successfully!');
     } else {
         $form->error('danger', 'Could not add comment!');
     }
 }
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:14,代码来源:comment.php

示例5: process

 /**
  * Process the lock
  * @param string $id
  * @return boolean
  */
 public static function process($id)
 {
     $lock_data = lock::exists($id);
     if ($lock_data !== false) {
         $minutes = round(abs(strtotime(format::now()) - strtotime($lock_data)) / 60, 2);
         if ($minutes > 30) {
             lock::release($id);
             $lock_data = false;
         }
     }
     // we are ok to proceed
     if ($lock_data === false) {
         lock::create($id);
         return true;
     } else {
         return false;
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:23,代码来源:lock.php

示例6: get

 /**
  * Get information
  *
  * @param string $ip
  * @return array
  */
 public function get($ip)
 {
     $ip = $ip . '';
     // try to get IP information from cache
     $cache = new cache('db');
     $cache_id = 'misc_ip_ipinfo_' . $ip;
     $data = $cache->get($cache_id);
     if ($data !== false) {
         return ['success' => true, 'error' => [], 'data' => $data];
     }
     // if we need to query ipinfo.io
     $json = file_get_contents("http://ipinfo.io/{$ip}/json");
     $data = json_decode($json, true);
     if (isset($data['country'])) {
         $temp = explode(',', $data['loc']);
         $save = ['ip' => $ip, 'date' => format::now('date'), 'country' => $data['country'], 'region' => $data['region'], 'city' => $data['city'], 'postal' => $data['postal'], 'lat' => format::read_floatval($temp[0]), 'lon' => format::read_floatval($temp[1])];
         $cache->set($cache_id, $save, ['misc_ip_ipinfo'], 604800);
         return ['success' => true, 'error' => [], 'data' => $save];
     } else {
         return ['success' => false, 'error' => ['Could not decode IP address!'], 'data' => ['ip' => $ip]];
     }
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:28,代码来源:base.php

示例7: action_index

    public function action_index()
    {
        $input = request::input(null, true, true);
        $result = ['success' => false, 'error' => [], 'loggedin' => false, 'expired' => false, 'expires_in' => 0];
        if (!empty($input['token']) && !empty($input[session_name()])) {
            $crypt = new crypt();
            $token_data = $crypt->token_validate($input['token'], ['skip_time_validation' => true]);
            if (!($token_data === false || $token_data['id'] !== 'general')) {
                // quering database
                $model = new numbers_backend_session_db_model_sessions();
                $db = $model->db_object();
                $session_id = $db->escape($input[session_name()]);
                $expire = format::now('timestamp');
                $sql = <<<TTT
\t\t\t\t\tSELECT
\t\t\t\t\t\tsm_session_expires,
\t\t\t\t\t\tsm_session_user_id
\t\t\t\t\tFROM {$model->name}
\t\t\t\t\tWHERE 1=1
\t\t\t\t\t\tAND sm_session_id = '{$session_id}'
\t\t\t\t\t\tAND sm_session_expires >= '{$expire}'
TTT;
                $temp = $db->query($sql);
                // put values into result
                $result['expired'] = empty($temp['rows']);
                $result['loggedin'] = !empty($temp['rows'][0]['sm_session_user_id']);
                // calculate when session is about to expire
                if (!empty($temp['rows'])) {
                    $now = format::now('unix');
                    $expires = strtotime($temp['rows'][0]['sm_session_expires']);
                    $result['expires_in'] = $expires - $now;
                }
                $result['success'] = true;
            }
        }
        // rendering
        layout::render_as($result, 'application/json');
    }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:38,代码来源:check.php

示例8: merge


//.........这里部分代码省略.........
             // validate object_data
             $sql_options = [];
             foreach ($options['options_model'] as $k => $v) {
                 // we skip inactive model validations
                 if ($v['options_model'] == 'object_data_model_inactive') {
                     continue;
                 }
                 // process models
                 $temp = explode('::', $v['options_model']);
                 $model = factory::model($temp[0], true);
                 if (empty($temp[1])) {
                     $temp[1] = 'options';
                 }
                 if ($model->initiator_class == 'object_data' || $model->initiator_class == 'object_table' && !in_array($temp[1], ['options', 'options_active'])) {
                     $temp_options = array_keys(object_data_common::process_options($v['options_model'], null, $v['options_params'], $v['existing_values']));
                     // difference between arrays
                     $diff = array_diff($v['current_values'], $temp_options);
                     if (!empty($diff)) {
                         $result['options_model'][$k] = 1;
                     }
                 } else {
                     if ($model->initiator_class == 'object_table' && in_array($temp[1], ['options', 'options_active'])) {
                         // last element in the pk is a field
                         $pk = $model->pk;
                         $last = array_pop($pk);
                         // handling inactive
                         $options_active = [];
                         if ($temp[1] == 'options_active') {
                             $options_active = $model->options_active ? $model->options_active : [$model->column_prefix . 'inactive' => 0];
                         }
                         $sql_options[$k] = ['model' => $temp[0], 'field' => $last, 'params' => $v['options_params'], 'values' => $v['current_values'], 'existing_values' => $v['existing_values'], 'options_active' => $options_active];
                     }
                 }
             }
             // validating options
             if (!empty($sql_options)) {
                 $sql_model = new object_table_validator();
                 $sql_result = $sql_model->validate_options_multiple($sql_options);
                 if (!empty($sql_result['discrepancies'])) {
                     foreach ($sql_result['discrepancies'] as $k => $v) {
                         $result['options_model'][$k] = 1;
                     }
                 }
             }
             // we roll back if we have errors
             if (!empty($result['options_model'])) {
                 break;
             }
         }
         // comapare main row
         $this->timestamp = format::now('timestamp');
         $temp = $this->compare_one_row($data, $original, $this->data, ['flag_delete_row' => $options['flag_delete_row'] ?? false, 'flag_main_record' => true]);
         // if we goe an error
         if (!empty($temp['error'])) {
             $result['error'] = $temp['error'];
             break;
         }
         // we display warning if form has not been changed
         if (empty($temp['data']['total'])) {
             $result['warning'][] = object_content_messages::no_changes;
             break;
         }
         // insert history
         if (!empty($temp['data']['history'])) {
             foreach ($temp['data']['history'] as $k => $v) {
                 $temp2 = $this->primary_model->db_object->insert($k, $v);
                 if (!$temp2['success']) {
                     $result['error'] = $temp2['error'];
                     goto error;
                 }
             }
         }
         // audit
         if (!empty($temp['data']['audit'])) {
             // we need to put relation into pk
             if (!empty($this->primary_model->relation['field'])) {
                 $temp['data']['audit']['pk'][$this->primary_model->relation['field']] = $temp['new_serials'][$this->primary_model->relation['field']] ?? $data[$this->primary_model->relation['field']] ?? $original[$this->primary_model->relation['field']];
             }
             // merge
             $temp2 = factory::model($this->primary_model->audit_model, true)->merge($temp['data']['audit'], ['changes' => $temp['data']['total']]);
             if (!$temp2['success']) {
                 $result['error'] = $temp2['error'];
                 break;
             }
         }
         // if we got here we can commit
         $result['success'] = true;
         $result['deleted'] = $temp['data']['deleted'];
         $result['inserted'] = $temp['data']['inserted'];
         $result['updated'] = $temp['data']['updated'];
         $result['new_serials'] = $temp['new_serials'];
         // commit transaction
         $this->primary_model->db_object->commit();
         return $result;
     } while (0);
     // we roll back on error
     error:
     $this->primary_model->db_object->rollback();
     return $result;
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:101,代码来源:collection.php

示例9: gc

 /**
  * Garbage collector
  *
  * @param int $mode - 1 - old, 2 - all
  * @param array $tags
  * @return boolean
  */
 public function gc($mode = 1, $tags = [])
 {
     if ($mode == 2) {
         $sql = 'DELETE FROM ' . $this->model_cache->name;
     } else {
         if ($mode == 1) {
             $sql = 'DELETE FROM ' . $this->model_cache->name . ' WHERE sm_cache_expire < \'' . format::now('timestamp') . '\'';
             if (!empty($tags)) {
                 $tags2 = array_fix($tags);
                 $temp = [];
                 foreach ($tags2 as $v) {
                     $temp[] = "sm_cache_tags LIKE '% {$v} %'";
                 }
                 $sql .= ' OR (' . implode(' OR ', $temp) . ')';
             }
         }
     }
     $db = new db($this->model_cache->db_link);
     $result = $db->query($sql);
     return $result['success'];
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:28,代码来源:base.php

示例10: render

 /**
  * Render
  * 
  * @param string $type
  * @return string
  */
 public function render($type)
 {
     $result = '';
     $session = new session();
     // main switch
     switch ($type) {
         case 'pdf':
             // document properties
             $this->header['pdf']['orientation'] = isset($this->header['pdf']['orientation']) ? $this->header['pdf']['orientation'] : 'P';
             $this->header['pdf']['unit'] = 'mm';
             $this->header['pdf']['format'] = isset($this->header['pdf']['format']) ? $this->header['pdf']['format'] : 'LETTER';
             $this->header['pdf']['encoding'] = isset($this->header['pdf']['encoding']) ? $this->header['pdf']['encoding'] : 'UTF-8';
             $this->header['pdf']['font'] = isset($this->header['pdf']['font']) ? $this->header['pdf']['font'] : array('family' => 'helvetica', 'style' => '', 'size' => 8);
             //include 'tcpdf/tcpdf.php';
             // create new PDF document
             $pdf = new TCPDF($this->header['pdf']['orientation'], $this->header['pdf']['unit'], $this->header['pdf']['format'], true, $this->header['pdf']['encoding'], false);
             // set margins
             $pdf->SetMargins(0, 0, 0);
             $pdf->setPrintHeader(false);
             // disable auto break
             $pdf->SetAutoPageBreak(false, 0);
             // set default font subsetting mode
             $pdf->setFontSubsetting(true);
             // set color for background
             $pdf->SetFillColor(255, 255, 255);
             // set font
             $pdf->SetFont($this->header['pdf']['font']['family'], $this->header['pdf']['font']['style'], $this->header['pdf']['font']['size']);
             // stats
             $page_counter = 1;
             $page_y = 0;
             $flag_new_page = true;
             $flag_filter = true;
             $flag_first_row = true;
             $columns = array();
             $all_columns = array();
             // gethering all columns
             foreach ($this->data as $k => $v) {
                 if ($v['t'] == 'columns') {
                     $all_columns[] = $v;
                 }
             }
             // looping through the data
             foreach ($this->data as $k => $v) {
                 if ($v['t'] == 'columns') {
                     continue;
                 }
                 if ($flag_new_page) {
                     // add new page
                     $pdf->AddPage($this->header['pdf']['orientation'], '', true);
                     // drawing header
                     $pdf->MultiCell(40, 5, format::datetime(format::now()), 0, 'L', 1, 0, 5, 5, true, 0, false, true, 10, 'T');
                     // company + book name
                     $pw = $pdf->getPageWidth();
                     $pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
                     // todo: fix here
                     $pdf->MultiCell($pw - 90, 5, $session->company_name . ': ' . $session->book_name, 0, 'C', 1, 0, 40, 5, true, 0, false, true, 10, 'T');
                     // page counter
                     $pdf->SetFont($this->header['pdf']['font']['family'], '', $this->header['pdf']['font']['size']);
                     $pdf->MultiCell(40, 5, 'Page ' . $page_counter, 0, 'R', 1, 0, $pw - 45, 5, true, 0, false, true, 10, 'T');
                     // report name
                     $pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
                     $report_name = $this->header['name'] . ' (' . implode('-', application::get(array('mvc', 'controllers'))) . ')';
                     $pdf->MultiCell($pw - 10, 5, $report_name, 0, 'L', 1, 0, 5, 10, true, 0, false, true, 10, 'T');
                     if (isset($this->header['description'])) {
                         $pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
                         $pdf->MultiCell(205, 5, $this->header['description'], 0, 'L', 1, 0, 5, 15, true, 0, false, true, 10, 'T');
                         $page_y = 25;
                     } else {
                         $page_y = 20;
                     }
                     // if we need to add a filter
                     if ($flag_filter) {
                         if (isset($this->header['filter'])) {
                             foreach ($this->header['filter'] as $k2 => $v2) {
                                 $pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
                                 $pdf->MultiCell(50, 5, $k2 . ':', 0, 'L', 1, 0, 5, $page_y, true, 0, false, true, 10, 'T');
                                 $pdf->SetFont($this->header['pdf']['font']['family'], '', $this->header['pdf']['font']['size']);
                                 $number_of_cells = $pdf->MultiCell($pdf->getPageWidth() - 60, 5, $v2, 0, 'L', 1, 0, 55, $page_y, true, 0, false, true, 10, 'T');
                                 if ($number_of_cells > 1) {
                                     $page_y += 5 * ($number_of_cells - 1);
                                 }
                                 $page_y += 5;
                             }
                         }
                         $flag_filter = false;
                         // adding one line space
                         $page_y += 5;
                     }
                     // page counter
                     $page_counter++;
                     $flag_new_page = false;
                 }
                 // rendering rows
                 if ($flag_first_row) {
//.........这里部分代码省略.........
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:101,代码来源:base.php

示例11: process_default_value

 /**
  * Process default value
  *
  * @param string $key
  * @param mixed $default
  * @param array $neighbouring_values
  * @return mixed
  */
 private function process_default_value($key, $default, $value, &$neighbouring_values, $set_neightbouring_values = true, $changed_field = [], $options = [])
 {
     if (strpos($default, 'dependent::') !== false) {
         // nothing
     } else {
         if (strpos($default, 'master_object::') !== false) {
             $field = explode('::', str_replace(['master_object::', 'static::'], '', $default));
             $value = $this->master_object->{$field[0]}->{$field[1]}->{$field[2]};
         } else {
             if (strpos($default, 'parent::') !== false) {
                 $field = str_replace(['parent::', 'static::'], '', $default);
                 $value = $this->values[$field] ?? null;
             } else {
                 if ($default === 'now()') {
                     $default = format::now('timestamp');
                 }
                 $value = $default;
             }
         }
     }
     // handling override_field_value method
     if (!empty($this->wrapper_methods['process_default_value']['main'])) {
         // fix changed field
         if (empty($changed_field)) {
             $changed_field = [];
         }
         $changed_field['parent'] = $changed_field['parent'] ?? null;
         $changed_field['detail'] = $changed_field['detail'] ?? null;
         $changed_field['subdetail'] = $changed_field['subdetail'] ?? null;
         // call override method
         $model = $this->wrapper_methods['process_default_value']['main'][0];
         $model->{$this->wrapper_methods['process_default_value']['main'][1]}($this, $key, $default, $value, $neighbouring_values, $changed_field, $options);
     }
     // if we need to set neightbouring values
     if ($set_neightbouring_values) {
         $neighbouring_values[$key] = $value;
     }
     return $value;
 }
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:47,代码来源:base.php

示例12: process_who_columns

 /**
  * Process who columns
  *
  * @param mixed $types
  * @param array $row
  */
 public function process_who_columns($types, &$row, $timestamp = null)
 {
     if ($types === 'all') {
         $types = array_keys($this->who);
     }
     if (!is_array($types)) {
         $types = [$types];
     }
     if (empty($timestamp)) {
         $timestamp = format::now('timestamp');
     }
     foreach ($types as $type) {
         if (!empty($this->who[$type])) {
             // timestamp
             $row[$this->column_prefix . $type . '_timestamp'] = $timestamp;
             // entity #
             $row[$this->column_prefix . $type . '_entity_id'] = entity::id();
         } else {
             if ($type == 'optimistic_lock') {
                 if ($this->optimistic_lock) {
                     $row[$this->optimistic_lock_column] = $timestamp;
                 }
             }
         }
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:32,代码来源:table.php

示例13: gc

    /**
     * Garbage collector
     *
     * @param int $life
     * @return boolean
     */
    public function gc($life)
    {
        // step 1: we need to move expired sessions to logins table
        $db = new db($this->model_seessions->db_link);
        $expire = format::now('timestamp');
        // generating sqls
        $sql_move = <<<TTT
\t\t\tINSERT INTO sm_logins (
\t\t\t\tsm_login_id,
\t\t\t\tsm_login_started,
\t\t\t\tsm_login_last_requested,
\t\t\t\tsm_login_pages_count,
\t\t\t\tsm_login_user_ip,
\t\t\t\tsm_login_user_id
\t\t\t)
\t\t\tSELECT
\t\t\t\tnextval('sm_logins_sm_login_id_seq') sm_login_id,
\t\t\t\ts.sm_session_started sm_login_started,
\t\t\t\ts.sm_session_last_requested sm_login_last_requested,
\t\t\t\ts.sm_session_pages_count sm_login_pages_count,
\t\t\t\ts.sm_session_user_ip sm_login_user_ip,
\t\t\t\ts.sm_session_user_id sm_login_user_id
\t\t\tFROM sm_sessions s
\t\t\tWHERE 1=1
\t\t\t\tAND s.sm_session_expires < '{$expire}'
TTT;
        // session cleaning sql
        $sql_delete = <<<TTT
\t\t\tDELETE FROM sm_sessions
\t\t\tWHERE 1=1
\t\t\t\tAND sm_session_expires < '{$expire}'
TTT;
        // making changes to database
        $db->begin();
        $result = $db->query($sql_move);
        if (!$result['success']) {
            $db->rollback();
            return false;
        }
        $result = $db->query($sql_delete);
        if (!$result['success']) {
            $db->rollback();
            return false;
        }
        $db->commit();
        return true;
    }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:53,代码来源:base.php


注:本文中的format::now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。