Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron problem - Passing Parameters

Status
Not open for further replies.

tcardoso

Programmer
Jan 31, 2005
56
PT
Hi,

how can I pass parameters in cron job like I tried:

{...domain...}\cron_test.php?code=CRONCODE

and in cron_test.php I had:
if($_GET['code'] != "CRONCODE") {
print "WTF are you looking?";
die("");
}
//rest of cron code here

But it wont work... if I remove ?code=CRONCODE from cron job and if($_GET['code'] line from php it work (but without any protection)

If there is another way to protect cron jobs :) say...

Thanks,
Telmo Cardoso
 
when you say, won't work - what happens? does it always print the WTF text?

if so i'd suggest a tweak:

Code:
if (empty($_GET['code']) || strtolower(trim($_GET['code'))] !== 'croncode'){
  die('bad code');
}

bear in mind that passing any data to a webpage other than over ssl is insecure. a more secure solution would be to use SSL and htaccess or some other challenge-response paradigm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top