Location: PHPKode > scripts > MobileBB > mobilebb_2.9.7/mobilebb/include/admin.php
<?	
if ($user_level!=9) die("Access denied.");
if (isset($_GET['action2'])) $action2=$_GET['action2']; else $action2 = '';

if ($action2=='mkforum') 
	{mysql_query("INSERT INTO board_forums (`forum_name`,`forum_parent`)
		VALUES ('Example ".rand(1,99)."','0') ") or die(mysql_error());echo '--- DONE - one random topic created.<br>';};


echo '<table border=1><caption>General Statistics:</caption>';

echo "<tr><td>";
$result = mysql_query("SELECT count(user_email) as a from board_users") or die(mysql_error()); 
$row = mysql_fetch_assoc($result);
echo "User Accounts:".$row['a']."<br>\r\nLast Registered:<br>";
$result = mysql_query("SELECT * FROM board_users order by user_reg_dt desc limit 10") or die(mysql_error()); 
while($row = mysql_fetch_array($result))
	{
	echo $row['user_reg_ip'].' '.date("Y-m-d",$row['user_reg_dt']).' '.$row['user_email'].' <br>';
	}

echo "</td><td>Last login:<br>";
$result = mysql_query("SELECT * FROM board_users order by user_lastlogin_dt desc limit 10") or die(mysql_error()); 
while($row = mysql_fetch_array($result))
	{
	echo date("Y-m-d H:i",$row['user_lastlogin_dt']).' '.$row['user_email'].' <br>';
	}

echo "</td><td>";
$result = mysql_query("SELECT count(topic_id) as a from board_topics") or die(mysql_error()); 
$row = mysql_fetch_assoc($result);
echo "Topics:".$row['a']."<br>\r\nLast posted topics:<br>";
$result = mysql_query("SELECT * FROM board_topics order by topic_create_dt desc limit 10") or die(mysql_error()); 
while($row = mysql_fetch_array($result))
	{
	echo date("Y-m-d",$row['topic_create_dt']).' <a href=\'?action=vtopic&id='.$row['topic_id'].'\'>'.$row['topic_title'].'</a> <br>';
	}


echo "</td><td>Top talkers:<br>\r\n";
$result = mysql_query("SELECT count(topic_poster_id) as a,topic_poster_id FROM `board_topics` group by `topic_poster_id` order by a limit 10") or die(mysql_error()); 
while($row = mysql_fetch_array($result))
	{
	echo $row['a'].' '.get_username($row['topic_poster_id']).'</a> <br>';
	}
echo "</td></tr></table><hr>";

// ================= EDIT_TOPIC START
if (isset($_GET['id'])) $id=$_GET['id']; else $id='';
if ($action2=='edit_topic')
	{
	if (isset($_POST['submit']))
		{
		$id=$_POST['id'];
		$query_sub='';
//		print_r ($_REQUEST['edit']);
//		Warning: mysql_real_escape_string() expects parameter 1 to be string
//		As we push array which conflict with purity real scape, but works. sorry. TODO
		echo '<font color=red>Do not worry about top mysql_real_escape errors if any :(</font><br>';		
		foreach ($_REQUEST['edit'] as $key=>$value)
			{
//			echo "$key $value<br>";
			$query_sub.="`$key`='$value',";
			}	// foreach edit
		$query="UPDATE board_topics set ".substr($query_sub,0,-1)." where topic_id='".$id."' limit 1";
//		echo $query;
		mysql_query($query) or die(mysql_error());
		echo "<div class=success>Update complete even errors can appeared.</div>";
		}	// if isset submit

	echo "Edit topic:<br><form method=post enctype=\"multipart/form-data\">";
	$result = mysql_query("SELECT * from board_topics where topic_id='".$id."' limit 1") or die(mysql_error()); 
	while($row = mysql_fetch_assoc($result))
		{
//		print_r ($row);
		foreach ($row as $key=>$row2) {
			echo "$key:<input type=text name='edit[".$key."]' value='".$row2."'><br>";
			}	// foreach 
		}	// while
	echo "<br>
		<input type=hidden name=id value='".$id."'>
		<input type=submit name=submit value=submit></form>";	
	}	// if get action2
// ================= EDIT_TOPIC END


// ================= EDIT_POST START
if (isset($_GET['id'])) $id=$_GET['id']; else $id='';
if ($action2 == 'edit_post')
	{
	if (isset($_POST['submit']))
		{
		$id=$_POST['id'];
		$query_sub='';
//		print_r ($_REQUEST['edit']);
//		Warning: mysql_real_escape_string() expects parameter 1 to be string
//		As we push array which conflict with purity real scape, but works. sorry. TODO
		echo '<font color=red>Do not worry about top mysql_real_escape errors if any :(</font><br>';
		foreach ($_REQUEST['edit'] as $key=>$value)
			{
//			echo "$key $value<br>";
			$query_sub.="`$key`='$value',";
			}	// foreach edit
		$query="UPDATE board_comments set ".substr($query_sub,0,-1)." where post_id='".$id."' limit 1";
//		echo $query;
		mysql_query($query) or die(mysql_error());
		echo "<div class=success>Update complete even errors can appeared.</div>";
		}	// if isset submit

	echo "Edit comment:<br><form method=post enctype=\"multipart/form-data\">";
	$result = mysql_query("SELECT * from board_comments where post_id='".$id."' limit 1") or die(mysql_error()); 
	while($row = mysql_fetch_assoc($result))
		{
//		print_r ($row);
		foreach ($row as $key=>$row2) {
			if ($key!='post_text')
				echo "$key:<input type=text name='edit[".$key."]' value='".$row2."'><br>";
				else 
				echo "$key:<textarea name='edit[".$key."]' rows=6>".$row2."</textarea><br>";
			}	// foreach 
		}	// while
	echo "<br>
		<input type=hidden name=id value='".$id."'>
		<input type=submit name=submit value=submit></form>";	
	}	// if get action2
// ================= EDIT_POST END


// ================= EDIT_FORUM START
if (isset($_GET['id'])) $id=$_GET['id']; else $id='';
if ($action2 == 'edit_forum')
	{
	if (isset($_POST['submit']))
		{
		$id=$_POST['id'];
		$query_sub='';
//		print_r ($_REQUEST['edit']);
//		Warning: mysql_real_escape_string() expects parameter 1 to be string
//		As we push array which conflict with purity real scape, but works. sorry. TODO
		echo '<font color=red>Do not worry about top mysql_real_escape errors if any :(</font><br>';
		foreach ($_REQUEST['edit'] as $key=>$value)
			{
//			echo "$key $value<br>";
			$query_sub.="`$key`='$value',";
			}	// foreach edit
		$query="UPDATE board_forums set ".substr($query_sub,0,-1)." where forum_id='".$id."' limit 1";
//		echo $query;
		mysql_query($query) or die(mysql_error());
		echo "<div class=success>Update complete even errors can appeared.</div>";
		}	// if isset submit

	echo "Edit comment:<br><form method=post enctype=\"multipart/form-data\">";
	$result = mysql_query("SELECT * from board_forums where forum_id='".$id."' limit 1") or die(mysql_error()); 
	while($row = mysql_fetch_assoc($result))
		{
//		print_r ($row);
		foreach ($row as $key=>$row2) {
			if ($key!='post_text')
				echo "$key:<input type=text name='edit[".$key."]' value='".$row2."'><br>";
				else 
				echo "$key:<textarea name='edit[".$key."]' rows=6>".$row2."</textarea><br>";
			}	// foreach 
		}	// while
	echo "<br>
		<input type=hidden name=id value='".$id."'>
		<input type=submit name=submit value=submit></form>";	
	}	// if get action2
// ================= EDIT_FORUM END



echo "<hr> * <a href='?action=admin&action2=mkforum'> Create new random forum in main category.</a><hr>";
?>
Return current item: MobileBB