Не мога мещо да го направя тоя мод да стане за панела ако можете направете ми го

<?php
/***************************************************************************
* admin_reports.php
* -------------------
* begin : Fryday, Mar 30, 2007
* copyright : (C) 2001 Wicher
* email : ---
*
* $Id: admin_reports.php,v 1.0.0 2007/03/30 23:33:13 Wicher Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
//
// Load default header
//
$no_page_header = TRUE;
$phpbb_root_path = './../';
require($phpbb_root_path . 'extension.inc');
if (!class_exists('Template'))
{
require('./pagestart.' . $phpEx);
}
$sql = "SELECT *
FROM " . REPORTS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain banlist information", "", __LINE__, __FILE__, $sql);
}
$reports = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$total_reports = count($reports);
if ($board_config['ReportSystem'])
{
if( !empty($setmodules) )
{
$filename = basename(__FILE__);
$module['General']['Съобщения ('.$total_reports.')'] = $filename;
return;
}
if (isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']))
{
$mode = (isset($HTTP_POST_VARS['mode'])) ? htmlspecialchars($HTTP_POST_VARS['mode']) : htmlspecialchars($HTTP_GET_VARS['mode']);
}
else
{
$mode = '';
}
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
$start = ($start < 0) ? 0 : $start;
// Start program
if (!$mode)
{
$template->set_filenames(array(
'body' => 'admin/reports_body.tpl')
);
if ($total_reports == 0)
{
$template->assign_block_vars('switch_no_reports', array());
}
else
{
$template->assign_block_vars('switch_reports', array());
}
$template->assign_vars(array(
'L_REPORT_TITLE' => $lang['Report_admin_title'],
'L_REPORT_TITLE_EXPLAIN' => $lang['Report_admin_title_explain'],
'L_POSTREPORTS' => $lang['Reports'],
'L_EDIT_LINK' => $lang['Edit_this_profile'],
'L_VIEW_LINK' => $lang['View_this_profile'],
'L_SEND_PM' => $lang['Send_pm'],
'L_GOTOPOST' => $lang['GoToPost'],
'L_NO_REPORTS' => $lang['no_reports'],
'L_DELETE_THIS_REPORT' => $lang['Delete_this_report'],
'L_DELETE_ALL_REPORTS' => $lang['Delete_all_reports'],
'L_OVERALL_INFO' => $lang['Overall_info'],
'L_REPORT_REASON' => $lang['Report_reason'],
'L_REPORTSTATUS' => $lang['Reportstatus'],
'L_REPORTID' => $lang['Report_ID'],
'L_REPORTTIME' => $lang['ReportTime'],
'L_REPORTER' => $lang['Reporter'],
'L_POSTPOSTERNAME' => $lang['PostPostername'],
'L_SET_AS' => $lang['SetAs'],
'L_NEWREPORT' => $lang['NewReport'],
'L_UNDER_EXAMINATION' => $lang['UnderExamination'],
'L_CLOSED' => $lang['Closed'],
'L_SET_MESS' => $lang['set_mess'],
'L_MESS' => $lang['postmessyes_no'],
'U_DELETE_ALL_REPORTS' => append_sid("admin_reports.$phpEx?mode=delete_all"),
'PAGINATION' => generate_pagination("admin_reports.$phpEx?np=y", $total_reports, $board_config['posts_per_page'], $start),
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['posts_per_page'] ) + 1 ), ceil( $total_reports / $board_config['posts_per_page'] ))
));
$sql = "SELECT *
FROM " . REPORTS_TABLE . "
ORDER BY report_time DESC
LIMIT $start, ".$board_config['posts_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain banlist information", "", __LINE__, __FILE__, $sql);
}
$reports = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$total_reports = count($reports);
for($i = 0; $i < $total_reports; $i++)
{
$report_id = $reports[$i]['report_id'];
$topic_id = $reports[$i]['topic_id'];
$post_id = $reports[$i]['post_id'];
$user_id = $reports[$i]['user_id'];
$report_time = create_date($board_config['default_dateformat'], $reports[$i]['report_time'], $board_config['board_timezone']);
$reporter_id = $reports[$i]['reporter_id'];
$report_reason = $reports[$i]['report_reason'];
$report_status = $reports[$i]['report_status'];
$assigned_to = $reports[$i]['assigned_to'];
$sql = "SELECT username FROM " . USERS_TABLE . "
WHERE user_id = $assigned_to";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain assigned to data', '', __LINE__, __FILE__, $sql);
}
$this_userdata = $db->sql_fetchrow($result);
if ($this_userdata['username'])
{
$assigned_to_name = $lang['assigned_to'] . ' ' . $this_userdata['username'];
}
else
{
$assigned_to_name = '';
}
$db->sql_freeresult($result);
if ($report_status == 1)
{
$report_status_img = $images['report_red'];
$l_report_status = $lang['NewReport'];
}
if ($report_status == 2)
{
$report_status_img = $images['report_orange'];
$l_report_status = $lang['UnderExamination'];
}
if ($report_status == 3)
{
$report_status_img = $images['report_blue'];
$l_report_status = $lang['Closed'];
}
if ($user_id && $user_id != ANONYMOUS)
{
$sql = "SELECT username FROM " . USERS_TABLE . "
WHERE user_id = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain this users data', '', __LINE__, __FILE__, $sql);
}
$this_userdata = $db->sql_fetchrow($result);
$this_username = $this_userdata['username'];
$db->sql_freeresult($result);
$l_guest = '';
$u_baduser_editprofilelink = '<a href="'.append_sid("admin_users.$phpEx?mode=edit&".POST_USERS_URL."=" . $user_id).'">'.$lang['Edit_this_profile'].'</a>';
$u_baduser_viewprofilelink = '<a href="'.append_sid($phpbb_root_path."profile.$phpEx?mode=viewprofile&&".POST_USERS_URL."=" . $user_id).'">'.$lang['View_this_profile'].'</a>';
$u_baduser_send_pm = '<a href="'.append_sid($phpbb_root_path."privmsg.php?mode=post&" . POST_USERS_URL . "=" . $user_id).'">'.$lang['Send_pm'].'</a>';
$sql = "SELECT reported_mess FROM " . POSTS_TABLE . "
WHERE post_id = $post_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain this users data', '', __LINE__, __FILE__, $sql);
}
$this_postmess = $db->sql_fetchrow($result);
$reported_mess = $this_postmess['reported_mess'];
}
else
{
$sql = "SELECT post_username, reported_mess FROM " . POSTS_TABLE . "
WHERE post_id = $post_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain this users data', '', __LINE__, __FILE__, $sql);
}
$this_userdata = $db->sql_fetchrow($result);
$this_username = $this_userdata['post_username'];
$db->sql_freeresult($result);
$l_guest = ' (<i>' . $lang['Guest'] . '</i>)';
$user_id = ANONYMOUS;
$u_baduser_editprofilelink = '';
$u_baduser_viewprofilelink = '';
$u_baduser_send_pm = '';
$reported_mess = $this_userdata['reported_mess'];
}
// get reporters name
$sql = "SELECT username FROM " . USERS_TABLE . "
WHERE user_id = $reporter_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain this users data', '', __LINE__, __FILE__, $sql);
}
$this_userdata = $db->sql_fetchrow($result);
$this_reportername = $this_userdata['username'];
$db->sql_freeresult($result);
//
// Again this will be handled by the templating
// code at some point
//
$row_class = ( !($i % 2) ) ? 'row1' : 'row2';
$divider_height = ($i < $total_reports-1) ? '14' : '0';
$template->assign_block_vars('reportrow', array(
'DIVIDER_TD_HEIGHT' => $divider_height,
'ROW_CLASS' => $row_class,
'REPORT_ID' => $report_id,
'BAD_USERNAME' => $this_username,
'BAD_USER_ID' => $user_id,
'GUEST' => $l_guest,
'REPORTER_NAME' => $this_reportername,
'REPORTER_ID' => $reporter_id,
'REPORT_TIME' => $report_time,
'REPORT_REASON' => $report_reason,
'POST_ID' => $post_id,
'REPORT_CURRENT_STATUS_IMG' => $phpbb_root_path.$report_status_img,
'REPORT_RED_STATUS_IMG' => $phpbb_root_path.$images['report_red'],
'REPORT_ORANGE_STATUS_IMG' => $phpbb_root_path.$images['report_orange'],
'REPORT_BLUE_STATUS_IMG' => $phpbb_root_path.$images['report_blue'],
'MESS_IMG' => ($reported_mess != 1) ? $phpbb_root_path.$images['reported_mess_no'] : $phpbb_root_path.$images['reported_mess_yes'],
'REPORT_STATUS' => $l_report_status,
'ASSIGNED_TO' => $assigned_to_name,
'U_DELETE_REPORT' => append_sid("admin_reports.$phpEx?mode=delete&report=".$report_id."&" . POST_POST_URL . "=" . $post_id . "&start=".$start),
'U_SET_RED' => append_sid("admin_reports.$phpEx?mode=update&status=1&report=".$report_id."&start=".$start),
'U_SET_ORANGE' => append_sid("admin_reports.$phpEx?mode=update&status=2&report=".$report_id."&start=".$start),
'U_SET_BLUE' => append_sid("admin_reports.$phpEx?mode=update&status=3&report=".$report_id."&start=".$start),
'U_SET_MESS' => append_sid("admin_reports.$phpEx?mode=set_mess&report=".$report_id."&" . POST_POST_URL . "=" . $post_id . "&start=".$start),
'U_EDIT_BAD_USERNAME' => $u_baduser_editprofilelink,
'U_VIEW_BAD_USERNAME' => $u_baduser_viewprofilelink,
'U_SEND_BADUSER_PM' => $u_baduser_send_pm,
'U_EDIT_REPORTER' => append_sid("admin_users.$phpEx?mode=edit&" . POST_USERS_URL . "=" . $reporter_id),
'U_VIEW_REPORTER' => append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $reporter_id),
'U_SEND_REPORTER_PM' => append_sid($phpbb_root_path . "privmsg.php?mode=post&" . POST_USERS_URL . "=" . $reporter_id),
'U_GOTO_POST' => append_sid($phpbb_root_path . "viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id
));
}
include('./page_header_admin.' . $phpEx);
$template->pparse('body');
include('./page_footer_admin.' . $phpEx);
}
else if ($mode == 'update')
{
$status = intval($HTTP_GET_VARS['status']);
$report_id = intval($HTTP_GET_VARS['report']);
if ($status == 2)
{
$add_sql = ', assigned_to = '.$userdata['user_id'];
}
if ($status == 1) //if you add " || $status == 3" here finished reports wont show the name of the one that treated the reoprt.
{
$add_sql = ', assigned_to = 0';
}
$sql = "UPDATE " . REPORTS_TABLE . "
SET report_status = $status $add_sql
WHERE report_id = $report_id";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not update reportstatus', '', __LINE__, __FILE__, $sql);
}
redirect(append_sid("admin/admin_reports.$phpEx?start=$start", true));
}
else if ($mode == 'delete')
{
$report_id = intval($HTTP_GET_VARS['report']);
$sql = "DELETE
FROM " . REPORTS_TABLE . "
WHERE report_id = $report_id";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not delete report', '', __LINE__, __FILE__, $sql);
}
if (isset($HTTP_GET_VARS[POST_POST_URL]))
{
$post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
}
else
{
message_die(GENERAL_ERROR, 'post ID not set, cannot update posts table', '', __LINE__, __FILE__, $sql);
}
$sql = "UPDATE " . POSTS_TABLE . "
SET reported = 0
WHERE post_id = $post_id";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not update reportstatus', '', __LINE__, __FILE__, $sql);
}
$sql = "SELECT *
FROM " . REPORTS_TABLE . "
LIMIT $start, ".$board_config['posts_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain reportlist information", "", __LINE__, __FILE__, $sql);
}
$reports = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$total_reports = count($reports);
if ($total_reports == 0)
{
$start = $start-$board_config['posts_per_page'];
}
redirect(append_sid("admin/admin_reports.$phpEx?start=$start", true));
}
else if ($mode == 'delete_all')
{
$sql = "SELECT *
FROM " . REPORTS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain reportslist information", "", __LINE__, __FILE__, $sql);
}
$reports = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
for($j = 0; $j < count($reports); $j++)
{
$post_id_list .= ( ($post_id_list != '') ? ', ' : '' ) . $reports[$j]['post_id'];
}
$sql = "UPDATE " . POSTS_TABLE . "
SET reported = 0
WHERE post_id IN ($post_id_list)";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not update reportstatus', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE
FROM " . REPORTS_TABLE . "
WHERE report_id > 0";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not delete reports', '', __LINE__, __FILE__, $sql);
}
redirect(append_sid("admin/admin_reports.$phpEx", true));
}
else if ($mode == 'set_mess')
{
if (isset($HTTP_GET_VARS[POST_POST_URL]))
{
$post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
}
else
{
message_die(GENERAL_ERROR, 'post ID not set, cannot update posts table', '', __LINE__, __FILE__, $sql);
}
$sql = "SELECT reported_mess
FROM " . POSTS_TABLE . "
WHERE post_id = $post_id
LIMIT 1";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain report mess information", "", __LINE__, __FILE__, $sql);
}
$mess_info = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$cur_mess_setting = intval($mess_info['reported_mess']);
$reported_mess = ($cur_mess_setting == 1) ? 0 : 1;
$sql = "UPDATE " . POSTS_TABLE . "
SET reported_mess = $reported_mess
WHERE post_id = $post_id";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not update reportstatus', '', __LINE__, __FILE__, $sql);
}
$sql = "SELECT *
FROM " . REPORTS_TABLE . "
LIMIT $start, ".$board_config['posts_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain reportlist information", "", __LINE__, __FILE__, $sql);
}
$reports = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$total_reports = count($reports);
if ($total_reports == 0)
{
$start = $start-$board_config['posts_per_page'];
}
redirect(append_sid("admin/admin_reports.$phpEx?start=$start", true));
}
}
?>