[PHP] HEAD method in PHP 4.1.2

2004-01-23 Thread Lucas Gonze
Hello PHP world,

I need to fetch headers via a HEAD request.  This is doable via context 
options as of PHP 5.0.0, but the PHP on this server is 4.1.2.  
Upgrading PHP is not an option.

Does anybody know a way to do this?  I realize I can write my own HTTP 
client requests, but doing a good job with that a different thing.

Thanks in advance.

- Lucas Gonze

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Threading & PHP

2004-01-24 Thread Lucas Gonze
One possibility is to have the code which first receives the request 
split it up into subrequests and do HTTP requests for the subrequests.  
Whether that makes sense depends on whether the overhead of an HTTP 
transaction is a big part of the execution time of the subrequests.

- Lucas

On Saturday, Jan 24, 2004, at 15:24 America/New_York, Galen wrote:

Hi,

This may be completely crazy, but let me tell you what I want to do: 
thread PHP.

My server is a dual-processor 2 GHz machine, and it's not very loaded. 
I have a few tasks that are huge and lengthy and would benefit from 
being placed in their own "thread" if you will. This would serve to 
either accelerate the process by splitting it among CPUs or allow the 
process to continue "in the background" for a few seconds after all 
pages have been loaded.

There are two areas where I'd use this:
1) To accelerate results in a relevancy ranking/fuzzy matching 
algorithm I have created, and although I've optimized the heck out of 
it, it can be slow when hundreds of thousands of items are thrown at 
it. It would be easy to split the array in half and run the algorithm 
on both halves, which would almost half processing time for returning 
results.

2) With image processing. When a user uploads an image to a few of my 
pages, the image is processed, re-compressed, and filed in the 
database or a file system. This can take several seconds, and I'd 
prefer that the user doesn't have to wait for the process to complete.

How might I be able to make some PHP code run as a "thread" that would 
serve these purposes?

-Galen

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] problem identifying $_SERVER['HTTP_REFERER']

2004-02-05 Thread Lucas Gonze

First thing to do is figure out whether the problem is with the referrer
var or with your code.  Try adding a logger to dump all environment vars
to a log file, then check it the next time one of these errors comes up.

good luck.

- Lucas

On Thu, 5 Feb 2004, Pablo Gosse wrote:

> Hi all.  I've got a simple mailer script that I wrote a few years ago
> that has been acting up over the past week.
>
> The problem is with the following check I perform at the very top of the
> script:
>
> if (!stristr($_SERVER['HTTP_REFERER'],"unbc.ca")) {
>   die("You can't access this script outside of our domain.");
> }
>
> The mailer is located in my personal webspace on the web.unbc.ca server
> and the calling forms are all located on www.unbc.ca.
>
> For some reason some people (apparently around 10 over the past week)
> are getting this error from two particular forms, but I know for certain
> that these forms are within our domain.
>
> Does anyone know why this would be happening other than someone making
> an illegal copy of the form and posting it on another domain (which I
> doubt is the case)?
>
> As I wrote earlier this script is about three years old, so at the time
> I didn't code using the $_SERVER and $_POST vars and just refered to
> them variable names explicitly.  However, the PHP version on the machine
> hasn't changed for a long time (4.1.2) so I can't see why this would
> suddenly start happening now.
>
> To be safe I've just converted all the $_SERVER and $_POST vars in the
> script to use these references, so I'll be interested to see if the
> error goes away but I doubt it will.
>
> I was debating writing a simple regular expression to use instead of the
> stristr check but I don't really think it will make a difference as the
> only way the stristr check will fail is if the string 'unbc.ca' is NOT
> found in the referring page.
>
> Does anyone have any idea what could be causing this problem?  Short of
> removing the check altogether I can't really see another way around it.
>
> Cheers and thanks much in advance,
>
> Pablo
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need a way to automate user logout

2004-02-05 Thread Lucas Gonze

One way is to save the time of last access every time a user requests a
page, then poll to find users for whom now() - last_access_time >
TIMEOUT.

- Lucas

On Thu, 5 Feb 2004, Christian Calloway wrote:

> Damn stateless nature of HTTP, hey everyone, can someone point me or give me
> an idea on how I would automatically log out (destroy user sessions and make
> note of it in the database) on some type of schedule. I have designed a
> security system that depends upon people logging out to determine the amount
> of time they have accumalated on their accounts. Of course people do not
> always (never) do this, so I need a way to do it for them. We are running
> redhat linux, I am sure there is a way to say run a certain script at a
> certain time blah blah etc etc. But I am only a programmer, and am
> absolutely clueless on the finer points of nix. I can write a script in
> perl, php, java, u name it, but how do I have it run on a set schedule?
> Thanks
>
> Christian
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] post variables

2004-02-17 Thread Lucas Gonze

I can't think of a reason for this, so I would doublecheck your
assumptions.  There is a $_SERVER variable to check the method.

You might want to put the php printenv.php page in place of your current
script to see what it says about the request method and POST variables.

- Lucas

On Tue, 17 Feb 2004, julian haffegee wrote:

> Hi all,
>
> I am having a nightmare accessing my POST variables. I can red them if I use
> the GET method on my form, but POST is always blank
>
> I have
>
> while( list($key, $value) = each ($_POST)){
>   print "$key  $value";
> }
> print "_REQUEST: "; print_r($_REQUEST);
> print "_GET: "; print_r($_GET);
> print "_POST: "; print_r($_POST);
>
> at the top which tells me its not working.
>
> I have a workaround using perl, but I need to sort this once and for only
> uing php
>
> What have I forgotten?
>
> Please help, and thanks if you can!
>
> Jules
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] post variables (SpamEnder: BLOCKED 8BZF-SE44074-lgonze@panix.com) (fwd)

2004-02-17 Thread Lucas Gonze

Is it possible to ban subscribers who issue this kind of auto-response?

-- Forwarded message --
Date: Tue, 17 Feb 2004 21:33:04 -
From: Alan Hale <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: Re: [PHP] post variables (SpamEnder:  BLOCKED
[EMAIL PROTECTED])

In an effort to eliminate unsolicited e-mail, I have installed SpamEnder.
Please REPLY to this e-mail, without modifying the subject line, so that I
can receive your original message. Upon my approval, future e-mails you send
to me will be released automatically. If you do not REPLY to this e-mail,
SpamEnder will block all future e-mails from this address and will not give
you another opportunity to reply.

Copyright 2003, Evolvian, Inc. (http://www.evolvian.com/)

--
Excerpt from original message:

I can't think of a reason for this, so I would doublecheck your
assumptions.  There is a $_SERVER variable to check the method.

You might want to put the php printenv.php page in place of your current
script to see what it says about the request method and POST variables.

- Lucas

On Tue, 17 Feb 2004, julian haffegee wrote:

> Hi all,
>
> I am having a nightmare accessing my POST variables. I can red them if I
use
> the GET method on my form, but POST is always blank
>
> I have
>
> while( list($key, $value) = each ($_POST)){
>   print "$key  $value";
> }
> print "_REQUEST: "; print_r($_REQUEST);
> print "_GET: "; print_r($_GET);
> print "_POST: "; print_r($_POST);
>
> at the top which tells me its not working.
>
> I have a workaround using perl, but I need to sort this once and for only
> uing php
>
> What have I forgotten?
>
> Please help, and thanks if you can!
>
> Jules
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.574 / Virus Database: 364 - Release Date: 29/01/2004

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] sending reply, the continuing

2004-02-20 Thread Lucas Gonze
I have a situation where I want to send a cached result back then 
recalculate the cache.  This is necessary because it takes a long time 
to generate a page.  Is there a way for me to return what the browser 
needs, then terminate the connection without stopping my script?

Thanks in advance.

- Lucas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] sending reply, the continuing

2004-02-20 Thread Lucas Gonze
s/the continuing/then continuing/

"The continuing" sounds like a Steven King title.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Fwd: [PHP] sending reply, the continuing

2004-02-20 Thread Lucas Gonze
On Friday, Feb 20, 2004, at 13:52 America/New_York, Pablo Gosse wrote:
If by terminate the connection you mean stop sending back information 
to
the browser, then perhaps you should look into output control 
functions:

http://ca3.php.net/manual/en/ref.outcontrol.php
Well, the best match there is ob_end_flush, as far as I can tell.  
Unfortunately that keeps the connection alive while the cache is being 
recalculated, so that even though the browser has everything it's going 
to get almost immediately, the throbber keeps going for quite a while, 
thereby freaking out my users.  :(

I could fork(), have the parent exit, and regenerate the cache in the 
child process, but pcntl_fork is not designed for a web server 
environment.*

- Lucas

* http://www.php.net/manual/en/ref.pcntl.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] sending reply, the continuing

2004-02-20 Thread Lucas Gonze
On Friday, Feb 20, 2004, at 14:30 America/New_York, John W. Holmes 
wrote:
Maybe register_shutdown_function()?
Hm, so the way this works is that my shutdown function is called after 
the connection is terminated, and I do the work there...  I'm going to 
implement this and see how well it works.

Nice bit of PHP obscurantia, John.

- Lucas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] sending reply, the continuing

2004-02-20 Thread Lucas Gonze
On Friday, Feb 20, 2004, at 14:57 America/New_York, Chris W. Parker 
wrote:

how about having your php script execute another php script via the
command line?
wouldn't this allow the web page to close it's connection while the
command line continued to do it's thing unaware of what was going on
with the web server?
I thought about that but ended up not doing it for fear of zombies -- 
that was my interpretation of the warning in the documentation that CGI 
scripts shouldn't futz with process control.

In the end the cleanest solution was to set up a cron job which fetches 
the cache regenerator.  This was purely an issue of convenience.  I 
implemented both the cron solution and the callback solution, and found 
that the version using the callback wasn't working.  Obviously this 
meant a bug, but given that the solutions are roughly as good as one 
another I just stuck with the one that was quicker.

Thanks folks!

- Lucas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Safe Mode

2004-02-21 Thread Lucas Gonze
On Saturday, Feb 21, 2004, at 09:18 America/New_York, 
[EMAIL PROTECTED] wrote:
Is it possible to set Apache in such a way that everyting is run under 
safe-mode, except for a directory and everything underneath in a 
virtual domain?
Very likely yes, if your admin permits it.  The place to look for an 
answer is in documentation for httpd.conf.

Good luck.

- Lucas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Safe Mode

2004-02-21 Thread Lucas Gonze
On Saturday, Feb 21, 2004, at 20:17 America/New_York, 
[EMAIL PROTECTED] wrote:

Lucas Gonze wrote:
On Saturday, Feb 21, 2004, at 09:18 America/New_York, 
[EMAIL PROTECTED] wrote:
Is it possible to set Apache in such a way that everyting is run 
under safe-mode, except for a directory and everything underneath in 
a virtual domain?
Very likely yes, if your admin permits it.  The place to look for an 
answer is in documentation for httpd.conf.
Good luck.
- Lucas
Can safe mode be turned off in the .htaccess file?
My guess is no.  That is a decision which should belong to the server 
admin.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: Re[4]: [PHP] Detecting Binaries

2004-02-23 Thread Lucas Gonze
Alternatively, count unigrams in the first 1000 characters and get the 
euclidean distance to a sample from e.g. an english text, a french 
text, a chinese text, etc.

- Lucas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Doing things in the background

2004-03-02 Thread Lucas Gonze

One solution is to use a javascript body.write to output the  HTML before you start processing, then do your
processing, then issue another body.write to reset the URL of the current
page to the result display page.

- Lucas

On Tue, 2 Mar 2004, Dan McCullough wrote:

>
>
> Have a script where I need to submit a form and then while its doing its
> magic show a animated gif and then display the results.
> Also anyone know a good site for a document in indexing tables in mysql.
>
> dan mccullough
> sr. engineer
> url:  heathermccullough.com
> tf:   866.298.3991
> w:   603.444.9808
> 
> There is no such thing as a problem, unless the servers are on fire.
> Sometimes great opportunity comes brilliantly disguised as bad news.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] "calling" one php script from another

2004-03-03 Thread Lucas Gonze


On Wed, 3 Mar 2004, Brian V Bonini wrote:

> On Wed, 2004-03-03 at 14:49, Jim & Sara Feldman wrote:
> > Does anyone know of a way to jump from one php script to
> > another without going through the client browser? The closest I have
> > been able to come to doing that is to use nested frames where the
> > parent frame can call multiple php scripts, one for each child frame.
>
> header("Location: /path/to/script/foo.php");

Won't that redirect through the browser?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php