Dethman Posted November 6, 2009 Share Posted November 6, 2009 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /home/crikeyga/public_html/ulc/cron2.php on line 268 here is the cron file I am not sure whats going on? <?php include ("clib/clib1.php"); function deleteAtack($id){ $str = "DELETE FROM `AtackLog` WHERE ID='$id'"; //echo $str; $q = mysql_query($str); } function deleteOldAtacks(){ $time=time()-$conf["days_to_hold_logs"]*24*60*60; $str="DELETE FROM `AtackLog` where time<'$time'"; } function deleteAtacksOfUser($userID){ $str = "DELETE FROM `AtackLog` WHERE userID='$userID'"; //echo $str; $q = mysql_query($str); } function deleteIP($id){ $str = "DELETE * FROM `IPs` WHERE userID='$id'"; //echo $str; $q = mysql_query($str); if (!$q) {print ('Query failed: '.mysql_error()); return; } } function deleteIPByIP($ip){ $str = "DELETE FROM `IPs` WHERE ip='$ip'"; //echo $str; $q = mysql_query($str); if (!$q) {print ('Query failed: '.mysql_error()); return; } } function deleteIPByID($id){ $str = "DELETE FROM `IPs` WHERE ID='$id'"; //echo $str; $q = mysql_query($str); if (!$q) {print ('Query failed: '.mysql_error()); return; } } function deleteUserWeapon($id,$weaponID=""){ if ($weaponID ){$str2=" AND weaponID='$weaponID' ";} $str = "DELETE FROM `Weapon` WHERE userID='$id' $str2"; //echo $str; $q = mysql_query($str); if (!$q) {print ('Query failed: '.mysql_error()); return; } } function deleteUser($id){ $str = "DELETE FROM `UserDetails` WHERE ID='$id'"; //echo $str; $q = mysql_query($str); $str = "DELETE FROM `Ranks` WHERE userID='$id'"; $q = mysql_query($str); deleteUserWeapon($id); deleteIP($id); deleteAtacksOfUser($id); deleteSpyLogsOfUser($id); deleteMessagesOfUser($id); $str = "update `UserDetails` set commander=0 WHERE commander='$id' "; $q = mysql_query($str); /* if (!$q) { print ('Query failed: '.mysql_error()); return; }*/ } function deleteOldUsers(){ $users=getOldUsers(); //echo 1; for ($i=0;$i<count($users);$i++){ if (($users[$i]['active']==1)||((!$users[$i]['active']))) deleteUser($users[$i]['ID']); } //echo 2; } function setLastTurnTime($date){ updateMercenary(" lastTurnTime = '$date' "); } function updateMercenary($str){ $str = "update `Mercenaries` set $str "; //echo "$str<br>"; $q = mysql_query($str); if (!$q) { print ('Query failed: '.mysql_error()); return; } } function getUserWeapon($user){ $str="SELECT * FROM `Weapon` Where isAtack='1' and userID='{$user['ID']}' ORDER BY `weaponStrength` DESC "; //print $str; $q = mysql_query($str); if (!$q) { print ('Query failed: '.mysql_error()); return; } if (!mysql_num_rows($q)) { return; } else{ $st=""; $i=0; while ($row = mysql_fetch_array($q)){ $st[$i]=$row; $i++; } return $st; } } function getOldUsers(){ global $conf; $time=time()-$conf["days_of_inactivity_before_delete_this_user"]*24*60*60; $str="SELECT ID, active FROM `UserDetails` where lastTurnTime<'$time'"; //alert($str); $q = mysql_query($str); if (!$q) {print ('Query failed: '.mysql_error()); return; } if (!mysql_num_rows($q)) {return;} else{ $st=""; $i=0; while ($row = mysql_fetch_array($q)){ $st[$i]=$row; $i++; } return $st; } } function getActiveUsers($fields="*"){ $str="SELECT $fields FROM `UserDetails` WHERE active='1'"; //print $str; $q = @mysql_query($str); if (!$q) {print ('Query failed: '.mysql_error()); return; } if (!@mysql_num_rows($q)) {return;} else{ $st=""; $i=0; while ($row = mysql_fetch_array($q)){ $row['untrainedSold']=floor($row['untrainedSold']); $st[$i]=$row; $i++; } return $st; } } function getWeaponAllocation($user,$weaponA,$trainedCount,$untrainedCount){ if (count($weaponA)>$trainedCount){ $trainedW=$trainedCount; $untrainedUnW=$untrainedCount-count($weaponA)+$trainedW; if ($untrainedUnW<0)$untrainedUnW=0; $untrainedW=$untrainedCount-$untrainedUnW; $trainedUnW=0; }else{ $trainedW=count($weaponA); $untrainedW=0; $trainedUnW=$trainedCount-$trainedW; $untrainedUnW=$untrainedCount; } if ($untrainedW<0)$untrainedW=0; $wepAlloc["trainedW"]=$trainedW; $wepAlloc["untrainedUnW"]=$untrainedUnW; $wepAlloc["untrainedW"]=$untrainedW; $wepAlloc["trainedUnW"]=$trainedUnW; return $wepAlloc; } function getWeaponArray($weaponA1){ $k=0; for ($i=0;$i<count($weaponA1);$i++){ for ($j=0; $j<$weaponA1[$i]['weaponCount'];$j++){ $weaponA[$k]=$weaponA1[$i]; $k++; } } return $weaponA; } function getStrikeAction($user){ global $conf; $num=0; $trainedCount=$user['trainedAttackSold']+$user['trainedAttackMerc']; $untrainedCount=$user['untrainedMerc']+$user['untrainedSold']; $weaponA1=getUserWeapon($user); if (!count($weaponA1)&&!$trainedCount) return 0; /*$k=0; for ($i=0;$i<count($weaponA1);$i++){ for ($j=0; $j<$weaponA1[$i]->weaponCount ;$j++){ $weaponA[$k]=$weaponA1[$i]; $k++; } }*/ $weaponA=getWeaponArray($weaponA1); if ($weaponA){ $wepAlloc=getWeaponAllocation($user,$weaponA,$trainedCount,$untrainedCount); $wI=0; for ($i=0; $i<$wepAlloc["trainedW"];$i++,$wI++){ $num+=$weaponA[$wI]['weaponStrength']*5; } for ($i=0; $i<$wepAlloc["untrainedW"];$i++,$wI++){ $num+=$weaponA[$wI]['weaponStrength']*4; } }else{ $wepAlloc["trainedUnW"]=$trainedCount; $wepAlloc["untrainedUnW"]=$untrainedCount; } $num+=$wepAlloc["trainedUnW"]*5; $num+=$wepAlloc["untrainedUnW"]*4; for ($i=0; $i<=$user['siegeLevel'];$i++){ if ($conf["race"][$user['race']]["siege"][$i]["attack"]){ $num+=round(($num*$conf["race"][$user['race']]["siege"][$i]["attack"])/100); } } if ($conf["race"][$user['race']]["attack"]){ $num+=round(($num*$conf["race"][$user['race']]["attack"])/100); } return $num; } function getUserIncome($user){ global $conf; $income=0; $income+=$user['trainedAttackSold']; $income+=$user['trainedDefSold']; $income+=$user['untrainedSold']; $income*=$conf["gold_from_soldier"]; if ($conf["race"][$user['race']]["income"]){ $income+=round(($income*$conf["race"][$user['race']]["income"])/100); } return $income; } function getDefUserWeapon($user){ $str="SELECT * FROM `Weapon` Where isAtack='0' and userID='{$user['ID']}' ORDER BY `weaponStrength` DESC"; //print $str; $q = mysql_query($str); if (!$q) { print ('Query failed: '.mysql_error()); return; } if (!mysql_num_rows($q)) { return; } else{ $st=""; $i=0; while ($row = mysql_fetch_array($q)){ $st[$i]=$row; $i++; } return $st; } } function getDefenseAction($user){ global $conf; $num=0; $trainedCount=$user['trainedDefSold']+$user['trainedDefMerc']; $untrainedCount=$user['untrainedMerc']+$user['untrainedSold']; $weaponA1=getDefUserWeapon($user); if (!count($weaponA1)&&!$trainedCount) return 0; $k=0; for ($i=0;$i<count($weaponA1);$i++){ for ($j=0; $j<$weaponA1[$i]['weaponCount'] ;$j++){ $weaponA[$k]=$weaponA1[$i]; $k++; } } if ($weaponA){ $wepAlloc=getWeaponAllocation($user,$weaponA,$trainedCount,$untrainedCount); $wI=0; for ($i=0; $i<$wepAlloc["trainedW"];$i++,$wI++){ $num+=$weaponA[$wI]['weaponStrength']*5; } for ($i=0; $i<$wepAlloc["untrainedW"];$i++,$wI++){ $num+=$weaponA[$wI]['weaponStrength']*4; } }else{ $wepAlloc["trainedUnW"]=$trainedCount; $wepAlloc["untrainedUnW"]=$untrainedCount; } $num+=$wepAlloc["trainedUnW"]*5; $num+=$wepAlloc["untrainedUnW"]*4; for ($i=0; $i<=$user['fortificationLevel'] ;$i++){ if ($conf["race"][$user['race']]["fortification"][$i]["defence"]){ $num+=round(($num*$conf["race"][$user['race']]["fortification"][$i]["defence"])/100); } } if ($conf["race"][$user['race']]["defend"]){ $num+=round(($num*$conf["race"][$user['race']]["defend"])/100); } return $num; } function getCovertAction($user){ global $conf; $num=0; if (!$user['spies']){return 0;} $num=round($user['spies']*pow(2,$user['currentSpySkill'])); if ($conf["race"][$user['race']]["spy"]){ $num+=round(($num*$conf["race"][$user['race']]["spy"])/100); } return $num; } function setWeapon($id,$fields){ $str = "update `Weapon` set $fields WHERE ID='$id' "; //echo "$str<br>"; $q = mysql_query($str); if (!$q) { print ('Query failed: '.mysql_error()); return; } } function updateUser($id, $str){ $str = "update `UserDetails` set $str WHERE ID='$id' "; //echo "$str<br>"; $q = mysql_query($str); if (!$q) { print ('Query failed: '.mysql_error()); return; } return $q; } function setUserRank($id, $rank, $strikeActionRank, $defenceActionRank ,$covertActionRank ){ $str = "update `Ranks` set rank='$rank' , strikeActionRank='$strikeActionRank', defenceActionRank='$defenceActionRank', covertActionRank='$covertActionRank' WHERE userID='$id' "; //echo "$str<br>"; //return; $q = mysql_query($str); if (!$q) { print ('Query failed: '.mysql_error()); return; } } ?> Thank you for any help. Link to comment https://forums.phpfreaks.com/topic/180494-fatal-error-allowed-memory-size-of-134217728-bytes-exhausted/ Share on other sites More sharing options...
JJ2K Posted November 6, 2009 Share Posted November 6, 2009 Could be a never-ending loop, but of a wild stab but try echoing out: count($weaponA1) $weaponA1[$i]['weaponCount'] What values do they hold? Or what is on line 268? Link to comment https://forums.phpfreaks.com/topic/180494-fatal-error-allowed-memory-size-of-134217728-bytes-exhausted/#findComment-952186 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.