Jump to content
MakeWebGames

Forums Function On staff Panel V2 Codes


chaoswar4u
 Share

Recommended Posts

On V2 version of codes ive added the staff room.php and edited menu's as needed. The bug  in the staff panel u get the following options.

    Forums

> Add Forum

> Edit Forum

> Delete Forum

The add forum function works but the edit and delete links just open a white page. All the staff panel is there etc just a white box where you would expect to load the fields to enter data. Anyone got any ideas?

Link to comment
Share on other sites

  • 6 months later...

Re: Forums Function On staff Panel V2 Codes

replace

staff_forums.php with this

staff_forums.php

<?php
include "sglobals.php";
if($ir['user_level'] > 2)
{
die("403");
}
//This contains forum stuffs
switch($_GET['action'])
{
case "addforum": addcity(); break;
case "editforum": editcity(); break;
case "delforum": delcity(); break;
default: print "Error: This script requires an action."; break;
}
function addcity()
{
global $db, $ir, $c, $h, $userid;
$name=$_POST['name'];
$desc=$_POST['desc'];
$auth=$_POST['auth'];
if($auth and $desc and $name)
{
$q=$db->query("SELECT * FROM forum_forums WHERE ff_name='{$name}'");
if($db->num_rows($q))
{
print "Sorry, you cannot have two forums with the same name.";
$h->endpage();
exit;
}
$db->query("INSERT INTO forum_forums (ff_name, ff_desc, ff_auth, ff_lp_poster_name, ff_lp_t_name) VALUES('$name', '$desc', '$auth', 'N/A', 'N/A')");
print "Forum {$name} added to the game.";
stafflog_add("Created Forum $name");
}
else
{
print "<h3>Add Form</h3><hr />
<form action='staff_forums.php?action=addforum' method='post'>
Name: <input type='text' name='name' />

Description: <input type='text' name='desc' />

Authorization: <input type='radio' name='auth' value='public' checked='checked' /> Public <input type='radio' name='auth' value='staff' /> Staff Only


<input type='submit' value='Add Forum' /></form>";
}
}
function editcity()
{
global $db, $ir, $c, $h, $userid;
switch($_POST['step'])
{
case "2":

$name=$_POST['name'];
$desc=$_POST['desc'];
$auth=$_POST['auth'];
$q=$db->query("SELECT * FROM forum_forums WHERE ff_name='{$name}' AND ff_id!={$_POST['id']}");
if($db->num_rows($q))
{
print "Sorry, you cannot have two forums with the same name.";
$h->endpage();
exit;
}
$name=$_POST['name'];
$q=$db->query("SELECT * FROM forum_forums WHERE ff_id={$_POST['id']}");
$old=$db->fetch_row($q);
$db->query("UPDATE forum_forums SET ff_desc='$desc', ff_name='$name', ff_auth='$auth' WHERE ff_id={$_POST['id']}");
print "Forum $name was edited successfully.";
stafflog_add("Edited forum $name");
break;
case "1":
$q=$db->query("SELECT * FROM forum_forums WHERE ff_id={$_POST['id']}");
$old=$db->fetch_row($q);
print "<h3>Editing a Forum</h3><hr />
<form action='staff_forums.php?action=editforum' method='post'>
<input type='hidden' name='step' value='2' />
<input type='hidden' name='id' value='{$_POST['id']}' />
Name: <input type='text' name='name' value='{$old['ff_name']}' />

Description: <input type='text' name='desc' value='{$old['ff_desc']}' />

";
if($old['ff_auth']=="public")
{
print "Authorization: <input type='radio' name='auth' value='public' checked='checked' /> Public <input type='radio' name='auth' value='staff' /> Staff Only
";
}
else
{
print "Authorization: <input type='radio' name='auth' value='public' /> Public <input type='radio' name='auth' value='staff' checked='checked' /> Staff Only
";
}
print "
<input type='submit' value='Edit Forum' /></form>";
break;
default:
print "<h3>Editing a Forum</h3><hr />
<form action='staff_forums.php?action=editforum' method='post'>
<input type='hidden' name='step' value='1' />
Forum: ".forum2_dropdown($c, "id")."

<input type='submit' value='Edit Forum' /></form>";
break;
}
}
function delcity()
{
global $db,$ir,$c,$h,$userid;
if($_POST['forum'])
{
$q=$db->query("SELECT * FROM forum_forums WHERE ff_id={$_POST['forum']}");
$old=$db->fetch_row($q);
if($_POST['forum']==$_POST['forum2']) { die("You cannot select the same crime group to move the crimes to."); }

$db->query("UPDATE forum_posts SET fp_forum_id={$_POST['forum2']} WHERE fp_forum_id={$old['ff_id']}");
$db->query("UPDATE forum_topics SET ft_forum_id={$_POST['forum2']} WHERE ft_forum_id={$old['ff_id']}");
recache_forum($_POST['forum2']);
$db->query("DELETE FROM forum_forums WHERE ff_id={$old['ff_id']}");
print "Forum {$old['ff_name']} deleted.";
stafflog_add("Deleted forum {$old['ff_name']}");
}
else
{
print "
<script type='text/javascript'>
function checkme()
{
if(document.theform.forum.value==document.theform.forum2.value)
{
alert('You cannot select the same forum to move the posts to.');
return false;
}
return true;
}
</script>
<h3>Delete Forum</h3><hr />
Deleting a forum is permanent - be sure. .<form action='staff_forums.php?action=delforum' method='post' name='theform'  onsubmit='return checkme();'>
Forum: ".forum2_dropdown($c, "forum")."

Move posts & topics in the deleted forum to: ".forum2_dropdown($c, "forum2")."

<input type='submit' value='Delete Forum' /></form>";
}
}
function report_clear()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 3)
{
die("403");
}
$_GET['ID'] = abs((int) $_GET['ID']);
stafflog_add("Cleared player report ID {$_GET['ID']}");
$db->query("DELETE FROM preports WHERE prID={$_GET['ID']}");
print "Report cleared and deleted!

[url='staff_users.php?action=reportsview']> Back[/url]";
}
function recache_forum($forum)
{
global $ir, $c, $userid, $h, $db;

$q=$db->query("SELECT p.*,t.* FROM forum_posts p LEFT JOIN forum_topics t ON p.fp_topic_id=t.ft_id WHERE p.fp_forum_id=$forum ORDER BY p.fp_time DESC LIMIT 1");
if(!$db->num_rows($q))
{
$db->query("update forum_forums set ff_lp_time=0, ff_lp_poster_id=0, ff_lp_poster_name='N/A', ff_lp_t_id=0, ff_lp_t_name='N/A',ff_posts=0, ff_topics=0 where ff_id={$forum}");

}
else
{
$r=$db->fetch_row($q);
$tn=mysql_escape($r['ft_name']);
$pn=mysql_escape($r['fp_poster_name']);
$posts=$db->num_rows($db->query("SELECT fp_id FROM forum_posts WHERE fp_forum_id=$forum"));
$topics=$db->num_rows($db->query("SELECT ft_id FROM forum_topics WHERE ft_forum_id=$forum"));
$db->query("update forum_forums set ff_lp_time={$r['fp_time']}, ff_lp_poster_id={$r['fp_poster_id']}, ff_lp_poster_name='$pn', ff_lp_t_id={$r['ft_id']}, ff_lp_t_name='$tn',ff_posts=$posts, ff_topics=$topics where ff_id={$forum}");

}
}
$h->endpage();
?>
Link to comment
Share on other sites

  • 6 months later...
  • 1 month later...
  • 1 month later...

Re: Forums Function On staff Panel V2 Codes

Try This =]

 

<?php
include "sglobals.php";

switch($_GET['action'])
{
case "addforum": addcity(); break;
case "editforum": editcity(); break;
case "delforum": delcity(); break;
default: print "Error: This script requires an action."; break;
}
function addcity()
{
global $db, $ir, $c, $h, $userid;
$name=$_POST['name'];
$desc=$_POST['desc'];
$auth=$_POST['auth'];
if($auth and $desc and $name)
{
$q=$db->query("SELECT * FROM forum_forums WHERE ff_name='{$name}'");
if($db->num_rows($q))
{
print "Sorry, you cannot have two forums with the same name.";
$h->endpage();
exit;
}
$db->query("INSERT INTO forum_forums (ff_name, ff_desc, ff_auth, ff_lp_poster_name, ff_lp_t_name) VALUES('$name', '$desc', '$auth', 'N/A', 'N/A')");
print "Forum {$name} added to the game.";
stafflog_add("Created Forum $name");
}
else
{
print "<h3>Add Form</h3><hr />
<form action='staff_forums.php?action=addforum' method='post'>
Name: <input class='textbox'  type='text' name='name' />

Description: <input class='textbox'  type='text' name='desc' />

Authorization: <input class='textbox'  type='radio' name='auth' value='public' checked='checked' /> Public <input class='textbox'  type='radio' name='auth' value='staff' /> Staff Only


<input class='textbox'  type='submit' value='Add Forum' /></form>";
}
}
function editcity()
{
global $db, $ir, $c, $h, $userid;
switch($_POST['step'])
{
case "2":

$name=$_POST['name'];
$desc=$_POST['desc'];
$auth=$_POST['auth'];
$q=$db->query("SELECT * FROM forum_forums WHERE ff_name='{$name}' AND ff_id!={$_POST['id']}");
if($db->num_rows($q))
{
print "Sorry, you cannot have two forums with the same name.";
$h->endpage();
exit;
}
$name=$_POST['name'];
$q=$db->query("SELECT * FROM forum_forums WHERE ff_id={$_POST['id']}");
$old=$db->fetch_row($q);
$db->query("UPDATE forum_forums SET ff_desc='$desc', ff_name='$name', ff_auth='$auth' WHERE ff_id={$_POST['id']}");
print "Forum $name was edited successfully.";
stafflog_add("Edited forum $name");
break;
case "1":
$q=$db->query("SELECT * FROM forum_forums WHERE ff_id={$_POST['id']}");
$old=$db->fetch_row($q);
print "<h3>Editing a Forum</h3><hr />
<form action='staff_forums.php?action=editforum' method='post'>
<input class='textbox'  type='hidden' name='step' value='2' />
<input class='textbox'  type='hidden' name='id' value='{$_POST['id']}' />
Name: <input class='textbox'  type='text' name='name' value='{$old['ff_name']}' />

Description: <input class='textbox'  type='text' name='desc' value='{$old['ff_desc']}' />

";
if($old['ff_auth']=="public")
{
print "Authorization: <input class='textbox'  type='radio' name='auth' value='public' checked='checked' /> Public <input class='textbox'  type='radio' name='auth' value='staff' /> Staff Only
";
}
else
{
print "Authorization: <input class='textbox'  type='radio' name='auth' value='public' /> Public <input class='textbox'  type='radio' name='auth' value='staff' checked='checked' /> Staff Only
";
}
print "
<input class='textbox'  type='submit' value='Edit Forum' /></form>";
break;
default:
print "<h3>Editing a Forum</h3><hr />
<form action='staff_forums.php?action=editforum' method='post'>
<input class='textbox'  type='hidden' name='step' value='1' />
Forum: ".forum2_dropdown($c, "id")."

<input class='textbox'  type='submit' value='Edit Forum' /></form>";
break;
}
}
function delcity()
{
global $db,$ir,$c,$h,$userid;
if($_POST['forum'])
{
$q=$db->query("SELECT * FROM forum_forums WHERE ff_id={$_POST['forum']}");
$old=$db->fetch_row($q);
if($_POST['forum']==$_POST['forum2']) { die("You cannot select the same crime group to move the crimes to."); }

$db->query("UPDATE forum_posts SET fp_forum_id={$_POST['forum2']} WHERE location={$old['ff_id']}");
$db->query("UPDATE forum_topics SET ft_forum_id={$_POST['forum2']} WHERE shopLOCATION={$old['ff_id']}");
recache_forum($_POST['forum2']);
$db->query("DELETE FROM forum_forums WHERE ff_id={$old['ff_id']}");
print "Forum {$old['ff_name']} deleted.";
stafflog_add("Deleted forum {$old['ff_name']}");
}
else
{
print "
<script type='text/javascript'>
function checkme()
{
if(document.theform.forum.value==document.theform.forum2.value)
{
alert('You cannot select the same forum to move the posts to.');
return false;
}
return true;
}
</script>
<h3>Delete Forum</h3><hr />
Deleting a forum is permanent - be sure. .<form action='staff_forums.php?action=delforum' method='post' name='theform'  onsubmit='return checkme();'>
Forum: ".forum2_dropdown($c, "forum")."

Move posts & topics in the deleted forum to: ".forum2_dropdown($c, "forum2")."

<input class='textbox'  type='submit' value='Delete Forum' /></form>";
}
}
function report_clear()
{
global $db,$ir,$c,$h,$userid;

$_GET['ID'] = abs((int) $_GET['ID']);
stafflog_add("Cleared player report ID {$_GET['ID']}");
$db->query("DELETE FROM preports WHERE prID={$_GET['ID']}");
print "Report cleared and deleted!

[url='staff_users.php?action=reportsview']> Back[/url]";
}
function recache_forum($forum)
{
global $ir, $c, $userid, $h, $db;

$q=$db->query("SELECT p.*,t.* FROM forum_posts p LEFT JOIN forum_topics t ON p.fp_topic_id=t.ft_id WHERE p.fp_forum_id=$forum ORDER BY p.fp_time DESC LIMIT 1");
if(!$db->num_rows($q))
{
$db->query("update forum_forums set ff_lp_time=0, ff_lp_poster_id=0, ff_lp_poster_name='N/A', ff_lp_t_id=0, ff_lp_t_name='N/A',ff_posts=0, ff_topics=0 where ff_id={$forum}");

}
else
{
$r=$db->fetch_row($q);
$tn=mysql_escape($r['ft_name']);
$pn=mysql_escape($r['fp_poster_name']);
$posts=$db->num_rows($db->query("SELECT fp_id FROM forum_posts WHERE fp_forum_id=$forum"));
$topics=$db->num_rows($db->query("SELECT ft_id FROM forum_topics WHERE ft_forum_id=$forum"));
$db->query("update forum_forums set ff_lp_time={$r['fp_time']}, ff_lp_poster_id={$r['fp_poster_id']}, ff_lp_poster_name='$pn', ff_lp_t_id={$r['ft_id']}, ff_lp_t_name='$tn',ff_posts=$posts, ff_topics=$topics where ff_id={$forum}");

}
}
$h->endpage();
?>

 

It Works Fine On My game :)

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...