check php_sapi_name() output, if its cli then its being invoked by the cron job since you would use php cli to invoke console jobs. place a check at the start of the controller if (php_sapi_name() == "cli") { // proceed }
Thanks. On Mon, May 12, 2008 at 9:18 PM, Mathew Nik Foscarini <[EMAIL PROTECTED]> wrote: > Well, wouldn't the remote address have the same IP address as the server? > Then again, I can't remember if $_SERVER is defined when running from the > command line? > > if( $_SERVER['SERVER_ADDR'] === $_SERVER['REMOTE_ADDR']) > { > // the client has the same IP as the server. > } > > Another approach would be to check if the command line arguments are set. > When you run PHP from the command line it defines argv and argc to hold the > cli arguments. > > if( isset( $argv ) && isset( $argc ) ) > { > // the command line arguments exist > } > > You could always check the command line for a secret hash code. > > if( $argv[1] === md5('my secret password') ) > { > // I'm run from the command line. > } > > ----- Original Message ---- > From: Action <[EMAIL PROTECTED]> > To: CakePHP <cake-php@googlegroups.com> > Sent: Monday, May 12, 2008 11:36:22 AM > Subject: Re: This is more of a general application design question than a > CakePHP question... > > > So, what is the best way to determine if a controller method is being > called from a cron job vs a normal user? I don't want normal users to > be able to goto the controller method that makes the requests from > these webservices. > > On May 12, 10:17 am, jonknee <[EMAIL PROTECTED]> wrote: > > > So just have a process that checks the remote services every 30-60 > > > seconds or so, it'll be frequently enough and it'll make the whole > > > local data thing so much easier. > > > > That's waaay to frequent and could easily look like abuse. Even large > > aggregators like Google Reader and Bloglines don't do that. And since > > this is a tumble log it's much worse because it's all personalized > > feeds (instead of a single RSS feed for CNN, you have an RSS feed for > > each Flickr user). So instead of making a request every 30 seconds, > > with just 100 users you are making 3 requests a second. That's > > definitely going to be noticed. > > > > I'd start at one or half hour intervals, perhaps with an option to > > poll more frequently (15 minutes?). > ------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now.<http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ> > > > > -- Thanks & Regards, Novice (http://ishuonweb.wordpress.com/). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---