FACT10 Posted December 6, 2009 Share Posted December 6, 2009 OK so I've had an old text-based RPG running with the permission of the owner, and due to security reasons we've decided to move to a friend's WAMP server, with PHP 5.3. Everything works fine, as it did on the previous server, except we're receiving this at the top of the page: ". * * Copyright [email protected], Adrian Osmond */ function makeBonus($name, $bonustofind, $db) { if ($bonustofind=="i") { $sql="SELECT * FROM `items`, `possessions` WHERE items.id = possessions.item AND items.infoup <> 0 AND possessions.user = '$name'"; $res=runSQL($sql, $currentuser["admin"]); $i=0; while ($iscore=mysql_fetch_array($res)) { $i=$i+$iscore["infoup"]; } return $i; } else if ($bonustofind=="s") { $sql="SELECT * FROM `items`, `possessions` WHERE items.id = possessions.item AND items.smuggleup <> 0 AND possessions.user = '$name'"; $res=runSQL($sql, $currentuser["admin"]); $s=0; while ($sscore=mysql_fetch_array($res)) { $s=$s+$sscore["smuggleup"]; } return $s; } else if ($bonustofind=="h") { $sql="SELECT * FROM `items`, `possessions` WHERE items.id = possessions.item AND items.hackup <> 0 AND possessions.user = '$name'"; $res=runSQL($sql, $currentuser["admin"]); $h=0; while ($hscore=mysql_fetch_array($res)) { $h=$h+$hscore["hackup"]; } return $h; } else if ($bonustofind=="g") { $sql="SELECT * FROM `items`, `possessions` WHERE items.id = possessions.item AND items.gunup <> 0 AND possessions.user = '$name'"; $res=runSQL($sql, $currentuser["admin"]); $g=0; while ($gscore=mysql_fetch_array($res)) { $g=$g+$gscore["gunup"]; } return $g; } else if ($bonustofind=="c") { $sql="SELECT * FROM `items`, `possessions` WHERE items.id = possessions.item AND items.coolup <> 0 AND possessions.user = '$name'"; $res=runSQL($sql, $currentuser["admin"]); $c=0; while ($cscore=mysql_fetch_array($res)) { $c=$c+$cscore["coolup"]; } return $c; } else { return 0; } } ?> Fatal error: Call to undefined function makeBonus() in C:\wamp\www\main.php on line 176" What's puzzling me is that the first part, which as you can see is just a comment, is being displayed along with the rest of the script. Then there's the undefined function error which worked perfectly on the old site. The itembonus.php code looks like this: <? error_reporting(E_ALL ^ E_NOTICE); function makeBonus($name, $bonustofind, $db) { if ($bonustofind=="i") { $sql="SELECT * FROM `items`, `possessions` WHERE items.id = possessions.item AND items.infoup <> 0 AND possessions.user = '$name'"; $res=mysql_query($sql, $db); $i=0; while ($iscore=mysql_fetch_array($res)) { $i=$i+$iscore["infoup"]; } return $i; } else if ($bonustofind=="s") { $sql="SELECT * FROM `items`, `possessions` WHERE items.id = possessions.item AND items.smuggleup <> 0 AND possessions.user = '$name'"; $res=mysql_query($sql, $db); $s=0; while ($sscore=mysql_fetch_array($res)) { $s=$s+$sscore["smuggleup"]; } return $s; } else if ($bonustofind=="h") { $sql="SELECT * FROM `items`, `possessions` WHERE items.id = possessions.item AND items.hackup <> 0 AND possessions.user = '$name'"; $res=mysql_query($sql, $db); $h=0; while ($hscore=mysql_fetch_array($res)) { $h=$h+$hscore["hackup"]; } return $h; } else if ($bonustofind=="g") { $sql="SELECT * FROM `items`, `possessions` WHERE items.id = possessions.item AND items.gunup <> 0 AND possessions.user = '$name'"; $res=mysql_query($sql, $db); $g=0; while ($gscore=mysql_fetch_array($res)) { $g=$g+$gscore["gunup"]; } return $g; } else if ($bonustofind=="c") { $sql="SELECT * FROM `items`, `possessions` WHERE items.id = possessions.item AND items.coolup <> 0 AND possessions.user = '$name'"; $res=mysql_query($sql, $db); $c=0; while ($cscore=mysql_fetch_array($res)) { $c=$c+$cscore["coolup"]; } return $c; } else { return 0; } } ?> And main.php looks like this: <?php error_reporting(E_ALL ^ E_NOTICE); ob_start(); include ("session.php"); if(isset($_SESSION["colourscheme"])) { $colour=$_SESSION["colourscheme"]; } else { $_SESSION["colourscheme"]=black; $colour="black"; } include ("connection.php"); include ("itemBonus.php"); function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } ?> <html> <head> <title>Hitmen - Welcome</title> <link REL="stylesheet" TYPE="text/css" href="<?php echo $colour."/"; ?>style.css"> </head> <body> <div id="body2" onClick="mnu_all_off()"> <?php if (isset($_POST["details"])) { $_SESSION["user"] = $_POST["user"]; $user=$_SESSION["user"]; $pass = $_POST["pass"]; $pass = md5($pass); $_SESSION["pass"]=$pass; } else { if (isset($_SESSION['user'])) { $user=$_SESSION["user"]; $pass=$_SESSION["pass"]; } } $sql = "SELECT * FROM `users` WHERE `name` = '$user'"; $userresult = mysql_query($sql,$db); if ($currentuser = mysql_fetch_array($userresult)) { $user=$currentuser["name"]; if ($pass == $currentuser["pass"]) { if ($currentuser["activated"]=="y") { $_SESSION["homeallowed"]="y"; $_SESSION["businessallowed"]="y"; $_SESSION["improveallowed"]="y"; $_SESSION["statusallowed"]="y"; $_SESSION["communityallowed"]="y"; if ((((mktime()+$timediff))>=($currentuser["wantedtime"]+7200)) && ($currentuser["wanted"] <> 0)) { $wanteddown=floor((((mktime()+$timediff))-$currentuser["wantedtime"])/7200); $nextwantedtime=($currentuser["wantedtime"]+($wanteddown*7200)); if (($currentuser["wanted"]-$wanteddown<=0)) { runSQL("UPDATE `users` SET `wanted`='0', `wantedtime`='$nextwantedtime' WHERE `name` = '$user'", $currentuser["admin"]); } else { runSQL("UPDATE `users` SET `wanted`=`wanted`-'$wanteddown', `wantedtime`='$nextwantedtime' WHERE `name` = '$user'", $currentuser["admin"]); } } if (isset($_POST["details"])) { if ($currentuser["actiontype"]=="flying") { $_SESSION["businessallowed"]="n"; $_SESSION["improveallowed"]="n"; $_SESSION["statusallowed"]="n"; header("location: flying.php"); } else if ($currentuser["actiontype"]=="jail") { $_SESSION["businessallowed"]="n"; $_SESSION["improveallowed"]="n"; $_SESSION["statusallowed"]="n"; header("location: jail.php"); } else if (substr($currentuser["actiontype"],0,5)=="train") { $_SESSION["businessallowed"]="n"; $_SESSION["improveallowed"]="n"; $_SESSION["flyallowed"]="n"; header("location: train.php"); } } else { if ($currentuser["actiontype"]=="flying") { $_SESSION["businessallowed"]="n"; $_SESSION["improveallowed"]="n"; $_SESSION["statusallowed"]="n"; } else if ($currentuser["actiontype"]=="jail") { $_SESSION["businessallowed"]="n"; $_SESSION["improveallowed"]="n"; $_SESSION["statusallowed"]="n"; } else if (substr($currentuser["actiontype"],0,5)=="train") { $_SESSION["businessallowed"]="n"; $_SESSION["improveallowed"]="n"; $_SESSION["statusallowed"]="n"; } } if ($currentuser["actiontype"]=="attempting") { header("Location: killuser.php?action=attacking"); } if ($currentuser["actiontype"]=="attempted") { header("Location: killuser.php?action=attacked"); } if ($currentuser["dead"]=="y") { header("location: dead.php"); } else { runSQL("UPDATE `users` SET `lastactive`='".(mktime()+$timediff)."', `ip` = '".$_SERVER["REMOTE_ADDR"]."' WHERE `name` = '$user'", $currentuser["admin"]); } if (($currentuser["actiontime"] + $currentuser["actionlength"]) < (mktime()+$timediff)) { if ($currentuser["actiontype"]=="flying") { header("location: flying.php"); } else if ($currentuser["actiontype"]=="jail") { header("location: jail.php"); } else if (substr($currentuser["actiontype"],0,5)=="train") { header("location: train.php"); } } //auto updating of fakelocos... $sql="SELECT * FROM `users` WHERE `fakelocotime`='$fakelocotime'"; if ($fakelocotime < ".((mktime()+$timediff)).") { runSQL("UPDATE `users` SET `fakeloco`= 'n' WHERE `fakelocotime` < '".((mktime()+$timediff))."'"); } //auto updating of ranks... runSQL("UPDATE `users` SET `rank` = 'N/A' WHERE `dead`='y' OR `activated`='n';", "y"); runSQL("UPDATE `users` SET `rank` = 'Admin' WHERE `admin`='y';", "y"); runSQL("TRUNCATE TABLE `scores`", "y"); $sql="SELECT * FROM `users` WHERE `activated`='y' AND `dead`='n' AND admin='n'"; $rankedresult=mysql_query($sql, $db); while ($rank=mysql_fetch_array($rankedresult)) { $name=$rank["name"]; $score=($rank["gunskill"]+$rank["hackskill"]+$rank["infoskill"]+$rank["smuggleskill"]+ makeBonus($name,"g",$db)+ makeBonus($name,"h",$db)+ makeBonus($name,"s",$db)+ makeBonus($name,"i",$db))*100; $score=$score+($cash/100000); $sql="SELECT * FROM `insurance` WHERE `user` = '$name'"; $insuranceresult=mysql_query($sql, $db); while ($ins=mysql_fetch_array($insuranceresult)) { $score=$score+($ins["amount"]/100000); } $sql="SELECT * FROM `possessions` WHERE `user` = '$name'"; $possessionsresult=mysql_query($sql, $db); $score=$score+(mysql_num_rows($possessionsresult)*75); while ($pos=mysql_fetch_array($possessionsresult)) { $sql="SELECT * FROM `items` WHERE `id`='".$pos["item"]."'"; $itemresult=mysql_query($sql, $db); while ($it=mysql_fetch_array($itemresult)) { $score=$score+($it["price"]/10000); if ($it["numleft"]<10) { $score=$score+(100/($it["numleft"]+1)); } } } $sql="SELECT * FROM `property` WHERE `user` = '$name'"; $propertyresult=mysql_query($sql, $db); $score=$score+(mysql_num_rows($propertyresult)*100); while ($prop=mysql_fetch_array($propertyresult)) { $score=$score+($prop["type"]*$prop["type"]*4); } $score=$score - 50*floor((mktime()+$timediff-$rank["lastactive"])/(3600*24)); runSQL("INSERT INTO `scores` (`name`, `score`) VALUES ('".$rank["name"]."', '$score')", "y"); } //auto updating of contracts... $sql="SELECT * FROM `contracts` WHERE `date` < '".date("Y-m-d", mktime (0,0,0,date("m") ,date("d"),date("Y")))."'"; $num = mysql_num_rows(mysql_query($sql,$db)); if ($num > 0) { runSQL("DELETE FROM `contracts` WHERE `date` < '".date("Y-m-d", mktime (0,0,0,date("m") ,date("d"),date("Y")))."'", "y");; for ($i=0; $i<$num; $i++) { for ($i=1; $i<=$num; $i++) { $sql="SELECT * FROM `cities`"; $citiesresult=mysql_query($sql, $db); $numcities=mysql_num_rows($citiesresult); mt_srand(make_seed()); $randcity=mt_rand(0,$numcities-1); $sql="SELECT * FROM `cities` LIMIT $randcity, 1"; $cityresult = mysql_query($sql,$db); if ($thecity = mysql_fetch_array($cityresult)) { $city=$thecity["name"]; $difficulty=$thecity["difficulty"]; } mt_srand(make_seed()); $tf=mt_rand(1,10); mt_srand(make_seed()); $sec=mt_rand(1,20); mt_srand(make_seed()); $tp=mt_rand(1,12); mt_srand(make_seed()); $dt=mt_rand(0,5); if ($difficulty==1) { if ($tf <=4) { $timeframe=3; } else if ($tf >4 && $tf <=7) { $timeframe=2; } else { $timeframe=1; } if ($sec <=5) { $security=1; } else if ($sec >5 && $sec <=10) { $security=2; } else if ($sec >10 && $sec <=14) { $security=3; } else if ($sec >14 && $sec <=17) { $security=4; } else { $security=5; } if ($tp ==1) { $type="Club"; $env="indoors"; $busy="busy"; } else if ($tp ==2) { $type="Office"; $env="indoors"; $busy="busy"; } else if ($tp ==3) { $type="Streets"; $env="open"; $busy="busy"; } else if ($tp ==4) { $type="Car"; $env="open"; $busy="busy"; } else if ($tp > 4 && $tp <=6) { $type="Home"; $env="indoors"; $busy="empty"; } else if ($tp > 6 && $tp <= { $type="Gym"; $env="indoors"; $busy="empty"; } else if ($tp > 8 && $tp <=10) { $type="Park"; $env="open"; $busy="empty"; } else { $type="Open Air"; $env="open"; $busy="empty"; } } else if ($difficulty==2) { if ($tf <=3) { $timeframe=3; } else if ($tf >3 && $tf <=6) { $timeframe=2; } else { $timeframe=1; } if ($sec <=3){ $security=1; } else if ($sec >3 && $sec <=7) { $security=2; } else if ($sec >7 && $sec <=13) { $security=3; } else if ($sec >13 && $sec <=17) { $security=4; } else { $security=5; } if ($tp ==1) { $type="Club"; $env="indoors"; $busy="busy"; } else if ($tp ==2) { $type="Office"; $env="indoors"; $busy="busy"; } else if ($tp ==3) { $type="Park"; $env="open"; $busy="empty"; } else if ($tp ==4) { $type="Open Air"; $env="open"; $busy="empty"; } else if ($tp > 4 && $tp <=6) { $type="Home"; $env="indoors"; $busy="empty"; } else if ($tp > 6 && $tp <= { $type="Gym"; $env="indoors"; $busy="empty"; } else if ($tp > 8 && $tp <=10) { $type="Streets"; $env="open"; $busy="busy"; } else { $type="Car"; $env="open"; $busy="busy"; } } else if ($difficulty==3) { if ($tf <=2) { $timeframe=3; } else if ($tf >2 && $tf <=4) { $timeframe=2; } else { $timeframe=1; } if ($sec <=9) { $security=5; } else if ($sec >9 && $sec <=13) { $security=4; } else if ($sec >13 && $sec <=17) { $security=3; } else if ($sec >17 && $sec <=19) { $security=2; } else { $security=1; } if ($tp ==1) { $type="Park"; $env="open"; $busy="empty"; } else if ($tp ==2) { $type="Open Air"; $env="open"; $busy="empty"; } else if ($tp ==3) { $type="Gym"; $env="indoors"; $busy="empty"; } else if ($tp ==4) { $type="Home"; $env="indoors"; $busy="empty"; } else if ($tp > 4 && $tp <=6) { $type="Club"; $env="indoors"; $busy="busy"; } else if ($tp > 6 && $tp <= { $type="Office"; $env="indoors"; $busy="busy"; } else if ($tp > 8 && $tp <=10) { $type="Streets"; $env="indoors"; $busy="busy"; } else { $type="Car"; $env="open"; $busy="busy"; } } $date=date("Y-m-d", mktime (0,0,0,date("m") ,date("d")+$dt,date("Y"))); if ($env=="indoors" && $busy=="busy") { $typediff=1.5; } else if ($env=="open" && $busy=="busy") { $typediff=1.4; } else if ($env=="indoors" && $busy=="empty") { $typediff=1.3; } else if ($env=="open" && $busy=="empty") { $typediff=1.2; } $diff=$security*(10/$timeframe); $diff=$diff*((10+$difficulty)/10)*$typediff; runSQL("INSERT INTO `contracts` (`id`, `difficulty`, `city`, `date`, `type`, `security`, `timeframe`) VALUES ('', '$diff', '$city', '$date', '$type', '$security', '$timeframe')", "y"); } } //also do ranking.... runSQL("TRUNCATE TABLE `scores`", "n"); $sql="SELECT * FROM `users` WHERE `activated`='y' AND `dead`='n'"; $rankedresult=mysql_query($sql, $db); while ($rank=mysql_fetch_array($rankedresult)) { $name=$rank["name"]; $score=($rank["gunskill"]+$rank["hackskill"]+$rank["infoskill"]+$rank["smuggleskill"]+ makeBonus($name,"g",$db)+ makeBonus($name,"h",$db)+ makeBonus($name,"s",$db)+ makeBonus($name,"i",$db))*100; $score=$score+($cash/100000); $sql="SELECT * FROM `insurance` WHERE `user` = '$name'"; $insuranceresult=mysql_query($sql, $db); while ($ins=mysql_fetch_array($insuranceresult)) { $score=$score+($ins["amount"]/100000); } $sql="SELECT * FROM `possessions` WHERE `user` = '$name'"; $possessionsresult=mysql_query($sql, $db); $score=$score+(mysql_num_rows($possessionsresult)*75); while ($pos=mysql_fetch_array($possessionsresult)) { $sql="SELECT * FROM `items` WHERE `id`='".$pos["item"]."'"; $itemresult=mysql_query($sql, $db); while ($it=mysql_fetch_array($itemresult)) { $score=$score+($it["price"]/10000); if ($it["numleft"]<10) { $score=$score+(100/($it["numleft"]+1)); } } } $sql="SELECT * FROM `property` WHERE `user` = '$name'"; $propertyresult=mysql_query($sql, $db); $score=$score+(mysql_num_rows($propertyresult)*100); while ($prop=mysql_fetch_array($propertyresult)) { $score=$score+($prop["type"]*$prop["type"]*4); } $score=$score - 50*floor((mktime()+$timediff-$rank["lastactive"])/(3600*24)); runSQL("INSERT INTO `scores` (`name`, `score`) VALUES ('".$rank["name"]."', '$score')", "n"); } if (mysql_num_rows($rankedresult)>0) { $sql="SELECT * FROM `scores` ORDER BY `score` DESC"; $scoresresult=mysql_query($sql, $db); $i=1; while ($score=mysql_fetch_array($scoresresult)) { runSQL("UPDATE `users` SET `rank`='$i' WHERE `name` = '".$score["name"]."'", "n"); $i++; } } } include ("top.php"); echo " <table width=750 class=\"collapsed\">\n"; echo " <tr class=\"tb_border\">\n"; echo " <td colspan=3></td>\n"; echo " </tr>\n"; echo " <tr valign=top>\n"; echo " <td width=10 class=\"border\">\n"; echo " </td>\n"; echo " <td width=730 class=\"normal\">\n"; echo " <b><i>CRIMINAL UNDERWORLD ON THE RISE</i></b><br>\n"; echo " <i>Reuters</i><br><br>\n"; echo " A REPORT RELEASED by Interpol today shines light on the ever-growing underworld of<br>\n"; echo " contract killers, drug dealers, gun runners and computer hackers. Interpol's Secretary General,<br>\n"; echo " Robert Noble, said in a press conference today that the members of this criminal underworld are<br>\n"; echo " ''almost impossible to trace'', and that the findings of the report were ''just the tip of the<br>\n"; echo " iceberg''.<br><br>\n"; echo " <i>OUT OF CONTROL</i><br><br>\n"; echo " Mr. Noble also revealed that Interpol does not have a definite list of wanted criminals due to<br>\n"; echo " the loose structure of the underground, which has spread all over the globe. ''The vastness of this<br>\n"; echo " criminal empire is staggering. We have followed leads in various cities across the world, from the United States<br>\n"; echo " to Europe to the Middle East and beyond. We believe the structure is based loosely on international drug routes<br>\n"; echo " but the true nature and intents of the secret underground world has yet to be revealed''.<br><br>\n"; echo " <i>A LAW UNTO THEMSELVES</i><br><br>\n"; echo " The report also details the range and severity of crimes Interpol have attached to members of the crime ring, from<br>\n"; echo " hacking government databases and bank accounts, to smuggling weapons and drugs across the globe, to contract<br>\n"; echo " killing.''These criminals have no regard for law and order. They are a law unto themselves, and through our own<br>\n"; echo " total focus on anti-terrorism operations in the Middle East and beyond this underworld has been allowed to spread it's<br>\n"; echo " influence across the world''...<br><br>\n"; echo " <b>Welcome to Hitmen, $user.</b><br>\n"; echo " <td width=10 class=\"border\">\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr class=\"tb_border\">\n"; echo " <td colspan=3></td>\n"; echo " </tr>\n"; echo " </table>\n"; include ("bottom.php"); } else { $_SESSION["message"]="4"; header("location: index.php"); } } else { $_SESSION["message"]="2"; header("location: index.php"); } } else { $_SESSION["message"]="3"; header("location: index.php"); } ?> I'd really appreciate any advice as to why this page has suddenly decided to act up. The database is exactly the same so I can only assume it's the server. If any more information is needed please let me know, and I apologise for posting the entire page but I'm not sure what is not needed and what is. Thanks! Link to comment https://forums.phpfreaks.com/topic/184149-strange-call-to-undefined-function-error/ Share on other sites More sharing options...
oni-kun Posted December 6, 2009 Share Posted December 6, 2009 <? error_reporting(E_ALL ^ E_NOTICE); function makeBonus($name, $bonustofind, $db) Not a single of my WAMP servers are configured to use short tags by default. Try switching them to "<?php". This is all I can see so far, and would explain the comment being echo'd atleast. (where is the comment btw? I don't see it in what you displayed, that should be relevant code.) Link to comment https://forums.phpfreaks.com/topic/184149-strange-call-to-undefined-function-error/#findComment-972239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.