Jump to content

|PHP| Interesting Scripts for your Website


Auntie Mangos
 Share

Recommended Posts

  • Replies 171
  • Created
  • Last Reply

Top Posters In This Topic

yeah it works fine.

- i dont know why but i can see only my first char and the other chars not

- what must i do for make a kombination with race and gender (like human->1 and gender->0 : show img 1-0.jpg) (like human->1 and gender->1 : show img 1-1.jpg)

sorry that i cant show you the pics.

on the pictures you can see on race human-male-pic, human-female-pic, orc-male-pic, orc-female-pic,...

just so you know... im not going to make everything you want...there will be a moment on which you'll have to learn to edit stuff yourself

i'll check what's with the chars, the pics can be done like this:

[img='.$charinfo['race'].]

NOTE: not tested

EDIT:

again, new version...this time it's the last one unless there's an important bug somewhere

<?php
$reading = @fopen("config.php", 'r');
if ($reading)               // if we can read the config.php file that's on the frontpage... of this thread: [url]http://getmangos.eu/community/viewtopic.php?id=11566[/url]
   include "config.php";
else                           // else, we define them here
{
   $port = "3306";
   $host = "localhost";
   $user = "root";
   $pass = "mangos"; 
   $mangoscharacters = "characters";
   $mangosrealm = "realmd";
}
if (!(isset($_COOKIE['logged_in'])) && $_POST['password'] == "")    // if the form is not posted and the cookie not present
{
   ?>
   <html>
   <body>
   <form name="login" method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
       Username: <input type="text" name="username">
       Password: <input type="password" name="password">
       <input type="submit" value="Log in">
   </form>
   </body>
   </html>
   <?php
}
else if (($_POST['username'] != "" && $_POST['password'] != "") || isset($_COOKIE['logged_in']))  // if something was posted or the cookie is present
{
   if (!isset($_COOKIE['logged_in']))       // get the name and pass from the form and make the pass sha encrypted
   {
       $username = $_POST['username'];
       $password = $_POST['password'];
       $username = strtoupper($username);
       $password = strtoupper($password);
       $password = SHA1($username.':'.$password);
   }
   else                      // else, we read the cookie
   {
       $parts = explode(",", $_COOKIE['logged_in']);          // split the cookie's contents at the comma
       $username = $parts[0];                         // part 1 is the username
       $password = $parts[1];                         // part 2 is the password
   }

   $class = array(1=>"Warrior",2=>"Paladin",3=>"Hunter",4=>"Rogue",5=>"Priest",6=>"Death Knight",7=>"Shaman",8=>"Mage",9=>"Warlock",11=>"Druid");
   $race = array(1=>"Human",2=>"Orc",3=>"Dwarf",4=>"Night Elf",5=>"Undead",6=>"Tauren",7=>"Gnome",8=>"Troll",10=>"Blood Elf",11=>"Draenei");
   $map = array(0=>"Eastern Kingdoms",1=>"Kalimdor",33=>"Shadowfang Keep",34=>"Stormwind Stockade",35=>"Stormwind Prison",36=>"Deadmines",43=>"Wailing Caverns",44=>"Monastery",47=>"Razorfen Kraul",48=>"Blackfathom",70=>"Uldaman",90=>"Gnomeragon",109=>"Sunken Temple",129=>"Razorfen Downs",169=>"Emerald Dream",189=>"Monastery",209=>"Tanaris",229=>"Black Rock Spire",230=>"Black Rock Depths",249=>"Onyxia Lair",269=>"Caverns Of Time",289=>"School of Necromancy",309=>"Zulgurub",329=>"Stratholme",349=>"Mauradon",369=>"Deeprun Tram",389=>"Orgrimmar",409=>"MoltenCore",429=>"DireMaul",469=>"Blackwing Lair",509=>"AhnQiraj",530=>"Dalaran",531=>"AhnQiraj Temple",532=>"Karazahn",533=>"Stratholme",534=>"Hyjal Past",540=>"Hellfire Military",542=>"Hellfire Demon",543=>"Hellfire Rampart",544=>"Hellfire Raid",545=>"Coilfang Pumping",546=>"Coilfang Marsh",547=>"Coilfang Draenei",548=>"Coilfang Raid",550=>"Tempest Keep Raid",552=>"Tempest Keep Arcane",553=>"Tempest Keep Atrium",554=>"Tempest Keep Factory",555=>"Auchindoun Shadow",556=>"Auchindoun Demon",557=>"Auchindoun Ethereal",558=>"Auchindoun Draenei",560=>"Hillsbrad Past",562=>"Blades Edge Arena",564=>"Black Temple",565=>"Gruuls Lair",566=>"Netherstorm BG",568=>"ZulAman",571=>"Northrend",574=>"Valgarde 70",575=>"Utgarde Pinnacle",576=>"Nexus 70",578=>"Nexus 80",580=>"Sunwell Plateau",595=>"Stratholme COT",598=>"Sunwell 5",599=>"Ulduar 70",600=>"Drak Theron Keep",602=>"Ulduar 80",603=>"Ulduar Raid",604=>"GunDrak",607=>"Northrend BG",608=>"Violet Hold",609=>"Ebon Hold",615=>"The Obsidian Sanctum",616=>"The Eye of Eternity",617=>"Dalaran Sewers",618=>"The Ring of Valor",619=>"Ahn'kahet: The Old Kingdom",624=>"Vault of Archavon",628=>"Isle of Conquest",631=>"Icecrown Citadel Raid",632=>"Forge of Souls",649=>"Argent Tournament Raid",650=>"Argent Tournament Dungeon",658=>"Pit Of Saron",668=>"Halls of Reflection",723=>"Stormwind",724=>"The Ruby Sanctum");
   $gender = array(0=>"Male",1=>"Female");

   $host = $host.":".$port;
   $connection = mysql_connect($host, $user, $pass);
   if ($connection)
       $connected_db = mysql_select_db($mangosrealm);
   if ($connection && $connected_db)
   {
       $query = mysql_query("SELECT `sha_pass_hash`, `id` FROM `account` WHERE `username` = '$username';");
       if (mysql_num_rows($query) != 0)
       {
           $fields = mysql_fetch_assoc($query);
           $real_pass = $fields['sha_pass_hash'];
           $id = $fields['id'];
           if ($password == $real_pass)
           {
               setcookie("logged_in", $username.",".$password, time()+600);
               mysql_select_db($mangoscharacters);
               $getchars = mysql_query("SELECT * FROM `characters` WHERE `account` = '$id';");    //query to get all the char fields from the DB
               if ($getchars)
               {
                   echo '
                       <table border="0.5">
                       <tr>
                           <th>Picture</th>
                           <th>Name</th>
                           <th>Race</th>
                           <th>Class</th>
                           <th>Level</th>
                           <th>Map</th>
                           <th>Gender</th>
                       </tr>
                   ';
                   for($i = 0; $i < mysql_num_rows($getchars); $i++)    // process all chars, one by one
                   {
                       $charinfo = mysql_fetch_assoc($getchars);     // get all the fields from the query
                       echo '
                           <tr>
                               <td>[img='.$charinfo['race'].]
                               <td>'.$charinfo['name'].'</td>
                               <td>'.$race[$charinfo['race']].'</td>
                               <td>'.$class[$charinfo['class']].'</td>
                               <td>'.$charinfo['level'].'</td>
                               <td>'.$map[$charinfo['map']].'</td>
                               <td>'.$gender[$charinfo['gender']].'</td>
                           </tr>
                       ';
                   }
                   echo '
                       </table>
                   ';
               }
               else
                   die("You don't have any characters");
           }
           else
               die("Wrong pass!");
       }
       else
           die("Account does not exist!");
   }
}
?>

the image now has it's own column in the output, if the image is not found it will display "$race-$gender" (where $race is the race etc.)

and it now processes all chars

Link to comment
Share on other sites

Heya

who can help me with a GM online check ( online check, if online a gm on my server )

regards

Betaman

something like this?

<?php
$reading = @fopen("config.php", 'r');
if ($reading)               // if we can read the config.php file that's on the frontpage... of this thread: [url]http://getmangos.eu/community/viewtopic.php?id=11566[/url]
   include "config.php";
else                           // else, we define them here
{
   $port = "3306";
   $host = "localhost";
   $user = "root";
   $pass = "mangos"; 
   $mangoscharacters = "characters";
   $mangosrealm = "realmd";
}
/* OPTIONS */
$gmonly = 1;
/* End of OPTIONS */

$class = array(1=>"Warrior",2=>"Paladin",3=>"Hunter",4=>"Rogue",5=>"Priest",6=>"Death Knight",7=>"Shaman",8=>"Mage",9=>"Warlock",11=>"Druid");
$race = array(1=>"Human",2=>"Orc",3=>"Dwarf",4=>"Night Elf",5=>"Undead",6=>"Tauren",7=>"Gnome",8=>"Troll",10=>"Blood Elf",11=>"Draenei");
$map = array(0=>"Eastern Kingdoms",1=>"Kalimdor",33=>"Shadowfang Keep",34=>"Stormwind Stockade",35=>"Stormwind Prison",36=>"Deadmines",43=>"Wailing Caverns",44=>"Monastery",47=>"Razorfen Kraul",48=>"Blackfathom",70=>"Uldaman",90=>"Gnomeragon",109=>"Sunken Temple",129=>"Razorfen Downs",169=>"Emerald Dream",189=>"Monastery",209=>"Tanaris",229=>"Black Rock Spire",230=>"Black Rock Depths",249=>"Onyxia Lair",269=>"Caverns Of Time",289=>"School of Necromancy",309=>"Zulgurub",329=>"Stratholme",349=>"Mauradon",369=>"Deeprun Tram",389=>"Orgrimmar",409=>"MoltenCore",429=>"DireMaul",469=>"Blackwing Lair",509=>"AhnQiraj",530=>"Dalaran",531=>"AhnQiraj Temple",532=>"Karazahn",533=>"Stratholme",534=>"Hyjal Past",540=>"Hellfire Military",542=>"Hellfire Demon",543=>"Hellfire Rampart",544=>"Hellfire Raid",545=>"Coilfang Pumping",546=>"Coilfang Marsh",547=>"Coilfang Draenei",548=>"Coilfang Raid",550=>"Tempest Keep Raid",552=>"Tempest Keep Arcane",553=>"Tempest Keep Atrium",554=>"Tempest Keep Factory",555=>"Auchindoun Shadow",556=>"Auchindoun Demon",557=>"Auchindoun Ethereal",558=>"Auchindoun Draenei",560=>"Hillsbrad Past",562=>"Blades Edge Arena",564=>"Black Temple",565=>"Gruuls Lair",566=>"Netherstorm BG",568=>"ZulAman",571=>"Northrend",574=>"Valgarde 70",575=>"Utgarde Pinnacle",576=>"Nexus 70",578=>"Nexus 80",580=>"Sunwell Plateau",595=>"Stratholme COT",598=>"Sunwell 5",599=>"Ulduar 70",600=>"Drak Theron Keep",602=>"Ulduar 80",603=>"Ulduar Raid",604=>"GunDrak",607=>"Northrend BG",608=>"Violet Hold",609=>"Ebon Hold",615=>"The Obsidian Sanctum",616=>"The Eye of Eternity",617=>"Dalaran Sewers",618=>"The Ring of Valor",619=>"Ahn'kahet: The Old Kingdom",624=>"Vault of Archavon",628=>"Isle of Conquest",631=>"Icecrown Citadel Raid",632=>"Forge of Souls",649=>"Argent Tournament Raid",650=>"Argent Tournament Dungeon",658=>"Pit Of Saron",668=>"Halls of Reflection",723=>"Stormwind",724=>"The Ruby Sanctum");
$gender = array(0=>"Male",1=>"Female");

$host = $host.":".$port;
$connection = mysql_connect($host, $user, $pass);
if ($connection)
   $connected_db = mysql_select_db($mangoscharacters);
if ($connection && $connected_db)
{
   $getchars = mysql_query("SELECT * FROM `characters`;");    //query to get all the char fields from the DB
   if ($getchars)
   {
       echo '
           <table border="0.5">
           <tr>
               <th>Account</th>
               <th>Picture</th>
               <th>Name</th>
               <th>Race</th>
               <th>Class</th>
               <th>Level</th>
               <th>Map</th>
               <th>Gender</th>
           </tr>
       ';
       for($j = 0; $j < mysql_num_rows($getchars); $j++)    // process all chars, one by one
       {
           $charinfo = mysql_fetch_assoc($getchars);     // get all the fields from the query
           mysql_select_db($mangosrealm);
           $accountid = $charinfo['account'];
           $accountquery = mysql_query("SELECT `username`, `gmlevel` FROM `account` WHERE `id` = '$accountid';");
           $accountinfo = mysql_fetch_assoc($accountquery);
           if ($gmonly == 1)
           {
               if ($accountinfo['gmlevel'] == 0)
                   continue;
           }
           echo '
               <tr>
                   <td>'.$accountinfo['username'].'</td>
                   <td>[img='.$charinfo['race'].]
                   <td>'.$charinfo['name'].'</td>
                   <td>'.$race[$charinfo['race']].'</td>
                   <td>'.$class[$charinfo['class']].'</td>
                   <td>'.$charinfo['level'].'</td>
                   <td>'.$map[$charinfo['map']].'</td>
                   <td>'.$gender[$charinfo['gender']].'</td>
               </tr>
           ';
       }
       echo '</table>';
   }
}
?>

Link to comment
Share on other sites

  • 39 years later...

Interesting PHP Scripts, that maybe you need in your website.

Chears.!

* config.php

<?php 
$ip = "";
$port = "";
$host = "";
$user = "";
$pass = ""; 
$mangoscharacters = "";
$mangosrealm = "";
$cod = 'utf8';
?>

* Server Status

<?php 
require_once ( 'config.php');
if (! $sock = @fsockopen($ip, $port, $num, $error, 3)) 
echo '<FONT COLOR=red>Off</FONT>';
else{ 
echo '<FONT COLOR=yellow>On</FONT>'; 
fclose($sock);
} 
?>

* Shows Current Online Players

<?
require_once ( 'config.php');
$conn = mysql_connect($host, $user, $pass) or die('Connection failed: ' . mysql_error());

mysql_select_db($mangoscharacters, $conn) or die('Select DB failed: ' . mysql_error());

$sql = "SELECT Count(Online) FROM `characters` WHERE `online` = 1";
$result = mysql_query($sql, $conn);
$row = mysql_fetch_array($result);
$online = $row["Count(Online)"];

echo $online; 
?>

* Shows Max Online Players

<?php
require_once ( 'config.php');

mysql_connect($host, $user, $pass) or die ("Can't connect with $host");
mysql_selectdb ("$mangosrealm");

$max = mysql_query ("select max(`maxplayers`) from uptime");     
$max = mysql_result ($max,0);
echo "Max online:$max 
";
?> 

* Show Uptime Server

<?php
require_once ( 'config.php');

mysql_connect($host, $user, $pass) or die ("Can't connect with $host");
mysql_selectdb ("$mangosrealm");

$sql = mysql_query ("SELECT * FROM $mangosrealm.`uptime` ORDER BY `starttime` DESC LIMIT 1");  
$uptime_results = mysql_fetch_array($sql);    

if ($uptime_results['uptime'] > 86400) { 
   $uptime =  round(($uptime_results['uptime'] / 24 / 60 / 60),2)." Days";
}
elseif($uptime_results['uptime'] > 3600) { 
   $uptime =  round(($uptime_results['uptime'] / 60 / 60),2)." Hours";
}
else { 
   $uptime =  round(($uptime_results['uptime'] / 60),2)." Min";
}

echo "Uptime:$uptime 
";
?> 

* Show Uptime Server (2)

<?php
require_once ( 'config.php');

mysql_connect($host, $user, $pass) or die ("Can't connect with $host");
mysql_select_db ("$mangosrealm");

$sql = mysql_query ("SELECT * FROM $mangosrealm.`uptime` ORDER BY `starttime` DESC LIMIT 1");  
$sql = time()-mysql_result ($sql,0);
$sec = $sql%60;
$uptime = intval ($sq/60);
$min = $sql%60;
$uptime = intval ($sql/60);
$hours = $sql%24;
$uptime = intval($sql/24);
$days = $sql;

echo "Time Online: $days days $hours hrs $min min $sec sec
";
?> 

* IP Banned

<?php   
require_once ( 'config.php');

echo "<center><table border=1><tr><th>IP:</th><th>Reason:</th><th>Ban Data</th><th>Unban Data</th></tr>"; 

$conn = mysql_connect($host, $user, $pass) or die ("Can't connect with $host");   
mysql_select_db($mangosrealm, $conn);   

$sql = "SELECT `ip`,`banreason`, `bandate`, `unbandate` FROM `ip_banned`";   
$result = mysql_query($sql, $conn);   

while ($result_data = mysql_fetch_array($result))   
{   
echo "<tr><td align=\\"center\\">".$result_data["ip"]."</td>";   
echo "<td align=\\"center\\">".$result_data["banreason"]."</td>";   
echo "<td align=\\"center\\">".date("d.m.Y H:m",$result_data["bandate"])."</td>";
echo "<td align=\\"center\\">".date("d.m.Y H:m",$result_data["unbandate"])."</td>";   

echo "</tr>";   

}   

mysql_close($conn);   

echo "</table></center>";   
?>

* IP Banned (2)

<?php  
require_once ('config.php');

echo "<table width=\\"100%\\" border=\\"1\\" align=\\"center\\"><tr>  
<td align=\\"center\\" width=\\"20%\\">IP:</td>  
<td align=\\"center\\" width=\\"20%\\">Ban set:</td>  
<td align=\\"center\\" width=\\"20%\\">Banned:</td>  
<td align=\\"center\\" width=\\"20%\\">Cause:</td>  
<td align=\\"center\\" width=\\"20%\\">Ban to:</td>  
</tr></table>";  

mysql_connect($host, $user, $pass) or die ("Can't connect with $host");
mysql_selectdb ("$mangosrealm");

$u=0;  
$bannedip = mysql_query("SELECT * FROM ip_banned ORDER BY bandate DESC LIMIT 100"); 

@$row = mysql_fetch_array($bannedip[$u]); {  
while($row = mysql_fetch_array($bannedip)) {  

$banip = $row['ip'];  
$bandate = date("H:i:s d.m.Y", $row['bandate']);  
$bannedby = $row['bannedby'];  
$banreason = $row['banreason'];  
$unbandate = date("H:i:s d.m.Y", $row['unbandate']);  
echo "<font color=\\"beer\\">  
<table width=\\"100%\\"border=\\"1\\" align=\\"center\\"><tr>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">$banip</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">$bandate g.</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">$bannedby</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">$banreason</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">$unbandate g.</td></color>  
</tr></table></font>";  
$u++;  
}  
}  
?>

* Account Banned

<?php   
require_once ( 'config.php');

echo "<center><table border=1><tr><th>acc ID:</th><th>User:</th><th>Reason:</th><th>Ban Data</th><th>Unban Data</th></tr>";   

$conn = mysql_connect($host, $user, $pass) or die ("Can't connect with $host");   

mysql_select_db($mangosrealm, $conn);   

$sqle = "SELECT `id`,`banreason`, `bandate`, `unbandate` FROM `account_banned`";   
$sql = "SELECT `ab`.*, `a`.`username` FROM `account_banned` as `ab` "
."LEFT JOIN `account` as `a` ON `a`.`id` = `ab`.`id`;";

$result = mysql_query($sql, $conn);   

while ($result_data = mysql_fetch_array($result))   

{   
echo "<tr><td align=\\"center\\">".$result_data["id"]."</td>";   
echo "<td align=\\"center\\">".$result_data["username"]."</td>";   
echo "<td align=\\"center\\">".$result_data["banreason"]."</td>";   
echo "<td align=\\"center\\">".date("d.m.Y H:m",$result_data["bandate"])."</td>";
echo "<td align=\\"center\\">".date("d.m.Y H:m",$result_data["unbandate"])."</td>";   

echo "</tr>";   

}   
mysql_close($conn);   
echo "</table></center>";   
?>

* Account Banned (2)

<?php  
require_once ('config.php');

echo "<table width=\\"100%\\" border=\\"1\\" align=\\"center\\"><tr>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">banned:</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">Ban set:</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">Banned:</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">Cause:</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">Ban to:</td> </color>  
</tr></table>";  


mysql_connect($host, $user, $pass) or die ("Can't connect with $host");
mysql_selectdb ("$mangosrealm");

$i=0;  
$data = mysql_query("SELECT * FROM account_banned WHERE active = 1 ORDER BY bandate DESC LIMIT 100");  
@$row = mysql_fetch_array($data[$i]); {  
while($row = mysql_fetch_array($data)) {  
$banid = $row['id'];  
$usern = mysql_query("SELECT * FROM account WHERE id= $banid LIMIT 1");  
$rowuser = mysql_fetch_array($usern);  
$banuser = $rowuser['username'];  
$bandate = date("H:i:s d.m.Y", $row['bandate']);  
$bannedby = $row['bannedby'];  
$banreason = $row['banreason'];  
$unbandate = date("H:i:s d.m.Y", $row['unbandate']);  

echo "<font color=\\"beer\\">  
<table width=\\"100%\\" border=\\"1\\" align=\\"center\\"><tr>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">$banuser</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">$bandate g.</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">$bannedby</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">$banreason</td></color>  
<color #FF0000><td align=\\"center\\" width=\\"20%\\">$unbandate g.</td></color>  
</tr></table></font>";  

$i++;  
}  
}  
?>

* Show the Races Stats from your server. (Improve by twister7)

<? 
require_once('config.php');
mysql_connect("$ip", "$user", "$pass");
mysql_select_db ("$mangoscharacters");
$race = array();
$class = array();
for($n=1; $n <= 11; $n++){
   $sql = "SELECT COUNT(race) FROM `characters` WHERE `race`=".$n;
   $query = mysql_query($sql);
   $race[$n] = mysql_result($query, 0);
   mysql_free_result($query);
}
for($n=1; $n <= 11; $n++){
   $sql = "SELECT COUNT(class) FROM `characters` WHERE `class`=".$n;
   $query = mysql_query($sql);
   $class[$n] = mysql_result($query, 0);
   mysql_free_result($query);
}

echo "Humans: ".$race[1]."
";
echo "Dwarves: ".$race[3]."
";
echo "Night Elf: ".$race[4]."
";
echo "Gnome: ".$race[7]."
";
echo "Draenei: ".$race[11]."
";
echo "Orc: ".$race[2]."
";
echo "Undead: ".$race[5]."
";
echo "Tauren: ".$race[6]."
";
echo "Troll: ".$race[8]."
";
echo "Blood Elf: ".$race[10]."

";
echo "Druid: ".$class[11]."
";
echo "Hunter: ".$class[3]."
";
echo "Mage: ".$class[8]."
";
echo "Paladin: ".$class[2]."
";
echo "Priest: ".$class[5]."
";
echo "Rogue: ".$class[4]."
";
echo "Shaman: ".$class[7]."
";
echo "Warlock: ".$class[9]."
";
echo "Warrior: ".$class[1]."
";
echo "Death Knight: ".$class[6]."
";
?>

* Mangos Registration (Code by Peec - Improved by Darkruler)

<?php
$realmd = array(
'db_host'=> 'localhost',        // Host IP
'db_username' => 'root',        // Database login-name
'db_password' => 'mangos',      // Database login-pass
'db_name_realm'=> 'realmd',     // Database name of realm
);

function check_for_symbols($string)
{
   $len=strlen($string);
   $allowed_chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
   for($i=0;$i<$len;$i++)if(!strstr($allowed_chars,$string[$i]))
       return TRUE;
   return FALSE;
}
function sha_password($user,$pass)
{
   $user = strtoupper($user);
   $pass = strtoupper($pass);
   return SHA1($user.':'.$pass);
}
if ($realmd[db_host] != "" && $realmd[db_username] != "" && $realmd[db_password] != "" && $realmd[db_name_realm] != "")
{
   $new_connect = mysql_connect($realmd[db_host],$realmd[db_username],$realmd[db_password]);
   if ($new_connect)
       $selectdb = mysql_select_db($realmd[db_name_realm],$new_connect);
   else
   {
       echo "Could NOT connect to db: Configs (Name/Pass/Port/IP) are incorrect";
       die;
   }

   if ($new_connect && !$selectdb)
   {
       echo "Could NOT connect to db: Database does not exist!";
       die; 
   }

   if ($_POST['registration'])
   {
       $username = $_POST['username'];
       $password = sha_password($username,$_POST['password']);
       $expansionnumber = $_POST['expansion'];

       $check_username = mysql_query("SELECT username FROM `account` WHERE username='$username'");
       if ($username == "")
       {
           echo "Field username is empty!";
       }
       else if ($password == "")
       {
           echo "Field password is empty!";
       }
       else if (check_for_symbols($_POST[password]) == TRUE)
       {
           echo "Error with creating account: password has invalid symbols in it.";
       }
       else if (check_for_symbols($username) == TRUE)
       {
           echo "Error with creating account: username has invalid symbols in it.";
       }
       else if (mysql_num_rows($check_username) != 0)
       {
           echo "Error with creating account: name is already in use.";
       }
       else
       {
           $username = mysql_real_escape_string($username);
           mysql_query("INSERT INTO account (username,sha_pass_hash,expansion) VALUES
('$username','$password','$expansionnumber')");
           if (mysql_error)
               echo mysql_errno($new_connect) . ": " . mysql_error($new_connect). "\\n";
           else
           {
               echo "Account created.";
               mysql_close($new_connect);
           }
       }
   }
   else
   {
       ?>
       <html>
       <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
       Username <input type="text" name="username">
       Password <input type="password" name="password">
       Expansion Selection<select name="expansion">
           <option value="1">Vanilla</option>
           <option value="2">TBC</option>
           <option value="3">WotLK</option>
       </select>
       <input type="submit" name="registration">
       </form>
       </html>
       <?php
   }
}
else
   echo "Config file either not present or connection variables are empty";
?>

* Mangos Recovey Password (Code by Peec)

<?php
/*
Very important! You need to run SQL update!
ALTER TABLE `account` ADD `reset_password` VARCHAR( 50 ) NOT NULL;
*/
/*Config*/
$realmd = array(
'db_host'=> 'localhost', //ip of db realm
'db_username' => 'mangos',//realm user
'db_password' => '',//realm password
'db_name'=> 'realmd',//realm db name
);
$config = array(
'path_to_thisfile' => 'http://mysite.com/lol/ownage/wow/pass_recovery.php', // Example: [url]http://mysite.com/lol/ownage/wow/[/url]
'email_from' => '[email protected]', // Who should the email be sent from ?
'email_subject' => 'Password recovery for our site!', // Subject of the mail ??
);



function sha_password($user,$pass){
$user = strtoupper($user);
$pass = strtoupper($pass);

return SHA1($user.':'.$pass);
}
function random_string($counts){
$str = "abcdefghijklmnopqrstuvwxyz";//Count 0-25
for($i=0;$i<$counts;$i++){
if ($o == 1){
$output .= rand(0,9);
$o = 0;
}else{
$o++;
$output .= $str[rand(0,25)];
}

}
return $output;
}


$realmd_bc_new_connect = mysql_connect($realmd[db_host],$realmd[db_username],$realmd[db_password]);
$selectdb = mysql_select_db($realmd[db_name],$realmd_bc_new_connect);

if ($_GET[h] && $_GET[h] != '' && $_GET[h] != '0'){
$output_random_pass = random_string(10);
$query = mysql_query("SELECT username FROM `account` WHERE reset_password='$_GET[h]'");
$res = mysql_fetch_array($query);
if (mysql_num_rows($query) == 1){
echo "Hi $res[username], Your password is: $output_random_pass. Please change your password fast as possible.";
$pass_hash = sha_password($res[username],$output_random_pass);
mysql_query("UPDATE `account` SET sha_pass_hash='$pass_hash' WHERE reset_password='$_GET[h]'");
mysql_query("UPDATE `account` SET reset_password='' WHERE username='$res[username]'");
}else{
echo "Error.";
}

}else{
?>

<?php
//this is where user fill in and send by email
if ($_POST[password_takeback]){
$check_security = mysql_query("SELECT id FROM `account` WHERE username='$_POST[username]' AND email='$_POST[email]'");
if (isset($_POST['username']) && isset($_POST['email']) && mysql_num_rows($check_security) == 1){
$rand = random_string(40);
mysql_query("UPDATE `account` SET reset_password='$rand' WHERE username='$_POST[username]'");
$to = $_POST["email"];
$from = "From: $config[email_from]";
$subject = $config[email_subject];
$message= "Hi $_POST[username], you have submitted a password recovery on our site. IF YOU DIDNT SUBMIT A PASSWORD REQUEST JUST DELETE THIS MAIL!. Please follow this link to complete the operation: $config[path_to_thisfile]?h=$rand";
mail($to, $subject, $message, $from); // This work if you have configured your php.ini file to send email, !on linux its default.
echo "An Email has been sent to you, please follow the email to complete the process.";
}else{
echo "Incorrect details, Please be sure that you submitted right Email and Username to your account";
}
}else{
?>
<form action="<?php echo $_SERVER[php_SELF]; ?>" method="POST">
Your Email: <input type="text" name="email">

Your Username: <input type="text" name="username">

<input type="submit" name="password_takeback">
</form>
<?php
}
}// End GET
?>

Link to comment
Share on other sites

* Top Arena.

Original Code by Kpacavcheg

<html>
<head>
<title>Top Arena</title>
<style>
body
{
   background: #000000;
   color: #8f7e4b;
   font: 10pt tahoma, verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
   margin: 0px 0px 0px 0px;
   padding: 0px;
   text-align: center;
}
a:link
{
   color: #d4c8a2;
   text-decoration: none;
}
a:visited
{
   color: #d4c8a2;
   text-decoration: none;
}
a:hover, a:active
{
   color: #FFFFFF;
   text-decoration: none;
}
</style>
</head>
<body>

<?
include ("config.php");

$j=1;
       $teamType = array(
               '2' => '2x2',
               '3' => '3x3',
               '5' => '5x5'
               );

$connect = mysql_connect($host,$user,$pass) OR DIE("'Can't connect with $host"); 
mysql_select_db($mangoscharacters,$connect) or die(mysql_error()); 
mysql_query("SET NAMES '$cod'"); 

if(!isset($_GET['guid'])){

$sql = mysql_query("SELECT * FROM `arena_team` ORDER by `name`");

echo "<center><table border=1 width=70%>
<tr>
<td>Team Name</td>
<td align=center>Command Type</td>
<td align=center><center>Team Leader</center></td>
<td>Faction</td>
<td align=center>Rating</td>

</tr>";
while ($row = mysql_fetch_array($sql)){
$query_num = mysql_query("SELECT COUNT(*) FROM `arena_team_member` WHERE `arenateamid`='$row[arenateamid]'");
$gleader = "SELECT name,race FROM `characters` WHERE `guid`='$row[captainguid]'";
$myrow = mysql_fetch_array(mysql_query($gleader));
$top = mysql_query("SELECT * FROM `arena_team_stats` WHERE `arenateamid`='$row[arenateamid]'");
$toprow = mysql_fetch_array($top);

if($myrow['race']=="1" or $myrow['race']=="3" or $myrow['race']=="4" or $myrow['race']=="7" or  $myrow['race']=="11"){

   $faction = "alliance";
   }else{
   $faction = "horde";}



echo "
<tr>
<td >
<p style='padding-left: 5px'>[url='?guid=".$row[arenateamid]."']".$row['name']."[/url]</p>
</td>
<td  align=center><center>".$teamType[$row['type']]."</center></td>

<td>[url=".$wowd."]".$myrow['name']."[/url]</td>
<td align=center><center><img src=images/".$faction.".gif title=".$faction."></center></td>
<td align=right><p style='padding-right: 8px'>".$toprow['rating']."</p></td></tr>";

}
echo "</table></center>

";
}

if (@$_GET['guid'] ) { 

$name = "SELECT * FROM `arena_team` WHERE `arenateamid`='$_GET[guid]'";
$nrow = mysql_fetch_array(mysql_query($name));
$top = "SELECT * FROM `arena_team_stats` WHERE `arenateamid`='$_GET[guid]'";
$trow = mysql_fetch_array(mysql_query($top));
$member = "SELECT * FROM `arena_team_member` WHERE `arenateamid`='$_GET[guid]'";
$mrow = mysql_fetch_array(mysql_query($member));

$sql = mysql_query("SELECT * FROM `characters`, `arena_team_member` WHERE `characters`.`guid`=`arena_team_member`.`guid` and `arenateamid` = '".$_GET["guid"]."' ");
$row = mysql_fetch_array($sql);
$data = explode(' ',$row['data']);
$lvl = $data[$ver];    
$gender = dechex($data[36]);
$gender = str_pad($gender,8, 0, STR_PAD_LEFT);
$gender = $gender{3};
$guid = $row['guid'];
$race = $row['race'];
$class = $row['class'];
$online = $row['online'];
$j=1;

echo "<center>
<table border=0 width=60%>
<tr>
<td>
<table border=1 width=100%>
<tr><td>Team Name</td><td  >".$nrow['name']."</td></tr>
<tr><td>Rating</td><td  >".$trow['rating']."</td></tr>
<tr><td>Command Type</td><td  >".$teamType[$nrow['type']]."</td></tr>
<tr><td colspan=2 >Statistics of the Week</td></tr>
<tr><td>Played: ".$trow['games']."</td><td  >Won: ".$trow['wins']."</td></tr>
<tr><td colspan=2 >Stats</td></tr>
<tr><td>Played: ".$trow['played']."</td><td  >Won: ".$trow['wins2']."</td></tr>


</table>
";

echo "<table border=1 width=100%>
<tr>
<td align=center>#</td>
<td align=center>Player Name</td>
<td align=center>lvl</td>
<td align=center>Race</td>
<td align=center>Class</td>
<td align=center>Game of the Week</td>
<td align=center>Won week</td>
<td align=center>Games for the season</td>
<td align=center>Won season</td>
<td align=center>Personal rating</td>
<td align=center>Online</td>
</tr>
";

echo "<tr>
<td valign=center width=3%>$j</td>
<td align=center valign=center width=20%>[url='/wow/wowd/?player=".$guid."']".$row[name]."[/url]</td>
<td width=20 align=center valign=center>$lvl</td>
<td align=center valign=center width=7%><img src=images/race/".$race."-".$gender.".gif></td>
<td align=center valign=center width=7%><img src=images/class/$class.gif></td>
<td align=center width=20%>".$mrow['played_week']."</td>
<td valign=center width=20%>".$mrow['wons_week']."</td>
<td valign=center width=10%>".$mrow['played_season']."</td>
<td valign=center width=10%>".$mrow['wons_season']."</td>
<td valign=center width=10%>".$mrow['personal_rating']."</td>
<td valign=center width=10%><center>[img=images/status/".$online.".gif]</center></td>
</tr>
";


echo "</table></td></tr></table></center>


";

echo "<table border=1><tr><td>[url='index.php']Index[/url]</td></tr></table>";
} 

?>

</body>
</html>

* Top Honor.

<?php

include ("config.php");

$characters = mysql_connect("$host", "$user", "$pass") or die('Connection Failed');

mysql_selectdb ("$mangoscharacters") or die('Cannot connect to Characters Database);

$result = mysql_query("SELECT * FROM `characters` ORDER BY `totalKills` DESC LIMIT 0 , 100 ");  

?>
<font color=#000000>
   <table align=center cellpadding="0" cellspacing="0"  border="1" width=100%>
   <thead>
       <td width="4%"><center>Nº</center></td>
       <td width="16%"><center>Character Name</center></td>
       <td width="4%"><center>level</center></td>
       <td width="5%"><center>Honor</center></td>
       <td width="4%"><center>Kills</center></td>
   </thead>
   <tbody>

<?php

while($rows = mysql_fetch_object($result)) 
{ 
$i++; 
$name = $rows->name; 
$level = $rows->level;  
$Total_Kills = $rows->totalKills;
$Total_Honor = $rows->totalHonorPoints;

   echo " 
<tr>
<td><center>",$i,"</center></td>
<td>[i]",$name,"[/i]</td>
<td><center>",$level,"</center></td>
<td><center>",$Total_Honor,"</center></td>
<td><center>",$Total_Kills,"</center></td>
</tr>"; 
} 

   mysql_close($characters);
?>

* Show Online PPL (Nick, Race, Class, Level, Gender).

<center><table border="0" width="50%">
 <tr>
  <td>[b]Nick:    [/b]</td>
  <td>[b]Race:    [/b]</td>
  <td>[b]Class:    [/b]</td>
  <td>[b]Level:    [/b]</td>
  <td>[b]Gender:    [/b]</td>
 </tr>
<?

require_once ( 'config.php');

mysql_connect ("$host","$user","$pass");
mysql_select_db ("$mangoscharacters");

$result = mysql_query ("SELECT name, race, class, level, gender FROM characters WHERE online = 1");
$num_online = mysql_num_rows($result);

$class = array(1=>"Warrior",2=>"Paladin",3=>"Hunter",4=>"Rogue",5=>"Priest",6=>"Death Knight",7=>"Shaman",8=>"Mage",9=>"Brujo",11=>"Druid");
$race = array(1=>"Human",2=>"Orc",3=>"Dwarf",4=>"Night Elf",5=>"Undead",6=>"Tauren",7=>"Gnome",8=>"Troll",10=>"Blood Elf",11=>"Draenei");
$gender = array(0=>"Male",1=>"Female");

if($num_online < 1) {
 echo "<tr><td colspan='4' align='center'>No Players Online!</td></tr>";
}

for($i=0; $i<$num_online; $i++) {
 $row = mysql_fetch_array($result);
 $t_name = $row['name'];
 $t_race = $row['race'];
 $t_class = $row['class'];
 $t_lvl = $row['level'];
 $t_gender = $row['gender'];
 echo "<tr>
   <td>[b]$t_name[/b]</td>";
 echo "<td>[b]$race[$t_race][/b]</td>";
 echo "<td>[b]$class[$t_class][/b]</td>";
 echo "<td>[b]$t_lvl[/b]</td>
 echo "<td>[b]$gender[$t_gender][/b]</td>
   </tr>";
}

* Show Online GM's (Nick, Race, Class, Level, Gender).

<center><table border="0" width="50%">
 <tr>
  <td>[b]Nick:     [/b]</td>
  <td>[b]Race:     [/b]</td>
  <td>[b]Class:    [/b]</td>
  <td>[b]Level:    [/b]</td>
  <td>[b]Gender:   [/b]</td>
 </tr>
<?

require_once ( 'config.php');

mysql_connect ("$host","$user","$pass");
mysql_select_db ("$mangoscharacters");

$result = mysql_query ("SELECT name, race, class, level, gender FROM characters WHERE account IN (SELECT id FROM $mangosrealm.account WHERE gmlevel > 0)");
$num_online = mysql_num_rows($result);

$class = array(1=>"Warrior",2=>"Paladin",3=>"Hunter",4=>"Rogue",5=>"Priest",6=>"Death Knight",7=>"Shaman",8=>"Mage",9=>"Brujo",11=>"Druid");
$race = array(1=>"Human",2=>"Orc",3=>"Dwarf",4=>"Night Elf",5=>"Undead",6=>"Tauren",7=>"Gnome",8=>"Troll",10=>"Blood Elf",11=>"Draenei");
$gender = array(0=>"Male",1=>"Female");

if($num_online < 1) {
 echo "<tr><td colspan='4' align='center'>No GM's Online!</td></tr>";
}

for($i=0; $i<$num_online; $i++) {
 $row = mysql_fetch_array($result);
 $t_name = $row['name'];
 $t_race = $row['race'];
 $t_class = $row['class'];
 $t_lvl = $row['level'];
 $t_gender = $row['gender'];
 echo "<tr>
   <td>[b]$t_name[/b]</td>";
 echo "<td>[b]$race[$t_race][/b]</td>";
 echo "<td>[b]$class[$t_class][/b]</td>";
 echo "<td>[b]$t_lvl[/b]</td>
 echo "<td>[b]$gender[$t_gender][/b]</td>
   </tr>";
}

Link to comment
Share on other sites

i dont have an "uptime" table, is it a custom patch?

btw, if anyone wants a honor rank, this sql creates it

SELECT c.name, c.level, c.race, c.class,
(CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(c.data, ' ', 23), ' ', -1) AS UNSIGNED) >> 16) & 1 AS gender,
CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(c.data, ' ', 1203), ' ', -1) AS UNSIGNED) AS kills,
CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(c.data, ' ', 1252), ' ', -1) AS UNSIGNED) AS honor,
g.name AS guild
FROM characters AS c LEFT JOIN guild AS g ON g.guildid = CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(c.data, ' ', 152), ' ', -1) AS UNSIGNED)
ORDER BY kills DESC
LIMIT 50;

arena rank could be done in a single query too, might work on that later.

Link to comment
Share on other sites

I advise everyone to take care about those kind of scripts.

In fact those scripts have a tight link with the DB's and the connection to servers, I think that exposing the scripts to the public is a threat to your servers.

Most of websites wont notice the impact but on some servers that host a huge amount of players the numbers of the requests made by the visitors can lead to a DoS.

Moreover that can help some malicious peeps to take your server down flooding the stats pages.

So the best solution is to use these scripts in some crontab task to populate the static stats web pages on your server. No more the impact on your servers on the web requests.

Depending on the stats you can run (via crontab or any other schedulers) the task every 1min to 5mins (eg: 1min for the server status and 5mins for the population, etc.).

Link to comment
Share on other sites

  • 2 weeks later...
I advise everyone to take care about those kind of scripts.

In fact those scripts have a tight link with the DB's and the connection to servers, I think that exposing the scripts to the public is a threat to your servers.

Most of websites wont notice the impact but on some servers that host a huge amount of players the numbers of the requests made by the visitors can lead to a DoS.

Moreover that can help some malicious peeps to take your server down flooding the stats pages.

So the best solution is to use these scripts in some crontab task to populate the static stats web pages on your server. No more the impact on your servers on the web requests.

Depending on the stats you can run (via crontab or any other schedulers) the task every 1min to 5mins (eg: 1min for the server status and 5mins for the population, etc.).

I'm not agree.. with the correct configuration, you can do everything, i have more than 2k and i no have any problem.

PD: In this days i update the post, with more interesting scripts. Chears.

Link to comment
Share on other sites

I'm not agree.. with the correct configuration, you can do everything, i have more than 2k and i no have any problem.

PD: In this days i update the post, with more interesting scripts. Chears.

Of course with the right config you can mitigate the impact.

Perhaps you could give us some hints on the proper config so everyone can tune their servers to avoid some weird issues ?

Link to comment
Share on other sites

The race count stuff can all be done in 1 query afaik

Yea I think so too, and that one is really bothering me because it's not pretty so I wrote this...

<?
require_once('config.php');

mysql_connect("$ip", "$user", "$pass");
mysql_select_db ("$mangoscharacters");
$race = array();
$class = array();
$query = "select race, class from characters";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
   $race[$row['race']]++;
   $class[$row['class']]++;
}

echo "Humans: $race[1]
";
echo "Dwarves: $race[3]
";
echo "Night Elf: $race[4]
";
echo "Gnome: $race[7]
";
echo "Draenei: $race[11]
";
echo "Orc: $race[2]
";
echo "Undead: $race[5]
";
echo "Tauren: $race[6]
";
echo "Troll: $race[8]
";
echo "Blood Elf: $race[10]

";
echo "Druid: $class[11]
";
echo "Hunter: $class[3]
";
echo "Mage: $class[8]
";
echo "Paladin: $class[2]
";
echo "Priest: $class[5]
";
echo "Rogue: $class[4]
";
echo "Shaman: $class[7]
";
echo "Warlock: $class[9]
";
echo "Warrior: $class[1]
";
echo "Death Knight: $class[6]
";
?>

I haven't tested it yet but it should be much more efficient.. please correct me if I'm wrong though

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use