FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP script to only be accessed by cron
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: PHP script to only be accessed by cron [message #175290 is a reply to message #175289] Wed, 31 August 2011 19:49 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
Luuk wrote:
> On 31-08-2011 10:20, The Natural Philosopher wrote:
>> 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
>
>
> The purpose of this script is not give, at least not by the OP.
> Can you tell here why PHP would not be the 'proper language'?
>

the main thinking Luuk was that to do what he wanted would invove a lot
of calls to libraries that are not a standard part of PHP but are a part
of the C library


Although I stand corrected because get_ppid() does seem to exist in PHP,
and that's half the battle.


I cant remember the way to programmatically read a process table as ps
does, but I am fairly sure php doesn't have a function to do it.



> PHP can be used form the comman line quit well, see:
> http://www.php.net/manual/en/features.commandline.interactive.php
> for some examples
>
> There's NO need to learn how to program in C, if one can do this task in PHP
>

Well firstly if you can code PHP its not a huge step to C, especially if
you have some crib code.

secondly its a shade more secure if you hide passwords and so on inside
nmunged data.

But my real reason was access to system libaries that dont as a rule
come with PHP.

Libproc.a is the standard way I believe to examine the /proc filesystem
where all this info exists.

In the end its a tradeoff between writing something in PHP to
interrogate that, and using some pre-existent source code in C

I've had similar issues with certain things where PHP did not handle
concurrent accesses to certain graphics libraries well. Very strange
bugs happened. Re wrote it in C and no more problems as I used a
different graphics library that PHP did not support.

I am a great fan of PHP but there are times when I abandon it because -
mainly - I need a library it doesn't support.

And I have not yet tackled the issues of writing my own extensions to it.

And although I know you can, I'd rather use shell or C for cron scripts.
PHP can be used, but for me its strengths lie in its easy merging with
HTML and mySQL: Althouh even there, I have written database interfaces
in C easily enough. C just doesn't do outputting of straight HTML the
way a ?> does ! :-)

I suppose at the end of the day is no big deal to write a massive
printf() statement, but is more tedious than a ?>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: php help
Next Topic: Newbie: very basic jquery drag drop
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 04:24:10 GMT 2024

Total time taken to generate the page: 0.03946 seconds