这是我的代码,这很烦人,因为我找不到问题。过去两天我一直在研究这个问题,但自己无法解决,我对编码比较陌生,所以请清楚地解释发生了什么因为我显然不会明白你在说什么。请帮我看看 - 这是代码。
<?php
session_start();
include_once("includes/db_connect.php");
if (isset($_SESSION['real_name'])){
include "mainmenu.php";
die("-");
exit();
}
error_reporting(0);
//This of course tells the website that what follows
$realip=$_SERVER['REMOTE_ADDR'];
if ($_POST['Submit'] && mysql_real_escape_string($_POST['username'])){
function change($msg){
$post = $msg;
$post = str_replace(" ", "", $post);
return $post;
}
$username = $_POST['username'];
$password = $_POST['password'];
$password = mysql_real_escape_string(strip_tags($password));
$ip = $_SERVER['REMOTE_ADDR'];
$date = gmdate('Y-m-d h:i:s');
$tquery = "SELECT nextlogin FROM users WHERE username='$username'";
$tresult = mysql_query($tquery) or die(mysql_error());
$trow = mysql_fetch_array($tresult);
if((time() < $trow['nextlogin']) ) {
$waittime=$trow['nextlogin'] - time();
die("This user has allready tried to login in the past 30 seconds! please wait $waittime seconds before you can login!");
}
$result = mysql_query("SELECT * FROM loginip") or die("Hack protection error Please contact admin@mafiasecrets.com and tell him about this!");
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
$id = $row['id'];
$timeleft = $row['time'] - time();
if ($timeleft <0){mysql_query("DELETE FROM loginip WHERE id='$id'");}
}// while loop
$select = mysql_query("SELECT * FROM loginip WHERE ip='$realip'");
$num = mysql_num_rows($select);
if($num>"0"){
die("Your ip has allready tried to login in the past 30 seconds, Please wait $timeleft seconds before you can login again!");
}
///check INFO
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1");
$login_check = mysql_num_rows($sql);
$inf = mysql_fetch_object($sql);
if ($login_check > "0"){
session_register('username');
$_SESSION['real_name'] = $username;
//This of course tells the website that what follows
$realip=$_SERVER['REMOTE_ADDR'];
$time2 = time();
$timestamp = time()+60;
$sql = "UPDATE users SET nextlogin='".strtotime ("+30 seconds")."' WHERE username='".mysql_real_escape_string($username)."'";
mysql_query($sql);
$sql = "INSERT INTO loginip SET id = '', ip = '$realip', time = '".strtotime ("+20 seconds")."'";
$res = mysql_query($sql);
mysql_query("UPDATE lastloginname SET username='$username' WHERE ip='$realip'");
mysql_query("UPDATE users SET online='Online', onlinetime2='$time2' WHERE username='$username'");
mysql_query("UPDATE users SET apperoffline='1' WHERE username='$username'")or die("Error aper oflin");
$time1=time()+500;
mysql_query("INSERT INTO `loggedin` (`id`, `ip`, `username`, `time`) VALUES ('', '$realip', '$username', '$time1')");
$sql = mysql_query("SELECT * FROM facebookshare WHERE username='$username'");
$fb_check = mysql_num_rows($sql);
if ($fb_check == "0"){
$timef = gmdate('Y-m-d h:i:s');
?>
<?php
mysql_query("INSERT INTO `facebookshare` (`id`, `username`, `time`) VALUES ('', '$username', '$timef')");
}//not shared
?><?php
$sql="SELECT * FROM users WHERE username='$username' LIMIT 1";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){ // Start looping table row
$rank = mysql_real_escape_string(strip_tags($rows['rank']));
$health = mysql_real_escape_string(strip_tags($rows['health']));
$country = mysql_real_escape_string(strip_tags($rows['country']));
$rankpoints = mysql_real_escape_string(strip_tags($rows['rankpoints']));
$rankbar = mysql_real_escape_string(strip_tags($rows['rankbar']));
$firstlogin = mysql_real_escape_string(strip_tags($rows['firstlogin']));
}
?>
<?
if($_POST['a']){
mysql_query("UPDATE users SET `firstlogin`=`firstlogin`+'1' WHERE username='$username'");
echo "<meta http-equiv='refresh' content='1;URL=veri.php'>";
}
?>
<style type="text/css">
<!--
.textbox {background-color: 222222; border-bottom: 1px solid #626262; border-left: 1px solid #040404; border-right: 1px solid #626262; border-top: 1px solid #040404; color: white; font-family: verdana; font-size: 18px;}
-->
</style>
<body bgcolor="#222222">
<META HTTP-EQUIV="Refresh" CONTENT="4; URL=play.php">
<table cellpadding="0" width="100%" height="100%">
<td width="100%" height = "100%"><center>
<font color="white" face="verdana" size="3">Welcome: </font><b><font color=khaki size=3 face=verdana><? echo $username ?></font></b><br>
<table width=300 cellpadding=0 cellspacing=0 align=center>
<tr>
<td height=5></td>
</tr>
<tr>
<td height=1 bgcolor=#444444></td>
</tr>
<tr>
<td height=5></td>
</tr>
</table>
<?php
$rank_1 = "Hobo";
$rank_2 = "Citizen";
$rank_3 = "Vandal";
$rank_4 = "Thug";
$rank_5 = "Respected Thug";
$rank_6 = "Mobster";
$rank_7 = "Respected Mobster";
$rank_8 = "Assassin";
$rank_9 = "Respected Assassin";
$rank_10 = "Mafioso";
$rank_11 = "Respected Mafioso";
$rank_12 = "Underboss";
$rank_13 = "Respected Underboss";
$rank_14 = "Boss";
$rank_15 = "Respected Boss";
$rank_16 = "Godfather";
$rank_17 = "Respected Godfather";
$rank_18 = "Gangster";
$rank_19 = "Immaculate Gangster";
$rank_2_exp = "50";
$rank_3_exp = "120";
$rank_4_exp = "350";
$rank_5_exp = "1100";
$rank_6_exp = "3200";
$rank_7_exp = "6100";
$rank_8_exp = "11300";
$rank_9_exp = "15000";
$rank_10_exp = "21000";
$rank_11_exp = "30000";
$rank_12_exp = "41000";
$rank_13_exp = "52000";
$rank_14_exp = "66500";
$rank_15_exp = "82500";
$rank_16_exp = "98000";
$rank_17_exp = "128000";
$rank_18_exp = "147000";
$rank_19_exp = "170000";
?>
<?php
$newmail = mysql_query("SELECT * FROM messages WHERE t='$username' AND r='0'");
$notoriouslegendskk = mysql_num_rows($newmail);?>
<?
if ($rankbar>=1){
if ($rankpoints > "$rank_19_exp"){
$nextrank = 0;
}else{
if ($rankpoints < "$rank_2_exp"){ $amount="$rank_2_exp"; $check="0";}
elseif ($rankpoints < "$rank_3_exp"){ $amount="$rank_3_exp"; $check="$rank_2_exp";}
elseif ($rankpoints < "$rank_4_exp"){ $amount="$rank_4_exp"; $check="$rank_3_exp";}
elseif ($rankpoints < "$rank_5_exp"){ $amount="$rank_5_exp"; $check="$rank_4_exp";}
elseif ($rankpoints < "$rank_6_exp"){ $amount="$rank_6_exp"; $check="$rank_5_exp";}
elseif ($rankpoints < "$rank_7_exp"){ $amount="$rank_7_exp"; $check="$rank_6_exp";}
elseif ($rankpoints < "$rank_8_exp"){ $amount="$rank_8_exp"; $check="$rank_7_exp";}
elseif ($rankpoints < "$rank_9_exp"){ $amount="$rank_9_exp"; $check="$rank_8_exp";}
elseif ($rankpoints < "$rank_10_exp"){ $amount="$rank_10_exp"; $check="$rank_9_exp";}
elseif ($rankpoints < "$rank_11_exp"){ $amount="$rank_11_exp"; $check="$rank_10_exp";}
elseif ($rankpoints < "$rank_12_exp"){ $amount="$rank_12_exp"; $check="$rank_11_exp";}
elseif ($rankpoints < "$rank_13_exp"){ $amount="$rank_13_exp"; $check="$rank_12_exp";}
elseif ($rankpoints < "$rank_14_exp"){ $amount="$rank_14_exp"; $check="$rank_13_exp";}
elseif ($rankpoints < "$rank_15_exp"){ $amount="$rank_15_exp"; $check="$rank_14_exp";}
elseif ($rankpoints < "$rank_16_exp"){ $amount="$rank_16_exp"; $check="$rank_15_exp";}
elseif ($rankpoints < "$rank_17_exp"){ $amount="$rank_17_exp"; $check="$rank_16_exp";}
elseif ($rankpoints < "$rank_18_exp"){ $amount="$rank_18_exp"; $check="$rank_17_exp";}
elseif ($rankpoints < "$rank_19_exp"){ $amount="$rank_19_exp"; $check="$rank_18_exp";}
/// total rankpoints - rankpoints required for current rank / rank points needed for next rank * 100
$end = $amount - $check;
$percent = $rankpoints - $check;
$percent = $percent / $end;
$add = $percent * 100;
if($rankbar==2){
$nextrank = sprintf ("%0.1f",$add);
}else{
$nextrank = round($add);
}
}//not undercover gangster
?>
<font color=white face=verdana size=2>You have <b style=color:khaki;><?php echo $notoriouslegendskk ?></b> new messages!</font><br>
<table width=300 cellpadding=0 cellspacing=0 align=center>
<tr>
<td height=5></td>
</tr>
<tr>
<td height=1 bgcolor=#444444></td>
</tr>
<tr>
<td height=5></td>
</tr>
</table>
<font color=silver face=verdana size=1>Rank: </font><font color=white face=verdana size=1><?php echo $rank ?></font><font color=silver face=verdana size=1> | </font> <font color=silver face=verdana size=1>Rank Up: </font><font color=white face=verdana size=1><?php echo $nextrank ?>%</font><font color=silver face=verdana size=1> | </font> <font color=silver face=verdana size=1>Health: </font><font color=white face=verdana size=1><?php echo $health ?>%</font><font color=silver face=verdana size=1> | </font> <font color=silver face=verdana size=1>Location: </font><font color=white face=verdana size=1><?php echo $country ?></font><br>
</center>
</td>
</table>
</body>
<?php } ?>
<?php
} else {
$sql = "UPDATE users SET nextlogin='".strtotime ("+20 seconds")."' WHERE username='".mysql_real_escape_string($username)."'";
mysql_query($sql);
$failtime = date('d-m-Y H:i:s', strtotime('+5 hours'));
mysql_query("INSERT INTO loginfails SET id = '', ip = '$realip', time = '$failtime', username = '$username', password = '$password'");
$sql = "INSERT INTO loginip SET id = '', ip = '$realip', time = '".strtotime ("+30 seconds")."'";
$res = mysql_query($sql);
echo"<b>Invalid Username/Password, Please go back and <a href=index.php>try again!</a></b>";
}else{
die("You did not attempt to login, <a href=index.php>Click</a> here to go to the login page!");
}
?>