Bank Interest


Pre-Requirements

  • Private Message System[/*]
  • A Point System[/*]
  • A Brain[/*]


First off you will want to make a file in:
/home/YOURUSERNAME/
This is so NO BODY can access the file and run it multiple times and what not.
You will want to name this file: bankcron.php.

In this file type something like the following.
PHP Code
  1. <?php
  2. require("public_html/config.php"); //get config
  3. function pti($points){ //define the functions
  4. if(($points >= '1') && ($points <= '49')){ //if the points is greater than 1 but less than 49
  5. $inf = '5'; //inflation or interest is 5%
  6. $new = '0.05'; //or decimal form is 0.05
  7. } //end 5% interest
  8. if(($points >= '50') && ($points <= '99')){ //or if points are 50 or more but less that 99
  9. $inf = '4'; //interest is 4%
  10. $new = '0.04'; //decimal is 0.03
  11. } //end 4%
  12. if(($points >= '100') && ($points <= '149')){ //100 but less than 149 is 3%
  13. $inf = '3'; //the third interest rating..
  14. $new = '0.03'; //decimal of 0.03
  15. } //end 3%
  16. if(($points >= '150') && ($points <= '199')){ //more than 150 but still less than 199
  17. $inf = '2'; //is 2% interest..
  18. $new = '0.02'; //which is 0.02 in decimal form
  19. } //end 2%
  20. if(($points >= '200')){ //person has more than 200+ points in bank
  21. $inf = '1'; //or 1% interest
  22. $new = '0.01'; //or 0.01 in decimal form
  23. } //end it
  24. if(($points == 0)){ //hehe if they dont have any yet they have a bank account
  25. $inf = '0'; //0% inflation for this user :O
  26. } //end
  27. $m1 = ($points * $new); //do some math to calculate new points
  28. $m1e = floor($m1); //round down
  29. $m2 = ($m1e + $points); //total up the points..
  30. return $m2; //return the new points
  31. } //end the function
  32. $getall = mysql_query("SELECT * FROM `bank` ORDER BY `id`"); //get all users from bank
  33. while($gt = mysql_fetch_array($getall)){ //loop the results
  34. $npts = pti($gt[points]); //new points the points in bank
  35. $updatepts = mysql_query("UPDATE `bank` SET `points` = '$npts' WHERE `username` = '$gt[username]';") or die(mysql_error()); //update the users points or die with an error
  36. $msg = "Hello $gt[username],
  37. This is just a message to tell you that your bank interest has been added to your bank account.
  38. <b>Old Balance</b>: $gt[points]
  39. <b>New Balance</b>: $npts"; //message to be sent to the users
  40. $date = date("l jS F Y h:i A"); //the date format
  41. $newpm = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('$gt[username]','BOT-Interest','$date','Bank Interest','$msg');"); //Private Message the users
  42. } //end the loop
  43. ?>


Then go into Cpanel > Cron Jobs and hit 'Simple'

Enter in the following:
TutorialNinja Image

that will be set at 4PM server time Every Thursday. Change it if you want :P
ShadowMage's Avatar
Author:
Views:
3,434
Rating:
Posted on Monday 22nd September 2008 at 10:58 AM
ShadowMage
ShadowMage's Avatar
https://rmb-scripting.com/tutorials.php?tutorial&tid=186
Posted on Sunday 21st September 2008 at 08:45 PM
Posted on Sunday 7th September 2008 at 06:01 PM
jambomb
jambomb's Avatar
Doesnt work i get this


<br />
<b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/home/******/BANKcron.php</b> on line <b>20</b><br />
Posted on Saturday 12th April 2008 at 02:01 PM
cyruswu
cyruswu's Avatar
It sends a message to them about any changes in there bank accont.
Posted on Wednesday 9th April 2008 at 06:04 PM
Dalez
Dalez's Avatar
So why do you need the PM system?
Posted on Saturday 29th March 2008 at 02:48 AM
ShadowMage
ShadowMage's Avatar
i believe theres an alternative hold on i'll go look then send a PM
Posted on Friday 28th March 2008 at 02:46 PM
test
test's Avatar
what if your hosting doesnt cpanel which doesnt provide cron functions
Posted on Saturday 14th July 2007 at 02:55 PM
ShadowMage
ShadowMage's Avatar
then their crap out of luck?
Posted on Saturday 14th July 2007 at 01:37 PM
cyruswu
cyruswu's Avatar
Mod-shadow.

What if someone does not have an brain. And is powered by an computer.
Posted on Friday 13th July 2007 at 10:59 PM
Diablosblizz
Diablosblizz's Avatar
Right now I have no use for. I don't have a website, just a front page linking to my retro.. which is being STUPID! :@