Need help with a registration script, it was written in PHP and originally ran fine on a 5.3 server. I'm now running 5.4 and it's become depreciated, if someone can rewrite the registration part of the script, that'd be greatly appreciated....
Would be GREATLY appreciated....to see what's wrong first hand.... Click here
Code:
<?php
/* For lack of sheer laziness, functions and variables will be defined here. */
/* Want them in a separate file? Do it your damn self! */
/* - Zan ^.^ */
// This page modified by Skyon Archer of http://www.tierrahosting.com
//Variables added by Skyon Archer
$submit = $_POST["submit"];
$submit = strip_tags($submit);
//Page Variables
$online='<span style="color:#4CC417; font-family:Tahoma; font-weight:bold;">Online</span> ';
$offline='<span style="color:#FF0000; font-family:Tahoma; font-weight:bold;">Offline</span> ';
//Functions
function servercheck($server,$port){
//Check that the port value is not empty
if(!$port){
$port=80;
}
//Check that the server value is not empty
if(empty($server)){
$server='SERVER_IP';
}
//Connection
$fp=@fsockopen($server, $port, $errno, $errstr, 1);
//Check if connection is present
if($fp){
//Return Alive
return 1;
} else{
//Return Dead
return 0;
}
//Close Connection
fclose($fp);
}
//Ports and Services to check
$services=array(
'<span style="color:#FF0000; font-family:Tahoma; font-weight:bold;">Login Server:</span> ' => array('SERVER_IP' => 12000) ,
'<span style="color:#FF0000; font-family:Tahoma; font-weight:bold;">Patch Server:</span> ' => array('SERVER_IP' => 12001),
'<span style="color:#FF0000; font-family:Tahoma; font-weight:bold;">Ship Server:</span> ' => array('SERVER_IP' => 12003),
//'<span style="color:#FF0000; font-family:Tahoma; font-weight:bold;">Web Server:</span> ' => array('localhost' => 80),
);
function check_email_address($email) {
// First, we check that there's one @ symbol,
// and that the lengths are right.
if(!preg_match('/^[^@]{1,64}@[^@]{1,255}$/', $email)) {
// Email invalid because wrong number of characters
// in one section or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if
(!preg_match("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&
?'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
$local_array[$i])) {
return false;
}
}
// Check if domain is IP. If not,
// it should be valid domain name
if (!preg_match("^\[?[0-9\.]+\]?$", $email_array[1])) {
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if
(!preg_match("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
?([A-Za-z0-9]+))$",
$domain_array[$i])) {
return false;
}
}
}
return true;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>RevPSO - A private Phantasy Star Online server!</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="StyleSheet" type="text/css" href="http://revpso.com/assets/css/style.css" media="screen" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<!-- Modified by Skyon Archer of http://www.tierrahosting.com -->
</head>
<body>
<div id="container">
<div id="header"></div>
<div id="navigation">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="register_new.php">Register an Account</a></li>
<li><a href="download.php">Download</a></li>
<li><a href="http://revillution.com/forums/">Forums</a></li>
<li><a href="about.php">About/F.A.Q</a></li>
<li><a href="donate.php">Donate!</a></li>
</ul>
</div>
<div id="content-container">
<div id="content">
<h2>
Welcome to RevPSO!
</h2>
<div style="text-align:center; margin: 0 auto;"><span style="color:#E41B17; font-family:Tahoma;">
<h3>Account Registration</h3>
<?php
if($_SERVER['REQUEST_METHOD'] == "POST") {
$status = '';
require_once('recaptchalib.php');
$privatekey = "6Ldj0eoSAAAAAN8tlAgMxhXM23o-s7BT-EhJxSW3";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
echo "<p>The reCAPTCHA wasn't entered correctly. (reCAPTCHA said: " . $resp->error . ")</p>";
$status = 'nogood';
}
//Variables
$pw = $_POST["password1"];
$password1 = strtolower(@mysql_real_escape_string($_POST["password1"]));
$password2 = strtolower(@mysql_real_escape_string($_POST["password2"]));
$username = strtolower(@mysql_real_escape_string($_POST["username"]));
$email1 = @mysql_real_escape_string($_POST["email1"]);
$email2 = @mysql_real_escape_string($_POST["email2"]);
$fake = check_email_address($email1);
if ($fake == FALSE) {
echo '<p>The email address you supplied is not valid.</p>';
$status = 'nogood';
}
if ((strlen ($_POST["username"]) > 16) || (strlen ($_POST["password1"]) > 16)){
echo '<p>Username or password is too long. (16 char max). Please try again.</p>';
$status = 'nogood';
}
if (!$username) {
echo "<p>You did not enter an account ID.</p>";
$status = 'nogood';
}
if (!$password1) {
echo "<p>You did not specify a password.</p>";
$status = 'nogood';
}
if ($password1 != $password2) {
echo "<p>Your passwords did not match.</p>";
$status = 'nogood';
}
if ($email1 != $email2) {
echo "<p>Your email addresses did not match.</p>";
$status = 'nogood';
}
if ($status == 'nogood'){
echo '<p><a href="register_new.php">Try Again</a></p>';
}
if ($status != 'nogood'){
$reg_seconds = round(time() / 3600);
$password1 .= "_" . $reg_seconds . "_salt";
if (!$db = @mysql_connect ("localhost", "DB_USER", "DB_PASS") )
die ("Can't connect to MySQL.");
if (!@mysql_select_db ("DB_NAME", $db))
die ("Can't select PSO database.");
$sql = "SELECT * from account_data WHERE username='" . $username . "'";
$result = mysql_query ($sql, $db);
if (!$result) die ("Unable to query database.");
if ($myrow = mysql_fetch_array($result)) {
echo '<p><a href="register_new.php">Try Again</a></p>';
die ("Account is already taken, yo.");
}
$password1 = md5($password1);
$sql = "INSERT into account_data (username,password,email,regtime,isgm,isactive) "
. "VALUES ('". $username . "', '" . $password1 . "', '" . $email1 . "', '" . $reg_seconds . "', '0', '1')";
$result = mysql_query ($sql, $db);
if (!$result) die ("Unable to add account into database.");
$gcnum = mysql_insert_id();
echo "<p>Account " . $username ." was successfully created!<br /><br />\r\nYour new guild card # is " . $gcnum . "</p>";
}
}else{
?>
<h4>*DO NOT USE CAPITALS FOR YOUR ACCOUNT NAME OR PASSWORD! MAKE SURE EVERYTHING IS LOWERCASE!*</h4>
<form method="post" action="register_new.php">
<table style="width:500px;border-collapse:collapse;" ><tr>
<td width="30%" align="left">Desired account ID:</td><td width="70%"><input name="username" size="45" value="" /></td>
</tr><tr>
<td width="30%" align="left">Password:</td><td width="70%"><input name="password1" size="45" type="password" /></td>
</tr><tr>
<td width="30%" align="left">Password (confirm):</td><td width="70%"><input name="password2" size="45" type="password" /></td>
</tr><tr>
<td width="30%" align="left">E-mail:</td><td width="70%"><input name="email1" size="45" value="" /></td>
</tr><tr>
<td width="30%" align="left">E-mail (confirm):</td><td width="70%"><input name="email2" size="45" value="" /></td>
</tr><tr>
<td colspan="2">
<?php
require_once('recaptchalib.php');
$publickey = "6Ldj0eoSAAAAAOl0olhqgepmD0p_vk04HtIJWlaU"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
</td>
</tr><tr>
<td colspan="2">
<span style="display:none;visibility:hidden;">
<label for="email">
Ignore this text box. You've been warned! : )
</label>
<input type="text" name="email" size="1" value="" />
</span><br /><input type="submit" name="submit" value="Sign Up" />
</td>
</tr></table>
<?php
}
?>
</div></div>
<div id="aside">
<h3>
Server Status
</h3>
<table id="serverstatus">
<?php
//Check All Services
foreach($services as $name => $server){
echo "<tr>
<td width='200'>$name</td>
";
foreach($server as $host => $port){
$status = servercheck($host,$port);
switch($status) {
case 1:
echo "<td>$online</td>";
break;
case 0:
echo "<td>$offline</td>";
break;
}
}
echo "</tr>";
}
?>
</table>
<p>
<form method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" value="_s-xclick" name="cmd" />
<input type="hidden" value="L5BWCMYLUACXE" name="hosted_button_id" />
<input type="image" border="0" alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypalobjects.com/WEBSCR-640-20110429-1/en_US/i/btn/btn_donateCC_LG.gif" />
<img width="1" border="0" height="1" src="https://www.paypalobjects.com/WEBSCR-640-20110429-1/en_US/i/scr/pixel.gif" alt="" />
</form>
</p>
<p>
<h3>Social Networks</h3><br />
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=209137425804263&xfbml=1"></script><fb:like href="https://www.facebook.com/pages/Revillution-Phantasy-Star-Online-Blue-Burst-REVPSO/109802629109620" send="true" width="190" show_faces="false" font="arial"></fb:like>
<!--<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FRevillution-Phantasy-Star-Online-Blue-Burst-REVPSO%2F109802629109620&width=200&colorscheme=light&show_faces=false&border_color=black&stream=true&header=true&height=427" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:427px;" allowTransparency="true"></iframe>-->
<br />
<g:plusone size="tall"></g:plusone></p>
</div>
<div id="footer">
RevPSO © Revillution Network 2011 - All rights reserved. | Hosted by <a href="http://www.revillution.com">Revillution</a> | Design by <a href="http://www.darkpixeldesigns.com">DarkPixelDesigns</a> | Ship code by DDrX & Zanoey.
</div>
</div>
</div>
</body>
</html>
Would be GREATLY appreciated....to see what's wrong first hand.... Click here







