php-general Digest 15 May 2006 02:02:00 -0000 Issue 4128

Topics (messages 236148 through 236163):

Re: Is it a bug ?
        236148 by: Fourat Zouari
        236149 by: cajbecu
        236150 by: Fourat Zouari

triming a query
        236151 by: Ross
        236152 by: Rasmus Lerdorf

$ENV['SCRIPT_FILENAME']
        236153 by: Ryan A
        236156 by: tedd
        236157 by: Rory Browne
        236158 by: Rory Browne
        236159 by: Ryan A

Exceptions in PHP
        236154 by: John Meyer
        236155 by: Jochem Maas

Re: Issues with upgrade to PHP 4.4.1
        236160 by: Chris Bruce

Going nuts with this, cant figure out whats the prob
        236161 by: Ryan A
        236163 by: Chris

[announce] new version of DHCP web interface
        236162 by: Daevid Vincent

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 5/14/06, Fourat Zouari <[EMAIL PROTECTED]> wrote:

ok
this is returning the retrived data from open sockets :
http://pastebin.com/716768

this is returning an empty string :
http://pastebin.com/716767


it's not a bug :)
i shoul wait for stream to be returned, i use :
--------------------
       while(($buff = stream_get_contents($socket[$i]))=="");
       echo $buff;
--------------------
it takes sometime to receive stream from socket, is it the best way (dont
think so) to wait for stream ?


On 5/14/06, chris smith <[EMAIL PROTECTED]> wrote:
>
> On 5/14/06, Fourat Zouari <[EMAIL PROTECTED]> wrote:
> > Code 1 :
> > -------------------------
> > var_dump(stream_get_contents($rr));
> > -------------------------
> > Output 1
> > -------------------------
> > string(185) "HTTP/1.1 202 Accepted
> > Server: Apache2
> > Content-Length: 24
> > Connection: close
> > Content-type: text/html
> > Pragma: no-cache
> > Cache-Control: no-cache
> >
> > 0: Accepted for delivery"
> > -------------------------
> >
> >
> > Code 2 :
> > -------------------------
> > $x = stream_get_contents($rr);
> > var_dump($x);
> > -------------------------
> > Output 2
> > -------------------------
> > string(0) ""
> > -------------------------
> >
> > Am i wrong ?
>
> Without seeing all of the code, we can't tell anything from that.
>
> Post it in http://pastebin.com and send us a url.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>



--- End Message ---
--- Begin Message ---
$var = file ("http://www.some.server.net:someport";);
then $var=explode ... bla bla..

that never crash.

cheers,
cajbecu


On 5/14/06, Fourat Zouari <[EMAIL PROTECTED]> wrote:
On 5/14/06, Fourat Zouari <[EMAIL PROTECTED]> wrote:
>
> ok
> this is returning the retrived data from open sockets :
> http://pastebin.com/716768
>
> this is returning an empty string :
> http://pastebin.com/716767
>

it's not a bug :)
i shoul wait for stream to be returned, i use :
--------------------
        while(($buff = stream_get_contents($socket[$i]))=="");
        echo $buff;
--------------------
it takes sometime to receive stream from socket, is it the best way (dont
think so) to wait for stream ?


On 5/14/06, chris smith <[EMAIL PROTECTED]> wrote:
> >
> > On 5/14/06, Fourat Zouari <[EMAIL PROTECTED]> wrote:
> > > Code 1 :
> > > -------------------------
> > > var_dump(stream_get_contents($rr));
> > > -------------------------
> > > Output 1
> > > -------------------------
> > > string(185) "HTTP/1.1 202 Accepted
> > > Server: Apache2
> > > Content-Length: 24
> > > Connection: close
> > > Content-type: text/html
> > > Pragma: no-cache
> > > Cache-Control: no-cache
> > >
> > > 0: Accepted for delivery"
> > > -------------------------
> > >
> > >
> > > Code 2 :
> > > -------------------------
> > > $x = stream_get_contents($rr);
> > > var_dump($x);
> > > -------------------------
> > > Output 2
> > > -------------------------
> > > string(0) ""
> > > -------------------------
> > >
> > > Am i wrong ?
> >
> > Without seeing all of the code, we can't tell anything from that.
> >
> > Post it in http://pastebin.com and send us a url.
> >
> > --
> > Postgresql & php tutorials
> > http://www.designmagick.com/
> >
>
>



--- End Message ---
--- Begin Message ---
cajbecu, am talking about non-blocking sockets, that's a simple blocking
socket

On 5/14/06, cajbecu <[EMAIL PROTECTED]> wrote:

$var = file ("http://www.some.server.net:someport";);
then $var=explode ... bla bla..

that never crash.

cheers,
cajbecu


On 5/14/06, Fourat Zouari <[EMAIL PROTECTED]> wrote:
> On 5/14/06, Fourat Zouari <[EMAIL PROTECTED]> wrote:
> >
> > ok
> > this is returning the retrived data from open sockets :
> > http://pastebin.com/716768
> >
> > this is returning an empty string :
> > http://pastebin.com/716767
> >
>
> it's not a bug :)
> i shoul wait for stream to be returned, i use :
> --------------------
>         while(($buff = stream_get_contents($socket[$i]))=="");
>         echo $buff;
> --------------------
> it takes sometime to receive stream from socket, is it the best way
(dont
> think so) to wait for stream ?
>
>
> On 5/14/06, chris smith <[EMAIL PROTECTED]> wrote:
> > >
> > > On 5/14/06, Fourat Zouari <[EMAIL PROTECTED]> wrote:
> > > > Code 1 :
> > > > -------------------------
> > > > var_dump(stream_get_contents($rr));
> > > > -------------------------
> > > > Output 1
> > > > -------------------------
> > > > string(185) "HTTP/1.1 202 Accepted
> > > > Server: Apache2
> > > > Content-Length: 24
> > > > Connection: close
> > > > Content-type: text/html
> > > > Pragma: no-cache
> > > > Cache-Control: no-cache
> > > >
> > > > 0: Accepted for delivery"
> > > > -------------------------
> > > >
> > > >
> > > > Code 2 :
> > > > -------------------------
> > > > $x = stream_get_contents($rr);
> > > > var_dump($x);
> > > > -------------------------
> > > > Output 2
> > > > -------------------------
> > > > string(0) ""
> > > > -------------------------
> > > >
> > > > Am i wrong ?
> > >
> > > Without seeing all of the code, we can't tell anything from that.
> > >
> > > Post it in http://pastebin.com and send us a url.
> > >
> > > --
> > > Postgresql & php tutorials
> > > http://www.designmagick.com/
> > >
> >
> >
>
>


--- End Message ---
--- Begin Message ---
Not so good with the string functions but I want to remove the last 15 
characters from a query. Thought this would work.

echo "the query is".rtrim($query, 15);

Ross 

--- End Message ---
--- Begin Message ---
Ross wrote:
Not so good with the string functions but I want to remove the last 15 characters from a query. Thought this would work.

echo "the query is".rtrim($query, 15);

echo "the query is".substr($query,0,-15);

-Rasmus

--- End Message ---
--- Begin Message ---
Hi,
I am going through another persons script (which is
not working) and have come accross this:

if (isset($ENV['SCRIPT_FILENAME']))
{
      $CLIENT_PATH= dirname($ENV['SCRIPT_FILENAME']);
      WelcomeScreen();
      TestSetup($TH_HASH);
      exit;
}

I am just starting on CLI stuff but I cant find much
references to $ENV['SCRIPT_FILENAME'], reading the
manual I know there is a $_ENV superglobal but just
$ENV?

I am pipeing some log data from apache to this script
but while debuggin I have noticed that i does not go
further than the above if() statement... 

and that part IS needed because if accesseed via a
POST it should execute that code and show the
WelcomeScreen()

Even a RTFM with a reference in the manual would be
appreciated.

Thanks!
Ryan

------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-----
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
At 11:59 AM -0700 5/14/06, Ryan A wrote:
Hi,
I am going through another persons script (which is
not working) and have come accross this:

if (isset($ENV['SCRIPT_FILENAME']))
{
      $CLIENT_PATH= dirname($ENV['SCRIPT_FILENAME']);
      WelcomeScreen();
      TestSetup($TH_HASH);
      exit;
}

I am just starting on CLI stuff but I cant find much
references to $ENV['SCRIPT_FILENAME'], reading the
manual I know there is a $_ENV superglobal but just
$ENV?

I am pipeing some log data from apache to this script
but while debuggin I have noticed that i does not go
further than the above if() statement...

and that part IS needed because if accesseed via a
POST it should execute that code and show the
WelcomeScreen()

Even a RTFM with a reference in the manual would be
appreciated.

Thanks!
Ryan


Ryan:

Try this to see if SCRIPT_FILENAME exist:

echo("<pre>");
print_r($_ENV);
echo("</pre>");

If I remember correctly (maybe not), but not all environmental variables are always present.

However, SCRIPT_FILENAME should provide you the path of the script that contains the call. If it's not there, then look to see if PATH_TRANSLATED is present, because that will provide the same result.

hth's

tedd

--
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Sorry - what's your question?

I think that $ENV should be $_ENV, which in turn should be $_SERVER.

On 5/14/06, Ryan A <[EMAIL PROTECTED]> wrote:

Hi,
I am going through another persons script (which is
not working) and have come accross this:

if (isset($ENV['SCRIPT_FILENAME']))
{
      $CLIENT_PATH= dirname($ENV['SCRIPT_FILENAME']);
      WelcomeScreen();
      TestSetup($TH_HASH);
      exit;
}

I am just starting on CLI stuff but I cant find much
references to $ENV['SCRIPT_FILENAME'], reading the
manual I know there is a $_ENV superglobal but just
$ENV?

I am pipeing some log data from apache to this script
but while debuggin I have noticed that i does not go
further than the above if() statement...

and that part IS needed because if accesseed via a
POST it should execute that code and show the
WelcomeScreen()

Even a RTFM with a reference in the manual would be
appreciated.

Thanks!
Ryan

------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-----
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

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



--- End Message ---
--- Begin Message ---
Unless there is an other piece of code filling up the $ENV array - possibly
a cleaning routine.

On 5/14/06, Rory Browne <[EMAIL PROTECTED]> wrote:

Sorry - what's your question?

I think that $ENV should be $_ENV, which in turn should be $_SERVER.


On 5/14/06, Ryan A < [EMAIL PROTECTED]> wrote:
>
> Hi,
> I am going through another persons script (which is
> not working) and have come accross this:
>
> if (isset($ENV['SCRIPT_FILENAME']))
> {
>       $CLIENT_PATH= dirname($ENV['SCRIPT_FILENAME']);
>       WelcomeScreen();
>       TestSetup($TH_HASH);
>       exit;
> }
>
> I am just starting on CLI stuff but I cant find much
> references to $ENV['SCRIPT_FILENAME'], reading the
> manual I know there is a $_ENV superglobal but just
> $ENV?
>
> I am pipeing some log data from apache to this script
> but while debuggin I have noticed that i does not go
> further than the above if() statement...
>
> and that part IS needed because if accesseed via a
> POST it should execute that code and show the
> WelcomeScreen()
>
> Even a RTFM with a reference in the manual would be
> appreciated.
>
> Thanks!
> Ryan
>
> ------
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
> -----
> Fight back spam! Download the Blue Frog.
> http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--- End Message ---
--- Begin Message ---
Hey guys,
Thanks for replying.

I have figured out what he is trying to do....
basically he wants to know if the script is being
called via the web or via CLI... if called via the web
he wants to display the welcomeScreen() if not he
wants to do other stuff...

Problem is, that ENV thing is wrong so I changed it to
$_SERVER, but it is still looping in that place...

Anyone have an idea of a variable (eg:
$_SERVER['REQUEST_METHOD'] ) that will be set only if
called via the web and ignored if called via cli?

BTW, i tried $_SERVER['REQUEST_METHOD'] but not
working :-(

Thanks!
Ryan


--- tedd <[EMAIL PROTECTED]> wrote:

> At 11:59 AM -0700 5/14/06, Ryan A wrote:
> >Hi,
> >I am going through another persons script (which is
> >not working) and have come accross this:
> >
> >if (isset($ENV['SCRIPT_FILENAME']))
> >{
> >       $CLIENT_PATH=
> dirname($ENV['SCRIPT_FILENAME']);
> >       WelcomeScreen();
> >       TestSetup($TH_HASH);
> >       exit;
> >}
> >
> >I am just starting on CLI stuff but I cant find
> much
> >references to $ENV['SCRIPT_FILENAME'], reading the
> >manual I know there is a $_ENV superglobal but just
> >$ENV?
> >
> >I am pipeing some log data from apache to this
> script
> >but while debuggin I have noticed that i does not
> go
> >further than the above if() statement...
> >
> >and that part IS needed because if accesseed via a
> >POST it should execute that code and show the
> >WelcomeScreen()
> >
> >Even a RTFM with a reference in the manual would be
> >appreciated.
> >
> >Thanks!
> >Ryan
> >
> 
> Ryan:
> 
> Try this to see if SCRIPT_FILENAME exist:
> 
> echo("<pre>");
> print_r($_ENV);
> echo("</pre>");
> 
> If I remember correctly (maybe not), but not all
> environmental 
> variables are always present.
> 
> However, SCRIPT_FILENAME should provide you the path
> of the script 
> that contains the call. If it's not there, then look
> to see if 
> PATH_TRANSLATED is present, because that will
> provide the same result.
> 
> hth's
> 
> tedd
> 
> -- 
>
------------------------------------------------------------------------------------
> http://sperling.com  http://ancientstones.com 
> http://earthstones.com
> 


------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-----
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
I have the following script:

try {
$conn = mysql_connect("localhost","webuser","testme") or die("Could not connect"); mysql_select_db("bookcollection",$conn) or die("Could not select database");
        //first, check to see if there is an author
        if ($_POST["neworoldauthor"] == "new") {
$sql = "SELECT * FROM AUTHORS WHERE FirstName=\"" . $_POST["authorfname"] . "\" AND LastName=\"" . $_POST["authorlname"] . "\"";
        $retval = mysql_query($sql);
        if (mysql_num_rows($retval) == 0) {
$sql = "INSERT INTO AUTHORS(FirstName, LastName) VALUES(\"" . $_POST["authorfname"] . "\",\"" . $_POST["authorlname"] . "\")";
                mysql_query($sql);
                $authorID = mysql_insert_id();
        } else {
                $row = mysql_fetch_array($retval,MYSQL_ASSOC);
                $authorID = $row["AuthorID"];
        }
        } else {  // it's an old author
                $authorID = $_POST["authors"];
        }
        //now, check titles
$sql = "SELECT * FROM TITLES WHERE TITLE_TITLE=\"" . $_POST["title"] . "\"";
        $retval = mysql_query($sql) or die(mysql_error());
        if (mysql_num_rows($retval) == 0) {
$sql = "INSERT INTO TITLES(TITLE_TITLE) VALUES(\"" . $_POST["title"] . "\")";
                mysql_query($sql);
                $titleID = mysql_insert_id();
        } else {
                $row = mysql_fetch_array($retval,MYSQL_ASSOC);
                $titleID = $row["TITLE_ID"];
        }
        //now, insert the book
$sql = "INSERT INTO BOOKS(CopyrightYear,CoverType,DatePurchased,EditionNumber,ISBNNumber,Notes,Pages,Publisher,LOCNumber) VALUES(\"" . $_POST["copyrightyear"] . "\",\"" . $_POST["covertype"] . "\",\"" . $_POST["datepurchased"] . "\"," . $_POST["editionnumber"] . ",\"" . $_POST["isbn"] . "\",\"" . addslashes($_POST["notes"]) . "\"," . (isset($_POST["numberofpages"])?$_POST["numberofpages"]:0) . ",\"" . $_POST["publisher"] . "\",\"" . $_POST["locnumber"] . "\")";
        mysql_query($sql);
        $bookID = mysql_insert_id();
        $sql = "INSERT INTO BOOK_TITLE(BOOK_ID,TITLE_ID) 
VALUES($bookID,$titleID)";
        mysql_query($sql);
$sql = "INSERT INTO AUTHOR_TITLE(AUTHOR_ID, TITLE_ID) VALUES($authorID,$titleID)";
        mysql_query($sql);
$sql = "INSERT INTO TITLE_GENRE(TITLE_ID,GENRE_ID) VALUES($titleID," . $_POST["genre"] . ")";
        mysql_query($sql);
        } catch(Exception $e) {
                echo $e->GetMessage();
                mysql_query("ROLLBACK");
        }
?>


I'm trying to get to the point where if the query doesn't execute, it pops out a message and rollsback any possible results. It doesn't. What's wrong on this script?
--- End Message ---
--- Begin Message ---
do you know what a php exception is and when/where/what generates them?
(if your coming from another language that supports exceptions you may need
to adjust your knowledge - php's exceptions are a little different -
for instance they are not ever generated by the engine itself)

does mysql_query() generate exceptions?
does mysql offer transactions in it's default storage type?
are tansactions on by default in storages types that support
transactions?

answering these questions will probably shed some light on
why your script doesn't do what you think it should.

John Meyer wrote:
I have the following script:


...



I'm trying to get to the point where if the query doesn't execute, it pops out a message and rollsback any possible results. It doesn't. What's wrong on this script?

well it has a big security hole going by the name of 'sql injection'.
if you google 'sql injection php' you should get lots of info on what it is
and how to fix the problem.



--- End Message ---
--- Begin Message ---
No one has any thoughts or advice on this?

Chris

On May 12, 2006, at 3:31 PM, Chris Bruce wrote:

I have a dedicated server and my host just did an upgrade of PHP to 4.4.1. This has caused a couple of major errors and I wanted to share them to see if anyone has any answers or has experienced similar problems.

1. imap functions are not working correctly. Specifically calling it thus:

imap_open({domain.ca:110/pop3},"mailbox","password") gives the following error:

Certificate failure for domain.ca: self signed certificate: /C=--/ ST=SomeState/L=SomeCity/O=SomeOrganization/ OU=SomeOrganizationalUnit/CN=localhost.localdomain/ [EMAIL PROTECTED]

if I add "notls" after pop3 "domain.ca:110/pop3/notls", imap_open works, but the script fails on the subsequent call to imap_fetchstructure.

This was working flawlessly prior to the upgrade to 4.4.1. Here is the configure command: './configure' '--prefix=/usr/local' '--with-config-file-path=/etc' '--with-mysql=/usr/local/mysql' '--enable-ftp' '--enable-bcmath' '-- disable-debug' '--with-gd' '--with-jpeg-dir=/usr' '--with-png-dir=/ usr/local' '--with-ttf' '--with-freetype-dir=/usr/local/freetype2' '--with-zlib' '--with-zlib-dir=/usr' '--with-imap=/usr' '--with- imap-ssl' '--with-kerberos' '--with-apache=../apache_1.3.34' '-- enable-bcmath' '--with-curl=/usr' '--with-pear' '--enable-ftp' '-- enable-calendar' '--enable-memory-limit' '--enable-magic-quotes' '-- enable-wddx' '--with-mhash=/ usr/local/mhash' '--with-openssl-dir=/ usr/local/ssl' '--with-openssl=/usr/local/ssl' '--enable-mbstring' '--with-mcrypt=/usr/local'

My concern here is the "with-imap-ssl". I don't want to use TLS, but as above, disabling it causes the script to die.

I have noticed that my host seems to have dropped the build in from another server as the build date is from October 2005.

Anyone have any ideas?

2. Using the setcookie() function, I am not able to set an expiry for the cookie to anything less than 3603 seconds. 3602 or less does not work. Is this a documented bug?

Thanks,

Chris

--- End Message ---
--- Begin Message ---
Hi,

This is my script:

(ryan_debug_write_to_file is my debug function that
writes stuff into a txt file instead of using a
print(), its working without a problem)

------------------------------
$stdin = fopen('php://stdin', 'r');

while ($line = fgets($stdin))
{
        $line=trim($line);
        ryan_debug_write_to_file('In while(),STDIN,
Start..'.$line.'---End ');

        
$pattern="/^(\d+\.\d+\.\d+\.\d+)\|(.+)\|(\d+)\|([\d-]+)\|(.+)\|(.+)$/";
        if (preg_match($pattern,$line,$m))
/*\|(.+)\|(.+)*/
        {
ryan_debug_write_to_file('Now in Preg match!');
/* This does not execute for some reason....ARRRRGH*/
....more code here
}
------------------------------

The problem is I never get the "Now in Preg match"
message... I have checked the preg_match by taking the
data and putting it in a file and reading it from
there like this:


-----------------------------------

<pre>
<?php

$stdin = fopen("test.txt", "r");
        while ($line = fgets($stdin))
        {
                $line=trim($line);
                echo '<b>In while(),Start..'.$line.'---End of
stdin<br></b>';

        
$pattern="/^(\d+\.\d+\.\d+\.\d+)\|(.+)\|(\d+)\|([\d-]+)\|(.+)\|(.+)$/";
        if (preg_match($pattern,$line,$m))
/*\|(.+)\|(.+)*/
        {


echo 'Now in Preg match!<br>';
                }
        }
?>
</pre>

-----------------------------------

and it works perfectly, so wheres the damn problem on
top? Spent the better part of 3 hours trying to find
the problem.

(you can download the test.txt script from
ezee.se/test/test.txt) basically, the preg_match is to
match this:

193.150.249.47|-|200|188|/usr/local/www/om/www/pass/coin|-



If you want to see the whole script you can download
it from ezee.se/test/coinpass_problem.php.txt


So pissed I want to take a print out of the script and
burn the sh*t.

Any help appreciated.

Thanks,
Ryan

------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-----
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
Ryan A wrote:
Hi,

This is my script:

(ryan_debug_write_to_file is my debug function that
writes stuff into a txt file instead of using a
print(), its working without a problem)

------------------------------
$stdin = fopen('php://stdin', 'r');

while ($line = fgets($stdin))
{
        $line=trim($line);
        ryan_debug_write_to_file('In while(),STDIN,
Start..'.$line.'---End ');

        
$pattern="/^(\d+\.\d+\.\d+\.\d+)\|(.+)\|(\d+)\|([\d-]+)\|(.+)\|(.+)$/";
        if (preg_match($pattern,$line,$m))
/*\|(.+)\|(.+)*/
        {
ryan_debug_write_to_file('Now in Preg match!');
/* This does not execute for some reason....ARRRRGH*/
....more code here
}
------------------------------

The problem is I never get the "Now in Preg match"
message... I have checked the preg_match by taking the
data and putting it in a file and reading it from
there like this:


-----------------------------------

<pre>
<?php

$stdin = fopen("test.txt", "r");
        while ($line = fgets($stdin))
        {
                $line=trim($line);
                echo '<b>In while(),Start..'.$line.'---End of
stdin<br></b>';

        
$pattern="/^(\d+\.\d+\.\d+\.\d+)\|(.+)\|(\d+)\|([\d-]+)\|(.+)\|(.+)$/";
        if (preg_match($pattern,$line,$m))
/*\|(.+)\|(.+)*/
        {


echo 'Now in Preg match!<br>';
                }
        }
?>
</pre>

-----------------------------------

and it works perfectly, so wheres the damn problem on
top? Spent the better part of 3 hours trying to find
the problem.

(you can download the test.txt script from
ezee.se/test/test.txt) basically, the preg_match is to
match this:

193.150.249.47|-|200|188|/usr/local/www/om/www/pass/coin|-



If you want to see the whole script you can download
it from ezee.se/test/coinpass_problem.php.txt


So pissed I want to take a print out of the script and
burn the sh*t.

If you cat test.txt | script.php

(script.php being the first example)

does it work?

I was wondering if the different line endings (dos/unix) might play a factor but I doubt it.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
I periodically make some changes to this little "project-o-mine". 

This new version fixes a few things:
* multiple lans and segments supported (CIDR)
* device names can contain spaces now -- finally!
* duplicate MACs are handled 
  (I realized my VMWare has the same MAC as my notebook in the ARP table. 
   Two IPs, same MAC. Go figure)
* A smidge more OO compliant. Still violates some best practices, but
whatever.

http://daevid.com/examples/dhcp/

Link at page bottom to download.

Requires:

arp
nmap
(dhcpd)
PHP
Web server (I use Apache)

--- End Message ---

Reply via email to