php-general Digest 5 Nov 2007 06:25:36 -0000 Issue 5110

Topics (messages 264025 through 264038):

How do I specify a local file for fopen()?
        264025 by: Jon Westcot
        264028 by: Cristian Vrabie

Re: How to replace  define in a require file with mysql?
        264026 by: Ronald Wiplinger

Question about php.ini file
        264027 by: Jon Westcot
        264029 by: Cristian Vrabie
        264030 by: Jon Westcot
        264031 by: Nathan Nobbe
        264032 by: Jon Westcot
        264034 by: Jon Westcot
        264036 by: Jochem Maas

Looking for ways to prevent timeout
        264033 by: Jon Westcot
        264035 by: Jochem Maas
        264037 by: Nathan Nobbe

php 4.4.7 configure and sablotron version issue
        264038 by: Edward Vermillion

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hi all:

    I've been beating my head against a brick wall trying to figure this out 
and I'm still no closer than I was two weeks ago.

    How do I specify a local file on my computer to use with fopen() on the 
server?

    I've checked and the allow_url_fopen setting is set to On.  I use the html 
<input type="file"> to let me browse to the file.  This, however, forces me to 
also POST the entire file to the server, which I DO NOT WANT it to do.  I just 
wanted to be able to use the <Browse> button to get to the file name.  But, 
even when I do this, the file name returned in the $_FILES array doesn't give 
me a file name that fopen() will actually open.

    Do I somehow have to get the server to recognize my computer as an 
http-based address?  If so, how do I do this?  The computer that has the file 
to be opened is a Windows-based computer (running WinXP or Vista), and it 
obviously has an Internet connection.  Do I need to retrieve, from the server, 
my computer's IP address and use that, in whole or in part, to reference the 
file to be opened?  If so, how?

    While I'm asking questions, does anyone know how to keep the file 
referenced in the <input type="file"> setup from actually being sent?  All I 
think I really need is the NAME of the file, not its actual contents, since I'm 
hoping to use fopen() to open the file and then to use fgetcsv() to retrieve 
the contents.

    ANY help you all can send my way will be greatly appreciated!

    Thanks in advance,

        Jon

--- End Message ---
--- Begin Message --- Server can't access files on clients computers as they wish or it would be madness. Nothing would be secure. However you can get to the file if you make it public in some way and with some restrictions. Therea are several methods: 1. (wich i think is best) install a ftp server and "share" the file through the server. use the php's ftp function to access the file 2. install a webserver like apache and place the file you want in the web-root folder (the public on). use fopen or whatever you want to open the file.

you must keep in mind that in order to do this you have to have a public ip adress (you can't do it if youre behind nat)


Jon Westcot wrote:
Hi all:

    I've been beating my head against a brick wall trying to figure this out 
and I'm still no closer than I was two weeks ago.

    How do I specify a local file on my computer to use with fopen() on the 
server?

    I've checked and the allow_url_fopen setting is set to On.  I use the html <input 
type="file"> to let me browse to the file.  This, however, forces me to also POST the 
entire file to the server, which I DO NOT WANT it to do.  I just wanted to be able to use the 
<Browse> button to get to the file name.  But, even when I do this, the file name returned in 
the $_FILES array doesn't give me a file name that fopen() will actually open.

    Do I somehow have to get the server to recognize my computer as an 
http-based address?  If so, how do I do this?  The computer that has the file 
to be opened is a Windows-based computer (running WinXP or Vista), and it 
obviously has an Internet connection.  Do I need to retrieve, from the server, 
my computer's IP address and use that, in whole or in part, to reference the 
file to be opened?  If so, how?

    While I'm asking questions, does anyone know how to keep the file referenced in the 
<input type="file"> setup from actually being sent?  All I think I really need 
is the NAME of the file, not its actual contents, since I'm hoping to use fopen() to open the 
file and then to use fgetcsv() to retrieve the contents.

    ANY help you all can send my way will be greatly appreciated!

    Thanks in advance,

        Jon


--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
> Ronald Wiplinger wrote:
>> I have a file linked with require into my program with statements like:
>>
>> define("_ADDRESS","Address");
>> define("_CITY","City");
>>
>> I would like to replace this with a mysql table with these two fields
>> (out of many other fields).
>>
>> How can I do that?
>>
>> bye
>>
>> Ronald
>>
> Well, if you have all the settings in a DB already, then what I would
> do is this.
>
> SELECT param_name, param_value FROM yourTable;
>
> then
>
> while ( list($name, $value) = mysql_fetch_row($results_handler) ) {
>     define($name, $value);
> }
>
> put this in place of your existing defines and you should be good.
>

Thanks! Works fine!
I need now a modification for that.

Two values:
SELECT param_name, param_value1, param_value2 FROM yourTable;

IF param_value1 is empty, than it should use param_value2

How can I add this?

Thank you again.

bye

Ronald

--- End Message ---
--- Begin Message ---
Hi all:

    I've learned, much to my pleasure, that I can place a php.ini file in the 
root directory of my shared domain to allow some customization of the php 
settings.  However, when I do this, I keep getting weird results.  Some of the 
values that I change appear as I've asked them to be.  Some appear to not 
change at all.  And some have been changing to what appears to be default 
values for php.

    I'm wondering a few things here.  First, my computer is Windows-based, but 
the server is Linux-based.  Do I need to somehow convert the Windows text file 
line termination characters to their Linux variants?  If so, how?  Is it 
possible that I'm trying to change values beyond some upper limit which is 
causing php to use the default value?

    The main values that I'm trying to change are:

        post_max_size
        upload_max_filesize
        memory_limit
        max_execution_time
        max_input_time

    If anyone knows of upper limits for these, I'd appreciate learning about 
them.

    As always, any help you can send my way will be greatly appreciated!

    Thanks,

        Jon

--- End Message ---
--- Begin Message --- You must take in count that before php even gets to receive something, it all passes through the HTTP server (apache or something). for most of these settings there are equivalents in the config file of the server that you need to change accordingly. this might be the cause of the weird results. for example, if your limit for uploaded files is 10M in php but the server is set to accept max 5M, 5M will be the limit

Jon Westcot wrote:
Hi all:

    I've learned, much to my pleasure, that I can place a php.ini file in the 
root directory of my shared domain to allow some customization of the php 
settings.  However, when I do this, I keep getting weird results.  Some of the 
values that I change appear as I've asked them to be.  Some appear to not 
change at all.  And some have been changing to what appears to be default 
values for php.

    I'm wondering a few things here.  First, my computer is Windows-based, but 
the server is Linux-based.  Do I need to somehow convert the Windows text file 
line termination characters to their Linux variants?  If so, how?  Is it 
possible that I'm trying to change values beyond some upper limit which is 
causing php to use the default value?

    The main values that I'm trying to change are:

        post_max_size
        upload_max_filesize
        memory_limit
        max_execution_time
        max_input_time

    If anyone knows of upper limits for these, I'd appreciate learning about 
them.

    As always, any help you can send my way will be greatly appreciated!

    Thanks,

        Jon


--- End Message ---
--- Begin Message ---
Hi Cristian:

    Thanks for the replies.

    In this case, what I've been noticing is that most of the values have
gone DOWN (i.e., gotten smaller) after I placed my own php.ini file in
place.  For example, upload_max_filesize was 8M before I placed my file,
but, afterwards, it was 2M!  I'm trying to increase this size, not decrease
it.

    Could it be the line-ending characters that are causing the problem?
Could PHP be seeing the new file but not realizing how to process it, which
would cause the values to flop over to their defaults?

    Thanks,

        Jon

----- Original Message -----

> You must take in count that before php even gets to receive something,
> it all passes through the HTTP server (apache or something). for most of
> these settings there are equivalents in the config file of the server
> that you need to change accordingly.
> this might be the cause of the weird results. for example, if your limit
> for uploaded files is 10M in php but the server is set to accept max 5M,
> 5M will be the limit
>
> Jon Westcot wrote:
> > Hi all:
> >
> >     I've learned, much to my pleasure, that I can place a php.ini file
in the root directory of my shared domain to allow some customization of the
php settings.  However, when I do this, I keep getting weird results.  Some
of the values that I change appear as I've asked them to be.  Some appear to
not change at all.  And some have been changing to what appears to be
default values for php.
> >
> >     I'm wondering a few things here.  First, my computer is
Windows-based, but the server is Linux-based.  Do I need to somehow convert
the Windows text file line termination characters to their Linux variants?
If so, how?  Is it possible that I'm trying to change values beyond some
upper limit which is causing php to use the default value?
> >
> >     The main values that I'm trying to change are:
> >
> >         post_max_size
> >         upload_max_filesize
> >         memory_limit
> >         max_execution_time
> >         max_input_time
> >
> >     If anyone knows of upper limits for these, I'd appreciate learning
about them.
> >
> >     As always, any help you can send my way will be greatly appreciated!
> >
> >     Thanks,
> >
> >         Jon

--- End Message ---
--- Begin Message ---
On 11/4/07, Jon Westcot <[EMAIL PROTECTED]> wrote:
>
> Hi Cristian:
>
>     Thanks for the replies.
>
>     In this case, what I've been noticing is that most of the values have
> gone DOWN (i.e., gotten smaller) after I placed my own php.ini file in
> place.  For example, upload_max_filesize was 8M before I placed my file,
> but, afterwards, it was 2M!  I'm trying to increase this size, not
> decrease
> it.
>
>     Could it be the line-ending characters that are causing the problem?
> Could PHP be seeing the new file but not realizing how to process it,
> which
> would cause the values to flop over to their defaults?


do you have ssh access to the server?
i recommend you start out by creating the simplest file you can by editing
it
directly on the linux server, via vim or w/e.
then using a phpinfo() script, you should see your overridden value in the
left
column (those are for the locally overridden values).
some other things to note are;

   1. apache must be properly configured to allow the .htaccess
   overrides.
   2. you cant override all the values in php.ini; see the documentation

regarding which ones can be overriden and where

here is an article regarding the process,
http://gentoo-wiki.com/HOWTO_php.ini_overrides_w/_.htaccess

-nathan

--- End Message ---
--- Begin Message ---
Hi Nathan:

    I'm not certain if I have all of the items you've mentioned, but I'll look 
into it.  And thanks for the link; I'll check that out, too.

    Jon

----- Original Message ----- 
From: Nathan Nobbe 
To: Jon Westcot 
Cc: PHP General 
Sent: Sunday, November 04, 2007 5:05 PM
Subject: Re: [PHP] Question about php.ini file


On 11/4/07, Jon Westcot <[EMAIL PROTECTED]> wrote:
  Hi Cristian:

      Thanks for the replies.

      In this case, what I've been noticing is that most of the values have
  gone DOWN (i.e., gotten smaller) after I placed my own php.ini file in
  place.  For example, upload_max_filesize was 8M before I placed my file, 
  but, afterwards, it was 2M!  I'm trying to increase this size, not decrease
  it.

      Could it be the line-ending characters that are causing the problem?
  Could PHP be seeing the new file but not realizing how to process it, which 
  would cause the values to flop over to their defaults?

do you have ssh access to the server?
i recommend you start out by creating the simplest file you can by editing it
directly on the linux server, via vim or w/e. 
then using a phpinfo() script, you should see your overridden value in the left
column (those are for the locally overridden values).
some other things to note are;

  1.. apache must be properly configured to allow the .htaccess overrides. 
  2.. you cant override all the values in php.ini; see the documentation
regarding which ones can be overriden and where


here is an article regarding the process, 
http://gentoo-wiki.com/HOWTO_php.ini_overrides_w/_.htaccess

-nathan


--- End Message ---
--- Begin Message ---
Hi Nathan:

    Another quick question regarding the use of the .htaccess file:

    If I'm trying to set something like post_max_size, which takes a shorthand 
value such as 16M in place of the full value, will using the php_value type of 
statement also accept the shorthand value, or do I need to place in the full 
value?

    Thanks again; this solution may be exactly what we need!

    Jon

----- Original Message ----- 
From: Nathan Nobbe 
To: Jon Westcot 
Cc: PHP General 
Sent: Sunday, November 04, 2007 5:05 PM
Subject: Re: [PHP] Question about php.ini file


On 11/4/07, Jon Westcot <[EMAIL PROTECTED]> wrote:
  Hi Cristian:

      Thanks for the replies.

      In this case, what I've been noticing is that most of the values have
  gone DOWN (i.e., gotten smaller) after I placed my own php.ini file in
  place.  For example, upload_max_filesize was 8M before I placed my file, 
  but, afterwards, it was 2M!  I'm trying to increase this size, not decrease
  it.

      Could it be the line-ending characters that are causing the problem?
  Could PHP be seeing the new file but not realizing how to process it, which 
  would cause the values to flop over to their defaults?

do you have ssh access to the server?
i recommend you start out by creating the simplest file you can by editing it
directly on the linux server, via vim or w/e. 
then using a phpinfo() script, you should see your overridden value in the left
column (those are for the locally overridden values).
some other things to note are;

  1.. apache must be properly configured to allow the .htaccess overrides. 
  2.. you cant override all the values in php.ini; see the documentation
regarding which ones can be overriden and where


here is an article regarding the process, 
http://gentoo-wiki.com/HOWTO_php.ini_overrides_w/_.htaccess

-nathan


--- End Message ---
--- Begin Message ---
Jon Westcot wrote:
> Hi Nathan:
> 
>     Another quick question regarding the use of the .htaccess file:
> 
>     If I'm trying to set something like post_max_size, which takes a 
> shorthand value such as 16M in place of the full value, will using the 
> php_value type of statement also accept the shorthand value, or do I need to 
> place in the full value?

yes, valid values for ini settings are the same regardless of where you set 
them (.ini, apache conf, php script)

> 
>     Thanks again; this solution may be exactly what we need!
> 
>     Jon
> 
> ----- Original Message ----- 
> From: Nathan Nobbe 
> To: Jon Westcot 
> Cc: PHP General 
> Sent: Sunday, November 04, 2007 5:05 PM
> Subject: Re: [PHP] Question about php.ini file
> 
> 
> On 11/4/07, Jon Westcot <[EMAIL PROTECTED]> wrote:
>   Hi Cristian:
> 
>       Thanks for the replies.
> 
>       In this case, what I've been noticing is that most of the values have
>   gone DOWN (i.e., gotten smaller) after I placed my own php.ini file in
>   place.  For example, upload_max_filesize was 8M before I placed my file, 
>   but, afterwards, it was 2M!  I'm trying to increase this size, not decrease
>   it.
> 
>       Could it be the line-ending characters that are causing the problem?
>   Could PHP be seeing the new file but not realizing how to process it, which 
>   would cause the values to flop over to their defaults?
> 
> do you have ssh access to the server?
> i recommend you start out by creating the simplest file you can by editing it
> directly on the linux server, via vim or w/e. 
> then using a phpinfo() script, you should see your overridden value in the 
> left
> column (those are for the locally overridden values).
> some other things to note are;
> 
>   1.. apache must be properly configured to allow the .htaccess overrides. 
>   2.. you cant override all the values in php.ini; see the documentation
> regarding which ones can be overriden and where
> 
> 
> here is an article regarding the process, 
> http://gentoo-wiki.com/HOWTO_php.ini_overrides_w/_.htaccess
> 
> -nathan
> 
> 

--- End Message ---
--- Begin Message ---
Hi all:

    I'm hoping to find a solution to the problem I'm having with my script 
timing out while inserting records into a table.

    Overall, the process is pretty fast, which is impressive, but when it gets 
to the 22,000 to 23,000 record mark, it seems to time out.  I've had it get up 
over 26,000 so far, but nothing better than that.  And I only need to process 
around 30,000 right now.

    I've tried setting max_execution_time to 1800; no improvement.  The value 
for max_input_time is -1, which, if I understood it correcctly, is the same as 
saying no limit.  And I've tried calling set_time_limit() with both 0 and with 
360, none of which seemed to help.

    Is there ANY WAY to increase the amount of time I can use when running a 
script that will work?  I've tried everything I can find in the PHP manual.

    Any help you can provide will be greatly appreciated!

        Jon

--- End Message ---
--- Begin Message ---
Jon Westcot wrote:
> Hi all:
> 
>     I'm hoping to find a solution to the problem I'm having with my script 
> timing out while inserting records into a table.
> 
>     Overall, the process is pretty fast, which is impressive, but when it 
> gets to the 22,000 to 23,000 record mark, it seems to time out.  I've had it 
> get up over 26,000 so far, but nothing better than that.  And I only need to 
> process around 30,000 right now.
> 
>     I've tried setting max_execution_time to 1800; no improvement.  The value 
> for max_input_time is -1, which, if I understood it correcctly, is the same 
> as saying no limit.  And I've tried calling set_time_limit() with both 0 and 
> with 360, none of which seemed to help.
> 
>     Is there ANY WAY to increase the amount of time I can use when running a 
> script that will work?  I've tried everything I can find in the PHP manual.
> 
>     Any help you can provide will be greatly appreciated!

http://php.net/ignore_user_abort will help, but nothing will stop you hitting a 
max execution time.
but my guess is your not hitting the max but rather the browser is killing the 
connection because it's
had no response fom your script and as a result apache is killing your script 
as it thinks it's no longer
needed (i.e. the browser no longer wants the response).

> 
>         Jon
> 

--- End Message ---
--- Begin Message ---
On 11/4/07, Jon Westcot <[EMAIL PROTECTED]> wrote:
>
> Hi all:
>
>     I'm hoping to find a solution to the problem I'm having with my script
> timing out while inserting records into a table.
>
>     Overall, the process is pretty fast, which is impressive, but when it
> gets to the 22,000 to 23,000 record mark, it seems to time out.  I've had it
> get up over 26,000 so far, but nothing better than that.  And I only need to
> process around 30,000 right now.
>
>     I've tried setting max_execution_time to 1800; no improvement.  The
> value for max_input_time is -1, which, if I understood it correcctly, is the
> same as saying no limit.  And I've tried calling set_time_limit() with both
> 0 and with 360, none of which seemed to help.
>
>     Is there ANY WAY to increase the amount of time I can use when running
> a script that will work?  I've tried everything I can find in the PHP
> manual.
>
>     Any help you can provide will be greatly appreciated!


are you familiar with ajax ?
i would build some client side tool that would split the job into a series
of requests.
say, you input 20,000; then the script fires off 5 requests, to do 4000
inserts a piece.
you could easily implement a status bar and it would be guaranteed to work.
also, it would scale just about as high as you can imagine.

-nathan

--- End Message ---
--- Begin Message --- Anybody trying to build php 4.4.7 with xslt/sablotron support? I'm setting up a new Debian server and configure kept quitting on Sablotron saying the version was less than 0.96. Looking at /usr/ include/sablot.h, it shows the version at 1.0.3. Configure was saying it was using /usr, and I couldn't find another salbot.h anywhere on the system, so as far as I can tell I was looking at the same file as configure.

I was looking in ext/xslt/config.m4 at:
[snip]

AC_TRY_RUN([
#include <stdlib.h>
#include <sablot.h>

int main ()
{
        double version;
        version = atof(SAB_VERSION);
        
        if (version >= 0.96) {
                exit(0);
        }
        exit(255);
}
    ],[
      AC_MSG_RESULT([>= 0.96])
    ],[
      AC_MSG_ERROR([Sablotron version 0.96 or greater required.])
    ])

[/snip]


and from sablot.h
[snip]

/* version info */
#define SAB_VERSION "1.0.3"
#define SAB_DATE "June 26, 2006"

[/snip]

I don't know enough about the configure test to say there's a bug there, but then I couldn't figure out how to get it to work either. Tried setting the SAB_VERSION define in sablot.h to 9 just to see if it would work, but no go. Finally gave up and removed the xslt stuff from the config options since I don't have a real need for them right now.

So anyone else having this problem, or know how to fix it?

Ed

--- End Message ---

Reply via email to