thebobby Posted October 7, 2012 Share Posted October 7, 2012 php-f/home/chelsi86/public_html/5mincrom.php does not work http://capone.x10.mx/5mincrom.php does not work capone.x10.mx/5mincrom.php does not work anybody help me Quote Link to comment Share on other sites More sharing options...
thebobby Posted October 7, 2012 Author Share Posted October 7, 2012 (edited) <? // Commandline only if(!isset($_SERVER['argc'])) die("Reticulating Splines"); require_once("dbcon.php"); require_once("classes.php"); //REGULAR CRON SCRIPT $num_updates = 1; $num_updates = 1; $result = mysql_query("SELECT * FROM `grpgusers`"); while($line = mysql_fetch_assoc($result)) { $updates_user = new User($line['id']); if($updates_user->rmdays > 0) {$multiplier = .25; } else {$multiplier = .20; } $username = $updates_user->username; $newawake = $updates_user->awake + ($num_updates * 20); $newawake = ($newawake > $updates_user->maxawake) ? $updates_user->maxawake : $newawake; $newhp = $updates_user->hp + round($num_updates * $updates_user->maxhp * $multiplier); $newhp = ($newhp > $updates_user->maxhp) ? $updates_user->maxhp : $newhp; $newenergy = $updates_user->energy + round($num_updates * $updates_user->maxenergy * $multiplier); $newenergy = ($newenergy > $updates_user->maxenergy) ? $updates_user->maxenergy : $newenergy; $newnerve = $updates_user->nerve + round($num_updates * $updates_user->maxnerve * $multiplier); $newnerve = ($newnerve > $updates_user->maxnerve) ? $updates_user->maxnerve : $newnerve; mysql_query("UPDATE `grpgusers` SET `awake` = '".$newawake."', `energy` = '".$newenergy."', `nerve` = '".$newnerve."', `hp` = '".$newhp."', `gcrime` = '0' WHERE `id`=\"$updates_user->id\""); } ?> Edited October 7, 2012 by illusions added tags Quote Link to comment Share on other sites More sharing options...
chicka Posted October 7, 2012 Share Posted October 7, 2012 Next time use code tags [/code***] remove the stars Quote Link to comment Share on other sites More sharing options...
sniko Posted October 7, 2012 Share Posted October 7, 2012 Have you tried cURL? Do you need your host to activate them? Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted October 7, 2012 Share Posted October 7, 2012 http://php.net/manual/en/reserved.variables.argc.php Perhaps its not enabled and for the love of Pete stop running crons in the wwwroot. Quote Link to comment Share on other sites More sharing options...
thebobby Posted October 8, 2012 Author Share Posted October 8, 2012 Fixed the problem Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted October 8, 2012 Share Posted October 8, 2012 (edited) <?php // Commandline only if(isset($_SERVER["REMOTE_ADDR"]) && ($_SERVER["REMOTE_ADDR"] != $_SERVER["SERVER_ADDR"])) die('Access Is Denied!'); require_once("dbcon.php"); require_once("classes.php"); //REGULAR CRON SCRIPT $num_updates = 1; $result = mysql_query("SELECT `id` FROM `grpgusers`"); while($line = mysql_fetch_assoc($result)) { $updates_user = new User($line['id']); $multiplier = ($updates_user->rmdays) ? .25 : .20; $username = $updates_user->username; $newawake = $updates_user->awake + ($num_updates * 20); $newawake = ($newawake > $updates_user->maxawake) ? $updates_user->maxawake : $newawake; $newhp = $updates_user->hp + round($num_updates * $updates_user->maxhp * $multiplier); $newhp = ($newhp > $updates_user->maxhp) ? $updates_user->maxhp : $newhp; $newenergy = $updates_user->energy + round($num_updates * $updates_user->maxenergy * $multiplier); $newenergy = ($newenergy > $updates_user->maxenergy) ? $updates_user->maxenergy : $newenergy; $newnerve = $updates_user->nerve + round($num_updates * $updates_user->maxnerve * $multiplier); $newnerve = ($newnerve > $updates_user->maxnerve) ? $updates_user->maxnerve : $newnerve; mysql_query('UPDATE `grpgusers` SET `awake` = "'.$newawake.'", `energy` = "'.$newenergy.'", `nerve` = "'.$newnerve.'", `hp` = "'.$newhp.'", `gcrime` = "0" WHERE `id` = '.$updates_user->id); ++$num_updates; } file_put_contents('5mincron_check.txt', "{$num_updates} updates on ".date('l jS \of F Y h:i:s A')."\n"); ?> A bit more efficient, there is no need to select *(everything) in the grpg users as we only use the ID. Also, this outputs into a "5mincron_check.txt" file, each update that happens. So you can follow that to see if something is stopping or not. Edited October 9, 2012 by HauntedDawg Quote Link to comment Share on other sites More sharing options...
Spudinski Posted October 8, 2012 Share Posted October 8, 2012 Just as a reference for other people with this problem... The cronjobs on cPanel, or anywhere else really, executes a command: a shell command. The difference in methods of executing the files via various ways. cURL / wget When using something similar like below, an HTTP(web) request is sent to the scripts/web page: curl http://your.domain.tld/scripts/your_cron.php # normally, an email sent if using cPanel when this is executed wget http://your.domain.tld/scripts/your_cron.php # note, this will save the output into a file This in essence is just the same as you opening up the URL in your browser. It's not recommended to use this approach, as anyone with the URL will be able to execute the script as well unless you protect it(not worth the hasstle). PHP This approach is really the only way you should be using, it gives security in the sense that the script will not be executable through the webserver. You would put the PHP file/script below(lower level in terms of directory) your web (root)directory, and issue a command that will call the PHP interpreter wit han absolute path to the file. php -f /home/you/scripts/your_cron.php No additional security is used for this approach, since no HTTP request is being made to execute the file. Quote Link to comment Share on other sites More sharing options...
thebobby Posted October 8, 2012 Author Share Posted October 8, 2012 Parse error: syntax error, unexpected $end in /home/chelsi86/public_html/55crnssssp.php on line 31 thats hat happens when i try yours HauntedDawg Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted October 9, 2012 Share Posted October 9, 2012 Did you completely overlook what Spudinski stated above? Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted October 9, 2012 Share Posted October 9, 2012 Parse error: syntax error, unexpected $end in /home/chelsi86/public_html/55crnssssp.php on line 31 thats hat happens when i try yours HauntedDawg Ive updated my post, its merely going to output how many users it went through, but you will at least know the script "completed" it's cycle. Quote Link to comment Share on other sites More sharing options...
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.