Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!defined('SCMS')) die("Hacking attempt!");
- // these methods are a bit crude, ill refine them later especially error checks.
- class plugin {
- function setSession() {
- $_SESSION['status'] = TRUE;
- $_SESSION['username'] = $username;
- $this->aconnect();
- $accountquery = mysql_query("SELECT id, admin FROM `users` WHERE account = '$user'");
- $account = mysql_fetch_row($accountquery);
- $_SESSION['admin'] = $account['admin'];
- $_SESSION['accountid'] = $account['id'];
- $this->close();
- }
- function securePass($user, $pass) {
- $user = strtoupper($user);
- $pass = strtoupper($pass);
- return SHA1($user.':'.$pass);
- }
- function changePass($user, $oldpass, $newpass) {
- $user = mysql_real_escape_string($account);
- //Encrypt old pass.
- $opass = $this->encrypt_password($user, $oldpass);
- //mysql connect
- $sql = new sql();
- $sql->aconnect();
- //Check for correct account and pass info.
- $querya = "SELECT `password` FROM account WHERE username= '$user'";
- $querya1 = mysql_query($query);
- if($querya1 == $opass) {
- //Encrypt new pass
- $npass = $this->encrypt_password($account, $npass);
- //Add new pass to account db.
- $queryp = "REPLACE INTO account (sha_pass_hash) VALUES ($npass) WHERE username= '$user'";
- mysql_query($queryp);
- }
- $sql->close();
- }
- function datatable($data) {
- $data = explode(' ',$data);
- return $data;
- }
- function register($user, $pass, $exp, $email) {
- $user = mysql_real_escape_string($user);
- $username = strtoupper($user);
- $pass = mysql_real_escape_string($pass);
- //encrypt pass.
- $password = $this->encrypt_password($user,$pass);
- //mysql connect.
- $sql = new sql();
- $sql->aconnect();
- //check and see if account name is used.
- $checka = "SELECT `id` FROM account WHERE username= '$user'";
- $checka1 = mysql_query($checka);
- if(mysql_num_rows($checka1) > 0) {
- die("<center>".acct_error."</center>");
- }
- $query = mysql_query("INSERT INTO account (username,sha_pass_hash,email,expansion) VALUES ('$username','$password','$email','$exp')");
- if(!$query) {
- die("<center>Mysql query error.</center>");
- }else{
- echo "<center>Account Created Successfully.</center>";
- }
- $sql->close();
- }
- function login($user, $pass) {
- $password = $this->encrypt_password($user,$pass);
- $sql = new sql();
- $sql->aconnect();
- $user = mysql_real_escape_string($user);
- // checks username and pass against the database
- $qry_check_user = mysql_query("SELECT username FROM `account` WHERE username='$user'");
- $qry_check_pass = mysql_query("SELECT sha_pass_hash FROM `account` WHERE username='$user'");
- if (mysql_num_rows($qry_check_user) != 1){
- // if username is incorrect print message
- echo "<center>".user_error."</center>";
- }
- if ($qry_check_pass != $password) {
- // if password is incorrect print message
- echo "<center>".pass_error."</center>";
- }
- if (mysql_num_rows($qry_check_user) != 0 || mysql_num_rows($qry_check_pass) != 0){
- $_SESSION['status'] = TRUE;
- $_SESSION['username'] = $username;
- $accountquery = mysql_query("SELECT id, gmlevel FROM `account` WHERE username='$user'");
- $account = mysql_fetch_row($accountquery);
- $_SESSION['gmlevel'] = $account['gmlevel'];
- $_SESSION['accountid'] = $account['id'];
- /*if ($_GET['pageid'] = "adminlog") {
- if ($_SESSION['gmlevel'] >= 3) {
- $_SESSION['admin'] = TRUE;
- }
- }*/
- ?>
- <SCRIPT LANGUAGE="JavaScript">
- <!-- Begin
- window.location="index.php";
- // End -->
- </script>
- <?php
- }
- $sql->close();
- }
- }
- function getRace($id) {
- $sql = new sql();
- $sql->wconnect();
- $raceQuery = "SELECT * FROM race WHERE raceid = '$id' LIMIT 1";
- $raceResult = mysql_query($raceQuery);
- if (!$raceResult) {
- $message = mysql_error();
- error_reporting('E_NONE');
- echo $message;
- }
- while ($raceRow = mysql_fetch_assoc($raceResult)) {
- $name = $raceRow['name'];
- }
- return $name;
- }
- function getRaceFaction($id) {
- $sql = new sql();
- $sql->wconnect();
- $raceQuery = "SELECT * FROM race WHERE raceid = '$id' LIMIT 1";
- $raceResult = mysql_query($raceQuery);
- if (!$raceResult) {
- trigger_error("Race id wrong.");
- }
- while ($raceRow = mysql_fetch_assoc($raceResult)) {
- $faction = $raceRow['faction'];
- }
- return $faction;
- }
- function pharsegold($type, $gold) {
- if($type == "g") {
- $money_gold = (int)($gold/10000);
- $returngold = $money_gold ;
- }else if($type == "s") {
- $money_gold = (int)($gold/10000);
- $money_silver = (int)(($gold-$money_gold*10000)/100);
- $returngold = $money_silver;
- }else if($type == "c") {
- $money_gold = (int)($gold/10000);
- $money_silver = (int)(($gold-$money_gold*10000)/100);
- $money_cooper = (int)($gold-$money_gold*10000-$money_silver*100);
- $returngold = $money_cooper;
- }
- return $returngold;
- }
- function realmlist($id,$name, $ip, $port, $mysql, $sqlun, $sqlpass, $chardb, $maxplr) {
- connectremotes($mysql, $sqlun, $sqlpass, $chardb);
- $queryup = "SELECT count(online) AS result_count FROM characters WHERE online = '1' LIMIT 1";
- $result2 = mysql_fetch_assoc(mysql_query($queryup));
- $countnum = $result2['result_count'];
- if($countnum <= "09") {
- $cntfin = str_replace("0", "", $result2['result_count']);
- } else if($countnum == "00") {
- $cntfin = "0";
- } else if(empty($countnum)) {
- $cntfin = "0";
- } else {
- $cntfin = $result2['result_count'];
- }
- $total = floor(($maxplr - $cntfin)/10);
- if($cntfin == "0") {
- $plr = "0";
- }else if(empty($cntfin)) {
- $plr = "0";
- } else {
- $plr = $cntfin;
- }
- $final = '
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td height="10px" align=center><div class="status"><a href=?pageid=status&id='.$id.' style="text-decoration:none">'.$name.'</a></div></td>
- </tr>
- <tr>
- <td><table width="100px" align="center" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td height="10px" width="'.$$cntfin.'" style="background-image:url(includes/images/status/bar2.png)"></td>
- <td height="10px" width="'.$total.'" style="background-image:url(includes/images/status/bar.png)"></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <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>
- </tr>
- </table>
- ';
- return $final;
- $sql->close();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement