Jump to content

Recommended Posts

hey guys, i have been working on making a script vbulletin 3.7.x compatable and am having trouble with one last page, i cannot get it to display anything other than blankness, any pointers would be greatly appreciated/ I think it may be issues with the sql but im not sure

 

 

<?php

error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);
$phrasegroups = array('postreports', 'cpuser');
$specialtemplates = array();
$globaltemplates = array();
$actiontemplates = array();

require_once('./global.php');
require_once('./includes/functions.php');
require_once('./includes/adminfunctions.php');
require_once('./includes/adminfunctions_user.php');

print_cp_header($vbphrase['postreports']);

if ($_REQUEST['do'] == 'closed')
{
        globalize($_REQUEST, array('page' => INT));

$perpage = 5;
$totalreports = $DB_site->query_first("
	SELECT COUNT(p.reportid) AS reportcount
	FROM " . TABLE_PREFIX . "postreport p
	WHERE p.status = 2
");

        $reportcount = $totalreports['reportcount'];

if ($reportcount == 0)
{
	print_stop_message('postreports_noclosed');
}

        sanitize_pageresults($reportcount, $page, $perpage);
$startat = ($page - 1) * $perpage;
$totalpages = ceil($reportcount / $perpage);

$searchquery = "
	SELECT
	postreport.*,
	user.username modname,
	user2.username reporter,
	post.username postername,
	post.userid posterid,
	thread.title,
	thread.threadid,
	forum.title forumtitle,
	forum.forumid
	FROM " . TABLE_PREFIX . "postreport AS postreport
	LEFT JOIN " . TABLE_PREFIX . "user AS user ON (postreport.modid = user.userid)
	LEFT JOIN " . TABLE_PREFIX . "user AS user2 ON (postreport.userid = user2.userid)
	LEFT JOIN " . TABLE_PREFIX . "post AS post ON (postreport.postid = post.postid)
	LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)
	LEFT JOIN " . TABLE_PREFIX . "forum AS forum ON (thread.forumid = forum.forumid)
	WHERE postreport.status = 2
	ORDER BY dateline DESC
	LIMIT $startat, $perpage
";

$postreports = $DB_site->query($searchquery);

	if ($page != 1)
	{
		$prv = $page - 1;
		$firstpage = "<input type=\"button\" class=\"button\" value=\"« " . $vbphrase['first_page'] . "\" tabindex=\"1\" onclick=\"window.location='postreports.php?$session[sessionurl]do=closed&=$perpage&page=1'\">";
		$prevpage = "<input type=\"button\" class=\"button\" value=\"< " . $vbphrase['prev_page'] . "\" tabindex=\"1\" onclick=\"window.location='postreports.php?$session[sessionurl]do=closed&page=$prv'\">";
	}

	if ($page != $totalpages)
	{
		$nxt = $page + 1;
		$nextpage = "<input type=\"button\" class=\"button\" value=\"" . $vbphrase['next_page'] . " >\" tabindex=\"1\" onclick=\"window.location='postreports.php?$session[sessionurl]do=closed&page=$nxt'\">";
		$lastpage = "<input type=\"button\" class=\"button\" value=\"" . $vbphrase['last_page'] . " »\" tabindex=\"1\" onclick=\"window.location='postreports.php?$session[sessionurl]do=closed&page=$totalpages'\">";
	}	

print_form_header();
print_table_header("Page $page of $totalpages. There are $reportcount closed reports.", 4);
print_table_footer(4, "$firstpage $prevpage   $nextpage $lastpage");		

while ($postreport = $DB_site->fetch_array($postreports))
{
	print_form_header('postreports', 'update');

	$postreport['datelinetime'] =
		vbdate($vboptions['timeformat'], $postreport['dateline']);
	$postreport['datelinedate'] =
		vbdate($vboptions['dateformat'], $postreport['dateline']);					 		
	$title = "" . $vbphrase['postreports_postreportfrom'] .
		 " <a href=\"" .
		 $vboptions['bburl'] .
		 "/member.php?u=" .
		 $postreport['userid'] .
		 "\" target=\"new\">" .
		 $postreport['reporter'] .
		 "</a> @ " .
		 $postreport['datelinedate'] . " " . $postreport['datelinetime'];

	print_table_header($title, 2);	


	$cell = array();

	$cell[] = "<input type=\"hidden\" name=\"reportid\" value=\"" .
	          $postreport['reportid'] .
	          "\">" .
	          "<input type=\"hidden\" name=\"page\" value=\"closed\">" .
		  $vbphrase[postreports_postnumber] .
		  ": " .
		  "<a href=\"" .
		  $vboptions['bburl'] .
		  "/showpost.php?postid=" .
		  $postreport['postid'] .
		  "\" target=\"new\">[" .
		  $postreport['postid'] .
		  "]</a>";
	$cell[] = "" . $vbphrase[postreports_postedby] .
		  ": " .
		  "<a href=\"" .
		  $vboptions[bburl] .
		  "/member.php?u=" .
		  $postreport[posterid] .
		  "\" target=\"new\">" .
		  $postreport[postername] .
		  "</a>";		
	print_cells_row($cell);

	$cell = array();

	$cell[] = "" . $vbphrase[postreports_onthread] .
		  ": " .
		  "<a href=\"" . 
		  $vboptions[bburl] .
		  "/showthread.php?p=" .
		  $postreport[postid] .
		  "\" target=\"new\">" .
		  $postreport[title] .
		  "</a>";
		  
	$cell[] = "" . $vbphrase[postreports_inforum] .
		  ": " .
		  "<a href=\"" . 
		  $vboptions[bburl] .
		  "/forumdisplay.php?f=" .
		  $postreport[forumid] .
		  "\" target=\"new\">" .
		  $postreport[forumtitle] .
		  "</a>";

	print_cells_row($cell);

	$cell = array();

	$cell[] = "" . $vbphrase[postreports_usercomment] . ":<br/><br/>" .
		   "<textarea rows=\"6\" cols=\"40\" disabled>" .
		   $postreport['reporttext'] .
		   "</textarea>";

	$cell[] = "" . $vbphrase[postreports_modcomment] . ":<br/><br/>" .
		  "<textarea id=\"modtext\" name=\"modtext\" rows=\"6\" cols=\"40\">" .
		  $postreport['modtext'] .
		  "</textarea>";		

	print_cells_row($cell);

	$cell = array();

	$cell[] = "" . $vbphrase[postreports_moderator] . ": " .
		  $postreport[modname];			

	if ($postreport['updatetime'] != null)
	{
	    $postreport['updatetimetime'] =
		vbdate($vboptions['timeformat'], $postreport['updatetime']);
	    $postreport['updatetimedate'] =
		vbdate($vboptions['dateformat'], $postreport['updatetime']);		
	    $cell[] = "" . $vbphrase[postreports_updated] . ": " .
	        $postreport['updatetimedate'] . " " . $postreport['updatetimetime'];		
	}
	else
	{
	    $cell[] = "" . $vbphrase[postreports_updated] . ": -";
	}

	print_cells_row($cell);

	$cell = array();

	$cell[] = "";


	switch ($postreport['status'])
	{
	case 1:
		$cell[] =  "" . $vbphrase[postreports_status] . ":<br/>" .
		  	   "<select id=\"status\" name=\"status\">" .
		  	   "<option value=\"0\">Open" .
		           "<option value=\"1\" selected>Pending" .
		           "<option value=\"2\">Closed" .
		           "</select>";						
		break;
	case 2:
		$cell[] =  "" . $vbphrase[postreports_status] . ":<br/>" .
		  	   "<select id=\"status\" name=\"status\">" .
		  	   "<option value=\"0\">Open" .
		           "<option value=\"1\">Pending" .
		           "<option value=\"2\" selected>Closed" .
		           "</select>";						
	 	break;
	case 0:
	default:
		$cell[] =  "" . $vbphrase[postreports_status] . ":<br/>" .
		  	   "<select id=\"status\" name=\"status\">" .
		  	   "<option value=\"0\" selected>Open" .
		           "<option value=\"1\">Pending" .
		           "<option value=\"2\">Closed" .
		           "</select>";				
		break;


	}
	print_cells_row($cell);
	print_submit_row("Save", "Reset", 4);
	print_table_footer();
}

print_form_header();
print_table_header("Page $page of $totalpages. There are $reportcount closed reports.", 4);
print_table_footer(4, "$firstpage $prevpage   $nextpage $lastpage");
}

if ($_REQUEST['do'] == 'list')
{
$totalreports = $DB_site->query_first("
	SELECT COUNT(p.reportid) AS reportcount
	FROM " . TABLE_PREFIX . "postreport p
	WHERE p.status < 2
");

if ($totalreports['reportcount'] == 0)
{
	print_stop_message('postreports_nooutstanding');
}

        $reports_per_page = 25;

        $totalpages = ceil(($totalreports[reportcount]) / $reports_per_page);
        $pagenumber = $_REQUEST['page'];

        if ($pagenumber == "" || $pagenumber == "0" || $pagenumber < 0)
        {
    $pagenumber = 1;
        }
        $page_start = ($pagenumber - 1) * $reports_per_page;
        $perpage = 1;
        
        $pagenav = construct_page_nav($totalpages, "postreports.php?$session[sessionurl]");
        
        echo $pagenav;

$searchquery = "
	SELECT
	postreport.*,
	user.username modname,
	user2.username reporter,
	post.username postername,
	post.userid posterid,
	thread.title,
	thread.threadid,
	forum.title forumtitle,
	forum.forumid
	FROM " . TABLE_PREFIX . "postreport AS postreport
	LEFT JOIN " . TABLE_PREFIX . "user AS user ON (postreport.modid = user.userid)
	LEFT JOIN " . TABLE_PREFIX . "user AS user2 ON (postreport.userid = user2.userid)
	LEFT JOIN " . TABLE_PREFIX . "post AS post ON (postreport.postid = post.postid)
	LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)
	LEFT JOIN " . TABLE_PREFIX . "forum AS forum ON (thread.forumid = forum.forumid)
	WHERE postreport.status < 2
	ORDER BY dateline DESC
	LIMIT $page_start, $reports_per_page
";

$postreports = $DB_site->query($searchquery);

while ($postreport = $DB_site->fetch_array($postreports))
{
	print_form_header('postreports', 'update');

	$postreport['datelinetime'] =
		vbdate($vboptions['timeformat'], $postreport['dateline']);
	$postreport['datelinedate'] =
		vbdate($vboptions['dateformat'], $postreport['dateline']);					 		
	$title = "" . $vbphrase['postreports_postreportfrom'] .
		 " <a href=\"" .
		 $vboptions['bburl'] .
		 "/member.php?u=" .
		 $postreport['userid'] .
		 "\" target=\"new\">" .
		 $postreport['reporter'] .
		 "</a> @ " .
		 $postreport['datelinedate'] . " " . $postreport['datelinetime'];

	print_table_header($title, 2);	


	$cell = array();

	$cell[] = "<input type=\"hidden\" name=\"reportid\" value=\"" .
	          $postreport['reportid'] .
	          "\">" .
	          "<input type=\"hidden\" name=\"page\" value=\"list\">" .
		  $vbphrase[postreports_postnumber] .
		  ": " .
		  "<a href=\"" .
		  $vboptions['bburl'] .
		  "/showpost.php?postid=" .
		  $postreport['postid'] .
		  "\" target=\"new\">[" .
		  $postreport['postid'] .
		  "]</a>";
	$cell[] = "" . $vbphrase[postreports_postedby] .
		  ": " .
		  "<a href=\"" .
		  $vboptions[bburl] .
		  "/member.php?u=" .
		  $postreport[posterid] .
		  "\" target=\"new\">" .
		  $postreport[postername] .
		  "</a>";		
	print_cells_row($cell);

	$cell = array();

	$cell[] = "" . $vbphrase[postreports_onthread] .
		  ": " .
		  "<a href=\"" . 
		  $vboptions[bburl] .
		  "/showthread.php?p=" .
		  $postreport[postid] .
		  "\" target=\"new\">" .
		  $postreport[title] .
		  "</a>";
		  
	$cell[] = "" . $vbphrase[postreports_inforum] .
		  ": " .
		  "<a href=\"" . 
		  $vboptions[bburl] .
		  "/forumdisplay.php?f=" .
		  $postreport[forumid] .
		  "\" target=\"new\">" .
		  $postreport[forumtitle] .
		  "</a>";

	print_cells_row($cell);

	$cell = array();

	$cell[] = "" . $vbphrase[postreports_usercomment] . ":<br/><br/>" .
		   "<textarea rows=\"6\" cols=\"40\" disabled>" .
		   $postreport['reporttext'] .
		   "</textarea>";

	$cell[] = "" . $vbphrase[postreports_modcomment] . ":<br/><br/>" .
		  "<textarea id=\"modtext\" name=\"modtext\" rows=\"6\" cols=\"40\">" .
		  $postreport['modtext'] .
		  "</textarea>";		

	print_cells_row($cell);

	$cell = array();

	$cell[] = "" . $vbphrase[postreports_moderator] . ": " .
		  $postreport[modname];			

	if ($postreport['updatetime'] != null)
	{
	    $postreport['updatetimetime'] =
		vbdate($vboptions['timeformat'], $postreport['updatetime']);
	    $postreport['updatetimedate'] =
		vbdate($vboptions['dateformat'], $postreport['updatetime']);		
	    $cell[] = "" . $vbphrase[postreports_updated] . ": " .
	        $postreport['updatetimedate'] . " " . $postreport['updatetimetime'];		
	}
	else
	{
	    $cell[] = "" . $vbphrase[postreports_updated] . ": -";
	}		

	print_cells_row($cell);

	$cell = array();

	$cell[] = "";


	switch ($postreport['status'])
	{
	case 1:
		$cell[] =  "" . $vbphrase[postreports_status] . ":<br/>" .
		  	   "<select id=\"status\" name=\"status\">" .
		  	   "<option value=\"0\">Open" .
		           "<option value=\"1\" selected>Pending" .
		           "<option value=\"2\">Closed" .
		           "</select>";						
		break;
	case 2:
		$cell[] =  "" . $vbphrase[postreports_status] . ":<br/>" .
		  	   "<select id=\"status\" name=\"status\">" .
		  	   "<option value=\"0\">Open" .
		           "<option value=\"1\">Pending" .
		           "<option value=\"2\" selected>Closed" .
		           "</select>";						
	 	break;
	case 0:
	default:
		$cell[] =  "" . $vbphrase[postreports_status] . ":<br/>" .
		  	   "<select id=\"status\" name=\"status\">" .
		  	   "<option value=\"0\" selected>Open" .
		           "<option value=\"1\">Pending" .
		           "<option value=\"2\">Closed" .
		           "</select>";				
		break;


	}
	print_cells_row($cell);
	print_submit_row("Save", "Reset", 4);
	print_table_footer();
}
}

if ($_POST['do'] == 'update')
{
$status = $_POST['status'];
$modtext = addslashes(htmlspecialchars_uni($_POST['modtext']));
$reportid = $_POST['reportid'];
$page = $_POST['page'];
$modid =  $bbuserinfo['userid'];

$DB_site->query("
	UPDATE " . TABLE_PREFIX . "postreport
	SET status = $status, modtext = '$modtext',
	updatetime = " . TIMENOW . ", modid = $modid
	WHERE reportid = $reportid
");

if ($page == "list")
{
	define('CP_REDIRECT', "postreports.php?do=list");
}
else
{
	define('CP_REDIRECT', "postreports.php?do=closed");
}

print_stop_message('postreports_updatedreport');
}

print_cp_footer();

?>

Link to comment
https://forums.phpfreaks.com/topic/138636-upgrading-a-script/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.