icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » Coding and Programming » PHP / cron job - Oh just help if you can please.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old February 14th, 2006, 4:35 AM   #1 (permalink)
Surpass Fan
Excelling Contributor
 
Joined in Feb 2004
Lives in Rotorua New Zealand
Hosted on Pass3
738 posts
Gave thanks: 0
Thanked 2 times
PHP / cron job - Oh just help if you can please.

I have a question from a client I am hosting. The question makes no sense at all to me being a programming idiot, but the team here is pretty smart so I thought I'd throw it open to the panel :-)

""we are trying to move images to another folder once processed.

I tried using move_uploaded_file, but was unable to since the file was ftp'd up instead of sent up via HTTP PUT (which is a requirement of move_uploaded_file). So I tried using the rename php function which will not work - it gives an error saying "Permission denied". Is there a way to give the php script permissions to carry out regular file operations when it is run from within a person's browser (which can only happen if they have entered a password to get access to that file). The script will also be run from a CRON job.

Could you check with the brains .
Any help would be gratefully appreciated.""
__________________
Pass3
www.beadit.co.nz
'Most Concise' Surpasser 2004
javaqueen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 14th, 2006, 4:48 AM   #2 (permalink)
I'm Dope as Crack
Resident.
 
David's Avatar
 
Joined in Mar 2004
Lives in Asheboro, NC
Hosted on Pass 7
13,036 posts
Gave thanks: 7
Thanked 29 times
What about using the copy() function? I don't know how you'd go about using it exactly, but from the look of it on php.net, it looks like a way to go. You'd just have to delete the file afterwards.
__________________
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 14th, 2006, 5:13 AM   #3 (permalink)
Surpass Fan
Excelling Contributor
 
Joined in Feb 2004
Lives in Rotorua New Zealand
Hosted on Pass3
738 posts
Gave thanks: 0
Thanked 2 times
Thanks David - I'll pass it on.
__________________
Pass3
www.beadit.co.nz
'Most Concise' Surpasser 2004
javaqueen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 14th, 2006, 10:39 AM   #4 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
mr_fern's Avatar
 
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
When they upload via FTP, the files belong to their username. When they run a PHP script through the browser, the script is run as nobody. That's why they couldn't rename the file. The file would need to be writeable by the world (i.e. chmod'd to 666) before the php script could modify it.

PHP Cron Jobs are usually done in two flavors, "php /path/to/script" and "lynx http://site.com/location/to/script"

If they do the cron jobs in the first way, php runs under their username, so the cron job can rename the file.

If they do the lynx method, then it's the same issue as running it in their web browser.

---------

If they decide to do the copy() method that David suggested, you could suggest to them to have the script also save the original filenames to a text file, and then create another cron job which reads that file and removes the originals. The cron job just has to be specifically ran as "php /path/to/script" to ensure the script has the proper permissions. That way they don't have to manually delete the files personally afterwards.
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 14th, 2006, 1:05 PM   #5 (permalink)
Surpass Fan
Excelling Contributor
 
Joined in Feb 2004
Lives in Rotorua New Zealand
Hosted on Pass3
738 posts
Gave thanks: 0
Thanked 2 times
Thanks Mr Fern, that almost makes sense to me :-), I'll pass it on. Thanks
__________________
Pass3
www.beadit.co.nz
'Most Concise' Surpasser 2004
javaqueen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On