Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 17th, 2006, 03:45 PM
Bob Bedford
Guest
 
Posts: n/a
Default serious problem need help.

Hi all,
I'm having troubles with my hosting and for a few reasons I can't change.

So here is my problem: I receive XML files with images included in the file.
I've to parse the file, save datas in a database and save images after
resizing them. The whole process takes sometimes more than 10 seconds (the
limit of the scripts) so I've errors.

It's there any way to have an other process that do the image processing
(like an automatic "post" wich send the images) ? How ? Exec isnt' allowed
on the server.

Please help....

Bob



  #2  
Old October 17th, 2006, 04:05 PM
.:[ ikciu ]:.
Guest
 
Posts: n/a
Default Re: serious problem need help.

Hmm Bob Bedford <bob@bedford.comwrote:
Quote:
images after resizing them. The whole process takes sometimes more
than 10 seconds (the limit of the scripts) so I've errors.
then you should to set new time limit for script execution


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this =mysql_query();


  #3  
Old October 17th, 2006, 04:35 PM
Bob Bedford
Guest
 
Posts: n/a
Default Re: serious problem need help.

then you should to set new time limit for script execution

Obviously you guess I can't do it !!! I can't modify anything in the server
settings.

Bob



  #4  
Old October 17th, 2006, 05:45 PM
.:[ ikciu ]:.
Guest
 
Posts: n/a
Default Re: serious problem need help.

Hmm Bob Bedford <bob@bedford.comwrote:
Quote:
Quote:
>then you should to set new time limit for script execution
>
Obviously you guess I can't do it !!! I can't modify anything in the
server settings.

why?

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this =mysql_query();


  #5  
Old October 17th, 2006, 06:25 PM
Tim Hunt
Guest
 
Posts: n/a
Default Re: serious problem need help.


Bob Bedford wrote:
Quote:
Quote:
then you should to set new time limit for script execution
>
Obviously you guess I can't do it !!! I can't modify anything in the server
settings.
>
Bob
Some hosts let you change the timeout using ini_set, does yours?

If not could you split the processing over two scripts?

In the first script parse the xml file, update database, copy the image
to a temporary file and use $_SESSION to store the temp filename. Then
redirect to the second script using header('Location:') and let the 2nd
script finish off the resizing & database updates

This way you have a whole twenty seconds to play with.

  #6  
Old October 17th, 2006, 06:25 PM
Stefan
Guest
 
Posts: n/a
Default Re: serious problem need help.

..:[ ikciu ]:. wrote:
Quote:
Hmm Bob Bedford <bob@bedford.comwrote:
Quote:
Quote:
>>then you should to set new time limit for script execution
>>
>Obviously you guess I can't do it !!! I can't modify anything in the
>server settings.
>
>
why?
>
he can't, thats it. Maybe he has a shared hosting service.
Bob, I heared of a method how the script calles itself if the execution-time
reaches a limit. Maybe that could be helpfull. I saw it in a script, but i
don't remember its name, it was about mysql, mysqldump or something like
that.
Stefan
  #7  
Old October 17th, 2006, 07:35 PM
Bob Bedford
Guest
 
Posts: n/a
Default Re: serious problem need help.

Some hosts let you change the timeout using ini_set, does yours?
No, id doesn't allow using ini_set. (it would be too simple).
Quote:
If not could you split the processing over two scripts?
That's the way I'm looking for.
Quote:
>
In the first script parse the xml file, update database, copy the image
to a temporary file and use $_SESSION to store the temp filename. Then
redirect to the second script using header('Location:') and let the 2nd
script finish off the resizing & database updates
>
This way you have a whole twenty seconds to play with.
It's there any way in PHP to execute (without using location as it changes
page) a new page ? I don't have access to exec()...
My idea is to manage the recording in the database then every time I've new
images, send them to a new script. The main process will do easely in 10
seconds then every process will redim and save the images (time consuming)
and it may also do it in 10 seconds.

Problem: I don't know how to do so (launch an other script without exec)
passing the files (like a normal post or get will do).

Bob



  #8  
Old October 17th, 2006, 07:55 PM
Moot
Guest
 
Posts: n/a
Default Re: serious problem need help.


Bob Bedford wrote:
Quote:
Hi all,
I'm having troubles with my hosting and for a few reasons I can't change.
>
So here is my problem: I receive XML files with images included in the file.
I've to parse the file, save datas in a database and save images after
resizing them. The whole process takes sometimes more than 10 seconds (the
limit of the scripts) so I've errors.
>
It's there any way to have an other process that do the image processing
(like an automatic "post" wich send the images) ? How ? Exec isnt' allowed
on the server.
>
Please help....
>
Bob
Do you have access to CRON? If so, you could parse the xml upon
retrieval and store the paths to the images to be redimensioned in a
table queue. You could then have a cron script run once a minute or
(as often as necessary) to try and clear out the queue.

  #9  
Old October 17th, 2006, 08:45 PM
Daz
Guest
 
Posts: n/a
Default Re: serious problem need help.


Moot wrote:
Quote:
Do you have access to CRON? If so, you could parse the xml upon
retrieval and store the paths to the images to be redimensioned in a
table queue. You could then have a cron script run once a minute or
(as often as necessary) to try and clear out the queue.
Another alternative to CRON, would be to create a script that checks if
anything needs to be done every time a page is clicked upon. It can be
as simple as adding a function call or include() to the pages you want
to act as the trigger. It's more of an advantage when you get heavier
traffic on a website, but it's a possibility. I think the best place to
add a trigger, would be to the footer (if you use one) which would be
appended to every page, and trigger last thing, so it wouldn't
interfere with the page generation for the user.

  #10  
Old October 17th, 2006, 09:25 PM
Tim Hunt
Guest
 
Posts: n/a
Default Re: serious problem need help.


Bob Bedford wrote:
Quote:
Quote:
Some hosts let you change the timeout using ini_set, does yours?
No, id doesn't allow using ini_set. (it would be too simple).
>
Quote:
If not could you split the processing over two scripts?
That's the way I'm looking for.
>
Quote:

In the first script parse the xml file, update database, copy the image
to a temporary file and use $_SESSION to store the temp filename. Then
redirect to the second script using header('Location:') and let the 2nd
script finish off the resizing & database updates

This way you have a whole twenty seconds to play with.
It's there any way in PHP to execute (without using location as it changes
page) a new page ? I don't have access to exec()...
My idea is to manage the recording in the database then every time I've new
images, send them to a new script. The main process will do easely in 10
seconds then every process will redim and save the images (time consuming)
and it may also do it in 10 seconds.
>
Problem: I don't know how to do so (launch an other script without exec)
passing the files (like a normal post or get will do).
>
You can curl or sockets to post data to another script

http://uk.php.net/manual/en/ref.curl.php
http://uk.php.net/manual/en/function.fsockopen.php.

The 1st script may timeout waiting for the response, I dont think this
will affect the execution of the 2nd script, as long as the 2nd script
starts before the 1st timeouts. A best guess not a guarantee..

  #11  
Old October 17th, 2006, 09:35 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: serious problem need help.

Bob Bedford wrote:
Quote:
Quote:
>>Some hosts let you change the timeout using ini_set, does yours?
>
No, id doesn't allow using ini_set. (it would be too simple).
>
>
Quote:
>>If not could you split the processing over two scripts?
>
That's the way I'm looking for.
>
>
Quote:
>>In the first script parse the xml file, update database, copy the image
>>to a temporary file and use $_SESSION to store the temp filename. Then
>>redirect to the second script using header('Location:') and let the 2nd
>>script finish off the resizing & database updates
>>
>>This way you have a whole twenty seconds to play with.
>
It's there any way in PHP to execute (without using location as it changes
page) a new page ? I don't have access to exec()...
My idea is to manage the recording in the database then every time I've new
images, send them to a new script. The main process will do easely in 10
seconds then every process will redim and save the images (time consuming)
and it may also do it in 10 seconds.
>
Problem: I don't know how to do so (launch an other script without exec)
passing the files (like a normal post or get will do).
>
Bob
>
>
>
Bob,

You don't "launch another page with exec()". Rather, you redirect to
the new page with header('Location: pagename').

Just be sure you don't create any output before this. And you can save
the data you're working on in the session (or pass it as GET parameters).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #12  
Old October 17th, 2006, 09:45 PM
.:[ ikciu ]:.
Guest
 
Posts: n/a
Default Re: serious problem need help.

Hmm Bob Bedford <bob@bedford.comwrote:
Quote:
Quote:
>then you should to set new time limit for script execution
..htaccess or ini_set()


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this =mysql_query();


  #13  
Old October 18th, 2006, 01:05 AM
Rik
Guest
 
Posts: n/a
Default Re: serious problem need help.

Daz wrote:
Quote:
Moot wrote:
Quote:
>Do you have access to CRON? If so, you could parse the xml upon
>retrieval and store the paths to the images to be redimensioned in a
>table queue. You could then have a cron script run once a minute or
>(as often as necessary) to try and clear out the queue.
>
Another alternative to CRON, would be to create a script that checks
if anything needs to be done every time a page is clicked upon. It
can be as simple as adding a function call or include() to the pages
you want to act as the trigger. It's more of an advantage when you
get heavier traffic on a website, but it's a possibility. I think the
best place to add a trigger, would be to the footer (if you use one)
which would be appended to every page, and trigger last thing, so it
wouldn't interfere with the page generation for the user.
Yup, perhaps flush(), and maybe on more traffic (allthough, on more traffic
an other hoster might be more helpfull), create a possibility it's fired:

if(rand(0,99) == 1){
//run script
}

--
Rik Wasmus


  #14  
Old October 18th, 2006, 07:05 AM
Bob Bedford
Guest
 
Posts: n/a
Default Re: serious problem need help.

You can curl or sockets to post data to another script
Quote:
>
http://uk.php.net/manual/en/ref.curl.php
http://uk.php.net/manual/en/function.fsockopen.php.
>
The 1st script may timeout waiting for the response, I dont think this
will affect the execution of the 2nd script, as long as the 2nd script
starts before the 1st timeouts. A best guess not a guarantee..
Thanks for your reply, I'll have a look at this solution.

Cheers



  #15  
Old October 18th, 2006, 07:15 AM
Bob Bedford
Guest
 
Posts: n/a
Default Re: serious problem need help.

You don't "launch another page with exec()". Rather, you redirect to the
Quote:
new page with header('Location: pagename').
>
Just be sure you don't create any output before this. And you can save
the data you're working on in the session (or pass it as GET parameters).
I wanted to avoid to redirect as I've to pass by all records I've already
done every time I call the script again and this will be very long.

I've got an other answer it has been said to "refresh" the page. Will first
look at fsockopen then at this solution. Maybe I'll do both.

Thanks.

Bob



  #16  
Old October 18th, 2006, 11:15 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: serious problem need help.

Bob Bedford wrote:
Quote:
Quote:
>>You don't "launch another page with exec()". Rather, you redirect to the
>>new page with header('Location: pagename').
>>
>>Just be sure you don't create any output before this. And you can save
>>the data you're working on in the session (or pass it as GET parameters).
>
>
I wanted to avoid to redirect as I've to pass by all records I've already
done every time I call the script again and this will be very long.
>
I've got an other answer it has been said to "refresh" the page. Will first
look at fsockopen then at this solution. Maybe I'll do both.
>
Thanks.
>
Bob
>
>
>
Yes, I understand it would be a hassle to skip over already-processed
records. It's one reason I suggested saving the info in your session.
Once you've processed a record you can remove it from the "to be
processed" list (and if necessary add it to a "completed" list).

Refresh is just redirect to the same page, which you can do, also. But
fsockopen() won't help. The process doing the fsockopen() will still
time out after 10 seconds. You need to actually transfer control to
another page (or the same one again).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
 

Bookmarks

Thread Tools

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

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

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles