Requirements: Simple MySQL & PHP knowledge.
Tired of everyone asking you for Moderator positions on your forum/server? Well here is your solution!
The system is similar to RuneScape's account recovery system. This is how is works:
* They enter answers to simple questions.
* The answers are stored on a SQL database.
* They are given a code, which they can enter into search.php to track their application.
* There is a very simple admin control panel that you can use to accept/deny applications.
* You can also IP ban people from using this.
* They can only enter 1 application at a time.
This was made 100% by me, so if you do use it, please give SlashScape (my server) some credits. Thanks!
Step one. Create these SQL queries:
And:Code:CREATE TABLE IF NOT EXISTS `apps` (
`ID` varchar(50) NOT NULL,
`Username` varchar(50) NOT NULL,
`age` varchar(5000) NOT NULL,
`Open` varchar(5000) NOT NULL,
`why` varchar(5000) NOT NULL,
`offer` varchar(5000) NOT NULL,
`other` varchar(5000) NOT NULL,
`IP` varchar(5000) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
That should be very simple!Code:CREATE TABLE IF NOT EXISTS `banip` (
`ID` int(12) NOT NULL auto_increment,
`IP` varchar(25) collate latin1_general_ci NOT NULL default '',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;
Now in your webhost make a new folder called "applications".
In that folder, add this into a page called 'applications.php':
Now add this into a file called 'connect.php':Code:<?php include "connect.php";
//this is the file that connect to sql
$s=$_SERVER["REMOTE_ADDR"];
//draws IP address of visitor
$ipbancheck="SELECT * from banip where IP='$s'";
$ipbancheck2=mysql_query($ipbancheck);
while($ipbancheck3=mysql_fetch_array($ipbancheck2))
{
$IPBANNED=$ipbancheck3[IP];
}
//above lines check to see if user Ip is in banned IPs
if ($IPBANNED)
{
print "You've been IP banned for abusing the Application system.";
}
else
{
?>
<html>
<head>
<title>SlashScape</title>
</head>
<body TEXT="red" bgcolor="black">
<div align="center">
<font face="Comic Sans MS">
<br>
<b>Moderator Application Form</b><br>
<br>
The more information you give the more likely your application will be accepted. Please only submit one application<br>
at a time. If you post more then one, all of your applications will be denied. Also, we ask that you use proper English, other wise we'll<br>
act as if we can't read your appeal, hence decline it.
<br>
______________________________________________________________________________________
<br>
<br>
<form action="process.php" method="post">
Username:
<input type="text" name="user">
<br><br>
Your age:
<input type="text" name="dob">
<br><br><br>
<b>Why should we pick you?<br>
<textarea rows="5" cols="50" wrap="physical" name="why"></textarea>
<br><br>
__________________<br><br>
<b>What would you offer to the Community by being a Moderator?<br>
<textarea rows="5" cols="50" wrap="physical" name="offer"></textarea>
<br><br>
__________________<br><br>
<b>All other information you'd like to offer:<br>
<textarea rows="5" cols="50" wrap="physical" name="other"></textarea>
<br><br>
<input type="submit" value="Submit">
</body>
</html>
<?php
}
?>
Now add this into a page called 'content.php':Code:<?
/*--------- DATABASE CONNECTION INFO---------*/
$hostname="localhost";
$mysql_login="SQL username";
$mysql_password="SQL password";
$database="SQL database";
// connect to the database server
if (!($db = mysql_pconnect($hostname, $mysql_login , $mysql_password))){
die("Can't connect to database server.");
}else{
// select a database
if (!(mysql_select_db("$database",$db))){
die("Can't connect to database.");
}
}
?>
[CODE]<?php
$dbuser="SQL Username";
$dbpass="SQL password";
$dbname = "SQL database";
$chandle = mysql_connect("localhost", $dbuser, $dbpass)
or die("Connection Failure to Database");
mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found." . $dbuser);
$mysql = mysql_query("SELECT * FROM apps where ID ='$_POSTNot much more to do! Add this into a file called 'process.php':Code:'") or die(mysql_error());
while($row = mysql_fetch_assoc($mysql)){
$p = $row['Open'];
}
if ($p == Open) {
echo '<frameset cols="*" rows="*"><frame style="width:100%;height:100%;margin:0;padding:0;" src="process/returnmessage_3.html" width="100%" height="100%" scrolling="auto" frameborder="0" marginwidth="0" marginheight="0" /></frameset>';
}
if ($p == Declined) {
echo '<frameset cols="*" rows="*"><frame style="width:100%;height:100%;margin:0;padding:0;" src="process/returnmessage_2.html" width="100%" height="100%" scrolling="auto" frameborder="0" marginwidth="0" marginheight="0" /></frameset>';
}
if ($p == Accepted) {
echo '<frameset cols="*" rows="*"><frame style="width:100%;height:100%;margin:0;padding:0;" src="process/returnmessage_1.html" width="100%" height="100%" scrolling="auto" frameborder="0" marginwidth="0" marginheight="0" /></frameset>';
}
if ($p == NULL) {
echo '<frameset cols="*" rows="*"><frame style="width:100%;height:100%;margin:0;padding:0;" src="process/returnmessage_4.html" width="100%" height="100%" scrolling="auto" frameborder="0" marginwidth="0" marginheight="0" /></frameset>';
}
?>
Only one more file left! Now add this into a file called 'search.php':Code:<?php
function assign_rand_value($num)
{
// accepts 1 - 36
switch($num)
{
case "1":
$rand_value = "a";
break;
case "2":
$rand_value = "b";
break;
case "3":
$rand_value = "c";
break;
case "4":
$rand_value = "d";
break;
case "5":
$rand_value = "e";
break;
case "6":
$rand_value = "f";
break;
case "7":
$rand_value = "g";
break;
case "8":
$rand_value = "h";
break;
case "9":
$rand_value = "i";
break;
case "10":
$rand_value = "j";
break;
case "11":
$rand_value = "k";
break;
case "12":
$rand_value = "l";
break;
case "13":
$rand_value = "m";
break;
case "14":
$rand_value = "n";
break;
case "15":
$rand_value = "o";
break;
case "16":
$rand_value = "p";
break;
case "17":
$rand_value = "q";
break;
case "18":
$rand_value = "r";
break;
case "19":
$rand_value = "s";
break;
case "20":
$rand_value = "t";
break;
case "21":
$rand_value = "u";
break;
case "22":
$rand_value = "v";
break;
case "23":
$rand_value = "w";
break;
case "24":
$rand_value = "x";
break;
case "25":
$rand_value = "y";
break;
case "26":
$rand_value = "z";
break;
case "27":
$rand_value = "0";
break;
case "28":
$rand_value = "1";
break;
case "29":
$rand_value = "2";
break;
case "30":
$rand_value = "3";
break;
case "31":
$rand_value = "4";
break;
case "32":
$rand_value = "5";
break;
case "33":
$rand_value = "6";
break;
case "34":
$rand_value = "7";
break;
case "35":
$rand_value = "8";
break;
case "36":
$rand_value = "9";
break;
}
return $rand_value;
}
function get_rand_id($length)
{
if($length>0)
{
$rand_id="";
for($i=1; $i<=$length; $i++)
{
mt_srand((double)microtime() * 1000000);
$num = mt_rand(1,36);
$rand_id .= assign_rand_value($num);
}
}
return $rand_id;
}
$ID = get_rand_id(20);
$s=$_SERVER["REMOTE_ADDR"];
$con = mysql_connect("localhost","SQL Username","SQL Password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("SQL database", $con);
$ipbancheck="SELECT * from apps where IP='$s' AND Open='Open'";
$ipbancheck2=mysql_query($ipbancheck);
while($ipbancheck3=mysql_fetch_array($ipbancheck2))
{
$IPBANNED=$ipbancheck3[IP];
}
//above lines check to see if user Ip is in banned IPs
if ($IPBANNED)
{
echo '<body TEXT="red" bgcolor="black"><center><font face="Comic Sans MS"><br><br>[ERROR]: You already have a Pending application open!<br> Please be patient, and wait until we make a decision on your other Application.</body></center>';
}
else
{
if ($_POST[user] == null) {
echo '<body TEXT="red" bgcolor="black"><font face="Comic Sans MS"><center><br><br>[ERROR]: You must fill in all of the boxes! <a href="application.php">Back</a></body></center>';
} else
if ($_POST[dob] == null) {
echo '<body TEXT="red" bgcolor="black"><font face="Comic Sans MS"><center><br><br>[ERROR]: You must fill in all of the boxes! <a href="application.php">Back</a></body></center>';
} else
if ($_POST[why] == null) {
echo '<body TEXT="red" bgcolor="black"><font face="Comic Sans MS"><center><br><br>[ERROR]: You must fill in all of the boxes! <a href="application.php">Back</a></body></center>';
} else
if ($_POST[offer] == null) {
echo '<body TEXT="red" bgcolor="black"><font face="Comic Sans MS"><center><br><br>[ERROR]: You must fill in all of the boxes! <a href="application.php">Back</a></body></center>';
} else
if ($_POST[other] == null) {
echo '<body TEXT="red" bgcolor="black"><font face="Comic Sans MS"><center><br><br>[ERROR]: You must fill in all of the boxes! <a href="application.php">Back</a></body></center>';
} else
$sql="INSERT INTO `apps` (`ID`, `Username`, `age`, `Open`, `why`, `offer`, `other`, `IP`)
VALUES
('$ID', '$_POST[user]', '$_POST[dob]', 'Open', '$_POST[why]','$_POST[offer]','$_POST[other]','$s')";
}
if (!mysql_query($sql,$con))
{
die();
}
mysql_close($con)
?>
<html>
<title>Process</title>
<body TEXT="red" bgcolor="black">
<font face="Comic Sans MS">
<div align="center"><br><br>
Your appeal has been submitted, and will be processed within 24 hours. To track your appeal, please write down this code:<br><br>
<b>
<?php
echo "$ID";
?>
</b><br><br>
You can track your appeal <a href="search.php">Here</a>.<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>Copyright © SlashScape 2008 - 2009. All Rights Reserved<br>
All webpages on our website are made 100% by our Web Developers.
</body>
</html>
Now download this file, and extract it to your application folder:Code:<html>
<body TEXT="red" bgcolor="black">
<center>
<font face="Comic Sans MS">
<br>
Please enter the Application ID that was given after the Application was submitted. When you hit the "Check Status" button,<br> you will be redirected to a page which will tell you the status of your Application.<br><br>
<form name="input" action="content.php" method="post">
<b>Application ID:</b><br><br> <input type="text" name="code" id ="code" maxlength="25"><br><br>
<input type="submit" value="Check Status">
[Only registered and activated users can see links. Click Here To Register...]
And you're done! You can edit the files inside the process folder if you wish, but don't forget to give me credits!!!!!
Yes, this was made 100% by me, so 100% credits go to me (h)
