本文整理汇总了PHP中phpbb\user::get_timestamp_from_format方法的典型用法代码示例。如果您正苦于以下问题:PHP user::get_timestamp_from_format方法的具体用法?PHP user::get_timestamp_from_format怎么用?PHP user::get_timestamp_from_format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\user
的用法示例。
在下文中一共展示了user::get_timestamp_from_format方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Runs this cron task.
*
* @return null
*/
public function run()
{
$sql = 'UPDATE ' . RATING_TABLE . ' SET
`top_hits_before` = `top_hits`,
`top_hosts_before` = `top_hosts`,
`top_in_before` = `top_in`,
`top_out_before` = `top_out`,
`top_hits` = 0,
`top_hosts` = 0,
`top_in` = 0,
`top_out` = 0
WHERE `top_id` BETWEEN 1 AND 100000
AND top_hosts > 1';
$this->db->sql_query($sql);
$this->db->sql_query('TRUNCATE TABLE ' . RATING_CLICK_TABLE);
$this->db->sql_query('TRUNCATE TABLE ' . RATING_HITS_TABLE);
$this->db->sql_query('TRUNCATE TABLE ' . RATING_ONLINE_TABLE);
$this->db->sql_query('OPTIMIZE TABLE ' . RATING_TABLE);
$this->db->sql_query('OPTIMIZE TABLE ' . RATING_CLICK_TABLE);
$this->db->sql_query('OPTIMIZE TABLE ' . RATING_HITS_TABLE);
$this->db->sql_query('OPTIMIZE TABLE ' . RATING_ONLINE_TABLE);
//$this->config->set('rating_platforms_active', 0);
$timestamp = time();
$timezone = new \DateTimeZone($this->config['board_timezone']);
$time = $this->user->get_timestamp_from_format('Y-m-d H:i:s', date('Y', $timestamp) . '-' . date('m', $timestamp) . '-' . date('d', $timestamp) . ' 00:00:00', $timezone);
$this->config->set('top_rating_last_gc', $time);
}
示例2: prune
/**
* Deletes the users from the list, whose visit is to old.
*/
public function prune()
{
$timestamp = time();
if ($this->config['wwh_version']) {
/* OLD function
self::$prune_timestamp = gmmktime(0, 0, 0, gmdate('m', $timestamp), gmdate('d', $timestamp), gmdate('Y', $timestamp));
self::$prune_timestamp -= ($this->config['board_timezone'] * 3600);
self::$prune_timestamp -= ($this->config['board_dst'] * 3600);*/
// Correct Time Zone. https://www.phpbb.com/community/viewtopic.php?f=456&t=2297986&start=30#p14022491
$timezone = new \DateTimeZone($this->config['board_timezone']);
self::$prune_timestamp = $this->user->get_timestamp_from_format('Y-m-d H:i:s', date('Y', $timestamp) . '-' . date('m', $timestamp) . '-' . date('d', $timestamp) . ' 00:00:00', $timezone);
self::$prune_timestamp = self::$prune_timestamp < $timestamp - 86400 ? self::$prune_timestamp + 86400 : (self::$prune_timestamp > $timestamp ? self::$prune_timestamp - 86400 : self::$prune_timestamp);
} else {
self::$prune_timestamp = $timestamp - (3600 * $this->config['wwh_del_time_h'] + 60 * $this->config['wwh_del_time_m'] + $this->config['wwh_del_time_s']);
}
if (!isset($this->config['wwh_last_clean']) || $this->config['wwh_last_clean'] != self::$prune_timestamp || !$this->config['wwh_version']) {
$this->db->sql_return_on_error(true);
$sql = 'DELETE FROM ' . WWH_TABLE . '
WHERE wwh_lastpage <= ' . self::$prune_timestamp;
$result = $this->db->sql_query($sql);
$this->db->sql_return_on_error(false);
if ((bool) $result === false) {
// database does not exist yet...
return false;
}
if ($this->config['wwh_version']) {
$this->config->set('wwh_last_clean', self::$prune_timestamp);
}
}
// Purging was not needed or done succesfully...
return true;
}
示例3: process_add_date
/**
* Process adding dates
* @param \phpbb\event\data $event
* @param bool $is_member_or_owner
*/
protected function process_add_date($event, $is_member_or_owner)
{
$add_dates = $this->request->variable('add_date', '', true);
if (empty($add_dates)) {
return array();
}
if (!$is_member_or_owner) {
return array($this->user->lang('NOT_AUTH_HOOKUP'));
}
$hookup_errors = array();
$add_dates = array_map("trim", explode("\n", $add_dates));
//replace german date formats
$add_dates = preg_replace('#(\\d{1,2})\\. ?(\\d{1,2})\\. ?(\\d{2})[,:]?[,: ]#', '20$3-$2-$1 ', $add_dates);
$add_dates = preg_replace('#(\\d{1,2})\\. ?(\\d{1,2})\\. ?(\\d{4})[,:]?[,: ]#', '$3-$2-$1 ', $add_dates);
$date_added = false;
foreach ($add_dates as $date) {
$text_match = preg_match('#\\#(.*)#', $date, $text);
//strtotime uses the local (server) timezone, so parse manually and use gmmktime to ignore any timezone
if (!preg_match('#(\\d{4})-(\\d{1,2})-(\\d{1,2}) (\\d{1,2}):(\\d{2})#', $date) && !$text_match) {
$hookup_errors[] = "{$date}: {$this->user->lang['INVALID_DATE']}";
} else {
$hookup_continue = true;
if ($text_match) {
$text = trim($text[1]);
$date_time = '0';
} else {
$text = null;
$date_time = $this->user->get_timestamp_from_format('Y-m-d H:i', $date);
if ($date_time < time()) {
$hookup_continue = false;
$hookup_errors[] = "{$date}: {$this->user->lang['CANNOT_ADD_PAST']}";
}
}
if ($hookup_continue) {
//check for duplicate
if (!$this->hookup->add_date($date_time, $text)) {
$hookup_errors[] = sprintf($this->user->lang['DATE_ALREADY_ADDED'], $this->user->format_date($date_time, $text));
} else {
$date_added = true;
}
}
}
}
if ($date_added) {
// Notification
$notify_data = array('user_id' => $this->user->data['user_id'], 'topic_title' => $event['topic_data']['topic_title'], 'topic_id' => $event['topic_id'], 'forum_id' => $event['forum_id']);
$this->notification_manager->update_notifications('gn36.hookup.notification.type.date_added', $notify_data);
}
return $hookup_errors;
}
示例4: process_config_change
/**
* Process config change of survey
*
* @return array errors
*/
protected function process_config_change()
{
if (!check_form_key($this->form_key_name)) {
return array($this->user->lang('FORM_INVALID'));
}
$new_settings = array('caption' => '', 'show_order' => 0, 'reverse_order' => 0, 'allow_change_answer' => 0, 'allow_multiple_answer' => 0, 'visibility' => 0, 'stop_time' => '', 'default_hide' => 0);
if ($this->survey->is_moderator()) {
$new_settings['topic_poster_right'] = 0;
}
foreach ($new_settings as $setting => $default) {
$new_settings[$setting] = $this->request->variable('survey_setting_' . $setting, $default, true);
}
if ($new_settings['caption'] == '') {
return array($this->user->lang('SURVEY_INVALID_CAPTION'));
}
if (!in_array($new_settings['show_order'], survey::$SHOW_ORDER_TYPES)) {
return array($this->user->lang('SURVEY_INVALID_SHOW_ORDER_TYPE'));
}
$new_settings['reverse_order'] = $new_settings['reverse_order'] ? 1 : 0;
$new_settings['allow_change_answer'] = $new_settings['allow_change_answer'] ? 1 : 0;
$new_settings['allow_multiple_answer'] = $new_settings['allow_multiple_answer'] ? 1 : 0;
$new_settings['default_hide'] = $new_settings['default_hide'] ? 1 : 0;
if (!in_array($new_settings['visibility'], survey::$VISIBILITY_TYPES)) {
return array($this->user->lang('SURVEY_INVALID_VISIBILITY_TYPE'));
}
if ($new_settings['stop_time'] != '') {
$orig_input = $new_settings['stop_time'];
$new_settings['stop_time'] = $this->user->get_timestamp_from_format('Y-m-d H:i', $new_settings['stop_time']);
if ($new_settings['stop_time'] === false || $new_settings['stop_time'] + 60 < $this->survey->fixed_time() && $new_settings['stop_time'] != $this->survey->settings['stop_time']) {
return array($this->user->lang('SURVEY_INVALID_STOPDATE', $orig_input));
}
} else {
$new_settings['stop_time'] = null;
}
if ($this->survey->is_moderator()) {
if (!in_array($new_settings['topic_poster_right'], survey::$TOPIC_POSTER_RIGHT_TYPES)) {
return array($this->user->lang('SURVEY_INVALID_TOPIC_POSTER_RIGHT_TYPE'));
}
}
$this->survey->change_config($new_settings);
return array();
}
示例5: process_add_date
/**
* Process adding dates
* @param \phpbb\event\data $event
* @param bool $is_member_or_owner
*/
protected function process_add_date($event, $is_member_or_owner)
{
$add_dates = $this->request->variable('add_date', '', true);
if (empty($add_dates)) {
return array();
}
if (!$is_member_or_owner) {
return array($this->user->lang('NOT_AUTH_HOOKUP'));
}
$hookup_errors = array();
$add_dates = array_map("trim", explode("\n", $add_dates));
//replace german date formats
$add_dates = preg_replace('#(\\d{1,2})\\. ?(\\d{1,2})\\. ?(\\d{2})[,:]?[,: ]#', '20$3-$2-$1 ', $add_dates);
$add_dates = preg_replace('#(\\d{1,2})\\. ?(\\d{1,2})\\. ?(\\d{4})[,:]?[,: ]#', '$3-$2-$1 ', $add_dates);
$date_added = false;
foreach ($add_dates as $date) {
//strtotime uses the local (server) timezone, so parse manually and use gmmktime to ignore any timezone
if (!preg_match('#(\\d{4})-(\\d{1,2})-(\\d{1,2}) (\\d{1,2}):(\\d{2})#', $date, $m)) {
$hookup_errors[] = "{$date}: {$this->user->lang['INVALID_DATE']}";
} else {
$date_time = $this->user->get_timestamp_from_format('Y-m-d H:i', $date);
if ($date_time < time()) {
$hookup_errors[] = "{$date}: {$this->user->lang['CANNOT_ADD_PAST']}";
} else {
//check for duplicate
if (!$this->hookup->add_date($date_time)) {
$hookup_errors[] = sprintf($this->user->lang['DATE_ALREADY_ADDED'], $this->user->format_date($date_time));
} else {
$date_added = true;
}
}
}
}
if ($date_added) {
//notify members about new dates
if ($this->messenger == null) {
include_once $this->phpbb_root_path . 'includes/functions_messenger.' . $this->phpEx;
$this->messenger = new \messenger();
}
$messenger = $this->messenger;
$notify_users = array();
$notified_userids = array();
// Fetch users to be notified:
foreach ($this->hookup->hookup_users as $user_id => $user) {
if ($user['notify_status'] == 0) {
$notify_users[$user_id] = $user;
}
}
if (!empty($notify_users)) {
$sql = 'SELECT u.user_id, u.username, u.user_lang, u.user_email, u.user_jabber, u.user_notify_type
FROM ' . USERS_TABLE . ' u
WHERE ' . $this->db->sql_in_set('u.user_id', array_keys($notify_users));
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) {
// TODO: Messenger ersetzen durch notification?
// https://www.phpbb.com/community/viewtopic.php?f=461&t=2259916#p13718356
$messenger->template('@gn36_hookup/hookup_dates_added', $row['user_lang']);
$messenger->to($row['user_email'], $row['username']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('USERNAME' => $row['username'], 'TOPIC_TITLE' => $event['topic_data']['topic_title'], 'U_TOPIC' => generate_board_url() . "/viewtopic.{$this->phpEx}?f={$event['forum_id']}&t={$event['topic_id']}"));
$messenger->send($row['user_notify_type']);
$notified_userids[] = $row['user_id'];
}
$this->db->sql_freeresult($result);
$messenger->save_queue();
//set notify status
foreach ($notified_userids as $user_id) {
$this->hookup->hookup_users[$user_id]['notify_status'] = 1;
}
}
}
return $hookup_errors;
}