Jump to content

Dethman

Members
  • Posts

    182
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.NimbusGames-llc.com

Profile Information

  • Gender
    Not Telling

Dethman's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Thank you very much it is now working
  2. Ok here is all of my code first off. Javascript: <script> function login() { var user = document.getElementById("user"); var pass = document.getElementById("pass"); // Set up request varible try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { alert("Error: Could not load page.");} //Show page is loading document.getElementById("login_error").innerHTML = 'Logging In<BR /><img src="img/ajax-loader2.gif">'; //scroll to top scroll(0,0); //send data xmlhttp.onreadystatechange = function(){ //Check page is completed and there were no problems. if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { //Write data returned to page var resp = xmlhttp.responseText; if(resp == "loggedin"){ window.location = "base.php"; }else{ document.getElementById("login_error").innerHTML = xmlhttp.responseText; } } } xmlhttp.open("GET", "login.php?user=" + user + "&pass=" + pass + ""); xmlhttp.send(null); //Stop any link loading normaly return false; } </script> Login Form: <TABLE class=small style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 5px; PADDING-TOP: 0px" width=130 align=center> <TBODY> <TR> <TD align=middle style="color:red;"><div id="login_error"></div></TD> </TR> <TR> <TD align=middle><FONT color=black><img src="img/user.gif"></FONT></TD></TR> <TR> <TD align=middle><INPUT class=login_input name="user" id="user" style="background:#fff;color:#000;"></TD></TR> <TR> <TD align=middle><FONT color=black><img src="img/pass.gif"></FONT></TD></TR> <TR> <TD align=middle><INPUT class=login_input style="background:#fff;color:#000;" type=password name="pass" id="pass"></TD></TR> <TR> <TD style="PADDING-TOP: 5px" align=middle><INPUT class=login_input style="WIDTH: 50px; background:#fff;color:#000;cursor:pointer;" type="submit" value=Login onclick="javascript:login()"></TD></TR> </TBODY></TABLE> PHP File login.php: <?php include "vsys.php"; // Database Connection Script /* Login.php */ function cleanuserinput($dirty){ if (get_magic_quotes_gpc()) { $clean = mysql_real_escape_string(stripslashes($dirty)); }else{ $clean = mysql_real_escape_string($dirty); } return $clean; } if(isset($_GET['user'])){ if(isset($_GET['pass'])){ $user = cleanuserinput($_GET['user']); $pass = cleanuserinput($_GET['pass']); $res = mysql_query("SELECT `ID` FROM `UserDetails` WHERE `userName` = '$user' AND `password` = '$pass'") or die("Error:<BR />".mysql_error()); $count = mysql_num_rows($res); $row = mysql_fetch_array($res); if($row['ID'] == ""){ die("Invalid Username or Password!"); }else{ $_SESSION["isLogined"] = $row['ID']; die ("loggedin"); } } } ?> Ok If I type in the correct user and pass thru the form it still dies Invalid Username and Pass If I do it like so "http://localhost/login.php?user=Brian&pass=mypass it actually sets the session and dies loggedin. For some reason the ajax is not sending the correct information to the php file. If anyone out there can help that would be good! also to the mods on the forums, I am not sure if this should be posted in javascript help if so please move this to wherever need. Thank you, Brian
  3. 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.
  4. This script is supposed to Train Troops for an army based MMORPG. Train Page: <TABLE width="100%"> <TBODY> <TR> <TD style="PADDING-RIGHT: 25px" vAlign=top width="50%"> <TABLE id="UserInfo" style="background:#000000;" class=table_lines cellSpacing=0 cellPadding=6 width="100%" border=0> <TBODY> <TR> <TH class="subhr" colSpan=2>Personnel</TH></TR> <TR> <TD><B>Trained Attack Soldiers</B></TD> <TD align=right><? numecho ($user->trainedAttackSold)?></TD></TR> <TR> <TD><B>Trained Attack Mercenaries</B></TD> <TD align=right><? numecho ($user->trainedAttackMerc)?></TD></TR> <TR> <TD><B>Trained Defense Soldiers</B></TD> <TD align=right><? numecho ($user->trainedDefSold)?></TD></TR> <TR> <TD><B>Trained Defense Mercenaries</B></TD> <TD align=right><? numecho ($user->trainedDefMerc) ?></TD></TR> <TR> <TD><B>Untrained Soldiers</B></TD> <TD align=right><? numecho ($user->untrainedSold) ?></TD></TR> <TR> <TD><B>Untrained Mercenaries</B></TD> <TD align=right><? numecho ($user->untrainedMerc) ?></TD></TR> <TR> <TD class=subh><B>Spies</B></TD> <TD class=subh align=right><? numecho ($user->spies) ?></TD></TR> <TR> <TD><B>Total Fighting Force</B></TD> <TD align=right><? numecho (getTotalFightingForce($user))?></TD></TR></TBODY></TABLE><BR></TD> <TD vAlign=top width="50%"> <TABLE class=table_lines id="UserInfo" style="background:#000000;" cellSpacing=0 cellPadding=6 width="100%" border=0> <TBODY> <TR> <TH class="subhr" align=middle colSpan=3>Train Your Troops</TH></TR> <TR> <TH class="subhr" align=left>Training Program</TH> <TH class="subhr" align=right>Cost Per Unit</TH> <TH class="subhr">Quantity</TH></TR> <TR> <TD>Attack Specialist</TD> <TD align=right>2,000 Plasma</TD> <TD align=middle><INPUT size=5 value=0 name=atsold id="atsold"></TD></TR> <TR> <TD>Defense Specialist</TD> <TD align=right>2,000 Plasma</TD> <TD align=middle><INPUT size=5 value=0 name=defsold id="defsold"></TD></TR> <TR> <TD>Spy</TD> <TD align=right>3,500 Plasma</TD> <TD align=middle><INPUT size=5 value=0 name=spy id="spy"></TD></TR> <TR> <TD>Reassign Attack Specialist</TD> <TD align=right>0 Plasma</TD> <TD align=middle><INPUT size=5 value=0 name=reat id="reat"></TD></TR> <TR> <TD>Reassign Defense Specialist</TD> <TD align=right>0 Plasma</TD> <TD align=middle><INPUT size=5 value=0 name=redef id="redef"></TD></TR> <TR> <TD align=middle colSpan=3 align="center"> <div id="respondeID"></div> <input type="hidden" id="plasma" value="56000000"> <input type="hidden" id="tritainium" value="45000000"> <a href="javascript:trainTroops();" class="tooltip" title="Here you can buy a flagship in which you can upgrade and use in a lengthy battle.">Train Troops</a> </TD></TR></TBODY></TABLE><BR></TD></TR> Train ajax Included Header File: function getXMLHttp() { var xmlHttp try { //Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch(e) { //Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Your browser does not support AJAX!") return false; } } } return xmlHttp; } function trainTroops() { var xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { HandleResponseTrain(xmlHttp.responseText); } } var atsold = document.getElementById("atsold").value; var defsold = document.getElementById("defsold").value; var spy = document.getElementById("spy").value; var reat = document.getElementById("reat").value; var redef = document.getElementById("redef").value; xmlHttp.open("GET", "train2.php?&atsold=" + atsold + "&defsold=" + defsold + "&spy= " + spy + "&reat= " + reat + "&redef= " + redef, true); xmlHttp.send(null); } function HandleResponseTrain(response) { document.getElementById('respondeID').innerHTML = response; } Php File train2.php: <?php include "../vsys.php"; $user=getUserDetails($_SESSION['isLogined'],"*"); if($_GET['train']){ if($_GET['atsold']){ $wal=$_GET['atsold'];$typ=0; $detail.=Train($user,$wal,$typ); } if($_GET['defsold']){ $wal=$_GET['defsold'];$typ=1; $detail.=Train($user,$wal,$typ); } if($_GET['spy']){ $wal=$_GET['spy'];$typ=2; $detail.=Train($user,$wal,$typ); } if($_GET['reat']){ $wal=$_GET['reat'];$typ=3; $detail.=Train($user,$wal,$typ); } if($_GET['redef']){ $wal=$_GET['redef'];$typ=4; $detail.=Train($user,$wal,$typ); } //echo "--$typ--"; die($detail); } ?> Train Function Inside vsys.php it is too lengthy to post: function Train($user,$wal,$type) { $nogold="Not enough plasma!"; $nosold="Not enough untrained colonists!"; if($type==0){ $pris=2000*$wal; if($pris <= ($user->gold)){ $q = @mysql_query("select untrainedSold from `UserDetails` where ID='$user->ID' "); $el=mysql_fetch_array($q, MYSQL_ASSOC); if($el[untrainedSold]>=$wal){ $q = @mysql_query("update `UserDetails` set trainedAttackSold=trainedAttackSold+'$wal', untrainedSold=untrainedSold-'$wal', gold=gold-'$pris' where ID='$user->ID' "); if (!$q) {print ('Query failed: '.mysql_error()); return; } }else return $nosold; } else return $nogold; } elseif($type==1){ $pris=2000*$wal; if($pris <= ($user->gold)){ $q = @mysql_query("select untrainedSold from `UserDetails` where ID='$user->ID' "); $el=mysql_fetch_array($q, MYSQL_ASSOC); if($el[untrainedSold]>=$wal){ $q = @mysql_query("update `UserDetails` set trainedDefSold=trainedDefSold+'$wal', untrainedSold=untrainedSold-'$wal', gold=gold-'$pris' where ID='$user->ID' "); if (!$q) {print ('Query failed: '.mysql_error()); return; } }else return $nosold; } else return $nogold; } elseif($type==2){ $pris=3500*$wal; if($pris <= ($user->gold)){ $q = @mysql_query("select untrainedSold from `UserDetails` where ID='$user->ID' "); $el=mysql_fetch_array($q, MYSQL_ASSOC); if($el[untrainedSold]>=$wal){ $q = @mysql_query("update `UserDetails` set spies=spies+'$wal', untrainedSold=untrainedSold-'$wal', gold=gold-'$pris' where ID='$user->ID' "); if (!$q) {print ('Query failed: '.mysql_error()); return; } }else return $nosold; } else return $nogold; } elseif($type==3){ $q = @mysql_query("select trainedAttackSold from `UserDetails` where ID='$user->ID' "); $el=mysql_fetch_array($q, MYSQL_ASSOC); if($el[trainedAttackSold])$q = @mysql_query("update `UserDetails` set trainedAttackSold=trainedAttackSold-'$wal', untrainedSold=untrainedSold+'$wal' where ID='$user->ID' "); } elseif($type==4){ $q = @mysql_query("select trainedDefSold from `UserDetails` where ID='$user->ID' "); $el=mysql_fetch_array($q, MYSQL_ASSOC); if($el[trainedDefSold])$q = @mysql_query("update `UserDetails` set trainedDefSold=trainedDefSold-'$wal', untrainedSold=untrainedSold+'$wal' where ID='$user->ID' "); } } You should not need the getUserDetails function. Ok the problem that I have here is that it simply does nothing, no error in error console, no training of troops, no php error, it just does nothing any help with this could be amazing! Please Reply asap, Brian Flores
  5. here is the function it deals with I will mark line 55 for you function do_option() { var xmlHttp = getXMLHttp(); var id = document.getElementById("id").value; xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { handle_option(xmlHttp.responseText); } } var option = document.getElementById("options").value; xmlHttp.open("GET", "option_js.php?option=" + option + "", true); xmlHttp.send(null); } function handle_option(type){ // LINE 55 document.getElementById('abottomPart').innerHTML = type; } If anyone could explain to me why this error is appearing it would be great, Thank you for your views
  6. Ok I got this Error: Fatal error: Out of memory line 192 Here is the file. 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++){ // This is the Line! $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; } The only problem is that I did not wright this function it was with the script, now if anyone can take a look at see if there is a simple fix or if someone could take a look to make sure the code is right or if someone could make this same function but on a 64M memory allocation, here is the entire file incase you need a full reference, <?php include ("clib/clib1.php"); 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_object($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_object($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_object($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_object($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; } } ?> Thanks for any help with this.
  7. Update on Code, it still does not work but I belive I am getting closer to a solution the problem with this code is that it creates another input box on a close but different part of the page worse yet it says "NaN Gold" Instead of a Number like it should say, well anyhow here is the code: Javascript: <SCRIPT language=javascript type=text/javascript> function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } function addCovertLevel() { var levelsUp, price, fullPrice, goldOnhand; levelsUp = document.getElementById('lvlup'); goldOnhand = document.getElementById('goldOnhand'); price = document.getElementById('price'); fullPrice = ( levelsUp * price ); if(fullPrice > goldOnhand){ document.getElementById('spyUpgradeDiv').innerHTML = "<TD><INPUT type=submit id='spyUpgrade' size='5' style='color:red;' value='Not Enough Gold' name=nogo></TD>"; }else{ document.getElementById('spyUpgradeDiv').innerHTML = "<TD><INPUT type=submit id='spyUpgrade' size='5' style='color:green;' value='"+addCommas(fullPrice)+" Gold' name='spyupgrade'></TD>"; } } </SCRIPT> HTML/PHP: <TR> <TD style="PADDING-RIGHT: 25px" vAlign=top> <FORM action=train.php method=post> <TABLE class=table_lines cellSpacing=0 cellPadding=6 width="100%" border=0> <TBODY> <TR> <TH align=middle colSpan=4>Upgrade Spy Skill</TH></TR> <TR> <TR><TD class=subh>Current Spy Skill</TD><TD>Level <? echo $user->currentSpySkill?></TD></TR> <TR><TD class=subh>Ammount</TD> <TD><input type="text" name="lvlup" value="1" id="lvlup" size="5" onchange="addCovertLevel()"></TD></TR> <TR><TD class=subh>Upgrade</TD> <b> <?php $goldOnhand = $user->gold; $prise = ($user->currentSpySkill*12000); ?> <input type="hidden" name="price" value="<? echo $prise;?>" id="price"> <input type="hidden" name="goldOnhand" value="<? echo $goldOnhand;?>" id="goldOnhand"> <div id="spyUpgradeDiv"> <TD> <INPUT type=submit id="spyUpgrade" size=5 style="color:<?if($price > $goldOnhand){echo 'red';}else{echo 'green';}?>" value="<? echo numecho($prise);?> Gold" name=spyupgrade> </TD> </div> </TR> </TR>
  8. Hello, I have been working on this for an hour and am getting frustrated, when the user types into the input box the amount of levels he/she wishes to advance the script will take the price per level and multiply by the amount typed, and then display it in the value of a submit box, please help with the code, I am confuzed and puzzled by why it is not working, my code is below, thank you to whomever counsels this code. Javascript: <SCRIPT language=javascript type=text/javascript> function addCovertLevel() { var levelsUp, price, fullPrice; levelsUp = document.getElementById('lvlup'); price = document.getElementById('price'); fullPrice = ( levelsUp * price ); document.getElementById('spyUpgrade').value = ""+fullPrice+" Gold"; } </SCRIPT> HTML/PHP: <TR> <TD style="PADDING-RIGHT: 25px" vAlign=top> <FORM action=train.php method=post> <TABLE class=table_lines cellSpacing=0 cellPadding=6 width="100%" border=0> <TBODY> <TR> <TH align=middle colSpan=4>Upgrade Spy Skill</TH></TR> <TR> <TR><TD class=subh>Current Spy Skill</TD><TD>Level <? echo $user->currentSpySkill?></TD></TR> <input type="hidden" name="price" value="<? echo $pris = ($user->currentSpySkill*12000);?>" id="price"> <TR><TD class=subh>Ammount</TD> <TD><input type="text" name="lvlup" value="0" id="lvlup" size="5" onchange="addCovertLevel();"></TD></TR> <TR><TD class=subh>Upgrade</TD> <b><TD><INPUT type=submit id="spyUpgrade" size=5 style="color:green;" value="0 Gold" name=spyupgrade></TD></TR> </TR>
  9. here is the error: Unknown column 'e_mail' in 'where clause'INSERT INTO `AccountDetails` (userName,race,e_mail,password,commander,active,uniqueLink) VALUES ('El Presidente','0','brianflores@ultimateconquest.com','00749359','','0','ug1255310986') here is the code, any help would be cool, function createUser($userName,$race,$e_mail,$password,$commander,$active=0,$uniqueLink="",$fortificationLevel=0,$siegeLevel=0, $gold=2800,$lastTurnTime=0,$attackTurns=17,$currentUnitProduction=0,$currentSpySkill=0, $trainedAttackSold=0,$trainedAttackMerc=0,$trainedDefSold=0,$trainedDefMerc=0,$untrainedSold=1,$untrainedMerc=0,$spies=0){ if (!$lastTurnTime){$lastTurnTime=time();} $uniqueLink=genUniqueLink(); $str = "INSERT INTO `AccountDetails` (userName,race,e_mail,password,commander,active,uniqueLink) VALUES ('$userName','$race','$e_mail','$password','$commander','$active','$uniqueLink')"; echo "$str<br>"; $q = @mysql_query($str); if (!$q) { print ('Query failed 1: '.mysql_error()); return; } $us=getUserDetailsByName($userName); $userID=$us->ID; $str2 = "INSERT INTO `UserDetails` (fortificationLevel,siegeLevel, gold,lastTurnTime,attackTurns,currentUnitProduction,currentSpySkill, trainedAttackSold,trainedAttackMerc,trainedDefSold,trainedDefMerc,untrainedSold,untrainedMerc,spies,ownerID) VALUES ('$fortificationLevel','$siegeLevel', '$gold','$lastTurnTime','$attackTurns','$currentUnitProduction','$currentSpySkill', '$trainedAttackSold','$trainedAttackMerc','$trainedDefSold','$trainedDefMerc','$untrainedSold','$untrainedMerc','$spies','$userID')"; $q = @mysql_query($str2); if (!$q) { print ('Query failed 2: '.mysql_error()); return; } $str= "INSERT INTO `Ranks` (userID) VALUES ('$userID') "; $q = @mysql_query($str); return $q; } Thanks for any help I cannot figure out why is gives that error.
  10. Does anyone know what I put in the minute box in the cron jobs section of Cpanel for 30 minutes?
  11. No, I still dont see anything wrong, but I wrote it a different way and solved it.
  12. Here is my Error please help, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '','0','nimbusgames@hotmail.com','83694713','','0','sc1254809263')' at line 1 Here is my Code. $str2 = "INSERT INTO `AccountDetails` (userName,race,e_mail,passwprd,commander,active,uniqueLink) VALUES ($userName','$race','$e_mail','$password','$commander','$active','$uniqueLink')"; $str = "INSERT INTO `UserDetails` (fortificationLevel,siegeLevel,gold,lastTurnTime,attackTurns,currentUnitProduction,currentSpySkill,trainedAttackSold,trainedAttackMerc,trainedDefSold,trainedDefMerc,untrainedSold,untrainedMerc,spies,owner) VALUES ('$fortificationLevel','$siegeLevel','$gold','$lastTurnTime','$attackTurns','$currentUnitProduction','$currentSpySkill','$trainedAttackSold','$trainedAttackMerc','$trainedDefSold','$trainedDefMerc','$untrainedSold','$untrainedMerc','$spies','$accontID')"; $q = @mysql_query($str2); if (!$q) { print ('Query failed: '.mysql_error()); return; } $us=getAccountByName($userName); $accountID=$us->ID; $q = @mysql_query($str); if (!$q) { print ('Query failed: '.mysql_error()); return; } Any Help would be Nice
  13. Well there are a number of ways you could do it, but trust me it might be lengthy. First you could assign all paragraphs and words of the site to an array and when the button is clicked switch the innerHTML to the word(s) or paragraph(s) wanted. Hope this helps, Brian.
  14. Ive tested this and it did not work can someone please fill me in on why it did not work? <html><!-- #BeginTemplate "/Templates/template.dwt" --> <head> <!-- #BeginEditable "doctitle" --> <title>Pro Flo X-Treme Clean, Inc. - SET Administration Cookie.</title> <!-- #EndEditable --> <link href="styles.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> var cookie_date = new Date ( 2012, 01, 01 ); document.cookie = "administrator=yes; firstName=Brian; lastName=Flores; email=brianflores@xtremeclean.com; expires=" + cookie_date.toGMTString(); var cookie = document.cookie; if( administrator ){ location.href="index.htm"; } </script> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#06780e"> </body> <!-- #EndTemplate --></html>
  15. Here is my Code : <script type="text/javascript" language="javascript"> function change(page){ if(page = 1){ document.getElementById('webpage').innerHTML = '<p class="title">Welcome to Pro Flo X-treme Clean, Inc.</p> <p class="text">Below is a List of What we do.</p> <ul class="bullet"> <li class="text">Carpet Cleaning<br> </li> <li>Red Spot Removal<br> </li> <li class="text">Carpet Repair and Re-installation<br> </li> <li class="text">Oreintal Rugs</li> </ul> <p class="text">Certified By The IICRC!</p> <p class="text">The IICRC is a non-profit certification institute that operates certification programs for the restoration, cleaning and inspection industries. For example, the IICRC has certification programs in the restoration industry for water damage restoration, fire damage restoration and even the specialties like mold remediation or odor control aswell as carpet cleaning or upholstery cleaning, hard surface floor cleaning, and ceramic tile cleaning .</p>'; } if(page = 2){ document.getElementById('webpage').innerHTML = '<p class="title">About Us</p> <p class="text">We are a certified firm...</p>'; } } </script> My Errors: change is not defined. Initiator A: <a href="javascript:change(2);" class="links">About Us</a> Any help would be really nice, I am still a noob to js.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.