Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.65 KB | None | 0 0
  1. <?php
  2. if(!defined('SCMS')) die("Hacking attempt!");
  3.  
  4.     // these methods are a bit crude, ill refine them later especially error checks.
  5.     class plugin {
  6.    
  7.         function setSession() {
  8.                 $_SESSION['status'] = TRUE;
  9.                 $_SESSION['username'] = $username;
  10.                 $this->aconnect();
  11.                 $accountquery = mysql_query("SELECT id, admin FROM `users` WHERE account = '$user'");
  12.                 $account = mysql_fetch_row($accountquery);
  13.                 $_SESSION['admin'] = $account['admin'];
  14.                 $_SESSION['accountid'] = $account['id'];
  15.                 $this->close();
  16.            
  17.         }
  18.        
  19.         function securePass($user, $pass) {
  20.        
  21.             $user = strtoupper($user);
  22.             $pass = strtoupper($pass);
  23.             return SHA1($user.':'.$pass);
  24.         }
  25.        
  26.         function changePass($user, $oldpass, $newpass) {
  27.        
  28.             $user = mysql_real_escape_string($account);
  29.             //Encrypt old pass.
  30.             $opass = $this->encrypt_password($user, $oldpass);
  31.             //mysql connect
  32.             $sql = new sql();
  33.             $sql->aconnect();
  34.             //Check for correct account and pass info.
  35.             $querya = "SELECT `password` FROM account WHERE username= '$user'";
  36.             $querya1 = mysql_query($query);
  37.            
  38.             if($querya1 == $opass) {
  39.                 //Encrypt new pass
  40.                 $npass = $this->encrypt_password($account, $npass);
  41.                 //Add new pass to account db.
  42.                 $queryp = "REPLACE INTO account (sha_pass_hash) VALUES ($npass) WHERE username= '$user'";
  43.                 mysql_query($queryp);
  44.             }
  45.             $sql->close();
  46.         }
  47.  
  48.         function datatable($data) {
  49.                
  50.             $data = explode(' ',$data);
  51.             return $data;
  52.         }
  53.        
  54.         function register($user, $pass, $exp, $email) {
  55.        
  56.             $user = mysql_real_escape_string($user);
  57.             $username = strtoupper($user);
  58.             $pass = mysql_real_escape_string($pass);
  59.             //encrypt pass.
  60.             $password = $this->encrypt_password($user,$pass);
  61.             //mysql connect.
  62.             $sql = new sql();
  63.             $sql->aconnect();
  64.             //check and see if account name is used.
  65.             $checka = "SELECT `id` FROM account WHERE username= '$user'";
  66.             $checka1 = mysql_query($checka);
  67.            
  68.             if(mysql_num_rows($checka1) > 0) {
  69.                 die("<center>".acct_error."</center>");
  70.             }  
  71.             $query = mysql_query("INSERT INTO account (username,sha_pass_hash,email,expansion) VALUES ('$username','$password','$email','$exp')");
  72.             if(!$query) {
  73.                 die("<center>Mysql query error.</center>");
  74.             }else{
  75.                 echo "<center>Account Created Successfully.</center>";
  76.             }
  77.            
  78.             $sql->close();
  79.         }
  80.        
  81.         function login($user, $pass) {
  82.        
  83.             $password = $this->encrypt_password($user,$pass);
  84.             $sql = new sql();
  85.             $sql->aconnect();
  86.             $user = mysql_real_escape_string($user);
  87.             // checks username and pass against the database   
  88.             $qry_check_user = mysql_query("SELECT username FROM `account` WHERE username='$user'");
  89.             $qry_check_pass = mysql_query("SELECT sha_pass_hash FROM `account` WHERE username='$user'");
  90.  
  91.             if (mysql_num_rows($qry_check_user) != 1){
  92.                 // if username is incorrect print message
  93.                 echo "<center>".user_error."</center>";
  94.             }
  95.        
  96.             if  ($qry_check_pass != $password) {
  97.                 // if password is incorrect print message
  98.                 echo "<center>".pass_error."</center>";
  99.             }
  100.        
  101.             if (mysql_num_rows($qry_check_user) != 0 || mysql_num_rows($qry_check_pass) != 0){
  102.                 $_SESSION['status'] = TRUE;
  103.                 $_SESSION['username'] = $username;
  104.                 $accountquery = mysql_query("SELECT id, gmlevel FROM `account` WHERE username='$user'");
  105.                 $account = mysql_fetch_row($accountquery);
  106.                 $_SESSION['gmlevel'] = $account['gmlevel'];
  107.                 $_SESSION['accountid'] = $account['id'];
  108.             /*if ($_GET['pageid'] = "adminlog") {
  109.                     if ($_SESSION['gmlevel'] >= 3) {
  110.                         $_SESSION['admin'] = TRUE;
  111.                     }
  112.             }*/
  113.             ?>
  114.             <SCRIPT LANGUAGE="JavaScript">
  115.             <!-- Begin
  116.             window.location="index.php";
  117.             // End -->
  118.             </script>
  119.             <?php
  120.  
  121.             }
  122.             $sql->close();
  123.         }  
  124.        
  125.     }
  126.  
  127.     function getRace($id) {
  128.    
  129.         $sql = new sql();
  130.         $sql->wconnect();
  131.         $raceQuery = "SELECT * FROM race WHERE raceid = '$id' LIMIT 1";
  132.         $raceResult = mysql_query($raceQuery);
  133.  
  134.         if (!$raceResult) {
  135.             $message  = mysql_error();
  136.             error_reporting('E_NONE');
  137.             echo $message;
  138.         }
  139.         while ($raceRow = mysql_fetch_assoc($raceResult)) {
  140.             $name = $raceRow['name'];
  141.         }
  142.  
  143.         return $name;
  144.     }
  145.  
  146.  
  147.     function getRaceFaction($id) {
  148.        
  149.         $sql = new sql();
  150.         $sql->wconnect();
  151.         $raceQuery = "SELECT * FROM race WHERE raceid = '$id' LIMIT 1";
  152.         $raceResult = mysql_query($raceQuery);
  153.  
  154.         if (!$raceResult) {
  155.             trigger_error("Race id wrong.");
  156.         }
  157.  
  158.         while ($raceRow = mysql_fetch_assoc($raceResult)) {
  159.             $faction = $raceRow['faction'];
  160.         }
  161.  
  162.         return $faction;
  163.     }
  164.  
  165.     function pharsegold($type, $gold) {
  166.    
  167.         if($type == "g") {
  168.             $money_gold = (int)($gold/10000);
  169.             $returngold = $money_gold ;
  170.         }else if($type == "s") {
  171.             $money_gold = (int)($gold/10000);
  172.             $money_silver = (int)(($gold-$money_gold*10000)/100);
  173.             $returngold = $money_silver;
  174.         }else if($type == "c") {
  175.             $money_gold = (int)($gold/10000);
  176.             $money_silver = (int)(($gold-$money_gold*10000)/100);
  177.             $money_cooper = (int)($gold-$money_gold*10000-$money_silver*100);
  178.             $returngold = $money_cooper;
  179.         }
  180.        
  181.         return $returngold;
  182.     }
  183.  
  184.     function realmlist($id,$name, $ip, $port, $mysql, $sqlun, $sqlpass, $chardb, $maxplr) {
  185.         connectremotes($mysql, $sqlun, $sqlpass, $chardb);
  186.         $queryup = "SELECT  count(online) AS result_count FROM characters WHERE online = '1' LIMIT 1";
  187.         $result2 = mysql_fetch_assoc(mysql_query($queryup));
  188.  
  189.         $countnum = $result2['result_count'];
  190.         if($countnum <= "09") {
  191.             $cntfin = str_replace("0", "", $result2['result_count']);
  192.         } else if($countnum == "00") {
  193.             $cntfin = "0";
  194.         } else if(empty($countnum)) {
  195.             $cntfin = "0";
  196.         } else {
  197.             $cntfin = $result2['result_count'];
  198.         }
  199.         $total = floor(($maxplr - $cntfin)/10);
  200.  
  201.         if($cntfin == "0") {
  202.             $plr = "0";
  203.         }else if(empty($cntfin)) {
  204.             $plr = "0";
  205.         } else {
  206.             $plr = $cntfin;
  207.         }
  208.  
  209.         $final = '
  210.             <table width="100%" border="0" cellspacing="0" cellpadding="0">
  211.                 <tr>
  212.                     <td height="10px" align=center><div class="status"><a href=?pageid=status&id='.$id.' style="text-decoration:none">'.$name.'</a></div></td>
  213.                 </tr>
  214.                 <tr>
  215.                     <td><table width="100px" align="center" border="0" cellspacing="0" cellpadding="0">
  216.                 <tr>
  217.                     <td height="10px" width="'.$$cntfin.'" style="background-image:url(includes/images/status/bar2.png)"></td>
  218.                     <td height="10px" width="'.$total.'" style="background-image:url(includes/images/status/bar.png)"></td>
  219.                 </tr>
  220.             </table></td>
  221.                 </tr>
  222.                 <tr>
  223.                     <td height="10px" align=center><center> <font style="font-size:9px; font-family:Tahoma, Geneva, sans-serif">('.$plr.' / '.$maxplr.' ) '.players_online.'</font></center><br /></td>
  224.                 </tr>  
  225.             </table>
  226.         ';
  227.         return $final;
  228.         $sql->close();
  229.     }
  230. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement