-
Posts
25 -
Joined
-
Last visited
Everything posted by Twysted
-
This is JS not PHP
-
actually with WAMP you don't have all those issues. To OP right click the wamp icon in taskbar and set to run all services then try again. thuis is a common problem with many new users of wamp
-
Son Of A ...... Long pause.... i fixed it. it wasn't a foreach i needed it was a section....geesh. all i wanted was poited in the right diraction.
-
after examining it for some time i have noticed that it is splitting the results between all the tables. I am lost as to how this is happening. some help would be appreciated.
-
I will try your suggestion i have tried naming them but it still doesn't work. that didn't work very well did grab data but here is a screenshot
-
http://www.smarty.net/docsv2/en/language.variables.tpl#language.variables.assoc.arrays http://www.smarty.net/docsv2/en/language.variables.tpl#language.variables.array.indexes
-
I have fixed the php and it is showing there should be a row but it's not showing the data. i have not changed the tpl file anymore so what you see above is how it still is but here is the update i made to the php and also an image showing what i see. php <?php if($Auth->isLogged()) { $aid = $Auth->loggedAid(); $limit = 10; $row = array(); $db->query('SELECT * FROM ptc WHERE active = 1'); if($db->returned_rows >= 1) { $username = $Auth->loggedUsername(); $time = time(); $row = $db->fetch_assoc_all(); $smarty->assign('row', $row); $smarty->assign('username', $username); $smarty->assign('time', $time); } else { //set var not to display ptc ads $smarty->assign("row", "No PTC are available"); } } $smarty->display('ptc_view.tpl'); ?>
-
Ok so i have made the page to load the data and i have my tpl file loading i just can't figure out for the life of me why it is not displaying correctly. what it is displaying php for the page <?php if($Auth->isLogged()) { $aid = $Auth->loggedAid(); $limit = 10; //grab available PTC links from db output in json $db->select('*', 'ptc', 'active = 1'); if($db->returned_rows >= 1) { $username = $Auth->loggedUsername(); $time = time(); //$row = $db->fetch_assoc_all(); $smarty->assign('row', $db->fetch_assoc()); $smarty->assign('username', $username); $smarty->assign('time', $time); } else { //set var not to display ptc ads $smarty->assign("row", "No PTC are available"); } } $smarty->display('ptc_view.tpl'); ?> tpl file <!-- START content-container --> <section id="content-container" class="clearfix"> <div id="main-wrap" class="clearfix"> <div class="page_content"> <table class="table table-hover"> <tr> <th>Ad Link</th> <th>Earnings | Points</th> <th>Times Completed</th> <th>Total Visits</th> <th>Date Added</th> </tr> {foreach key=pid item=ri from=$row} <tr> <td><a href="Pages/ptcview/{$ri[0]}">{$ri[1]}</a><br/>{$ri[3]}</td> <td>{$ri[5]} | {$ri[6]} pts</td> <td>{$ri[8]}</td> <td>{$ri[7]}</td> <td>{$ri[13]}</td> </tr> {foreachelse} <tr> <td colspan="5">Sorry there are no PTC ads available right now</td> </tr> {/foreach} can someone please show me where i have gone wrong? BTW the db table does exist and there is 1 record in it.
-
compare.php <?php /** * * Class \webdof\Text\diff\Compare * * Compares two texts, finds the diffrences and patches back to * the original version using a minimal ammount of data. * * Version: 4.0.0 * * @Author: Till Wehowski, http://www.webfan.de * @Author: php Community, http://php.net * @License: Do What The Fuck You Want To Public License * * */ namespace webdof\Text\diff; /** * Example: $text_1 = 'Dies ist ein Test uber Hackfleisch.<br />Dies ist ein Text uber Hackfleisch.'; $text_2 = "Dies ist Text uber Kackfleisch.<br />Dies ist Test uber Kackfleisch."; $newversion = $text_2; $comp = new \webdof\Text\diff\Compare(); $diff = $comp->calcdiffer($text_1, $text_2); echo $text_1.'<br />'; echo $text_2.'<br />'; echo '<pre>'.print_r($diff, true).'</pre>'; $back = ''; foreach( $diff as $step => $d) { if($d[0] === '=' || $d[0] === '-')$back.= $d[1]; } echo 'Patching:<br />'; echo $back.'<br />'; echo '<br />'; echo 'Patching Rüwärts nur mit Änderungen und strlen(equals):<br />'; $diff = $comp->minimize( $diff ); $oldversion = $comp->patch( $text_2, $diff ); echo '<pre>'.print_r($diff, true).'</pre>'; echo $oldversion.'<br />'; echo '<br /><br />Test 2<br />'; $text_1 = 'An einem Sommertag fuhr ich mit dem Fahrrad über die Straße nach Hause.'; $text_2 = 'An einem schönen Sommertag ging ich mit dem Auto über die Straße spazieren.'; echo $text_1.'<br />'; echo $text_2.'<br />'; $comp = new \webdof\Text\diff\Compare(); $diff = $comp->calcdiffer($text_1, $text_2); $diff = $comp->minimize( $diff ); $oldversion = $comp->patch( $text_2, $diff ); echo $oldversion.'<br />'; * */ class Compare { const ADD = 0; // = '+'; const DEL = 1; // = '-'; const EQUAL = 2; // = '='; protected $data = array( 'old' => NULL, 'version' => array( 'new' => NULL, 'diff' => NULL, ), ); function __construct($old = NULL, $new = NULL) { if(is_string($old) && is_string($new))return $this->diff($old, $new); } public function data($data = NULL) { if(is_array($data) && (isset($data['old']) || isset($data['version'])))$this->data = $data; return $this->data; } public function diff($old, $new, $returns = 'version'){ $this->data = array( 'old' => $old, 'version' => array( 'new' => $new, 'diff' => $this->minimize( $this->calcdiffer($old, $new) ), ), ); switch($returns){ case 'version' : $result = $this->data['version']; break; case 'minimized' : case 'diff' : $result = $this->data['version']['diff']; break; case 'all' : case 'max' : $this->data['sha1'] = array( 'old' => sha1($old), 'new' => sha1($new), ); $this->data['strlen'] = array( 'old' => strlen($old), 'new' => strlen($new), ); $result = $this->data; break; case 'data' : default : $result = $this->data; break; } return $result; } /* * Alias for patch * */ public function rollback($newversion, $diff) { return $this->patch($newversion, $diff); } public function patch($newversion, $diff) { $back = array_reverse($diff); $str = ''; $r = strrev($newversion); $offset = 0; foreach($back as $step => $d) { if($d[0] === self::DEL)$d[1] = strrev($d[1]); if($d[0] === self::EQUAL)$str.= substr($r, $offset, $d[2] ); if($d[0] === self::DEL)$str.= $d[1]; if($d[0] === self::ADD || $d[0] === self::EQUAL)$offset += $d[2]; } $oldversion = strrev($str); return $oldversion; } /* * * minimize * compress the diff data, we only need the the added and equal strings position and length * and the value of the deleted strings * */ public function minimize($diff) { foreach($diff as $step => $d) { if($diff[$step][0] !== self::DEL)$diff[$step][1] = NULL; } return $diff; } /* * Returns the differences of $a and $b */ public function calcdiffer($a, $b) { $alen = strlen($a); $blen = strlen($b); $aptr = 0; $bptr = 0; $ops = array(); while($aptr < $alen && $bptr < $blen) { $matchlen = $this->matchlen(substr($a, $aptr), substr($b, $bptr)); if($matchlen) { $str = substr($a, $aptr, $matchlen); $ops[] = array(self::EQUAL, $str, strlen($str) ); $aptr += $matchlen; $bptr += $matchlen; continue; } /* Difference found */ $bestlen=0; $bestpos=array(0,0); for($atmp = $aptr; $atmp < $alen; $atmp++) { for($btmp = $bptr; $btmp < $blen; $btmp++) { $matchlen = $this->matchlen(substr($a, $atmp), substr($b, $btmp)); if($matchlen>$bestlen) { $bestlen=$matchlen; $bestpos=array($atmp,$btmp); } if($matchlen >= $blen-$btmp)break; } } if(!$bestlen)break; $adifflen = $bestpos[0] - $aptr; $bdifflen = $bestpos[1] - $bptr; if($adifflen) { $str = substr($a, $aptr, $adifflen); $ops[] = array(self::DEL, $str, strlen($str) ); $aptr += $adifflen; } if($bdifflen) { $str = substr($b, $bptr, $bdifflen); $ops[] = array(self::ADD, $str, strlen($str) ); $bptr += $bdifflen; } $str = substr($a, $aptr, $bestlen); $ops[] = array(self::EQUAL, $str, strlen($str) ); $aptr += $bestlen; $bptr += $bestlen; } if($aptr < $alen) { /* b has too much stuff */ $str = substr($a, $aptr); $ops[] = array(self::DEL, $str, strlen($str) ); } if($bptr < $blen) { /* a has too little stuff */ $str = substr($b, $bptr); $ops[] = array(self::ADD, $str, strlen($str) ); } return $ops; } protected function matchlen(&$a, &$b) { $c=0; $alen = strlen($a); $blen = strlen($b); $d = min($alen, $blen); while($a[$c] == $b[$c] && $c < $d) $c++; return $c; } } //eof example.php <?php $text_1 = 'Dies ist ein Test uber Hackfleisch.<br />Dies ist ein Text uber Hackfleisch.'; $text_2 = "Dies ist Text uber Kackfleisch.<br />Dies ist Test uber Kackfleisch."; $newversion = $text_2; $comp = new \webdof\Text\diff\Compare(); $diff = $comp->calcdiffer($text_1, $text_2); $html.= $text_1.'<br />'; $html.= '<hr noshade>'; $html.= $text_2.'<br />'; $html.= '<pre>'.print_r($diff, true).'</pre>'; $back = ''; foreach( $diff as $step => $d) { if($d[0] === '=' || $d[0] === '-')$back.= $d[1]; } $html.= 'Patching:<br />'; $html.= $back.'<br />'; $html.= '<br />'; $html.= 'Patching Rüwärts nur mit Änderungen und strlen(equals):<br />'; $diff = $comp->minimize( $diff ); $oldversion = $comp->patch( $text_2, $diff ); $html.= '<pre>'.print_r($diff, true).'</pre>'; $html.= $oldversion.'<br />'; $html.= '<br /><br />Test 2<br />'; $text_1 = 'An einem Sommertag fuhr ich mit dem Fahrrad über die Straße nach Hause.'; $text_2 = 'An einem schönen Sommertag ging ich mit dem Auto über die Straße spazieren.'; $html.= $text_1.'<br />'; $html.= $text_2.'<br />'; $comp = new \webdof\Text\diff\Compare(); $diff = $comp->calcdiffer($text_1, $text_2); $diff = $comp->minimize( $diff ); $oldversion = $comp->patch( $text_2, $diff ); $html.= $oldversion .'<br />'; echo $html; ?> include compare.php in example.php and this solution should fix it for you.
-
try using a num_rows method in your sql and then using an if statement to check if the query was successful. if the if statement you can add the while loop.
-
after this $count=mysql_num_rows($result); add this $row=mysql_fetch_array($result);
-
nevermind i fixed it
-
ok that didn't help
-
even on php 5?
-
no errors
-
ok i have tried all i can think of MySQL Version: 5.0.27-standard PHP Version: 4.4.4 PHPMyAdmin Version: phpMyAdmin - 2.9.0.2 my register script: <?php include( "includes/inc-header.php" ); echo "<br>"; if ( !$_GET['stp'] ) { ?> <form action="register.php?stp=2" method="post"> <table width="60%" border="0" align="center"> <tr><td colspan="4" class="bodycell3">Register</td></tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Username:</b></td> <td class="bodycell4" width="50%" align="center"><input name="username" type="text" size="30"></td> </tr> <tr> <td class="bodycell4" colspan="2" align="right">Your username may be between 5 - 16 Characters.</td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Password:</b></td> <td class="bodycell4" width="50%" align="center"><input name="password1" type="password" size="30"></td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Re-type Password:</b></td> <td class="bodycell4" width="50%" align="center"><input name="password2" type="password" size="30"></td> </tr> <tr> <td class="bodycell4" colspan="2" align="right">Your password may be between 5 - 10 Characters.</td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Email:</b></td> <td class="bodycell4" width="50%" align="center"><input name="email1" type="text" size="30"></td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Re-type Email:</b></td> <td class="bodycell4" width="50%" align="center"><input name="email2" type="text" size="30"></td> </tr> <tr> <td class="bodycell4" colspan="2" align="right">Email must be correct as you need to validate your account.</td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>First Name:</b></td> <td class="bodycell4" width="50%" align="center"><input name="firstname" type="text" size="30"></td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Last Name:</b></td> <td class="bodycell4" width="50%" align="center"><input name="lastname" type="text" size="30"></td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Gender:</b></td> <td class="bodycell4" width="50%" align="center"> <select name="gender"> <option value="Male">Male</option> <option value="Female">Female</option> </select> </td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Race:</b></td> <td class="bodycell4" width="50%" align="center"> <select name="race"> <option value="1"><?=$SETTINGS['prace_1']?></option> <option value="2"><?=$SETTINGS['prace_2']?></option> <option value="3"><?=$SETTINGS['prace_3']?></option> <option value="4"><?=$SETTINGS['prace_4']?></option> <option value="5"><?=$SETTINGS['prace_5']?></option> <option value="6"><?=$SETTINGS['prace_6']?></option> </select> </td> </tr> <tr> <td class="bodycell4" colspan="2"> Races start with:<br> -><?=$SETTINGS['prace_1']?>: +2500 Defense, +2500 Offense, +15000 Gold<br> -><?=$SETTINGS['prace_2']?>: +5 Army, +40000 Gold<br> -><?=$SETTINGS['prace_3']?>: +5000 Offense, +2500 Defense<br> -><?=$SETTINGS['prace_4']?>: +7500 Defense<br> -><?=$SETTINGS['prace_5']?>: +7500 Offense<br> -><?=$SETTINGS['prace_6']?>: +5000 Offense, +25000 Gold<br> </td> </tr> <tr> <td colspan="4" class="bodycell4"> <center> <input name="register" type="submit" value="Register"> </center> </td> </tr> </table> </form> <?php } elseif ( $_GET['stp'] == 2 ) { $username = htmlentities( stripslashes( $_POST['username'] ) ); $password1 = stripslashes( $_POST['password1'] ); $password2 = stripslashes( $_POST['password2'] ); $email1 = strip_tags( stripslashes( $_POST['email1'] ) ); $email2 = strip_tags( stripslashes( $_POST['email2'] ) ); $firstname = htmlentities( stripslashes( $_POST['firstname'] ) ); $lastname = htmlentities( stripslashes( $_POST['lastname'] ) ); $gender = htmlentities( stripslashes( $_POST['gender'] ) ); $race = htmlentities( stripslashes( $_POST['race'] ) ); $utaken = $db->fetch( $db->query( "SELECT * FROM users WHERE uLogin=\"$username\"" ) ); $etaken = $db->fetch( $db->query( "SELECT * FROM users WHERE uEmail=\"$email1\"" ) ); echo "<center>"; if ( strlen( $username ) < 5 ) { echo "$username is too long."; } elseif ( strlen( $username ) > 16 ) { echo "Your username is too long."; } elseif ( $utaken ) { echo "The username you entered is already in use."; } elseif ( $password1 != $password2 ) { echo "The passwords entered do not match."; } elseif ( strlen( $password1 ) < 5 ) { echo "Your password is too short."; } elseif ( strlen( $password1 ) > 10 ) { echo "Your password is too long."; } elseif ( $email1 != $email2 ) { echo "The emails entered do not match."; } elseif ( $etaken ) { echo "The email you entered is already in use."; } else { if ( !$firstname ) { $firstname = "n/a"; } if ( !$lastname ) { $lastname = "n/a"; } if ( $race == 1 ) { $citizens = "3"; $gold = "40000"; $offense = "7500"; $defense = "7500"; } elseif ( $race == 2 ) { $citizens = "8"; $gold = "65000"; $offense = "5000"; $defense = "5000"; } elseif ( $race == 3 ) { $citizens = "3"; $gold = "25000"; $offense = "10000"; $defense = "7500"; } elseif ( $race == 4 ) { $citizens = "3"; $gold = "25000"; $offense = "5000"; $defense = "12500"; } elseif ( $race == 5 ) { $citizens = "3"; $gold = "25000"; $offense = "12500"; $defense = "5000"; } elseif ( $race == 6 ) { $citizens = "3"; $gold = "50000"; $offense = "10000"; $defense = "5000"; } $randcode = rand( 1000, 9999 ) . "-" . rand( 1000, 9999 ) . "-" . rand( 100, 999 ); $querydb = "INSERT INTO `users` "; $querydb .= "( `uEmail` , `uLogin` , `uPassword` , `uFirstName` , `uLastName` , `uGender` , `uCode` , `uRace` , `uGold` , `uCitizens` , `uOffensiveMen` , `uDefensiveMen` , `uMiners` , `uOffense` , `uDefense` ) "; $querydb .= "VALUES ('NULL, '$email1', '$username', '$password1', '$firstname', '$lastname', '$gender', '$randcode', '$race', '$gold', '$citizens', '5', '5', '1', '$offense', '$defense')"; $db->query( $querydb ); $linsrt = mysql_insert_id(); $db->query( "INSERT INTO `users_online` (`uID`,`uIPAddress`,`uCode`) VALUES (\"LOL - $linsrt\",\"" . $REMOTE_ADDR . "\",\"logged_out\")" ); $x = 1; $YourRegLink = $SETTINGS['game_url'] . "validate2.php?email=" . $email1 . "&code=" . $randcode; $TheSender = $SETTINGS['game_email']; $TheRecipient = $email1; $TheSubject = $SETTINGS['gamename'] . ": Validation Code"; $TheText = "<font face='Tahoma' size='1'>Dear " . $username . ",<br>Welcome to " . $SETTINGS['gamename'] . ". <BR> You will need to type in the following confirmation code on the website, before you can play " . $SETTINGS['gamename'] . ".<br> <br> REG-CODE: " . $randcode . "<br> <br> Or you can click the following link:<br> <a href='" . $YourRegLink . "'>" . $YourRegLink . "</a><BR><BR>"; $TheText = $TheText . "Or, you could copy and paste the following url into your browser:<BR>" . $YourRegLink . "</font>"; $TheText = $TheText . "<BR><BR>"; $TheText = $TheText . "Any replies to this email will be automatically deleted."; $TheText2 = "Dear " . $username . ",\r\nWelcome to " . $SETTINGS['gamename'] . ". \r\n You will need to type in the following confirmation code on the website, before you can play " . $SETTINGS['gamename'] . ".\r\n\r\n REG-CODE: " . $randcode . "\r\n \r\n"; $TheText2 = $TheText . "Or, you could copy and paste the following url into your browser:\r\n" . $YourRegLink; $TheText2 = $TheText . "\r\n\r\n"; $TheText2 = $TheText . "Any replies to this email will be automatically deleted."; $headers = "From: $TheSender\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $boundary = uniqid( "hbsignup" ); $headers .= "Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n"; $headers .= "$TheText2\r\n\r\n"; $headers .= "--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split( base64_encode( $TheText2 ) ); $headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split( base64_encode( $TheText ) ); if ( mail( $email1, $TheSubject, "", $headers ) ) { ?> Your confirmation code has been sent.<BR> Once you have received your code, <A HREF='validate.php'>click here</A> to activate your account. <?php } else { ?> You have to <h5><A HREF="validate2.php?email=<?php echo $email1; ?>&code=<?php echo $randcode; ?>"><B>ACTIVATE</B></A></h5> your account, before you can play.<BR> Please activate your account, by <A HREF="validate2.php?email=<?php echo $email1; ?>&code=<?php echo $randcode; ?>"><B>CLICKING HERE</B></A>.<BR> From there, you can login. <BR> <?php } } if ( !$x ) { echo "<br><br>"; echo "<a href=\"javascript:history.back();\">BACK</a>"; } echo "</center>"; } include( "includes/inc-footer.php" ); ?> it send email and goes to step 2 but doesn't insert into database
-
ok i have this set so you convert x ore into x silver but i don't know how to make it where you convert xy ore into x silver. anybobody can help me with this? [code]<?php $isadmin = "*"; include( "../includes/inc-header.php" ); if ( !$_POST['ore1_convert'] && !$_POST['silver_convert'] ) { ?> <form action="silver_bank.php" method="post"> <table width="100%" border="0"> <tr> <td colspan="2" class="bodycell3">Conversion Labratory</td> </tr> <tr> <td colspan="2" class="bodycell4"> <center> Conversions: <?=$user['uConvert']?> / <?=$user['uConvertMax']?> </center> </td> </tr> <tr> <td class="bodycell4" width="50%" align="center"> <b>Convert Ore to Silver:</b><br><br> <input name="ore1" type="text" value="0" size="5" maxlength="10"> / <?=$user['uOre']?><br><br> <input name="ore1_convert" type="submit" value="Convert"> </td> <td class="bodycell4" width="50%" align="center"> <b>DeConvert Silver to Ore:</b><br><br> <input name="ore2" type="text" value="0" size="5" maxlength="10"> / <?=$user['uSilver']?><br><br> <input name="silver_convert" type="submit" value="DeConvert"> </td> </tr> </table> </form> <?php } elseif ( $_POST['silver_convert'] ) { ?> <table width="100%" border="0"> <tr> <td class="bodycell3">Conversion Labratory</td> </tr> <tr> <td class="bodycell4" align="center"> <?php $ores = round( str_replace( "-", "", $_POST['ore1'] ) ); if ( $ores > $user['uOre'] ) { echo "You don't have enough Ore."; } elseif ( $ores < 5 ) { echo "You must enter a proper amount."; } elseif ( $user['uConvert'] == 0 ) { echo "You can't deposit any more for today."; } else { echo "You sucessfully coverted $ores Ore, Into $ores Silver."; $db->query( "UPDATE users SET uOre=uOre-$ores,uSilver=uSilver+$ores,uConvert=uConvert-1 WHERE uID='" . $user['uID'] . "'" ); } ?> <br><br> <a href="javascript:history.back();">BACK</a> </td> </tr> </table> <?php } elseif ( $_POST['silver_convert'] ) { ?> <table width="100%" border="0"> <tr> <td class="bodycell3">Conversion Labratory</td> </tr> <tr> <td class="bodycell4" align="center"> <?php $ores = round( str_replace( "-", "", $_POST['ore2'] ) ); if ( $ores > $user['uSilver'] ) { echo "You don't have enough silver on hand."; } elseif ( $ores < 10 ) { echo "You must enter a proper amount."; } else { echo "You sucessfully deconverted $ores silver back into Ore."; $db->query( "UPDATE users SET uOre=uOre+$ores,uSilver=uSilver-$ores WHERE uID='" . $user['uID'] . "'" ); } ?> <br><br> <a href="javascript:history.back();">BACK</a> </td> </tr> </table> <?php } include( "../includes/inc-footer.php" ); ?>[/code]
-
i will do it for ya, for $15
-
try phpautomembersarea
-
insert news into a database, and make a varible table in database telling it marquee then apply that to the news and bring it all out at one time.
-
What is a good simple and secure membership system?
Twysted replied to wrighteq's topic in Third Party Scripts
try phpautomembersarea -
ok i am not sure what i am doing that is wrong but i can't get my refer links to work. any ideas that would help? i included the files having to do with it. [attachment deleted by admin]
-
any help at all?
-
ok what i want to do on this is make it where if attacker is success, loser loses defenive men. can someone show me how i would go about making it that way? [code]<?php $isadmin = "*"; include( "../includes/inc-header.php" ); if ( !$_GET['id'] && !$_POST['turns'] && !$_POST['id'] ) { $users_total = $db->fetch( $db->query( "SELECT count(*) FROM users" ) ); $pages = ceil( $users_total[0] / 25 ); if ( $_GET['p'] ) { $currentpage = round( $_GET['p'] ); } else { $currentpage = round( $_POST['page'] )-1; } if ( $currentpage < 1 ) { $currentpage = 0; } if ( $currentpage + 1 > $pages ) { $currentpage = $pages-1; } $lmin = $currentpage * 25; $lmax = $lmin + 25; if ( $_POST['find_username'] ) { $theuser = htmlentities( stripslashes( $_POST['username'] ) ); $whereclause = " WHERE uLogin LIKE \"%$theuser%\""; } ?> <form action="attack.php" method="post"> <table width="100%" border="0"> <tr> <td class="bodycell3" width="50%">Find By Page</td> <td class="bodycell3" width="50%">Find By Username</td> </tr> <tr> <td class="bodycell4" width="50%" align="center"> <br> <input name="page" size="5" maxlength="10" type="number"> / <?=$pages?><br><br> <input name="find_page" value="Submit" type="submit"><br><br> </td> <td class="bodycell4" width="50%" align="center"> <br> <input name="username" size="10" maxlength="30" type="text"><br><br> <input name="find_username" value="Submit" type="submit"><br><br> </td> </tr> </table> </form> <?php $x = $currentpage * 25; if ( $x < 0 ) { $x = 0; } $column1 .= "<b>Rank</b><br>"; $column2 .= "<b>Username</b><br>"; $column3 .= "<b>Gold</b><br>"; $column4 .= "<b>Army Size</b><br>"; $column5 .= "<b>Level</b><br>"; $thequery = "SELECT uID,uLogin,(uOffensiveMen+uDefensiveMen) AS uArmySize,uGold,uLevel FROM users$whereclause ORDER BY uEXP DESC LIMIT $lmin, 25"; $result = $db->query( $thequery ); while ( $themost = $db->fetch( $result ) ) { $x++; $column1 .= "<hr>$x<br>"; $column2 .= "<hr><a href=\"profile.php?id=" . $themost['uID'] . "\">" . $themost['uLogin'] . "</a> "; $isonline = $db->fetch( $db->query( "SELECT uID FROM users_online WHERE uTime>'$mintime15' AND uID='" . $themost['uID'] . "'" ) ); if ( $isonline ) { $column2 .= " [Online]<br>"; } else { $column2 .= "<br>"; } $column3 .= "<hr>" . $themost['uGold'] . "<br>"; $column4 .= "<hr>" . $themost['uArmySize'] . "<br>"; $column5 .= "<hr>" . $themost['uLevel'] . "<br>"; } ?> <table width="100%" border="0"> <tr> <td class="bodycell3">Attack</td> </tr> <tr> <td class="bodycell4"> <table width="90%" border="0" align="center"> <tr> <td align="left"> <?php if ( $currentpage > 0 ) { ?> <a href="attack.php?p=<?=$currentpage-1?>">Previous</a> <?php } else { echo "Previous"; } ?> </td> <td align="right"> <?php if ( $currentpage + 1 < $pages ) { ?> <a href="attack.php?p=<?=$currentpage + 1?>">Next</a> <?php } else { echo "Next"; } ?> </td> </tr> </table> </td> </tr> <tr> <td class="bodycell4"> <table width="100%" border="0"> <tr> <td width="10%" align="center"> <?=$column1?> </td> <td width="35%"> <?=$column2?> </td> <td width="25%" align="center"> <?=$column3?> </td> <td width="20%" align="center"> <?=$column4?> </td> <td width="10%" align="center"> <?=$column5?> </td> </tr> </table> </td> </tr> <tr> <td class="bodycell4"> <table width="90%" border="0" align="center"> <tr> <td align="left"> <?php if ( $currentpage > 0 ) { ?> <a href="attack.php?p=<?=$currentpage-1?>">Previous</a> <?php } else { echo "Previous"; } ?> </td> <td align="right"> <?php if ( $currentpage + 1 < $pages ) { ?> <a href="attack.php?p=<?=$currentpage + 1?>">Next</a> <?php } else { echo "Next"; } ?> </td> </tr> </table> </td> </tr> </table> <?php } elseif ( $_GET['id'] ) { $theid = round( $_GET['id'] ); $result = $db->query( "SELECT uID,uLogin FROM users WHERE uID=\"$theid\"" ); $enemy = $db->fetch( $result ); ?> <table width="100%" border="0"> <tr> <td class="bodycell3">Attack</td> </tr> <tr> <td class="bodycell4" align="center"> <?php if ( !$enemy ) { echo "This player does not exist."; } elseif ( $enemy['uID'] == $user['uID'] ) { echo "You can not attack yourself."; } else { echo "<form action=\"attack.php\" method=\"post\">"; echo "<br>You have " . $user['uAttackTurns'] . " attack turns available to use against " . $enemy['uLogin'] . ".<br><br>"; echo "<input name=\"id\" type=\"hidden\" value=\"" . $enemy['uID'] . "\">"; echo "<input name=\"turns\" type=\"text\" size=\"5\" maxlength=\"$theid\"> / " . $SETTINGS['max_atk_turns'] . "<br><br>"; echo "<input name=\"attack\" type=\"submit\" value=\"Attack\"><br>"; echo "</form>"; } ?> </td> </tr> </table> <?php } elseif ( $_POST['turns'] && $_POST['id'] ) { $turns = round( str_replace( "-", "", $_POST['turns'] ) ); $theid = round( $_POST['id'] ); $result = $db->query( "SELECT * FROM users WHERE uID=\"$theid\"" ); $enemy = $db->fetch( $result ); ?> <table width="100%" border="0"> <tr> <td class="bodycell3">Attack</td> </tr> <tr> <td class="bodycell4" align="center"> <?php $timeminus24 = time() - ( 60 * 60 * 24 ); $query = "SELECT count(*) FROM logs WHERE lOther='" . $enemy['uID'] . "' AND lYou='" . $user['uID'] . "' AND lType='2' AND lTime2>'$timeminus24'"; $timesbattled = $db->fetch( $db->query( $query ) ); if ( !$enemy ) { echo "This player does not exist."; } elseif ( $enemy['uID'] == $user['uID'] ) { echo "You can not attack yourself."; } elseif ( $turns < 1 || $turns > $SETTINGS['max_atk_turns'] ) { echo "You must enter a valid amount of attack turns to use."; } elseif ( $turns > $user['uAttackTurns'] ) { echo "You don't have enough turns."; } elseif ( $enemy['uLevel'] < $user['uLevel'] - $SETTINGS['lvls_below'] ) { echo "You can't battle someone more than " . $SETTINGS['lvls_below'] . " levels below you."; } elseif ( $enemy['uLevel'] > $user['uLevel'] + $SETTINGS['lvls_above'] ) { echo "You can't battle someone more than " . $SETTINGS['lvls_above'] . " levels above you."; } elseif ( $timesbattled[0] >= $SETTINGS['attacks_24'] ) { echo "You can't battle someone more than " . $SETTINGS['attacks_24'] . " times in 24 hours."; } else { $weaponz1 = explode( ";", $user['uWeapon1'] . ";" . $user['uWeapon2'] . ";" . $user['uWeapon3'] . ";" . $user['uWeapon4'] . ";" . $user['uWeapon5'] ); $weaponz2 = explode( ";", $SETTINGS['wp_1_dmg'] . ";" . $SETTINGS['wp_2_dmg'] . ";" . $SETTINGS['wp_3_dmg'] . ";" . $SETTINGS['wp_4_dmg'] . ";" . $SETTINGS['wp_5_dmg'] ); $menleft = $user['uOffensiveMen']; $offense = $user['uOffense'] + ( $menleft * 250 ); $x = 0; while ( $x < 5 && $menleft != 0 ) { if ( $weaponz1[$x] >= $menleft ) { $offense = $offense + ( $menleft * $weaponz2[$x] ); $menleft = 0; } else { $offense = $offense + ( $weaponz1[$x] * $weaponz2[$x] ); $menleft = $menleft - $weaponz1[$x]; } $x++; } $armourz1 = explode( ";", $enemy['uArmour1'] . ";" . $enemy['uArmour2'] . ";" . $enemy['uArmour3'] . ";" . $enemy['uArmour4'] . ";" . $enemy['uArmour5'] ); $armourz2 = explode( ";", $SETTINGS['ar_1_dmg'] . ";" . $SETTINGS['ar_2_dmg'] . ";" . $SETTINGS['ar_3_dmg'] . ";" . $SETTINGS['ar_4_dmg'] . ";" . $SETTINGS['ar_5_dmg'] ); $menleft = $enemy['uDefensiveMen']; $defense = $enemy['uDefense'] + ( $menleft * 250 ); $x = 0; while ( $x < 5 && $menleft != 0 ) { if ( $armourz1[$x] >= $menleft ) { $defense = $defense + ( $menleft * $armourz2[$x] ); $menleft = 0; } else { $defense = $defense + ( $armourz1[$x] * $armourz2[$x] ); $menleft = $menleft - $armourz1[$x]; } $x++; } if ( $offense == $defense ) { if ( rand( 1, 2 ) == 1 ) { $offense += 50 * rand( 1, 6 ); } else { $offense += 50 * rand( 1, 6 ); } } echo "<br>Your " . $user['uOffensiveMen'] . " offensive men attack for $offense offense.<br><br>"; echo $enemy['uLogin'] . " defends your attack with $defense defense.<br><br>"; $time = time(); if ( $offense > $defense ) { $gold_gained_work = $enemy['uGold'] / 20; $gold_gained = $gold_gained_work * $turns; $exp_gained_work = rand( 1000, 3500 ); $exp_gained_work2 = $exp_gained_work / 10; $exp_gained = $exp_gained_work2 * $turns; echo "You defeated " . $enemy['uLogin'] . ", you have gained $gold_gained gold and also $exp_gained exp.<br>"; $user['uEXP'] = $user['uEXP'] + $exp_gained; $db->query( "UPDATE users SET uGold=uGold+'$gold_gained',uEXP=uEXP+'$exp_gained',uWon=uWon+'1',uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'" ); $db->query( "UPDATE users SET uGold=uGold-'$gold_gained',uLost=uLost+'1' WHERE uID='" . $enemy['uID'] . "'" ); $db->query( "INSERT INTO logs (`lType`,`lWinLose`,`lYou`,`lOther`,`lOtherLogin`,`lTurns`,`lGold`,`lEXP`,`lTime`,`lTime2`) VALUES ('2', '1', '" . $user['uID'] . "', '" . $enemy['uID'] . "', '" . $enemy['uLogin'] . "', '$turns', '$gold_gained', '$exp_gained', \"$gamedate\", '$time')" ); $db->query( "INSERT INTO logs (`lType`,`lWinLose`,`lYou`,`lOther`,`lOtherLogin`,`lTurns`,`lGold`,`lEXP`,`lTime`,`lTime2`) VALUES ('1', '2', '" . $enemy['uID'] . "', '" . $user['uID'] . "', '" . $user['uLogin'] . "', '$turns', '-$gold_gained', '0', \"$gamedate\", '$time')" ); if ( $user['uEXP'] > $user['uNextLevel'] ) { $at = $user['uNextLevel'] / 2; $add = $user['uNextLevel'] + $at; echo "<br>You have gained a level.<br>"; $db->query( "UPDATE users SET uLevel=uLevel+'1',uNextLevel=uNextLevel+'$add' WHERE uID='" . $user['uID'] . "'" ); } } elseif ( $offense < $defense ) { $gold_lost_work = $user['uGold'] / 40; $gold_lost = $gold_lost_work * $turns; $exp_gained_work = rand( 1000, 3500 ); $exp_gained_work2 = $exp_gained_work / 20; $exp_gained = $exp_gained_work2 * $turns; echo $enemy['uLogin'] . " defeated you, you have lost $gold_lost gold.<br>"; $enemy['uEXP'] = $enemy['uEXP'] + $exp_gained; $db->query( "UPDATE users SET uGold=uGold-'$gold_lost',uLost=uLost+'1',uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'" ); $db->query( "UPDATE users SET uGold=uGold+'$gold_lost',uWon=uWon+'1',uEXP=uEXP+'$exp_gained' WHERE uID='" . $enemy['uID'] . "'" ); $db->query( "INSERT INTO logs (`lType`,`lWinLose`,`lYou`,`lOther`,`lOtherLogin`,`lTurns`,`lGold`,`lEXP`,`lTime`,`lTime2`) VALUES ('2', '2', '" . $user['uID'] . "', '" . $enemy['uID'] . "', '" . $enemy['uLogin'] . "', '$turns', '-$gold_lost', '0', \"$gamedate\", '$time')" ); $db->query( "INSERT INTO logs (`lType`,`lWinLose`,`lYou`,`lOther`,`lOtherLogin`,`lTurns`,`lGold`,`lEXP`,`lTime`,`lTime2`) VALUES ('1', '1', '" . $enemy['uID'] . "', '" . $user['uID'] . "', '" . $user['uLogin'] . "', '$turns', '$gold_lost', '$exp_gained', \"$gamedate\", '$time')" ); if ( $enemy['uEXP'] > $enemy['uNextLevel'] ) { $at = $enemy['uNextLevel'] / 2; $add = $enemy['uNextLevel'] + $at; echo "<br>" . $enemy['uLogin'] . " has gained a level.<br>"; $db->query( "UPDATE users SET uLevel=uLevel+'1',uNextLevel=uNextLevel+'$add' WHERE uID='" . $enemy['uID'] . "'" ); } } echo "<br>"; } ?> </td> </tr> </table> <?php } include( "../includes/inc-footer.php" ); ?>[/code]