Jump to content
MakeWebGames

POG1

Members
  • Posts

    1,419
  • Joined

  • Last visited

Everything posted by POG1

  1. Re: Query Optimization yeah i know 25+ is probably enough
  2. Re: [mccode v2] Av Bank   mysql_fetch_row..
  3. Re: [mccode V2] Bank Investment use this..   <?php // // Copyright 2008 // PogOne Designs // Free investment MOD // include_once("globals.php"); $result = $db->query("SELECT * FROM `investment` WHERE `user` = '".$userid."' AND `time` < '".time()."' AND `collected` = '1'"); // INVESTMENT FINISHED if ($db->num_rows($result)) { $result = mysql_fetch_array($result,MYSQL_ASSOC); if($_GET['takeout']) { $new = $result['amount'] + $ir['money']; $db->query("UPDATE `investment` SET `collected` = '0' WHERE `user` = '".$userid."'"); $db->query("UPDATE `users` SET `money` = '".$new."' WHERE `userid` = '".$userid."'"); echo '<p style="text-align:center">You took your money out of your bank account! '. 'You may open another if you wish</p>'. '<p style="text-align:center">[url="investment.php"]Back[/url]</p>'; } else { echo '<p style="text-align:center">'. 'Your investment account is over! You can now widthdraw '. money_formatter($result['amount']). '</p><p style="text-align:center">[url="investment.php?takeout=TRUE"]Widthdraw![/url]</p>'; } $h->endpage(); die; } $result = $db->query("SELECT * FROM `investment` WHERE `user` = '".$userid."' AND `time` > '".time()."' AND `collected` = '0'"); // ALLREADY HAVE AN INVESTMENT if ($db->num_rows($result)) { $result = mysql_fetch_array($result,MYSQL_ASSOC); $time = date("j F Y (g:i a)",$result['time']); $money = money_formatter($result['amount']); echo '<p style="text-align:center">You allready have a investment account. At [b]'.$time.'[/b] you will '. 'be able to collect '.$money.'</p><p style="text-align:center">[url="index.php"]Back[/url]</p>'; $h->endpage(); die; } // INVEST MONEYS POST if(isset($_POST['submit']) AND isset($_POST['amount'])) { // Moneys to invest $amount = (isset($_POST['amount']) AND !ereg('[^0-9]', $_POST['amount'])) ? abs(@intval($_POST['amount'])) : 0 ; $time = (int) ereg_replace('[^0-9]+','',$_POST['time']); $alowed = array(7,14,21,28); if(!in_array($time,$alowed)) { echo ' Error! go back and try again</p>'; $h->endpage(); die; } if($amount > $ir['money']) { echo ' You dont have enough money!</p>'; $h->endpage(); die; } $end = (int) time() + ($time*((60*60)*24)); $multipliers = array(7=>0.05, 14=>0.07, 21=>0.12, 28=>0.175); $newAmount = ($amount * $multipliers[$time]); $result = $db->query("SELECT user FROM `investment` WHERE `user` = '".$userid."'"); $string = ($db->num_rows($result)) ? sprintf("UPDATE `investment` SET `time` = '%u', `amount` = '%u', `collected` = '1' WHERE `user` = '%u'",$end,$newAmount,$userid) : sprintf("INSERT INTO `investment` (`user`,`time`,`amount`) VALUES('%u','%u','%u')",$ir['userid'],$end,$newAmount,$userid); $db->query($string); $db->query(sprintf("UPDATE `users` SET `money` = '%u' WHERE `userid` = '%u'",($ir['money'] - $amount),$userid)); echo '<p style="text-align:center">'. 'You have invested [b]'.money_formatter($amount).'[/b].You will gain an extra [b]'.money_formatter($newAmount).'[/b]! '. 'You will be able to collect the money on '.date("j F Y (g:i a)",$end). '</p><p style="text-align:center">[url="index.php"]back[/url]</p>'; $h->endpage(); die; } echo ' Welcome to the [b]Investment bank[/b]. How much would you like to invest?</p>'. '<form method="post">'. '<p style="text-align:center"><label for="amount" style="width:150px;display:block;float:left">Money to invest</label><input type="text" id="amount" name="amount" /> [size="1"][url="javascript:void(0);"][all][/url][/size]</p>'. '<p style="text-align:center"><label for="time" style="width:150px;display:block;float:left">How long for?</label>'. '<select type="dropdown" id="time" name="time">'. '<option value="7">1 Week</option>'. '<option value="14">2 Weeks</option>'. '<option value="21">3 Weeks</option>'. '<option value="28">4 Weeks</option>'. '</select>'. '</p>'. '<p style="text-align:center;margin-top:50px;"><input type="submit" value="Invest!" name="submit" /></p>'. '</form>'; $h->endpage(); ?>
  4. Re: Query Optimization   your missing the point. Fetching 150 fields every page load per visitor compared to 50 fields would put more load onto the server. Also, you made a post about "optimization" and your not listening from the people who know what they are at.
  5. Re: Big thanks to Killah a sceenshot of it then?
  6. Re: Big thanks to Killah lets see the finished product then...
  7. Re: [mccode V2] Bank Investment   good thinking lol. i will take a look at the code and post an updated version. And maybe add a UPDATE users SET money=money-$amount WHERE userid=$userid   while you're add it. And also change this $result = $db->query("SELECT * FROM `investment` WHERE `user` = '".$userid."' AND `time` > '".time()."' AND `collected` = '0'");   to $result = $db->query("SELECT * FROM `investment` WHERE `user` = '".$userid."' AND `time` > '".time()."' AND `collected` = '1'");   Otherwise people will only ever be able to use the investment fund once and never again. I have made changes to it but there is no "edit" link for the first post. :(
  8. Re: How To Protect Your Game From Hackers? you said you don't have a cpannel, do you get your host do delete it for you?
  9. Re: Require Psd to be coded for mccodes v2 i will do it for you, mail me..
  10. Re: How To Protect Your Game From Hackers?   lol     ya think? -- Never *ever* make assumptions like this until you can personally guarantee ALL the code from the cpanel down to the microcode on a machine. CPanel is often listed as having some serious vulnerabilities in the security news. In fact I choose to install machines without any type of control panel for the very reason that they are insecure. As for securing a game, pretty basic stuff - read the topics in the PHP FAQs section here, we have covered the basics which will prevent 99% of attacks. The other 1%, well, that's a little trickier ;) But thankfully few people understand the concepts behind those attacks as yet, so I wouldn't worry about them - especially for such a small thing as a game. Reason i don't use cpanel!!!   is this needed for V2? if so, in which php file do I include it and where? You add it to every file, and not just once. ;)   do you get your host to delete it then?
  11. Re: Av Bank [FREE] float(11,2)? But you can only withdraw a whole number so i sit still pretty useless..
  12. Re: [mccode v2] Preferences How old are you now.. 14?
  13. Re: [mccode V2] Bank Investment   good thinking lol. i will take a look at the code and post an updated version.
  14. Re: [mccode v2] Preferences   Where did you get this?
  15. Re: [Any Mccode] Disallow Username It would make sense to add it into a function because it will be used throughout the website. Killah's version is pretty much the simplest way to do it. ;)   checkUsername($username) { $blocked = ( dave, bob, steve, georgina, linda ); if(!in_array($username, $blocked)) { return FALSE; } else { return TRUE; } }     if(!checkUsername($username)) { echo 'oops!'; die; }
  16. Re: The Destroyers   if that was aimed at me i wouldn't say i was either "top" or "popular" ;)
  17. Re: Av Bank [FREE] (float) would be useless for 2 reasons. 1. floor rounds a float into an integer. 2. the bank money field in the users table is integer so if a float would be inserted it would be rounded. :P
  18. Re: Av Bank [FREE] $interest = (int) floor($moneys * 0.01);
  19. Re: [mccode v2] Preferences your talking about using ajax but what would it be needed for in preferences?
  20. Re: [mccode V2] Bank Investment   yeah i would of done something like that, or for the else set the variable to FALSE
  21. Re: [mccode V2] Bank Investment strtr looks interesting but how would i strip all non numeric chars? Also, i was going to use preg_replace but i read somewhere (cant remember) it is slower than ereg and i couldn't get the pattern to work lol
  22. Re: [mccode V2] Bank Investment   they both do the same job ;)   lol
  23. Re: [mccode V2] Bank Investment no need for a cron ;)
  24. Nothing huge but at least i am contributing! I haven't "extensively" tested this mod but it worked when have tried it out. Any improvements please suggest them :) Create a file called "investment.php", paste this and save it   <?php // // Copyright 2008 // PogOne Designs // Free investment MOD // include_once("globals.php"); $result = $db->query("SELECT * FROM `investment` WHERE `user` = '".$userid."' AND `time` < '".time()."' AND `collected` = '1'"); if ($db->num_rows($result)) { $result = mysql_fetch_array($result,MYSQL_ASSOC); if($_GET['takeout']) { $new = $result['amount'] + $ir['money']; $db->query("UPDATE `investment` SET `collected` = '0' WHERE `user` = '".$userid."'"); $db->query("UPDATE `users` SET `money` = '".$new."' WHERE `userid` = '".$userid."'"); echo '<p style="text-align:center">You took your money out of your bank account! '. 'You may open another if you wish</p>'. '<p style="text-align:center">[url="investment.php"]Back[/url]</p>'; } else { echo '<p style="text-align:center">'. 'Your investment account is over! You can now widthdraw '. money_formatter($result['amount']). '</p><p style="text-align:center">[url="investment.php?takeout=TRUE"]Widthdraw![/url]</p>'; } $h->endpage(); die; } $result = $db->query("SELECT * FROM `investment` WHERE `user` = '".$userid."' AND `time` > '".time()."' AND `collected` = '0'"); if ($db->num_rows($result)) { $result = mysql_fetch_array($result,MYSQL_ASSOC); $time = date("j F Y (g:i a)",$result['time']); $money = money_formatter($result['amount']); echo '<p style="text-align:center">You allready have a investment account. At [b]'.$time.'[/b] you will '. 'be able to collect '.$money.'</p><p style="text-align:center">[url="index.php"]Back[/url]</p>'; $h->endpage(); die; } if(isset($_POST['submit']) AND isset($_POST['amount'])) { $amount = (int) ereg_replace('[^0-9]+','',$_POST['amount']); // time to invest $time = (int) ereg_replace('[^0-9]+','',$_POST['time']); $alowed = array(7,14,21,28); if(!in_array($time,$alowed) OR $amount == 0) { echo ' Error! go back and try again</p>'; $h->endpage(); die; } if($amount > $ir['money']) { echo ' You dont have enough money!</p>'; $h->endpage(); die; } $end = (int) time() + ($time*((60*60)*24)); $multipliers = array(7=>0.05, 14=>0.07, 21=>0.12, 28=>0.175); $newAmount = ($amount * $multipliers[$time]); $result = $db->query("SELECT * FROM `investment` WHERE `user` = '".$userid."'"); if($db->num_rows($result)) { $string = sprintf("UPDATE `investment` SET `time` = '%u', `amount` = '%u' WHERE `user` = '%u'",$end,$newAmount,$userid); } else { $string = sprintf("INSERT INTO `investment` (`user`,`time`,`amount`) VALUES('%u','%u','%u')",$ir['userid'],$end,$newAmount,$userid); } $db->query($string); echo '<p style="text-align:center">'. 'You have invested [b]'.money_formatter($amount).'[/b].You will gain an extra [b]'.money_formatter($newAmount).'[/b]! '. 'You will be able to collect the money on '.date("j F Y (g:i a)",$end). '</p><p style="text-align:center">[url="index.php"]back[/url]</p>'; $h->endpage(); } echo ' Welcome to the [b]Investment bank[/b]. How much would you like to invest?</p>'. '<form method="post">'. '<p style="text-align:center"><label for="amount" style="width:150px;display:block;float:left">Money to invest</label><input type="text" id="amount" name="amount" /> [size="1"][url="javascript:void(0);"][all][/url][/size]</p>'. '<p style="text-align:center"><label for="time" style="width:150px;display:block;float:left">How long for?</label>'. '<select type="dropdown" id="time" name="time">'. '<option value="7">1 Week</option>'. '<option value="14">2 Weeks</option>'. '<option value="21">3 Weeks</option>'. '<option value="28">4 Weeks</option>'. '</select>'. '</p>'. '<p style="text-align:center;margin-top:50px;"><input type="submit" value="Invest!" name="submit" /></p>'. '</form>'; $h->endpage(); ?>   Go to phpMyadmin and run this SQL.. CREATE TABLE IF NOT EXISTS `investment` ( `user` int(11) NOT NULL, `time` int(11) NOT NULL, `amount` int(11) NOT NULL, `collected` int(1) NOT NULL default '1' ) ENGINE=MyISAM DEFAULT CHARSET=latin1;   hope it works
  25. Re: Farming [v2]   if its not hard why don't you...
×
×
  • Create New...