protected function get_year(array $now) { $start = $this->user->create_datetime()->setDate($now['year'], 1, 1)->setTime(0, 0, 0)->getTimestamp(); $leap_year = gmdate('L', $start); $num_days = $leap_year ? 366 : 365; return array('start' => $start, 'stop' => $start + 86400 * $num_days - 1, 'date' => $this->user->format_date($start, 'Y', true)); }
public function get_bookmarks($ext_mode = '', $forums = array()) { define('POSTS_BOOKMARKS_TABLE', $this->table_prefix . 'posts_bookmarks'); $start = $this->request->variable('start', 0); $sql = 'SELECT COUNT(post_id) as posts_count FROM ' . POSTS_BOOKMARKS_TABLE . ' WHERE user_id = ' . $this->user->data['user_id']; $result = $this->db->sql_query($sql); $posts_count = (int) $this->db->sql_fetchfield('posts_count'); $this->db->sql_freeresult($result); $sql_where = $sql_fields = ''; if ($ext_mode != 'find') { $sql_where = 'LEFT JOIN ' . USERS_TABLE . ' u ON (p.poster_id = u.user_id)'; $sql_fields = ', p.post_time, u.user_id, u.username, u.user_colour'; } $pagination_url = append_sid("{$this->phpbb_root_path}postbookmark", "mode=find"); $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $posts_count, $this->config['topics_per_page'], $start); $sql = 'SELECT b.post_id AS b_post_id, b.user_id, b.bookmark_time, b.bookmark_desc, p.post_id, p.forum_id, p.topic_id, p.poster_id, p.post_subject, t.topic_title ' . $sql_fields . ' FROM ' . POSTS_BOOKMARKS_TABLE . ' b LEFT JOIN ' . POSTS_TABLE . ' p ON( b.post_id = p.post_id) LEFT JOIN ' . TOPICS_TABLE . ' t ON( t.topic_id = p.topic_id) ' . $sql_where . ' WHERE b.user_id = ' . $this->user->data['user_id'] . ' ORDER BY b.bookmark_time ASC'; $result = $this->db->sql_query_limit($sql, $this->config['topics_per_page'], $start); while ($row = $this->db->sql_fetchrow($result)) { $topic_author = $sql_where ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : ''; $post_time = $sql_where ? $this->user->format_date($row['post_time']) : ''; // Send vars to template $this->template->assign_block_vars('postrow', array('POST_ID' => $row['b_post_id'], 'POST_TIME' => $post_time, 'BOOKMARK_TIME' => $this->user->format_date($row['bookmark_time']), 'BOOKMARK_DESC' => $row['bookmark_desc'], 'TOPIC_AUTHOR' => $topic_author, 'POST_TITLE' => $row['post_subject'] ? $row['post_subject'] : $row['topic_title'], 'U_VIEW_POST' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "p=" . $row['post_id'] . "#p" . $row['post_id'] . ""), 'S_DELETED_TOPIC' => !$row['topic_id'] ? true : false, 'S_DELETED_POST' => !$row['post_id'] ? true : false, 'U_POST_BOOKMARK' => '[url=' . generate_board_url() . '/viewtopic.' . $this->php_ext . '?p=' . $row['post_id'] . '#p' . $row['post_id'] . ']' . ($row['post_subject'] ? $row['post_subject'] : $row['topic_title']) . '[/url]')); } $this->db->sql_freeresult($result); $this->template->assign_vars(array('TOTAL_BOOKMARKS' => $this->user->lang('TOTAL_BOOKMARKS', (int) $posts_count), 'PAGE_NUMBER' => $this->pagination->on_page($posts_count, $this->config['topics_per_page'], $start))); }
public function modify_memberlist($event) { $poster_data = $event['data']; $b = $event['template_data']; $b['JOINED'] = $this->user->format_date($poster_data['user_regdate'], $this->date_format); $event['template_data'] = $b; }
/** * This method is called to show the UCP page. * You can assign template variables to the template, or do anything else here. * * @param string $table * @param string $where Extra where clause. Please make sure to use AND as first. */ protected function show_ucp_complete($table, $where = '') { $sql = 'SELECT * FROM ' . $this->db->sql_escape($table) . ' WHERE user_id = ' . (int) $this->user->data['user_id'] . ' ' . $where . ' ORDER BY registration_id ASC'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('keys', array('CLASS' => $this->get_name(), 'ID' => $row['registration_id'], 'REGISTERED' => $this->user->format_date($row['registered']), 'LAST_USED' => $row['last_used'] ? $this->user->format_date($row['last_used']) : false, 'TYPE' => $this->user->lang($this->get_translatable_name()))); } $this->db->sql_freeresult($result); }
/** * Modify the joined date format in memberlist * * @param object $event The event object * @return null * @access public */ public function modify_profile($event) { $data = $event['data']; $template_data = $event['template_data']; // Are we changing profile or memberlist? if (strlen($template_data['U_NOTES']) > 0) { $template_data['JOINED'] = $this->user->format_date($data['user_regdate'], $this->config['joined_dateformat_profile']); } else { $template_data['JOINED'] = $this->user->format_date($data['user_regdate'], $this->config['joined_dateformat_memberlist']); } $event->offsetSet('template_data', $template_data); }
/** * {@inheritdoc} */ public function get_template_side($module_id) { $sql = 'SELECT user_id, username, user_regdate, user_colour FROM ' . USERS_TABLE . ' WHERE user_type <> ' . USER_IGNORE . ' AND user_inactive_time = 0 ORDER BY user_regdate DESC'; $result = $this->db->sql_query_limit($sql, $this->config['board3_max_last_member_' . $module_id], 0, 600); while (($row = $this->db->sql_fetchrow($result)) && $row['username']) { $this->template->assign_block_vars('latest_members', array('USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'JOINED' => $this->user->format_date($row['user_regdate'], $format = 'd M'))); } $this->db->sql_freeresult($result); return 'latest_members_side.html'; }
/** * Display stats on index page * * @param object $event The event object * @return null * @access public */ public function display_24_hour_stats($event) { // if the user is a bot if ($this->user->data['is_bot']) { return; } $this->user->add_lang_ext('rmcgirr83/activity24hours', 'common'); // obtain posts/topics/new users activity $activity = $this->obtain_activity_data(); // obtain user activity data $active_users = $this->obtain_active_user_data(); // Obtain guests data $total_guests_online_24 = $this->obtain_guest_count_24(); $user_count = 0; foreach ((array) $active_users as $row) { if (!$row['session_viewonline'] && !empty($row['session_time']) || !$row['user_allow_viewonline']) { if ($this->auth->acl_get('u_viewonline') || $row['user_id'] === $this->user->data['user_id']) { $row['username'] = '******' . $row['username'] . '</em>'; } else { continue; } } if ($row['user_lastvisit'] < $this->interval && $row['session_time'] < $this->interval) { continue; } $max_last_visit = max($row['user_lastvisit'], $row['session_time']); $hover_info = ' title="' . $this->user->format_date($max_last_visit) . '"'; ++$user_count; $this->template->assign_block_vars('lastvisit', array('USERNAME_FULL' => '<span' . $hover_info . '>' . get_username_string($row['user_type'] == USER_IGNORE ? 'no_profile' : 'full', $row['user_id'], $row['username'], $row['user_colour']) . '</span>')); } // assign the forum stats to the template. $this->template->assign_vars(array('USERS_24HOUR_TOTAL' => $this->user->lang('USERS_24HOUR_TOTAL', $user_count), 'USERS_ACTIVE' => $user_count, 'GUEST_ONLINE_24' => $this->config['load_online_guests'] ? $this->user->lang('GUEST_ONLINE_24', $total_guests_online_24) : '', 'HOUR_TOPICS' => $this->user->lang('24HOUR_TOPICS', $activity['topics']), 'HOUR_POSTS' => $this->user->lang('24HOUR_POSTS', $activity['posts']), 'HOUR_USERS' => $this->user->lang('24HOUR_USERS', $activity['users']), 'S_CAN_VIEW_24_HOURS' => true)); }
public function search($start = 1) { if (!$this->auth->acl_get('u_usermap_search')) { trigger_error('NOT_AUTHORISED'); } $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang('USERMAP_TITLE'), 'U_VIEW_FORUM' => $this->helper->route('tas2580_usermap_index', array()))); $lon = substr($this->request->variable('lon', ''), 0, 10); $lat = substr($this->request->variable('lat', ''), 0, 10); $dst = $this->request->variable('dst', $this->config['tas2580_usermap_search_distance']); $alpha = 180 * $dst / (6378137 / 1000 * 3.14159); $min_lon = $this->db->sql_escape($lon - $alpha); $max_lon = $this->db->sql_escape($lon + $alpha); $min_lat = $this->db->sql_escape($lat - $alpha); $max_lat = $this->db->sql_escape($lat + $alpha); $where = " WHERE ( user_usermap_lon >= '{$min_lon}' AND user_usermap_lon <= '{$max_lon}') AND ( user_usermap_lat >= '{$min_lat}' AND user_usermap_lat<= '{$max_lat}')"; $limit = (int) $this->config['topics_per_page']; $sql = 'SELECT COUNT(user_id) AS num_users FROM ' . USERS_TABLE . $where; $result = $this->db->sql_query($sql); $total_users = (int) $this->db->sql_fetchfield('num_users'); $this->db->sql_freeresult($result); $sql = 'SELECT user_id, username, user_colour, user_regdate, user_posts, group_id, user_usermap_lon, user_usermap_lat FROM ' . USERS_TABLE . $where; $result = $this->db->sql_query_limit($sql, $limit, ($start - 1) * $limit); while ($row = $this->db->sql_fetchrow($result)) { $distance = $this->get_distance($lon, $lat, $row['user_usermap_lon'], $row['user_usermap_lat']); $this->template->assign_block_vars('memberrow', array('USER_ID' => $row['user_id'], 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'JOINED' => $this->user->format_date($row['user_regdate']), 'POSTS' => $row['user_posts'], 'GROUP_ID' => $row['group_id'], 'DISTANCE' => $distance)); } $this->pagination->generate_template_pagination(array('routes' => array('tas2580_usermap_search', 'tas2580_usermap_search_page'), 'params' => array()), 'pagination', 'start', $total_users, $limit, ($start - 1) * $limit); $this->template->assign_vars(array('TOTAL_USERS' => $this->user->lang('TOTAL_USERS', (int) $total_users), 'L_SEARCH_EXPLAIN' => $this->user->lang('SEARCH_EXPLAIN', $dst, $lon, $lat))); return $this->helper->render('usermap_search.html', $this->user->lang('USERMAP_SEARCH')); }
public function handle_downloadlog() { if (!$this->auth->acl_get('a_')) { trigger_error('Access Denied'); } else { $this->user->add_lang_ext('dmzx/downloadlog', 'common'); $fileid = $this->request->variable('file', 0); $start = $this->request->variable('start', 0); // Pagination number from ACP $dll = $this->config['downloadlog_value']; // Generate pagination $sql = 'SELECT COUNT(downloadslog_id) AS total_downloadlogs FROM ' . $this->userdownloadslog_table . ' WHERE user_id = user_id AND file_id = ' . $fileid; $result = $this->db->sql_query($sql); $total_downloadlogs = (int) $this->db->sql_fetchfield('total_downloadlogs'); $sql = 'SELECT d.user_id, d.down_date, u.user_id, u.username, u.user_colour FROM ' . $this->userdownloadslog_table . ' d, ' . USERS_TABLE . ' u WHERE u.user_id = d.user_id AND file_id = ' . $fileid . ' ORDER BY d.down_date DESC'; $top_result = $this->db->sql_query_limit($sql, $dll, $start); while ($row = $this->db->sql_fetchrow($top_result)) { $this->template->assign_block_vars('downloaders', array('D_USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'D_TIME' => $this->user->format_date($row['down_date']))); } } $pagination_url = $this->helper->route('dmzx_downloadlog_controller', array('file' => $fileid)); //Start pagination $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_downloadlogs, $dll, $start); $this->template->assign_vars(array('DOWNLOADERS_USERS' => $total_downloadlogs == 1 ? $this->user->lang['DOWNLOADERS_COUNT'] : sprintf($this->user->lang['DOWNLOADERS_COUNTS'], $total_downloadlogs), 'DOWNLOADERS_VERSION' => $this->config['downloadlog_version'])); page_header('Downloaders Log', false); $this->template->set_filenames(array('body' => 'DownloadLog.html')); page_footer(); }
public function newusers() { $howmany = $this->howmany(); $sql_where = $this->ignore_users(); $sql_and = !empty($sql_where) ? ' AND user_inactive_reason = 0' : ' WHERE user_inactive_reason = 0'; // newest registered users if (($newest_users = $this->cache->get('_top_five_newest_users')) === false) { $newest_users = array(); // grab most recent registered users $sql = 'SELECT user_id, username, user_colour, user_regdate FROM ' . USERS_TABLE . ' ' . $sql_where . ' ' . $sql_and . ' ORDER BY user_regdate DESC'; $result = $this->db->sql_query_limit($sql, $howmany); while ($row = $this->db->sql_fetchrow($result)) { $newest_users[$row['user_id']] = array('user_id' => $row['user_id'], 'username' => $row['username'], 'user_colour' => $row['user_colour'], 'user_regdate' => $row['user_regdate']); } $this->db->sql_freeresult($result); // cache this data for 5 minutes, this improves performance $this->cache->put('_top_five_newest_users', $newest_users, 300); } foreach ($newest_users as $row) { $username_string = $this->auth->acl_get('u_viewprofile') ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']); $this->template->assign_block_vars('top_five_newest', array('REG_DATE' => $this->user->format_date($row['user_regdate']), 'USERNAME_FULL' => $username_string)); } }
protected function get_last_visit($user_id, $author = 0) { if ($user_id == $author) { $last_visit = ''; } else { $sql = 'SELECT session_user_id, MAX(session_time) AS session_time FROM ' . SESSIONS_TABLE . ' WHERE session_time >= ' . (time() - $this->config['session_length']) . ' AND ' . $this->db->sql_in_set('session_user_id', $user_id) . ' GROUP BY session_user_id'; $result = $this->db->sql_query($sql); $session_times = array(); while ($row = $this->db->sql_fetchrow($result)) { $session_times[$row['session_user_id']] = $row['session_time']; } $this->db->sql_freeresult($result); $sql = 'SELECT user_lastvisit FROM ' . USERS_TABLE . ' WHERE ' . $this->db->sql_in_set('user_id', $user_id); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $session_time = !empty($session_times[$user_id]) ? $session_times[$user_id] : 0; $last_visit = !empty($session_time) ? $session_time : $row['user_lastvisit']; $last_visit = $this->user->format_date($last_visit); } $this->db->sql_freeresult($result); } return $last_visit; }
/** * Update website verification number after a missing backlink, and send notificaton * * @param array $u_array Information about website * @param int $next_prune Date of next auto check * @return null */ private function _update_check($u_array, $next_prune) { if (!class_exists('messenger')) { include $this->root_path . 'includes/functions_messenger.' . $this->php_ext; } $messenger = new \messenger(false); // cron.php don't call $user->setup(), so $this->timezone is unset. // We need to define it, because we use user->format_date below $this->user->timezone = new \DateTimeZone($this->config['board_timezone']); $sql = 'UPDATE ' . DIR_LINK_TABLE . ' SET link_nb_check = link_nb_check + 1 WHERE ' . $this->db->sql_in_set('link_id', array_keys($u_array)); $this->db->sql_query($sql); foreach ($u_array as $data) { strip_bbcode($data['link_description']); $notification_data = array('cat_name' => \ernadoo\phpbbdirectory\core\categorie::getname((int) $data['link_cat']), 'link_id' => $data['link_id'], 'link_name' => $data['link_name'], 'link_url' => $data['link_url'], 'link_description' => $data['link_description'], 'next_cron' => $this->user->format_date($next_prune, $data['user_dateformat'])); if ($data['link_nb_check']) { $this->notification->delete_notifications('ernadoo.phpbbdirectory.notification.type.directory_website_error_cron', $notification_data); } // New notification system can't send mail to an anonymous user with an email address stored in another table than phpbb_users if ($data['link_user_id'] == ANONYMOUS) { $username = $email = $data['link_guest_email']; $messenger->template('@ernadoo_phpbbdirectory/directory_website_error_cron', $data['user_lang']); $messenger->to($email, $username); $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($username), 'LINK_NAME' => $data['link_name'], 'LINK_URL' => $data['link_url'], 'LINK_DESCRIPTION' => $data['link_description'], 'NEXT_CRON' => $this->user->format_date($next_prune, $data['user_dateformat']))); $messenger->send(NOTIFY_EMAIL); } else { $this->notification->add_notifications('ernadoo.phpbbdirectory.notification.type.directory_website_error_cron', $notification_data); } } }
public function get_thanks($post_id) { $view = $this->request->variable('view', ''); $further_thanks_text = $return = ''; $user_list = array(); $further_thanks = $count = 0; $maxcount = isset($this->config['thanks_number_post']) ? $this->config['thanks_number_post'] : false; foreach ($this->thankers as $thanker) { if ($thanker['post_id'] == $post_id) { if ($count >= $maxcount) { $further_thanks++; } else { $user_list[] = get_username_string('full', $thanker['user_id'], $thanker['username'], $thanker['user_colour']) . ($this->config['thanks_time_view'] && $thanker['thanks_time'] ? ' (' . $this->user->format_date($thanker['thanks_time'], false, $view == 'print' ? true : false) . ')' : ''); $count++; } } } if (!empty($user_list)) { $return = implode($user_list, ' • '); } if ($further_thanks > 0) { $further_thanks_text = $further_thanks == 1 ? $this->user->lang['FURTHER_THANKS'] : sprintf($this->user->lang['FURTHER_THANKS_PL'], $further_thanks); } $return = $return == '' ? false : $return . $further_thanks_text; return $return; }
/** * Display popup comment * * @param int $link_id The category ID * @param int $page Page number taken from the URL * @param string $mode add|edit * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object * @throws \phpbb\exception\http_exception */ public function view($link_id, $page, $mode = 'new') { $this->_check_comments_enable($link_id); $comment_id = $this->request->variable('c', 0); $view = $this->request->variable('view', ''); $start = ($page - 1) * $this->config['dir_comments_per_page']; $this->s_hidden_fields = array_merge($this->s_hidden_fields, array('page' => $page)); $this->_populate_form($link_id, $mode); $sql = 'SELECT COUNT(comment_id) AS nb_comments FROM ' . DIR_COMMENT_TABLE . ' WHERE comment_link_id = ' . (int) $link_id; $result = $this->db->sql_query($sql); $nb_comments = (int) $this->db->sql_fetchfield('nb_comments'); $this->db->sql_freeresult($result); // Make sure $start is set to the last page if it exceeds the amount $start = $this->pagination->validate_start($start, $this->config['dir_comments_per_page'], $nb_comments); $sql_array = array('SELECT' => 'a.comment_id, a.comment_user_id, a. comment_user_ip, a.comment_date, a.comment_text, a.comment_uid, a.comment_bitfield, a.comment_flags, u.username, u.user_id, u.user_colour, z.foe', 'FROM' => array(DIR_COMMENT_TABLE => 'a'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'a.comment_user_id = u.user_id'), array('FROM' => array(ZEBRA_TABLE => 'z'), 'ON' => 'z.user_id = ' . $this->user->data['user_id'] . ' AND z.zebra_id = a.comment_user_id')), 'WHERE' => 'a.comment_link_id = ' . (int) $link_id, 'ORDER_BY' => 'a.comment_date DESC'); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, $this->config['dir_comments_per_page'], $start); $have_result = false; while ($comments = $this->db->sql_fetchrow($result)) { $have_result = true; $edit_allowed = $this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_comment_dir') || $this->user->data['user_id'] == $comments['comment_user_id'] && $this->auth->acl_get('u_edit_comment_dir')); $delete_allowed = $this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_comment_dir') || $this->user->data['user_id'] == $comments['comment_user_id'] && $this->auth->acl_get('u_delete_comment_dir')); $this->template->assign_block_vars('comment', array('MINI_POST_IMG' => $this->user->img('icon_post_target', 'POST'), 'S_USER' => get_username_string('full', $comments['comment_user_id'], $comments['username'], $comments['user_colour']), 'S_USER_IP' => $comments['comment_user_ip'], 'S_DATE' => $this->user->format_date($comments['comment_date']), 'S_COMMENT' => generate_text_for_display($comments['comment_text'], $comments['comment_uid'], $comments['comment_bitfield'], $comments['comment_flags']), 'S_ID' => $comments['comment_id'], 'U_EDIT' => $edit_allowed ? $this->helper->route('ernadoo_phpbbdirectory_comment_edit_controller', array('link_id' => (int) $link_id, 'comment_id' => (int) $comments['comment_id'])) : '', 'U_DELETE' => $delete_allowed ? $this->helper->route('ernadoo_phpbbdirectory_comment_delete_controller', array('link_id' => (int) $link_id, 'comment_id' => (int) $comments['comment_id'], '_referer' => $this->helper->get_current_url())) : '', 'S_IGNORE_POST' => $comments['foe'] && ($view != 'show' || $comment_id != $comments['comment_id']) ? true : false, 'L_IGNORE_POST' => $comments['foe'] ? $this->user->lang('POST_BY_FOE', get_username_string('full', $comments['comment_user_id'], $comments['username'], $comments['user_colour']), '<a href="' . $this->helper->url('directory/link/' . $link_id . '/comment' . ($page > 1 ? '/' . $page : '') . '?view=show#c' . (int) $comments['comment_id']) . '">', '</a>') : '', 'L_POST_DISPLAY' => $comments['foe'] ? $this->user->lang('POST_DISPLAY', '<a class="display_post" data-post-id="' . $comments['comment_id'] . '" href="' . $this->helper->url('directory/link/' . $link_id . '/comment' . ($page > 1 ? '/' . $page : '') . '?c=' . (int) $comments['comment_id'] . '&view=show#c' . (int) $comments['comment_id']) . '">', '</a>') : '', 'S_INFO' => $this->auth->acl_get('m_info'))); } $base_url = array('routes' => 'ernadoo_phpbbdirectory_comment_view_controller', 'params' => array('link_id' => (int) $link_id)); $this->pagination->generate_template_pagination($base_url, 'pagination', 'page', $nb_comments, $this->config['dir_comments_per_page'], $start); $this->template->assign_vars(array('TOTAL_COMMENTS' => $this->user->lang('DIR_NB_COMMS', (int) $nb_comments), 'S_HAVE_RESULT' => $have_result ? true : false)); return $this->helper->render('comments.html', $this->user->lang['DIR_COMMENT_TITLE']); }
/** * @return Response */ public function main() { $this->lang->add_lang('common', 'paul999/downloadpage'); $sql = 'SELECT * FROM ' . $this->versions_table . ' WHERE active = 1 ORDER BY sort DESC'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('releases', array('NAME' => $row['name'], 'EOL' => $row['eol'], 'L_EOL' => $this->lang->lang('PHPBB_EOL', $row['name']), 'L_ALWAYS_CURRENT_DOWNLOAD' => $this->lang->lang('ALWAYS_CURRENT', ''), 'L_ALWAYS_CURRENT_UPDATE' => $this->lang->lang('ALWAYS_CURRENT', ''))); // Yes, we do a queries in a loop here. // However, as the versions table should have <= 3 versions this should be fine. $sql_row = 'SELECT * FROM ' . $this->releases_table . ' WHERE version_id = ' . $row['version_id'] . ' AND active = 1 ORDER BY release_time DESC'; $result_row = $this->db->sql_query($sql_row); while ($row_row = $this->db->sql_fetchrow($result_row)) { $this->template->assign_block_vars('releases.versions', array('RELEASED_AT' => $this->lang->lang('RELEASED_AT', $this->user->format_date($row_row['release_time'])))); $sql = 'SELECT * FROM ' . $this->downloads_table . ' WHERE active = 1 AND release_id = ' . (int) $row_row['release_id']; $int_result = $this->db->sql_query($sql); while ($int_row = $this->db->sql_fetchrow($int_result)) { $this->template->assign_block_vars('releases.versions.downloads', array('U_DOWNLOAD' => $this->controller_helper->route('paul999_downloadpage_download', array('id' => $int_row['download_id'])), 'NAME' => $int_row['name'], 'S_FULL_PACKAGE' => $int_row['type'] == constants::FULL_PACKAGE, 'S_LANG_PACKAGE' => $int_row['type'] == constants::TRANSLATION, 'S_UPDATE_PACKAGE' => $int_row['type'] == constants::UPDATE_PACKAGE)); } $this->db->sql_freeresult($int_result); } $this->db->sql_freeresult($result_row); } $this->db->sql_freeresult($result); return $this->controller_helper->render('@paul999_downloadpage/download_main.html'); }
public function base() { $this->user->add_lang_ext('tas2580/wiki', 'common'); $this->user->add_lang_ext('tas2580/wiki', 'overview'); // get all article $sql = 'SELECT article_title, article_url, article_description, article_views, article_last_edit FROM ' . $this->article_table . ' WHERE article_approved=1 ORDER BY article_id ASC'; $result = $this->db->sql_query($sql); while ($all_wiki_article = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('all_wiki_article', array('U_ARTICLE' => $this->helper->route('tas2580_wiki_article', array('article' => $all_wiki_article['article_url'])), 'ARTICLE_NAME' => $all_wiki_article['article_title'], 'ARTICLE_DESCRIPTION' => $all_wiki_article['article_description'], 'ARTICLE_VIEWS' => $all_wiki_article['article_views'], 'ARTICLE_LASTEDIT' => $this->user->format_date($all_wiki_article['article_last_edit']))); } $this->db->sql_freeresult($result); // get latest article $sql = 'SELECT article_title, article_url, article_description, article_views, article_time_created FROM ' . $this->article_table . ' WHERE article_approved=1 ORDER BY article_time_created DESC'; $result = $this->db->sql_query_limit($sql, 5); while ($all_wiki_article = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('latest_wiki_article', array('U_ARTICLE' => $this->helper->route('tas2580_wiki_article', array('article' => $all_wiki_article['article_url'])), 'ARTICLE_NAME' => $all_wiki_article['article_title'], 'ARTICLE_DESCRIPTION' => $all_wiki_article['article_description'], 'ARTICLE_VIEWS' => $all_wiki_article['article_views'], 'ARTICLE_TIME_CREATED' => $this->user->format_date($all_wiki_article['article_time_created']))); } $this->db->sql_freeresult($result); // get hot article $sql = 'SELECT article_title, article_url, article_description, article_views, article_last_edit FROM ' . $this->article_table . ' WHERE article_approved=1 ORDER BY article_views DESC'; $result = $this->db->sql_query_limit($sql, 5); while ($all_wiki_article = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('hot_wiki_article', array('U_ARTICLE' => $this->helper->route('tas2580_wiki_article', array('article' => $all_wiki_article['article_url'])), 'ARTICLE_NAME' => $all_wiki_article['article_title'], 'ARTICLE_DESCRIPTION' => $all_wiki_article['article_description'], 'ARTICLE_VIEWS' => $all_wiki_article['article_views'], 'ARTICLE_LASTEDIT' => $this->user->format_date($all_wiki_article['article_last_edit']))); } $this->db->sql_freeresult($result); // get sticky article $sql = 'SELECT article_title, article_url, article_description, article_views, article_last_edit FROM ' . $this->article_table . ' WHERE article_approved=1 AND article_sticky=1 ORDER BY article_last_edit DESC'; $result = $this->db->sql_query($sql); while ($all_wiki_article = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('sticky_wiki_article', array('U_ARTICLE' => $this->helper->route('tas2580_wiki_article', array('article' => $all_wiki_article['article_url'])), 'ARTICLE_NAME' => $all_wiki_article['article_title'], 'ARTICLE_DESCRIPTION' => $all_wiki_article['article_description'], 'ARTICLE_VIEWS' => $all_wiki_article['article_views'], 'ARTICLE_LASTEDIT' => $this->user->format_date($all_wiki_article['article_last_edit']))); } $this->db->sql_freeresult($result); return $this->helper->render('overview.html', $this->user->lang['OVERVIEW']); }
private function quick_ads_rebuild_message($message) { $quick_ads_template = array('S_USERNAME' => $this->user->data['user_id'] != ANONYMOUS ? $this->user->data['username'] : $this->user->lang['GUEST'], 'S_USER_ID' => $this->user->data['user_id'] != ANONYMOUS ? $this->user->data['user_id'] : '', 'S_CURRENT_TIME' => sprintf($this->user->lang['CURRENT_TIME'], $this->user->format_date(time(), false, true)), 'SITE_URL' => generate_board_url(), 'FORUM_URL' => generate_board_url(true), 'SITENAME' => $this->config['sitename'], 'SITE_DESCRIPTION' => $this->config['site_desc']); foreach ($quick_ads_template as $key => $value) { $message = str_replace('{' . $key . '}', $value, $message); } return htmlspecialchars_decode($message); }
/** * Parse template variables for module * * @param int $module_id Module ID * @param string $type Module type (center or side) * * @return string Template file name or false if nothing should * be displayed */ protected function parse_template($module_id, $type) { $attach_forums = false; $where = ''; // Get filetypes and put them into an array $filetypes = $this->get_selected_filetypes($module_id); if ($this->config['board3_attachments_forum_ids_' . $module_id] !== '') { $attach_forums_config = strpos($this->config['board3_attachments_forum_ids_' . $module_id], ',') !== false ? explode(',', $this->config['board3_attachments_forum_ids_' . $module_id]) : array($this->config['board3_attachments_forum_ids_' . $module_id]); $forum_list = array_unique(array_keys($this->auth->acl_getf('f_read', true))); if ($this->config['board3_attachments_forum_exclude_' . $module_id]) { $forum_list = array_unique(array_diff($forum_list, $attach_forums_config)); } else { $forum_list = array_unique(array_intersect($attach_forums_config, $forum_list)); } } else { $forum_list = array_unique(array_keys($this->auth->acl_getf('f_read', true))); } if (sizeof($forum_list)) { $attach_forums = true; $where = 'AND ' . $this->db->sql_in_set('t.forum_id', $forum_list); } if (sizeof($filetypes)) { if ($this->config['board3_attachments_exclude_' . $module_id]) { $where .= ' AND ' . $this->db->sql_in_set('a.extension', $filetypes, true); } else { $where .= ' AND ' . $this->db->sql_in_set('a.extension', $filetypes); } } if ($attach_forums === true) { // Just grab all attachment info from database $sql = 'SELECT a.*, t.forum_id FROM ' . ATTACHMENTS_TABLE . ' a, ' . TOPICS_TABLE . ' t WHERE a.topic_id <> 0 AND a.topic_id = t.topic_id ' . $where . ' ORDER BY filetime ' . (!$this->config['display_order'] ? 'DESC' : 'ASC') . ', post_msg_id ASC'; $result = $this->db->sql_query_limit($sql, $this->config['board3_attachments_number_' . $module_id], 0, 600); while ($row = $this->db->sql_fetchrow($result)) { $size_lang = $row['filesize'] >= 1048576 ? $this->user->lang['MIB'] : ($row['filesize'] >= 1024 ? $this->user->lang['KIB'] : $this->user->lang['BYTES']); $row['filesize'] = $row['filesize'] >= 1048576 ? round(round($row['filesize'] / 1048576 * 100) / 100, 2) : ($row['filesize'] >= 1024 ? round(round($row['filesize'] / 1024 * 100) / 100, 2) : $row['filesize']); $raw_filename = utf8_substr($row['real_filename'], 0, strrpos($row['real_filename'], '.')); $replace = character_limit($raw_filename, $this->config['board3_attach_max_length_' . $module_id]); $this->template->assign_block_vars('attach_' . $type, array('FILESIZE' => $row['filesize'] . ' ' . $size_lang, 'FILETIME' => $this->user->format_date($row['filetime']), 'DOWNLOAD_COUNT' => (int) $row['download_count'], 'FILENAME' => $replace, 'REAL_FILENAME' => $row['real_filename'], 'PHYSICAL_FILENAME' => basename($row['physical_filename']), 'ATTACH_ID' => $row['attach_id'], 'POST_IDS' => !empty($post_ids[$row['attach_id']]) ? $post_ids[$row['attach_id']] : '', 'POST_MSG_ID' => $row['post_msg_id'], 'U_FILE' => append_sid($this->phpbb_root_path . 'download/file.' . $this->php_ext, 'id=' . $row['attach_id']), 'U_TOPIC' => append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, 'p=' . $row['post_msg_id'] . '#p' . $row['post_msg_id']))); } $this->db->sql_freeresult($result); $this->template->assign_var('S_DISPLAY_ATTACHMENTS', true); } else { $this->template->assign_var('S_DISPLAY_ATTACHMENTS', false); } return 'attachments_' . $type . '.html'; }
/** * Send an email notification when a user logs into the ACP * * @param object $event The event object * @return null * @access public */ public function acp_login_notification($event) { if (!$this->config['sec_login_email']) { return; } if ($event['admin']) { $this->send_message(array('USERNAME' => $this->user->data['username'], 'IP_ADDRESS' => $this->user->ip, 'LOGIN_TIME' => $this->user->format_date(time(), $this->config['default_dateformat'], true)), 'acp_login', $this->user->data['user_email']); } }
/** * Assign TimeAgo timestamps into viewtopic.php template variables * * @param array $row Row data * @param array $block Template vars array * * @return array Template vars array * @access public */ public function set_posts_timeago($row, $block) { // set the detail level to display, 0 is Off, 1 is Short, 2 is Medium, 3 is Full. $detail = !empty($this->config['ta_viewtopic']) ? $this->config['ta_viewtopic'] : ''; // set the extended display option, 0 is Off, 1 On. When On, this appends the timeago string with the native phpBB timestamp $extend = !empty($this->config['ta_viewtopic_extended']) ? ' (' . $this->user->format_date($row['post_time']) . ')' : ''; $block = array_merge($block, ['TIMEAGO' => !empty($this->config['ta_active']) ? TRUE : FALSE, 'POST_DATE_ORIG' => $this->user->format_date($row['post_time']), 'POST_DATE' => !empty($this->config['ta_viewtopic']) ? $this->time_ago($row['post_time'], $detail) . ' ' . $this->user->lang('TA_AGO') . $extend : $this->user->format_date($row['post_time'])]); return $block; }
public function modify_viewtopic_postrow($event) { $view = $this->request->variable('view', ''); $row = $event['row']; $post_row = $event['post_row']; $post_time = $row['post_created'] ?: $row['post_time']; $post_row['POST_DATE'] = $this->user->format_date($post_time, false, $view == 'print' ? true : false); $event['post_row'] = $post_row; }
/** * date controller for return a date * * @return \phpbb\json_response A Json Response * @throws \phpbb\exception\http_exception */ public function return_date() { if (!$this->request->is_ajax()) { throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); } $timestamp = $this->request->variable('timestamp', 0); $json_response = new \phpbb\json_response(); $json_response->send(array('success' => true, 'DATE' => $this->user->format_date((int) $timestamp))); }
/** * Assign TimeAgo timestamps into viewtopic.php template variables. * * @param array $row Row data * @param array $block Template vars array * * @return array Template vars array */ public function set_posts_timeago($row, $block) { $detail = !empty($this->config['ta_viewtopic']) ? $this->config['ta_viewtopic'] : ''; $extend = !empty($this->config['ta_viewtopic_extended']) ? ' (' . $this->user->format_date($row['post_time']) . ')' : ''; $timeago = !empty($this->config['ta_viewtopic']) ? $this->time_ago($row['post_time'], $detail) : ''; $ta_output = !empty($timeago) ? $this->build_ta_output($timeago, $extend) : $this->user->format_date($row['post_time']); $block = array_merge($block, ['TIMEAGO' => !empty($this->config['ta_active']) ? true : false, 'POST_DATE_ORIG' => $this->user->format_date($row['post_time']), 'POST_DATE' => $this->ta_timer($row['post_time']) === true ? $this->user->format_date($row['post_time']) : $ta_output]); return $block; }
public function info($user_id) { if (!$this->auth->acl_gets('u_viewprofile')) { trigger_error('NOT_AUTHORISED'); } $sql_ary = array('SELECT' => 'u.username, u.user_colour, u.user_regdate, u.user_posts, u.user_lastvisit, u.user_rank, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'u.user_id = ' . (int) $user_id); /** * Modify SQL query in tas2580 AJAX userinfo extension * * @event tas2580.userinfo_modify_sql * @var string sql_ary The SQL query * @var int user_id The ID of the user * @since 0.2.3 */ $vars = array('sql_ary', 'user_id'); extract($this->phpbb_dispatcher->trigger_event('tas2580.userinfo_modify_sql', compact($vars))); $result = $this->db->sql_query_limit($this->db->sql_build_query('SELECT', $sql_ary), 1); $this->data = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if (!function_exists('phpbb_get_user_rank')) { include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext; } $user_rank_data = phpbb_get_user_rank($this->data, $this->data['user_posts']); // Get the avatar // Wen need to use the full URL here because we don't know the path where userinfo is called define('PHPBB_USE_BOARD_URL_PATH', true); $avatar = phpbb_get_user_avatar($this->data); $avatar = empty($avatar) ? '<img src="' . generate_board_url() . '/styles/' . $this->user->style['style_name'] . '/theme/images/no_avatar.gif" width="100" height="100" alt="' . $this->user->lang('USER_AVATAR') . '">' : $avatar; $memberdays = max(1, round((time() - $this->data['user_regdate']) / 86400)); $posts_per_day = $this->data['user_posts'] / $memberdays; $percentage = $this->config['num_posts'] ? min(100, $this->data['user_posts'] / $this->config['num_posts'] * 100) : 0; $result = array('userinfo_header' => sprintf($this->user->lang['VIEWING_PROFILE'], $this->data['username']), 'username' => get_username_string('no_profile', $user_id, $this->data['username'], $this->data['user_colour']), 'regdate' => $this->user->format_date($this->data['user_regdate']), 'posts' => $this->data['user_posts'], 'lastvisit' => $this->user->format_date($this->data['user_lastvisit']), 'avatar' => $avatar, 'rank' => empty($user_rank_data['title']) ? $this->user->lang('NA') : $user_rank_data['title'], 'postsperday' => $this->user->lang('POST_DAY', $posts_per_day), 'percentage' => $this->user->lang('POST_PCT', $percentage)); /** * Modify return data in tas2580 AJAX userinfo extension * * @event tas2580.userinfo_modify_result * @var array result The result array * @var int user_id The ID of the user * @since 0.2.3 */ $vars = array('result', 'user_id'); extract($this->phpbb_dispatcher->trigger_event('tas2580.userinfo_modify_result', compact($vars))); return new JsonResponse($result); }
/** * Display the output for this extension * * @return null * @access public */ public function display_output() { // Add the language file $this->language->add_lang('acp_activesessions', 'david63/activesessions'); // Start initial var setup $action = $this->request->variable('action', ''); $start = $this->request->variable('start', 0); $fc = $this->request->variable('fc', ''); $sort_key = $this->request->variable('sk', 's'); $sd = $sort_dir = $this->request->variable('sd', 'd'); $sort_dir = $sort_dir == 'd' ? ' DESC' : ' ASC'; $order_ary = array('i' => 's.session_ip' . $sort_dir . ', u.username_clean ASC', 's' => 's.session_start' . $sort_dir . ', u.username_clean ASC', 'u' => 'u.username_clean' . $sort_dir); $filter_by = ''; if ($fc == 'other') { for ($i = ord($this->language->lang('START_CHARACTER')); $i <= ord($this->language->lang('END_CHARACTER')); $i++) { $filter_by .= ' AND u.username_clean ' . $this->db->sql_not_like_expression(utf8_clean_string(chr($i)) . $this->db->get_any_char()); } } else { if ($fc) { $filter_by .= ' AND u.username_clean ' . $this->db->sql_like_expression(utf8_clean_string(substr($fc, 0, 1)) . $this->db->get_any_char()); } } $sql = $this->db->sql_build_query('SELECT', array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, s.*, f.forum_id, f.forum_name', 'FROM' => array(USERS_TABLE => 'u', SESSIONS_TABLE => 's'), 'LEFT_JOIN' => array(array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 's.session_forum_id = f.forum_id')), 'WHERE' => 'u.user_id = s.session_user_id AND s.session_time >= ' . (time() - $this->config['session_length'] * 60) . $filter_by, 'ORDER_BY' => $sort_key == '' ? 'u.username_clean' : $order_ary[$sort_key])); $result = $this->db->sql_query_limit($sql, $this->config['topics_per_page'], $start); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('active_sessions', array('ADMIN' => $row['session_admin'] ? $this->language->lang('YES') : $this->language->lang('NO'), 'AUTO_LOGIN' => $row['session_autologin'] ? $this->language->lang('YES') : $this->language->lang('NO'), 'BROWSER' => $row['session_browser'], 'FORUM' => $row['forum_id'] > 0 ? $row['forum_name'] : '', 'LAST_VISIT' => $this->user->format_date($row['session_last_visit']), 'SESSION_FORWARD' => $row['session_forwarded_for'], 'SESSION_ID' => $row['session_id'], 'SESSION_IP' => $row['session_ip'], 'SESSION_KEY' => $row['session_id'] . $row['user_id'], 'SESSION_ONLINE' => $row['session_viewonline'] ? $this->language->lang('YES') : $this->language->lang('NO'), 'SESSION_PAGE' => $row['session_page'], 'SESSION_START' => $this->user->format_date($row['session_start']), 'SESSION_TIME' => $this->user->format_date($row['session_time']), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))); } $this->db->sql_freeresult($result); $sort_by_text = array('u' => $this->language->lang('SORT_USERNAME'), 'i' => $this->language->lang('SESSION_IP'), 's' => $this->language->lang('SESSION_START')); $limit_days = array(); $s_sort_key = $s_limit_days = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); // Get total session count for output $sql = $this->db->sql_build_query('SELECT', array('SELECT' => 'COUNT(s.session_id) AS total_sessions', 'FROM' => array(USERS_TABLE => 'u', SESSIONS_TABLE => 's'), 'WHERE' => 'u.user_id = s.session_user_id' . $filter_by)); $result = $this->db->sql_query($sql); $session_count = (int) $this->db->sql_fetchfield('total_sessions'); $this->db->sql_freeresult($result); $action = "{$this->u_action}&sk={$sort_key}&sd={$sd}"; $link = $session_count ? adm_back_link($action . '&start=' . $start) : ''; if ($session_count == 0) { trigger_error($this->language->lang('NO_SESSION_DATA') . $link); } $start = $this->pagination->validate_start($start, $this->config['topics_per_page'], $session_count); $this->pagination->generate_template_pagination($action, 'pagination', 'start', $session_count, $this->config['topics_per_page'], $start); $first_characters = array(); $first_characters[''] = $this->language->lang('ALL'); for ($i = ord($this->language->lang('START_CHARACTER')); $i <= ord($this->language->lang('END_CHARACTER')); $i++) { $first_characters[chr($i)] = chr($i); } $first_characters['other'] = $this->language->lang('OTHER'); foreach ($first_characters as $char => $desc) { $this->template->assign_block_vars('first_char', array('DESC' => $desc, 'U_SORT' => $action . '&fc=' . $char)); } $this->template->assign_vars(array('ACTIVE_SESSIONS_VERSION' => ext::ACTIVE_SESSIONS_VERSION, 'S_SORT_DIR' => $s_sort_dir, 'S_SORT_KEY' => $s_sort_key, 'TOTAL_USERS' => $this->language->lang('TOTAL_SESSIONS', (int) $session_count), 'U_ACTION' => $action)); }
/** * {@inheritdoc} */ public function get_template_side($module_id) { // Last x visited bots $sql = 'SELECT username, user_colour, user_lastvisit FROM ' . USERS_TABLE . ' WHERE user_type = ' . USER_IGNORE . ' AND user_lastvisit > 0 ORDER BY user_lastvisit DESC'; $result = $this->db->sql_query_limit($sql, $this->config['board3_last_visited_bots_number_' . $module_id], 0, 600); $show_module = false; while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('last_visited_bots', array('BOT_NAME' => get_username_string('full', '', $row['username'], $row['user_colour']), 'LAST_VISIT_DATE' => $this->user->format_date($row['user_lastvisit']))); $show_module = true; } $this->db->sql_freeresult($result); if ($show_module) { return 'latest_bots_side.html'; } }
public function afficher_photos($event) { $user_id = $this->user->data["user_id"]; $this->user->add_lang_ext('Aurelienazerty/Photos', 'photos'); $lesPhotos = fonctionGetLastCommentaireForUser($user_id, 10, false); $lesPhotos = commentaireForUser($lesPhotos, $user_id); $tpl_loopname = 'recent_photos'; foreach ($lesPhotos['lignesMessage'] as $photo) { if ($photo['compteNonLu']) { $folder_alt = 'UNREAD_POST'; $folder_type = 'topic_unread'; $contexte = $photo['contexte']; $tpl_ary = array('LAST_POST_AUTHOR_FULL' => get_username_string('full', $photo['user_id'], $photo['username'], $photo['user_colour']), 'U_VIEW_PHOTO' => $photo['link'], 'PHOTO_TITLE' => $photo['nom'], 'LAST_POST_TIME' => $this->user->format_date($photo['date']), 'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt], 'TOPIC_IMG_STYLE' => $folder_type, 'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'PHOTO_CONTEXTE_URL' => replace_mod_rewrite($contexte[1]['href']), 'PHOTO_CONTEXTE' => $contexte[1]['txt']); //$vars = array('photo', 'tpl_ary'); //extract($this->dispatcher->trigger_event('Aurelienazerty.Photos.modify_tpl_ary', compact($vars))); $this->template->assign_block_vars($tpl_loopname, $tpl_ary); } } }
/** * Add & read action * * @return bool */ private function addAction() { $this->get = true; $message = utf8_normalize_nfc($this->request->variable('message', '', true)); if (!$message) { return; } $this->clean_message($message); $uid = $bitfield = $options = ''; $allow_bbcode = $this->auth->acl_get('u_ajaxchat_bbcode'); $allow_urls = $allow_smilies = true; generate_text_for_storage($message, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $sql_ary = ['chat_id' => 1, 'user_id' => $this->user->data['user_id'], 'username' => $this->user->data['username'], 'user_colour' => $this->user->data['user_colour'], 'message' => $message, 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'bbcode_options' => $options, 'time' => time()]; $sql = 'INSERT INTO ' . CHAT_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $this->db->sql_query($sql); $sql_ary2 = ['username' => $this->user->data['username'], 'user_colour' => $this->user->data['user_colour'], 'user_lastpost' => time(), 'user_lastupdate' => time()]; $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary2) . " WHERE user_id = {$this->user->data['user_id']}"; $result = $this->db->sql_query($sql); $sql = 'SELECT c.*, p.post_visibility, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height FROM ' . CHAT_TABLE . ' as c LEFT JOIN ' . USERS_TABLE . ' as u ON c.user_id = u.user_id LEFT JOIN ' . POSTS_TABLE . ' as p ON c.post_id = p.post_id WHERE c.message_id > ' . $this->last_id . ' ORDER BY c.message_id DESC'; $result = $this->db->sql_query_limit($sql, (int) $this->config['ajax_chat_chat_amount']); $rows = $this->db->sql_fetchrowset($result); if (!sizeof($rows) && time() - 60 < $this->last_time) { exit; } foreach ($rows as $row) { if ($row['forum_id'] && !$row['post_visibility'] == ITEM_APPROVED && !$this->auth->acl_get('m_approve', $row['forum_id'])) { continue; } if ($row['forum_id'] && !$this->auth->acl_get('f_read', $row['forum_id'])) { continue; } $avatar = ['avatar' => $row['user_avatar'], 'avatar_type' => $row['user_avatar_type'], 'avatar_height' => $row['user_avatar_height'], 'avatar_width' => $row['user_avatar_width']]; $avatar_thumb = ['avatar' => $row['user_avatar'], 'avatar_type' => $row['user_avatar_type'], 'avatar_height' => '', 'avatar_width' => 35]; $row['avatar'] = $this->user->optionget('viewavatars') ? phpbb_get_avatar($avatar, '') : ''; $row['avatar_thumb'] = $this->user->optionget('viewavatars') ? phpbb_get_avatar($avatar_thumb, '') : ''; if ($this->count++ == 0) { $this->last_id = $row['message_id']; $this->template->assign_vars(['SOUND_ENABLED' => true, 'SOUND_FILE' => 'soundout']); } if ($this->config['ajax_chat_time_setting']) { $time = $this->config['ajax_chat_time_setting']; } else { $time = $this->user->data['user_dateformat']; } $this->template->assign_block_vars('chatrow', ['MESSAGE_ID' => $row['message_id'], 'USERNAME_FULL' => $this->clean_username(get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST'])), 'USERNAME_A' => $row['username'], 'USER_COLOR' => $row['user_colour'], 'MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'TIME' => $this->user->format_date($row['time'], $time), 'CLASS' => $row['message_id'] % 2 ? 1 : 2, 'USER_AVATAR' => $row['avatar'], 'USER_AVATAR_THUMB' => $row['avatar_thumb']]); } $this->db->sql_freeresult($result); return; }
/** * {@inheritdoc} */ public function display(array $settings, $edit_mode = false) { $data = $this->context->get_data_ref(); if (!empty($data['.'][0]['TOTAL_USERS_ONLINE'])) { $l_online_users = $data['.'][0]['TOTAL_USERS_ONLINE']; $online_userlist = $data['.'][0]['LOGGED_IN_USER_LIST']; $l_online_record = $data['.'][0]['RECORD_USERS']; } else { $item_id = 0; $item = 'forum'; $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $l_online_record = $this->user->lang('RECORD_ONLINE_USERS', (int) $this->config['record_online_users'], $this->user->format_date($this->config['record_online_date'], false, true)); } $this->ptemplate->assign_vars(array('TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => $l_online_record, 'U_VIEWONLINE' => $this->_get_viewonline_url())); unset($data); return array('title' => 'WHO_IS_ONLINE', 'content' => $this->ptemplate->render_view('blitze/sitemaker', 'blocks/whois.html', 'whois_block')); }
/** * @param array $topic_data * @param array $post_data */ protected function _show_topics(array &$topic_data, array &$post_data) { for ($i = 0, $size = sizeof($topic_data); $i < $size; $i++) { $row =& $topic_data[$i]; $forum_id = $row['forum_id']; $topic_id = $row['topic_id']; $tpl_ary = array('FORUM_TITLE' => $row['forum_name'], 'TOPIC_TITLE' => truncate_string(censor_text($row['topic_title']), $this->settings['topic_title_limit'], 255, false, '...'), 'TOPIC_AUTHOR' => get_username_string('full', $row[$this->fields['user_id']], $row[$this->fields['username']], $row[$this->fields['user_colour']]), 'TOPIC_PREVIEW' => $this->_get_preview(array_pop($post_data[$topic_id])), 'TOPIC_POST_TIME' => $this->user->format_date($row[$this->fields['time']]), 'ATTACH_ICON_IMG' => $this->_get_attachment_icon($forum_id, $row['topic_attachment']), 'REPLIES' => $this->content_visibility->get_count('topic_posts', $row, $forum_id) - 1, 'VIEWS' => $row['topic_views'], 'S_UNREAD_TOPIC' => $this->_is_unread_topic($forum_id, $topic_id, $row['topic_last_post_time']), 'U_VIEWTOPIC' => append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "f={$forum_id}&t={$topic_id}"), 'U_VIEWFORUM' => append_sid($this->phpbb_root_path . 'viewforum.' . $this->php_ext, "f={$forum_id}")); $this->ptemplate->assign_block_vars('topicrow', $tpl_ary); unset($topic_data[$i], $post_data[$topic_id]); } }