OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 25 May 2003 23:05:08 -0000 Issue 2078

php-general-digest-helplists.php.net
Date: Sun May 25 2003 - 18:05:08 CDT


php-general Digest 25 May 2003 23:05:08 -0000 Issue 2078

Topics (messages 148907 through 148931):

Re: Apache problem:PHP will not execute
        148907 by: electroteque
        148908 by: electroteque
        148914 by: Gurhan Ozen

quantifiers not working in ereg.*
        148909 by: matze
        148916 by: Jason Wong

C++ Integration
        148910 by: Beach Defender
        148911 by: Leon Mergen

Re: Comparing values question.
        148912 by: Ernest E Vogelsinger

Retrieve multiple value's
        148913 by: Frank Keessen
        148915 by: David Otton

Re: Using PHP to connect to mysql 4
        148917 by: Jason Wong

W3C, Section 508, and PHP
        148918 by: Jeffery A.Clark
        148924 by: Ernest E Vogelsinger

Re: HTTP_REFERER <-> Norton firewall
        148919 by: Comex

PHP and javacript (reset) HELP
        148920 by: Philip D Heady
        148923 by: Leif K-Brooks

Problem with readfile, fsockopen, intermittent with apache
        148921 by: Steven
        148926 by: Ernest E Vogelsinger
        148927 by: Ernest E Vogelsinger

pdflib
        148922 by: Yann Larrivee
        148928 by: Evan Nemerson

PHP streams and stat/stat_url function
        148925 by: Edward Rudd

simple "while" loop terminated for no reason
        148929 by: Raymond

Validation problem
        148930 by: Dani Matielo

caching variables and preloading functions
        148931 by: ssamuel

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

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

attached mail follows:


set the application type for php

AddType application/x-httpd-php .php

-----Original Message-----
From: Kjell Hansen [mailto:kjell.hansentelia.com]
Sent: Sunday, May 25, 2003 8:56 PM
To: php-generallists.php.net
Subject: [PHP] Apache problem:PHP will not execute

Hi ye all,
I've just installed an Apache-server and it reports that PHP is enabled
but when I try to open a test page it will not execute but rather
download (like an unknown file type)

Where's the setting I've missed?!?!?

Thanx
/Kjell

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

attached mail follows:


to be even more cheeky u can add any extension u want

AddType application/x-httpd-php .303

or

AddType application/x-httpd-php .nowar

hehehe
-----Original Message-----
From: Kjell Hansen [mailto:kjell.hansentelia.com]
Sent: Sunday, May 25, 2003 8:56 PM
To: php-generallists.php.net
Subject: [PHP] Apache problem:PHP will not execute

Hi ye all,
I've just installed an Apache-server and it reports that PHP is enabled
but when I try to open a test page it will not execute but rather
download (like an unknown file type)

Where's the setting I've missed?!?!?

Thanx
/Kjell

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

attached mail follows:


On Sun, 2003-05-25 at 06:55, Kjell Hansen wrote:
> Hi ye all,
> I've just installed an Apache-server and it reports that PHP is enabled
> but when I try to open a test page it will not execute but rather
> download (like an unknown file type)
>
> Where's the setting I've missed?!?!?
>
> Thanx
> /Kjell
>
   Hi Kjell,
 There is step-by-step instructions here:
http://www.thesitewizard.com/archive/php4install.shtml
 
  Go through it, and make sure you have done all steps correctly
Gurhan

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

attached mail follows:


on a redhat 8.0 box with php 4.1.2 rpm (from rh v7.2) installed
the ereg.* functions don't work as i expect. in some cases -
especially when "\r\n" sequences are involved - the ereg functions
don't match a string, although they should. i tested with the same
code on several machines, it works fine on all, only the above
mentioned redhat box causes problems:

$foo ="barB\r\nfoo\r\n";
if(ereg(".+\r\nfo", $foo))
{
  print('matched');
}
else
{
  print('not matched');
}

i expect the output 'matched', and actually i get it on all machines
but the redhat box.

any idea what could be the reason for this behaviour?

/matze

--
   ( ( ( i ) ) ) http://barcelona.indymedia.org ( ( ( i ) ) )

 * using free software / Debian GNU/Linux | http://debian.org *
                                
gpg --keyserver keys.indymedia.org --recv-keys B9A88F6F

"La guerra es un acto abominable en el que se matan personas que no
 se conocen, dirigidas por personas que se conocen y no se matan"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+0LpHk2+kcbmoj28RArl0AKDYYN5GudIH0I9n1SkEih3HGu6d+gCfSMZW
O7j3T+rnkksu+Qq6BXuUbcA=
=vfTK
-----END PGP SIGNATURE-----

attached mail follows:


On Sunday 25 May 2003 20:42, matze wrote:
> on a redhat 8.0 box with php 4.1.2 rpm (from rh v7.2) installed
> the ereg.* functions don't work as i expect. in some cases -
> especially when "\r\n" sequences are involved - the ereg functions
> don't match a string, although they should. i tested with the same
> code on several machines, it works fine on all, only the above
> mentioned redhat box causes problems:
>
> $foo ="barB\r\nfoo\r\n";
> if(ereg(".+\r\nfo", $foo))
> {
> print('matched');
> }
> else
> {
> print('not matched');
> }
>
> i expect the output 'matched', and actually i get it on all machines
> but the redhat box.

FWIW using RH7.2, PHP 4.3.0 compiled from source the above matches.

> any idea what could be the reason for this behaviour?

Stab in the darK: as of RH8 the locale settings were changed, not sure whether
this has any bearing on your problem. Best ask on the RH list.

Another thing, when you installed php didn't it complain? RH7.2 used Apache
1.3.X and RH8 uses Apache 2.X.

BTW you're probably better off using the preg*() functions anyway.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
An apple every eight hours will keep three doctors away.
*/

attached mail follows:


Hi,
I've just been asked to integrate a payment gateway for a site here in
Oz. We are running on Linux and the bank in question has indicated that
they provide a C++ shared object library (e.g.gateway.so). They have
provided a pretty comphrensive API document, for C++ and Perl.

I've been trying to find references to let me know what I have do to
to access the library from PHP.

Does anyone have a link to good documentation on how to go about this?

Thanks
Barry
barryhpfm.biz

attached mail follows:


"Beach Defender" <userdomain.invalid> wrote in message
news:20030525131920.82038.qmailpb1.pair.com...
> Does anyone have a link to good documentation on how to go about this?

Well, not that, but my bet on this one is that you will be best off just
plainly implementing your own C functions inside PHP. You can do this easily
by hacking the core of PHP, documentation on how to do this is on the PHP
site.

Grt,

Leon

attached mail follows:


At 23:15 24.05.2003, Tom Ray [Lists] said:
--------------------[snip]--------------------
>I've written a guestbook script and I have IP banning in it. Basically
>it checks a flat file with a list of IP address in it and if they match
>the users IP they are denied the ability to post. That works all fine
>and dandy. But here's my question.
>
>How do I get it to compare against a block of IPs? So if I was to add
>1.1.1.* to the list to block everyone from that IP Block, how do I
>compare the 1.1.1.* to like 1.1.1.20 and still have it block? I looked
>over things at PHP.net and I'm guessing I'm just looking over something
>simple. Anyone have any thoughts or suggestions?
--------------------[snip]--------------------

An IP address (dotted notation) is simply a more human-readable notation
for a long value. PHP has the ip2long() and long2ip() functions to help
with that.

Assuming you want to ban the IP range 1.2.3.0 - 1.2.3.255, you could
    $ban_base = ip2long('1.2.3.0');
    $ban_top = ip2long('1.2.3.255');

All you need to do now is to check if a particular IP is within these borders:

    $ip2check = ip2long($_SERVER['CLIENT_ADDRESS']);
    if ($ip2check >= $ban_base && $ip2check <= $ban_top) {
       // banned IP
    }
    else {
       // IP is ok to post
    }

Be aware though that you cannot assume a certain person behind a single IP,
because:
- there might be more than one PCs having this IP (being a proxy server)
- a single PC may change IPs dynamically (Dial-Up, or AOL style)

As to my knowledge, IP-based banning is no good thing to do. You may miss
the target, or you're banning a whole bunch of people you don't want to ban.

Just my 2c worth,

--
>O Ernest E. Vogelsinger
   (\) ICQ #13394035
    ^ http://www.vogelsinger.at/

attached mail follows:


Hi there,

If got in one field multiple values (example; 5,6 or 7,9,23).

The seperator is a comma.

Question is: how can I retrieve this fields out of mysql and put it in array??

Thanks for your help!

Frank

attached mail follows:


On Sun, 25 May 2003 16:48:13 +0200, you wrote:

>If got in one field multiple values (example; 5,6 or 7,9,23).
>
>The seperator is a comma.
>
>Question is: how can I retrieve this fields out of mysql and put it in array??

split()

$array = split($string, $seperator)

from memory. Arguments might be the other way round.

attached mail follows:


On Sunday 25 May 2003 16:05, JJ Harrison wrote:
> Well, any suggestions how to fix it? (I'm running a just downloaded version
> of php 4.3.1)

Try connecting using the mysql commandline. If it doesn't work ask on the
mysql list to get it working.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Somehow, the world always affects you more than you affect it.
*/

attached mail follows:


[This followup was posted to php.general and a copy was sent to the cited author.]

Could anyone tell me if PHP conforms to Section 508
(www.section508.gov)?

attached mail follows:


At 19:32 25.05.2003, Jeffery A.Clark said:
--------------------[snip]--------------------
>[This followup was posted to php.general and a copy was sent to the cited
>author.]
>
>Could anyone tell me if PHP conforms to Section 508
>(www.section508.gov)?
--------------------[snip]--------------------

As far as I can see, Section 508 deals with the necessity to create
websites in a way so disabled persons may access the information provided.

Yes, you can use PHP to create such websites, but it's not a matter of PHP
but a matter of site design, not a matter of the tools you're using to
create it. You can create a very well structured, fully accessible website
with PHP as well as a site that contains only graphics and is full of
onClose="window.open('nextblurb.php')" rubbish...

--
>O Ernest E. Vogelsinger
   (\) ICQ #13394035
    ^ http://www.vogelsinger.at/

attached mail follows:


<004d01c3221a$affcf2f0$0100a8c0koch>
Martin Christian Koch:
>> 1. Only accept requests from your www-server on your pic-server.
>
> That is exactly what I requested. A method for the pic-server to be
> sure it's the www-server which is doing the requesting. Be advised
> that the pic-server has other purposes, acting as www-server for
> other sites and therefore I can't just let apache only accept
> requests from the www-server.

You could do a *double* readfile (but remember this puts extra load on the
servers). That is, do a readfile from the www to a php-script on the pic.
The php-script, in turn, IF THE REQUEST IS FROM THE WWW SERVER, reads a file
somewhere on the machine that the general public can't access :). Although,
using readfile would hide the address of the pic-server.

To check in PHP if the www-server is doing the requesting, compare
$_SERVER['remote_addr'] against the www-server's IP address,

>
>> 2. Do a readfile from your www-server to your pic-server.
>
> Thanks.
>
> Martin

--
1.41421356237309504880168872420969807856967187537694
No, it's true that the above isn't not true, unless it is.
The search is more profitable than the find.
Never, ever back down.
..==// Why not? \\==..

attached mail follows:


I have a form with drop down boxes coded in PHP that validates fields,
etc...and when I use an graphic to reset the forms via javascript (reset)
function. Well, it does not work. Any help is appreciated.

<td>
<a href="javascript:document.form1.reset()">
<input type="image" src="/contact/images/clear-request.gif" border="0"
alt="Clear Request" value="reset" width="119" height="27">
</a>
</td>

Philip D Heady
Ignission, Inc.

attached mail follows:


What does this have to do with PHP? To answer your question, you can't
make an <input> a link. Use an <img> tag instead.

Philip D Heady wrote:

>I have a form with drop down boxes coded in PHP that validates fields,
>etc...and when I use an graphic to reset the forms via javascript (reset)
>function. Well, it does not work. Any help is appreciated.
>
>
><td>
><a href="javascript:document.form1.reset()">
><input type="image" src="/contact/images/clear-request.gif" border="0"
>alt="Clear Request" value="reset" width="119" height="27">
></a>
></td>
>
>
>Philip D Heady
>Ignission, Inc.
>
>
>
>
>

--
The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.

attached mail follows:


Hi all,

I've been having a problem with readfile and fsockopen not working all
the
time with my PHP installation. The code worked fine for months without
and
then suddenly stopped working. The errors getting from the respective
calls
are:

Warning: readfile(http://www.someurl.com?arg)
http://www.php.net/function.readfile failed to create stream: HTTP
request
failed!

and:

fsockopen() [function.fsockopen]: php_hostconnect: connect failed

The strange thing about both of these errors, is that once the error is
occuring and the functions are not working, if I restart Apache (php is
running as an apache module), then the functions will work for a short
time
(havn't figured out exactly how long, at least 30 minutes or an hour)
before
something happens and they stop working again with the above errors.

I'm not certain it is a PHP issue, but may be something else that PHP
interacts with. I'm very stumped due to the odd behavior when restarting
apache.

Thanks for any help,
Steven

attached mail follows:


At 21:23 25.05.2003, Steven said:
--------------------[snip]--------------------
>I've been having a problem with readfile and fsockopen not working all
>the
>time with my PHP installation. The code worked fine for months without
>and
>then suddenly stopped working. The errors getting from the respective
>calls
>are:
>
>Warning: readfile(http://www.someurl.com?arg)
>http://www.php.net/function.readfile failed to create stream: HTTP
>request
>failed!
>
>and:
>
>fsockopen() [function.fsockopen]: php_hostconnect: connect failed
>
>The strange thing about both of these errors, is that once the error is
>occuring and the functions are not working, if I restart Apache (php is
>running as an apache module), then the functions will work for a short
>time
>(havn't figured out exactly how long, at least 30 minutes or an hour)
>before
>something happens and they stop working again with the above errors.
>
>I'm not certain it is a PHP issue, but may be something else that PHP
>interacts with. I'm very stumped due to the odd behavior when restarting
>apache.
--------------------[snip]--------------------

What operating system? What Apache and PHP version?

The effect you describe seems to me that PHP runs out of file handles.
Windoze issue?

--
>O Ernest E. Vogelsinger
   (\) ICQ #13394035
    ^ http://www.vogelsinger.at/

attached mail follows:


Do you close the socket you're opening? If PHP is running as Apache module,
opened sockets may be left open if you don't close them (which opsys or
Apache version would do this?) so Apache or PHP is running out of socket
descriptors, probably.

Just guessing.

--
>O Ernest E. Vogelsinger
   (\) ICQ #13394035
    ^ http://www.vogelsinger.at/

attached mail follows:


Hi i noticed that "pdf_add_weblink" is not affected by "pdf_translate"

I think that might be a bug, but befor i report i want to know if
someone else found this error in other version of php .

I am using PHP5 latest snaps.

Thanks

Yann Larrivee

attached mail follows:


Sounds suspiciously like a bug in pdflib, not PHP. Is pdf_add_note() affected
(in PDF files, Link is a Subtype of Annot)??? Have you tried using the C
library directly (w/o PHP)?

I don't have PDFLib to test with, and it would be treason to install it since
I'm working on competition ( http://www.coeus-group.com/panda ) ;-)

On Sunday 25 May 2003 12:44 pm, Yann Larrivee wrote:
> Hi i noticed that "pdf_add_weblink" is not affected by "pdf_translate"
>
> I think that might be a bug, but befor i report i want to know if
> someone else found this error in other version of php .
>
> I am using PHP5 latest snaps.
>
> Thanks
>
> Yann Larrivee

--

The public have an insatiable curiosity to know everything. Except what is
worth knowing. Journalism, conscious of this, and having tradesman-like
habits, supplies their demands.

-Oscar Wilde

attached mail follows:


with a PHP Stream, when are the stat functions called??
the php_stream_wrapper_ops structure's stat and stat_url members and
php_stream_ops structure's stat member.

Right now I have a php wrapper that wraps around the PhysFS libraru
(http://www.icculus.org/physfs/) And I would like to be able to implement
stat functions so in my PHP code I can check whether a file exists or if
it's a directory.. This wrapper is registered as physfs:// AND overrides
the php_plain_files wrapper so I can use regular paths and they will ALL
be forced to access the physfs system.. (I un-static'ed the structure in
main/streams.c so I could "illegally" override the members with my module.
. It's for use in an embedded game scripting engine..soo.)

right now I have enough implemented so opening files,directories,
includes and requires all go through the physfs wrapper. Just is_dir,
is_file, etc.. don't go through the wrapper and I would like to figure out
how to make them...

Also, what is the cast member of the stream_ops for??

Edward Rudd

attached mail follows:


hi, i'm using php ver 4.3.1 in winXP o/s.

my html output always halted halfway from execution. i find out
that it has got to do with the while loop.

for simplicity, i created a test php file that will execute a loop for
1000 times and print out some strings. however, even before it
reach 1000, it stops. there is no error given.

========================
the php file as below:

<html>
<head><title>test</title></head>
<body>

<?php

    $count = 0;

    while ($count < 1000) {
        print ++$count . ", field01, field02, field03, field04, field05,
field06, field07, field08, field09<br>\n";
    }

?>

</body>
</html>

========================
the html result generated as below:

<html>
<head><title>test</title></head>
<body>

1, field01, field02, field03, field04, field05, field06, field07, field08,
field09<br>
2, field01, field02, field03, field04, field05, field06, field07, field08,
field09<br>
3, field01, field02, field03, field04, field05, field06, field07, field08,
field09<br>
4, field01, field02, field03, field04, field05, field06, field07, field08,
field09<br>
:
:
:
933, field01, field02, field03, field04, field05, field06, field07, field08,
field09<br>

Note:: it ends here. no error displayed.

========================

all kind advices are appreciated. thanks in advance.

regards,
raymond

attached mail follows:


Ok, here is my problem. I have this website where my user will log in.

I have this function that list all the permissions possible

function lista_permissoes() {

    $result = mysql_query("select * from permissoes ORDER BY ordem");
    while ($row4 = mysql_fetch_array($result,MYSQL_ASSOC)) {
 $permissoes[] = $row4;
    }
   return $permissoes;
};

And this function that., I suppose, should check if the group that the
person belongs have this permission or not
function validar($grupo,$perm) {
    $permissao = mysql_query("select id_permissoes from grupos_permissoes
where id_grupos = $grupo") or die ('query failed');
 $row = mysql_fetch_array($permissao);
 $acesso = 0;
 for ($i = 0 ; $i<=sizeof($row); $i++){
 if (array_key_exists($perm, $row)) {
    $acesso = 1;
 }
}
return $acesso;
}

So, if the permission in question belongs to the group, it would return
$acesso 1, right? So, putting the 2 of them together, it would work like
this:
$permis = lista_permissoes();
for($i=0; $i<=sizeof($permis); $i++) {
$permiss = $permis[$i];
//here the SESSION is the id of the group of the user
 $aux = validar($_SESSION['ciranda']['id_grupo'],$permiss['id']);
 if ($aux) {
  ?>
          <a href="index-2.php?permissao=<?= $permiss['id'] ?>"
class="permiss">
          <?= $permiss['nome']?>
          </a><hr align="left" width="150">
          <?
 }
}

Well, I dont get any error, but I can get only the first permission
validated... its like the function is not looping back. Can anyone see what
is wrong?

Thank you in advance,

Dani

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.481 / Virus Database: 277 - Release Date: 13/5/2003

attached mail follows:


Hi,

I am looking for a way to do the following with PHP on Apache.

1) I have a list of functions that I would like loaded into memory when
the Apache server starts so that other .PHPs can call these functions at
any time. Somewhat of a way to expand the API set for PHP.

i.e., Say I have a file named "init.php" which has many functions
defined. When the Apache server loads, I want this file to be sourced
so that these functions are visible to all other phps.

2) I have several variables, that I want to be cached at server init
time. These variables are global variables and live until the server is
restarted and can be accessed by any .phps.

Are there any ways to do these?

thanks,
sunil.