php-general Digest 29 Dec 2001 00:47:18 -0000 Issue 1079

Topics (messages 78929 through 78987):

Re: is_uploaded_file
        78929 by: Andrey Hristov
        78946 by: Paul Roberts
        78947 by: Andrey Hristov
        78948 by: Paul Roberts
        78949 by: Andrey Hristov
        78965 by: Jim Lucas [php]

Links
        78930 by: Niklas Saers Mailinglistaccount

backtracing of includes
        78931 by: Henning Sprang
        78932 by: Jerry Verhoef (UGBI)
        78934 by: Henning Sprang
        78935 by: Paul Burney

Re: Generate Alphabet
        78933 by: Bogdan Stancescu

Only one instance of a script at a time !
        78936 by: Nicolas Guilhot
        78937 by: Jerry Verhoef (UGBI)
        78938 by: Julio Nobrega Trabalhando
        78939 by: Gerard Onorato
        78940 by: akul.otamedia.com
        78942 by: Andrey Hristov
        78944 by: Nicolas Guilhot
        78953 by: Gerard Onorato
        78954 by: Brian Clark

Re: Exec as user
        78941 by: charlesk

PHP + GD + IIS -=-=-=-=-=- I solved the problem -=-=-=-=-=-=-
        78943 by: EMIN CALIKLI

Re: MsSQL from FreeBSD
        78945 by: Brian Clark

Re: crack lib
        78950 by: Johnson, Kirk
        78952 by: Brian Clark

Re: MySql and /var/lib/mysql/mysql.sock Problem !!!
        78951 by: Brian Clark

redirect phpinfo output
        78955 by: charlesk
        78958 by: R'twick Niceorgaw

Help on JavaScript Windows with PHP
        78956 by: Carlos Fernando Scheidecker Antunes
        78962 by: Bogdan Stancescu

Mirroring via FTP
        78957 by: PaulC

How to desactivate some functions ?
        78959 by: Yves REVEILLON
        78960 by: Julio Nobrega Trabalhando

Searching a string or similar
        78961 by: Ash
        78963 by: Bogdan Stancescu
        78964 by: David Piasecki

Part II: Help on JavaScript Windows with PHP
        78966 by: Carlos Fernando Scheidecker Antunes
        78982 by: Bogdan Stancescu

find the fake users
        78967 by: Bas Jobsen

phpmyadmin blob blues
        78968 by: Paul S.
        78970 by: Bas Jobsen
        78973 by: Paul S.

Temp File missing Win2k
        78969 by: Ben Edwards

PHP certification
        78971 by: clint
        78972 by: Andrey Hristov

dot files in php directories
        78974 by: Paul S.

I'm having trouble handling POST file uploads... HELP!
        78975 by: Uchendu Nwachukwu

PEAR vs PHPLIB
        78976 by: Dennis Gearon
        78981 by: Manuel Lemos
        78986 by: Mark Charette

concurrent users
        78977 by: Jamie Fields
        78980 by: Ash

Dynamic Array Q
        78978 by: Chris Allen
        78979 by: Chris Allen

Security bulletin?
        78983 by: Bogdan Stancescu

More on Help on JavaScript Windows with PHP
        78984 by: Carlos Fernando Scheidecker Antunes
        78985 by: Bogdan Stancescu

ARGGG! File uploading on a local Windows box.
        78987 by: David Balatero

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 ---
Read the docs about copy_uploaded_file() (this is the function with some more docs, as 
I remember).


HTH

Andrey Hristov
----- Original Message ----- 
From: "Paul Roberts" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 2:41 PM
Subject: [PHP] is_uploaded_file


> I'm on PHP/4.0.2
> 
> i'm getting 
> Fatal error: Call to undefined function: is_uploaded_file() 
> 
> how can i emulate the function 
> 
> will also nag my host but...
> 
> 
> Paul Roberts
> [EMAIL PROTECTED]
> ++++++++++++++++++++++++
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 

--- End Message ---
--- Begin Message ---
no it's move_uploaded_file and it's 4.03 or greater as well.

i'm using empty() as i just want to see if i uploaded a file or not


Paul Roberts
[EMAIL PROTECTED]
++++++++++++++++++++++++
----- Original Message -----
From: "Andrey Hristov" <[EMAIL PROTECTED]>
To: "Paul Roberts" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 12:48 PM
Subject: Re: [PHP] is_uploaded_file


> Read the docs about copy_uploaded_file() (this is the function with some
more docs, as I remember).
>
>
> HTH
>
> Andrey Hristov
> ----- Original Message -----
> From: "Paul Roberts" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, December 28, 2001 2:41 PM
> Subject: [PHP] is_uploaded_file
>
>
> > I'm on PHP/4.0.2
> >
> > i'm getting
> > Fatal error: Call to undefined function: is_uploaded_file()
> >
> > how can i emulate the function
> >
> > will also nag my host but...
> >
> >
> > Paul Roberts
> > [EMAIL PROTECTED]
> > ++++++++++++++++++++++++
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>

--- End Message ---
--- Begin Message ---
>From : http://www.php.net/manual/en/features.file-upload.php
<?php
/* Userland test for uploaded file. */
function is_uploaded_file($filename) {
    if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
        $tmp_file = dirname(tempnam('', ''));
    }
    $tmp_file .= '/' . basename($filename);
    /* User might have trailing slash in php.ini... */
    return (ereg_replace('/+', '/', $tmp_file) == $filename);
} if (is_uploaded_file($userfile)) {
    copy($userfile, "/place/to/put/uploaded/file");
} else {
    echo "Possible file upload attack: filename '$userfile'.";
}
?>

HTH

Regards,
Andrey Hristov

----- Original Message ----- 
From: "Paul Roberts" <[EMAIL PROTECTED]>
To: "Andrey Hristov" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 5:13 PM
Subject: Re: [PHP] is_uploaded_file


> no it's move_uploaded_file and it's 4.03 or greater as well.
> 
> i'm using empty() as i just want to see if i uploaded a file or not
> 
> 
> Paul Roberts
> [EMAIL PROTECTED]
> ++++++++++++++++++++++++
> ----- Original Message -----
> From: "Andrey Hristov" <[EMAIL PROTECTED]>
> To: "Paul Roberts" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Friday, December 28, 2001 12:48 PM
> Subject: Re: [PHP] is_uploaded_file
> 
> 
> > Read the docs about copy_uploaded_file() (this is the function with some
> more docs, as I remember).
> >
> >
> > HTH
> >
> > Andrey Hristov
> > ----- Original Message -----
> > From: "Paul Roberts" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, December 28, 2001 2:41 PM
> > Subject: [PHP] is_uploaded_file
> >
> >
> > > I'm on PHP/4.0.2
> > >
> > > i'm getting
> > > Fatal error: Call to undefined function: is_uploaded_file()
> > >
> > > how can i emulate the function
> > >
> > > will also nag my host but...
> > >
> > >
> > > Paul Roberts
> > > [EMAIL PROTECTED]
> > > ++++++++++++++++++++++++
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 

--- End Message ---
--- Begin Message ---
yep it all works on my dev server but the host only has 4.02 installed these
functions are php 4.03+


----- Original Message -----
From: "Andrey Hristov" <[EMAIL PROTECTED]>
To: "Paul Roberts" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 3:26 PM
Subject: Re: [PHP] is_uploaded_file


> From : http://www.php.net/manual/en/features.file-upload.php
> <?php
> /* Userland test for uploaded file. */
> function is_uploaded_file($filename) {
>     if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
>         $tmp_file = dirname(tempnam('', ''));
>     }
>     $tmp_file .= '/' . basename($filename);
>     /* User might have trailing slash in php.ini... */
>     return (ereg_replace('/+', '/', $tmp_file) == $filename);
> } if (is_uploaded_file($userfile)) {
>     copy($userfile, "/place/to/put/uploaded/file");
> } else {
>     echo "Possible file upload attack: filename '$userfile'.";
> }
> ?>
>
> HTH
>
> Regards,
> Andrey Hristov
>
> ----- Original Message -----
> From: "Paul Roberts" <[EMAIL PROTECTED]>
> To: "Andrey Hristov" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Friday, December 28, 2001 5:13 PM
> Subject: Re: [PHP] is_uploaded_file
>
>
> > no it's move_uploaded_file and it's 4.03 or greater as well.
> >
> > i'm using empty() as i just want to see if i uploaded a file or not
> >
> >
> > Paul Roberts
> > [EMAIL PROTECTED]
> > ++++++++++++++++++++++++
> > ----- Original Message -----
> > From: "Andrey Hristov" <[EMAIL PROTECTED]>
> > To: "Paul Roberts" <[EMAIL PROTECTED]>
> > Cc: <[EMAIL PROTECTED]>
> > Sent: Friday, December 28, 2001 12:48 PM
> > Subject: Re: [PHP] is_uploaded_file
> >
> >
> > > Read the docs about copy_uploaded_file() (this is the function with
some
> > more docs, as I remember).
> > >
> > >
> > > HTH
> > >
> > > Andrey Hristov
> > > ----- Original Message -----
> > > From: "Paul Roberts" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Friday, December 28, 2001 2:41 PM
> > > Subject: [PHP] is_uploaded_file
> > >
> > >
> > > > I'm on PHP/4.0.2
> > > >
> > > > i'm getting
> > > > Fatal error: Call to undefined function: is_uploaded_file()
> > > >
> > > > how can i emulate the function
> > > >
> > > > will also nag my host but...
> > > >
> > > >
> > > > Paul Roberts
> > > > [EMAIL PROTECTED]
> > > > ++++++++++++++++++++++++
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > To contact the list administrators, e-mail:
[EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail:
[EMAIL PROTECTED]
> > >
> > >
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
>

--- End Message ---
--- Begin Message ---
I had 4.0.0 for a year or more and used that stuff quite well.
And the docs says :
"For earlier versions of PHP, you'll need to do something like
      the following.

Note: This will not work in versions of PHP 4
        after 4.0.2. It depends on internal functionality of PHP which
        changed after that version."


If one of your boxes is 4.0.2 and the other 4.0.3 use the output of phpinfo() with 
some kind of hack to determine wich one of the
function to use, or just write a wrapper which decides pipe to which function to make.


Regards,
Andrey Hristov

--- End Message ---
--- Begin Message ---
take a look at this little function.. :)  you might like it

http://www.php.net/manual/en/function.function-exists.php

----- Original Message -----
From: "Andrey Hristov" <[EMAIL PROTECTED]>
To: "Paul Roberts" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 7:35 AM
Subject: Re: [PHP] is_uploaded_file


> I had 4.0.0 for a year or more and used that stuff quite well.
> And the docs says :
> "For earlier versions of PHP, you'll need to do something like
>       the following.
>
> Note: This will not work in versions of PHP 4
>         after 4.0.2. It depends on internal functionality of PHP which
>         changed after that version."
>
>
> If one of your boxes is 4.0.2 and the other 4.0.3 use the output of
phpinfo() with some kind of hack to determine wich one of the
> function to use, or just write a wrapper which decides pipe to which
function to make.
>
>
> Regards,
> Andrey Hristov
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>

--- End Message ---
--- Begin Message ---
Hi. I've got the following problem. I've taken over a website of about
1200 static pages. Yes, that's right, 1200 static pages. Containing
roundabout a zillion working and broken links. I've done my job and made a
system that actually works, importing each page (manually with a
publishing tool written for the occation in PHP), adding the metadata
needed for nice searching and presenting in the three languages I need to
support, and actually got the system working. (yes, I will probably be
writing an article about the lot, because it contained multiple fun
challenges (and of course the bit about 1200 pages routine work :-/ ) ) To
finish off, I've got one last barrier. All these pages contained links.
Because I've actually categorized the information, in addition to the
already broken links, most are now totally broken. I've set up a handler
that takes care of the most 'duh'-style breaks (like index.html now being
index.php), but I've still go to go through all these funny links and
change them. Because I'm a user at the box, not root, and the webserver
owns most of the documents that I've only got read-access to, I need to
make a script that reads the document, extracts all the links (a href and
img src mainly) and lets me edit them. Does anyone have a decent regex
string that would allow me to get all the links and then do a
search-replace through the document to put in the correct ones?

Cheers

        Nik

--- End Message ---
--- Begin Message ---
Hy,
I would like to know if there is a way to get information on the include
hierarchy of files in php, especially to find out where which file is
included and trace back the line from some file until the first called
php file.

My special case here and now is that I get an error that some function
is already declared and cannot be declared again because of this.
I know i must have included the file with that function somewhere
already, but as i have lots of nested includes I have trouble right now
to find the place where ist already happens.
I know I can prevent those things in future by using things as
require_once and so on, and i can search through all the code, making
yself a map on paper to see which file includes what, but what i really
want to know is, if i can ask some function to tell me where the
function which makes the error stated above and from where the file is
included, and from where this file again is include, going as far back
until i have my first-called php file.



I hope you can understand what i mean,

henning


--- End Message ---
--- Begin Message ---
Don't think that a option like this exists.

But maybe you should consider using 

include_once or 
require_once

Also before you define the function use the function_exist("") and if the
function already exists don't redecleare it.

Jerry Verhoef

-----Original Message-----
From: Henning Sprang [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 28, 2001 2:24 PM
To: [EMAIL PROTECTED]
Subject: [PHP] backtracing of includes


Hy,
I would like to know if there is a way to get information on the include
hierarchy of files in php, especially to find out where which file is
included and trace back the line from some file until the first called
php file.

My special case here and now is that I get an error that some function
is already declared and cannot be declared again because of this.
I know i must have included the file with that function somewhere
already, but as i have lots of nested includes I have trouble right now
to find the place where ist already happens.
I know I can prevent those things in future by using things as
require_once and so on, and i can search through all the code, making
yself a map on paper to see which file includes what, but what i really
want to know is, if i can ask some function to tell me where the
function which makes the error stated above and from where the file is
included, and from where this file again is include, going as far back
until i have my first-called php file.



I hope you can understand what i mean,

henning



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


The information contained in this email is confidential and
may be legally privileged. It is intended solely for the 
addressee. Access to this email by anyone else is 
unauthorized. If you are not the intended recipient, any 
form of disclosure, production, distribution or any action 
taken or refrained from in reliance on it, is prohibited and 
may be unlawful. Please notify the sender immediately.

The content of the email is not legally binding unless 
confirmed by letter bearing two authorized signatures.
--- End Message ---
--- Begin Message ---
Hy,

Am 28 Dec 2001 14:27:50 +0100 schrieb Jerry Verhoef (UGBI):
> Don't think that a option like this exists.
> 
> But maybe you should consider using 
> 
> include_once or 
> require_once
> 
> Also before you define the function use the function_exist("") and if the
> function already exists don't redecleare it.

That's what I wrote - I know I can use things like that, but I am
curious if there are other ways to find out which file is included by
what and which function is defined in which file - i didn't find answers
about that in the manual.

Meanwhile I found out what the real problem was, namely that a function
was declared inside a function, and the parent function was called
twice, resulting in an error. I think it's generally not recommended to
declare functions inside functions as I see no obvious reason now when
this should be useful, only that it can make things complicated as i saw
right now.(btw: this code does not come from myself, i am just making
additions to it)

So, I am still curious if and how one can trace function definitions and
includes in a convenient way.

henning

--- End Message ---
--- Begin Message ---
on 12/28/01 8:53 AM, Henning Sprang at [EMAIL PROTECTED] wrote:

> That's what I wrote - I know I can use things like that, but I am
> curious if there are other ways to find out which file is included by
> what and which function is defined in which file - i didn't find answers
> about that in the manual.

I'm not sure if there is anything built in that you can use, but you
probably should start with the:

__FILE__ and __LINE__

constants.  The __FILE__ constant is the name of the script file being
executed.  If it's in an include file, it will be the name of the include
file, not the parent file.  The __LINE__ is the current line within the file
(include).

HTH.

Paul Burney

<?php
    while ($self != "asleep") {
        $sheep_count++;
    }
?>


--- End Message ---
--- Begin Message ---
Philip Olson wrote:

> > I seriously doubt your code works -- have you tested it? I think the code
> > you submitted will most probably output "1 2 3 4...24 25 26" (spaces are
> > actually \n's). I never tested it though, so I may be mistaken.
>
> Yes, it works.  Test it before posting such doubts :)
>
> Regards,
> Philip Olson

Ok, tested it and to my surprize it does work. But why?!

Questions:
1. $letter++ -- why doesn't this evaluate $letter as integer before
incrementing?
2. print $letter++ -- why doesn't this evaluate to "b" at the first loop when
it's already 'a'? Ok, this I may be able to explain because it's neither "print
++$letter" nor "print ($letter++)", but I wouldn't have trusted this syntax to
work this way a million years!

Nice, elegant code indeed! Apologies for doubting it! :-)

Bogdan



--- End Message ---
--- Begin Message ---
Running a php script with a cron job, how can I do to have only one instance
of the script running ?

Thanks for any answer.


Nicolas

--- End Message ---
--- Begin Message ---
Pseudo code:

check if pid file exists
yes -> DIE
no -> write pid file

At end of script
delete pid file

Jerry Verhoef

-----Original Message-----
From: Nicolas Guilhot [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 28, 2001 3:32 PM
To: Php General MailingList
Subject: [PHP] Only one instance of a script at a time !


Running a php script with a cron job, how can I do to have only one instance
of the script running ?

Thanks for any answer.


Nicolas


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


The information contained in this email is confidential and
may be legally privileged. It is intended solely for the 
addressee. Access to this email by anyone else is 
unauthorized. If you are not the intended recipient, any 
form of disclosure, production, distribution or any action 
taken or refrained from in reliance on it, is prohibited and 
may be unlawful. Please notify the sender immediately.

The content of the email is not legally binding unless 
confirmed by letter bearing two authorized signatures.
--- End Message ---
--- Begin Message ---
  Another idea, run a script that opens a file and flocks it until it's
executed. I am sorry if this is dumb as I have little experience on locking
files, but, I guess if it's locked it won't get opened again and executed
(via include() or eval());

--

Julio Nobrega.

Um dia eu chego lá:
http://sourceforge.net/projects/toca

Ajudei? Salvei? Que tal um presentinho?
http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884


"Jerry Verhoef" <[EMAIL PROTECTED]> wrote in message
1CDA86C6527BD311B91F0008C784121003D551DF@ugbiex1">news:1CDA86C6527BD311B91F0008C784121003D551DF@ugbiex1...
> Pseudo code:
>
> check if pid file exists
> yes -> DIE
> no -> write pid file
>
> At end of script
> delete pid file
>
> Jerry Verhoef
>
> -----Original Message-----
> From: Nicolas Guilhot [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 28, 2001 3:32 PM
> To: Php General MailingList
> Subject: [PHP] Only one instance of a script at a time !
>
>
> Running a php script with a cron job, how can I do to have only one
instance
> of the script running ?
>
> Thanks for any answer.
>
>
> Nicolas
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
> The information contained in this email is confidential and
> may be legally privileged. It is intended solely for the
> addressee. Access to this email by anyone else is
> unauthorized. If you are not the intended recipient, any
> form of disclosure, production, distribution or any action
> taken or refrained from in reliance on it, is prohibited and
> may be unlawful. Please notify the sender immediately.
>
> The content of the email is not legally binding unless
> confirmed by letter bearing two authorized signatures.


--- End Message ---
--- Begin Message ---
There may be a much easier method however why not write a file and then check for it's 
existence on the next execution. Delete the file at the end of 
execution to clear the way  for the next pass.

Quick and dirty so probably at least on typo
<?
$pidFile = "path/to/file/filename";
if (!is_file ($pidFile)) {
        touch ($pidFile);
        // code to execute
        unlink ($pidFile);
}
?>
On Fri, 28 Dec 2001 15:31:33 +0100, Nicolas Guilhot wrote:

>Running a php script with a cron job, how can I do to have only one instance
>of the script running ?
>
>Thanks for any answer.
>
>
>Nicolas
>
>
>-- 
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>



--- End Message ---
--- Begin Message ---
Hello Jerry,

Friday, December 28, 2001, 5:37:39 PM, you wrote:

JVU> Pseudo code:

JVU> check if pid file exists
yes ->> DIE
no ->> write pid file

JVU> At end of script
JVU> delete pid file

  This code can't guarantee the result. Use file locking instead.
  

JVU> -----Original Message-----
JVU> From: Nicolas Guilhot [mailto:[EMAIL PROTECTED]]
JVU> Sent: Friday, December 28, 2001 3:32 PM
JVU> To: Php General MailingList
JVU> Subject: [PHP] Only one instance of a script at a time !


JVU> Running a php script with a cron job, how can I do to have only one instance
JVU> of the script running ?






-- 
Best regards,
 akul                            mailto:[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Under *nix - SysV semaphores

HTH

Regards,
Andrey Hristov
----- Original Message ----- 
From: "Nicolas Guilhot" <[EMAIL PROTECTED]>
To: "Php General MailingList" <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 4:31 PM
Subject: [PHP] Only one instance of a script at a time !


> Running a php script with a cron job, how can I do to have only one instance
> of the script running ?
> 
> Thanks for any answer.
> 
> 
> Nicolas
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 

--- End Message ---
--- Begin Message ---
I was thinking about this solution, but what can I do if the script ends
prematurely. The file will never be deleted ??
Anybody has an example of how to use flock ?

Nicolas

"Gerard Onorato" <[EMAIL PROTECTED]> a écrit dans le message news:
[EMAIL PROTECTED]
> There may be a much easier method however why not write a file and then
check for it's existence on the next execution. Delete the file at the end
of
> execution to clear the way  for the next pass.
>
> Quick and dirty so probably at least on typo
> <?
> $pidFile = "path/to/file/filename";
> if (!is_file ($pidFile)) {
> touch ($pidFile);
> // code to execute
> unlink ($pidFile);
> }
> ?>
> On Fri, 28 Dec 2001 15:31:33 +0100, Nicolas Guilhot wrote:
>
> >Running a php script with a cron job, how can I do to have only one
instance
> >of the script running ?
> >
> >Thanks for any answer.
> >
> >
> >Nicolas
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
>


--- End Message ---
--- Begin Message ---
Nicolas,

You could try something like

<?
$pifFile = "/path/to/file/filename";
if(file_exists($pifFile))
{
  $fp = fopen($pifFile, "r");
  flock($fp, 2);
        // your code
  fclose($fp);
} 

Note: Just wrote it, not tested.
Note: You would probably want to do somethig more graceful then simply rely on the 
file existing... like create the file if it doesn't exist and then lock it.
Note: From the manual - flock() will not work on NFS and many other networked file 
systems. Check your operating system documentation for more details. 
On some operating systems flock() is implemented at the process level. When using a 
multithreaded server API like ISAPI you may not be able to rely on flock() to 
protect files against other PHP scripts running in parallel threads of the same server 
instance! 



>Anybody has an example of how to use flock ?

--- End Message ---
--- Begin Message ---
* Nicolas Guilhot ([EMAIL PROTECTED]) [Dec 28. 2001 10:00]:

> I was thinking about this solution, but what can I do if the script ends
> prematurely. The file will never be deleted ??

It's a nasty hack, but you chould run a separate shell script to 
check for the existance of the running script, then call the script 
if it's not running.

something like (/bin/sh):

PID=`ps aux | grep [program] | grep -v grep | awk {'print $2'}` 

Replace [program] with the program name.

That'll get you the PID if the script is already running. You can kill
it, or just exit instead, for example. That's one way..

-- 
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
$ mount -t neuro /dev/brain /mnt/head

--- End Message ---
--- Begin Message ---
I tried echo %PATH% > test.txt and both the webpage and the dos prompt echo the 
correct path information.  This shows that a batch file executed by php can access the 
system vars. They have a diffence only in accessing the %USERNAME% variable.  Could 
this be indicative that it is running as the system user?  If so how do I change that?

Charles Killmer

---------- Original Message ----------------------------------
From: Mike Eheler <[EMAIL PROTECTED]>
Date: Thu, 27 Dec 2001 16:56:21 -0800

Try doing this

<?
     echo '<pre>';
     print_r(array($HTTP_SERVER_VARS,$HTTP_ENV_VARS));
     echo '</pre>';
?>

And see if the information you want is in there anywhere.

Mike

> I don't believe that the system variables are available to php.  I work on
> *nix mostly, but I have a windows machine at home running php and I can't
> access any of my system var's.
> ----- Original Message -----
> From: "charlesk " <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, December 27, 2001 11:33 AM
> Subject: [PHP] Exec as user
> 
> 
> 
>>I have been looking through the docs and found no help on either finding
>>
> which user the EXEC'ed commands run as, or how to specify which user they
> should run as.  I tried exec, system, and passthru running a batch file that
> would write %USERNAME% to a file.  And all three functions wrote nothing.
> They would however write "hello world".  Has anybody else run into this.
> 
>>I tried exec("test.bat");
>>test.bat:
>>echo %USERNAME% > test.txt
>>
>>when run from a command line it resulting in "Charles"
>>when run from a webpage it resulted in "ECHO is on."
>>if I added a line "echo off" above the echo username it resulted in "ECHO
>>
> is off." again only from the webpage.
> 
>>In essense I need to update a DNS server through a web page.  It works if
>>
> the script is local but not if it has to update a different server.
> 
>>Charles Killmer
>>Windows 2000 Server, IIS 5.0, PHP 4.1.0
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>>
>>
>>
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---

Hi Brian ,
I 've solved the problem :)... :)... :)... :)... :)... :)... :)... :)... :)... :)... 
:)... :)...
:)... :)... :)
I installed version of php 4.0.7 (php-4.0.7rc1-win32.zip) ;

1- I extracted zip package ,
2- I copied (also configured) php.ini file to my \winnt folder. (with php_gd.dll and 
php_mssql.dll)
3- I copied php4ts.dll to /winnt/system32 driver (it's important for isapi)
4- I copied ntwdblib.php to /winnt/system32 driver (it's important for MsSQL 7.0 
extension)
5- I configured IIS to run php extensions with isapi .
6- I started the IIS service and I tested with my basic code which uses GD library .
7- And...Dadaaaaaa.... Everything is worked....

I think php 4.0.6 (which makes me crazy) have a problem with GD library.
Sincerely.

--- End Message ---
--- Begin Message ---
* Valentin V. Petruchek ([EMAIL PROTECTED]) [Dec 28. 2001 04:51]:

> > OK, we're talking about Linux, right?

> No ;) FreeBsd 4.x don't know exactly about x

Duh, that was stupid of me. It's right there in the subject.

> > I'll bet `cat /proc/sys/fs/file-max` gives you 4096

OK, then give this a try:

sysctl -w kern.maxfiles=8192
sysctl -w kern.maxfilesperproc=8192

(or however high you want to go)

And it may need a reboot; I dont know if that would take effect
immediately (check it with ulimit -n after you do it). If it works, 
you might have to stick that in rc.local in order to get it to stick 
whenever you reboot. 

Again, I don't know if that'll have any effect.. 

-- 
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
One World, One Web, One Program.

--- End Message ---
--- Begin Message ---

Hey, what is everyone talking about? What is the new crack lib
functionality? Is it in the docs yet?

TIA

Kirk
--- End Message ---
--- Begin Message ---
* Johnson, Kirk ([EMAIL PROTECTED]) [Dec 28. 2001 10:54]:


> Hey, what is everyone talking about? What is the new crack lib
> functionality? Is it in the docs yet?

<http://download.php.net/manual/en/ref.crack.php>
<http://www.zugeschaut-und-mitgebaut.de/php/extension.crack.html>

-- 
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
STATUS QUO is Latin for the mess we're in.

--- End Message ---
--- Begin Message ---
* ger ([EMAIL PROTECTED]) [Dec 27. 2001 20:05]:

>                Does anybody know what is my problem ?

> I try to access to my mysql database and I get the next errror :

> " Can't connect trough /var/lib/mysql/mysql.sock "  

I'm sure you've checked to see if the mysql server is running..

The socket should be owner:group mysql (or whatever user you set up to
run the mysql server).

Are you trying to access it via PHP or just the command line?

If it's PHP, you could try altering mysql.default_socket in your
php.ini to what mysql expects. Run mysqladmin and check to see where the
socket is:

mysqladmin -u root -p[password] variables

Replace [password] with your real password.

Otherwise, you can set it by altering $MYSQL_UNIX_PORT in your
safe_mysqld script, or in whatever file you're using to start mysqld, to
please PHP, but it may break other applications that depend on it being
somewhere else. Check those scripts, they're probably defining the socket 
in there somewhere.

-- 
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
UNIX: measuring in inconvenient units since 57,974,400!

--- End Message ---
--- Begin Message ---
How can I redirect the output from phpinfo to a file.
If I try 
error_log(phpinfo(),3,"z:\\".date("YmdHis").".html");

all that is in the file is the number 1.

The output gets sent to the user.

Charles Killmer
--- End Message ---
--- Begin Message ---
buffer the output of phpinfo() using ob_start() then get the buffer using
ob_get_contents() and store it in your new html file using fwrite()
hope this helps
R'twick
----- Original Message -----
From: "charlesk " <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 12:15 PM
Subject: [PHP] redirect phpinfo output


> How can I redirect the output from phpinfo to a file.
> If I try
> error_log(phpinfo(),3,"z:\\".date("YmdHis").".html");
>
> all that is in the file is the number 1.
>
> The output gets sent to the user.
>
> Charles Killmer
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>

--- End Message ---
--- Begin Message ---
Hello all!

I've wrote to scripts that use Javascript too. The idea is to have a parent
window teste_popup.php4 and a child window pop.php4. When a link is clicked
on the parent window, the child window will open. After the user enters
information on the child window he must close it and that will update the
parent window.possibility to me.

But there's a little problem,though.

The only browser that it works is MS IE. It does not work on
Nestcape (Win or *NIX) or Konqueror (*NIX).

If I try it on a different browser, say Netscape or Konqueror, when I click
the main window to open the popup window it does work.
The thing that does not work is when you click close on the popup window. It
does not close the popup window and if I close the window it does not update
the parent window.

I've written two test PHP scripts teste_popup.php4 (the main window) and
pop.php4
that I am including below. Maybe someone can help me out by pointing where
it is
wrong.

teste_popup.php4 (parent window script)

<?php
// teste_popup.php4
print("<html>\n");
print("<head>\n");
//print("<script type=\"text/javascript\">\n");
print("<script language=\"JavaScript\"><!--\n");
print("function newWin(urlLoc) {\n");
print("    _winName=\"Janelateste\";\n");
print("    _info = \"toolbar=no\";\n");
print("    _info += \",location=no\";\n");
print("    _info += \",directories=no\";\n");
print("    _info += \",status=yes\";\n");
print("    _info += \",menubar=no\";\n");
print("    _info += \",scrollbars=yes\";\n");
print("    _info += \",resizable=yes\";\n");
print("    _info += \",titlebar=no\";\n");
print("    _info += \",dependent=no\";\n");
print("    _info += \",channelmode=no\";\n");
print("    _info += \",height=480\";\n");
print("    _info += \",width=640\";\n");
print("    _info += \",left=200\";\n");
print("    _info += \",top=100\";\n");
print("    DispWin=window.open(urlLoc,_winName,_info);\n");
print("} \n");
print("//--></script>\n");
print("</head>\n");
print("<body>\n");
print("<p>\n");
print("Esse e um teste usando Javascript para montar as janelas\n");
print("a parte de numero de operacoes, pecas, etc de garantia.\n");
print("</p>\n");
print("<b>\n");
print("Data : ".date(d."/".m."/".Y." ".H.":".i.":".s)."\n");
print("<b>\n");
print("<br>\n");
print("<br>\n");
print("<a href=\"JavaScript:newWin('pop.php4?oper=1');\">link</a>\n");
print("<br>\n");
print("</body>\n");
print("</html>\n");
?>

pop.php4 - child popup window

<?php
// pop.php4

print("<html>\n");
print("<head>\n");
//print("<script type=\"text/javascript\">\n");
print("<script language=\"JavaScript\"><!--\n");
print("self.menubar.visible=false\n");
print("self.tollbar.visible=false\n");
print("self.locationbar.visible=false\n");
print("self.personalbar.visible=false\n");
print("self.statusbar.visible=false\n");
print("function oldWin(urlLoc) {\n");
print("    returnwin=window.opener.navigate(urlLoc);\n");
print("    window.opener.focus();\n");
print("    window.close();\n");
print("} \n");
print("//--></script>\n");
print("</head>\n");
print("<body onunload=\"JavaScript:oldWin('teste_popup.php4?oper=1')\">\n");
print("<b>\n");
print("Child window\n");
print("</b>\n");
print("<br>\n");
print("Parametro oper = ".$HTTP_GET_VARS["oper"]."\n");
print("<br>\n");
print("<a href=\"JavaScript:oldWin('teste_popup.php4?oper=1')\">Close e
Update</a>\n");
print("<br>\n");
print("</body>\n");
print("</html>\n");

?>

Could anyone help me out to adapt it to any browser?

Thank you very much and merry christmas,

Carlos Fernando Scheidecker Antunes.
Salt Lake City, Utah - USA.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
I don't know if this is it, but you may:

1. Replace
print("    returnwin=window.opener.navigate(urlLoc);\n");
with
print("    window.opener.location='urlLoc';\n");

2. Try opening the pop-up widow with Netscape allowing the location input box to
appear, click on "Close e Update" and, if it doesn't work, type "javascript:" in
the location bow -- then check for errors reported by Netscape. 9 cases out of
10, if you solve the problem with Netscape, Konqueror will work as well.

Please let me know of your progress - I'm curious what the problem is.

Bogdan

Carlos Fernando Scheidecker Antunes wrote:

> Hello all!
>
> I've wrote to scripts that use Javascript too. The idea is to have a parent
> window teste_popup.php4 and a child window pop.php4. When a link is clicked
> on the parent window, the child window will open. After the user enters
> information on the child window he must close it and that will update the
> parent window.possibility to me.


--- End Message ---
--- Begin Message ---
Does anybody have any code to give an example of mirroring a directory, and
sub dirs?

The code needs to connect to a remote FTP server, and download the entire
contents to the local hard drive.

Many thanks,
Paul


--- End Message ---
--- Begin Message ---
Hello,

please anybody know how to desactivate any function as mail or function to
show the source of a php page ?

Thanks !


--- End Message ---
--- Begin Message ---
  php.ini has a disable_functions setting, maybe acessable by ini_set()
too...

--

Julio Nobrega.

Um dia eu chego lá:
http://sourceforge.net/projects/toca

Ajudei? Salvei? Que tal um presentinho?
http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884


"Yves Reveillon" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello,
>
> please anybody know how to desactivate any function as mail or function to
> show the source of a php page ?
>
> Thanks !
>
>


--- End Message ---
--- Begin Message ---
Hi i've taken a look throught he manual and i can't find a function to do
this

Basically i want to take in a string and check that the string doesn't
contain a certain word or something

ie check that it doesn't contain <SCRIPT LANGUAGE = Javascript> to prevent
hackers/crackers on my guestbook


Thanks

Ash



--- End Message ---
--- Begin Message ---
if (strpos("<SCRIPT LANGUAGE = Javascript>",$input_string)===false) {
  echo("Yeah, right!");
  exit;
}

You'll have a lot of problems, though, because
1. You also need to check for <script type="text/javascript">;
2. You have to strtolower() both strings in order to eliminate capitalization
differences;
3. and the tougher: how do you check for this one:
"<script language                              ='javascript' \t>", where "\t"
is a tab character? And obviously all the possible combinations...

Bogdan

Ash wrote:

> Hi i've taken a look throught he manual and i can't find a function to do
> this
>
> Basically i want to take in a string and check that the string doesn't
> contain a certain word or something
>
> ie check that it doesn't contain <SCRIPT LANGUAGE = Javascript> to prevent
> hackers/crackers on my guestbook
>
> Thanks
>
> Ash
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
This should be a better alternative:

http://www.php.net/manual/en/function.strip-tags.php



-----Original Message-----
From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 28, 2001 11:14 AM
To: Ash
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Searching a string or similar

if (strpos("<SCRIPT LANGUAGE = Javascript>",$input_string)===false) {
  echo("Yeah, right!");
  exit;
}

You'll have a lot of problems, though, because
1. You also need to check for <script type="text/javascript">;
2. You have to strtolower() both strings in order to eliminate
capitalization
differences;
3. and the tougher: how do you check for this one:
"<script language                              ='javascript' \t>", where
"\t"
is a tab character? And obviously all the possible combinations...

Bogdan

Ash wrote:

> Hi i've taken a look throught he manual and i can't find a function to
do
> this
>
> Basically i want to take in a string and check that the string doesn't
> contain a certain word or something
>
> ie check that it doesn't contain <SCRIPT LANGUAGE = Javascript> to
prevent
> hackers/crackers on my guestbook
>
> Thanks
>
> Ash
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



--- End Message ---
--- Begin Message ---
Hello Bogdan,

I greatly appreciated your help. Now it is way better but some behaviours are 
still weird as I describe below:

On Microsoft Internet Explorer:

- If you close the popup window by clicking the close icon, the onunload 
event works just fine.

- If you close the popup window by closing on the link it reloads the parent 
window twice, which is not good because the parent window that I need it to 
be done reads info from a database and this can be time consuming. What 
happens here is that it calls the oldWin function and then the onunload event.

On Netscape and Konqueror:

- if you close the popup window by clicking the close icon, the onunload 
event is not called or recoginized. I wonder if I need to register the events 
with captureEents. If so, how can I do it?

- If you close the popup window by closing on the link it reloads the parent 
window once since it does not recognize the onunload event.

There should be a way by creating a variable or whatever that would not call
the oldWin function twice if the onunload event is fired.

Do you know how to do it?

Could you help me with that?

Thanks again.

regards,

Carlos Fernando.




On Friday 28 December 2001 12:08 pm, Bogdan Stancescu wrote:
> I don't know if this is it, but you may:
>
> 1. Replace
> print("    returnwin=window.opener.navigate(urlLoc);\n");
> with
> print("    window.opener.location='urlLoc';\n");
>
> 2. Try opening the pop-up widow with Netscape allowing the location input
> box to appear, click on "Close e Update" and, if it doesn't work, type
> "javascript:" in the location bow -- then check for errors reported by
> Netscape. 9 cases out of 10, if you solve the problem with Netscape,
> Konqueror will work as well.
>
> Please let me know of your progress - I'm curious what the problem is.
>
> Bogdan
>
> Carlos Fernando Scheidecker Antunes wrote:
> > Hello all!
> >
> > I've wrote to scripts that use Javascript too. The idea is to have a
> > parent window teste_popup.php4 and a child window pop.php4. When a link
> > is clicked on the parent window, the child window will open. After the
> > user enters information on the child window he must close it and that
> > will update the parent window.possibility to me.


Hello all!

I've wrote to scripts that use Javascript too. The idea is to have a parent
window teste_popup.php4 and a child window pop.php4. When a link is clicked
on the parent window, the child window will open. After the user enters
information on the child window he must close it and that will update the
parent window.possibility to me.

But there's a little problem,though.

The only browser that it works is MS IE. It does not work on
Nestcape (Win or *NIX) or Konqueror (*NIX).

If I try it on a different browser, say Netscape or Konqueror, when I click
the main window to open the popup window it does work.
The thing that does not work is when you click close on the popup window. It
does not close the popup window and if I close the window it does not update
the parent window.

I've written two test PHP scripts teste_popup.php4 (the main window) and
pop.php4
that I am including below. Maybe someone can help me out by pointing where
it is
wrong.

teste_popup.php4 (parent window script)

<?php
// teste_popup.php4
print("<html>\n");
print("<head>\n");
//print("<script type=\"text/javascript\">\n");
print("<script language=\"JavaScript\"><!--\n");
print("function newWin(urlLoc) {\n");
print("    _winName=\"Janelateste\";\n");
print("    _info = \"toolbar=no\";\n");
print("    _info += \",location=no\";\n");
print("    _info += \",directories=no\";\n");
print("    _info += \",status=yes\";\n");
print("    _info += \",menubar=no\";\n");
print("    _info += \",scrollbars=yes\";\n");
print("    _info += \",resizable=yes\";\n");
print("    _info += \",titlebar=no\";\n");
print("    _info += \",dependent=no\";\n");
print("    _info += \",channelmode=no\";\n");
print("    _info += \",height=480\";\n");
print("    _info += \",width=640\";\n");
print("    _info += \",left=200\";\n");
print("    _info += \",top=100\";\n");
print("    DispWin=window.open(urlLoc,_winName,_info);\n");
print("} \n");
print("//--></script>\n");
print("</head>\n");
print("<body>\n");
print("<p>\n");
print("Esse e um teste usando Javascript para montar as janelas\n");
print("a parte de numero de operacoes, pecas, etc de garantia.\n");
print("</p>\n");
print("<b>\n");
print("Data : ".date(d."/".m."/".Y." ".H.":".i.":".s)."\n");
print("<b>\n");
print("<br>\n");
print("<br>\n");
print("<a href=\"JavaScript:newWin('pop.php4?oper=1');\">link</a>\n");
print("<br>\n");
print("</body>\n");
print("</html>\n");
?>

pop.php4 - child popup window

<?php
// pop.php4

print("<html>\n");
print("<head>\n");
//print("<script type=\"text/javascript\">\n");
print("<script language=\"JavaScript\"><!--\n");
print("self.menubar.visible=false\n");
print("self.tollbar.visible=false\n");
print("self.locationbar.visible=false\n");
print("self.personalbar.visible=false\n");
print("self.statusbar.visible=false\n");
print("function oldWin(urlLoc) {\n");
print("    returnwin=window.opener.navigate(urlLoc);\n");
print("    window.opener.focus();\n");
print("    window.close();\n");
print("} \n");
print("//--></script>\n");
print("</head>\n");
print("<body onunload=\"JavaScript:oldWin('teste_popup.php4?oper=1')\">\n");
print("<b>\n");
print("Child window\n");
print("</b>\n");
print("<br>\n");
print("Parametro oper = ".$HTTP_GET_VARS["oper"]."\n");
print("<br>\n");
print("<a href=\"JavaScript:oldWin('teste_popup.php4?oper=1')\">Close e
Update</a>\n");
print("<br>\n");
print("</body>\n");
print("</html>\n");

?>

Could anyone help me out to adapt it to any browser?

Thank you very much and merry christmas,

Carlos Fernando Scheidecker Antunes.
Salt Lake City, Utah - USA.
--- End Message ---
--- Begin Message ---
The way it looks to me, you do both the window opening sequence and the closing
procedure twice:
- Window opening: you specify window options (toolbar, status bar etc) once in the
window.open() call and once in the actual window code;
- Window closing: you perform the same actions once upon clicking on "Close e
Update" and once upon actual window closing (via onUnload()).

Try implementing both procedures only once in a way that they're ran by both types
of browsers.

AFAIK you don't need to implement any kind of captureEvents, but I may be wrong
about it.

Only now did I read your final paragraph: I think you'd better leave the
onUnload() in place and only window.close() in the link, which should trigger
onUnload(). Hope this works with NS 4.x!

I don't have any clue why closing the pop-up via Windows controls both doesn't
trigger onUnload and reloads the parent window -- are you sure you're not wrong
about this? I mean, if it reloads the parent window, doesn't this mean that
onUnload() works?

My suggestion is fiddling with the onUndload() function triggering it via a link
(as suggested in the previous message -- with a href="javascript:oldWin()") until
you get no error messages when accessing "javascript:" in Netscape. You didn't
tell me -- do you get any more error messages now upon accessing "javascript:"?

Bogdan

Carlos Fernando Scheidecker Antunes wrote:

> Hello Bogdan,
>
> On Microsoft Internet Explorer:
> On Netscape and Konqueror:

--- End Message ---
--- Begin Message ---
Hello,

On this list yesterday: "As long as these tools are out
there, it should keep all of us on our toes, and programming with security
constantly on our minds."

Today i have tested,  Smart HitBot (http://www.hitbot.f2s.com/). Bad stuff 
for stats, toplist, searchengines etc.

Now i want filler out this requests. Do you have some ideas?

I will start with a simple script, say:
<?php

include("counter.php");
if(!real_one()) $counter-=2;
$counter++;

$fp=fopen("counter.php","w+");
fwrite($fp, <?\n \$counter=$counter; \n?>");
fclose($fp);

?> 

Maybe i can do something with the interval between 2 requests, with real 
users this should be 'random', someting like:
<?
function real_one()
{
include("real.php");

if ($interval==0)
        {
               $interval=time()-$last;
               $last=time();
        }
else if($interval==(time()-$last))
        {
        $interval=0;
        $last=time();
        }
else 
        {
        $interval=time()-$last;
        $last=time();
        }

$fp=fopen("real.php","w+");
fwrite($fp, <?\n \$interval=$interval;\n \$last=$last; \n?>");
fclose($fp);
return $interval;
}

?>


It's something, but not safe. one real user between two fake -> count 2 
fakers.

If have also looked at $HTTP_USER_AGENT:
--
request1: 
Mozilla/4.0 (compatible; MSIE 5.01; Windows 98)
request2: 
Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)
request3: 
Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
etc.
--

So this will always start with "Mozilla/4.0 ("
This will be the same as the header from IE6.0 installed on the same machine. 
It will be different  from faker to faker(???) depending on the installed 
browser(s).

Thanks for your help.

Bas
--- End Message ---
--- Begin Message ---
I had been using "blob" for a lot of mysql text fields, even email
address as well as other data. all of a sudden, it seems, instead of
seeing and editting these blob values in phpmyadmin (i currently have
2.2.2) tables all i see in the fields is "[BLOB]" and I am ubnable to
edit the fields.

Does anyone know what is going on?

--- End Message ---
--- Begin Message ---
In config.inc.php:
--
// In browse mode...
$cfgShowBlob              = FALSE;  // display blob field contents
--
Maybe put it on TRUE?

Op vrijdag 28 december 2001 16:52, schreef Paul S.:
> I had been using "blob" for a lot of mysql text fields, even email
> address as well as other data. all of a sudden, it seems, instead of
> seeing and editting these blob values in phpmyadmin (i currently have
> 2.2.2) tables all i see in the fields is "[BLOB]" and I am ubnable to
> edit the fields.
>
> Does anyone know what is going on?
--- End Message ---
--- Begin Message ---
That is the one. Thanks. Diff than the previous phpmyadmin it appears, too.
I'll read through all those parms.


Bas Jobsen wrote:

> In config.inc.php:
> --
> // In browse mode...
> $cfgShowBlob              = FALSE;  // display blob field contents
> --
> Maybe put it on TRUE?
>
> Op vrijdag 28 december 2001 16:52, schreef Paul S.:
> > I had been using "blob" for a lot of mysql text fields, even email
> > address as well as other data. all of a sudden, it seems, instead of
> > seeing and editting these blob values in phpmyadmin (i currently have
> > 2.2.2) tables all i see in the fields is "[BLOB]" and I am ubnable to
> > edit the fields.
> >
> > Does anyone know what is going on?

--- End Message ---
--- Begin Message ---
I am ruining PHP with IIS on Win2k.  I am using a PHP app which was working 
fine but when the app douse a file/upload/submit in the page posted to the 
temporary file seems not to exist.  This was working fine on my Win98 
setup.  Any idea what is wrong?

Ben

--- End Message ---
--- Begin Message ---
Does anyone know if there are plans to offer a PHP certification in the future?

I know this can be a mute point, I am just curious.

Thanks!
Clint
--- End Message ---
--- Begin Message ---
Brainbench?

Regards,
Andrey Hristov
----- Original Message ----- 
From: "clint " <[EMAIL PROTECTED]>
To: "PHP General" <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 11:13 PM
Subject: [PHP] PHP certification


> Does anyone know if there are plans to offer a PHP certification in the future?
> 
> I know this can be a mute point, I am just curious.
> 
> Thanks!
> Clint
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 

--- End Message ---
--- Begin Message ---
When reloading php software to new directories deleting the old dir is
often difficult because there is a dot file (often with a majic quotes
directrive) so directories aren't empty. I have to telnet to my main
account and use command line ftp to delete the (still invisible)
offending dot files. Then I can delete the dir with my standard ftp
client.

I know that I have seen unix systems where I can view/delete dot files
with an ftp client. Is that under my control (I have user unix access)
or system only control? It's linux/apache.

--- End Message ---
--- Begin Message ---
I am having a problem moving files uploaded using POST.

What is supposed to happen is it takes two files, a picture and its
associated thumbnail, both of which have been uploaded via HTTP POST,  and
moves them to two different folders, renaming them appropriately.

Here's the code...

-----------------------------------------------------------
BEGIN CODE FRAGMENT
-----------------------------------------------------------

function upload($pid) {
 GLOBAL $siteroot, $HTTP_POST_FILES, $fileroot;

 // more manageable variable names to work with
 $picfile = $HTTP_POST_FILES['picfile']['tmp_name'];
 $thumbfile = $HTTP_POST_FILES['thumbfile']['tmp_name'];
 $pic = $HTTP_POST_FILES['picfile']['name'];
 $thumb = $HTTP_POST_FILES['thumbfile']['name'];

 // check if *pictures* were uploaded, as opposed to some other file type
 if(!$picsize = getimagesize($picfile) || !$thumbsize =
getimagesize($thumbfile) ) {
  $error[] = "Either the picture was not uploaded properly, or ".
     "it was not a valid picture. Please hit 'back' and try ".
     "again.";
 }

 // get the file extension of the pictures
 $picext = strstr($pic, ".");
 $thumbext = strstr($thumb, ".");

 // create the filenames pictures will be stored under
 $picname = "pic" . $pid . $picext;
 $thumbname = "thumb" . $pid . $thumbext;

 // destination path for pictures and thumbnails
 $picdest = "$fileroot/pictures/$picname";
 $thumbdest = "$fileroot/thumbs/$thumbname";

 // debug info
 $message = "<b>Picture Source:</b> $picfile<br>\n".
    "<b>Picture Dest:</b> $picdest<br><br>\n\n".
    "<b>Thumbnail Source:</b> $thumbfile<br>\n".
    "<b>Thumbnail Dest:</b> $thumbdest<br><br>\n\n";

 message($message);

 // security check then copy files to destination folder...
 if (!is_uploaded_file($picfile) || !is_uploaded_file($thumbfile) ) {
  $error[] = "Possible File Upload attack. File Upload aborted.";
 } elseif (!$movepic = copy($picfile, $picdest) || !$movethumb =
copy($thumbfile, $thumbdest) ) {
  // ... or quit with error
  $error[] = "File could not be copied. Please retry.<br>\n".
     "<b>Picture Source:</b> $picfile<br>\n".
     "<b>Picture Dest:</b> $picdest<br><br>\n\n".
     "<b>Thumbnail Source:</b> $thumbfile<br>\n".
     "<b>Thumbnail Dest:</b> $thumbdest<br><br>\n\n".
     "Picture: $movepic<br> Thumbnail: $movethumb";

 }

 // check for errors or write successful entry to dbase
 if(isset($error) ) {
  error($error);
 } else {
  $db = open_db();

  $query = "UPDATE yb_pictures SET ".
       "thumburl='" . $thumbname . "', ".
       "picurl='" . $picname . "', ".
       "status='3' ".
       "WHERE id='" . $pid . "'";
  $result = query($query, $db);

  // output for user
  $message = "Picture uploaded successfully. Please ".
     "<a href=\"$siteroot/manager.php\">go back to the Site ".
     "Manager.";
  message($message);
 }
}

-----------------------------------------------------------
END CODE FRAGMENT
-----------------------------------------------------------

My problem is that the script completes successfully and reports "Picture
uploaded successfully". But when I go to see if the files are there, the
thumbnail file is missing. Only the picture file appears where it should.

I have checked, re-checked and checked again for typos or other errors in
the file or directory names, and I am sure there are none.

I have no idea what could be the problem.

Go to http://www.unndunn.com/guestbook.php?action=showVersionInfo for info
about the version of PHP the server is running.

Thanks in advance!

--
Uchendu Nwachukwu
newsreply AT unndunn DOT com - www.unndunn.com




--- End Message ---
--- Begin Message ---
How are the usage stats for these two libraries shaping up?

Both have advantages, I'm just wondering which one to start my own designs
around.
--- End Message ---
--- Begin Message ---
Hello,

Dennis Gearon wrote:
> 
> How are the usage stats for these two libraries shaping up?
> 
> Both have advantages, I'm just wondering which one to start my own designs
> around.

That depends on what you want to do. You also should consider other well
thought solutions. If you are looking for a well structured framework
look at BinaryCloud ( http://binarycloud.tigris.org/ ). If you are
looking for a good database abstraction package, look at Metabase (
http://phpclasses.UpperDesign.com/browse.html/package/20 ).

Unlike PEAR-DB and PHPlib, Metabase provides true database independence
to your applications. This means that with Metabase, you do not have to
handle database differences with database specific code in your
applications. For instance, each database may format date fields in
different ways. Metabase assures that all date values that go back and
forth the database are formatted according to the ISO 9601 format
(YYYY-MM-DD), regardless if the underlying database uses that format to
represent dates or some other.

There are other nice features like the ability to install your database
schemas just by defining your tables, fields, indexes and sequences in a
custom XML format that is database independent. Just take a look in the
page above to learn more about it.

Regards,
Manuel Lemos
--- End Message ---
--- Begin Message ---


> From: Manuel Lemos [mailto:[EMAIL PROTECTED]]
> Unlike PEAR-DB and PHPlib, Metabase provides true database independence
> to your applications.

Actually - no. Querys/conformance to specs/sequences/stored procs and more
are different from DB to DB. While the abstration layers help a little, they
really don't help a lot.

Mark C.


--- End Message ---
--- Begin Message ---
I have recently been requested to choose new technology to be used within my
organization.  My options seem to include PHP and JSP, and I am leaning
toward PHP.  The one thing I really need to know is how many concurrent
users PHP can handle at one time.  This project is for an extremely large
corp and I need to know that PHP can scale at the level that I need it to.
Thanks in advance.
Jay Fields

--- End Message ---
--- Begin Message ---
"Jamie Fields" <[EMAIL PROTECTED]> wrote in message
> I have recently been requested to choose new technology to be used within
my
> organization.  My options seem to include PHP and JSP, and I am leaning
> toward PHP.  The one thing I really need to know is how many concurrent
> users PHP can handle at one time.  This project is for an extremely large
> corp and I need to know that PHP can scale at the level that I need it to.
> Thanks in advance.
> Jay Fields

JSP is going to be faster as these objects are all ready created & loaded
(apparantly according to the Sun Micro Systems guy) php however is more
likely to be on a external webserver. Probabily not that much help but
thought i'd put in my 2 pence


--- End Message ---
--- Begin Message ---
Hey!

Looking for a way to add an entry in my array ...the way I have it the array
is getting rebuilt everytime...
Anyway to add an entry without calling a function to do it inside the main
while loop??

while ($row = mysql_fetch_object($result_query))
                {
                $look = "$row->year" . "$row->month" . "$row->day";
                $title = $row->title;


                $Schedule = array(
                        $look => "$title",
                        );

                }


thanks,

ccma

--- End Message ---
--- Begin Message ---
never mind...gheez my head is holidazed :)


$Schedule = array();
        while ($row = mysql_fetch_object($result_query))
                {
                $look = "$row->year" . "$row->month" . "$row->day";
                $title = $row->title;


                $Schedule[$look] =$title;
                }


Happy New Year!!

-ccma

----- Original Message -----
From: "Chris Allen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 4:27 PM
Subject: [PHP] Dynamic Array Q


> Hey!
>
> Looking for a way to add an entry in my array ...the way I have it the
array
> is getting rebuilt everytime...
> Anyway to add an entry without calling a function to do it inside the main
> while loop??
>
> while ($row = mysql_fetch_object($result_query))
>                 {
>                 $look = "$row->year" . "$row->month" . "$row->day";
>                 $title = $row->title;
>
>
>                 $Schedule = array(
>                         $look => "$title",
>                         );
>
>                 }
>
>
> thanks,
>
> ccma
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>

--- End Message ---
--- Begin Message ---
Hello everybody!

Apart from the usual best wishes for 2002, I have a question: does
anyone know of a good security list/newsletter/bulletin for PHP?
Actually, any kind of good source would be great, even if it's net
security in general -- what I'm looking for is:
1. Mostly PHP security (including PHP packages with vulnerabilities)
and
2. A good source (I'd like to subscribe to an active
list/newsletter/bulletin so they publish info from other sources as well
-- not only original data they found out without any external info).

Too much to ask? :-)

Bogdan


--- End Message ---
--- Begin Message ---
Hello Bogdan,

Before anything, thank you!

I've installed Netscape 6.2 on a Linux box and it works just like MS IE.

Just like I told you. The unload event does not work or is called by either
netscape 4.x or konqueror.

But it is called by Netscape 6.2 and MS IE 5.x & 6.x.

I think that JS implementations on those browsers might be quite different.
I wonder how to make the onunload event work on Netscape 4.x and Konqueror.
That's why I thought creating a captureEvents.

Also a good thing would be creating a popup window without the close (X) and
minimize ( _ ) icons since I can only create it without the resize and
maximize buttons. Do you know how to create a java popup window without the
close icon? If it is possible the problem is solved since the only way a
user could close it is by clicking on the link.

Thank you,

Carlos Fernando Scheidecker Antunes.



----- Original Message -----
From: "Bogdan Stancescu" <[EMAIL PROTECTED]>
To: "Carlos Fernando Scheidecker Antunes" <[EMAIL PROTECTED]>
Cc: "PHP-GENERAL" <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 5:31 PM
Subject: Re: [PHP] Part II: Help on JavaScript Windows with PHP


The way it looks to me, you do both the window opening sequence and the
closing
procedure twice:
- Window opening: you specify window options (toolbar, status bar etc) once
in the
window.open() call and once in the actual window code;
- Window closing: you perform the same actions once upon clicking on "Close
e
Update" and once upon actual window closing (via onUnload()).

Try implementing both procedures only once in a way that they're ran by both
types
of browsers.

AFAIK you don't need to implement any kind of captureEvents, but I may be
wrong
about it.

Only now did I read your final paragraph: I think you'd better leave the
onUnload() in place and only window.close() in the link, which should
trigger
onUnload(). Hope this works with NS 4.x!

I don't have any clue why closing the pop-up via Windows controls both
doesn't
trigger onUnload and reloads the parent window -- are you sure you're not
wrong
about this? I mean, if it reloads the parent window, doesn't this mean that
onUnload() works?

My suggestion is fiddling with the onUndload() function triggering it via a
link
(as suggested in the previous message -- with a href="javascript:oldWin()")
until
you get no error messages when accessing "javascript:" in Netscape. You
didn't
tell me -- do you get any more error messages now upon accessing
"javascript:"?

Bogdan

Carlos Fernando Scheidecker Antunes wrote:

> Hello Bogdan,
>
> On Microsoft Internet Explorer:
> On Netscape and Konqueror:

--- End Message ---
--- Begin Message ---
Hello, Carlos!

1. onUnload IS called by Netscape. Didn't test it with Konqueror, but I guess
it's called as well;
2. My guess is that you have a problem with the function itself, that's why I
strongly suggest you define it as a standalone function and use "javascript:"
for debugging;
3. No, there's no way to create a function without close buttons -- which is
quite normal regarding W3C... Would you like amazon.com to be able to open a
browser window you can't close? :-)

Bogdan

Carlos Fernando Scheidecker Antunes wrote:

> Hello Bogdan,
>
> Just like I told you. The unload event does not work or is called by either
> netscape 4.x or konqueror.

--- End Message ---
--- Begin Message ---
Hi, I am running PHP 4.10 off my Win2000 box, and I am trying to upload a
file to it (Apache is running off the same box I'm uploading from).

I have the following form:

=============
<FORM method="POST" action="catalog_admin.php?action=additemsave"
enctype="multipart/form-data">
<INPUT type="hidden" name="MAX_FILE_SIZE" value="10000">
<INPUT type="file" name="userfile">
<input type="submit" name="additem_submit" value="Add Product"> <input
type="reset" name="reset" value="Reset Form">
</FORM>
============

and the php script that handles it:

============
<?php
$sql = "INSERT INTO products (category_id, item_name, item_company,
item_price, item_listprice, item_discount, dimensions_height,
dimensions_width, dimensions_length, dimensions_weight_lbs, number_in_stock,
product_description)
values('$category_id','$item_name','$item_company','$item_price','$item_list
price','$item_discount','$dimensions_height',
'$dimensions_width','$dimensions_length','$dimensions_weight_lbs','$number_i
n_stock','$product_description')";
$result = mysql_query($sql, $dbconn) or die(mysql_error());
$item_id = mysql_insert_id();
$array = explode("/", $userfile_type);
if ($array[1] == "pjpeg" || $array[1] == "jpeg") {
$array[1] = "jpg";
}
$ext = $array[1];
$new_file = "$imagedir" . "\\" . "$item_id.$ext";
if (!move_uploaded_file($userfile, $new_file)) {
$sql = "DELETE FROM products WHERE (item_id = '$item_id')";
$result = mysql_query($sql);
metadie("Unable to move the uploaded image file to the new directory
($imagedir) ($new_file) ($userfile). Image type was ".$array[1]);
}
$sql = "UPDATE products SET image_src='$new_file' WHERE (item_id =
'$item_id')";
$result = mysql_query($sql);
?>
==========================
My problem is, whenever I upload an image, $userfile is always "none". I
know I'm uploading it on the form end, but it doesn't seem to register it on
the PHP script's end. Any help here?

Thanks,
David Balatero ([EMAIL PROTECTED])

--- End Message ---

Reply via email to