PDA

View Full Version : [PHP] GM Login Script


Nick
07-05-2009, 06:19 AM
//Code By Kickerbat & Ahorner.
//Purpose: World Of Warcraft GM Login privlidge script. Access login parts of a website with gm rights only. You can edit to your own will.

Login.php

<?php

//Start session
session_start();

//include_once("config.php");
//If you want to wack the sql defines below in a config for multipul pages then copy the defines into a config.php and remove the // infront of the include and delete the define data in this script.

//Connect to mysql server
//E.G define(MYSQL_HOST,"localhost");
define(MYSQL_HOST," "); // SQL server location (usually localhost)
define(MYSQL_USER," "); // Username for that server
define(MYSQL_PASS," "); // Password for that server
define(MYSQL_ACCOUNTS," "); // The Database with the tables: accounts
define(MYSQL_LOGON," "); // The Database with the tables: characters, and mailbox_insert_queue (usually logon)
define(MYSQL_ASCENT," "); // The Database with the items table and such (usually ascent)
$link=mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PA SS);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db=mysql_select_db(MYSQL_ACCOUNTS);
if(!$db) {
die("Unable to select database");
}
$login = $_POST['login'];
$password = $_POST['password'];

$login = mysql_real_escape_string(html_entity_decode(htmlen tities($login)));
$password = mysql_real_escape_string(html_entity_decode(htmlen tities($password)));

//Create query
$result=mysql_query("SELECT acct FROM accounts WHERE login='$login' AND password='$password'");
while ($row = mysql_fetch_array($result)) {
$acct = $row['acct'];}
$result2 = mysql_query("SELECT gm FROM accounts WHERE acct='$acct'");
while ($row2 = mysql_fetch_array($result2)) {
$gm = $row2['gm'];}
$qry3="SELECT acct FROM accounts WHERE login='$login' AND password='$password'";
$result3=mysql_query($qry3);
$acct=mysql_fetch_assoc($result3);
$accountid = $acct['acct'];
$db2=mysql_select_db(MYSQL_LOGON);
if(!$db2) {
die("Unable to select database");
}
$result4=mysql_query("SELECT * FROM characters WHERE acct='$accountid'");
//Check whether the query was successful or not
if($result) {
if ($gm == "0"){
header("location: not-gm-page.php"); //EDIT
exit();
}
else{
if(mysql_num_rows($result3)>0) {
//Login Successful
session_regenerate_id();
$member=mysql_fetch_assoc($result4);
$_SESSION['SESS_MEMBER_ID']=$member['guid'];
session_write_close();
header("location: gm-logged-in-successfully-page.php"); //EDIT
exit();
}else {
//Login failed
header("location: login-failed-page.php"); //EDIT
exit();
}
}

}else {
die("Query failed");
}
?>

Auth.php
<?php
session_start();
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID'])=='')) {
header("location: not-logged-in-page.php");
exit();
}
?>

Logout.php
<?php
//Start the session
session_start();
//Unset the variable SESS_MEMBER_ID stored in sessions
unset($_SESSION['SESS_MEMBER_ID']);
?>
Logged Out Message

Other
How do i make gm only pages?
<?
require_once('auth.php');
?>
To your page header.

Credits
KickerBat
AHorner

Fightnight
07-05-2009, 08:59 AM
LOVE IT! :D ,
Just 1 problem for me ^^ "I could set it up :$"
+rep from me !

Nick
07-05-2009, 09:49 AM
LOL, I had a gm login tool, ive erased it from my computer so i cannot share it :(, Sorry.