• (3 Pages)
  • +
  • 1
  • 2
  • 3

Text Based Mafia Game || Staff and Forum Part 5 Rate Topic: ***** 2 Votes

#1 Denis1  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 32
  • View blog
  • Posts: 102
  • Joined: 29-July 09

Posted 18 August 2010 - 12:40 PM

Hello please check out my other tutorials before attempting this one.

Setup.php

We need to set up some basic things to get our Database ready for all the pages we are going to add.

Step One - Mysql tables.

This SQL Table is to save our replys that we get from the topics in the forum.
--
-- Table structure for table `replys`
--

CREATE TABLE IF NOT EXISTS `replys` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(20) NOT NULL default '',
  `message` text NOT NULL,
  `tid` int(11) NOT NULL default '0',
  `date` varchar(50) NOT NULL default '',
  `topictype` char(1) NOT NULL default '1',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13421 ;

-- --------------------------------------------------------


This Table hold the games basic information like staff , what are the ranks or level what are the cars etc etc.

--
-- Table structure for table `sitestats`
--

CREATE TABLE IF NOT EXISTS `sitestats` (
  `id` int(1) NOT NULL auto_increment,
  `admins` text NOT NULL,
  `mods` text NOT NULL,
  `admins_ip` text NOT NULL,
  `mods_ip` text NOT NULL,
  `hdo` text NOT NULL,
  `ranks` text NOT NULL,
  `wealth` text NOT NULL,
  `cars` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

-- --------------------------------------------------------


This table hold all the topics that are created in the forum.
--
-- Table structure for table `topics`
--

CREATE TABLE IF NOT EXISTS `topics` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(50) NOT NULL default '',
  `message` text NOT NULL,
  `name` varchar(20) NOT NULL default '',
  `date` varchar(50) NOT NULL default '',
  `topicstate` char(1) NOT NULL default '0',
  `locked` char(1) NOT NULL default '1',
  `type` varchar(1) NOT NULL default '1',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2237 ;

-- --------------------------------------------------------


Dont worry if you dont understand what these mean for now i will explain them when we get to it. For now just add it so the are ready when we get to them.

Step Two. - Setup.php
Now things are going to get a little be confusing, but please bear with me and i promise you will understand every thing by the end of this part. Ok we have to do this in-order for the forum to work, To save you time i have created a set up file to help you set up the database. Click and download this Attached File  setup.php (1.45K)
Number of downloads: 538 setup file and upload it to your server. Before browsing to it make sure the tables above are added. Browse to the file and type in your name. When you get an reply saying You are the first admin, Delete the setup file. MAKE SURE THAT YOU DELETE IT OTHERWISE ANYONE CAN MAKE THEM SELF ADMIN.

What the Setup file does -
The setup file insert a new data in the sitestats table on the database. You are only going to have 1 data because you only have 1 game. After the data is inserted in to the database your name is then inserted in to the Admin section of the table. Making you the one and only admin. Please make sure that the setup file is deleted. You can study the code to try and understanding it yourself.

Step Three. - Safe.php
We need to update Safe.php, Remember i told you that Safe.php holds information on the site which is quick to access.
// This select the information from sitestats so that it is easy access in the game. It select it from id one because that's the only id that should be there. 
$sql = "SELECT * FROM sitestats WHERE id='1'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$admins = htmlspecialchars($row->admins);
$mods = htmlspecialchars($row->mods);
$hdo = htmlspecialchars($row->hdo);
$admins_ip = htmlspecialchars($row->admins_ip);
$mods_ip = htmlspecialchars($row->mods_ip);

$admin_array = explode("-", $admins);
$mods_array = explode("-", $mods);
$hdo_array = explode("-", $hdo);
$admin_ip_array = explode("-", $admins_ip);
$mods_ip_array = explode("-", $mods_ip);

The code above have created staff arrays for when we get to creating our staff system. I am not going to explain all of this. Please make sure that all of this steps are completed because we need for these things to be here so we dont encounter any problems.


Staff.php


I know you have lots of questions, i would too. i am going to explain them now. We need staffs in our game to help run the game and make sure your rules are kept to. Think of staff as the police the help enforce the rules(law). The Staff you choose must help keep your game fair and just. The also have the responsibility to make sure that things dont get to a point where people would quit and dont want to play because of unfairness. the basic hierarchy of the staff is as follow :-
  • Admin - This is your title as the creator. The admin has every tool available to staff. As the admin you are responsible to make the tough decisions about the game and when all fails you dont.
  • MOD - Moderators are below you when it comes to command. Choose you mods wisely as the will have useful tools in the game and if used for evil purposes it will do a lot of damages.
  • HDO - Help Desk Operators are in charge to help with little question that player may have in the game. When you and your mods are busy working on more important things the HDO will help answer simple questions. HDO are members who fully understand your game and these are members who have proven them self as being very knowing in the game.


Step One
As we get deep in to these tutorials, the html coding are going to get very long but it is just the design which is easy to understand. So i will be attaching them to the post, you will have to download them in order continue, keep in mine that the name used in fields will correspond to the php, so if you have being changing the names or are thinking of changing the names of the fields please change them too in the html. This is a Simple html design to help you add the basic you need.
<?php if (in_array($name, $admin_array)){ 
<form name="form1" method="post" action="">
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Admins</td>
    </tr>
    <tr>
      <td colspan="4" align="center" <?php
	
	if(empty($admins)){
	echo "There are no admins.";
	}else{
	
	$admins_list = explode("-", $admins);
	 		  
foreach( $admins_list as $key => $value){
	echo "<input name=\"admin_name\" type=\"radio\" value=\"".$value."\" onfocus=\"if(this.blur)this.blur()\">".$value."";

}		
}// if no friends.  
		  ?></td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="admin" type="text"  id="admin" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_admin" type="submit"  id="Add_admin" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_admin" type="submit"  id="Remove_admin" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >MOD List: </td>
    </tr>
    <tr>
      <td height="20" colspan="4" align="center" >Names of Mods will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="Mod" type="text" id="Mod" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_mod" type="submit"  id="Add_mod" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_Mod" type="submit"  id="Remove_Mod" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Hdo List: </td>
    </tr>
    <tr>
      <td colspan="4" align="center" >Names of HDOs will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="hdo" type="text" id="hdo" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_hdo" type="submit"  id="Add_hdo" onfocus="if(this.blur)this.blur()" value="Add." /></td>
      <td width="100" align="right" ><input name="Remove_hdo" type="submit"  id="Remove_hdo" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
</form>
<? } ?>

You will notice the php in the html code. This is a validation to only let people in the admin array to see this page. This is so that other who are not admin can not see/edit your page. You will be seeing. For the purpose of this tutorial all my validations will be only admin based. if you think a Mod or a HDO should see it then follow these step.
You will also see that the php in the middle shows the admin already in the array. So if you did the setup right you should see your name.

Remember we created three arrays in safe. These arrays are filled with data from database.
Consider the php code below.
<?php if (in_array($name, $admin_array)){ ?>
Some html admins only.
<? } ?>

[size="4"][b] or[/b][/size]

<?php if (in_array($name, $admin_array)){

echo "Something for admin only";

} ?>



That code will only let admins see what every html you put in there

if(in_array($name, $admin_array) or in_array($name, $mods_array) or in_array($name, $hdo_array)){ ?>
What every is in the html will be seeing by Admins , Mods and HDOs.
<? } ?>


The code above let all three staff type see what every you want them to see.

We are going to talk more about validations later when we come to security part, for now this is the basic understanding you nee.

Step Two
- PHP to add admin.
The code below is basic and easy to understand. Remember i am showing you the basic so there have to be a lot of effort on your part. The code shows you how to add a admin and remove an admin. so study the code and make changes to the names in the fields so you will be able to add MODS AND HDOs.
<?php if(isset($_POST['Add_admin'])){

if(empty($_POST['admin'])){
echo "You didn't enter a name.";
}else{

if (in_array($_POST['admin'], $admin_array)) {
   echo "This person is already a admin.";
}else{

$sql = "SELECT name FROM users WHERE name='".mysql_real_escape_string($_POST['admin'])."'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$admin_name = htmlspecialchars($row->name);

if(empty($admin_name)){
echo "This users doesn't exist";
}else{

if(empty($admins)){

$result = mysql_query("UPDATE sitestats SET admins='".mysql_real_escape_string($admin_name)."' ,admins_ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."' WHERE id='1'") 
or die(mysql_error());

$admins = $admin_name;

}else{

$new_admin = $admins."-".$admin_name;
$new_ip = $admins_ip."-".$_SERVER['REMOTE_ADDR'];

$result = mysql_query("UPDATE sitestats SET admins='".mysql_real_escape_string($new_admin)."' ,admins_ip='".mysql_real_escape_string($new_ip)."' WHERE id='1'") 
or die(mysql_error());

$admins = $new_admin;

}

echo "You added ".$admin_name." as new admin.";

}// if empty field.
}// if exist check.
}// if already in check.
}// if isset.

if(isset($_POST['Remove_admin'])){

if(empty($_POST['admin_name'])){
echo "You didn't select a person to demote from admin.";
}else{

if (!in_array($_POST['admin_name'], $admin_array)) {
   echo "This person isn't a admin.";
}else{

$new_admin = "";
foreach( $admin_array as $key => $value){
if($value != $_POST['admin_name']){
if(empty($new_admin)){
$new_admin = $value;
}else{
$new_admin = $new_admin."-".$value;
}
}
}

$new_ip = "";
foreach( $admin_ip_array as $key => $value){
if($value != $_POST['admin_name']){
if(empty($new_ip)){
$new_ip = $value;
}else{
$new_ip = $new_ip."-".$value;
}
}
}

$result = mysql_query("UPDATE sitestats SET admins='".mysql_real_escape_string($new_admin)."' ,admins_ip='".mysql_real_escape_string($new_ip)."' WHERE id='1'") 
or die(mysql_error());
$result = mysql_query("UPDATE users SET state='0' WHERE id='".mysql_real_escape_string($new_admin)."'") 
or die(mysql_error());
$admins = $new_admin;

echo "You removed ".$_POST['admin_name']." from his admin position.";

}// if no friend selected.
}// if not in friendslist.
}// if isset.

?>


The only new thing here is adding creating new arrays and adding and removing values from existing array. You can read more on array and try and understand this code before attempting to edit it.
Remember the fields names should be the same in the php as well otherwise things will work as you plan.

Forum.php
Yes we are going to dive right in to Forum.php. Please dont think that because it is a Forum that means it is complex, NO , in fact this is a very basic forum system.

This is a basic and simple forum. The structure of this forum consist of -
  • Forum.php (Main forum page were topics are displayed.)
  • Forum_View.php (Where you can view topics.)
  • Forum_Edit.php (A Page where topics are edited.)


Because we have quit a lot of php code this time i am going to take some of the php code and put it on another page. these pages will be -
  • _Forum.php (Holds the codes for the main forum)
  • _Forum_view.php (holds the code for the topics view)


Thats is the basic structure of the forum.
Step One - HTML Design

Like i said before the HTML are really pointless to be posting here because it is long and you already understand it. So i have design the basic forum structure to help save you time. But please look this over and over. try and understand why it is design the way it is. Do some changes to it to make it easy for when you come to edit it. Download the three files.

Forum.php :Attached File  Forum.php (7.25K)
Number of downloads: 460
Forum_Edit.php :Attached File  Forum_Edit.php (1.4K)
Number of downloads: 443
Forum_View.php : Attached File  Forum_View.php (4.39K)
Number of downloads: 445

I cannot stress enough how important it is to keep the name of these file the way the are. Please if you must change it MAKE SURE YOU UNDERSTAND THE PHP WELL ENOUGH TO CHANGE ANYTHING ON IT.

Step Two
- Complex PHP
these php code are a little be complex to what we have being doing so far. There is nothing new that you dont already know. We are going to start with _Forum.
Create a page called _Forum.php and add the following.
<?
// Server setitng that we are going to use later.
$page_url = explode(".", $_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = $page_url[0].".php";

if($_SERVER['REQUEST_URI'] == "/_Forum.php"){
exit();
}

if(empty($_GET['type'])){
$_GET['type'] = 1;
}else{
	if(!is_numeric($_GET['type'])){
		$_GET['type'] = 1;
	}
}

// pagenation
$amount = 20;

$nsql = "SELECT * FROM topics WHERE topicstate = '0' and type='".mysql_real_escape_string($_GET['type'])."'";            
$nres = mysql_query($nsql) or die(mysql_error());
$totaltopics = mysql_num_rows($nres);

if (empty($_GET['page'])){
$page = 1;
}else {
	if(is_numeric($_GET['page'])){
$page = $_GET['page'];
	}else{
$page = 1;
	}
}

$min = $amount * ( $page - 1 );
$max = $amount;

if($_GET['type'] == 1){ $select_1 = "selected='selected'";}

// auto clean forum script.

if($totaltopics >= 500){

mysql_query("DELETE FROM topics WHERE topicstate=0") 
or die(mysql_error()); 

mysql_query("DELETE FROM replys WHERE topictype= 0") 
or die(mysql_error()); 
}

if(in_array($name, $admin_array)){

// clean forum script

if ( $_POST['action'] == "Clean Forum" ){ 
mysql_query("DELETE FROM topics WHERE topicstate=0") 
or die(mysql_error()); 

mysql_query("DELETE FROM replys WHERE topictype= 0") 
or die(mysql_error()); 
}

// delete topic script

if ( $_POST['action'] == "Delete" ){ 

$id = $_POST['id'];
if(!empty($id)){
$delete = implode(",",$id);
$delete = explode(",",$delete);
for($a = 0; !empty($delete[$a]);$a++){
mysql_query("DELETE FROM topics WHERE id='".mysql_real_escape_string($delete[$a])."'") 
or die(mysql_error()); 

mysql_query("DELETE FROM replys WHERE tid='".mysql_real_escape_string($delete[$a])."'") 
or die(mysql_error()); 
}// for loop.
}// if nothing selected.<br />
}// if isset.

// sticky script.

if ( $_POST['action'] == "Sticky" ){ 

$id = $_POST['id'];
if(!empty($id)){
$delete = implode(",",$id);
$delete = explode(",",$delete);
//Make sure to clear all fields by a for-loop is easy to erase
for($a = 0; !empty($delete[$a]);$a++){

$stresult = mysql_query("UPDATE topics SET topicstate='2' WHERE id='".mysql_real_escape_string($delete[$a])."'")
or die(mysql_error());

$stresult = mysql_query("UPDATE replys SET topictype='2' WHERE tid='".mysql_real_escape_string($delete[$a])."'")
or die(mysql_error());

}// for loop.
}// if nothing selected.
}// if isset.

// lock topic script.

if ( $_POST['action'] == "Lock" ){ 

$id = $_POST['id'];
if(!empty($id)){
//Checks if the id is empty or not
$delete = implode(",",$id);
$delete = explode(",",$delete);
//Make sure to clear all fields by a for-loop is easy to erase
for($a = 0; !empty($delete[$a]);$a++){

$stresult = mysql_query("UPDATE topics SET locked='2' WHERE id='".mysql_real_escape_string($delete[$a])."'")
or die(mysql_error());

}// for loop.
}// if nothing selected.
}// if isset.

// unlock topic script.

if ( $_POST['action'] == "Unlock" ){ 

$id = $_POST['id'];
if(!empty($id)){
$delete = implode(",",$id);
$delete = explode(",",$delete);
for($a = 0; !empty($delete[$a]);$a++){

$stresult = mysql_query("UPDATE topics SET locked='1' WHERE id='".mysql_real_escape_string($delete[$a])."'")
or die(mysql_error());

}// for loop.
}// if nothing selected.
}// if isset.

// important script.

if ( $_POST['action'] == "Important" ){ 

$id = $_POST['id'];
if(!empty($id)){
$delete = implode(",",$id);
$delete = explode(",",$delete);
for($a = 0; !empty($delete[$a]);$a++){

$stresult = mysql_query("UPDATE topics SET topicstate='1' WHERE id='".mysql_real_escape_string($delete[$a])."'")
or die(mysql_error());

$stresult = mysql_query("UPDATE replys SET topictype='1' WHERE tid='".mysql_real_escape_string($delete[$a])."'")
or die(mysql_error());

}// for loop.
}// if nothing selected.
}// if isset.

// remove important/sticky script.

if ( $_POST['action'] == "Remove" ){ 

$stresult = mysql_query("UPDATE topics SET topicstate='0' WHERE id='".mysql_real_escape_string($_POST['topic_id'])."'")
or die(mysql_error());

$stresult = mysql_query("UPDATE replys SET topictype='0' WHERE tid='".mysql_real_escape_string($_POST['topic_id'])."'")
or die(mysql_error());

}

// move topic script.

if ($_POST['action'] == "Move"){ 

$id = $_POST['id'];
if(!empty($id)){
$delete = implode(",",$id);
$delete = explode(",",$delete);
for($a = 0; !empty($delete[$a]);$a++){

$stresult = mysql_query("UPDATE topics SET type='".mysql_real_escape_string($_POST['type_move'])."' WHERE id='".mysql_real_escape_string($delete[$a])."'")
or die(mysql_error());

}// for loop.
}// if nothing selected.
}// if isset.

}// if allowed.

// add topic script.

if (isset($_POST['Submit'])){

$m_check = str_replace(' ', '', $_POST['message']);
$t_check = str_replace(' ', '', $_POST['topictitle']);

if((empty($t_check)) or (empty($m_check))){ 
echo "All fields need to be filled.";
}
else {
	
if (strlen($_POST['topictitle']) > "50"){
echo "Your subject may not be longer then 50 characters.";
}else{


$date = gmdate("m-d-y-H:i:s");
$sql = "INSERT INTO topics SET id = '', title = '" .mysql_real_escape_string($_POST['topictitle']). "', message  = '" .mysql_real_escape_string($_POST['message']). "', date = '" .mysql_real_escape_string($date). "', name = '" .mysql_real_escape_string($name). "', type = '1'";
$res = mysql_query($sql);


}// if subject is to long.
}// if empty field
}// if post submit.

?>

i have lots of comments to explain what is happening at every stage
All the validation on here are basic and i am only human and i may have made mistakes so look them over before running them on your site

On the forum page i have tools only for admin (Again you need to think which staff member get these tools.). These tools include. :-
  • Lock - To lock the topic from members posting on it
  • Unlock - to unlock the pages for user to post on it
  • Sticky - Less important announcements / reminders / information to users
  • Important - To make topics important which will display at the top of the page for users to see
  • Remove - This removes the status of the Important/ Sticky topics back to normal. (Dont mistake it for delete) Remove apply only to important / Sticky topics, it will take their status back to normal topics.
  • Delete - this delete the topic forever
  • Clean Forum - Delete all normal topics expects important and Sticky


all the control for this is in the php code above which is basic to understand. Please check it over and make sure you understand what us going on.

Create a page _Forum_view.php. Please make sure that you get the forum name right. the have to be 100% otherwise it will not work.

add this php code on to it.
<?
$page_url = explode(".", $_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = $page_url[0].".php";

if($_SERVER['REQUEST_URI'] == "/_Forum_View.php"){
exit();
}

// up topic

if ($_POST['Edit'] == "Edit")
{ 
$date = ("m-d-y-H:i:s");

$sql = "SELECT name FROM topics WHERE id = '" .mysql_real_escape_string($_GET['id']). "'"; 
$res = mysql_query($sql) or die(mysql_error()); 
$row = mysql_fetch_array($res);
if ( $row['name'] != $name and (!in_array($name, $admin_array) and !in_array($name, $manager_array))){
echo "You are not allowed to edit this post.";
}else{

$m_check = str_replace(' ', '', $_POST['message']);
$t_check = str_replace(' ', '', $_POST['topictitle']);

if((empty($m_check)) or (empty($t_check))){ 
echo "All fields need to be filled.";
}else{

if (strlen($_POST['topictitle']) > "50"){
echo "Your subject may not be longer then 50 characters.";
}else{

$result = mysql_query("UPDATE topics SET message = '" .mysql_real_escape_string($_POST['message']). "', title = '" .mysql_real_escape_string($_POST['topictitle']). "' WHERE id = '" .mysql_real_escape_string($_GET['id']). "'") 
or die(mysql_error()); 

echo "Your topic has been upd.";
	
	}// if subject is larger then 50 characters.
	}// if fields are empty.
	}// name check.
	}// if post edit.



// page script.

$amount = 10;

$csql = "SELECT * FROM replys WHERE tid = '" .mysql_real_escape_string($_GET['id']). "' ORDER BY date DESC"; 
$cres = mysql_query($csql) or die(mysql_error());
$totaltopics = mysql_num_rows($cres);

if (empty($_GET['page'])){
$page = 1;
}else {
	if(is_numeric($_GET['page'])){
$page = $_GET['page'];
	}else{
$page = 1;
	}
}

$min = $amount * ( $page - 1 );
$max = $amount;

$sql = "SELECT * FROM topics WHERE id = '" .mysql_real_escape_string($_GET['id']). "'"; 
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($res);

$date = gmdate("m-d-y-H:i:s");

if(isset($_POST['Reply'])){

$m_check = str_replace(' ', '', $_POST['message']);

if (empty($m_check)){
echo "You didn't type anything in the message box.";
}
else {

if(!in_array($name, $admin_array) and $row['locked'] == "2"){
echo "You can't post in a locked topic.";
}else {

	
$sql = "INSERT INTO replys SET id = '', name = '" .mysql_real_escape_string($name). "', message = '" .mysql_real_escape_string($_POST['message']). "', date = '" .mysql_real_escape_string($date). "', tid = '" .mysql_real_escape_string($_GET['id']). "', topictype = '" .mysql_real_escape_string($_GET['id']). "'";
$res = mysql_query($sql);

$result = mysql_query("UPDATE topics SET date='" .mysql_real_escape_string($date). "' WHERE id = '" .mysql_real_escape_string($_GET['id']). "'") 
or die(mysql_error()); 

}// if locked.
}// if empty
}// if post reply

// selecting reply's.

$sql = "SELECT id,title,message,date,name FROM topics WHERE id = '" .mysql_real_escape_string($_GET['id']). "'"; 
$res = mysql_query($sql); 
$row = mysql_fetch_array($res); 

// delete reply topic.

if ( $_GET['action'] == "Rreply" and ( in_array($name, $admin_array))){ 

mysql_query("DELETE FROM replys WHERE id='".mysql_real_escape_string($_GET['rid'])."'") 
or die(mysql_error()); 

echo "Reply Deleted.";

}

// lock topic script.

if (( $_GET['action'] == "lock" ) and ($row['name'] == $name)){ 

$stresult = mysql_query("UPDATE topics SET locked='2' WHERE id='".mysql_real_escape_string($_GET['id'])."'")
or die(mysql_error());

echo "The topic has been locked.";

}

?>


again this is basic and you should be able to understand this.

Thats all for this part of the tutorials. If i have left anything out, made any mistake or you see anyway to improve all the coding that i have up please make a post pointing them out. Remember i am only human and can make mistakes.

In the next part we are going to look at Profiles of players and Edit profiles Also Find Players.
See you then

Attached File  setup.php (1.45K)
Number of downloads: 538
Attached File  Forum.php (7.25K)
Number of downloads: 460
Attached File  Forum_Edit.php (1.4K)
Number of downloads: 443
Attached File  Forum_View.php (4.39K)
Number of downloads: 445


--------
Mod: the code can be found here:
https://github.com/m...ext_Based_Mafia

This post has been edited by modi123_1: 08 January 2014 - 09:03 PM
Reason for edit:: Attempted to add back in attachements


Is This A Good Question/Topic? 1
  • +

Replies To: Text Based Mafia Game || Staff and Forum Part 5

#2 Eetu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 09-September 10

Posted 12 September 2010 - 10:07 PM

Hmm, when I create Staff.php and add that 1st code into it >
<html>
<body>
<?php if (in_array($name, $admin_array)){ 
<form name="form1" method="post" action="">
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Admins</td>
    </tr>
    <tr>
      <td colspan="4" align="center" <?php
    
    if(empty($admins)){
    echo "There are no admins.";
    }else{
    
    $admins_list = explode("-", $admins);
               
foreach( $admins_list as $key => $value){
    echo "<input name=\"admin_name\" type=\"radio\" value=\"".$value."\" onfocus=\"if(this.blur)this.blur()\">".$value."";

}        
}// if no friends.  
          ?></td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="admin" type="text"  id="admin" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_admin" type="submit"  id="Add_admin" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_admin" type="submit"  id="Remove_admin" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >MOD List: </td>
    </tr>
    <tr>
      <td height="20" colspan="4" align="center" >Names of Mods will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="Mod" type="text" id="Mod" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_mod" type="submit"  id="Add_mod" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_Mod" type="submit"  id="Remove_Mod" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Hdo List: </td>
    </tr>
    <tr>
      <td colspan="4" align="center" >Names of HDOs will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="hdo" type="text" id="hdo" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_hdo" type="submit"  id="Add_hdo" onfocus="if(this.blur)this.blur()" value="Add." /></td>
      <td width="100" align="right" ><input name="Remove_hdo" type="submit"  id="Remove_hdo" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
</form>
<? } ?>
</body>
</html>

And then I check > http://localhost/staff.php
There is Parse error:
Parse error: syntax error, unexpected '<' in D:\xampp\htdocs\staff.php on line 4


Hmm in line 4 is:
<form name="form1" method="post" action="">


?? O.o

This post has been edited by Eetu: 12 September 2010 - 10:13 PM

Was This Post Helpful? 0
  • +
  • -

#3 Denis1  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 32
  • View blog
  • Posts: 102
  • Joined: 29-July 09

Posted 13 September 2010 - 08:02 AM

View PostEetu, on 13 September 2010 - 04:07 AM, said:

Hmm, when I create Staff.php and add that 1st code into it >
<html>
<body>
<?php if (in_array($name, $admin_array)){ 
<form name="form1" method="post" action="">
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Admins</td>
    </tr>
    <tr>
      <td colspan="4" align="center" <?php
    
    if(empty($admins)){
    echo "There are no admins.";
    }else{
    
    $admins_list = explode("-", $admins);
               
foreach( $admins_list as $key => $value){
    echo "<input name=\"admin_name\" type=\"radio\" value=\"".$value."\" onfocus=\"if(this.blur)this.blur()\">".$value."";

}        
}// if no friends.  
          ?></td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="admin" type="text"  id="admin" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_admin" type="submit"  id="Add_admin" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_admin" type="submit"  id="Remove_admin" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >MOD List: </td>
    </tr>
    <tr>
      <td height="20" colspan="4" align="center" >Names of Mods will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="Mod" type="text" id="Mod" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_mod" type="submit"  id="Add_mod" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_Mod" type="submit"  id="Remove_Mod" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Hdo List: </td>
    </tr>
    <tr>
      <td colspan="4" align="center" >Names of HDOs will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="hdo" type="text" id="hdo" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_hdo" type="submit"  id="Add_hdo" onfocus="if(this.blur)this.blur()" value="Add." /></td>
      <td width="100" align="right" ><input name="Remove_hdo" type="submit"  id="Remove_hdo" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
</form>
<? } ?>
</body>
</html>

And then I check > http://localhost/staff.php
There is Parse error:
Parse error: syntax error, unexpected '<' in D:\xampp\htdocs\staff.php on line 4


Hmm in line 4 is:
<form name="form1" method="post" action="">


?? O.o


Sorry that was my mistake.
At the end of line 3 add
?>
it is a php closing tag i forgot to add that in. Since your php doesn't have a closing tag, the server is taking your html tag as php. Hence syntax error because <form isn't a php syntax.
Was This Post Helpful? 0
  • +
  • -

#4 Eetu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 09-September 10

Posted 13 September 2010 - 09:02 PM

Oh ok :)
Was This Post Helpful? 0
  • +
  • -

#5 iLeetz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-November 10

Posted 16 November 2010 - 02:27 PM

<html>
<body>
<?php if (in_array($name, $admin_array)){ ?>
<form name="form1" method="post" action="">
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Admins</td>
    </tr>
    <tr>
      <td colspan="4" align="center" 
        <?php	
	if(empty($admins)){
	echo "There are no admins.";
	}else{
	
	$admins_list = explode("-", $admins);
	 		  
foreach( $admins_list as $key => $value){
	echo "<input name=\"admin_name\" type=\"radio\" value=\"".$value."\" onfocus=\"if(this.blur)this.blur()\">".$value."";

}		
}// if no friends.  
		  ?></td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="admin" type="text"  id="admin" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_admin" type="submit"  id="Add_admin" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_admin" type="submit"  id="Remove_admin" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >MOD List: </td>
    </tr>
    <tr>
      <td height="20" colspan="4" align="center" >Names of Mods will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="Mod" type="text" id="Mod" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_mod" type="submit"  id="Add_mod" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_Mod" type="submit"  id="Remove_Mod" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Hdo List: </td>
    </tr>
    <tr>
      <td colspan="4" align="center" >Names of HDOs will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="hdo" type="text" id="hdo" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_hdo" type="submit"  id="Add_hdo" onfocus="if(this.blur)this.blur()" value="Add." /></td>
      <td width="100" align="right" ><input name="Remove_hdo" type="submit"  id="Remove_hdo" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
</form>
<? } ?>
</html>
</body>


I added a ?> on line 3 but, it gives me this error:

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/a7600362/public_html/Staff.php on line 2

Also in Safe.php where do I add
// This select the information from sitestats so that it is easy access in the game. It select it from id one because that's the only id that should be there. 
$sql = "SELECT * FROM sitestats WHERE id='1'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$admins = htmlspecialchars($row->admins);
$mods = htmlspecialchars($row->mods);
$hdo = htmlspecialchars($row->hdo);
$admins_ip = htmlspecialchars($row->admins_ip);
$mods_ip = htmlspecialchars($row->mods_ip);

$admin_array = explode("-", $admins);
$mods_array = explode("-", $mods);
$hdo_array = explode("-", $hdo);
$admin_ip_array = explode("-", $admins_ip);
$mods_ip_array = explode("-", $mods_ip);


This post has been edited by iLeetz: 16 November 2010 - 02:33 PM

Was This Post Helpful? 0
  • +
  • -

#6 Denis1  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 32
  • View blog
  • Posts: 102
  • Joined: 29-July 09

Posted 17 November 2010 - 04:53 PM

View PostiLeetz, on 16 November 2010 - 08:27 PM, said:

<html>
<body>
<?php if (in_array($name, $admin_array)){ ?>
<form name="form1" method="post" action="">
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Admins</td>
    </tr>
    <tr>
      <td colspan="4" align="center" 
        <?php	
	if(empty($admins)){
	echo "There are no admins.";
	}else{
	
	$admins_list = explode("-", $admins);
	 		  
foreach( $admins_list as $key => $value){
	echo "<input name=\"admin_name\" type=\"radio\" value=\"".$value."\" onfocus=\"if(this.blur)this.blur()\">".$value."";

}		
}// if no friends.  
		  ?></td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="admin" type="text"  id="admin" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_admin" type="submit"  id="Add_admin" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_admin" type="submit"  id="Remove_admin" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >MOD List: </td>
    </tr>
    <tr>
      <td height="20" colspan="4" align="center" >Names of Mods will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="Mod" type="text" id="Mod" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_mod" type="submit"  id="Add_mod" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_Mod" type="submit"  id="Remove_Mod" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Hdo List: </td>
    </tr>
    <tr>
      <td colspan="4" align="center" >Names of HDOs will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="hdo" type="text" id="hdo" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_hdo" type="submit"  id="Add_hdo" onfocus="if(this.blur)this.blur()" value="Add." /></td>
      <td width="100" align="right" ><input name="Remove_hdo" type="submit"  id="Remove_hdo" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
</form>
<? } ?>
</html>
</body>


I added a ?> on line 3 but, it gives me this error:

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/a7600362/public_html/Staff.php on line 2

Also in Safe.php where do I add
// This select the information from sitestats so that it is easy access in the game. It select it from id one because that's the only id that should be there. 
$sql = "SELECT * FROM sitestats WHERE id='1'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$admins = htmlspecialchars($row->admins);
$mods = htmlspecialchars($row->mods);
$hdo = htmlspecialchars($row->hdo);
$admins_ip = htmlspecialchars($row->admins_ip);
$mods_ip = htmlspecialchars($row->mods_ip);

$admin_array = explode("-", $admins);
$mods_array = explode("-", $mods);
$hdo_array = explode("-", $hdo);
$admin_ip_array = explode("-", $admins_ip);
$mods_ip_array = explode("-", $mods_ip);



on line 10 you forgot to close the html ">"
<html>
<body>
<?php if (in_array($name, $admin_array)){ ?>
<form name="form1" method="post" action="">
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Admins</td>
    </tr>
    <tr>
      <td colspan="4" align="center"> 
        <?php	
	if(empty($admins)){
	echo "There are no admins.";
	}else{
	
	$admins_list = explode("-", $admins);
	 		  
foreach( $admins_list as $key => $value){
	echo "<input name=\"admin_name\" type=\"radio\" value=\"".$value."\" onfocus=\"if(this.blur)this.blur()\">".$value."";

}		
}// if no friends.  
		  ?></td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="admin" type="text"  id="admin" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_admin" type="submit"  id="Add_admin" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_admin" type="submit"  id="Remove_admin" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >MOD List: </td>
    </tr>
    <tr>
      <td height="20" colspan="4" align="center" >Names of Mods will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="Mod" type="text" id="Mod" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_mod" type="submit"  id="Add_mod" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_Mod" type="submit"  id="Remove_Mod" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Hdo List: </td>
    </tr>
    <tr>
      <td colspan="4" align="center" >Names of HDOs will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="hdo" type="text" id="hdo" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_hdo" type="submit"  id="Add_hdo" onfocus="if(this.blur)this.blur()" value="Add." /></td>
      <td width="100" align="right" ><input name="Remove_hdo" type="submit"  id="Remove_hdo" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
</form>
<? } ?>
</html>
</body>


Was This Post Helpful? 0
  • +
  • -

#7 HappyJackie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-January 09

Posted 09 December 2010 - 09:47 PM

I am having the same issue as the individual above is there anyone that can help with this?
Was This Post Helpful? 0
  • +
  • -

#8 Guest_Teutonic Knight*


Reputation:

Posted 19 January 2011 - 10:22 PM

How do you reorder the forum so that it would put the recent posts on the bottom of the other posts?
Was This Post Helpful? 0

#9 Denis1  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 32
  • View blog
  • Posts: 102
  • Joined: 29-July 09

Posted 22 January 2011 - 01:18 PM

View PostTeutonic Knight, on 20 January 2011 - 05:22 AM, said:

How do you reorder the forum so that it would put the recent posts on the bottom of the other posts?


On the _Forum_view.php at around line 49 to 50 fine
ORDER BY date  DESC 
and change it to
ORDER BY date  ASC


and guys i am updating this whole tutorial making it a bit more advance solving other issues will be out soon.
Was This Post Helpful? 0
  • +
  • -

#10 Guest_gordy*


Reputation:

Posted 09 February 2011 - 09:56 AM

i cant see what is wrong, im getting these 3 errors -


Warning: in_array() [function.in-array]: Wrong datatype for second argument in /www/zymichost.com/g/o/r/gordylovesbecca/htdocs/staff.php on line 1

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /www/zymichost.com/g/o/r/gordylovesbecca/htdocs/staff.php on line 63
or


Warning: in_array() [function.in-array]: Wrong datatype for second argument in /www/zymichost.com/g/o/r/gordylovesbecca/htdocs/staff.php on line 69

<?php if (in_array($name, $admin_array)){ ?>
<form name="form1" method="post" action="">
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Admins</td>
    </tr>
    <tr>
      <td colspan="4" align="center" </html><?php
	
	if(empty($admins)){
	echo "There are no admins.";
	}else{
	
	$admins_list = explode("-", $admins);
	 		  
foreach( $admins_list as $key => $value){
	echo "<input name=\"admin_name\" type=\"radio\" value=\"".$value."\" onfocus=\"if(this.blur)this.blur()\">".$value."";

}		
}// if no friends.  
		  ?></td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="admin" type="text"  id="admin" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_admin" type="submit"  id="Add_admin" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_admin" type="submit"  id="Remove_admin" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >MOD List: </td>
    </tr>
    <tr>
      <td height="20" colspan="4" align="center" >Names of Mods will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="Mod" type="text" id="Mod" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_mod" type="submit"  id="Add_mod" value="Add." onfocus="if(this.blur)this.blur()" /></td>
      <td width="100" align="right" ><input name="Remove_Mod" type="submit"  id="Remove_Mod" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
  <br>
  <table width="90%" border="1" >
    <tr>
      <td colspan="4" align="left" >Hdo List: </td>
    </tr>
    <tr>
      <td colspan="4" align="center" >Names of HDOs will appear here</td>
    </tr>
    <tr>
      <td width="50" align="left" ><b>Name:</b></td>
      <td align="center" ><input name="hdo" type="text" id="hdo" style='width: 95%; ' maxlength="20" /></td>
      <td width="100" align="right" ><input name="Add_hdo" type="submit"  id="Add_hdo" onfocus="if(this.blur)this.blur()" value="Add." /></td>
      <td width="100" align="right" ><input name="Remove_hdo" type="submit"  id="Remove_hdo" value="Remove." onfocus="if(this.blur)this.blur()"/></td>
    </tr>
  </table>
</form>
<? } ?>

<?php if (in_array($name, $admin_array)){ ?>
Some html admins only.
<? } ?>

[size="4"][b] or[/b][/size]

<?php if (in_array($name, $admin_array)){

echo "Something for admin only";

} ?>


<?php if(isset($_POST['Add_admin'])){

if(empty($_POST['admin'])){
echo "You didn't enter a name.";
}else{

if (in_array($_POST['admin'], $admin_array)) {
   echo "This person is already a admin.";
}else{

$sql = "SELECT name FROM users WHERE name='".mysql_real_escape_string($_POST['admin'])."'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$admin_name = htmlspecialchars($row->name);

if(empty($admin_name)){
echo "This users doesn't exist";
}else{

if(empty($admins)){

$result = mysql_query("UPDATE sitestats SET admins='".mysql_real_escape_string($admin_name)."' ,admins_ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."' WHERE 

id='1'") 
or die(mysql_error());

$admins = $admin_name;

}else{

$new_admin = $admins."-".$admin_name;
$new_ip = $admins_ip."-".$_SERVER['REMOTE_ADDR'];

$result = mysql_query("UPDATE sitestats SET admins='".mysql_real_escape_string($new_admin)."' ,admins_ip='".mysql_real_escape_string($new_ip)."' WHERE id='1'") 
or die(mysql_error());

$admins = $new_admin;

}

echo "You added ".$admin_name." as new admin.";

}// if empty field.
}// if exist check.
}// if already in check.
}// if isset.

if(isset($_POST['Remove_admin'])){

if(empty($_POST['admin_name'])){
echo "You didn't select a person to demote from admin.";
}else{

if (!in_array($_POST['admin_name'], $admin_array)) {
   echo "This person isn't a admin.";
}else{

$new_admin = "";
foreach( $admin_array as $key => $value){
if($value != $_POST['admin_name']){
if(empty($new_admin)){
$new_admin = $value;
}else{
$new_admin = $new_admin."-".$value;
}
}
}

$new_ip = "";
foreach( $admin_ip_array as $key => $value){
if($value != $_POST['admin_name']){
if(empty($new_ip)){
$new_ip = $value;
}else{
$new_ip = $new_ip."-".$value;
}
}
}

$result = mysql_query("UPDATE sitestats SET admins='".mysql_real_escape_string($new_admin)."' ,admins_ip='".mysql_real_escape_string($new_ip)."' WHERE id='1'") 
or die(mysql_error());
$result = mysql_query("UPDATE users SET state='0' WHERE id='".mysql_real_escape_string($new_admin)."'") 
or die(mysql_error());
$admins = $new_admin;

echo "You removed ".$_POST['admin_name']." from his admin position.";

}// if no friend selected.
}// if not in friendslist.
}// if isset.

?>


Was This Post Helpful? 0

#11 Phantom Coder  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 26-April 09

Posted 06 February 2012 - 09:50 AM

View PostHappyJackie, on 09 December 2010 - 09:47 PM, said:

I am having the same issue as the individual above is there anyone that can help with this?


did you require("safe.php); ?
i was having the same problem until i realized it was using variables from safe.php

This post has been edited by modi123_1: 06 February 2012 - 10:06 AM
Reason for edit:: removed excessive quote

Was This Post Helpful? 0
  • +
  • -

#12 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8890
  • View blog
  • Posts: 33,338
  • Joined: 12-June 08

Posted 06 February 2012 - 10:06 AM

@phantomcoder - you do realize the post you replied to was from "09 December 2010", right? You might want to check those dates in the future.
Was This Post Helpful? 0
  • +
  • -

#13 Phantom Coder  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 26-April 09

Posted 06 February 2012 - 06:03 PM

Thanks for the this part in your tutorial. I came across a couple of bugs I been trying to figure out and remove but so far no luck. I just have the stock code you have in the post I did not see any reason to make this post any longer with the exact same code.

1st when you lock a post the admin tool links disappear. don't we need some way to unlock a post?
2nd when you navigate to the post in your browser window e.g. http://mafiagame.ric...m_edit.php?id=1
you can still edit the post even if it was locked. would we need some way to check to see if we arrived to the post using the edit post button?

Thanks again for the great tutorials
Was This Post Helpful? 0
  • +
  • -

#14 Phantom Coder  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 26-April 09

Posted 06 February 2012 - 06:18 PM

@modi123_1 I'm sorry I did notice the dates but I still looked to see if someone answered their questions I have forums post that I have on other boards I still check to see if I got an answer. I thought someone would benefit from it since I had the exact same error they did until I figured it out.
Was This Post Helpful? 0
  • +
  • -

#15 ChrisH94  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-April 12

Posted 17 April 2012 - 02:09 AM

Staff.php keep's giving me a parse error
Parse error: syntax error, unexpected '<' in /home/ragel925/public_html/MafiaGame/staff.php on line 94


<?php if (in_array($name, $admin_array)) {
        < form name = "form1"method = "post"action = "" > < table width = "90%"border =
            "1" > < tr > < td colspan = "4"align = "left" > Admins < / td > < / tr > < tr > <
            td colspan = "4"align = "center" < ? php if (empty($admins)) {
            echo "There are no admins.";
        } else {

            $admins_list = explode("-", $admins);

            foreach ($admins_list as $key => $value) {
                echo "<input name=\"admin_name\" type=\"radio\" value=\"" . $value . "\" onfocus=\"if(this.blur)this.blur()\">" .
                    $value . "";

            }
        } // if no friends.

?></td>



I gave up last night and came back to it this morning, i'm still unsure why.
Any help appreciated.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3