本文整理汇总了PHP中Settings::mysqlTimeDiff方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::mysqlTimeDiff方法的具体用法?PHP Settings::mysqlTimeDiff怎么用?PHP Settings::mysqlTimeDiff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings::mysqlTimeDiff方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createRecord
//.........这里部分代码省略.........
}
}
} elseif (strip_tags($this->info[$name]) != strip_tags($this->old_info[$name]) && !@in_array($name, $_REQUEST['grid_inputs']) || $grid_input_modified) {
$modified = true;
$changes .= '<b>' . $name . '</b> ' . $CFG->comments_set_to . ' ' . (is_array($value) ? print_r($value, true) : $value) . '<br/>';
}
$bypass = false;
$compare = false;
$filtered = false;
}
}
if ($register_changes) {
$changes .= '</div>';
}
if ($on_new_record_only && $this->record_created) {
$modified = true;
}
if ($this->info[$trigger_field] != $this->old_info[$trigger_field] || $modified) {
if ($this->info[$trigger_field] == $trigger_value || !$trigger_value && $trigger_field || $modified) {
if (!is_array($insert_array) && stristr($insert_array, 'array:')) {
$insert_array = str_ireplace('array:', '', $insert_array);
$ia1 = explode(',', $insert_array);
if (is_array($ia1)) {
foreach ($ia1 as $v) {
if (strstr($v, '=>')) {
$ia2 = explode('=>', $v);
$ia3[$ia2[0]] = $ia2[1];
$last_key = $ia2[0];
} else {
$ia3[$last_key] .= ',' . $v;
}
}
}
unset($insert_array);
$insert_array = $ia3;
}
if (is_array($insert_array)) {
foreach ($insert_array as $new_field => $old_field) {
if ($old_field == 'curdate') {
$insert_values[$new_field] = date('Y-m-d 00:00:00');
} elseif ($old_field == 'curtime') {
$insert_values[$new_field] = date('Y-m-d H:i:s', time() + Settings::mysqlTimeDiff() * 3600);
} elseif ($old_field == 'user_id') {
$insert_values[$new_field] = User::$info['id'];
} elseif ($old_field == 'record_id') {
$insert_values[$new_field] = $this->record_id;
} elseif (strstr($old_field, '(') && strstr($old_field, ')')) {
if ($this->record_created) {
$this->old_info['id'] = $this->record_id;
}
$formula = String::doFormulaReplacements($old_field, $this->old_info, 1);
$insert_values[$new_field] = eval("return ({$formula});");
} elseif ($old_field == 'current_url') {
$insert_values[$new_field] = $CFG->url;
} elseif (!is_array($old_field)) {
if (array_key_exists($old_field, $this->info)) {
$insert_values[$new_field] = $this->info[$old_field];
} else {
$insert_values[$new_field] = $old_field;
}
} else {
$insert_values[$new_field] = DB::getForeignValue(implode(',', $old_field), $this->info['id']);
}
}
if ($register_changes) {
$insert_values['comments'] = $changes;
}
if ($store_row && $table == 'comments') {
if ($this->edit_record && $table != $this->table) {
$row = DB::getRecord($table, $this->edit_record_field_id, 0, 1);
$insert_values['f_table_row'] = serialize($row);
} else {
$insert_values['f_table_row'] = serialize($this->info);
}
}
$CFG->ignore_request = $table;
$CFG->bypass_unserialize = true;
$this->edit_record_id_field = $this->edit_record_id_field ? $this->edit_record_id_field : $this->record_id;
if (!$this->edit_record) {
if ($if_not_exists) {
$insert_values1 = $insert_values;
if ($k = array_search($this->record_id, $insert_values1)) {
unset($insert_values1[$k]);
}
if (DB::recordExists($table, $insert_values1)) {
return false;
}
}
$this->create_record[] = array('table' => $table, 'insert_values' => $insert_values);
//echo 'Insert:';
//print_ar($insert_values);
} else {
$this->create_record[] = array('edit' => 1, 'table' => $table, 'insert_values' => $insert_values, 'id' => $this->edit_record_field_id);
//echo 'Update:';
//print_ar($insert_values);
}
}
}
}
}
示例2: parseVariables
public static function parseVariables($variables, $row, $record_id = 0, $url = false, $update_variable_values = false)
{
global $CFG;
$reserved_keywords = array('current_url', 'action', 'bypass', 'is_tab');
if (is_array($variables)) {
foreach ($variables as $k => $v) {
$is_formula = strstr($v, '(') && strstr($v, ')');
$k1 = $url ? "{$url}[{$k}]" : $k;
$v1 = $is_formula ? $v : str_replace('[', '', str_replace(']', '', $v));
if (strstr($v1, '(') && strstr($v1, ')')) {
$formula = String::doFormulaReplacements($v1, $row, 1);
$v1 = eval("return ({$formula});");
}
if (in_array($k, $reserved_keywords)) {
$variables1[$k] = $v;
} elseif ($k == 'record_id') {
$variables1[$k1] = $is_formula ? $v1 : $record_id;
} elseif ($k == 'id') {
$variables1[$k] = $is_formula ? $v1 : $record_id;
if ($update_variable_values) {
$variables1['record_id'] = $is_formula ? $v1 : $record_id;
}
} elseif ($v1 == 'id') {
$variables1[$k1] = $is_formula ? $v1 : $record_id;
} elseif ($v1 == 'curdate') {
$variables1[$k1] = date('Y-m-d 00:00:00');
} elseif ($v1 == 'curtime') {
$variables1[$k1] = date('Y-m-d H:i:s', time() + Settings::mysqlTimeDiff() * 3600);
} elseif ($k == 'user_id') {
$variables1[$k1] = User::$info['id'];
} elseif (strstr($v1, 'count')) {
$p = explode('(', $v1);
$v1 = str_replace(')', '', $p[1]);
$variables1[$k1] = DB::countRows($v1);
} elseif (strstr($v1, '.')) {
$parts = explode('.', $v1);
$sql = "SELECT {$parts[1]} FROM {$parts[0]} WHERE f_id = {$record_id}";
$result = db_query_array($sql);
if ($result) {
$m1 = $parts[1];
$variables1[$k1] = $result[0][$m1];
}
} elseif (strstr($v1, ',')) {
$variables1[$k1] = DB::getForeignValue(implode(',', $v1), $row);
} else {
self::replaceSystemVars($v1);
if (strstr($v1, '++')) {
$v1 = $row[str_replace('++', '', $v1)] + 1;
} elseif (strstr($v1, '--')) {
$v1 = $row[str_replace('--', '', $v1)] - 1;
} else {
$v1 = array_key_exists($v1, $row) ? $row[$v1] : $v;
}
$variables1[$k1] = $v1;
}
}
}
if ($record_id > 0 && $update_variable_values) {
$variables1['record_id'] = $record_id;
}
return $variables1;
}
示例3: show
private function show($comments)
{
global $CFG;
if ($comments) {
echo '<ul>';
foreach ($comments as $comment) {
$elapsed = time() + Settings::mysqlTimeDiff() * 3600 - strtotime($comment['date']);
if ($elapsed < 60) {
$time_ago = $CFG->comments_less_than_minute;
} elseif ($elapsed > 60 && $elapsed < 60 * 60) {
$minutes = floor($elapsed / 60);
$time_ago = str_ireplace('[field]', $minutes, $CFG->comments_minutes_ago);
} elseif ($elapsed > 60 * 60 && $elapsed < 60 * 60 * 24) {
$hours = floor($elapsed / 60 / 60);
$time_ago = str_ireplace('[field]', $hours, $CFG->comments_hours_ago);
} elseif ($elapsed > 60 * 60 * 24 && $elapsed < 60 * 60 * 24 * 30.4) {
$days = floor($elapsed / 60 / 60 / 24);
$time_ago = str_ireplace('[field]', $days, $CFG->comments_days_ago);
} else {
$months = floor($elapsed / 60 / 60 / 24 / 30.4);
$time_ago = str_ireplace('[field]', $months, $CFG->comments_months_ago);
}
if ($comment['user_id'] > 0) {
$user = DB::getRecord($this->user_table, $comment['user_id'], false, true);
$name = !empty($comment['website']) ? Link::url($comment['website'], $user['user']) : $user['user'];
} else {
$name = !empty($comment['website']) ? Link::url($comment['website'], $comment['name']) : $comment['name'];
}
$short = $this->short_version ? '_short' : '';
$icon = $comment['type'] ? eval('return $CFG->comment_type_' . $comment['type'] . ';') : $CFG->comment_type_1;
$action = $comment['type'] ? eval('return $CFG->comments_action_' . $comment['type'] . $short . ';') : $CFG->comments_wrote_label;
$action = String::doFormulaReplacements($action, unserialize($comment['f_table_row']), 1, 1);
echo '
<li id="comment_' . $comment['id'] . '" class="level_' . $comment['type'] . '">
<div class="c_head">';
if ($this->fields) {
foreach ($this->fields as $f_name => $field) {
$CFG->o_method_id = $field['method_id'];
$CFG->o_method_name = 'field';
$record = new Record($field['table'], $comment['record_id']);
echo '<div class="added_field">' . $record->field($field['name'], $field['caption'], $field['subtable'], $field['subtable_fields'], $field['link_url'], $field['concat_char'], true, $field['f_id_field'], $field['order_by'], $field['order_asc'], $comment['record_id'], $field['link_is_tab'], $field['limit_is_curdate'], false, $field['link_id_field']) . '</div>';
}
}
echo '
' . $icon . ' ' . $name . ' (' . $time_ago . ') ' . $action . '
</div>';
if (!$this->short_version) {
echo '
<div class="c_comment">
' . (strlen($comment['comments']) != strlen(strip_tags($comment['comments'])) ? $comment['comments'] : nl2br($comment['comments'])) . '
</div>';
}
echo '
' . ($comment['type'] <= 1 && !$this->short_version ? '<div class="c_reply"><a href="#" onclick="showReplyBox(' . $comment['id'] . ',' . $this->i . ');return false;">' . $CFG->comments_reply_label . '</a></div>' : '') . '
<div class="c_form"></div>
</li>';
if (is_array($comment['children'])) {
Comments::show($comment['children']);
}
}
echo '<div style="clear:both;height:0;"></div></ul>';
}
}
示例4: getTimeRemaining
function getTimeRemaining()
{
$diff = Settings::mysqlTimeDiff();
return strtotime($this->item_info['exp_date']) - time() + 3600 + $diff * 3600;
}