/modcp.php
PHP | 3485 lines | 3105 code | 285 blank | 95 comment | 411 complexity | 18af37e26dd3e0b23276447ac16e8228 MD5 | raw file
Possible License(s): LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * MyBB 1.6
- * Copyright 2010 MyBB Group, All Rights Reserved
- *
- * Website: http://mybb.com
- * License: http://mybb.com/about/license
- *
- * $Id$
- */
- define("IN_MYBB", 1);
- define('THIS_SCRIPT', 'modcp.php');
- $templatelist = "modcp_reports,modcp_reports_report,modcp_reports_multipage,modcp_reports_allreport";
- $templatelist .= ",modcp_reports_allnoreports,modcp_reports_noreports,modcp_banning,modcp_banning_ban";
- $templatelist .= ",modcp_banning_multipage,modcp_banning_nobanned,modcp_banning_auser,modcp_banning_error";
- $templatelist .= ",modcp_banning_edit,modcp_banning_banned_user,modcp_nav,modcp_modlogs_noresults,modcp";
- $templatelist .= ",modcp_no_announcements_global,modcp_announcements_global,modcp_announcements_forum,modcp_announcements";
- $templatelist .= ",codebuttons,smilieinsert,modcp_announcements_new,modcp_modqueue_empty,forumjump_bit,forumjump_special";
- $templatelist .= ",modcp_modlogs,modcp_finduser_user,modcp_finduser,usercp_profile_customfield,usercp_profile_profilefields";
- $templatelist .= ",modcp_editprofile,modcp_ipsearch,modcp_banuser_addusername,modcp_banuser,modcp_warninglogs_nologs";
- $templatelist .= ",modcp_warninglogs,modcp_modlogs_result,modcp_editprofile_signature_info,modcp_editprofile_signature_options,modcp_editprofile_signature";
- require_once "./global.php";
- require_once MYBB_ROOT."inc/functions_user.php";
- require_once MYBB_ROOT."inc/functions_upload.php";
- require_once MYBB_ROOT."inc/functions_modcp.php";
- require_once MYBB_ROOT."inc/class_parser.php";
- $parser = new postParser;
- // Set up the array of ban times.
- $bantimes = fetch_ban_times();
- // Load global language phrases
- $lang->load("modcp");
- if($mybb->user['uid'] == 0 || $mybb->usergroup['canmodcp'] != 1)
- {
- error_no_permission();
- }
- $errors = '';
- // SQL for fetching items only related to forums this user moderates
- $moderated_forums = array();
- if($mybb->usergroup['issupermod'] != 1)
- {
- $query = $db->simple_select("moderators", "*", "(id='{$mybb->user['uid']}' AND isgroup = '0') OR (id='{$mybb->user['usergroup']}' AND isgroup = '1')");
- while($forum = $db->fetch_array($query))
- {
- $flist .= ",'{$forum['fid']}'";
-
- $children = get_child_list($forum['fid']);
- if(!empty($children))
- {
- $flist .= ",'".implode("','", $children)."'";
- }
- $moderated_forums[] = $forum['fid'];
- }
- if($flist)
- {
- $tflist = " AND t.fid IN (0{$flist})";
- $flist = " AND fid IN (0{$flist})";
- }
- }
- else
- {
- $flist = $tflist = '';
- }
- // Retrieve a list of unviewable forums
- $unviewableforums = get_unviewable_forums();
- if($unviewableforums && !is_super_admin($mybb->user['uid']))
- {
- $flist .= " AND fid NOT IN ({$unviewableforums})";
- $tflist .= " AND t.fid NOT IN ({$unviewableforums})";
- $unviewableforums = str_replace("'", '', $unviewableforums);
- $unviewableforums = explode(',', $unviewableforums);
- }
- // Fetch the Mod CP menu
- eval("\$modcp_nav = \"".$templates->get("modcp_nav")."\";");
- $plugins->run_hooks("modcp_start");
- // Make navigation
- add_breadcrumb($lang->nav_modcp, "modcp.php");
- if($mybb->input['action'] == "do_reports")
- {
- // Verify incoming POST request
- verify_post_check($mybb->input['my_post_key']);
- if(!is_array($mybb->input['reports']))
- {
- error($lang->error_noselected_reports);
- }
- $sql = '1=1';
- if(!$mybb->input['allbox'])
- {
- $mybb->input['reports'] = array_map("intval", $mybb->input['reports']);
- $rids = implode($mybb->input['reports'], "','");
- $rids = "'0','{$rids}'";
- $sql = "rid IN ({$rids})";
- }
- $plugins->run_hooks("modcp_do_reports");
- $db->update_query("reportedposts", array('reportstatus' => 1), "{$sql}{$flist}");
- $cache->update_reportedposts();
-
- $page = intval($mybb->input['page']);
-
- redirect("modcp.php?action=reports&page={$page}", $lang->redirect_reportsmarked);
- }
- if($mybb->input['action'] == "reports")
- {
- add_breadcrumb($lang->mcp_nav_reported_posts, "modcp.php?action=reports");
- if(!$mybb->settings['threadsperpage'])
- {
- $mybb->settings['threadsperpage'] = 20;
- }
- // Figure out if we need to display multiple pages.
- $perpage = $mybb->settings['threadsperpage'];
- if($mybb->input['page'] != "last")
- {
- $page = intval($mybb->input['page']);
- }
- $query = $db->simple_select("reportedposts", "COUNT(rid) AS count", "reportstatus ='0'");
- $report_count = $db->fetch_field($query, "count");
- $mybb->input['rid'] = intval($mybb->input['rid']);
- if($mybb->input['rid'])
- {
- $query = $db->simple_select("reportedposts", "COUNT(rid) AS count", "rid <= '".$mybb->input['rid']."'");
- $result = $db->fetch_field($query, "count");
- if(($result % $perpage) == 0)
- {
- $page = $result / $perpage;
- }
- else
- {
- $page = intval($result / $perpage) + 1;
- }
- }
- $postcount = intval($report_count);
- $pages = $postcount / $perpage;
- $pages = ceil($pages);
- if($mybb->input['page'] == "last")
- {
- $page = $pages;
- }
- if($page > $pages || $page <= 0)
- {
- $page = 1;
- }
- if($page && $page > 0)
- {
- $start = ($page-1) * $perpage;
- }
- else
- {
- $start = 0;
- $page = 1;
- }
- $upper = $start+$perpage;
- $multipage = multipage($postcount, $perpage, $page, "modcp.php?action=reports");
- if($postcount > $perpage)
- {
- eval("\$reportspages = \"".$templates->get("modcp_reports_multipage")."\";");
- }
- $query = $db->simple_select("forums", "fid, name");
- while($forum = $db->fetch_array($query))
- {
- $forums[$forum['fid']] = $forum['name'];
- }
-
- $plugins->run_hooks("modcp_reports_start");
- $reports = '';
- $query = $db->query("
- SELECT r.*, u.username, up.username AS postusername, up.uid AS postuid, t.subject AS threadsubject
- FROM ".TABLE_PREFIX."reportedposts r
- LEFT JOIN ".TABLE_PREFIX."posts p ON (r.pid=p.pid)
- LEFT JOIN ".TABLE_PREFIX."threads t ON (p.tid=t.tid)
- LEFT JOIN ".TABLE_PREFIX."users u ON (r.uid=u.uid)
- LEFT JOIN ".TABLE_PREFIX."users up ON (p.uid=up.uid)
- WHERE r.reportstatus='0'
- ORDER BY r.dateline DESC
- LIMIT {$start}, {$perpage}
- ");
- if(!$db->num_rows($query))
- {
- eval("\$reports = \"".$templates->get("modcp_reports_noreports")."\";");
- }
- else
- {
- while($report = $db->fetch_array($query))
- {
- $trow = alt_trow();
- if(is_moderator($report['fid']))
- {
- $trow = 'trow_shaded';
- }
- $report['postlink'] = get_post_link($report['pid'], $report['tid']);
- $report['threadlink'] = get_thread_link($report['tid']);
- $report['posterlink'] = get_profile_link($report['postuid']);
- $report['reporterlink'] = get_profile_link($report['uid']);
- $reportdate = my_date($mybb->settings['dateformat'], $report['dateline']);
- $reporttime = my_date($mybb->settings['timeformat'], $report['dateline']);
- $report['threadsubject'] = htmlspecialchars_uni($parser->parse_badwords($report['threadsubject']));
- eval("\$reports .= \"".$templates->get("modcp_reports_report")."\";");
- }
- }
- $plugins->run_hooks("modcp_reports_end");
- eval("\$reportedposts = \"".$templates->get("modcp_reports")."\";");
- output_page($reportedposts);
- }
- if($mybb->input['action'] == "allreports")
- {
- add_breadcrumb($lang->mcp_nav_all_reported_posts, "modcp.php?action=allreports");
- if(!$mybb->settings['threadsperpage'])
- {
- $mybb->settings['threadsperpage'] = 20;
- }
- // Figure out if we need to display multiple pages.
- $perpage = $mybb->settings['threadsperpage'];
- if($mybb->input['page'] != "last")
- {
- $page = intval($mybb->input['page']);
- }
- $query = $db->simple_select("reportedposts", "COUNT(rid) AS count");
- $warnings = $db->fetch_field($query, "count");
- if($mybb->input['rid'])
- {
- $mybb->input['rid'] = intval($mybb->input['rid']);
- $query = $db->simple_select("reportedposts", "COUNT(rid) AS count", "rid <= '".$mybb->input['rid']."'");
- $result = $db->fetch_field($query, "count");
- if(($result % $perpage) == 0)
- {
- $page = $result / $perpage;
- }
- else
- {
- $page = intval($result / $perpage) + 1;
- }
- }
- $postcount = intval($warnings);
- $pages = $postcount / $perpage;
- $pages = ceil($pages);
- if($mybb->input['page'] == "last")
- {
- $page = $pages;
- }
- if($page > $pages || $page <= 0)
- {
- $page = 1;
- }
- if($page)
- {
- $start = ($page-1) * $perpage;
- }
- else
- {
- $start = 0;
- $page = 1;
- }
- $upper = $start+$perpage;
- $multipage = multipage($postcount, $perpage, $page, "modcp.php?action=allreports");
- if($postcount > $perpage)
- {
- eval("\$allreportspages = \"".$templates->get("modcp_reports_multipage")."\";");
- }
-
- $plugins->run_hooks("modcp_allreports_start");
- $query = $db->query("
- SELECT r.*, u.username, up.username AS postusername, up.uid AS postuid, t.subject AS threadsubject
- FROM ".TABLE_PREFIX."reportedposts r
- LEFT JOIN ".TABLE_PREFIX."posts p ON (r.pid=p.pid)
- LEFT JOIN ".TABLE_PREFIX."threads t ON (p.tid=t.tid)
- LEFT JOIN ".TABLE_PREFIX."users u ON (r.uid=u.uid)
- LEFT JOIN ".TABLE_PREFIX."users up ON (p.uid=up.uid)
- ORDER BY r.dateline DESC
- LIMIT {$start}, {$perpage}
- ");
- $allreports = '';
- if(!$db->num_rows($query))
- {
- eval("\$allreports = \"".$templates->get("modcp_reports_allnoreports")."\";");
- }
- else
- {
- while($report = $db->fetch_array($query))
- {
- $trow = alt_trow();
- $report['threadsubject'] = $lang->na;
- $report['threadlink'] = get_thread_link($report['tid']);
- $report['posterlink'] = get_profile_link($report['postuid']);
- $report['postlink'] = get_post_link($report['pid'], $report['tid']);
- $report['postusername'] = build_profile_link($report['postusername'], $report['postuid']);
- $report['reporterlink'] = get_profile_link($report['uid']);
- $reportdate = my_date($mybb->settings['dateformat'], $report['dateline']);
- $reporttime = my_date($mybb->settings['timeformat'], $report['dateline']);
- if($report['reportstatus'] == 0)
- {
- $trow = "trow_shaded";
- }
-
- if($report['threadsubject'])
- {
- $report['threadsubject'] = htmlspecialchars_uni($parser->parse_badwords($report['threadsubject']));
- $report['threadsubject'] = "<a href=\"".get_thread_link($report['tid'])."\" target=\"_blank\">{$report['threadsubject']}</a>";
- }
- eval("\$allreports .= \"".$templates->get("modcp_reports_allreport")."\";");
- }
- }
- $plugins->run_hooks("modcp_allreports_end");
- eval("\$allreportedposts = \"".$templates->get("modcp_reports_allreports")."\";");
- output_page($allreportedposts);
- }
- if($mybb->input['action'] == "modlogs")
- {
- add_breadcrumb($lang->mcp_nav_modlogs, "modcp.php?action=modlogs");
- $perpage = intval($mybb->input['perpage']);
- if(!$perpage || $perpage <= 0)
- {
- $perpage = $mybb->settings['threadsperpage'];
- }
- $where = '';
- // Searching for entries by a particular user
- if($mybb->input['uid'])
- {
- $where .= " AND l.uid='".intval($mybb->input['uid'])."'";
- }
- // Searching for entries in a specific forum
- if($mybb->input['fid'])
- {
- $where .= " AND t.fid='".intval($mybb->input['fid'])."'";
- }
- // Order?
- switch($mybb->input['sortby'])
- {
- case "username":
- $sortby = "u.username";
- break;
- case "forum":
- $sortby = "f.name";
- break;
- case "thread":
- $sortby = "t.subject";
- break;
- default:
- $sortby = "l.dateline";
- }
- $order = $mybb->input['order'];
- if($order != "asc")
- {
- $order = "desc";
- }
-
- $plugins->run_hooks("modcp_modlogs_start");
- $query = $db->query("
- SELECT COUNT(l.dateline) AS count
- FROM ".TABLE_PREFIX."moderatorlog l
- LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=l.uid)
- LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=l.tid)
- WHERE 1=1 {$where}{$tflist}
- ");
- $rescount = $db->fetch_field($query, "count");
- // Figure out if we need to display multiple pages.
- if($mybb->input['page'] != "last")
- {
- $page = intval($mybb->input['page']);
- }
- $postcount = intval($rescount);
- $pages = $postcount / $perpage;
- $pages = ceil($pages);
- if($mybb->input['page'] == "last")
- {
- $page = $pages;
- }
- if($page > $pages || $page <= 0)
- {
- $page = 1;
- }
- if($page)
- {
- $start = ($page-1) * $perpage;
- }
- else
- {
- $start = 0;
- $page = 1;
- }
- $multipage = multipage($postcount, $perpage, $page, "modcp.php?action=modlogs&perpage=$perpage&uid={$mybb->input['uid']}&fid={$mybb->input['fid']}&sortby={$mybb->input['sortby']}&order={$mybb->input['order']}");
- if($postcount > $perpage)
- {
- eval("\$resultspages = \"".$templates->get("modcp_modlogs_multipage")."\";");
- }
- $query = $db->query("
- SELECT l.*, u.username, u.usergroup, u.displaygroup, t.subject AS tsubject, f.name AS fname, p.subject AS psubject
- FROM ".TABLE_PREFIX."moderatorlog l
- LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=l.uid)
- LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=l.tid)
- LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=l.fid)
- LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=l.pid)
- WHERE 1=1 {$where}{$tflist}
- ORDER BY {$sortby} {$order}
- LIMIT {$start}, {$perpage}
- ");
- while($logitem = $db->fetch_array($query))
- {
- $information = '';
- $logitem['action'] = htmlspecialchars_uni($logitem['action']);
- $log_date = my_date($mybb->settings['dateformat'], $logitem['dateline']);
- $log_time = my_date($mybb->settings['timeformat'], $logitem['dateline']);
- $trow = alt_trow();
- $username = format_name($logitem['username'], $logitem['usergroup'], $logitem['displaygroup']);
- $logitem['profilelink'] = build_profile_link($username, $logitem['uid']);
- if($logitem['tsubject'])
- {
- $information = "<strong>{$lang->thread}</strong> <a href=\"".get_thread_link($logitem['tid'])."\" target=\"_blank\">".htmlspecialchars_uni($logitem['tsubject'])."</a><br />";
- }
- if($logitem['fname'])
- {
- $information .= "<strong>{$lang->forum}</strong> <a href=\"".get_forum_link($logitem['fid'])."\" target=\"_blank\">{$logitem['fname']}</a><br />";
- }
- if($logitem['psubject'])
- {
- $information .= "<strong>{$lang->post}</strong> <a href=\"".get_post_link($logitem['pid'])."#pid{$logitem['pid']}\">".htmlspecialchars_uni($logitem['psubject'])."</a>";
- }
- // Edited a user?
- if(!$logitem['tsubject'] || !$logitem['fname'] || !$logitem['psubject'])
- {
- $data = unserialize($logitem['data']);
- if($data['uid'])
- {
- $information = $lang->sprintf($lang->edited_user_info, htmlspecialchars_uni($data['username']), get_profile_link($data['uid']));
- }
- }
- eval("\$results .= \"".$templates->get("modcp_modlogs_result")."\";");
- }
- if(!$results)
- {
- eval("\$results = \"".$templates->get("modcp_modlogs_noresults")."\";");
- }
-
- $plugins->run_hooks("modcp_modlogs_filter");
- // Fetch filter options
- $sortbysel[$mybb->input['sortby']] = "selected=\"selected\"";
- $ordersel[$mybb->input['order']] = "selected=\"selected\"";
- $query = $db->query("
- SELECT DISTINCT l.uid, u.username
- FROM ".TABLE_PREFIX."moderatorlog l
- LEFT JOIN ".TABLE_PREFIX."users u ON (l.uid=u.uid)
- ORDER BY u.username ASC
- ");
- while($user = $db->fetch_array($query))
- {
- // Deleted Users
- if(!$user['username'])
- {
- $user['username'] = $lang->na_deleted;
- }
-
- $selected = '';
- if($mybb->input['uid'] == $user['uid'])
- {
- $selected = " selected=\"selected\"";
- }
- $user_options .= "<option value=\"{$user['uid']}\"{$selected}>".htmlspecialchars_uni($user['username'])."</option>\n";
- }
- $forum_select = build_forum_jump("", $mybb->input['fid'], 1, '', 0, true, '', "fid");
- eval("\$modlogs = \"".$templates->get("modcp_modlogs")."\";");
- output_page($modlogs);
- }
- if($mybb->input['action'] == "do_delete_announcement")
- {
- verify_post_check($mybb->input['my_post_key']);
- $aid = intval($mybb->input['aid']);
- $query = $db->simple_select("announcements", "aid, subject, fid", "aid='{$aid}'");
- $announcement = $db->fetch_array($query);
- if(!$announcement['aid'])
- {
- error($lang->error_invalid_announcement);
- }
- if(($mybb->usergroup['issupermod'] != 1 && $announcement['fid'] == -1) || ($announcement['fid'] != -1 && !is_moderator($announcement['fid'])) || ($unviewableforums && in_array($announcement['fid'], $unviewableforums)))
- {
- error_no_permission();
- }
-
- $plugins->run_hooks("modcp_do_delete_announcement");
- $db->delete_query("announcements", "aid='{$aid}'");
- $cache->update_forumsdisplay();
- redirect("modcp.php?action=announcements", $lang->redirect_delete_announcement);
- }
- if($mybb->input['action'] == "delete_announcement")
- {
- $aid = intval($mybb->input['aid']);
- $query = $db->simple_select("announcements", "aid, subject, fid", "aid='{$aid}'");
- $announcement = $db->fetch_array($query);
- $announcement['subject'] = htmlspecialchars_uni($announcement['subject']);
- if(!$announcement['aid'])
- {
- error($lang->error_invalid_announcement);
- }
- if(($mybb->usergroup['issupermod'] != 1 && $announcement['fid'] == -1) || ($announcement['fid'] != -1 && !is_moderator($announcement['fid'])) || ($unviewableforums && in_array($announcement['fid'], $unviewableforums)))
- {
- error_no_permission();
- }
-
- $plugins->run_hooks("modcp_delete_announcement");
- eval("\$announcements = \"".$templates->get("modcp_announcements_delete")."\";");
- output_page($announcements);
- }
- if($mybb->input['action'] == "do_new_announcement")
- {
- verify_post_check($mybb->input['my_post_key']);
- $announcement_fid = intval($mybb->input['fid']);
- if(($mybb->usergroup['issupermod'] != 1 && $announcement_fid == -1) || ($announcement_fid != -1 && !is_moderator($announcement_fid)) || ($unviewableforums && in_array($announcement['fid'], $unviewableforums)))
- {
- error_no_permission();
- }
- if(!trim($mybb->input['title']))
- {
- $errors[] = $lang->error_missing_title;
- }
- if(!trim($mybb->input['message']))
- {
- $errors[] = $lang->error_missing_message;
- }
- if(!trim($mybb->input['fid']))
- {
- $errors[] = $lang->error_missing_forum;
- }
- $startdate = @explode(" ", $mybb->input['starttime_time']);
- $startdate = @explode(":", $startdate[0]);
- $enddate = @explode(" ", $mybb->input['endtime_time']);
- $enddate = @explode(":", $enddate[0]);
- if(stristr($mybb->input['starttime_time'], "pm"))
- {
- $startdate[0] = 12+$startdate[0];
- if($startdate[0] >= 24)
- {
- $startdate[0] = "00";
- }
- }
- if(stristr($mybb->input['endtime_time'], "pm"))
- {
- $enddate[0] = 12+$enddate[0];
- if($enddate[0] >= 24)
- {
- $enddate[0] = "00";
- }
- }
-
- $months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
- if(!in_array($mybb->input['starttime_month'], $months))
- {
- $mybb->input['starttime_month'] = 1;
- }
- $startdate = gmmktime(intval($startdate[0]), intval($startdate[1]), 0, (int)$mybb->input['starttime_month'], intval($mybb->input['starttime_day']), intval($mybb->input['starttime_year']));
-
- if($startdate < 0 || $startdate == false)
- {
- $errors[] = $lang->error_invalid_start_date;
- }
- if($mybb->input['endtime_type'] == "2")
- {
- $enddate = '0';
- }
- else
- {
- if(!in_array($mybb->input['endtime_month'], $months))
- {
- $mybb->input['endtime_month'] = 1;
- }
- $enddate = gmmktime(intval($enddate[0]), intval($enddate[1]), 0, (int)$mybb->input['endtime_month'], intval($mybb->input['endtime_day']), intval($mybb->input['endtime_year']));
- if($enddate < 0 || $enddate == false)
- {
- $errors[] = $lang->error_invalid_end_date;
- }
- elseif($enddate < $startdate)
- {
- $errors[] = $lang->error_end_before_start;
- }
- }
-
- $plugins->run_hooks("modcp_do_new_announcement_start");
- if(!$errors)
- {
- $insert_announcement = array(
- 'fid' => $announcement_fid,
- 'uid' => $mybb->user['uid'],
- 'subject' => $db->escape_string($mybb->input['title']),
- 'message' => $db->escape_string($mybb->input['message']),
- 'startdate' => $startdate,
- 'enddate' => $enddate,
- 'allowhtml' => $db->escape_string($mybb->input['allowhtml']),
- 'allowmycode' => $db->escape_string($mybb->input['allowmycode']),
- 'allowsmilies' => $db->escape_string($mybb->input['allowsmilies']),
- );
- $aid = $db->insert_query("announcements", $insert_announcement);
-
- $plugins->run_hooks("modcp_do_new_announcement_end");
-
- $cache->update_forumsdisplay();
- redirect("modcp.php?action=announcements", $lang->redirect_add_announcement);
- }
- else
- {
- $mybb->input['action'] = 'new_announcement';
- }
- }
- if($mybb->input['action'] == "new_announcement")
- {
- add_breadcrumb($lang->mcp_nav_announcements, "modcp.php?action=announcements");
- add_breadcrumb($lang->add_announcement, "modcp.php?action=new_announcements");
- $announcement_fid = intval($mybb->input['fid']);
- if(($mybb->usergroup['issupermod'] != 1 && $announcement_fid == -1) || ($announcement_fid != -1 && !is_moderator($announcement_fid)) || ($unviewableforums && in_array($announcement['fid'], $unviewableforums)))
- {
- error_no_permission();
- }
- // Deal with inline errors
- if(is_array($errors))
- {
- $errors = inline_error($errors);
-
- // Set $announcement to input stuff
- $announcement['subject'] = $mybb->input['title'];
- $announcement['message'] = $mybb->input['message'];
- $announcement['allowhtml'] = $mybb->input['allowhtml'];
- $announcement['allowmycode'] = $mybb->input['allowmycode'];
- $announcement['allowsmilies'] = $mybb->input['allowsmilies'];
-
- $months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
- if(!in_array($mybb->input['starttime_month'], $months))
- {
- $mybb->input['starttime_month'] = 1;
- }
-
- if(!in_array($mybb->input['endtime_month'], $months))
- {
- $mybb->input['endtime_month'] = 1;
- }
-
- $startmonth = $mybb->input['starttime_month'];
- $startdateyear = htmlspecialchars_uni($mybb->input['starttime_year']);
- $startday = intval($mybb->input['starttime_day']);
- $starttime_time = htmlspecialchars($mybb->input['starttime_time']);
- $endmonth = $mybb->input['endtime_month'];
- $enddateyear = htmlspecialchars_uni($mybb->input['endtime_year']);
- $endday = intval($mybb->input['endtime_day']);
- $endtime_time = htmlspecialchars($mybb->input['endtime_time']);
- }
- else
- {
- // Note: dates are in GMT timezone
- $starttime_time = gmdate("g:i a", TIME_NOW);
- $endtime_time = gmdate("g:i a", TIME_NOW);
- $startday = $endday = gmdate("j", TIME_NOW);
- $startmonth = $endmonth = gmdate("m", TIME_NOW);
- $startdateyear = gmdate("Y", TIME_NOW);
- $enddateyear = $startdateyear+1;
- }
- // Generate form elements
- for($i = 1; $i <= 31; ++$i)
- {
- if($startday == $i)
- {
- $startdateday .= "<option value=\"$i\" selected=\"selected\">$i</option>\n";
- }
- else
- {
- $startdateday .= "<option value=\"$i\">$i</option>\n";
- }
- if($endday == $i)
- {
- $enddateday .= "<option value=\"$i\" selected=\"selected\">$i</option>\n";
- }
- else
- {
- $enddateday .= "<option value=\"$i\">$i</option>\n";
- }
- }
- $startmonthsel = $endmonthsel = array();
- $startmonthsel[$startmonth] = "selected=\"selected\"";
- $endmonthsel[$endmonth] = "selected=\"selected\"";
- $startdatemonth .= "<option value=\"01\" {$startmonthsel['01']}>{$lang->january}</option>\n";
- $enddatemonth .= "<option value=\"01\" {$endmonthsel['01']}>{$lang->january}</option>\n";
- $startdatemonth .= "<option value=\"02\" {$startmonthsel['02']}>{$lang->february}</option>\n";
- $enddatemonth .= "<option value=\"02\" {$endmonthsel['02']}>{$lang->february}</option>\n";
- $startdatemonth .= "<option value=\"03\" {$startmonthsel['03']}>{$lang->march}</option>\n";
- $enddatemonth .= "<option value=\"03\" {$endmonthsel['03']}>{$lang->march}</option>\n";
- $startdatemonth .= "<option value=\"04\" {$startmonthsel['04']}>{$lang->april}</option>\n";
- $enddatemonth .= "<option value=\"04\" {$endmonthsel['04']}>{$lang->april}</option>\n";
- $startdatemonth .= "<option value=\"05\" {$startmonthsel['05']}>{$lang->may}</option>\n";
- $enddatemonth .= "<option value=\"05\" {$endmonthsel['05']}>{$lang->may}</option>\n";
- $startdatemonth .= "<option value=\"06\" {$startmonthsel['06']}>{$lang->june}</option>\n";
- $enddatemonth .= "<option value=\"06\" {$endmonthsel['06']}>{$lang->june}</option>\n";
- $startdatemonth .= "<option value=\"07\" {$startmonthsel['07']}>{$lang->july}</option>\n";
- $enddatemonth .= "<option value=\"07\" {$endmonthsel['07']}>{$lang->july}</option>\n";
- $startdatemonth .= "<option value=\"08\" {$startmonthsel['08']}>{$lang->august}</option>\n";
- $enddatemonth .= "<option value=\"08\" {$endmonthsel['08']}>{$lang->august}</option>\n";
- $startdatemonth .= "<option value=\"09\" {$startmonthsel['09']}>{$lang->september}</option>\n";
- $enddatemonth .= "<option value=\"09\" {$endmonthsel['09']}>{$lang->september}</option>\n";
- $startdatemonth .= "<option value=\"10\" {$startmonthsel['10']}>{$lang->october}</option>\n";
- $enddatemonth .= "<option value=\"10\" {$endmonthsel['10']}>{$lang->october}</option>\n";
- $startdatemonth .= "<option value=\"11\" {$startmonthsel['11']}>{$lang->november}</option>\n";
- $enddatemonth .= "<option value=\"11\" {$endmonthsel['11']}>{$lang->november}</option>\n";
- $startdatemonth .= "<option value=\"12\" {$startmonthsel['12']}>{$lang->december}</option>\n";
- $enddatemonth .= "<option value=\"12\" {$endmonthsel['12']}>{$lang->december}</option>\n";
- $title = htmlspecialchars_uni($announcement['subject']);
- $message = htmlspecialchars_uni($announcement['message']);
- $html_sel = $mycode_sel = $smilies_sel = array();
- if($mybb->input['allowhtml'] || !isset($mybb->input['allowhtml']))
- {
- $html_sel['yes'] = ' checked="checked"';
- }
- else
- {
- $html_sel['no'] = ' checked="checked"';
- }
- if($mybb->input['allowmycode'] || !isset($mybb->input['allowmycode']))
- {
- $mycode_sel['yes'] = ' checked="checked"';
- }
- else
- {
- $mycode_sel['no'] = ' checked="checked"';
- }
- if($mybb->input['allowsmilies'] || !isset($mybb->input['allowsmilies']))
- {
- $smilies_sel['yes'] = ' checked="checked"';
- }
- else
- {
- $smilies_sel['no'] = ' checked="checked"';
- }
- if($mybb->input['endtime_type'] == 2 || !isset($mybb->input['endtime_type']))
- {
- $end_type_sel['infinite'] = ' checked="checked"';
- }
- else
- {
- $end_type_sel['finite'] = ' checked="checked"';
- }
- // MyCode editor
- $codebuttons = build_mycode_inserter();
- $smilieinserter = build_clickable_smilies();
-
- $plugins->run_hooks("modcp_new_announcement");
- eval("\$announcements = \"".$templates->get("modcp_announcements_new")."\";");
- output_page($announcements);
- }
- if($mybb->input['action'] == "do_edit_announcement")
- {
- verify_post_check($mybb->input['my_post_key']);
- // Get the announcement
- $aid = intval($mybb->input['aid']);
- $query = $db->simple_select("announcements", "aid, subject, fid", "aid='{$aid}'");
- $announcement = $db->fetch_array($query);
- // Check that it exists
- if(!$announcement['aid'])
- {
- error($lang->error_invalid_announcement);
- }
- // Mod has permissions to edit this announcement
- if(($mybb->usergroup['issupermod'] != 1 && $announcement['fid'] == -1) || ($announcement['fid'] != -1 && !is_moderator($announcement['fid'])) || ($unviewableforums && in_array($announcement['fid'], $unviewableforums)))
- {
- error_no_permission();
- }
- // Basic error checking
- if(!trim($mybb->input['title']))
- {
- $errors[] = $lang->error_missing_title;
- }
- if(!trim($mybb->input['message']))
- {
- $errors[] = $lang->error_missing_message;
- }
- if(!trim($mybb->input['fid']))
- {
- $errors[] = $lang->error_missing_forum;
- }
- $startdate = @explode(" ", $mybb->input['starttime_time']);
- $startdate = @explode(":", $startdate[0]);
- $enddate = @explode(" ", $mybb->input['endtime_time']);
- $enddate = @explode(":", $enddate[0]);
- if(stristr($mybb->input['starttime_time'], "pm"))
- {
- $startdate[0] = 12+$startdate[0];
- if($startdate[0] >= 24)
- {
- $startdate[0] = "00";
- }
- }
- if(stristr($mybb->input['endtime_time'], "pm"))
- {
- $enddate[0] = 12+$enddate[0];
- if($enddate[0] >= 24)
- {
- $enddate[0] = "00";
- }
- }
- $months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
- if(!in_array($mybb->input['starttime_month'], $months))
- {
- $mybb->input['starttime_month'] = 1;
- }
- $startdate = gmmktime(intval($startdate[0]), intval($startdate[1]), 0, (int)$mybb->input['starttime_month'], intval($mybb->input['starttime_day']), intval($mybb->input['starttime_year']));
- if($startdate < 0 || $startdate == false)
- {
- $errors[] = $lang->error_invalid_start_date;
- }
- if($mybb->input['endtime_type'] == "2")
- {
- $enddate = '0';
- }
- else
- {
- if(!in_array($mybb->input['endtime_month'], $months))
- {
- $mybb->input['endtime_month'] = 1;
- }
- $enddate = gmmktime(intval($enddate[0]), intval($enddate[1]), 0, (int)$mybb->input['endtime_month'], intval($mybb->input['endtime_day']), intval($mybb->input['endtime_year']));
- if($enddate < 0 || $enddate == false)
- {
- $errors[] = $lang->error_invalid_end_date;
- }
- elseif($enddate < $startdate)
- {
- $errors[] = $lang->error_end_before_start;
- }
- }
-
- $plugins->run_hooks("modcp_do_edit_announcement_start");
- // Proceed to update if no errors
- if(!$errors)
- {
- $update_announcement = array(
- 'uid' => $mybb->user['uid'],
- 'subject' => $db->escape_string($mybb->input['title']),
- 'message' => $db->escape_string($mybb->input['message']),
- 'startdate' => $startdate,
- 'enddate' => $enddate,
- 'allowhtml' => $db->escape_string($mybb->input['allowhtml']),
- 'allowmycode' => $db->escape_string($mybb->input['allowmycode']),
- 'allowsmilies' => $db->escape_string($mybb->input['allowsmilies']),
- );
- $db->update_query("announcements", $update_announcement, "aid='{$aid}'");
-
- $plugins->run_hooks("modcp_do_edit_announcement_end");
-
- $cache->update_forumsdisplay();
- redirect("modcp.php?action=announcements", $lang->redirect_edit_announcement);
- }
- else
- {
- $mybb->input['action'] = 'edit_announcement';
- }
- }
- if($mybb->input['action'] == "edit_announcement")
- {
- $announcement_fid = intval($mybb->input['fid']);
- $aid = intval($mybb->input['aid']);
- add_breadcrumb($lang->mcp_nav_announcements, "modcp.php?action=announcements");
- add_breadcrumb($lang->edit_announcement, "modcp.php?action=edit_announcements&aid={$aid}");
- // Get announcement
- $query = $db->simple_select("announcements", "*", "aid='{$aid}'");
- $announcement = $db->fetch_array($query);
- if(!$announcement['fid'])
- {
- error($lang->error_invalid_announcement);
- }
- if(($mybb->usergroup['issupermod'] != 1 && $announcement['fid'] == -1) || ($announcement['fid'] != -1 && !is_moderator($announcement['fid'])) || ($unviewableforums && in_array($announcement['fid'], $unviewableforums)))
- {
- error_no_permission();
- }
- if(!$announcement['startdate'])
- {
- // No start date? Make it now.
- $announcement['startdate'] = TIME_NOW;
- }
- $makeshift_end = false;
- if(!$announcement['enddate'])
- {
- $makeshift_end = true;
- $makeshift_time = TIME_NOW;
- if($announcement['startdate'])
- {
- $makeshift_time = $announcement['startdate'];
- }
- // No end date? Make it a year from now.
- $announcement['enddate'] = $makeshift_time + (60 * 60 * 24 * 366);
- }
- // Deal with inline errors
- if(is_array($errors))
- {
- $errors = inline_error($errors);
- // Set $announcement to input stuff
- $announcement['subject'] = $mybb->input['title'];
- $announcement['message'] = $mybb->input['message'];
- $announcement['allowhtml'] = $mybb->input['allowhtml'];
- $announcement['allowmycode'] = $mybb->input['allowmycode'];
- $announcement['allowsmilies'] = $mybb->input['allowsmilies'];
-
- $months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
- if(!in_array($mybb->input['starttime_month'], $months))
- {
- $mybb->input['starttime_month'] = 1;
- }
-
- if(!in_array($mybb->input['endtime_month'], $months))
- {
- $mybb->input['endtime_month'] = 1;
- }
-
- $startmonth = $mybb->input['starttime_month'];
- $startdateyear = htmlspecialchars_uni($mybb->input['starttime_year']);
- $startday = intval($mybb->input['starttime_day']);
- $starttime_time = htmlspecialchars($mybb->input['starttime_time']);
- $endmonth = $mybb->input['endtime_month'];
- $enddateyear = htmlspecialchars_uni($mybb->input['endtime_year']);
- $endday = intval($mybb->input['endtime_day']);
- $endtime_time = htmlspecialchars($mybb->input['endtime_time']);
- $errored = true;
- }
- else
- {
- // Note: dates are in GMT timezone
- $starttime_time = gmdate('g:i a', $announcement['startdate']);
- $endtime_time = gmdate('g:i a', $announcement['enddate']);
- $startday = gmdate('j', $announcement['startdate']);
- $endday = gmdate('j', $announcement['enddate']);
- $startmonth = gmdate('m', $announcement['startdate']);
- $endmonth = gmdate('m', $announcement['enddate']);
- $startdateyear = gmdate('Y', $announcement['startdate']);
- $enddateyear = gmdate('Y', $announcement['enddate']);
- $errored = false;
- }
- // Generate form elements
- for($i = 1; $i <= 31; ++$i)
- {
- if($startday == $i)
- {
- $startdateday .= "<option value=\"$i\" selected=\"selected\">$i</option>\n";
- }
- else
- {
- $startdateday .= "<option value=\"$i\">$i</option>\n";
- }
- if($endday == $i)
- {
- $enddateday .= "<option value=\"$i\" selected=\"selected\">$i</option>\n";
- }
- else
- {
- $enddateday .= "<option value=\"$i\">$i</option>\n";
- }
- }
- $startmonthsel = $endmonthsel = array();
- $startmonthsel[$startmonth] = "selected=\"selected\"";
- $endmonthsel[$endmonth] = "selected=\"selected\"";
- $startdatemonth .= "<option value=\"01\" {$startmonthsel['01']}>{$lang->january}</option>\n";
- $enddatemonth .= "<option value=\"01\" {$endmonthsel['01']}>{$lang->january}</option>\n";
- $startdatemonth .= "<option value=\"02\" {$startmonthsel['02']}>{$lang->february}</option>\n";
- $enddatemonth .= "<option value=\"02\" {$endmonthsel['02']}>{$lang->february}</option>\n";
- $startdatemonth .= "<option value=\"03\" {$startmonthsel['03']}>{$lang->march}</option>\n";
- $enddatemonth .= "<option value=\"03\" {$endmonthsel['03']}>{$lang->march}</option>\n";
- $startdatemonth .= "<option value=\"04\" {$startmonthsel['04']}>{$lang->april}</option>\n";
- $enddatemonth .= "<option value=\"04\" {$endmonthsel['04']}>{$lang->april}</option>\n";
- $startdatemonth .= "<option value=\"05\" {$startmonthsel['05']}>{$lang->may}</option>\n";
- $enddatemonth .= "<option value=\"05\" {$endmonthsel['05']}>{$lang->may}</option>\n";
- $startdatemonth .= "<option value=\"06\" {$startmonthsel['06']}>{$lang->june}</option>\n";
- $enddatemonth .= "<option value=\"06\" {$endmonthsel['06']}>{$lang->june}</option>\n";
- $startdatemonth .= "<option value=\"07\" {$startmonthsel['07']}>{$lang->july}</option>\n";
- $enddatemonth .= "<option value=\"07\" {$endmonthsel['07']}>{$lang->july}</option>\n";
- $startdatemonth .= "<option value=\"08\" {$startmonthsel['08']}>{$lang->august}</option>\n";
- $enddatemonth .= "<option value=\"08\" {$endmonthsel['08']}>{$lang->august}</option>\n";
- $startdatemonth .= "<option value=\"09\" {$startmonthsel['09']}>{$lang->september}</option>\n";
- $enddatemonth .= "<option value=\"09\" {$endmonthsel['09']}>{$lang->september}</option>\n";
- $startdatemonth .= "<option value=\"10\" {$startmonthsel['10']}>{$lang->october}</option>\n";
- $enddatemonth .= "<option value=\"10\" {$endmonthsel['10']}>{$lang->october}</option>\n";
- $startdatemonth .= "<option value=\"11\" {$startmonthsel['11']}>{$lang->november}</option>\n";
- $enddatemonth .= "<option value=\"11\" {$endmonthsel['11']}>{$lang->november}</option>\n";
- $startdatemonth .= "<option value=\"12\" {$startmonthsel['12']}>{$lang->december}</option>\n";
- $enddatemonth .= "<option value=\"12\" {$endmonthsel['12']}>{$lang->december}</option>\n";
- $title = htmlspecialchars_uni($announcement['subject']);
- $message = htmlspecialchars_uni($announcement['message']);
- $html_sel = $mycode_sel = $smilies_sel = array();
- if($announcement['allowhtml'])
- {
- $html_sel['yes'] = ' checked="checked"';
- }
- else
- {
- $html_sel['no'] = ' checked="checked"';
- }
- if($announcement['allowmycode'])
- {
- $mycode_sel['yes'] = ' checked="checked"';
- }
- else
- {
- $mycode_sel['no'] = ' checked="checked"';
- }
- if($announcement['allowsmilies'])
- {
- $smilies_sel['yes'] = ' checked="checked"';
- }
- else
- {
- $smilies_sel['no'] = ' checked="checked"';
- }
- if(($errored && $mybb->input['endtime_type'] == 2) || (!$errored && intval($announcement['enddate']) == 0) || $makeshift_end == true)
- {
- $end_type_sel['infinite'] = ' checked="checked"';
- }
- else
- {
- $end_type_sel['finite'] = ' checked="checked"';
- }
- // MyCode editor
- $codebuttons = build_mycode_inserter();
- $smilieinserter = build_clickable_smilies();
-
- $plugins->run_hooks("modcp_edit_announcement");
- eval("\$announcements = \"".$templates->get("modcp_announcements_edit")."\";");
- output_page($announcements);
- }
- if($mybb->input['action'] == "announcements")
- {
- add_breadcrumb($lang->mcp_nav_announcements, "modcp.php?action=announcements");
- // Fetch announcements into their proper arrays
- $query = $db->simple_select("announcements", "aid, fid, subject, enddate");
- while($announcement = $db->fetch_array($query))
- {
- if($announcement['fid'] == -1)
- {
- $global_announcements[$announcement['aid']] = $announcement;
- continue;
- }
- $announcements[$announcement['fid']][$announcement['aid']] = $announcement;
- }
- if($mybb->usergroup['issupermod'] == 1)
- {
- if($global_announcements && $mybb->usergroup['issupermod'] == 1)
- {
- // Get the global announcements
- foreach($global_announcements as $aid => $announcement)
- {
- $trow = alt_trow();
- if($announcement['startdate'] > TIME_NOW || ($announcement['enddate'] < TIME_NOW && $announcement['enddate'] != 0))
- {
- $icon = "<img src=\"{$theme['imgdir']}/minioff.gif\" alt=\"({$lang->expired})\" title=\"{$lang->expired_announcement}\" style=\"vertical-align: middle;\" /> ";
- }
- else
- {
- $icon = "<img src=\"{$theme['imgdir']}/minion.gif\" alt=\"({$lang->active})\" title=\"{$lang->active_announcement}\" style=\"vertical-align: middle;\" /> ";
- }
- $subject = htmlspecialchars_uni($announcement['subject']);
- eval("\$announcements_global .= \"".$templates->get("modcp_announcements_announcement_global")."\";");
- }
- }
- else
- {
- // No global announcements
- eval("\$announcements_global = \"".$templates->get("modcp_no_announcements_global")."\";");
- }
- eval("\$announcements_global = \"".$templates->get("modcp_announcements_global")."\";");
- }
- else
- {
- // Moderator is not super, so don't show global annnouncemnets
- $announcements_global = '';
- }
- fetch_forum_announcements();
- if(!$announcements_forum)
- {
- eval("\$announcements_forum = \"".$templates->get("modcp_no_announcements_forum")."\";");
- }
-
- $plugins->run_hooks("modcp_announcements");
-
- eval("\$announcements = \"".$templates->get("modcp_announcements")."\";");
- output_page($announcements);
- }
- if($mybb->input['action'] == "do_modqueue")
- {
- require_once MYBB_ROOT."inc/class_moderation.php";
- $moderation = new Moderation;
- // Verify incoming POST request
- verify_post_check($mybb->input['my_post_key']);
-
- $plugins->run_hooks("modcp_do_modqueue_start");
- if(is_array($mybb->input['threads']))
- {
- // Fetch threads
- $query = $db->simple_select("threads", "tid", "tid IN (".implode(",", array_map("intval", array_keys($mybb->input['threads'])))."){$flist}");
- while($thread = $db->fetch_array($query))
- {
- $action = $mybb->input['threads'][$thread['tid']];
- if($action == "approve")
- {
- $threads_to_approve[] = $thread['tid'];
- }
- else if($action == "delete")
- {
- $threads_to_delete[] = $thread['tid'];
- }
- }
- if(!empty($threads_to_approve))
- {
- $moderation->approve_threads($threads_to_approve);
- log_moderator_action(array('tids' => $threads_to_approve), $lang->multi_approve_threads);
- }
- if(!empty($threads_to_delete))
- {
- foreach($threads_to_delete as $tid)
- {
- $moderation->delete_thread($tid);
- }
- log_moderator_action(array('tids' => $threads_to_delete), $lang->multi_delete_threads);
- }
-
- $plugins->run_hooks("modcp_do_modqueue_end");
-
- redirect("modcp.php?action=modqueue", $lang->redirect_threadsmoderated);
- }
- else if(is_array($mybb->input['posts']))
- {
- // Fetch posts
- $query = $db->simple_select("posts", "pid", "pid IN (".implode(",", array_map("intval", array_keys($mybb->input['posts'])))."){$flist}");
- while($post = $db->fetch_array($query))
- {
- $action = $mybb->input['posts'][$post['pid']];
- if($action == "approve")
- {
- $posts_to_approve[] = $post['pid'];
- }
- else if($action == "delete")
- {
- $moderation->delete_post($post['pid']);
- }
- }
- if(is_array($posts_to_approve))
- {
- $moderation->approve_posts($posts_to_approve);
- }
- log_moderator_action(array('pids' => $posts_to_approve), $lang->multi_approve_posts);
-
- $plugins->run_hooks("modcp_do_modqueue_end");
-
- redirect("modcp.php?action=modqueue&type=posts", $lang->redirect_postsmoderated);
- }
- else if(is_array($mybb->input['attachments']))
- {
- $query = $db->query("
- SELECT a.pid, a.aid
- FROM ".TABLE_PREFIX."attachments a
- LEFT JOIN ".TABLE_PREFIX."posts p ON (a.pid=p.pid)
- LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
- WHERE aid IN (".implode(",", array_map("intval", array_keys($mybb->input['attachments'])))."){$tflist}
- ");
- while($attachment = $db->fetch_array($query))
- {
- $action = $mybb->input['attachments'][$attachment['aid']];
- if($action == "approve")
- {
- $db->update_query("attachments", array("visible" => 1), "aid='{$attachment['aid']}'");
- }
- else if($action == "delete")
- {
- remove_attachment($attachment['pid'], '', $attachment['aid']);
- }
- }
-
- $plugins->run_hooks("modcp_do_modqueue_end");
-
- redirect("modcp.php?action=modqueue&type=attachments", $lang->redirect_attachmentsmoderated);
- }
- }
- if($mybb->input['action'] == "modqueue")
- {
- if($mybb->input['type'] == "threads" || !$mybb->input['type'])
- {
- $forum_cache = $cache->read("forums");
- $query = $db->simple_select("threads", "COUNT(tid) AS unapprovedthreads", "visible=0 {$flist}");
- $unapproved_threads = $db->fetch_field($query, "unapprovedthreads");
- // Figure out if we need to display multiple pages.
- if($mybb->input['page'] != "last")
- {
- $page = intval($mybb->input['page']);
- }
- $perpage = $mybb->settings['threadsperpage'];
- $pages = $unapproved_threads / $perpage;
- $pages = ceil($pages);
- if($mybb->input['page'] == "last")
- {
- $page = $pages;
- }
- if($page > $pages || $page <= 0)
- {
- $page = 1;
- }
- if($page)
- {
- $start = ($page-1) * $perpage;
- }
- else
- {
- $start = 0;
- $page = 1;
- }
- $multipage = multipage($pages, $perpage, $page, "modcp.php?action=modqueue&type=threads");
- $query = $db->query("
- SELECT t.tid, t.dateline, t.fid, t.subject, p.message AS postmessage, u.username AS username, t.uid
- FROM ".TABLE_PREFIX."threads t
- LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=t.firstpost)
- LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
- WHERE t.visible='0' {$tflist}
- ORDER BY t.lastpost DESC
- LIMIT {$start}, {$perpage}
- ");
- while($thread = $db->fetch_array($query))
- {
- $altbg = alt_trow();
- $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
- $thread['threadlink'] = get_thread_link($thread['tid']);
- $thread['forumlink'] = get_forum_link($thread['fid']);
- $forum_name = $forum_cache[$thread['fid']]['name'];
- $threaddate = my_date($mybb->settings['dateformat'], $thread['dateline']);
- $threadtime = my_date($mybb->settings['timeformat'], $thread['dateline']);
- $profile_link = build_profile_link($thread['username'], $thread['uid']);
- $thread['postmessage'] = nl2br(htmlspecialchars_uni($thread['postmessage']));
- $forum = "<strong>{$lang->meta_forum} <a href=\"{$thread['forumlink']}\">{$forum_name}</a></strong>";
- eval("\$threads .= \"".$templates->get("modcp_modqueue_threads_thread")."\";");
- }
- if(!$threads && $mybb->input['type'] == "threads")
- {
- eval("\$threads = \"".$templates->get("modcp_modqueue_threads_empty")."\";");
- }
- if($threads)
- {
- add_breadcrumb($lang->mcp_nav_modqueue_threads, "modcp.php?action=modqueue&type=threads");
-
- $plugins->run_hooks("modcp_modqueue_threads_end");
-
- eval("\$mass_controls = \"".$templates->get("modcp_modqueue_masscontrols")."\";");
- eval("\$threadqueue = \"".$templates->get("modcp_modqueue_threads")."\";");
- output_page($threadqueue);
- }
- $type = 'threads';
- }
- if($mybb->input['type'] == "posts" || (!$mybb->input['type'] && !$threadqueue))
- {
- $forum_cache = $cache->read("forums");
- $query = $db->query("
- SELECT COUNT(pid) AS unapprovedposts
- FROM ".TABLE_PREFIX."posts p
- LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
- WHERE p.visible='0' {$tflist} AND t.firstpost != p.pid
- ");
- $unapproved_posts = $db->fetch_field($query, "unapprovedposts");
- // Figure out if we need to display multiple pages.
- if($mybb->input['page'] != "last")
- {
- $page = intval($mybb->input['page']);
- }
- $perpage = $mybb->settings['postsperpage'];
- $pages = $unapproved_posts / $perpage;
- $pages = ceil($pages);
- if($mybb->input['page'] == "last")
- {
- $page = $pages;
- }
- if($page > $pages || $page <= 0)
- {
- $page = 1;
- }
- if($page)
- {
- $start = ($page-1) * $perpage;
- }
- else
- {
- $start = 0;
- $page = 1;
- }
- $multipage = multipage($pages, $perpage, $page, "modcp.php?action=modqueue&type=posts");
- $query = $db->query("
- SELECT p.pid, p.subject, p.message, t.subject AS threadsubject, t.tid, u.username, p.uid, t.fid, p.dateline
- FROM ".TABLE_PREFIX."posts p
- LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
- LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
- WHERE p.visible='0' {$tflist} AND t.firstpost != p.pid
- ORDER BY p.dateline DESC
- LIMIT {$start}, {$perpage}
- ");
- while($post = $db->fetch_array($query))
- {
- $altbg = alt_trow();
- $post['threadsubject'] = htmlspecialchars_uni($parser->parse_badwords($post['threadsubject']));
- $post['threadlink'] = get_thread_link($post['tid']);
- $post['forumlink'] = get_forum_link($post['fid']);
- $post['postlink'] = get_post_link($post['pid'], $post['tid']);
- $forum_name = $forum_cache[$post['fid']]['name'];
- $postdate = my_date($mybb->settings['dateformat'], $post['dateline']);
- $posttime = my_date($mybb->settings['timeformat'], $post['dateline']);
- $profile_link = build_profile_link($post['username'], $post['uid']);
- $thread = "<strong>{$lang->meta_thread} <a href=\"{$post['threadlink']}\">{$post['threadsubject']}</a></strong>";
- $forum = "<strong>{$lang->meta_forum} <a href=\"{$post['forumlink']}\">{$forum_name}</a></strong><br />";
- $post['message'] = nl2br(htmlspecialchars_uni($post['message']));
- eval("\$posts .= \"".$templates->get("modcp_modqueue_posts_post")."\";");
- }
- if(!$posts && $mybb->input['type'] == "posts")
- {
- eval("\$posts = \"".$templates->get("modcp_modqueue_posts_empty")."\";");
- }
- if($posts)
- {
- add_breadcrumb($lang->mcp_nav_modqueue_posts, "modcp.php?action=modqueue&type=posts");
-
- $plugins->run_hooks("modcp_modqueue_posts_end");
-
- eval("\$mass_controls = \"".$templates->get("modcp_modqueue_masscontrols")."\";");
- eval("\$postqueue = \"".$templates->get("modcp_modqueue_posts")."\";");
- output_page($postqueue);
- }
- }
- if($mybb->input['type'] == "attachments" || (!$mybb->input['type'] && !$postqueue && !$threadqueue))
- {
- $query = $db->query("
- SELECT COUNT(aid) AS unapprovedattachments
- FROM ".TABLE_PREFIX."attachments a
- LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
- LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
- WHERE a.visible='0' {$tflist}
- ");
- $unapproved_attachments = $db->fetch_field($query, "unapprovedattachments");
- // Figure out if we need to display multiple pages.
- if($mybb->input['page'] != "last")
- {
- $page = intval($mybb->input['page']);
- }
- $perpage = $mybb->settings['postsperpage'];
- $pages = $unapproved_attachments / $perpage;
- $pages = ceil($pages);
- if($mybb->input['page'] == "last")
- {
- $page = $pages;
- }
- if($page > $pages || $page <= 0)
- {
- $page = 1;
- }
- if($page)
- {
- $start = ($page-1) * $perpage;
- }
- else
- {
- $start = 0;
- $page = 1;
- }
- $multipage = multipage($pages, $perpage, $page, "modcp.php?action=modqueue&type=attachments");
- $query = $db->query("
- SELECT a.*, p.subject AS postsubject, p.dateline, p.uid, u.username, t.tid, t.subject AS threadsubject
- FROM ".TABLE_PREFIX."attachments a
- LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
- LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
- LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
- WHERE a.visible='0'
- ORDER BY a.dateuploaded DESC
- LIMIT {$start}, {$perpage}
- ");
- while($attachment = $db->fetch_array($query))
- {
- $altbg = alt_trow();
- if(!$attachment['dateuploaded'])
- {
- $attachment['dateuploaded'] = $attachment['dateline'];
- }
-
- $attachdate = my_date($mybb->settings['dateformat'], $attachment['dateuploaded']);
- $attachtime = my_date($mybb->settings['timeformat'], $attachment['dateuploaded']);
- $attachment['postsubject'] = htmlspecialchars_uni($attachment['postsubject']);
- $attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
- $attachment['threadsubject'] = htmlspecialchars_uni($attachment['threadsubject']);
- $attachment['filesize'] = get_friendly_size($attachment['filesize']);
- $link = get_post_link($attachment['pid'], $attachment['tid']) . "#pid{$attachment['pid']}";
- $thread_link = get_thread_link($attachment['tid']);
- $profile_link = build_profile_link($attachment['username'], $attachment['uid']);
- eval("\$attachments .= \"".$templates->get("modcp_modqueue_attachments_attachment")."\";");
- }
- if(!$attachments && $mybb->input['type'] == "attachments")
- {
- eval("\$attachments = \"".$templates->get("modcp_modqueue_attachments_empty")."\";");
- }
- if($attachments)
- {
- add_breadcrumb($lang->mcp_nav_modqueue_attachments, "modcp.php?action=modqueue&type=attachments");
-
- $plugins->run_hooks("modcp_modqueue_attachments_end");
-
- eval("\$mass_controls = \"".$templates->get("modcp_modqueue_masscontrols")."\";");
- eval("\$attachmentqueue = \"".$templates->get("modcp_modqueue_attachments")."\";");
- output_page($attachmentqueue);
- }
- }
- // Still nothing? All queues are empty! :-D
- if(!$threadqueue && !$postqueue && !$attachmentqueue)
- {
- add_breadcrumb($lang->mcp_nav_modqueue, "modcp.php?action=modqueue");
-
- $plugins->run_hooks("modcp_modqueue_end");
-
- eval("\$queue = \"".$templates->get("modcp_modqueue_empty")."\";");
- output_page($queue);
- }
- }
- if($mybb->input['action'] == "do_editprofile")
- {
- // V…
Large files files are truncated, but you can click here to view the full file