Jump to content
MakeWebGames

Registration


Recommended Posts

Hello, I have a registration script for a V1 game. Its abit messed. The userstat doesnt get inserted. And theres is alot of bugs...and security probelms..Any one can help me out?

 

<?php

session_start();
require "mysql.php";
require "global_func.php";

print <<<EOF

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="JavaScript">
<!--
function getCookieVal (offset) {
 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1)
 endstr = document.cookie.length;
 return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
 var arg = name + "=";
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while (i < clen) {
 var j = i + alen;
 if (document.cookie.substring(i, j) == arg)
 return getCookieVal (j);
 i = document.cookie.indexOf(" ", i) + 1;
 if (i == 0) break;
 }
 return null;
}
function SetCookie (name,value,expires,path,domain,secure) {
 document.cookie = name + "=" + escape (value) +
 ((expires) ? "; expires=" + expires.toGMTString() : "") +
 ((path) ? "; path=" + path : "") +
 ((domain) ? "; domain=" + domain : "") +
 ((secure) ? "; secure" : "");
}
function DeleteCookie (name,path,domain) {
 if (GetCookie(name)) {
 document.cookie = name + "=" +
 ((path) ? "; path=" + path : "") +
 ((domain) ? "; domain=" + domain : "") +
 "; expires=Thu, 01-Jan-70 00:00:01 GMT";
 }
}
// -->
</script>
<script language="JavaScript">
var usr;
var pw;
var sv;
function getme()
{
usr = document.login.username;
pw = document.login.password;
sv = document.login.save;
  if (GetCookie('player') != null)
  {
       usr.value = GetCookie('username')
       pw.value = GetCookie('password')
       if (GetCookie('save') == 'true')
       {
       sv[0].checked = true;
       }
  }
}
function saveme()
{
  if (usr.value.length != 0 && pw.value.length != 0)
  {
       if (sv[0].checked)
       {
               expdate = new Date();
               expdate.setTime(expdate.getTime()+(365 * 24 * 60 * 60 * 1000));
               SetCookie('username', usr.value, expdate);
               SetCookie('password', pw.value, expdate);
               SetCookie('save', 'true', expdate);
       }
               if (sv[1].checked)
               {
               DeleteCookie('username');
               DeleteCookie('password');
               DeleteCookie('save');
               }
       }
               else
       {
               alert('You must enter a username/password.');
               return false;
       }
}
</script>
</head>
<head>
<!--
       SEO Requirements
-->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Massive online multiplayer text based RPG game. Gangster warfare at its best.">
<meta name="keywords" content="rpg games, fun games, online rpg, multiplayer games, play free game, free rpg, rpg game, online mmorpg, mmorpg games, fun game">
<meta name="robots" content="index,follow" />
<meta name="author" content="Dragon Blade">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
       @import url("css/layout.css");
-->
</style>
<title>LostNation</title>
</head>
<div id="wrapper" class="bg7">
       <div class="bg8">
            <div id="wrapperA"></div>
               <div class="content">
                       <div id="header">
                               <div id="logo">
                               <h1>LostNation</h1>
                               <h2> </h2>
                               </div>
                               <div id="splash">
                               <h3> </h3>
                               </div>
                       </div>
                       <div id="mainmenu" class="bg3" style="margin-left: 15px;">
                               <ul>
                                       <li><a href="login.php" id="mainmenu1" accesskey="1" title="" class="link1">Home</a></li>
                                       <li><a href="news.php" id="mainmenu2" accesskey="2" title="" class="link1 vline">News</a></li>
                                       <li><a href="reviews.php" id="mainmenu3" accesskey="3" title="" class="link1 vline">Reviews</a></li>
                                       <li><a href="articles.php" id="mainmenu4" accesskey="4" title="" class="link1 vline">Articles</a></li>
                                       <li><a href="details.php" id="mainmenu5" accesskey="5" title="" class="link1 vline">Staff</a></li>
                                       <li><a href="contact.php" id="mainmenu6" accesskey="6" title="" class="link1 vline">Contact</a></li>
                               </ul>
                               <p class="text1" style="width: 200px; float: right; margin: 0px 15px 0 0;"><script language="JavaScript" type="text/javascript" src="date.js"></script></p>
                       </div>
                       <!-- Begin Main Content -->
                       <div class="two-col">
                               <div class="colA">
                                       <div id="box1">
                                       <h2 class="text2 title1">LostNation Links</h2>
                                       <ul class="ul1">
                                       <li><span class="bbit-li-info"><a href="login.php">Login</a></span></li>
                                       <li><span class="bbit-li-info"><a href="register.php">Register</a></span></li>
                                       <li><span class="bbit-li-info"><a href="resend.php">Lost Password</a></span></li>
                                       <li><span class="bbit-li-info"><a href="tos.php">Terms of Service</a></span></li>
                                       <li><span class="bbit-li-info"><a href="policy.php">Privacy Policy</a></span></li>
                                       <li><span class="bbit-li-info"><a href="preview.php">Preview</a></span></li>
                               </ul>
                               <div class="boxfoot">
						<!-- # -->
			</div>
                               </div>
                               </div>
                               <div class="colB">
                               <div id="box5">
                               <div class="notice-donate">LostNation Registration</div>
EOF;
$ip = ($_SERVER['REMOTE_ADDR']);
if (file_exists('ipbans/' . $ip))
{
   die(
           "<b><span style='color: red; font-size: 120%'>
           Your IP has been banned, there is no way around this.
           </span></b>
           </body></html>");
}
if($_POST['username'])
{

 if(!$_SESSION['captcha'] or $_SESSION['captcha'] != $_POST['captcha'])
 {
 unset($_SESSION['captcha']);
print "Captcha Test Failed<br />
><a href='register.php'>Back</a>";
exit();
}

 unset($_SESSION['captcha']);
}
if ($_POST['username'])
{
   $sm = 100;
   if ($_POST['promo'] == "Your Promo Code Here")
   {
       $sm += 100;
   }

$class = mysql_query("SELECT className, money, crystals, strength, guard, agility, iq, labor FROM player_class WHERE classID = {$_POST['classID']}");
if(mysql_num_rows($class))
{
   $c = mysql_fetch_array($class);
   $money = $c["money"]+$sm;
   $crystals = $c["crystals"];
   $strength = $c["strength"];
   $guard = $c["guard"];
   $agility = $c["agility"];
   $iq = $c["iq"];
   $labor = $c["labor"];
}
else
{
   $crystals = 10;
   $strength = 10;
   $guard = 10;
   $agility = 10;
   $iq = 10;
   $labor = 10;
}

$username=$_POST['username'];
$username=str_replace(array("<", ">"), array("<", ">"), $username);
$q=mysql_query("SELECT * FROM users WHERE username='{$username}' OR login_name='{$username}'");
$q2=mysql_query("SELECT * FROM users WHERE email='{$_POST['email']}'");

if(strlen($_POST['username']) < 6)
{
print "Sorry, the username is too short.<br />
><a href='register.php'>Back</a>";
}
else if(strlen($_POST['username']) > 15)
{
print "Sorry, the username is too large.<br />
><a href='register.php'>Back</a>";
}
else if(mysql_num_rows($q))
{
print "Username already in use. Choose another.<br />
><a href='register.php'>Back</a>";
}
else if (!preg_match("/^[ a-zA-Z0-9]*$/", trim($_POST['username'])))
{
print "Your username contained characters that aren't allowed. Only A-Z, 0-9 and spaces accepted.<br />
><a href='register.php'>Back</a>";
}
else if(mysql_num_rows($q2))
{
print "E-Mail already in use. Choose another.<br />
><a href='register.php'>Back</a>";
}
else if(strlen($_POST['password']) < 6)
{
print "Your password is too small.<br />
><a href='register.php'>Back</a>";
}
else if($_POST['password'] != $_POST['cpassword'])
{
print "The passwords did not match, go back and try again.<br />
><a href='register.php'>Back</a>";
}
else
{
$_POST['ref'] = abs((int) $_POST['ref']);
$IP = $_SERVER['REMOTE_ADDR'];
$q=mysql_query("SELECT * FROM users WHERE lastip='$IP' AND userid={$_POST['ref']}");
if(mysql_num_rows($q))
{
die("No creating referral multies. Bad dog.<br />
><a href='register.php'>Back</a>");
}
if($_POST['ref'] > 0)
{
$ref=mysql_query("SELECT * FROM users WHERE userid={$_POST['ref']}");
if(!mysql_num_rows($ref))
{
die("Your adding a non existent refer<br />
><a href='register.php'>Back</a>");
}
}








    $r=mysql_fetch_array($q);
}
mysql_query("INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill,
brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup,player_class) VALUES( '{$username}', '{$username}',
md5('{$_POST['password']}'), 1, $money, $crystals, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}',
-1, '$IP', '$IP','{$_POST['classID']}')");


   	$i = mysql_insert_id($c);
mysql_query(
"INSERT INTO userstats VALUES($i, $strength, $agility, $guard, $labor, $iq)",
$c);


       if ($_POST['ref'])
       {
           mysql_query(
                   "UPDATE `users`
                   SET `crystals` = `crystals` + 2
                   WHERE `userid` = {$_POST['ref']}");
           event_add($_POST['ref'],
                   "For refering $username to the game, you have earnt 2 valuable crystals!",
                   $c);
           $e_rip = mysql_real_escape_string($rem_IP, $c);
           $e_oip = mysql_real_escape_string($ip, $c);
           mysql_query(
                   "INSERT INTO `referals`
                   VALUES(NULL, {$_POST['ref']}, $i, " . time()
                           . ", '{$e_rip}', '$e_oip')", $c);
       }
       print 
               "You have signed up, enjoy the game.<br />
> <a href='login.php'>Login</a>";
   }

else
{
   $gref = abs((int) $_GET['REF']);
   $fref = $gref ? $gref : '';



       $chars =
               "1234567890";
       $len = strlen($chars);
       $_SESSION['captcha'] = "";
       for ($i = 0; $i < 4; $i++)
           $_SESSION['captcha'] .= $chars[rand(0, $len - 1)];




   echo"






<br /><br /><center><div style='background-color:#222222; text-align: left; color:white; padding-left: 10px; width:75%; border:1px solid #EEEEEE'>
	<small><b><h3><u><b>Register:</b></u></h3>
		Its never been easier to sign up and register an account. <br />
		Registration is free and within just a few minutes you can being joining the ultimate RPG gaming experience.<br /><br />Just complete the fields below.<br /><br />
    			Fields marked <font size = 3 color = red>*</font> are to be completed: <br /><br />
</div>
</center><br /><br />







<form action='register.php' method='post'>
<table width='75%' class='table' cellspacing='1'>
<tr>   


<td><font color = red>*</font> Username:</td><td><center><input type='text' name='username' /></center></td>
</tr>
<tr>
<td><font color = red>*</font> Password:</td><td><center><input type='password' name='password' /></center></td>
</tr>
<tr>
<td><font color = red>*</font> Confirm Password:</td><td><center><input type='password' name='cpassword' /></center></td>
</tr>
<tr>
<td><font color = red>*</font> Email:</td><td><center><input type='text' name='email' /></center></td>
</tr>
<tr>
<td><font color = red>*</font> Confirm Email:</td><td><center><input type='text' name='cemail' /></center></td>
</tr>
<tr>
<td>Promo Code:</td><td><center><input type='text' name='promo' /></center></td>
</tr>
<tr>
<td>Player Class:</td><td><center>".class_dropdown(NULL, "classID")."</td></center>
</tr>
<tr>
<td><img src='captcha.php?bgcolor=C3C3C3' width='200' height='50'  /></td><td><input type='text' name='captcha' /></td>
</tr>
<tr>
<td colspan= '2'><center><input type='submit' value='Submit' /></center></td>

</form></table>

<br /><br /><center><div style='background-color:#222222; text-align: left; color:white; padding-left: 10px; width:75%; border:1px solid #EEEEEE'>
	<small><b><h3><u><b>Disclaimer:</b></u></h3>When registering an account you accept all Terms of Service & Privacy Policy. In addition you are required to comply with all ingame rules. If you disagree with any of the Terms of Service / Privacy Policy or Game Rules at anytime you should terminate all use of your account and contact [email protected] and request that your account be deleted. <br /><br />
</div>
</center><br /><br />







<hr width = 75%><center>> <a href='login.php'>Login</a><hr width = 75%></center>";




}

print '
     			        </div>
                       	</div>
               		</div>
               		<div id="login-wrapperB" $ie6_fix></div>
               		<br style="clear: both;" />
               		</div>
     			</div>
       	</div>
<div id="footer"><p class="style2">Game Copyright ©{$year} Dragon Blade. All rights reserved worldwide.</center></i></p></div>
</div>
</body>
</html>
';
?>
Edited by Dragon Blade
Link to comment
Share on other sites

Yeah this is bad. Please separate the business logic (The PHP code) and the presentation logic. In this case to improve you should move All of the PHP code to the top of the file (expect the outputting). To help you make improvements I first would need to see the files mysql.php and global_func.php as well. Cheers.

The code is already badly messed up, so a good start is to auto-format using Netbeans. It still looks like ****, but better **** than before.

http://pastebin.com/v3YL57Zc

Edited by Aventro
Link to comment
Share on other sites

Is this gangster warfare or lost nation? Do you have permission to convert it?

Where did gangster warfare come from? And what is it?

 

Yeah this is bad. Please separate the business logic (The PHP code) and the presentation logic. In this case to improve you should move All of the PHP code to the top of the file (expect the outputting). To help you make improvements I first would need to see the files mysql.php and global_func.php as well. Cheers.

The code is already badly messed up, so a good start is to auto-format using Netbeans. It still looks like ****, but better **** than before.

This is the global_func.php -

 

<?php


function class_dropdown($connection, $ddname = "classID", $selected = -1)
{
  global $c;
   $ret = "<select name='$ddname' type='dropdown'>";
   $q =
           mysql_query(
                   "SELECT `classID`, `classNAME`
                    FROM `player_class`
                    ORDER BY `classID` ASC");
   if ($selected == -1)
   {
       $first = 0;
   }
   else
   {
       $first = 1;
   }
   while ($r = mysql_fetch_array($q))
   {
       $ret .= "\n<option value='{$r['classID']}'";
       if ($selected == $r['classID'] || $first == 0)
       {
           $ret .= " selected='selected'";
           $first = 1;
       }
       $ret .= ">{$r['classNAME']}</option>";
   }
   mysql_free_result($q);
   $ret .= "\n</select>";
   return $ret;
}



function getPlayerClass($uId = NULL)
{
   global $userid;
   if(!$uId)
       $uId = $userid;
   $u = mysql_fetch_array(mysql_query("SELECT `player_class` FROM `users` WHERE userid = {$uId}"));
   $class = mysql_query("SELECT `classNAME` FROM `player_class` WHERE `classID` = {$u['player_class']}");
   if (mysql_num_rows($class))
   {
       $c = mysql_fetch_array($class);
       return $c['classNAME'];
   }
   else
   return "Not Defined";
}    

function money_formatter($muny, $symb = '$')
{
   $moneys = "";
   $muny = (string) $muny;
   if (strlen($muny) <= 3)
   {
       return $symb . $muny;
   }
   $dun = 0;
   for ($i = strlen($muny); $i > 0; $i -= 1)
   {
       if ($dun % 3 == 0 && $dun > 0)
       {
           $moneys = "," . $moneys;
       }
       $dun += 1;
       $moneys = $muny[$i - 1] . $moneys;
   }
   return $symb . $moneys;
}



function location_dropdown($connection, $ddname = "location", $selected = -1)
{
   $ret = "<select name='$ddname' type='dropdown'>";
   $q =
           mysql_query("SELECT * FROM cities ORDER BY cityname ASC",
                   $connection);
   if ($selected == -1)
   {
       $first = 0;
   }
   else
   {
       $first = 1;
   }
   while ($r = mysql_fetch_array($q))
   {
       $ret .= "\n<option value='{$r['cityid']}'";
       if ($selected == $r['cityid'] || $first == 0)
       {
           $ret .= " selected='selected'";
           $first = 1;
       }
       $ret .= ">{$r['cityname']}</option>";
   }
   $ret .= "\n</select>";
   return $ret;
}

function shop_dropdown($connection, $ddname = "shop", $selected = -1)
{
   $ret = "<select name='$ddname' type='dropdown'>";
   $q =
           mysql_query("SELECT * FROM shops ORDER BY shopNAME ASC",
                   $connection);
   if ($selected == -1)
   {
       $first = 0;
   }
   else
   {
       $first = 1;
   }
   while ($r = mysql_fetch_array($q))
   {
       $ret .= "\n<option value='{$r['shopID']}'";
       if ($selected == $r['shopID'] || $first == 0)
       {
           $ret .= " selected='selected'";
           $first = 1;
       }
       $ret .= ">{$r['shopNAME']}</option>";
   }
   $ret .= "\n</select>";
   return $ret;
}

function user_dropdown($connection, $ddname = "user", $selected = -1)
{
   global $db;
   $ret = "<select name='$ddname' type='dropdown'>";
   $q =
          mysql_query(
                   "SELECT `userid`, `username`
   				 FROM `users`
   				 ORDER BY `username` ASC");
   if ($selected == -1)
   {
       $first = 0;
   }
   else
   {
       $first = 1;
   }
   while ($r = mysql_fetch_array($q))
   {
       $ret .= "\n<option value='{$r['userid']}'";
       if ($selected == $r['userid'] || $first == 0)
       {
           $ret .= " selected='selected'";
           $first = 1;
       }
       $ret .= ">{$r['username']}</option>";
   }
  mysql_free_result($q);
   $ret .= "\n</select>";
   return $ret;
}


function fed_user_dropdown($connection, $ddname = "user", $selected = -1)
{
   $ret = "<select name='$ddname' type='dropdown'>";
   $q =
           mysql_query(
                   "SELECT * FROM users WHERE fedjail=1 ORDER BY username ASC",
                   $connection);
   if ($selected == -1)
   {
       $first = 0;
   }
   else
   {
       $first = 1;
   }
   while ($r = mysql_fetch_array($q))
   {
       $ret .= "\n<option value='{$r['userid']}'";
       if ($selected == $r['userid'] || $first == 0)
       {
           $ret .= " selected='selected'";
           $first = 1;
       }
       $ret .= ">{$r['username']}</option>";
   }
   $ret .= "\n</select>";
   return $ret;
}

function event_add($userid,$text,$connection=0)
{

$text=mysql_escape($text);
mysql_query("INSERT INTO events VALUES('',$userid,UNIX_TIMESTAMP(),0,'$text','0')");
mysql_query("UPDATE users SET new_events=new_events+1 WHERE userid={$userid}");
return 1;
}


function forumb_user_dropdown($connection, $ddname = "user", $selected = -1)
{
   global $db;
   $ret = "<select name='$ddname' type='dropdown'>";
   $q =
            mysql_query(
                   "SELECT `userid`, `username`
                    FROM `users`
                    WHERE `forumban` > 0
                    ORDER BY `username` ASC");
   if ($selected == -1)
   {
       $first = 0;
   }
   else
   {
       $first = 1;
   }
   while ($r = mysql_fetch_array($q))
   {
       $ret .= "\n<option value='{$r['userid']}'";
       if ($selected == $r['userid'] || $first == 0)
       {
           $ret .= " selected='selected'";
           $first = 1;
       }
       $ret .= ">{$r['username']}</option>";
   }
    mysql_free_result($q);
   $ret .= "\n</select>";
   return $ret;
}
function forum_dropdown($connection, $ddname = "forum", $selected = -1)
{
   global $db;
   $ret = "<select name='$ddname' type='dropdown'>";
   $q =
            mysql_query(
                   "SELECT `ff_id`, `ff_name`
   				 FROM `forum_forums`
   				 ORDER BY `ff_name` ASC");
   if ($selected == -1)
   {
       $first = 0;
   }
   else
   {
       $first = 1;
   }
   while ($r =  mysql_fetch_array($q))
   {
       $ret .= "\n<option value='{$r['ff_id']}'";
       if ($selected == $r['ff_id'] || $first == 0)
       {
           $ret .= " selected='selected'";
           $first = 1;
       }
       $ret .= ">{$r['ff_name']}</option>";
   }
    mysql_free_result($q);
   $ret .= "\n</select>";
   return $ret;
}



function forum2_dropdown($connection, $ddname = "forum", $selected = -1)
{
   global $db;
   $ret = "<select name='$ddname' type='dropdown'>";
   $q =
           mysql_query(
                   "SELECT `ff_id`, `ff_name`
                    FROM `forum_forums`
                    WHERE `ff_auth` != 'gang'
                    ORDER BY `ff_name` ASC");
   if ($selected == -1)
   {
       $first = 0;
   }
   else
   {
       $first = 1;
   }
   while ($r =  mysql_fetch_array($q))
   {
       $ret .= "\n<option value='{$r['ff_id']}'";
       if ($selected == $r['ff_id'] || $first == 0)
       {
           $ret .= " selected='selected'";
           $first = 1;
       }
       $ret .= ">{$r['ff_name']}</option>";
   }
   mysql_free_result($q);
   $ret .= "\n</select>";
   return $ret;
}



function mysql_escape($str)
{
   global $c;
   return mysql_real_escape_string($str, $c);
}

function check_level()
{
   global $ir, $c, $userid;
   $ir['exp_needed'] =
           (int) (($ir['level'] + 1) * ($ir['level'] + 1)
                   * ($ir['level'] + 1) * 2.2);
   if ($ir['exp'] >= $ir['exp_needed'])
   {
       $expu = $ir['exp'] - $ir['exp_needed'];
       $ir['level'] += 1;
       $ir['exp'] = $expu;
       $ir['energy'] += 2;
       $ir['brave'] += 2;
       $ir['maxenergy'] += 2;
       $ir['maxbrave'] += 2;
       $ir['hp'] += 50;
       $ir['maxhp'] += 50;
       $ir['exp_needed'] =
               (int) (($ir['level'] + 1) * ($ir['level'] + 1)
                       * ($ir['level'] + 1) * 2.2);
       mysql_query(
               "UPDATE users SET level=level+1,exp=$expu,energy=energy+2,brave=brave+2,maxenergy=maxenergy+2,maxbrave=maxbrave+2,
hp=hp+50,maxhp=maxhp+50 where userid=$userid", $c);
   }
}

function get_rank($stat, $mykey)
{
   global $ir, $userid, $c;
   $q =
           mysql_query(
                   "SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.$mykey > $stat AND us.userid != $userid AND u.user_level != 0",
                   $c);
   return mysql_result($q, 0, 0) + 1;
}

/**
* Given a password input given by the user and their actual details,
* determine whether the password entered was correct.
*
* Note that password-salt systems don't require the extra md5() on the $input.
* This is only here to ensure backwards compatibility - that is,
* a v2 game can be upgraded to use the password salt system without having
* previously used it, without resetting every user's password.
*
* @param string $input The input password given by the user.
* 						Should be without slashes.
* @param string $salt 	The user's unique pass salt
* @param string $pass	The user's encrypted password
*
* @return boolean	true for equal, false for not (login failed etc)
*
*/
function verify_user_password($input, $salt, $pass)
{
   return ($pass === encode_password($input, $salt));
}

/**
* Given a password and a salt, encode them to the form which is stored in
* the game's database.
*
* @param string $password 		The password to be encoded
* @param string $salt			The user's unique pass salt
* @param boolean $already_md5	Whether the specified password is already
* 								a md5 hash. This would be true for legacy
* 								v2 passwords.
*
* @return string	The resulting encoded password.
*/
function encode_password($password, $salt, $already_md5 = false)
{
   if (!$already_md5)
   {
       $password = md5($password);
   }
   return md5($salt . $password);
}

/**
* Generate a salt to use to secure a user's password
* from rainbow table attacks.
*
* @return string	The generated salt, 8 alphanumeric characters
*/
function generate_pass_salt()
{
   return substr(md5(microtime_float()), 0, 8);
}

function microtime_float()
{
   list($usec, $sec) = explode(" ", microtime());
   return ((float) $usec + (float) $sec);
}

/**
*
* @return string The URL of the game.
*/
function determine_game_urlbase()
{
   $domain = $_SERVER['HTTP_HOST'];
   $turi = $_SERVER['REQUEST_URI'];
   $turiq = '';
   for ($t = strlen($turi) - 1; $t >= 0; $t--)
   {
       if ($turi[$t] != '/')
       {
           $turiq = $turi[$t] . $turiq;
       }
       else
       {
           break;
       }
   }
   $turiq = '/' . $turiq;
   if ($turiq == '/')
   {
       $domain .= substr($turi, 0, -1);
   }
   else
   {
       $domain .= str_replace($turiq, '', $turi);
   }
   return $domain;
}

/**
* Get the file size in bytes of a remote file, if we can.
*
* @param string $url	The url to the file
*
* @return int			The file's size in bytes, or 0 if we could
* 						not determine its size.
*/

function get_filesize_remote($url)
{
   // Retrieve headers
   if (strlen($url) < 8)
   {
       return 0; // no file
   }
   $is_ssl = false;
   if (substr($url, 0, 7) == 'http://')
   {
       $port = 80;
   }
   else if (substr($url, 0, 8) == 'https://' && extension_loaded('openssl'))
   {
       $port = 443;
       $is_ssl = true;
   }
   else
   {
       return 0; // bad protocol
   }
   // Break up url
   $url_parts = explode('/', $url);
   $host = $url_parts[2];
   unset($url_parts[2]);
   unset($url_parts[1]);
   unset($url_parts[0]);
   $path = '/' . implode('/', $url_parts);
   if (strpos($host, ':') !== false)
   {
       $host_parts = explode(':', $host);
       if (count($host_parts) == 2 && ctype_digit($host_parts[1]))
       {
           $port = (int) $host_parts[1];
           $host = $host_parts[0];
       }
       else
       {
           return 0; // malformed host
       }
   }
   $request =
           "HEAD {$path} HTTP/1.1\r\n" . "Host: {$host}\r\n"
                   . "Connection: Close\r\n\r\n";
   $fh = fsockopen(($is_ssl ? 'ssl://' : '') . $host, $port);
   if ($fh === false)
   {
       return 0;
   }
   fwrite($fh, $request);
   $headers = array();
   $total_loaded = 0;
   while (!feof($fh) && $line = fgets($fh, 1024))
   {
       if ($line == "\r\n")
       {
           break;
       }
       if (strpos($line, ':') !== false)
       {
           list($key, $val) = explode(':', $line, 2);
           $headers[strtolower($key)] = trim($val);
       }
       else
       {
           $headers[] = strtolower($line);
       }
       $total_loaded += strlen($line);
       if ($total_loaded > 50000)
       {
           // Stop loading garbage!
           break;
       }
   }
   fclose($fh);
   if (!isset($headers['content-length']))
   {
       return 0;
   }
   return (int) $headers['content-length'];
}
// GPC fix: added in 1.1.1
if (version_compare(PHP_VERSION, '5.4.0-dev') < 0
       && function_exists('get_magic_quotes_gpc'))
{
   $_core_gpc_on = get_magic_quotes_gpc();
}
else
{
   $_core_gpc_on = false;
}
if (!$_core_gpc_on)
{
   foreach ($_POST as $k => $v)
   {
       $_POST[$k] = addslashes($v);
   }
   foreach ($_GET as $k => $v)
   {
       $_GET[$k] = addslashes($v);
   }
}
// Error reporting we want
@error_reporting(E_ALL & ~E_NOTICE);
// Tidy?
if (class_exists('tidy'))
{

   function tidy_test()
   {
       $html = ob_get_clean();

       // Specify configuration
       $config =
               array('indent' => true, 'output-xhtml' => true, 'wrap' => 200);

       // Tidy
       $tidy = new tidy;
       $tidy->parseString($html, $config, 'latin1');
       $tidy->cleanRepair();

       // Output
       echo $tidy;
   }
   ob_start();
   register_shutdown_function('tidy_test');
}

 

 

mysql.php -

 

<?php



date_default_timezone_set('Europe/London'); #Set default timezone

$c =
mysql_connect('localhost', 'LOL', 'LOL') or die(mysql_error());
mysql_select_db('LOL', $c);




Link to comment
Share on other sites

Where did gangster warfare come from? And what is it?

In the meta description.. it's nice that you actually read your scripts before asking for help.

Link to comment
Share on other sites

Ohh, there isn't no game called Gangster warfare, someone made the Meta description up for me, It was going to be based of gangs wars. But its based on something differnt. But Im going to change it...But dont know what to change to. I'm going to be late for prayer lol. Brb.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...