本文整理汇总了PHP中gen_sort_selects函数的典型用法代码示例。如果您正苦于以下问题:PHP gen_sort_selects函数的具体用法?PHP gen_sort_selects怎么用?PHP gen_sort_selects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gen_sort_selects函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gen_topic_sort_options
/**
* Generate <select> markup
*/
protected function gen_topic_sort_options($forum_data)
{
// Dummy variables
$sort_days = 0;
$limit_days = array();
$sort_by_text = array('x' => $this->user->lang('SORTTOPICS_USER_DEFAULT'), 'a' => $this->user->lang('AUTHOR'), 't' => $this->user->lang('POST_TIME'), 'c' => $this->user->lang('SORTTOPICS_CREATED_TIME'), 'r' => $this->user->lang('REPLIES'), 's' => $this->user->lang('SUBJECT'), 'v' => $this->user->lang('VIEWS'));
$sort_key = isset($forum_data['sort_topics_by']) ? $forum_data['sort_topics_by'] : $this->default_sort_by;
$sort_dir = isset($forum_data['sort_topics_order']) ? $forum_data['sort_topics_order'] : $this->default_sort_order;
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, false, $this->default_sort_by, $this->default_sort_order);
return array('by' => $s_sort_key, 'order' => $s_sort_dir);
}
示例2: main
//.........这里部分代码省略.........
AND is_orphan = 0';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$deleted_filenames[] = $row['real_filename'];
}
$db->sql_freeresult($result);
if ($num_deleted = $this->attachment_manager->delete('attach', $delete_files)) {
if (sizeof($delete_files) != $num_deleted) {
$error[] = $user->lang['FILES_GONE'];
}
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACHMENTS_DELETED', false, array(implode(', ', $deleted_filenames)));
$notify[] = sprintf($user->lang['LOG_ATTACHMENTS_DELETED'], implode($user->lang['COMMA_SEPARATOR'], $deleted_filenames));
} else {
$error[] = $user->lang['NO_FILES_TO_DELETE'];
}
}
}
if ($action == 'stats') {
$this->handle_stats_resync();
}
$stats_error = $this->check_stats_accuracy();
if ($stats_error) {
$error[] = $stats_error;
}
$template->assign_vars(array('S_MANAGE' => true));
$start = $request->variable('start', 0);
// Sort keys
$sort_days = $request->variable('st', 0);
$sort_key = $request->variable('sk', 't');
$sort_dir = $request->variable('sd', 'd');
// Sorting
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('f' => $user->lang['FILENAME'], 't' => $user->lang['FILEDATE'], 's' => $user->lang['FILESIZE'], 'x' => $user->lang['EXTENSION'], 'd' => $user->lang['DOWNLOADS'], 'p' => $user->lang['ATTACH_POST_TYPE'], 'u' => $user->lang['AUTHOR']);
$sort_by_sql = array('f' => 'a.real_filename', 't' => 'a.filetime', 's' => 'a.filesize', 'x' => 'a.extension', 'd' => 'a.download_count', 'p' => 'a.in_message', 'u' => 'u.username');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
$min_filetime = $sort_days ? time() - $sort_days * 86400 : '';
$limit_filetime = $min_filetime ? " AND a.filetime >= {$min_filetime} " : '';
$start = $sort_days && isset($_POST['sort']) ? 0 : $start;
$attachments_per_page = (int) $config['topics_per_page'];
$stats = $this->get_attachment_stats($limit_filetime);
$num_files = $stats['num_files'];
$total_size = $stats['upload_dir_size'];
// Make sure $start is set to the last page if it exceeds the amount
/* @var $pagination \phpbb\pagination */
$pagination = $phpbb_container->get('pagination');
$start = $pagination->validate_start($start, $attachments_per_page, $num_files);
// If the user is trying to reach the second half of the attachments list, fetch it starting from the end
$store_reverse = false;
$sql_limit = $attachments_per_page;
if ($start > $num_files / 2) {
$store_reverse = true;
// Select the sort order. Add time sort anchor for non-time sorting cases
$sql_sort_anchor = $sort_key != 't' ? ', a.filetime ' . ($sort_dir == 'd' ? 'ASC' : 'DESC') : '';
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'ASC' : 'DESC') . $sql_sort_anchor;
$sql_limit = $pagination->reverse_limit($start, $sql_limit, $num_files);
$sql_start = $pagination->reverse_start($start, $sql_limit, $num_files);
} else {
// Select the sort order. Add time sort anchor for non-time sorting cases
$sql_sort_anchor = $sort_key != 't' ? ', a.filetime ' . ($sort_dir == 'd' ? 'DESC' : 'ASC') : '';
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC') . $sql_sort_anchor;
$sql_start = $start;
}
$attachments_list = array();
// Just get the files
$sql = 'SELECT a.*, u.username, u.user_colour, t.topic_title
FROM ' . ATTACHMENTS_TABLE . ' a
LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = a.poster_id)
LEFT JOIN ' . TOPICS_TABLE . " t ON (a.topic_id = t.topic_id)\n\t\t\t\t\tWHERE a.is_orphan = 0\n\t\t\t\t\t\t{$limit_filetime}\n\t\t\t\t\tORDER BY {$sql_sort_order}";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
$i = $store_reverse ? $sql_limit - 1 : 0;
// Store increment value in a variable to save some conditional calls
$i_increment = $store_reverse ? -1 : 1;
while ($attachment_row = $db->sql_fetchrow($result)) {
$attachments_list[$i] = $attachment_row;
$i = $i + $i_increment;
}
$db->sql_freeresult($result);
$base_url = $this->u_action . "&{$u_sort_param}";
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_files, $attachments_per_page, $start);
$template->assign_vars(array('TOTAL_FILES' => $num_files, 'TOTAL_SIZE' => get_formatted_filesize($total_size), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir));
// Grab extensions
$extensions = $cache->obtain_attach_extensions(true);
for ($i = 0, $end = sizeof($attachments_list); $i < $end; ++$i) {
$row = $attachments_list[$i];
$row['extension'] = strtolower(trim((string) $row['extension']));
$comment = $row['attach_comment'] && !$row['in_message'] ? str_replace(array("\n", "\r"), array('<br />', "\n"), $row['attach_comment']) : '';
$display_cat = $extensions[$row['extension']]['display_cat'];
$l_downloaded_viewed = $display_cat == ATTACHMENT_CATEGORY_NONE ? 'DOWNLOAD_COUNTS' : 'VIEWED_COUNTS';
$template->assign_block_vars('attachments', array('ATTACHMENT_POSTER' => get_username_string('full', (int) $row['poster_id'], (string) $row['username'], (string) $row['user_colour'], (string) $row['username']), 'FILESIZE' => get_formatted_filesize((int) $row['filesize']), 'FILETIME' => $user->format_date((int) $row['filetime']), 'REAL_FILENAME' => !$row['in_message'] ? utf8_basename((string) $row['real_filename']) : '', 'PHYSICAL_FILENAME' => utf8_basename((string) $row['physical_filename']), 'EXT_GROUP_NAME' => !empty($extensions[$row['extension']]['group_name']) ? $user->lang['EXT_GROUP_' . $extensions[$row['extension']]['group_name']] : '', 'COMMENT' => $comment, 'TOPIC_TITLE' => !$row['in_message'] ? (string) $row['topic_title'] : '', 'ATTACH_ID' => (int) $row['attach_id'], 'POST_ID' => (int) $row['post_msg_id'], 'TOPIC_ID' => (int) $row['topic_id'], 'POST_IDS' => !empty($post_ids[$row['attach_id']]) ? (int) $post_ids[$row['attach_id']] : '', 'L_DOWNLOAD_COUNT' => $user->lang($l_downloaded_viewed, (int) $row['download_count']), 'S_IN_MESSAGE' => (bool) $row['in_message'], 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}", 'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id'])));
}
break;
}
if (sizeof($error)) {
$template->assign_vars(array('S_WARNING' => true, 'WARNING_MSG' => implode('<br />', $error)));
}
if (sizeof($notify)) {
$template->assign_vars(array('S_NOTIFY' => true, 'NOTIFY_MSG' => implode('<br />', $notify)));
}
}
示例3: mcp_notes_user_view
/**
* Display user notes
*/
function mcp_notes_user_view($action)
{
global $_CLASS, $_CORE_CONFIG, $config;
$user_id = request_var('u', 0);
$username = request_var('username', '');
$start = request_var('start', 0);
$st = request_var('st', 0);
$sk = request_var('sk', 'b');
$sd = request_var('sd', 'd');
$url = 'forums&file=mcp&i=notes&mode=user_notes';
$sql_where = $user_id ? "user_id = {$user_id}" : "username = '" . $db->sql_escape($username) . "'";
$sql = 'SELECT *
FROM ' . CORE_USERS_TABLE . "\n\t\tWHERE {$sql_where}";
$result = $_CLASS['core_db']->query($sql);
$userrow = $_CLASS['core_db']->fetch_row_assoc($result);
$_CLASS['core_db']->free_result($result);
if (!$userrow) {
trigger_error('NO_USER');
}
$user_id = $userrow['user_id'];
$deletemark = $action === 'del_marked';
$deleteall = $action === 'del_all';
$marked = get_variable('marknote', 'REQUEST', false, 'array:int');
$usernote = request_var('usernote', '', true);
// Handle any actions
if (($deletemark || $deleteall) && $_CLASS['forums_auth']->acl_get('a_clearlogs')) {
$where_sql = '';
if ($deletemark && !empty($marked)) {
$where_sql = ' AND log_id IN (' . implode(', ', $marked) . ')';
}
if ($where_sql || $deleteall) {
$sql = 'DELETE FROM ' . FORUMS_LOG_TABLE . '
WHERE log_type = ' . LOG_USERS . " \n\t\t\t\t\tAND reportee_id = {$user_id}\n\t\t\t\t\t{$where_sql}";
$_CLASS['core_db']->query($sql);
add_log('admin', 'LOG_CLEAR_USER', $userrow['username']);
$msg = $deletemark ? 'MARKED_NOTES_DELETED' : 'ALL_NOTES_DELETED';
$redirect = generate_link($url . '&u=' . $user_id);
$_CLASS['core_display']->meta_refresh(3, $redirect);
trigger_error($_CLASS['core_user']->lang[$msg] . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
}
if ($usernote && $action === 'add_feedback') {
add_log('admin', 'LOG_USER_FEEDBACK', $userrow['username']);
add_log('user', $user_id, 'LOG_USER_GENERAL', $usernote);
$redirect = generate_link($url . '&u=' . $user_id);
$_CLASS['core_display']->meta_refresh(3, $redirect);
trigger_error($_CLASS['core_user']->lang['USER_FEEDBACK_ADDED'] . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
// Generate the appropriate user information for the user we are looking at
$rank_title = $rank_img = '';
//get_user_rank($userrow['user_rank'], $userrow['user_posts'], $rank_title, $rank_img);
$avatar_img = '';
if (!empty($userrow['user_avatar'])) {
switch ($userrow['user_avatar_type']) {
case AVATAR_UPLOAD:
$avatar_img = $_CORE_CONFIG['global']['path_avatar_upload'] . '/';
break;
case AVATAR_GALLERY:
$avatar_img = $_CORE_CONFIG['global']['path_avatar_gallery'] . '/';
break;
}
$avatar_img .= $userrow['user_avatar'];
$avatar_img = '<img src="' . $avatar_img . '" width="' . $userrow['user_avatar_width'] . '" height="' . $userrow['user_avatar_height'] . '" alt="" />';
}
$limit_days = array(0 => $_CLASS['core_user']->lang['ALL_ENTRIES'], 1 => $_CLASS['core_user']->lang['1_DAY'], 7 => $_CLASS['core_user']->lang['7_DAYS'], 14 => $_CLASS['core_user']->lang['2_WEEKS'], 30 => $_CLASS['core_user']->lang['1_MONTH'], 90 => $_CLASS['core_user']->lang['3_MONTHS'], 180 => $_CLASS['core_user']->lang['6_MONTHS'], 365 => $_CLASS['core_user']->lang['1_YEAR']);
$sort_by_text = array('a' => $_CLASS['core_user']->lang['SORT_USERNAME'], 'b' => $_CLASS['core_user']->lang['SORT_DATE'], 'c' => $_CLASS['core_user']->lang['SORT_IP'], 'd' => $_CLASS['core_user']->lang['SORT_ACTION']);
$sort_by_sql = array('a' => 'l.username', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
// Define where and sort sql for use in displaying logs
$sql_where = $st ? $_CLASS['core_user']->time - $st * 86400 : 0;
$sql_sort = $sort_by_sql[$sk] . ' ' . ($sd == 'd' ? 'DESC' : 'ASC');
$log_data = array();
$log_count = 0;
view_log('user', $log_data, $log_count, $config['posts_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);
$_CLASS['core_template']->assign('S_USER_NOTES', false);
if ($log_count) {
$_CLASS['core_template']->assign('S_USER_NOTES', true);
foreach ($log_data as $row) {
$_CLASS['core_template']->assign_vars_array('usernotes', array('REPORT_BY' => $row['username'], 'REPORT_AT' => $_CLASS['core_user']->format_date($row['time']), 'ACTION' => $row['action'], 'IP' => $row['ip'], 'ID' => $row['id']));
}
}
$pagination = generate_pagination($url . "&u={$user_id}&st={$st}&sk={$sk}&sd={$sd}", $log_count, $config['posts_per_page'], $start);
$_CLASS['core_template']->assign_array(array('U_POST_ACTION' => generate_link($url . '&u=' . $user_id), 'S_CLEAR_ALLOWED' => $_CLASS['forums_auth']->acl_get('a_clearlogs'), 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'L_TITLE' => $_CLASS['core_user']->get_lang('MCP_NOTES_USER'), 'PAGE_NUMBER' => on_page($log_count, $config['posts_per_page'], $start), 'PAGINATION' => $pagination['formated'], 'PAGINATION_ARRAY' => $pagination['array'], 'TOTAL_REPORTS' => $log_count == 1 ? $_CLASS['core_user']->get_lang('LIST_REPORT') : sprintf($_CLASS['core_user']->get_lang('LIST_REPORTS'), $log_count), 'USERNAME' => $userrow['username'], 'USER_COLOR' => !empty($userrow['user_colour']) ? $userrow['user_colour'] : '', 'RANK_TITLE' => $rank_title, 'JOINED' => $_CLASS['core_user']->format_date($userrow['user_reg_date']), 'POSTS' => $userrow['user_posts'] ? $userrow['user_posts'] : 0, 'WARNINGS' => @$userrow['user_warnings'] ? $userrow['user_warnings'] : 0, 'AVATAR_IMG' => $avatar_img, 'RANK_IMG' => $rank_img));
}
示例4: array
}
}
// Forum rules and subscription info
$s_watching_forum = array('link' => '', 'link_toggle' => '', 'title' => '', 'title_toggle' => '', 'is_watching' => false);
if ($config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_subscribe', $forum_id) || $user->data['user_id'] == ANONYMOUS)) {
$notify_status = isset($forum_data['notify_status']) ? $forum_data['notify_status'] : NULL;
watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status, $start, $forum_data['forum_name']);
}
$s_forum_rules = '';
gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']);
// Topic ordering options
$limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => $auth->acl_get('m_approve', $forum_id) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved', 's' => 'LOWER(t.topic_title)', 'v' => 't.topic_views');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);
// Limit topics to certain time frame, obtain correct topic count
if ($sort_days) {
$min_post_time = time() - $sort_days * 86400;
$sql = 'SELECT COUNT(topic_id) AS num_topics
FROM ' . TOPICS_TABLE . "\n\t\tWHERE forum_id = {$forum_id}\n\t\t\tAND (topic_last_post_time >= {$min_post_time}\n\t\t\t\tOR topic_type = " . POST_ANNOUNCE . '
OR topic_type = ' . POST_GLOBAL . ')
AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id);
$result = $db->sql_query($sql);
$topics_count = (int) $db->sql_fetchfield('num_topics');
$db->sql_freeresult($result);
if (isset($_POST['sort'])) {
$start = 0;
}
$sql_limit_time = "AND t.topic_last_post_time >= {$min_post_time}";
// Make sure we have information about day selection ready
示例5: main
//.........这里部分代码省略.........
$message = request_var('message', '', true);
// Sort keys
$sort_days = request_var('st', 0);
$sort_key = request_var('sk', 't');
$sort_dir = request_var('sd', 'd');
// Delete entries if requested and able
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) {
$where_sql = '';
if ($deletemark && $marked) {
$sql_in = array();
foreach ($marked as $mark) {
$sql_in[] = $mark;
}
$where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')';
unset($sql_in);
}
if ($where_sql || $deleteall) {
$sql = 'DELETE FROM ' . LOG_TABLE . '
WHERE log_type = ' . LOG_USERS . "\n\t\t\t\t\t\t\t{$where_sql}";
$db->sql_query($sql);
add_log('admin', 'LOG_CLEAR_USER', $user_row['username']);
}
}
if ($submit && $message) {
add_log('admin', 'LOG_USER_FEEDBACK', $user_row['username']);
add_log('user', $user_id, 'LOG_USER_GENERAL', $message);
trigger_error($user->lang['USER_FEEDBACK_ADDED'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
// Sorting
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
$sort_by_sql = array('u' => 'l.user_id', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
// Define where and sort sql for use in displaying logs
$sql_where = $sort_days ? time() - $sort_days * 86400 : 0;
$sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
// Grab log data
$log_data = array();
$log_count = 0;
view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);
$template->assign_vars(array('S_FEEDBACK' => true, 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start), 'PAGINATION' => generate_pagination($this->u_action . "&u={$user_id}&{$u_sort_param}", $log_count, $config['topics_per_page'], $start, true), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs')));
foreach ($log_data as $row) {
$template->assign_block_vars('log', array('USERNAME' => $row['username'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => nl2br($row['action']), 'ID' => $row['id']));
}
break;
case 'profile':
$cp = new custom_profile();
$cp_data = $cp_error = array();
$data = array();
$sql = 'SELECT lang_id
FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_iso = '" . $db->sql_escape($user_row['user_lang']) . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$user_row['iso_lang_id'] = $row['lang_id'];
if ($submit) {
$var_ary = array('icq' => (string) '', 'aim' => (string) '', 'msn' => (string) '', 'yim' => (string) '', 'jabber' => (string) '', 'website' => (string) '', 'location' => (string) '', 'occupation' => (string) '', 'interests' => (string) '', 'bday_day' => 0, 'bday_month' => 0, 'bday_year' => 0);
foreach ($var_ary as $var => $default) {
$data[$var] = in_array($var, array('location', 'occupation', 'interests')) ? request_var($var, $default, true) : ($data[$var] = request_var($var, $default));
}
$var_ary = array('icq' => array(array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 17), 'msn' => array('string', true, 5, 255), 'jabber' => array(array('string', true, 5, 255), array('match', true, '#^[a-z0-9\\.\\-_\\+]+?@(.*?\\.)*?[a-z0-9\\-_]+?\\.[a-z]{2,4}(/.*)?$#i')), 'yim' => array('string', true, 5, 255), 'website' => array(array('string', true, 12, 255), array('match', true, '#^http[s]?://(.*?\\.)*?[a-z0-9\\-]+\\.[a-z]{2,4}#i')), 'location' => array('string', true, 2, 255), 'occupation' => array('string', true, 2, 500), 'interests' => array('string', true, 2, 500), 'bday_day' => array('num', true, 1, 31), 'bday_month' => array('num', true, 1, 12), 'bday_year' => array('num', true, 1901, gmdate('Y', time())));
$error = validate_data($data, $var_ary);
// validate custom profile fields
$cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error);
if (sizeof($cp_error)) {
示例6: mcp_warn_list_view
/**
* Lists all users with warnings
*/
function mcp_warn_list_view($action)
{
global $phpEx, $phpbb_root_path, $config;
global $template, $db, $user, $auth;
$user->add_lang('memberlist');
$start = request_var('start', 0);
$st = request_var('st', 0);
$sk = request_var('sk', 'b');
$sd = request_var('sd', 'd');
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_WARNINGS']);
$sort_by_sql = array('a' => 'username_clean', 'b' => 'user_last_warning', 'c' => 'user_warnings');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
// Define where and sort sql for use in displaying logs
$sql_where = ($st) ? (time() - ($st * 86400)) : 0;
$sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
$users = array();
$user_count = 0;
view_warned_users($users, $user_count, $config['topics_per_page'], $start, $sql_where, $sql_sort);
foreach ($users as $row)
{
$template->assign_block_vars('user', array(
'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'USERNAME' => $row['username'],
'USERNAME_COLOUR' => ($row['user_colour']) ? '#' . $row['user_colour'] : '',
'U_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']),
'WARNING_TIME' => $user->format_date($row['user_last_warning']),
'WARNINGS' => $row['user_warnings'],
));
}
$template->assign_vars(array(
'U_POST_ACTION' => $this->u_action,
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
'S_SELECT_SORT_DIR' => $s_sort_dir,
'S_SELECT_SORT_KEY' => $s_sort_key,
'S_SELECT_SORT_DAYS' => $s_limit_days,
'PAGE_NUMBER' => on_page($user_count, $config['topics_per_page'], $start),
'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd"), $user_count, $config['topics_per_page'], $start),
'TOTAL_USERS' => ($user_count == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $user_count),
));
}
示例7: main
function main($id, $mode)
{
global $auth, $db, $user, $template;
global $config, $phpbb_root_path, $phpEx;
$user->add_lang('acp/common');
//-- mod start : Garage ----------------------------------------------------------------------------------------------------
//-- add
$user->add_lang('acp/garage');
//-- mod finish : Garage ---------------------------------------------------------------------------------------------------
$action = request_var('action', array('' => ''));
if (is_array($action)) {
list($action, ) = each($action);
} else {
$action = request_var('action', '');
}
// Set up general vars
$start = request_var('start', 0);
$deletemark = $action == 'del_marked' ? true : false;
$deleteall = $action == 'del_all' ? true : false;
$marked = request_var('mark', array(0));
// Sort keys
$sort_days = request_var('st', 0);
$sort_key = request_var('sk', 't');
$sort_dir = request_var('sd', 'd');
$this->tpl_name = 'mcp_logs';
$this->page_title = 'MCP_LOGS';
$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
$forum_list[] = 0;
$forum_id = $topic_id = 0;
switch ($mode) {
case 'front':
break;
case 'forum_logs':
$forum_id = request_var('f', 0);
if (!in_array($forum_id, $forum_list)) {
trigger_error('NOT_AUTHORISED');
}
$forum_list = array($forum_id);
break;
case 'topic_logs':
$topic_id = request_var('t', 0);
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql);
$forum_id = (int) $db->sql_fetchfield('forum_id');
$db->sql_freeresult($result);
if (!in_array($forum_id, $forum_list)) {
trigger_error('NOT_AUTHORISED');
}
$forum_list = array($forum_id);
break;
}
// Delete entries if requested and able
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) {
if (confirm_box(true)) {
if ($deletemark && sizeof($marked)) {
$sql = 'DELETE FROM ' . LOG_TABLE . '
WHERE log_type = ' . LOG_MOD . '
AND ' . $db->sql_in_set('forum_id', $forum_list) . '
AND ' . $db->sql_in_set('log_id', $marked);
$db->sql_query($sql);
add_log('admin', 'LOG_CLEAR_MOD');
} else {
if ($deleteall) {
$sql = 'DELETE FROM ' . LOG_TABLE . '
WHERE log_type = ' . LOG_MOD . '
AND ' . $db->sql_in_set('forum_id', $forum_list);
if ($mode == 'topic_logs') {
$sql .= ' AND topic_id = ' . $topic_id;
}
$db->sql_query($sql);
add_log('admin', 'LOG_CLEAR_MOD');
}
}
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('f' => $forum_id, 't' => $topic_id, 'start' => $start, 'delmarked' => $deletemark, 'delall' => $deleteall, 'mark' => $marked, 'st' => $sort_days, 'sk' => $sort_key, 'sd' => $sort_dir, 'i' => $id, 'mode' => $mode, 'action' => request_var('action', array('' => '')))));
}
}
// Sorting
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
$sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
// Define where and sort sql for use in displaying logs
$sql_where = $sort_days ? time() - $sort_days * 86400 : 0;
$sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
// Grab log data
$log_data = array();
$log_count = 0;
view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort);
$template->assign_vars(array('PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), 'TOTAL' => $log_count == 1 ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count), 'PAGINATION' => generate_pagination($this->u_action . "&{$u_sort_param}", $log_count, $config['topics_per_page'], $start), 'L_TITLE' => $user->lang['MCP_LOGS'], 'U_POST_ACTION' => $this->u_action, 'S_CLEAR_ALLOWED' => $auth->acl_get('a_clearlogs') ? true : false, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_LOGS' => $log_count > 0));
foreach ($log_data as $row) {
$data = array();
$checks = array('viewtopic', 'viewforum');
foreach ($checks as $check) {
if (isset($row[$check]) && $row[$check]) {
$data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
}
//.........这里部分代码省略.........
示例8: base
/**
* Index Controller
* Route: gallery/search
*
* @return Symfony\Component\HttpFoundation\Response A Symfony Response object
*/
public function base()
{
$search_id = $this->request->variable('search_id', '');
$image_id = $this->request->variable('image_id', 0);
$submit = $this->request->variable('submit', false);
$keywords = utf8_normalize_nfc($this->request->variable('keywords', '', true));
$add_keywords = utf8_normalize_nfc($this->request->variable('add_keywords', '', true));
$username = $this->request->variable('username', '', true);
$user_id = $this->request->variable('user_id', array(0));
$search_terms = $this->request->variable('terms', 'all');
$search_album = $this->request->variable('aid', array(0));
$search_child = $this->request->variable('sc', true);
$search_fields = $this->request->variable('sf', 'all');
$sort_days = $this->request->variable('st', 0);
$sort_key = $this->request->variable('sk', 't');
$sort_dir = $this->request->variable('sd', 'd');
$start = $this->request->variable('start', 0);
$this->user->add_lang_ext('phpbbgallery/core', array('gallery'));
$this->user->add_lang('search');
/**
* Build the sort options
*/
$limit_days = array(0 => $this->user->lang['ALL_IMAGES'], 1 => $this->user->lang['1_DAY'], 7 => $this->user->lang['7_DAYS'], 14 => $this->user->lang['2_WEEKS'], 30 => $this->user->lang['1_MONTH'], 90 => $this->user->lang['3_MONTHS'], 180 => $this->user->lang['6_MONTHS'], 365 => $this->user->lang['1_YEAR']);
$sort_by_text = array('t' => $this->user->lang['TIME'], 'n' => $this->user->lang['IMAGE_NAME'], 'u' => $this->user->lang['SORT_USERNAME'], 'vc' => $this->user->lang['GALLERY_VIEWS']);
$sort_by_sql = array('t' => 'image_time', 'n' => 'image_name_clean', 'u' => 'image_username_clean', 'vc' => 'image_view_count');
if ($this->gallery_config->get('allow_rates')) {
$sort_by_text['ra'] = $this->user->lang['RATING'];
$sort_by_sql['ra'] = 'image_rate_points';
//@todo: (phpbb_gallery_contest::$mode == phpbb_gallery_contest::MODE_SUM) ? 'image_rate_points' : 'image_rate_avg';
$sort_by_text['r'] = $this->user->lang['RATES_COUNT'];
$sort_by_sql['r'] = 'image_rates';
}
if ($this->gallery_config->get('allow_comments')) {
$sort_by_text['c'] = $this->user->lang['COMMENTS'];
$sort_by_sql['c'] = 'image_comments';
$sort_by_text['lc'] = $this->user->lang['NEW_COMMENT'];
$sort_by_sql['lc'] = 'image_last_comment';
}
$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
$sql_order = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
// We will build SQL array and then build query (easely change count with rq)
$sql_array = $sql_where = array();
$sql_array['FROM'] = array($this->images_table => 'i');
$sql_array['ORDER_BY'] = $sql_order;
$sql_array['GROUP_BY'] = $sort_by_sql[$sort_key];
if ($keywords || $username || $user_id || $search_id || $submit) {
// Let's resolve username to user id ... or array of them.
if ($username) {
if (strpos($username, '*') !== false && utf8_strlen(str_replace(array('*', '%'), '', $username)) < $this->config['min_search_author_chars']) {
trigger_error(sprintf($this->user->lang['TOO_FEW_AUTHOR_CHARS'], $this->config['min_search_author_chars']));
}
$username_parsed = strpos($username, '*') !== false ? ' username_clean ' . $this->db->sql_like_expression(str_replace('*', $this->db->get_any_char(), utf8_clean_string($this->db->sql_escape($username)))) : ' username_clean = \'' . $this->db->sql_escape(utf8_clean_string($username)) . '\'';
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
WHERE ' . $username_parsed . '
AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
$result = $this->db->sql_query_limit($sql, 100);
while ($row = $this->db->sql_fetchrow($result)) {
$user_id_ary[] = (int) $row['user_id'];
}
$this->db->sql_freeresult($result);
$user_id_ary[] = (int) ANONYMOUS;
$user_id = $user_id_ary;
}
if (!empty($user_id)) {
$sql_where[] = $this->db->sql_in_set('i.image_user_id', $user_id);
}
// if we search in an existing search result just add the additional keywords. But we need to use "all search terms"-mode
// so we can keep the old keywords in their old mode, but add the new ones as required words
if ($add_keywords) {
if ($search_terms == 'all') {
$keywords .= ' ' . $add_keywords;
} else {
$search_terms = 'all';
$keywords = preg_replace('#\\s+#u', ' |', $keywords) . ' ' . $add_keywords;
}
}
$keywords_ary = $keywords ? explode(' ', $keywords) : array();
// pre-made searches
$sql = $field = $l_search_title = $search_results = '';
$total_match_count = 0;
$sql_limit = 0;
$search_query = '';
$matches = array('i.image_name', 'i.image_desc');
if (!sizeof($keywords_ary) && !sizeof($user_id_ary)) {
trigger_error('NO_SEARCH_RESULTS');
}
$matches = array('i.image_name', 'i.image_desc');
foreach ($keywords_ary as $word) {
$match_search_query = '';
foreach ($matches as $match) {
$match_search_query .= ($match_search_query ? ' OR ' : '') . 'LOWER(' . $match . ') ';
//.........这里部分代码省略.........
示例9: mcp_warn_list_view
/**
* Lists all users with warnings
*/
function mcp_warn_list_view($action)
{
global $phpEx, $phpbb_root_path, $config, $phpbb_container;
global $template, $db, $user, $auth, $request;
$user->add_lang('memberlist');
$pagination = $phpbb_container->get('pagination');
$start = $request->variable('start', 0);
$st = $request->variable('st', 0);
$sk = $request->variable('sk', 'b');
$sd = $request->variable('sd', 'd');
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_WARNINGS']);
$sort_by_sql = array('a' => 'username_clean', 'b' => 'warning_time', 'c' => 'user_warnings');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
// Define where and sort sql for use in displaying logs
$sql_where = $st ? time() - $st * 86400 : 0;
$sql_sort = $sort_by_sql[$sk] . ' ' . ($sd == 'd' ? 'DESC' : 'ASC');
$users = array();
$user_count = 0;
$this->view_warnings_list($users, $user_count, $config['topics_per_page'], $start, $sql_where, $sql_sort);
foreach ($users as $row) {
$template->assign_block_vars('user', array('U_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $row['user_id']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => $row['username'], 'USERNAME_COLOUR' => $row['user_colour'] ? '#' . $row['user_colour'] : '', 'U_USER' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $row['user_id']), 'WARNING_TIME' => $row['warning_end'] ? $user->format_date($row['warning_end']) : $user->lang['PERMANENT'], 'WARNINGS' => $user->format_date($row['warning_time']), 'WARNING_STATUS' => $row['warning_status'] ? true : false, 'WARNING_TYPE' => $row['warning_type'] == BAN ? $user->lang['BAN'] : $user->lang['WARNING'], 'U_WARNING_POST_URL' => $row['post_id'] ? append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'p=' . $row['post_id'] . '#p' . $row['post_id']) : '', 'U_EDIT' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=\\rxu\\AdvancedWarnings\\mcp\\warnings_module&mode=' . ($row['post_id'] ? 'warn_post&p=' . $row['post_id'] : 'warn_user') . '&u=' . $row['user_id'] . '&warn_id=' . $row['warning_id']) : ''));
}
$base_url = append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=\rxu\\AdvancedWarnings\\mcp\\warnings_module&mode=list&st={$st}&sk={$sk}&sd={$sd}");
if ($user_count) {
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $user_count, $config['topics_per_page'], $start);
}
$template->assign_vars(array('U_POST_ACTION' => $this->u_action, 'S_CLEAR_ALLOWED' => $auth->acl_get('a_clearlogs') ? true : false, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'PAGE_NUMBER' => $user_count ? $pagination->on_page($user_count, $config['topics_per_page'], $start) : '', 'TOTAL_WARNINGS' => $user->lang('LIST_WARNINGS', (int) $user_count)));
}
示例10: main
function main($id, $mode)
{
global $db, $user, $auth, $template, $cache;
global $config, $phpbb_root_path, $phpEx;
$user->add_lang(array('acp/board', 'mods/asacp', 'mods/acp_asacp', 'install', 'acp/common'));
include $phpbb_root_path . 'antispam/acp_functions.' . $phpEx;
$error = $notify = array();
$submit = isset($_POST['submit']) ? true : false;
$action = request_var('action', '');
add_form_key('as_acp');
if ($submit && !check_form_key('as_acp')) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$error = $options = array();
switch ($mode) {
case 'ip_search':
$this->tpl_name = 'antispam/mcp_asacp';
$this->page_title = 'ASACP_IP_SEARCH';
$ip = request_var('ip', '');
$type = request_var('type', '');
if ($ip) {
asacp_display_ip_search($type, $ip, $this->u_action . '&ip=' . $ip, request_var('start', 0));
}
$template->assign_vars(array('L_TITLE' => $user->lang['ASACP_IP_SEARCH'], 'L_TITLE_EXPLAIN' => $user->lang['ASACP_IP_SEARCH_EXPLAIN'], 'S_DATA_OUTPUT' => true, 'S_DISPLAY_IP_INPUT' => $ip ? false : true, 'U_BACK' => $type ? $this->u_action . '&ip=' . $ip : false, 'U_BACK_NONE' => $this->u_action));
break;
// case 'ip_search' :
// case 'ip_search' :
case 'log':
case 'flag':
$this->tpl_name = 'mcp_logs';
if ($mode == 'log') {
$this->page_title = $user->lang['ASACP_SPAM_LOG'];
} else {
$this->page_title = $user->lang['ASACP_FLAG_LOG'];
// Reset the user flag new notification
if ($user->data['user_flag_new']) {
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_flag_new = 0 WHERE user_id = ' . $user->data['user_id']);
}
}
$user->add_lang('mcp');
// Set up general vars
$start = request_var('start', 0);
$action = request_var('action', array('' => ''));
if (is_array($action)) {
list($action, ) = each($action);
} else {
$action = request_var('action', '');
}
$deletemark = !empty($_POST['delmarked']) || $action == 'del_marked' ? true : false;
$deleteall = !empty($_POST['delall']) || $action == 'del_all' ? true : false;
$marked = request_var('mark', array(0));
// Sort keys
$sort_days = request_var('st', 0);
$sort_key = request_var('sk', 't');
$sort_dir = request_var('sd', 'd');
$keywords = utf8_normalize_nfc(request_var('keywords', '', true));
$keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
// Delete entries if requested and able
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) {
if (confirm_box(true)) {
clear_spam_log($mode, $deletemark ? false : $deleteall, $marked, $keywords);
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('start' => $start, 'delmarked' => $deletemark, 'delall' => $deleteall, 'mark' => $marked, 'st' => $sort_days, 'sk' => $sort_key, 'sd' => $sort_dir, 'keywords' => $keywords, 'i' => $id, 'mode' => $mode, 'action' => $this->u_action)));
}
}
// Sorting
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('t' => $user->lang['SORT_DATE'], 'u' => $user->lang['SORT_USERNAME'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
$sort_by_sql = array('t' => 'l.log_time', 'u' => 'u.username_clean', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
// Define where and sort sql for use in displaying logs
$sql_days = $sort_days ? time() - $sort_days * 86400 : 0;
$sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
// Grab log data
$log_data = array();
$log_count = 0;
if ($mode == 'log') {
view_spam_log('spam', $log_data, $log_count, $config['topics_per_page'], $start, '', $sql_days, $sql_sort, $keywords);
} else {
view_spam_log('flag', $log_data, $log_count, $config['topics_per_page'], $start, '', $sql_days, $sql_sort, $keywords);
}
$template->assign_vars(array('L_TITLE' => $this->page_title, 'L_EXPLAIN' => '', 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), 'PAGINATION' => generate_pagination($this->u_action . "&{$u_sort_param}{$keywords_param}", $log_count, $config['topics_per_page'], $start), 'TOTAL' => $log_count == 1 ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), 'S_CLEAR_ALLOWED' => $auth->acl_get('a_clearlogs'), 'S_KEYWORDS' => $keywords, 'S_LOGS' => $log_count > 0 ? true : false));
foreach ($log_data as $row) {
$template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'REPORTEE_USERNAME' => $row['reportee_username'] && $row['user_id'] != $row['reportee_id'] ? $row['reportee_username_full'] : '', 'IP' => '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&mode=ip_search&ip={$row['ip']}") . '">' . $row['ip'] . '</a>', 'DATE' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'DATA' => sizeof($row['data']) ? @vsprintf($user->lang[$row['operation'] . '_DATA'], $row['data']) : '', 'ID' => $row['id']));
}
break;
//case 'log' :
//case 'flag' :
//case 'log' :
//case 'flag' :
case 'flag_list':
$user->add_lang('memberlist');
$this->tpl_name = 'antispam/mcp_asacp';
$this->page_title = 'ASACP_FLAG_LIST';
$start = request_var('start', 0);
$limit = request_var('limit', 20);
$db->sql_query('SELECT count(user_id) as cnt FROM ' . USERS_TABLE . ' WHERE user_flagged = 1');
$total = $db->sql_fetchfield('cnt');
$sql = 'SELECT user_id, username, user_colour, user_ip, user_posts FROM ' . USERS_TABLE . ' WHERE user_flagged = 1';
//.........这里部分代码省略.........
示例11: base
/**
* Image Controller
* Route: gallery/image_id/{image_id}
*
* @param int $image_id Image ID
* @return Symfony\Component\HttpFoundation\Response A Symfony Response object
*/
public function base($image_id, $page = 0)
{
$this->user->add_lang_ext('phpbbgallery/core', array('gallery'));
try {
$sql = 'SELECT *
FROM ' . $this->table_images . '
WHERE image_id = ' . (int) $image_id;
$result = $this->db->sql_query($sql);
$this->data = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if (!$this->data) {
// Image does not exist
throw new \OutOfBoundsException('INVALID_IMAGE');
}
$this->loader->load($this->data['image_album_id']);
} catch (\Exception $e) {
return $this->error($e->getMessage(), 404);
}
$album_id = (int) $this->data['image_album_id'];
$album_data = $this->loader->get($album_id);
$this->check_permissions($album_id, $album_data['album_user_id'], $this->data['image_status'], $album_data['album_auth_access']);
$this->display->generate_navigation($album_data);
if (!$this->user->data['is_bot'] && isset($this->user->data['session_page']) && (strpos($this->user->data['session_page'], '&image_id=' . $image_id) === false || isset($this->user->data['session_created']))) {
$sql = 'UPDATE ' . $this->table_images . '
SET image_view_count = image_view_count + 1
WHERE image_id = ' . $image_id;
$this->db->sql_query($sql);
}
// Do stuff here
$page_title = $this->data['image_name'];
if ($page > 1) {
$page_title .= ' - ' . $this->user->lang('PAGE_TITLE_NUMBER', $page);
}
$s_allowed_delete = $s_allowed_edit = $s_allowed_status = false;
if (($this->gallery_auth->acl_check('m_', $album_id, $album_data['album_user_id']) || $this->data['image_user_id'] == $this->user->data['user_id']) && $this->user->data['user_id'] != ANONYMOUS) {
//$s_user_allowed = (($this->data['image_user_id'] == $this->user->data['user_id']) && ($album_data['album_status'] != phpbb_ext_gallery_core_album::STATUS_LOCKED));
$s_user_allowed = $this->data['image_user_id'] == $this->user->data['user_id'] && $album_data['album_status'] != 1;
$s_allowed_delete = $this->gallery_auth->acl_check('i_delete', $album_id, $album_data['album_user_id']) && $s_user_allowed || $this->gallery_auth->acl_check('m_delete', $album_id, $album_data['album_user_id']);
$s_allowed_edit = $this->gallery_auth->acl_check('i_edit', $album_id, $album_data['album_user_id']) && $s_user_allowed || $this->gallery_auth->acl_check('m_edit', $album_id, $album_data['album_user_id']);
$s_quick_mod = $s_allowed_delete || $s_allowed_edit || $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']) || $this->gallery_auth->acl_check('m_move', $album_id, $album_data['album_user_id']);
$this->user->add_lang_ext('phpbbgallery/core', 'gallery_mcp');
$this->template->assign_vars(array('S_MOD_ACTION' => $this->helper->route('phpbbgallery_moderate_image', array('image_id' => $image_id)), 'S_QUICK_MOD' => $s_quick_mod, 'S_QM_MOVE' => $this->gallery_auth->acl_check('m_move', $album_id, $album_data['album_user_id']), 'S_QM_EDIT' => $s_allowed_edit, 'S_QM_DELETE' => $s_allowed_delete, 'S_QM_REPORT' => $this->gallery_auth->acl_check('m_report', $album_id, $album_data['album_user_id']), 'S_QM_STATUS' => $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']), 'S_IMAGE_REPORTED' => $this->data['image_reported'] ? true : false, 'U_IMAGE_REPORTED' => $this->data['image_reported'] ? $this->helper->route('phpbbgallery_moderate_image', array('image_id' => $image_id)) : '', 'S_STATUS_APPROVED' => $this->data['image_status'] == \phpbbgallery\core\image\image::STATUS_APPROVED, 'S_STATUS_UNAPPROVED' => $this->data['image_status'] == \phpbbgallery\core\image\image::STATUS_UNAPPROVED, 'S_STATUS_LOCKED' => $this->data['image_status'] == \phpbbgallery\core\image\image::STATUS_LOCKED));
}
$image_desc = generate_text_for_display($this->data['image_desc'], $this->data['image_desc_uid'], $this->data['image_desc_bitfield'], 7);
// Let's see if we can get next end prev
$sort_key = $this->request->variable('sk', $album_data['album_sort_key'] ? $album_data['album_sort_key'] : $this->config['phpbb_gallery_default_sort_key']);
$sort_dir = $this->request->variable('sd', $album_data['album_sort_dir'] ? $album_data['album_sort_dir'] : $this->config['phpbb_gallery_default_sort_dir']);
if (in_array($sort_key, array('r', 'ra'))) {
$sql_help_sort = ', image_id ' . ($sort_dir == 'd' ? 'ASC' : 'DESC');
} else {
$sql_help_sort = ', image_id ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
}
$limit_days = array();
$sort_by_text = array('t' => $this->user->lang['TIME'], 'n' => $this->user->lang['IMAGE_NAME'], 'vc' => $this->user->lang['GALLERY_VIEWS'], 'u' => $this->user->lang['SORT_USERNAME']);
$sort_by_sql = array('t' => 'image_time', 'n' => 'image_name_clean', 'vc' => 'image_view_count', 'u' => 'image_username_clean');
if ($this->config['phpbb_gallery_allow_rates']) {
$sort_by_text['ra'] = $this->user->lang['RATING'];
$sort_by_sql['ra'] = 'image_rate_points';
$sort_by_text['r'] = $this->user->lang['RATES_COUNT'];
$sort_by_sql['r'] = 'image_rates';
}
if ($this->config['phpbb_gallery_allow_comments']) {
$sort_by_text['c'] = $this->user->lang['COMMENTS'];
$sort_by_sql['c'] = 'image_comments';
$sort_by_text['lc'] = $this->user->lang['NEW_COMMENT'];
$sort_by_sql['lc'] = 'image_last_comment';
}
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
$sql_sort_order .= $sql_help_sort;
// Let's see if there is prieveus image
$sql = 'SELECT *
FROM ' . $this->table_images . '
WHERE image_album_id = ' . (int) $album_id . "\n\t\t\t\tAND image_status <> 3\n\t\t\tORDER BY {$sql_sort_order}" . $sql_help_sort;
$result = $this->db->sql_query($sql);
$images_array = array();
while ($row = $this->db->sql_fetchrow($result)) {
$images_array[] = $row;
}
$cur = 0;
foreach ($images_array as $id => $var) {
if ($var['image_id'] == $image_id) {
$cur = $id;
}
}
$next = $prev = false;
if (count($images_array) > $cur + 1) {
$next = array('image_id' => $images_array[$cur + 1]['image_id'], 'image_name' => $images_array[$cur + 1]['image_name']);
}
if ($cur > 0) {
$prev = array('image_id' => $images_array[$cur - 1]['image_id'], 'image_name' => $images_array[$cur - 1]['image_name']);
}
$this->db->sql_freeresult($result);
//.........这里部分代码省略.........
示例12: main
function main($id, $mode)
{
global $db, $user, $auth, $template, $cache, $phpbb_container;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
global $request;
$user->add_lang('mcp');
// Set up general vars
$action = request_var('action', '');
$forum_id = request_var('f', 0);
$topic_id = request_var('t', 0);
$start = request_var('start', 0);
$deletemark = $request->variable('delmarked', false, false, \phpbb\request\request_interface::POST);
$deleteall = $request->variable('delall', false, false, \phpbb\request\request_interface::POST);
$marked = request_var('mark', array(0));
// Sort keys
$sort_days = request_var('st', 0);
$sort_key = request_var('sk', 't');
$sort_dir = request_var('sd', 'd');
$this->tpl_name = 'acp_logs';
$this->log_type = constant('LOG_' . strtoupper($mode));
$pagination = $phpbb_container->get('pagination');
// Delete entries if requested and able
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) {
if (confirm_box(true)) {
$conditions = array();
if ($deletemark && sizeof($marked)) {
$conditions['log_id'] = array('IN' => $marked);
}
if ($deleteall) {
if ($sort_days) {
$conditions['log_time'] = array('>=', time() - $sort_days * 86400);
}
$keywords = utf8_normalize_nfc(request_var('keywords', '', true));
$conditions['keywords'] = $keywords;
}
$phpbb_log = $phpbb_container->get('log');
$phpbb_log->delete($mode, $conditions);
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('f' => $forum_id, 'start' => $start, 'delmarked' => $deletemark, 'delall' => $deleteall, 'mark' => $marked, 'st' => $sort_days, 'sk' => $sort_key, 'sd' => $sort_dir, 'i' => $id, 'mode' => $mode, 'action' => $action)));
}
}
// Sorting
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
$sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
// Define where and sort sql for use in displaying logs
$sql_where = $sort_days ? time() - $sort_days * 86400 : 0;
$sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
$keywords = utf8_normalize_nfc(request_var('keywords', '', true));
$keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
$l_title = $user->lang['ACP_' . strtoupper($mode) . '_LOGS'];
$l_title_explain = $user->lang['ACP_' . strtoupper($mode) . '_LOGS_EXPLAIN'];
$this->page_title = $l_title;
// Define forum list if we're looking @ mod logs
if ($mode == 'mod') {
$forum_box = '<option value="0">' . $user->lang['ALL_FORUMS'] . '</option>' . make_forum_select($forum_id);
$template->assign_vars(array('S_SHOW_FORUMS' => true, 'S_FORUM_BOX' => $forum_box));
}
// Grab log data
$log_data = array();
$log_count = 0;
$start = view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort, $keywords);
$base_url = $this->u_action . "&{$u_sort_param}{$keywords_param}";
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
$template->assign_vars(array('L_TITLE' => $l_title, 'L_EXPLAIN' => $l_title_explain, 'U_ACTION' => $this->u_action . "&{$u_sort_param}{$keywords_param}&start={$start}", 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), 'S_KEYWORDS' => $keywords));
foreach ($log_data as $row) {
$data = array();
$checks = array('viewtopic', 'viewlogs', 'viewforum');
foreach ($checks as $check) {
if (isset($row[$check]) && $row[$check]) {
$data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
}
}
$template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'REPORTEE_USERNAME' => $row['reportee_username'] && $row['user_id'] != $row['reportee_id'] ? $row['reportee_username_full'] : '', 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'DATA' => sizeof($data) ? implode(' | ', $data) : '', 'ID' => $row['id']));
}
}
示例13: get_pm_from
/**
* Get Messages from folder/user
*/
function get_pm_from($folder_id, $folder, $user_id)
{
global $user, $db, $template, $config, $auth, $phpbb_container, $phpbb_root_path, $phpEx, $request;
$start = $request->variable('start', 0);
// Additional vars later, pm ordering is mostly different from post ordering. :/
$sort_days = $request->variable('st', 0);
$sort_key = $request->variable('sk', 't');
$sort_dir = $request->variable('sd', 'd');
/* @var $pagination \phpbb\pagination */
$pagination = $phpbb_container->get('pagination');
// PM ordering options
$limit_days = array(0 => $user->lang['ALL_MESSAGES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
// No sort by Author for sentbox/outbox (already only author available)
// Also, sort by msg_id for the time - private messages are not as prone to errors as posts are.
if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) {
$sort_by_text = array('t' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
$sort_by_sql = array('t' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time'));
} else {
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
$sort_by_sql = array('a' => array('u.username_clean', 'p.message_time'), 't' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time'));
}
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
$folder_sql = 't.folder_id = ' . (int) $folder_id;
// Limit pms to certain time frame, obtain correct pm count
if ($sort_days) {
$min_post_time = time() - $sort_days * 86400;
if (isset($_POST['sort'])) {
$start = 0;
}
$sql = 'SELECT COUNT(t.msg_id) AS pm_count
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . " p\n\t\t\tWHERE {$folder_sql}\n\t\t\t\tAND t.user_id = {$user_id}\n\t\t\t\tAND t.msg_id = p.msg_id\n\t\t\t\tAND p.message_time >= {$min_post_time}";
$result = $db->sql_query_limit($sql, 1);
$pm_count = (int) $db->sql_fetchfield('pm_count');
$db->sql_freeresult($result);
$sql_limit_time = "AND p.message_time >= {$min_post_time}";
} else {
$pm_count = !empty($folder[$folder_id]['num_messages']) ? $folder[$folder_id]['num_messages'] : 0;
$sql_limit_time = '';
}
$base_url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&mode=view&action=view_folder&f={$folder_id}&{$u_sort_param}");
$start = $pagination->validate_start($start, $config['topics_per_page'], $pm_count);
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start);
$template->assign_vars(array('TOTAL_MESSAGES' => $user->lang('VIEW_PM_MESSAGES', (int) $pm_count), 'POST_IMG' => !$auth->acl_get('u_sendpm') ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'), 'S_NO_AUTH_SEND_MESSAGE' => !$auth->acl_get('u_sendpm'), 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_TOPIC_ICONS' => $config['enable_pm_icons'] ? true : false, 'U_POST_NEW_TOPIC' => $auth->acl_get('u_sendpm') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=compose') : '', 'S_PM_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&mode=view&action=view_folder&f={$folder_id}" . ($start !== 0 ? "&start={$start}" : ''))));
// Grab all pm data
$rowset = $pm_list = array();
// If the user is trying to reach late pages, start searching from the end
$store_reverse = false;
$sql_limit = $config['topics_per_page'];
if ($start > $pm_count / 2) {
$store_reverse = true;
// Select the sort order
$direction = $sort_dir == 'd' ? 'ASC' : 'DESC';
$sql_limit = $pagination->reverse_limit($start, $sql_limit, $pm_count);
$sql_start = $pagination->reverse_start($start, $sql_limit, $pm_count);
} else {
// Select the sort order
$direction = $sort_dir == 'd' ? 'DESC' : 'ASC';
$sql_start = $start;
}
// Sql sort order
if (is_array($sort_by_sql[$sort_key])) {
$sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
} else {
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
}
$sql = 'SELECT t.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour, p.message_reported
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u\n\t\tWHERE t.user_id = {$user_id}\n\t\t\tAND p.author_id = u.user_id\n\t\t\tAND {$folder_sql}\n\t\t\tAND t.msg_id = p.msg_id\n\t\t\t{$sql_limit_time}\n\t\tORDER BY {$sql_sort_order}";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
$pm_reported = array();
while ($row = $db->sql_fetchrow($result)) {
$rowset[$row['msg_id']] = $row;
$pm_list[] = $row['msg_id'];
if ($row['message_reported']) {
$pm_reported[] = $row['msg_id'];
}
}
$db->sql_freeresult($result);
// Fetch the report_ids, if there are any reported pms.
if (!empty($pm_reported) && $auth->acl_getf_global('m_report')) {
$sql = 'SELECT pm_id, report_id
FROM ' . REPORTS_TABLE . '
WHERE report_closed = 0
AND ' . $db->sql_in_set('pm_id', $pm_reported);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$rowset[$row['pm_id']]['report_id'] = $row['report_id'];
}
$db->sql_freeresult($result);
}
$pm_list = $store_reverse ? array_reverse($pm_list) : $pm_list;
return array('pm_count' => $pm_count, 'pm_list' => $pm_list, 'rowset' => $rowset);
}
示例14: main
function main($id, $mode)
{
global $auth, $db, $user, $template, $request;
global $config, $phpbb_container, $phpbb_log;
$user->add_lang('acp/common');
$action = $request->variable('action', array('' => ''));
if (is_array($action)) {
list($action, ) = each($action);
} else {
$action = $request->variable('action', '');
}
// Set up general vars
$start = $request->variable('start', 0);
$deletemark = $action == 'del_marked' ? true : false;
$deleteall = $action == 'del_all' ? true : false;
$marked = $request->variable('mark', array(0));
// Sort keys
$sort_days = $request->variable('st', 0);
$sort_key = $request->variable('sk', 't');
$sort_dir = $request->variable('sd', 'd');
$this->tpl_name = 'mcp_logs';
$this->page_title = 'MCP_LOGS';
/* @var $pagination \phpbb\pagination */
$pagination = $phpbb_container->get('pagination');
$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
$forum_list[] = 0;
$forum_id = $topic_id = 0;
switch ($mode) {
case 'front':
break;
case 'forum_logs':
$forum_id = $request->variable('f', 0);
if (!in_array($forum_id, $forum_list)) {
send_status_line(403, 'Forbidden');
trigger_error('NOT_AUTHORISED');
}
$forum_list = array($forum_id);
break;
case 'topic_logs':
$topic_id = $request->variable('t', 0);
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql);
$forum_id = (int) $db->sql_fetchfield('forum_id');
$db->sql_freeresult($result);
if (!in_array($forum_id, $forum_list)) {
send_status_line(403, 'Forbidden');
trigger_error('NOT_AUTHORISED');
}
$forum_list = array($forum_id);
break;
}
// Delete entries if requested and able
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) {
if (confirm_box(true)) {
if ($deletemark && sizeof($marked)) {
$conditions = array('forum_id' => array('IN' => $forum_list), 'log_id' => array('IN' => $marked));
$phpbb_log->delete('mod', $conditions);
} else {
if ($deleteall) {
$keywords = $request->variable('keywords', '', true);
$conditions = array('forum_id' => array('IN' => $forum_list), 'keywords' => $keywords);
if ($sort_days) {
$conditions['log_time'] = array('>=', time() - $sort_days * 86400);
}
if ($mode == 'topic_logs') {
$conditions['topic_id'] = $topic_id;
}
$phpbb_log->delete('mod', $conditions);
}
}
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('f' => $forum_id, 't' => $topic_id, 'start' => $start, 'delmarked' => $deletemark, 'delall' => $deleteall, 'mark' => $marked, 'st' => $sort_days, 'sk' => $sort_key, 'sd' => $sort_dir, 'i' => $id, 'mode' => $mode, 'action' => $request->variable('action', array('' => '')))));
}
}
// Sorting
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
$sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
// Define where and sort sql for use in displaying logs
$sql_where = $sort_days ? time() - $sort_days * 86400 : 0;
$sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
$keywords = $request->variable('keywords', '', true);
$keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
// Grab log data
$log_data = array();
$log_count = 0;
$start = view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords);
$base_url = $this->u_action . "&{$u_sort_param}{$keywords_param}";
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
$template->assign_vars(array('TOTAL' => $user->lang('TOTAL_LOGS', (int) $log_count), 'L_TITLE' => $user->lang['MCP_LOGS'], 'U_POST_ACTION' => $this->u_action . "&{$u_sort_param}{$keywords_param}&start={$start}", 'S_CLEAR_ALLOWED' => $auth->acl_get('a_clearlogs') ? true : false, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_LOGS' => $log_count > 0, 'S_KEYWORDS' => $keywords));
foreach ($log_data as $row) {
$data = array();
$checks = array('viewpost', 'viewtopic', 'viewforum');
foreach ($checks as $check) {
if (isset($row[$check]) && $row[$check]) {
$data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
//.........这里部分代码省略.........
示例15: view
/**
* View controller for display a category
*
* @param int $cat_id The category ID
* @param int $page Page number taken from the URL
* @param int $sort_days Specifies the maximum amount of days a link may be old
* @param string $sort_key is the key of $sort_by_sql for the selected sorting: a|t|r|s|v|p
* @param string $sort_dir is either a or d representing ASC and DESC (ascending|descending)
* @param string $mode watch|unwatch
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
* @throws \phpbb\exception\http_exception
*/
public function view($cat_id, $page, $sort_days, $sort_key, $sort_dir, $mode = '')
{
if (false === $this->categorie->get($cat_id)) {
throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_CATS');
}
$start = ($page - 1) * $this->config['dir_show'];
$default_sort_days = 0;
$default_sort_key = (string) substr($this->config['dir_default_order'], 0, 1);
$default_sort_dir = (string) substr($this->config['dir_default_order'], 2);
$sort_days = !$sort_days ? $this->request->variable('st', $default_sort_days) : $sort_days;
$sort_key = !$sort_key ? $this->request->variable('sk', $default_sort_key) : $sort_key;
$sort_dir = !$sort_dir ? $this->request->variable('sd', $default_sort_dir) : $sort_dir;
$link_list = $rowset = array();
// Categorie ordering options
$limit_days = array(0 => $this->user->lang['SEE_ALL'], 1 => $this->user->lang['1_DAY'], 7 => $this->user->lang['7_DAYS'], 14 => $this->user->lang['2_WEEKS'], 30 => $this->user->lang['1_MONTH'], 90 => $this->user->lang['3_MONTHS'], 180 => $this->user->lang['6_MONTHS'], 365 => $this->user->lang['1_YEAR']);
$sort_by_text = array('a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME'], 'r' => $this->user->lang['DIR_COMMENTS_ORDER'], 's' => $this->user->lang['DIR_NAME_ORDER'], 'v' => $this->user->lang['DIR_NB_CLICKS_ORDER']);
$sort_by_sql = array('a' => 'u.username_clean', 't' => array('l.link_time', 'l.link_id'), 'r' => 'l.link_comment', 's' => 'LOWER(l.link_name)', 'v' => 'l.link_view');
if ($this->config['dir_activ_pagerank']) {
$sort_by_text['p'] = $this->user->lang['DIR_PR_ORDER'];
$sort_by_sql['p'] = 'l.link_pagerank';
}
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);
$u_sort_param = $sort_days === $default_sort_days && $sort_key == $default_sort_key && $sort_dir == $default_sort_dir ? array() : array('sort_days' => $sort_days, 'sort_key' => $sort_key, 'sort_dir' => $sort_dir);
// Are we watching this categorie?
$s_watching_categorie = array('link' => '', 'link_toggle' => '', 'title' => '', 'title_toggle' => '', 'is_watching' => false);
if ($this->config['email_enable'] && $this->user->data['is_registered']) {
$notify_status = isset($this->categorie->data['notify_status']) ? $this->categorie->data['notify_status'] : null;
if ($message = $this->categorie->watch_categorie($mode, $s_watching_categorie, $this->user->data['user_id'], $cat_id, $notify_status)) {
return $this->helper->message($message);
}
}
// A deadline has been selected
if ($sort_days) {
$min_post_time = time() - $sort_days * 86400;
$sql = 'SELECT COUNT(link_id) AS nb_links
FROM ' . DIR_LINK_TABLE . '
WHERE link_cat = ' . (int) $cat_id . '
AND link_time >= ' . $min_post_time;
$result = $this->db->sql_query($sql);
$nb_links = (int) $this->db->sql_fetchfield('nb_links');
$this->db->sql_freeresult($result);
if ($this->request->is_set_post('sort')) {
$start = 0;
}
$sql_limit_time = " AND l.link_time >= {$min_post_time}";
} else {
$sql_limit_time = '';
$nb_links = (int) $this->categorie->data['cat_links'];
}
// Make sure $start is set to the last page if it exceeds the amount
$start = $this->pagination->validate_start($start, $this->config['dir_show'], $nb_links);
// Build navigation links
$this->categorie->generate_dir_nav($this->categorie->data);
// Jumpbox
$this->categorie->make_cat_jumpbox();
$base_url = array('routes' => 'ernadoo_phpbbdirectory_page_controller', 'params' => array_merge(array('cat_id' => $cat_id), $u_sort_param));
$this->pagination->generate_template_pagination($base_url, 'pagination', 'page', $nb_links, $this->config['dir_show'], $start);
$this->template->assign_vars(array('S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_CATLIST' => $this->categorie->make_cat_select($cat_id), 'S_PAGE_ACTION' => $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => $cat_id, 'page' => $page)), 'S_CAT_ID' => $cat_id, 'TOTAL_LINKS' => $this->user->lang('DIR_NB_LINKS', (int) $nb_links), 'U_NEW_SITE' => $this->helper->route('ernadoo_phpbbdirectory_new_controller', array('cat_id' => $cat_id)), 'U_WATCH_CAT' => $s_watching_categorie['link'], 'U_WATCH_CAT_TOGGLE' => $s_watching_categorie['link_toggle'], 'S_WATCH_CAT_TITLE' => $s_watching_categorie['title'], 'S_WATCH_CAT_TOGGLE' => $s_watching_categorie['title_toggle'], 'S_WATCHING_CAT' => $s_watching_categorie['is_watching']));
// If the user is trying to reach late pages, start searching from the end
$store_reverse = false;
$sql_limit = $this->config['dir_show'];
if ($start > $nb_links / 2) {
$store_reverse = true;
// Select the sort order
$direction = $sort_dir == 'd' ? 'ASC' : 'DESC';
$sql_limit = $this->pagination->reverse_limit($start, $sql_limit, $nb_links);
$sql_start = $this->pagination->reverse_start($start, $sql_limit, $nb_links);
} else {
// Select the sort order
$direction = $sort_dir == 'd' ? 'DESC' : 'ASC';
$sql_start = $start;
}
if (is_array($sort_by_sql[$sort_key])) {
$sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
} else {
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
}
// Grab just the sorted link ids
$sql_array = array('SELECT' => 'l.link_id', 'FROM' => array(DIR_LINK_TABLE => 'l'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'l.link_user_id = u.user_id')), 'WHERE' => "l.link_cat = {$cat_id}\n\t\t\t\tAND l.link_active = 1\n\t\t\t\t\t{$sql_limit_time}", 'ORDER_BY' => $sql_sort_order);
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start);
while ($row = $this->db->sql_fetchrow($result)) {
$link_list[] = (int) $row['link_id'];
}
$this->db->sql_freeresult($result);
if (sizeof($link_list)) {
// We get links, informations about poster, votes and number of comments
//.........这里部分代码省略.........