Re: PHP script to only be accessed by cron [message #175285 is a reply to message #175274] |
Wed, 31 August 2011 16:45 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
jwcarlton wrote:
>>> I'm writing a PHP script that I want to ONLY be accessed by a
>>> predefined cron. Can you guys suggest a way to prevent non-cron
>>> accesses?
>> 1/. Write it in a proper language for this purpose, C, not php
>>
>> 2/. Check the id of the parent process: compare that with running
>> processes . If it ain't cron abort the program.
>>
>> 3/. When you have it working, delete the source code.
>>
>>> I wouldn't mind encoding the page, too, JUST in case I have a root
>>> breach (not expected, of course, but not impossible).
>> That's the second reason to write it in C.
>>
>> Since I would
>>
>>> only need to encode one page, once, would it be reasonable to use the
>>> free trial of Zend Guard? Or would you guys suggest something
>>> different?
>> Why not start with the right approach, instead of patching the wrong
>> approach?
>>
>> I like PHP. But its not the only language in town and this is where I
>> would definitely get out the C compiler
>
> I think you make an excellent point, NP. It's been awhile since I've
> messed with C and have forgotten more than I should, but I think
> you're right that it's the appropriate language.
>
> In retrospect, I don't know if I've EVER coded in C. I think I started
> in C++. Oh, well, it's not a big deal to go find a compiler and see
> what I remember :-) "Hello World", here I come! LOL
>
> FWIW, Alvaro, I don't really have a problem, I'm just trying to
> prevent one before it has a chance to happen :-) I figure that it's
> better to tighten it up the best that I can in the beginning, instead
> of trying to come back to it later. I'm more or less just playing with
> this script right now, anyway.
I've been rediscovering C after a few years absence. And trying to
write, if not understand C++. Which I always considered was just too
smart for its own good, and not really needful for the sort of
programming I wanted to do anyway.
I've still got a segfault to sort out in one cron program..sigh. It is
fine when the remote web server has the data. Its fine if the remote
webserver isn't there at all Or refuses the connection..
But I forgot that sometimes web servers can send data like 'sorry, the
data you want is unavailable at this time'..THAT segfaults it..
|
|
|