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 23 Oct 2005 13:03:42 -0000 Issue 3753

php-general-digest-helplists.php.net
Date: Sun Oct 23 2005 - 08:03:42 CDT


php-general Digest 23 Oct 2005 13:03:42 -0000 Issue 3753

Topics (messages 224476 through 224514):

Re: Using PHP-based form authentication, circumventing existing Apache .htaccess "require valid-user"
        224476 by: Robert Cummings
        224477 by: Dan Trainor
        224481 by: Richard Lynch
        224484 by: Dan Trainor

Re: file_exists()
        224478 by: Jonny Bergström
        224482 by: Richard Lynch
        224489 by: Jonny Bergström

Processing two post values
        224479 by: Shaun
        224485 by: tg-php.gryffyndevelopment.com
        224487 by: Richard Lynch
        224498 by: Minuk Choi

Re: Ugh, w32 anything is making me want to drink!
        224480 by: Eric Butera
        224483 by: Richard Lynch
        224500 by: Leif Gregory

Re: Memory Leak?
        224486 by: Richard Lynch
        224495 by: tg-php.gryffyndevelopment.com
        224496 by: Richard Lynch

Re: Calling PostgreSQL & MySQL Stored Procedures
        224488 by: Richard Lynch

Re: Dynamically Loading Plugins
        224490 by: Richard Lynch

Re: JPG Slide show
        224491 by: Richard Lynch
        224507 by: John Taylor-Johnston

Re: XML-RPC Error:-32300:transport error - could not open socket
        224492 by: Richard Lynch

Re: PHP on Windows 2003 Server
        224493 by: Richard Lynch

Re: Email Validation built-in? RFC
        224494 by: Richard Lynch
        224502 by: Manuel Lemos

Re: Declaring vars as INT ?
        224497 by: Richard Lynch

Re: Submit/Validate triggering problem.
        224499 by: Richard Lynch

Re: White background with imagecreatetruecolor()
        224501 by: Richard Lynch

Re: Inserting NULL Integer Values
        224503 by: Richard Lynch

Forcing auto_prepend_file to work regardless of what document was accessed
        224504 by: Dan Trainor
        224505 by: Richard Lynch
        224506 by: Dan Trainor
        224508 by: Richard Lynch

Abstract Classes?
        224509 by: Alan Lord
        224510 by: Jasper Bryant-Greene
        224513 by: Alan Lord

Php and Ruby
        224511 by: Jacob Friis Saxberg
        224512 by: Jacob Friis Saxberg
        224514 by: Greg Donald

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:


On Sat, 2005-10-22 at 19:28, Dan Trainor wrote:
> Hello, all -
>
> I'm trying to think of how this might be possible, but I can't seem to
> come up with anything.
>
> I'd like to make a login form of sorts, which would enable a user to
> authenticate against. A simple HTML form, with a PHP back-end, where a
> user enters a username and password. If this authentication succeeds,
> the user is redirected to the protected area. However, this protected
> area was originally protected by an Apache .htaccess-style "require
> valid-user".
>
> After authentication succeeds, I'd like to redirect the user to the
> Apache protected directory, circumventing the .htaccess "require
> valid-user" method - because the user has already authenticated by some
> other means, and there's no need to re-authenticate against HTTP Basic
> Authentication.
>
> Anyone know if this is possible, and if so, how this might work? I'm
> just looking for some ideas here.

If you know the appropriate login and password then you can redirect
using the username and password in the url (not very secure though):

    http://user:passwordwww.someplace.ext/blahBlahBlah.php

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


Robert Cummings wrote:
> On Sat, 2005-10-22 at 19:28, Dan Trainor wrote:
>
>>Hello, all -
>>
>>I'm trying to think of how this might be possible, but I can't seem to
>>come up with anything.
>>
>>I'd like to make a login form of sorts, which would enable a user to
>>authenticate against. A simple HTML form, with a PHP back-end, where a
>>user enters a username and password. If this authentication succeeds,
>>the user is redirected to the protected area. However, this protected
>>area was originally protected by an Apache .htaccess-style "require
>>valid-user".
>>
>>After authentication succeeds, I'd like to redirect the user to the
>>Apache protected directory, circumventing the .htaccess "require
>>valid-user" method - because the user has already authenticated by some
>>other means, and there's no need to re-authenticate against HTTP Basic
>>Authentication.
>>
>>Anyone know if this is possible, and if so, how this might work? I'm
>>just looking for some ideas here.
>
>
> If you know the appropriate login and password then you can redirect
> using the username and password in the url (not very secure though):
>
> http://user:passwordwww.someplace.ext/blahBlahBlah.php
>
> Cheers,
> Rob.

Thanks for the suggestion, Rob, but the dominant browser (sadly, IE) no
longer supports this in later versions.

Thanks
-dant

attached mail follows:


You USED to be able to do that by putting

http://username:passwordexample.com

but then Microsoft, in its infinite wisdom, decided that was a
"security risk" and stopped supporting it.

AFAIK, there's no way to SET the USER/PASS from server to browser...

Hmmmm.

You could maybe use cURL to login, then pass back all the responses to
the browser, and then the headers that make them be "logged in" would
work for both your login and their .htaccess.

The PHP Form and HTTP Auth part of all this for your first login is
documented right in the manual, so you needn't strain your brain on
that bit.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Richard Lynch wrote:
> You USED to be able to do that by putting
>
> http://username:passwordexample.com
>
> but then Microsoft, in its infinite wisdom, decided that was a
> "security risk" and stopped supporting it.
>
> AFAIK, there's no way to SET the USER/PASS from server to browser...
>
> Hmmmm.
>
> You could maybe use cURL to login, then pass back all the responses to
> the browser, and then the headers that make them be "logged in" would
> work for both your login and their .htaccess.
>
> The PHP Form and HTTP Auth part of all this for your first login is
> documented right in the manual, so you needn't strain your brain on
> that bit.
>

Thanks for the response, Richard -

However, I'm not looking to insert usernames or passwords into the
client browser. I'm simply looking for a way to have apache totally
ignore all AuthConfig information if the user has already authenticated
to the system using some PHP form hackery.

I think I found a solution here that I'm going to play with.

Thanks
-dant

attached mail follows:


Good idea yes. But apparantly Windows couldn't do it either. :-(

function file_exists_windows($path) {
exec('dir ' . $path, $output, $return_status);
return $return_status == 0 ? true : false; // Windows dir will return 0 when
something was found
}

It works with "normal" ascii file names, but other than that it's a no.
Makes you wonder what the problem is here, maybe exec() not supporting
unicode either.

attached mail follows:


On Sat, October 22, 2005 7:12 pm, Jonny Bergström wrote:
> Good idea yes. But apparantly Windows couldn't do it either. :-(
>
> function file_exists_windows($path) {
> exec('dir ' . $path, $output, $return_status);
> return $return_status == 0 ? true : false; // Windows dir will return
> 0 when
> something was found
> }

First, I don't think $return_status is what you think it is.

$return_status is FALSE if your command is not syntactically valid.

It will be TRUE if your command is syntactically valid, but you'll
need to LOOK at $output to see if the file is listed or not.

> It works with "normal" ascii file names, but other than that it's a
> no.
> Makes you wonder what the problem is here, maybe exec() not supporting
> unicode either.

If the filename is funky, you are going to have to do whatever you
would do in a DOS prompt to escape it, munge, or otherwise convert it
to whatever that version of Windows uses.

Inlucding 8.3 on ancient Windows, if PHP runs on that junk.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On 10/23/05, Oliver Grätz <oliver.graetzarcor.de> wrote:
>
> I believe that the problem is not Windows being unable to look fpr unicode
> files but PHP being unable to put th unicode string correctly in the command
> line you are trying to execute. Check this by doing "exec('echo >test.txt'.$path);" and checking if the unicode arrives in the text file. If not,
> perhaps the multibyte-extension might help out.
>
>
Yes PHP won't do this either. Unfortunately the "DOS" box in Windows doesn't
allow entering kanji either, but running a normal batch file with the same
echo line does indeed work, test.txt containing the correct characters as
entered into the .bat file.

attached mail follows:


Hi,

I have a form on my site with a database driven amount of rooms for a
property - bedrooms, bathrooms and receptions.

For each room there will be a textfield allowing users to enter the x and y
dimensions.

For each room I need to insert the values to the database, however I cant
think of a way to do this. All one can do with php is a foreach on the
$_POST values whereas I need to process two at a time i.e. one insert of the
x and y values per room. Here is the form I have created:

<form action="<?php action=<?php echo $frm['action']; ?>&property_id=<?php
echo $_GET['property_id']; ?>" method="post">
 <table>
 <tr>
  <?php
   $i = 1;
   while( $i <= $frm["Number_Of_Bedrooms"] ){
  ?>
  <tr>
   <td>Bedroom <?php echo $i ?>
   <td>X:<input name="bedroom_<?php echo $i ?>_x" type="text" /></td>
   <td>Y:<input name="bedroom_<?php echo $i ?>_y" type="text" /></td>
  </tr>
  <?php
   $i++;
   }
   $i = 1;
   while( $i <= $frm["Number_Of_Bathrooms"] ){
  ?>
  <tr>
   <td>Bathroom <?php echo $i ?>
   <td>X:<input name="bathroom_<?php echo $i ?>_x" type="text" /></td>
   <td>Y:<input name="bathroom_<?php echo $i ?>_y" type="text" /></td>
  </tr>
  <?php
   $i++;
   }
   $i = 1;
   while( $i <= $frm["Number_Of_Receptions"] ){
  ?>
  <tr>
   <td>Reception <?php echo $i ?>
   <td>X:<input name="reception_<?php echo $i ?>_x" type="text" /></td>
   <td>Y:<input name="reception_<?php echo $i ?>_y" type="text" /></td>
  </tr>
  <?php
   $i++;
   }
  ?>
  <tr>
   <td>&nbsp;</td>
   <td><input type="submit" name="Submit" value="<? echo
$frm["submit_text"]; ?>"></td>
   <td>&nbsp;</td>
  </tr>
 </table>
</form>

attached mail follows:


Depending on your requirements, I think add one room at a time.

For instance, your property sheet comes up initially with "No rooms configured".

Then have a SELECT/OPTION pulldown for type:

Bedroom
Bathroom
Living Room
Garage
Dining Room
Kitchen
etc...

Then have an X and Y input box.

You could even get fancy and have addition room info like irregular cutouts that reduce the room's square footage, etc.

User clicks ADD and it creates an entry in the database and returns to the "Add Rooms" screen with a list of all the rooms already configured.

Finally just put a "Done" or "Finished" button that moves to the next step in the process (or back to a main screen).

When the number of items is almost always unknown, your best bet is to keep the interface flexible. Otherwise you end up with "Well, we only built this to handle 4 bedrooms.. this property has 5.. ok, just add it as a living room and we'll make sure the customer knows it's another bedroom". That's just clumsy.

Database could have a Proprerty table (main info regarding the property), a PropertyFeatures table (containing info about rooms, yard, etc.. with the PropertyID that it belongs to), then maybe a third table for addition info regarding the PropertyFeature, like irregular cutouts, wall paint color, carpet/flooring type, etc.

I don't know how much control you have or how many requirements that may conflict with this you have are, but that's how I'd design it.

Good luck!

-TG

= = = Original message = = =

Hi,

I have a form on my site with a database driven amount of rooms for a
property - bedrooms, bathrooms and receptions.

For each room there will be a textfield allowing users to enter the x and y
dimensions.

For each room I need to insert the values to the database, however I cant
think of a way to do this. All one can do with php is a foreach on the
$_POST values whereas I need to process two at a time i.e. one insert of the
x and y values per room. Here is the form I have created:

<form action="<?php action=<?php echo $frm['action']; ?>&property_id=<?php
echo $_GET['property_id']; ?>" method="post">
 <table>
 <tr>
  <?php
   $i = 1;
   while( $i <= $frm["Number_Of_Bedrooms"] )
  ?>
  <tr>
   <td>Bedroom <?php echo $i ?>
   <td>X:<input name="bedroom_<?php echo $i ?>_x" type="text" /></td>
   <td>Y:<input name="bedroom_<?php echo $i ?>_y" type="text" /></td>
  </tr>
  <?php
   $i++;
   
   $i = 1;
   while( $i <= $frm["Number_Of_Bathrooms"] )
  ?>
  <tr>
   <td>Bathroom <?php echo $i ?>
   <td>X:<input name="bathroom_<?php echo $i ?>_x" type="text" /></td>
   <td>Y:<input name="bathroom_<?php echo $i ?>_y" type="text" /></td>
  </tr>
  <?php
   $i++;
   
   $i = 1;
   while( $i <= $frm["Number_Of_Receptions"] )
  ?>
  <tr>
   <td>Reception <?php echo $i ?>
   <td>X:<input name="reception_<?php echo $i ?>_x" type="text" /></td>
   <td>Y:<input name="reception_<?php echo $i ?>_y" type="text" /></td>
  </tr>
  <?php
   $i++;
   
  ?>
  <tr>
   <td>&nbsp;</td>
   <td><input type="submit" name="Submit" value="<? echo
$frm["submit_text"]; ?>"></td>
   <td>&nbsp;</td>
  </tr>
 </table>
</form>

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

attached mail follows:


On Sat, October 22, 2005 7:14 pm, Shaun wrote:
> For each room I need to insert the values to the database, however I
> cant
> think of a way to do this. All one can do with php is a foreach on the
> $_POST values whereas I need to process two at a time i.e. one insert
> of the
> x and y values per room. Here is the form I have created:

Actually, PHP will let you process the variables in any manner you see
fit. :-)

What I would recommend in THIS case is to take advantage of your room
numbers to do more like this:

> <form action="<?php action=<?php echo $frm['action'];
> ?>&property_id=<?php
> echo $_GET['property_id']; ?>" method="post">
> <table>
> <tr>
> <?php
> $i = 1;
> while( $i <= $frm["Number_Of_Bedrooms"] ){
> ?>
> <tr>
> <td>Bedroom <?php echo $i ?>
> <td>X:<input name="bedroom_<?php echo $i ?>_x" type="text" /></td>
> <td>Y:<input name="bedroom_<?php echo $i ?>_y" type="text" /></td>

<input name="bedroom_x[<?php echo $i?>]" />
<input name="bedroom_y[<?php echo $i?>]" />

At the other end, when you process these, you'll have:

$property_id = $_POST['propery_id'];
$bedroom_x = $_POST['bedroom_x'];
$bedroom_y = $_POST['bedroom_y'];
while (list($i, $x) = each($bedroom_x)){
  $y = $bedroom_y[$i];
  echo "Bedroom $i: ($x, $y)<br />\n";
}

Note that PHP is one of the FEW languages that lets you use arrays as
NAME= in the HTML form and you can do something useful with it.

ASP don't do that.

JavaScript will choke on those names, most likely.

So, in reality, it's PHP's flexibility in processing of POST data that
is going to make this simple and natural rather than contrived and
complex.

NOTE:
This sample code contains no error-checking, data scrubing, nor
data-vaildation.

That's all got to be added by you.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


...not quite sure what you're asking. Are you asking for help on how to
process these variables?

I wrote this off the top of my head... meaning that I did not test it...
since I don't know if this was what you were asking... I just fiddled
with it.
Add this code and tell me if it prints out the sql statements the way
you wanted

BTW,

I think your code is wrong here

<form action="<?php action=<?php echo $frm['action']; ?>&property_id=<?php
echo $_GET['property_id']; ?>" method="post">

should be

<form action="<?php echo $frm['action'];?>&property_id=<?php
echo $_GET['property_id']; ?>" method="post">

-Minuk

====BEGIN CODE====

$roomArray = array();
$roomArray['bedroom'] = array();
$roomArray['bathroom'] = array();
$roomArray['reception']=array();

/*
 * I am assuming all you have are 3 types of rooms, 'bedroom',
'bathroom', and 'reception'
 *
 * I am also assuming that the lowest room number is 1 and that the all
the room values are of the following format :
 *
 * ROOMNAME_ROOMNUMBER_X
 * ROOMNAME_ROOMNUMBER_Y
 *
 * the format is strict, there must be an "_" after the room name and
one after room number
 */

/*
 * Loop through post, and if the form name starts with a room name...
then try to "decipher" the form name.
 * If appropriate, then add.
 */
foreach ($_POST as $key=>$value)
{
    /*
     * see if the $key has "_" after the first character
     * and another "_" after the first one
     *
     * Search for the following
     *
     * Valid form names are of
     *
     * CHARACTER + (1 or more letters) + "_" + NUMBER + (1 or more
numbers) + "_" + (X or Y)
     *
     * Using explode, if we break a form name at the '_', the valid
types should break into three pieces
     * room name
     * room number
     * room dimension(x or y)
     */

    $roomDataArray = explode('_', $key);

    if (count($roomDataArray)==3)
    {
          $roomName = $roomDataArray[0];
          $roomNumber = $roomDataArray[1];
          $roomDimension = $roomDataArray[2];

          /*
           * check to see if $roomName exists in $roomArray,
           * $roomNumber is a number
           * $roomDimension is 'X' or 'Y'
           * $_POST[$key] is a number > 0
           */
   
          if (isset($roomArray[$roomName])
             && is_numeric($roomNumber)
             && (strcasecmp($roomDimension, 'x') == 0 ||
strcasecmp($roomDimension, 'y')==0)
             && is_numeric($_POST[$key])
             )
        {
             if (!isset($roomArray[$roomName][$roomNumber]))
                $roomArray[$roomName][$roomNumber] = array();

            $roomArray[$roomName][$roomNumber][$roomDimension] = $value;
             //By the way, $_POST[$key] = $value, in case I lost 'ya there
        }
    }
}

/*
 * At this point, $roomArray should be of the following format
 *
 * $roomArray['bedroom'][1][x] = 10;
 * $roomArray['bedroom'][1][y] = 20;
 * .
 * .
 * .
 * etc.
 *
 * generate an insert sql statement PER ROOM
 */

echo 'sql commands <BR><BR>';

foreach ($roomArray as $roomName=>$roomNumberDataArray)
    foreach ($roomNumberDataArray as $roomNumber=>$roomDimensionArray)
       foreach ($roomDimensionArray as $roomDimension => $value)
       {
            $sql = 'insert into database.table("roomName", "roomNumber",
"roomDimensionName", "roomDimensionValue") values ("'.$roomName.'",
"'.$roomNumber.'", "'.$roomDimension.'", "'.$value.'");';

            echo $sql.'<BR>';
        }

echo 'done';

====END CODE====

Shaun wrote:

>Hi,
>
>I have a form on my site with a database driven amount of rooms for a
>property - bedrooms, bathrooms and receptions.
>
>For each room there will be a textfield allowing users to enter the x and y
>dimensions.
>
>For each room I need to insert the values to the database, however I cant
>think of a way to do this. All one can do with php is a foreach on the
>$_POST values whereas I need to process two at a time i.e. one insert of the
>x and y values per room. Here is the form I have created:
>
><form action="<?php action=<?php echo $frm['action']; ?>&property_id=<?php
>echo $_GET['property_id']; ?>" method="post">
> <table>
> <tr>
> <?php
> $i = 1;
> while( $i <= $frm["Number_Of_Bedrooms"] ){
> ?>
> <tr>
> <td>Bedroom <?php echo $i ?>
> <td>X:<input name="bedroom_<?php echo $i ?>_x" type="text" /></td>
> <td>Y:<input name="bedroom_<?php echo $i ?>_y" type="text" /></td>
> </tr>
> <?php
> $i++;
> }
> $i = 1;
> while( $i <= $frm["Number_Of_Bathrooms"] ){
> ?>
> <tr>
> <td>Bathroom <?php echo $i ?>
> <td>X:<input name="bathroom_<?php echo $i ?>_x" type="text" /></td>
> <td>Y:<input name="bathroom_<?php echo $i ?>_y" type="text" /></td>
> </tr>
> <?php
> $i++;
> }
> $i = 1;
> while( $i <= $frm["Number_Of_Receptions"] ){
> ?>
> <tr>
> <td>Reception <?php echo $i ?>
> <td>X:<input name="reception_<?php echo $i ?>_x" type="text" /></td>
> <td>Y:<input name="reception_<?php echo $i ?>_y" type="text" /></td>
> </tr>
> <?php
> $i++;
> }
> ?>
> <tr>
> <td>&nbsp;</td>
> <td><input type="submit" name="Submit" value="<? echo
>$frm["submit_text"]; ?>"></td>
> <td>&nbsp;</td>
> </tr>
> </table>
></form>
>
>
>

attached mail follows:


On 10/22/05, Jochem Maas <jochemiamjochem.com> wrote:
>
> John Nichel wrote:
> > Jay Blanchard wrote:
> >
> >> [snip]
> >>
> >>> I just noticed that extension_dir in phpinfo is c:\php4 THAT AIN'T
> >>> RIGHT!
> >>> Why is PHP not loading the proper ini file? This is probably the
> >>> source of
> >>> my problems all along! ACK!!!!!
> >>>
> >>
> >>
> >> This is what happens when you go over to the dark side.
> >> [/snip]
> >>
> >> It's not my fault! How do I fix this?
> >>
> >
> > Hell if I know, I haven't touched a Windows machine in years. Move the
> > ini file you want it to read to the location it's looking in?
> >
> > You could symbolic link it....oops...wait...no, you can't. ;)
>
> actually the underlying 'OS' does support something I think they call
> hard links - but you need a 3rd extension to use it (free download
> somewhere,
> gives you an extra item in context menu) ... behold the power of the dark
> side. :-)
>
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I don't know if this has been said or not, but phpinfo() shows the path to
the ini near the top like:
Configuration File (php.ini) Path d:\program files\easyphp1-8\apache\php.ini

attached mail follows:


On Sat, October 22, 2005 7:14 pm, Eric Butera wrote:
> On 10/22/05, Jochem Maas <jochemiamjochem.com> wrote:
>>
>> John Nichel wrote:
>> > Jay Blanchard wrote:
>> >
>> >> [snip]
>> >>
>> >>> I just noticed that extension_dir in phpinfo is c:\php4 THAT
>> AIN'T
>> >>> RIGHT!
>> >>> Why is PHP not loading the proper ini file? This is probably the
>> >>> source of
>> >>> my problems all along! ACK!!!!!

IF you are using Apache, and you should be :-), you MIGHT be able to
use that Apache directive that tells PHP to find the ini file
elsewhere

Otherwise, it's compiled into the DLL and you are stuck.

A Windoze "shortcut" WILL NOT WORK

That 3rd party thing might.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hello Richard,

Saturday, October 22, 2005, 6:37:14 PM, you wrote:
> Otherwise, it's compiled into the DLL and you are stuck.

> A Windoze "shortcut" WILL NOT WORK

One of the easiest ways to ensure you're using the php.ini file you
want is to create the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath

I usually stick my php.ini in my php folder because I ensure that I
(my user account) has sufficient rights to modify anything in the php
folder whereas the server admin wouldn't give my user account rights
to modify files in the Windows folder.

You can read more here:

http://docs.php.net/en/configuration.html#configuration.file

In addition to setting the directives in the php.ini file for your
extensions folder, I'd also add it to your Windows Path.

You can do that by:

Right-click My Computer

Choose properties

Advanced tab

Click the Environment Variables button

Under System variables, edit the Path

At the end of the path line, add a semi-colon (if there isn't one)

Then type in the full path to your extensions folder i.e.
C:\PHP\ext

Click, Ok, then Ok, then Ok.

Restart your webserver, run phpinfo() and make sure that the ini path
is the one you specified.

Just FYI, you might add the main php folder to your path as well
because some of the .dlls you want might be in that folder
libeay32.dll for instance.

--
                          TBUDL/BETA/DEV/TECH Lists Moderator / PGP 0x6C0AB16B
 __ ____ ____ ____ Geocaching: http://gps.PCWize.com
( ) ( ___)(_ _)( ___) TBUDP Wiki Site: http://www.PCWize.com/thebat/tbudp
 )(__ )__) _)(_ )__) Roguemoticons & Smileys: http://PCWize.com/thebat
(____)(____)(____)(__) PHP Tutorials and snippets: http://www.DevTek.org

What's the difference between ignorance and apathy?
I don't know and I don't care.

attached mail follows:


On Sat, October 22, 2005 5:04 pm, tg-phpgryffyndevelopment.com wrote:
> Does it make a difference if instead of one record at a time, you pull
> 10, 20, 100... might speed up your process a little and if it
> doesn't use any more memory, then why not?

I could make a buffer of N lines and read them, I guess.

I kinda figured at 1 line a second, PHP and the OS would have no
problem buffering from the disk.

> Another thought.. can you use database replication here? So instead
> of dumping all the records and processing and inserting the ones that
> are new, you'd only be acting on what's changed since the last backup.
> With real replication, you can do this realtime (or at least
> semi-realtime), but you could simulate replication in your PHP script
> as well.

This data's coming from an external source.

Replication is probably not gonna happen.

Though I am going to ask for a timestamp column so I can ignore rows
that haven't changed since my last import.

That should kill about 90% of the MySQL processing, which seems to be
the biggest CPU sink here.

If that happens, I can probably change the sleep to usleep and a
quarter second or so.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


One other thing to keep in mind. Connecting to a database and disconnecting takes some amount of time. If you do it in batches of 10, 100, whatever then make sure you only connect and disconnect once or else you won't have any time savings at all (and will burden the server unnecessarily).

Sucks that you don't have more control over the incoming data.

Good luck in finding a solution.

-TG

= = = Original message = = =

On Sat, October 22, 2005 5:04 pm, tg-phpgryffyndevelopment.com wrote:
> Does it make a difference if instead of one record at a time, you pull
> 10, 20, 100... might speed up your process a little and if it
> doesn't use any more memory, then why not?

I could make a buffer of N lines and read them, I guess.

I kinda figured at 1 line a second, PHP and the OS would have no
problem buffering from the disk.

> Another thought.. can you use database replication here? So instead
> of dumping all the records and processing and inserting the ones that
> are new, you'd only be acting on what's changed since the last backup.
> With real replication, you can do this realtime (or at least
> semi-realtime), but you could simulate replication in your PHP script
> as well.

This data's coming from an external source.

Replication is probably not gonna happen.

Though I am going to ask for a timestamp column so I can ignore rows
that haven't changed since my last import.

That should kill about 90% of the MySQL processing, which seems to be
the biggest CPU sink here.

If that happens, I can probably change the sleep to usleep and a
quarter second or so.

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

attached mail follows:


On Sat, October 22, 2005 9:24 pm, tg-phpgryffyndevelopment.com wrote:
> Sucks that you don't have more control over the incoming data.

Just for the record, for when the source of this data reads this thread.

I am ECSTATIC to have this data, period.

:-)

I know we'll work out a viable solution in time, even if replication
is not in the cards.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sat, October 22, 2005 12:55 pm, Colin Shreffler wrote:
> Can any one please tell me how you call a stored procedure in either
> PostgreSQL or MySQL from php?

WILD GUESS:

$query = "call silly_sproc()";
mysql_query($query, $connection) or die(mysql_error($connection));
pg_exec($connection, $query) or die(pg_last_error($connection));

With an argument is left as an exercise to the reader.

HINT: Stuff whatever you would type in the mysql/psql monitor into $query

No promise this works, as I've only done user-defiend functions rather
than stored procedures (unless those are the same...) in PostgreSQL,
and my webhost's MySQL probably ain't up to stored procedures yet.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sat, October 22, 2005 5:56 pm, Todd Nine wrote:
> I have need to dynamically load some classes. I have created an
> abstract class that defines a function. Note that I'm using PHP 4 so
> abstract is not enforced. 3rd party plugins will then implement this
> interface. Users will upload their plugins via a web interface. After
> I save the php class file to the directory ./plugins, I will need to
> load it later. Basically I need to do something like.

Am I to understand that users are uploading PHP code you're going to
execute?...

Sure hope you trust them :-)

Anyway, if you can force them to use that __autoload() thingie (see
the manual) then you're all set. Their class name matches their
filename and it just works like Magic when you make a new $whatever.

Or, the other way around, you know what to make a new of because it
matches the filename.

You need unique filenames anyway, so that keeps your class names
unique, unless somebody crams some "helper" class into their file.

May want to have a "rule" that additional classes in a file MUST have
the filename and underscore as the first part of any helper classes,
just to avoid collisions.

That would probably be the "right way"

If your version of PHP does not support __autoload, check in PECL and
PEAR and in user-contributed notes for work-arounds and
backward-compatible functions.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sat, October 22, 2005 11:15 am, John Taylor-Johnston wrote:
> Found this on one of my favourite tech show sites:
> http://www.flickr.com/photos/globalhermit/sets/1134389/show/
> Is there something in PHP I can script or find toproduce a slide show
> of
> the contents of a Linux directory? (Baby pictures :) )

If you can't find it in one of the 10,000 PHP image gallery scripts
out there, I'll eat my hat. :-)

Simplest way isn't PHP at all, but a META HTTP-EQUIV="REFRESH" tag in
the HTML to go to the next URL/image.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


>... out there, I'll eat my hat. :-)

Get your false teeth out and glue them on. I defy you to find one that
works.
Was it a php3 thing where "= " meant "echo "? I saw this in a number of
scripts where folks were still using <? instead of <?php !?
I've spent 2-3 hours trying to get a number (I can name them) of
galeries to work. :(
Show me one that generates thumbnails - And works for you personally.
But thanks for the Yahoo key words to search with: "PHP image gallery
scripts".
Any one :) Please.

Richard Lynch wrote:

>On Sat, October 22, 2005 11:15 am, John Taylor-Johnston wrote:
>
>
>>Found this on one of my favourite tech show sites:
>>http://www.flickr.com/photos/globalhermit/sets/1134389/show/
>>Is there something in PHP I can script or find toproduce a slide show
>>of
>>the contents of a Linux directory? (Baby pictures :) )
>>
>>
>
>If you can't find it in one of the 10,000 PHP image gallery scripts
>out there, I'll eat my hat. :-)
>
>Simplest way isn't PHP at all, but a META HTTP-EQUIV="REFRESH" tag in
>the HTML to go to the next URL/image.
>
>
>

--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."

  ' ' ' Collège de Sherbrooke:
 ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/
    - 819-569-2064

  °v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures
 /(_)\ Université de Sherbrooke
  ^ ^ http://compcanlit.ca/ T: 819.569.2064

attached mail follows:


On Sat, October 22, 2005 10:19 am, Dan McCullough wrote:
> I'm having any issue finding out why this is happening and how to fix
> it. Is it a permissions problem between php and the server or
> something else?
> Help

Go to the command line/shell or even, gak, MS-DOS, and type:

telnet XYZ 32000

XYZ should be an IP address like 192.168.1.1 or a domain name.

Either the server responds, or it's not working and PHP can't fix it.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sat, October 22, 2005 9:49 am, Tomás Liendo wrote:
> Hi, I have enough experience working with PHP on Windows XP over IIS,
> but
> now I need to work on Windows Server 2003, algo with IIS.
> I installed PHP (With the installer that I downloaded from
> www.php.net) but
> it doesn't work. When I try to see a PHP page I receive the following
> message:
>
> "The server can not found"
>
> What can I do?

That usually means you have the IP/domainname wrong.

If you are using 'localhost' try 127.0.0.1 instead, and if that works,
you just have to fix the "hosts" file that Windows doesn't provide by
default in some weird directory I'll never remember. info.com it.

If 127.0.0.1 is what you are using, try 'localhost' for fun.

If neither of those work, use the actual IP address of the machine.
Run the command "winipcfg" and it should tell you what the IP is in a
fancy window. Or, if not, because MS changed that this week,
"ipconfig" in an MS-DOS prompt, if it exists in Win2003, should do the
trick.

You can also use "ping" to figure out if the machine is there, unless
that's been turned off on the box.

Also try a different browser. IE often lies in its error messages.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sat, October 22, 2005 2:32 pm, James Benson wrote:
> It would be nice to have a php function valid_email or something but
> until then i suppose we just make do with what is available, for what
> I
> need I use the following:-
>
> eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"
> .""."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)
>
> Ive never had problems with it but have up to now no need for
> multilanguage validation.
>
> What is wrong with that validation anyway?

If you are lucky, it does not reject any valid emails.

For sure, however, it is not the 3-page 'correct' validation and
therefore must accept at least SOME invalid emails...

Almost for sure, it doesn't accept the new-fangled international emails.

Presumably, if a built-in PHP function did this, changing it in one
place would make everybody's code work right for this monumental
change...

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hello,

on 10/22/2005 12:58 AM Richard Lynch said the following:
> Checking MX records is not reliable at all.

I agree that it is less useful today, but it still help catches many
domain name typos.

> ... would it not make sense for there to be a BUILT-IN PHP function of
> a TRUE email syntactic validation?

I don't see that being much better than passing a good regular
expression to preg_match.

> Currently, email syntax validation is being done in very limited
> fashion, if not outright "wrong" by rejecting what actually ARE valid
> email addresses in about 10,000,000 PHP scripts by users who don't
> have any realistic options to truly "do it right" because who can
> really live with that 3-page Regex in their PHP code?

For many years I use this regular expression in popular email validation
and forms generation and validation classes.

http://www.phpclasses.org/formsgeneration

http://www.phpclasses.org/emailvalidation

Rather than accepting only valid characters, it rejects all invalid
characters as specified in the RFC.

^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}$

I think it could be enhanced to reject all invalid characters as
specified in the RFC instead of accepting only the valid ASCII
characters. It would be just a matter of changing a variable in both the
classes above.

Other than using that expression in PHP, the forms class can do the same
  in Javascript to reduce server round trip to check the email format.

The email validation class can perform subsequent validation of DNS
records and simulate delivery to see if the remote SMTP server would
accept. It returns 3 kinds of results: Yes, no, maybe (not possible to
determine for sure). It is even capable to distinguish a real rejection
from a whitelist temporary rejection.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

attached mail follows:


On Fri, October 21, 2005 2:39 pm, Chris Knipe wrote:
> Function DoSomething($Blah) {
> $Blah = (int) $Blah;
> return $Blah
> }
>
> $Blah, cannot be larger than 2147483647, and sometimes, I get negative
> integers back from the above function.
>
> This is with PHP 4.4.0 on FreeBSD 5.4-STABLE. Can anyone else perhaps
> confirm this, and if it is indeed true, is this a bug, or a limitation
> somewhere on PHP? Any other ways to confirm that *large* numbers, are
> indeed integers? I'm working with numbers in the form of yyyymmddsss
> (20051025001 for today for example)

PHP integers are limited by 32-bit hardware and a simplicity of design
to -2147483648 to 2147483647.

There are no unsigned, long, double long, or google ungle longles.
[I made that last one up, but it sure sounds good, don't it?]

Your options are, however, several.

1. Use BCMATH or that fancy new-fangled big-number package to deal
with numbers as big as you want, subject only to the amount of RAM in
your box and the number of values you want to use at one time.
Performance will not be integer-fast as these packages use
string-manipulation to compute mathematical values, but they can get
VERY big numbers, with whatever precision you specify.

2. In this particular instance, it's a *DATE* so you should consider
converting it to a Unix time-stamp. This does limit you to 1/1/1970
midnight to somewhere in March 2038, however, as that is the same
32-bit limited range in number of seconds between 1/1/1970 midnight
and 2 * 2147483647 seconds later than that. Note that this is
strictly hardware-based, so if you get a 64-bit machine, your date
range goes until, like, 1970 + 2 * (2038 - 1970)

If your dates range beyond 1/1/1970 and/or 2038, you may want to
simply NOT convert them to integer in the first place.

Also note that database software can generally provide more options
for date storage, date arithmetic and date-handling in general.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Fri, October 21, 2005 10:51 am, Uros Dukanac wrote:
> I can make "workaround" by checking the value of $Filter (is it "A" or
> "B") to
> determine which button sent a request (see "Workaround code" after
> "Original
> code"), but it looks "dirty" to me, and I'm wondering why to do that

It's pretty standard to check which button was pressed by what values
are sent from the browser.

That's just how it's done.

> if ($AForm->validate() && Filter == "A")

I got no clue what all the QuickForm and validate() stuff is doing,
but you may not really care about validate() here unless $Filter ==
'B'...

So I'd maybe switch the order of the tests and put $Filter first.

Or maybe you always want validate() for A to run, even when they don't
click on A?

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Tue, October 18, 2005 2:21 pm, John Nichel wrote:
> I'm diving into the gd functions for the first time, and I'm having a
> problem creating a white background for an image when using
> imagecreatetruecolor(). The manual says that this function will
> create
> a _black_ image, but looking at imagecolorallocate() it says that the
> first call to this function fills the background color, and they have
> examples like this...
>
> $im = imagecreatetruecolor('example.jpg');
> // sets background to red
> $background = imagecolorallocate($im, 255, 0, 0);

> And that creates the image with the right sizes and positions, but the
> background is black. Is there something wrong in my code, or is the
> manual wrong on the imagecolorallocate() function? TIA.

I believe the automatic filling in of the background color may have
been only in GD 1.0 or something...

I'm not sure I ever saw it work.

On the plus side, it's easy to fill in the background:

imagefilledrectangle($image, 0, 0, $width - 1, $height - 1, $background);

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Tue, October 18, 2005 2:15 pm, Shaun wrote:
> Thanks for your replies, rather than check each vaule by name I am
> trying to
> produce a more dynamic solution:
>
> foreach ($_POST as $key => $value) {
> if ($value == '') {
> $_POST[$key] == 'NULL';

If you actually have == in this line, that is your trouble.

> }
> }
>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hello, all -

Anyone know if it's possible to use auto_prepend_file to force the
appending of a file to the request, regardless of what kind of document
is generated?

I can see this being a problem if the document was a picture or a video
or some such - but is thre a hidden argument list to auto_prepend_file
where I can force inclusion of this file, if x, y, and z document types
were requested?

Thanks!
-dant

attached mail follows:


On Sat, October 22, 2005 11:25 pm, Dan Trainor wrote:
> Anyone know if it's possible to use auto_prepend_file to force the
> appending of a file to the request, regardless of what kind of
> document
> is generated?
>
> I can see this being a problem if the document was a picture or a
> video
> or some such - but is thre a hidden argument list to auto_prepend_file
> where I can force inclusion of this file, if x, y, and z document
> types
> were requested?

Not the way you describe it, but...

In .htaccess, put:

<Files .xyz>
  ForceType application/x-httpd-php
</Files>

Now all your .xyz files ARE PHP files.

auto_prepend will happen.

PHP will "parse" the files but do nothing unless they happen to
contain the character combination <?php (or <? or <?= if you have
short_tags on)

This may or may not be suitable in your environment.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Richard Lynch wrote:
> On Sat, October 22, 2005 11:25 pm, Dan Trainor wrote:
>
>>Anyone know if it's possible to use auto_prepend_file to force the
>>appending of a file to the request, regardless of what kind of
>>document
>>is generated?
>>
>>I can see this being a problem if the document was a picture or a
>>video
>>or some such - but is thre a hidden argument list to auto_prepend_file
>>where I can force inclusion of this file, if x, y, and z document
>>types
>>were requested?
>
>
> Not the way you describe it, but...
>
> In .htaccess, put:
>
> <Files .xyz>
> ForceType application/x-httpd-php
> </Files>
>
>
> Now all your .xyz files ARE PHP files.
>
> auto_prepend will happen.
>
> PHP will "parse" the files but do nothing unless they happen to
> contain the character combination <?php (or <? or <?= if you have
> short_tags on)
>
> This may or may not be suitable in your environment.
>

This would be a great solution, and I'm sure my concern is something
that's been discussed many times on this list - I'm worried about the
performance hit that the machine would take, if/when parsing a large
number of files, in this manner.

For small sites, I have no problem adding .html, .htm and friends to
PHP's own AddType. But I'm not so sure for larger sites.

I'll browse the archive for info and data, and weigh my options.

Thanks
-dant

attached mail follows:


On Sat, October 22, 2005 11:42 pm, Dan Trainor wrote:
> This would be a great solution, and I'm sure my concern is something
> that's been discussed many times on this list - I'm worried about the
> performance hit that the machine would take, if/when parsing a large
> number of files, in this manner.
>
> For small sites, I have no problem adding .html, .htm and friends to
> PHP's own AddType. But I'm not so sure for larger sites.
>
> I'll browse the archive for info and data, and weigh my options.

Last benchmarks I saw clocked in at 5 to 10% loss to run all .htm and
.html files through PHP.

That was awhile ago, though.

Test on a dev server with apache benchmark (ab) before and after and see.

PHP doesn't really *DO* much until it hits '<?php' if you think about it.

It just reads the file, uses something like strtok() to search for
'<?php' and spits it back out.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hi All,

I have started reading a couple of books about PHP 5 and whilst most of
it is comprehensible even to me :-), I fail to understand WHY there is
such a thing as an abstract class or method?

I think I understand what it is: A class that can't itself be
instantiated, only inherited from, or a method that describes itself
only in terms of what properties it accepts but no implementation
detail.

But could someone explain why I would want to use this? I'm sure it is
very useful but I can't quite see the benefit...

Thanks in advance

Al

attached mail follows:


On Sun, 2005-10-23 at 08:54 +0100, Alan Lord wrote:
> Hi All,
>
> I have started reading a couple of books about PHP 5 and whilst most of
> it is comprehensible even to me :-), I fail to understand WHY there is
> such a thing as an abstract class or method?
>
> I think I understand what it is: A class that can't itself be
> instantiated, only inherited from, or a method that describes itself
> only in terms of what properties it accepts but no implementation
> detail.
>
> But could someone explain why I would want to use this? I'm sure it is
> very useful but I can't quite see the benefit...

Hi Alan

Here's an example from an application framework I've been working on.

It has classes to represent the different HTTP response statuses (like
301 Moved Permanently, 304 Not Modified etc.) with required and
forbidden headers for each and different characteristics (like no
request-body allowed etc).

I have an Abstract class called HTTP_Response, from which
HTTP_Response_Moved_Permanently, HTTP_Response_Not_Modified, and many
others all inherit.

The reason HTTP_Response is abstract is because there's no such thing as
an HTTP_Response on its own. It has to be a specific type of HTTP
Response, that is a 301 Moved Permanently or a 304 Not Modified.

Does that help?

--
Jasper Bryant-Greene
General Manager
Album Limited

e: jasperalbum.co.nz
w: http://www.album.co.nz/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand

attached mail follows:


Thanks Jasper,

That makes sense.

But what benefit is there is having it as an explicitly "abstract"
class? Why can't it just be a "normal" class definition which you
inherit from?

Sorry to be so dense....

Al

> -----Original Message-----
> From: Jasper Bryant-Greene [mailto:jasperalbum.co.nz]
> Sent: 23 October 2005 09:19
> To: Alan Lord
> Cc: php-generallists.php.net
> Subject: Re: [PHP] Abstract Classes?
>
> On Sun, 2005-10-23 at 08:54 +0100, Alan Lord wrote:
> > Hi All,
> >
> > I have started reading a couple of books about PHP 5 and
> whilst most
> > of it is comprehensible even to me :-), I fail to
> understand WHY there
> > is such a thing as an abstract class or method?
> >
> > I think I understand what it is: A class that can't itself be
> > instantiated, only inherited from, or a method that
> describes itself
> > only in terms of what properties it accepts but no implementation
> > detail.
> >
> > But could someone explain why I would want to use this? I'm
> sure it is
> > very useful but I can't quite see the benefit...
>
> Hi Alan
>
> Here's an example from an application framework I've been working on.
>
> It has classes to represent the different HTTP response statuses (like
> 301 Moved Permanently, 304 Not Modified etc.) with required
> and forbidden headers for each and different characteristics
> (like no request-body allowed etc).
>
> I have an Abstract class called HTTP_Response, from which
> HTTP_Response_Moved_Permanently, HTTP_Response_Not_Modified,
> and many others all inherit.
>
> The reason HTTP_Response is abstract is because there's no
> such thing as an HTTP_Response on its own. It has to be a
> specific type of HTTP Response, that is a 301 Moved
> Permanently or a 304 Not Modified.
>
> Does that help?
>
> --
> Jasper Bryant-Greene
> General Manager
> Album Limited
>
> e: jasperalbum.co.nz
> w: http://www.album.co.nz/
> p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
> a: PO Box 579, Christchurch 8015, New Zealand
>
>

attached mail follows:


Hi.

How can I use Ruby with Php?
My goal is to have (Independence of Presentation Logic(IoPL)).

Thanks,
Jacob

attached mail follows:


> How can I use Ruby with Php?

I mean Rails. sorry :)

> My goal is to have (Independence of Presentation Logic(IoPL)).

attached mail follows:


On 10/23/05, Jacob Friis Saxberg <webcom.dkgmail.com> wrote:
> > How can I use Ruby with Php?
>
> I mean Rails. sorry :)

http://www.rubyonrails.org/

I have a couple of Rails apps on my own server with other PHP apps
running there too. Apache will run mod_fcgi and mod_php at the same
time with no problems.

--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/