Я потратил бесчисленные часы, пытаясь самостоятельно выяснить, почему Firefox удваивает мои запросы. Я проверил код в Opera, IE и Chrome, и он отлично работает. Я опубликую в одном из моих меньших кодов. В настоящее время я использую систему, в которой выбранный файл страницы включает в себя «header.php» в начале, а затем в конце «footer.php».
Я просто опубликую файл главной страницы, но, если мне нужно будет также включить страницы верхнего и нижнего колонтитула, пожалуйста, дайте мне знать.
<?php $title = "Weapons Shop"; include("header.php"); ?>
<?php
if (!$buy) {
print "Hello and welcome to the Weapons Shop, where you can buy anything from scrap metal weapons to high grade swords. <br><br><table>
<tr><td width=120><b><u>Name</td><td width=100><b><u>Effect</td><td width=50><b><u>Cost</td><td width=50><b><u>Platinum</td><td><b><u>Level needed</td><td><b><u>Options</td></tr>";
$wsel = mysql_query("select * from equipments where type='W' and status='S' and owner=0 order by cost asc");
while ($wep = mysql_fetch_array($wsel)) {
print "<tr><td>$wep[name]</td><td>+$wep[power] Defense</td><td>";
$acost = $wep['cost'];
$arcost = "".number_format($acost, 0,'.',',');
print "$arcost</td><td>$wep[plat]</td><td>$wep[minlev]</td><td>-
<A href=weapons3.php?buy=$wep[id]>Buy</a></td></tr>";
}
print "</table>";
}
if ($buy) {
$arm = mysql_fetch_array(mysql_query("select * from equipments where id=$buy"));
if (empty ($arm[id])) {
print "No such weapon. Go back to the <a href=weapons3.php>shop</a>.";
include("footer.php");
exit;
}
if ($arm[status] != S) {
print "That's not a shop item. Go back to the <a href=weapons3.php>shop</a>.";
include("footer.php");
exit;
}
if ($arm[minlev] > $stat[level]) {
print "Your level is too low for that! Go back to the <a href=weapons3.php>shop</a>.";
include("footer.php");
exit;
}
if ($arm[cost] > $stat[credits]) {
print "You can't afford that! Go back to the <a href=weapons3.php>shop</a>.";
include("footer.php");
exit;
}
$newcost = ceil($arm[cost] * .75);
mysql_query("insert into equipment (owner, name, power, cost, type) values($stat[id],'$arm[name]',$arm[power],$newcost),$arm[type]")
or die("Could not add weapon.");
print "You paid <b>$arm[cost]</b> credits, but you now have a new <b>$arm[name] +$arm[power]</b> weapon.";
mysql_query("update players set credits=credits-$arm[cost] where id=$stat[id]");
}
?>
<?php include("footer.php"); ?>
Проблема в этом файле заключается в том, что в Firefox, если пользователь покупает оружие, он создает 2 единицы оружия и заряжает игрока вдвое.
Я обнаружил очень мало похожих проблем на форумах, которые я нашел через Google, и ни одна из найденных мной проблем не дала разумного решения, чтобы остановить проблему. Я перепробовал все, что мог придумать, чтобы решить эту проблему, и не нашел нигде, кроме аптеки для таблеток от головной боли.
Пожалуйста, помогите, если можете!
EDIT:
в ответ на комментарии, у меня есть ниже мои 'header.php' и 'footer.php', а также 'config.php', так как он также задействован.
config.php
<?php
mysql_pconnect("localhost","root","");
mysql_select_db("maindbinfo");
$cpass="";
$gamename="Rise of Kingdoms";
?>
header.php
<?php
include("config.php");
session_start(); ?>
<?php
if(isset($_SESSION['user'])) {
if (isset($_SESSION['pass'])) {
$stat = mysql_fetch_array(mysql_query("select * from players where user='$user' and pass='$pass'"));
if (empty ($stat['id'])) {
print "Invalid login.";
print "<META http-equiv=refresh content=4;URL=index.php>";
} } }
$ctime = time();
mysql_query("update players set lpv=$ctime where id=$stat[id]");
$ip = $_SERVER;
mysql_query("update players set ip='$ip' where id=$stat[id]");
mysql_query("update players set page='$title' where id=$stat[id]");
$remove_these = array("<", ">", "+","=" ,"-", "--");
function varscan($num) {
global $stat;
global $title;
$remove_these = array("<", ">", "+","=" ,"-", "*");
for($b = 0; $b <= 5; $b++) {
if (preg_match("/[$remove_these[$b]]/i", "$num")) {
$fulltime = date("F j, Y, g:i a");
print "!Alert! You have been caught trying to cheat, an admin will view what you have just
typed in and if it is a valid cheat or close to one you will be banned for an amount
of time depending on how many times you have tried... If you accidentally ran into this,
just mail id 1 by <a href=mail.php?view=write&to=1&re=Hacking:Accident>Clicking Here</a>. Thank you!";
mysql_query("insert into adminlog (log, reason) values('Hacking Attempt<br>User: <b>$stat[user]</b><br>Id: <b>$stat[id]</b><br>
IP: <b>$stat[ip]</b><br>Time: <b>$fulltime</b><br>Page: <b>$title<br>Script: <b>$num</b>','hacking')");
$writeindoc = "Hacking Attempt<br>User: <b>$stat[user]</b><br>Id: <b>$stat[id]</b><br>IP: <b>$stat[ip]</b><br>Time: <b>
$fulltime</b><br>Page: <b>$title</b><br>Script: <b>$num</b><br>---------------------<br>";
$filename = "logs/hackinglog.htm";
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
print "Could not open log file";
exit;
}
if (fwrite($handle, $writeindoc) === FALSE) {
print "Could not write to the log file";
exit;
}
fclose($handle);
}else{
print "Error with a log file";
}
include("footer.php");
exit;
}
}
return $num = str_replace($remove_these, "", "$num");
return $num = htmlspecialchars($num);
return $num = strip_tags($num);
}
?>
<head>
<title>Rise of Kingdoms</title>
<link rel=stylesheet href=style.css>
</head>
<body leftmargin=0 rightmargin=0 onload="window.status='Rise of Kingdoms | Version 0.1'">
<center>
<table width=98% valign=top class=td cellpadding=0 cellspacing=0>
<td align=right bgcolor=DDCC71 style="border-bottom: solid 747d58 1px;">
<a href=irc://irc.netgamers.org/riseofkingdoms><b>IRC:</b> irc.Netgamers.org
#RiseofKingdoms</a> <b>Game Time:</b> </b>
<? $date = date("h:i:s A T");
print "$date"; ?>
<b>Rise of Kingdoms</b> | Version 1.0
</td></tr>
<tr><td><center><img src='banner.png'><br><b><a href=donate.php>Become a Donator to gain the
upper hand over the rest</a></b><br><b><a href=vote.php>Please remember to Vote for Rise of Kingdoms</a></b></center>
<table>
<tr>
<td valign=top width=15%><table cellpadding=0 cellspacing=0 class=td width=100%>
<tr><td style="border-bottom: solid 747d58 1px;" bgcolor=DDCC71
align=center>
<b>Statistics</b>
</td></tr>
<tr><td>
<?php
print "<center><b><u>$stat[user]</b></u> ($stat[id])</center><br>";
print "<b>Level:</b> $stat[level]<br><br>";
$expn = (($stat['level'] * 62) + ($stat['level'] * 24));
$cexpn = "".number_format($expn, 0,'.',',');
$curexp = "".number_format($stat['exp'], 0,'.',',');
$pct = (($stat['exp']/$expn) * 100);
$pct = round($pct,"0");
print "<b>Exp:</b> $curexp/$cexpn ($pct%)<br>";
print "<b>Health:</b> $stat[hp]/$stat[max_hp]<br>";
print "<b>Energy:</b> $stat[energy]/$stat[max_energy]<br>";
print "<b>Steps:</b> $stat[steps]/$stat[max_steps]<br><br>";
$credit = $stat['credits'];
$credits= "".number_format($credit, 0,'.',',');
print "<b>Credits:</b> $credits<br>";
$bank = $stat['bank'];
$banks = "".number_format($bank, 0,'.',',');
print "<b>Bank:</b> $banks<br>";
print "<b>Diamonds:</b> $stat[diamonds]<br>";
$plati = $stat['platinum'];
$platin = "".number_format($plati, 0,'.',',');
print "<b>Platinum:</b> $platin<br><br>";
print "<b>Referrals:</b> $stat[refs]<br>";
?>
</td></tr>
</table><br>
<table cellpadding=0 cellspacing=0 class=td width=100%>
<tr><td style="border-bottom: solid 747d58 1px;" bgcolor=DDCC71 align=center>
<b>Navigation</b>
</td></tr>
<tr>
<td style="background-image: url('');
background-position: left bottom; background-repeat: no-repeat">
- <a href=stats.php>Overview</a><br>
- <a href=equip.php>Equipment</a><br>
<?php
$numlog = mysql_num_rows(mysql_query("select * from log where unread='F' and owner=$stat[id]"));
print "- <a href=log.php>Log</a> [$numlog]<br><br>";
?>
<?php
if ($stat['town'] == 1) { print "- <a href=city.php>Silverlake (Town)</a><br>"; }
if ($stat['town'] == 2) { print "- <a href=seccity.php>Shylock (Town)</a><br>"; }
if ($stat['town'] == 3) { print "- <a href=tricity.php>Falconview Peaks (Town)</a><br>"; }
if ($stat['town'] == 4) { print "- <a href=forcity.php>Maplehedge Crossing (Town)</a><br>"; }
?>
<?php
$king = mysql_fetch_array(mysql_query("select * from kingdom where owner=$stat[id]"));
if ($king) {
print "- <a href=kingdom.php>Your Kingdom</a><br>";
}
else {
print "";
}
?>
- <a href=battle.php>Battle Arena</a><br><br>
<?php
if ($stat['tribe']) {
print "- <a href=tribes.php?view=my>My Tribe</a><br>";
}
?>
<?php
$edneed = ($stat['max_hp'] - $stat['hp']);
$itneed = ($edneed * 5);
$crneed = ($itneed * $stat['level']);
print "- <a href=hospital.php>Hospital</a> [$crneed cr]<br>";
?>
<?php
$mnumlog = mysql_num_rows(mysql_query("select * from mail where unread='T' and owner=$stat[id]"));
print "- <a href=mail.php>Mail</a> [$mnumlog]<br><br>";
?>
- <a href=bank.php>The Bank</a><br><br>
- <a href=forums.php?view=topics>Forums</a><br>
<?php
if ($stat['tribe'] > 0) {
print "- <a href=tforums.php?view=topics>Tribe Forum</a><br>";
}
?>
<?php
$psel = mysql_query("select * from players where page='Chat'");
$ctime = time();
while ($pl = mysql_fetch_array($psel)) {
$span = ($ctime - $pl['lpv']);
if ($span <= 180) {
$numoc = ('$numoc' + 1);
}
}
$numoc = ('$numoc' + 0);
print "- <a href=chat.php>The Pub</a> [$numoc]<br>";
?>
- <a href=irc://irc.netgamers.org/riseofkingdoms>IRC Chat</a><br><br>
- <a href=account.php>Account Options</a><br>
- <a href=logout.php>Log Out</a><br>
- <a href=help.php>Help</a><br>
<?php
if ($stat['rank'] == 'Staff') {
print "<br>- <a href=news.php>Post News</a>";
print "<br>- <a href=staff.php>Staff Options</a>";
}
if ($stat['rank'] == 'Staff') {
print "<br>- <a href=sforum.php?view=topics>Admin/Staff Forums</a>";
}
?>
<?php
if ($stat['rank'] == 'Admin') {
$anumlog = mysql_num_rows(mysql_query("select * from alog where unread='T'"));
print "<br>- <a href=adminlog.php?view=adminlog>Admin Log [$anumlog]</a>"; }
if ($stat['rank'] == 'Admin') {
print "<br>- <a href=admin.php>Admin Options</a>";
}
?>
<?php
if ($stat['rank'] == 'Admin') {
print "<br>- <a href=aforum.php?view=topics>Admin/Staff Forum</a>";
}
?>
</td></tr>
</table>
</td><td width=50% valign=top>
<?php
$jchance = rand(1,10000);
$jchance2 = rand(1,10000);
if ($jchance == $jchance2) {
print "<table cellpadding=0 cellspacing=0 class=td width=100%>";
print "<tr><td style=\"border-bottom: solid 747d58 1px;\" align=center bgcolor=747d58><b>Juggernaut Vore</b></td></tr>";
print "<tr><td>";
$numj = mysql_num_rows(mysql_query("select * from core where name='Juggernaut' and owner=$stat[id]"));
if ($numj <= 0) {
print "You found the <b>Juggernaut Vore</b>! The most powerful default Vore in the game.<br>";
mysql_query("insert into core (owner,name,type,ref_id,power,defense) values($stat[id],'Juggernaut','Secret',3,10,10)");
} else {
print "You found the <b>Juggernaut Vore</b>! It's jealousy of your other Juggernaut makes it leave in a huff.";
}
print "</td></tr></table><br>";
}
?>
<table cellpadding=0 cellspacing=0 class=td width=100%>
<tr><td style="border-bottom: solid 747d58 1px;" bgcolor=DDCC71 align=center>
<?php
print "<b>$title</b>"; ?>
</td></tr>
<tr><td>
а это мой footer.php
footer.php
</td></tr>
</table><br>
<br>
</td><td width=15% valign=top>
<table cellpadding=0 cellspacing=0 class=td width=100%><tr>
<td style="border-bottom: solid 747d58 1px;" bgcolor=DDCC71 align=center>
<b>Storage</b>
</td></tr><tr><td>
<?php
print "<center><b><u></b></u></center>";
print "<b>Rats Tails:</b> $stat[ratt]<br>";
print "<b>Chicken Feathers:</b> $stat[chickf]<br>";
print "<b>Wolf Hairs:</b> $stat[wolfh]<br>";
print "<b>Hunters Arrows:</b> $stat[hunta]<br>";
print "<b>Witches Brooms:</b> $stat[witchb]<br>";
print "<b>Cobra Fangs:</b> $stat[cobraf]<br>";
print "<b>Dragon Scales:</b> $stat[drags]<br><br>";
if ($stat['mines'] > 0) {
print "<b>Burelia:</b> $stat[burelia]<br>";
print "<b>Alethite:</b> $stat[alethite]<br><br>";
}
if ($stat['flicence'] >= 1) {
print "<b>Carp:</b> $stat[carp]<br>"; }
if ($stat['flicence'] >= 2) {
print "<b>Saratoga:</b> $stat[saratoga]<br>"; }
if ($stat['flicence'] >= 3) {
print "<b>Largemouth Bass:</b> $stat[bass]<br>"; }
if ($stat['flicence'] >= 4) {
print "<b>Lobster:</b> $stat[lobs]<br>"; }
$test = (($stat['level'] * 135) * ($stat['level'] * 2));
print "$test";
if ($stat['refaward'] == 'Y') {
if ($stat['level'] >= 5) {
print " ";
mysql_query("update players set diamonds=diamonds+10 where id=$stat[referred]");
mysql_query("update players set refaward='N' where id=$stat[id]");
mysql_query("update players set refwin=refwin+1 where id=$stat[referred]");
mysql_query("insert into log (owner, log) values($stat[referred],'<b>$stat[user] ($stat[id])</b> has reached level 5.
Your 10 Diamonds have been recieved.')"); }
else {
print " "; } }
?>
</td></tr></table><br><table cellpadding=0 cellspacing=0 class=td width=100%><tr>
<td style="border-bottom: solid 747d58 1px;" bgcolor=DDCC71 align=center>
<b>Online Players</b>
</td></tr>
<tr><td>
<?php
$psel = mysql_query("select * from players order by id asc");
$ctime = time();
while ($pl = mysql_fetch_array($psel)) {
$span = ($ctime - $pl['lpv']);
if ($span <= 500) {
if ($pl['rank'] == 'Admin') {
print "<img src=images/admin.gif>";
}
if ($pl['rank'] == 'Staff') {
print "<img src=Tiny_S.gif>";
}
print "<a href=view.php?view=$pl[id]>$pl[user] ($pl[id])</a>";
if ($pl['sub'] > 0) {
print "<img src=http://www.renhelp.net/images/tutorials/star.gif>";
}
print "<br>";
}
}
print "</td></tr>
</table><br>
<table cellpadding=0 cellspacing=0 class=td width=100%>
<tr>
<td style='border-bottom: solid 747d58 1px;' bgcolor=DDCC71 align=center>
<b>Game Stats</b>
</td></tr>
<tr><td>
";
$nump = @mysql_num_rows(mysql_query("select * from players"));
$numo = ('$numo' + 1);
$numw = @mysql_num_rows(mysql_query("select * from equipment where type='W'"));
$numa = @mysql_num_rows(mysql_query("select * from equipment where type='A'"));
print "<b>$nump</b> total players.<br>";
print "<b>$numo</b> players online.<br>";
print "<b>$numw</b> weapons.<br>";
print "<b>$numa</b> armor.<br>";
?>
</td></tr></table><br>
<table cellpadding=0 cellspacing=0 class=td width=100%><tr>
<td style="border-bottom: solid 747d58 1px;" bgcolor=DDCC71 align=center>
<b>Vote for Rise of Kingdoms</b></td></tr>
<tr><td>
<?php
print "Please vote using these links to help promote and support this game. For each vote you will receive <b>1 Diamond</b>.
The more you vote, the more people see the game, and therefore the more people join and make the game more enjoyable!
<br><br>";
if ($stat['vote'] == 'N') {
print "<a href=vote.php?vote=1>Top 100 Arena</a><br>"; }
if ($stat['vote2'] == 'N') {
print "<a href=vote.php?vote=2>Top 50 Onrpg</a><br>"; }
if ($stat['vote3'] == 'N') {
print "<a href=vote.php?vote=3>Top Game Sites</a><br>"; }
if ($stat['vote4'] == 'N') {
print "<a href=vote.php?vote=4>GTOP 100</a><br>"; }
if ($stat['vote5'] == 'N') {
print "<a href=vote.php?vote=5>Game Sites 100</a><br>"; }
if ($stat['vote6'] == 'N') {
print "<a href=vote.php?vote=6>Ultimate Top 200 Game Sites</a><br>"; }
if ($stat['vote7'] == 'N') {
print "<a href=vote.php?vote=7>PHP Games Network</a>"; }
?>
</td></tr>
</td></tr></table>
<center>
</body>
</html>