arcticfang Posted October 26, 2009 Posted October 26, 2009 Hey everyone. For some reason, my day cron script isn't working. :/ It's being run successfully, but something in the php is faulty and I just can't place it. Any help is greatly appreciated!! <?php include "config.php"; global $_CONFIG; if($_GET['code'] != $_CONFIG['code']) { die(""); } define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $db->query("UPDATE fedjail set fed_days=fed_days-1"); $q=$db->query("SELECT * FROM fedjail WHERE fed_days=0"); $ids=array(); while($r=$db->fetch_row($q)) { $ids[]=$r['fed_userid']; } if(count($ids) > 0) { $db->query("UPDATE users SET fedjail=0 WHERE userid IN(".implode(",", $ids).")"); } $db->query("DELETE FROM fedjail WHERE fed_days=0"); $db->query("UPDATE users SET daysingang=daysingang+1 WHERE gang > 0"); $db->query("UPDATE users SET daysold=daysold+1, boxes_opened=0"); $db->query("UPDATE users SET mailban=mailban-1 WHERE mailban > 0"); $db->query("UPDATE users SET donatordays=donatordays-1 WHERE donatordays > 0"); $db->query("UPDATE users SET cdays=cdays-1 WHERE course > 0"); $db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney/50) where bankmoney>0"); $db->query("UPDATE users SET cybermoney=cybermoney+(cybermoney/100*7) where cybermoney>0"); $q=$db->query("SELECT * FROM users WHERE cdays=0 AND course > 0"); while($r=$db->fetch_row($q)) { $cd=$db->query("SELECT * FROM courses WHERE crID={$r['course']}"); $coud=$db->fetch_row($cd); $userid=$r['userid']; $db->query("INSERT INTO coursesdone VALUES({$r['userid']},{$r['course']})"); $upd=""; $ev=""; if($coud['crSTR'] > 0) { $upd.=",us.strength=us.strength+{$coud['crSTR']}"; $ev.=", {$coud['crSTR']} strength"; } if($coud['crGUARD'] > 0) { $upd.=",us.guard=us.guard+{$coud['crGUARD']}"; $ev.=", {$coud['crGUARD']} guard"; } if($coud['crLABOUR'] > 0) { $upd.=",us.labour=us.labour+{$coud['crLABOUR']}"; $ev.=", {$coud['crLABOUR']} labour"; } if($coud['crAGIL'] > 0) { $upd.=",us.agility=us.agility+{$coud['crAGIL']}"; $ev.=", {$coud['crAGIL']} agility"; } if($coud['crIQ'] > 0) { $upd.=",us.IQ=us.IQ+{$coud['crIQ']}"; $ev.=", {$coud['crIQ']} IQ"; } $ev=substr($ev,1); if ($upd) { $db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET us.userid=us.userid $upd WHERE u.userid=$userid"); } $db->query("INSERT INTO events VALUES('',$userid,unix_timestamp(),0,'Congratulations, you completed the {$coud['crNAME']} and gained $ev!')"); } $db->query("UPDATE users SET course=0 WHERE cdays=0"); $db->query("TRUNCATE TABLE votes;"); ?> Quote
Dave Posted October 26, 2009 Posted October 26, 2009 Hey, Run the cron manually (Ie by going to http://yourdomain.com/cron_day.php?code=LALALAL) then report back with any errors which you receive :). Quote
arcticfang Posted October 26, 2009 Author Posted October 26, 2009 Hmm.. it seems to work then. :/ It must be the cron job.. can you tell me if there's anything wrong with this? php -q /home/starwars/public_html/cron_day.php code=yadayadayada Quote
Dave Posted October 27, 2009 Posted October 27, 2009 php -q /home/starwars/public_html/cron_day.php code=yadayadayada You've forgetting something in the string php -q /home/starwars/public_html/cron_day.php?code=yadayadayada Quote
a_bertrand Posted October 27, 2009 Posted October 27, 2009 I doubt the question mark will work in a cron as it will be expanded by shell (as if I remember right it's a special character). So if you need to pass parameters it's with a space, and then you need to parse the thing by hand. Second solution is use wget to actually "load" a php from apache, then you must remember to trash the result otherwise you will fill your space with all sort of junks. Quote
arcticfang Posted October 28, 2009 Author Posted October 28, 2009 Thanks for the replies! The '?' is not supposed to be included. It will corrupt the cron. How would I use wget to do this? And how would I go about automatically cleaning up after itself? That cron above works for EVERYTHING but the day script, btw. :/ Quote
Joshua Posted October 28, 2009 Posted October 28, 2009 Ok, in your cron jobs, the ? is included /home/starwars/public_html/cron_day.php?code=yadayadayada But hopefully you know yadayadayada isnt going to work and you have the actual cron code provided by your installer there =P Quote
a_bertrand Posted October 28, 2009 Posted October 28, 2009 http://www.webmasterworld.com/forum40/1303.htm Quote
Joshua Posted October 28, 2009 Posted October 28, 2009 curl http://MYSITE.COM/cron_fivemins.php?code=MYCODEHERE Thats my cron-jobs and they work :P Quote
arcticfang Posted October 28, 2009 Author Posted October 28, 2009 got it to work by simply adding ">/dev/null 2>&1" to the end. :D thanks for all your help everyone!! much appreciated!!! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.