[PHP] isset or array_key_exists?

2006-02-18 Thread Nikolay Rastegaev
Please, answer:

what construction works faster:

   if (  isset ( $result [$i] [key] )  )
   {do something;   }

or

   if (  array_key_exists ( key, $result [$i] )  )
   {do something;   }

?

Nikolay


[PHP] Re: isset or array_key_exists?

2006-02-18 Thread Rafael
	After a little test, although the results are not conclusive, I would 
say that isset(), and also that array_key_exists() may even use isset() 
(or similiar) internally as a first step -let's remember that isset() 
only does a fast search and it returns FALSE if the value is NULL; on 
the other hand, array_key_exists() returns TRUE even if the value is 
NULL-  I said this (as an hypotesis) because the difference in time when 
the key exists and when it doesn't is quite big, sometimes about 10 
times slower.


	The script I used to test it was this (it is assumed that any extra 
operation affected both loops equally)

?php

$arr_test = array( 'key' = array( 1 = -1 ) );
$num_oprs = 1000;


$start= micro_time();
for ( $i = 0;  $i  $num_oprs;  $i ++ ) {
if ( isset($arr_test['key'][1]) ) ;
}
echo  'pisset: ', micro_time() - $start, /p\n;


$start = micro_time();
for ( $i = 0;  $i  $num_oprs;  $i ++ ) {
if ( array_key_exists(1, $arr_test['key']) ) ;
}
echo  'parray_key_exists: ', micro_time() - $start, /p\n;



function micro_time( ) {
return  preg_replace('/^0(\.\d+) (\d+)$/X',
 '$2$1', microtime());
}

 ?

Nikolay Rastegaev wrote:

Please, answer:

what construction works faster:

   if (  isset ( $result [$i] [key] )  )
   {do something;   }

or

   if (  array_key_exists ( key, $result [$i] )  )
   {do something;   }

?

--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
[EMAIL PROTECTED]
http://www.innox.com.mx

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



Re: [PHP] Clear POST variables

2006-02-18 Thread John Wells
[snip]
If it's not wrong for me to push the back button, why are you
breaking it with all your re-directs :-)
[/snip]

I was a bit short in my explanation -- I tend to use the redirect
method so that users *can* use the back button (or refresh).  I'm
trying to *not* break it. :)

That said, the unique token method is very interesting, I'll
definitely check it out.  But I'm curious, if you check for an
existing token and do find one (so the user has possibly refreshed the
browser), don't you have to program a particular way to handle it? And
might that handling method be different for each type of action being
taken? Does this run the risk of overcomplicating the code as well?

Then again, being forced to consider and handle *exceptions* is a very
good thing when developing a stable application...

I'll enjoy playing around with these ideas...

John




On 2/17/06, Curt Zirzow [EMAIL PROTECTED] wrote:
 On Thu, Feb 16, 2006 at 09:34:12PM -0600, Mike Tuller wrote:
  ...
 
  This is how I learned in some book somewhere. Is everyone saying that
  I need to either use sessions, or redirect so that when someone
  refreshes insert.php, it doesn't submit the information again? To me
  it seems that there has to be a more efficient way. I don't
  understand the token thing that some are suggesting.

 Since  web requests are stateless you need to protect yourself
 in some ways, this is a method to prevent those duplicate entries
 in the db when someone refreshes the browser and reposts the data.

 The only difference with richards code with what I have is that he stores it
 differently than I generally do. The concept is as follows:

 form.php:
 ?php

 // generate a token
 $my_token = md5(uniqid('thisformid', true));

 // store the token in a place that can be retrieved
 // on the next place, richard uses a db, i usually just use the
 // _SESSION where it is stored isn't relevent

 $_SESSION['tokens'][$my_token] = time(); // use time() so we can expire

 // put the token in the form to be passed to the next page
 ?
 form
   input type=hidden name=form_token value=?php echo $my_token?
 /form


 action.php:
 ?php

 // grab the token in the form:
 $token = $_POST['form_token'];

 // test it against what we stored in the previous page.
 if (isset($_SESSION['tokens'][$token]) ) {

   // forget the token
   unset($_SESSION['tokens'][$token]); // very important

   // do stuff..

 } else {
   // form submitted twice or they tried to access this page
   // directly.. a no no.
 }


 Curt.
 --
 cat .signature: No such file or directory

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



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



RE: [PHP] Problem with HUGE floating values and fmod

2006-02-18 Thread Marco Almeida
THANKS!

That did the trick.

For future reference to all people needing to calculate check digits with
ISO 7604 (MOD 97-10) method:

$check=98-bcmod(($num.00),97);

The .00 part is imporant... If $num was multiplied by 100 we wouldn't get
a correct value in bcmod. 


Marco Almeida
Project Manager

WEBDADOS
Tecnologias de Informação

Telef.:  +351 21 466 93 00  
Fax: +351 21 466 42 81  
Móvel:   +351 96 324 43 44  
Email:   [EMAIL PROTECTED]  
www: http://www.webdados.pt 
Morada:  R. 9 de Abril, 3-3A, Sala 4
2765-545 S. Pedro do Estoril

-Original Message-
From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
Sent: sexta-feira, 17 de Fevereiro de 2006 20:40
To: php-general@lists.php.net; [EMAIL PROTECTED]
Subject: Re: [PHP] Problem with HUGE floating values and fmod

On Fri, Feb 17, 2006 at 06:48:13PM -, Marco Almeida wrote:
 Hi there,
  
 I'm trying to calculate check digits for a payment system, using the 
 ISO
 7064 (MOD 97-10) algorithm, wich is, already translated to PHP:
 
 $check=98-fmod(($num*100),97);
 
 Where $num is a huge number...
 
 Example: 90150123123400043211 should have check digit 51 In windows 
 calculator: 98 - ( (90150123123400043211 * 100) mod 97) works OK and I 
 get 51 as result

 In PHP I get 13...

You will need to use GMP or BCMath to do math operations numbers that size.

See:
http://php.net/language.types.integer.php


Curt.
--
cat .signature: No such file or directory

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



Re: [PHP] DB Error ??? help please ...

2006-02-18 Thread Jochem Maas

Mehmet Fatih Akbulut wrote:

hi all,
today, i get this error frequently :


do people keep coming up to you
in the street and shouting 'DB Error' at
you or what?



A fatal error has occurred
DB Error: extension not found
[line 542 of /var/www/horde/kronolith/lib/Driver/sql.php]
...

but php5-mysql is installed. and also i installed pear db ...


has PEAR DB got anything to do with this? I doubt it given that
there seems to be a custom DB driver included in whatever
you are trying to run.

and what is php5-mysql exactly (probably a RPM?)


what may cause this problem ? and how can i fix this ?


install the mysql extension or make the code work with
the myslqi extension:

http://nl2.php.net/manual/en/ref.mysql.php
http://nl2.php.net/manual/en/ref.mysqli.php


help please ...
many thanks in advance ...



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



Re: [PHP] Saving a BLOB image to a file (SOLVED)

2006-02-18 Thread tedd

On 2/16/06, tedd [EMAIL PROTECTED] wrote:


 However, after given it some thought, I would imagine that one could
 get a unique generated string, create a file with that string, give
 the file the correct permissions, then pull the image from the dB and
 save, do image processing, and then reload the image into a web page,
 and delete the file without any conflict. I can envision lot's of
 users doing that simultaneously without problems. BUT, I haven't
 tried it yet!


I have used a user's IP address (dots removed) and microtime appended
to create a unique file name. The target directory is world writable.
Not the most elegant solution... I found that sometimes the file had
not been written yet and trying to display it on a page right away
resulted in file not found...

--
Gerry


Gerry:

Above, I said that I haven't tried it yet, but I just finished the 
code and it works well enough, I think. The technique is pretty 
simple -- just create a tmp directory with 777 permissions and then 
run this code.


?php

$token = md5(uniqid(1));
$token .= .txt;
$filename = tmp/$token;
$contents = This is the content of the file.;

echo(hrbr/Writing file br/br/);

$file = fopen( $filename, w );
fwrite( $file, $contents);
fclose( $file );

if( file_exists( $filename ) )
{  
$file_length = filesize( $filename );

echo(File created at $filenamebr/ );
echo( File size: $file_length bytesbr/);
echo( br/$contentsbr/ );
}
else
{
echo( br/Unable to create filebr/ );
}

echo(hrbr/Reading file:br/br/);

$filesize = filesize($filename);
$file = fopen( $filename, r );
$text = fread( $file, $filesize );
fclose( $file );

echo( File read at: $filenamebr/ );
echo( File Size: $filesize bytesbr/ );
echo( br/$textbr/ );

echo(hrbr/Deleting file br/);

$return = unlink($filename);
if($return)
{
echo(br/Successful delete of: $filenamebr/);
}
else
{
echo(br/Failed to delete of: $filenamebr/);
}

?
--

http://sperling.com/

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



Re: [PHP] Re: isset or array_key_exists?

2006-02-18 Thread Robert Cummings
On Sat, 2006-02-18 at 04:56, Rafael wrote:
   After a little test, although the results are not conclusive, I would 
 say that isset(), and also that array_key_exists() may even use isset() 
 (or similiar) internally as a first step -let's remember that isset() 
 only does a fast search and it returns FALSE if the value is NULL; on 
 the other hand, array_key_exists() returns TRUE even if the value is 
 NULL-  I said this (as an hypotesis) because the difference in time when 
 the key exists and when it doesn't is quite big, sometimes about 10 
 times slower.

isset is a keyword in PHP
array_key_exists() is a function.

Keywords are much faster than functions due tot he overhead functions
occur for setting up the stack.

If you don't care about null values, use isset(). If you do, use
array_key_exists().

The reason isset() doesn't return true for null entries has been
described in the past. The official stance was that null is not a value.

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.  |
`'

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



Re: [PHP] Re: isset or array_key_exists?

2006-02-18 Thread Satyam


- Original Message - 
From: Robert Cummings [EMAIL PROTECTED]

To: Rafael [EMAIL PROTECTED]
Cc: PHP-General php-general@lists.php.net
Sent: Saturday, February 18, 2006 3:21 PM
Subject: Re: [PHP] Re: isset or array_key_exists?



On Sat, 2006-02-18 at 04:56, Rafael wrote:

After a little test, although the results are not conclusive, I would
say that isset(), and also that array_key_exists() may even use isset()
(or similiar) internally as a first step -let's remember that isset()
only does a fast search and it returns FALSE if the value is NULL; on
the other hand, array_key_exists() returns TRUE even if the value is
NULL-  I said this (as an hypotesis) because the difference in time when
the key exists and when it doesn't is quite big, sometimes about 10
times slower.


isset is a keyword in PHP
array_key_exists() is a function.

Keywords are much faster than functions due tot he overhead functions
occur for setting up the stack.

If you don't care about null values, use isset(). If you do, use
array_key_exists().

The reason isset() doesn't return true for null entries has been
described in the past. The official stance was that null is not a value.

Cheers,
Rob.
--



Accessing a non-existing element, doesn't create it? Thus, using isset to 
evaluate whether an element exists creates it, though with a null value.  If 
you make a first pass on the array with isset, a second pass with 
array_key_exists would give true for all of them though isset would give the 
same results as in the first pass.  I think this happened to me once when I 
went through an array with isset or isempty or some such to make some 
calculations and then on the second pass, when I printed it, I got lots of 
empty cells that were created empty in the first pass.


Satyam

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



[PHP] Subtracting Large Numbers

2006-02-18 Thread Bruce
I am puzzled by the following code:

?php
print pMaxInt=.PHP_INT_MAX;
$AA = -190668411;
$BB = -2181087916;
print brAA=$AA;
print brBB=$BB;
$AA = (int)$AA + (int)$BB;
print brAA+BB=$AA;
?

On some systems, I get:

MaxInt=2147483647
AA=-190668411
BB=-2181087916
AA+BB=-2338152059

On others, I get:

MaxInt=2147483647
AA=-190668411
BB=-2181087916
AA+BB=1923210969

Why the difference?

Thanks...Bruce

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



[PHP] Different Values for intval(float)

2006-02-18 Thread Bruce
Consider the following code:

$BB = -2181087916;
$AA = (int)$BB;
$AA = intval($BB);

On some systems, $AA will be int(-2147483648), which is actually
consistent with the documentation.

On most systems, however, $AA will be int(2113879380), which is the
same value truncated at 32 bits.

I actually need the latter behavior, as it needs to duplicate Delphi
code, which, like C, behaves the same way.

This is encryption code that does a bunch of calculations on signed
32-bit numbers and ignores any overflows.

Any ideas how I can do this?

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



Re: [PHP] Different Values for intval(float)

2006-02-18 Thread Ashley M. Kirchner

Bruce wrote:

Consider the following code:

$BB = -2181087916;
$AA = (int)$BB;
$AA = intval($BB);

On some systems, $AA will be int(-2147483648), which is actually
consistent with the documentation.

On most systems, however, $AA will be int(2113879380), which is the
same value truncated at 32 bits.
   Interestingly enough, I tried it on several of my machines, which 
are different platforms and different (sub)versions of PHP and I got 
different results:


   RH7.3 with PHP 4.1.2: 2113879380

   IRIX 6.5.11 with PHP 4.2.3:   2147483647

   FC1 with PHP 4.3.6:   2113879380
   RH7.3 with PHP 4.3.9: 2113879380

   FC3 with PHP 4.3.10: -2147483648
   FC4 with PHP 4.4.0:  -2147483648
   FC4 with PHP 5.0.5:  -2147483648

   So my question now, is it version or platform related?

--
H | I haven't lost my mind; it's backed up on tape somewhere.
 +
 Ashley M. Kirchner mailto:[EMAIL PROTECTED]   .   303.442.6410 x130
 IT Director / SysAdmin / WebSmith . 800.441.3873 x130
 Photo Craft Imaging   . 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A. 


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



Re: [PHP] attaching MySQL 5.0.18 to PHP 4.4.2

2006-02-18 Thread Kim Christensen
On 2/17/06, Paul Goepfert [EMAIL PROTECTED] wrote:
 I forgot to mention that that php and mysql are installed on a windows
  machine which means I didn't have to run the configure script that
 would associate mysql with php.  How do I do this on a windows
 machine?

Open up php.ini, check that you have extension_dir set to the
directory where all your PHP extensions reside (typically C:\php\ext
on PHP5, and C:\php\extensions on PHP4). If the path is OK, then
scroll to section where all the extensions are to be loaded and
uncomment the line with php_mysql.dll in it. Restart your web server
and you should be set to go - check phpinfo() afterwards to see if it
loads ok.

--
Kim Christensen
[EMAIL PROTECTED]

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



Re: [PHP] Clear POST variables

2006-02-18 Thread Kim Christensen
On 2/18/06, John Wells [EMAIL PROTECTED] wrote:
 That said, the unique token method is very interesting, I'll
 definitely check it out.  But I'm curious, if you check for an
 existing token and do find one (so the user has possibly refreshed the
 browser), don't you have to program a particular way to handle it? And
 might that handling method be different for each type of action being
 taken? Does this run the risk of overcomplicating the code as well?

In my particular case I normally just unset the $_REQUEST array, which
in turn makes my form handling code not run (i always check for
existing form values before processing them, but who doesn't...) and,
depending on where on the site everything takes place, redirect them
to a proper place.

--
Kim Christensen
[EMAIL PROTECTED]

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



[PHP] Retrieve URL Typed

2006-02-18 Thread Ministério Público
I need a way to retrieve a URL typed by anyone who is visiting my site so
that I can redirect someone who typed for exemple www.site.com, to one of
the folders I have in the directory, and if that user typed
www.othersite.com he would be sent to another folder. I thank any insight.
Rodrigo


Re: [PHP] Re: isset or array_key_exists?

2006-02-18 Thread Rafael
	Actually, it doesn't have much sense that it creates a variable (or 
index), though it had sense why wouldn't be so easily detected, so I 
printed the array after the loops and there's no new keys.  I think that 
if that was the case, it was definitely a bug that has been corrected 
(PHP 4.4.0)

*Note: I guess that's because isset() is not a function, but a keyword

	That was very ilustrative Rob, thanks for the info (it's the kind of 
thing I shouldn't forget)


Satyam wrote:
[···]

isset is a keyword in PHP
array_key_exists() is a function.

Keywords are much faster than functions due tot he overhead functions
occur for setting up the stack.

If you don't care about null values, use isset(). If you do, use
array_key_exists().

The reason isset() doesn't return true for null entries has been
described in the past. The official stance was that null is not a value.


[···]


Accessing a non-existing element, doesn't create it? Thus, using isset 
to evaluate whether an element exists creates it, though with a null 
value.  If you make a first pass on the array with isset, a second pass 
with array_key_exists would give true for all of them though isset would 
give the same results as in the first pass.  I think this happened to me 
once when I went through an array with isset or isempty or some such to 
make some calculations and then on the second pass, when I printed it, I 
got lots of empty cells that were created empty in the first pass.

--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
[EMAIL PROTECTED]
http://www.innox.com.mx

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



[PHP] Retrieve the Http Host from the Http Header

2006-02-18 Thread Ministério Público
I need a way to retrieve the URL typed by anyone visiting the website, so
that I can rerout them to the apropriate folder, does anyone know how to do
this?
 I got a message saying that I should use the phpinfo and use the variables
that are given as response, but the problem is that the variable that is
usefull is the HTTP HEADER HOST and I dont know how to retrieve it. I thank
anyone who can help.
Rodrigo


Re: [PHP] Retrieve URL Typed

2006-02-18 Thread Kim Briggs
On 2/18/06, Ministério Público [EMAIL PROTECTED] wrote:

 I need a way to retrieve a URL typed by anyone who is visiting my site so
 that I can redirect someone who typed for exemple www.site.com, to one of
 the folders I have in the directory, and if that user typed
 www.othersite.com he would be sent to another folder. I thank any insight.
 Rodrigo


Hi Rodrigo,

Not really a PHP questions, but you can most likely make a local .htaccess
file to take care of this, even in a shared hosting environment.  I don't
know the details, but here is an example I copied to make all www.domain.comand
domain.com requests get grouped together for page ranking, etc.

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.kimbriggs\.com
RewriteRule ^(.*)$ http://kimbriggs.com/$1 [R=permanent,L]

cheers,
--
http://kimbriggs.com


[PHP] Recursive permissions

2006-02-18 Thread tedd

Hi gang:

Question: I know you can set a directory to have certain permissions, 
but how do you set the permissions to be recursive? In other words, 
for example, if you set the directory to be 755, then everything 
placed within that directory will also be 755.


Thanks.

tedd

--

http://sperling.com/

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



Re: [PHP] ! in front of a variable?

2006-02-18 Thread Gerry Danen
! reverses a true/false input. I use it to flip a setting on or off.

Gerry

On 2/17/06, Jeff [EMAIL PROTECTED] wrote:
 Hey all,

 I've got some code from someone else I've inherited and need to sort out
 some problems with.  The programmer that wrote it originally was much
 better than I and programmed a little over my head to say the least.

 One function that I've come across that has 5 variables as input:

 function($var1,$var2,!$var2,$var3-cc,$var3-bcc);

 The question I have is on the 3rd input variable, what does the ! in
 front of $var2 do to that variable?

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



Re: [PHP] Recursive permissions

2006-02-18 Thread Kim Christensen
On 2/18/06, tedd [EMAIL PROTECTED] wrote:
 Hi gang:

 Question: I know you can set a directory to have certain permissions,
 but how do you set the permissions to be recursive? In other words,
 for example, if you set the directory to be 755, then everything
 placed within that directory will also be 755.

http://php.net/manual/en/function.umask.php

--
Kim Christensen
[EMAIL PROTECTED]

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




[PHP] Distribution of records

2006-02-18 Thread Alan Milnes

Hi Guys,

I'm looking for some help in buiding up the right queries / code for 
this.  I have a database that tracks all the plays of my Football Team.  
Here are the relevant Fields:-


Formation
OCall
DCall
OYards
Key

The key is an amalgam of the first 3 fields so a typical record might 
look like this:-


Formation - I
OCall - RT
DCall - BZ
OYards - 5
Key - IRTBZ

What I want to do is to produce report that looks like this:-

Form
OCall
DCall
OYards - Median
OYards - Mean
OYards  0
OYards 0 - 4
OYards 5+

So in other words for every combination of Formation, OCall and DCall I 
want to report how many times it occured, what the Median and Mean 
values were and what the distribution of plays was.


I reckon I'm going to have to create an array and then loop over the 
array pulling out the relevant information but are there any special 
techniques I should consider?


Thanks

Alan

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



[PHP] regular pattern to match �

2006-02-18 Thread Patrick
im trying to get my regular pattern to allow åäöÅÄÖ but it refuses to,
i have something like this:

[^a-zA-ZåäöÅÄÖ0-9-_ ]

But this dosent seem to work, anyone got any ideas?

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



[PHP] regular pattern to match swedish characters

2006-02-18 Thread Patrick
im trying to get my regular pattern to allow åäöÅÄÖ but it refuses to,
i have something like this:

[^a-zA-ZåäöÅÄÖ0-9-_ ]

But this dosent seem to work, anyone got any ideas?

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



[PHP] Re: regular pattern to match åäö

2006-02-18 Thread Manuel Lemos
Hello,

on 02/18/2006 07:42 PM Patrick said the following:
 im trying to get my regular pattern to allow åäöÅÄÖ but it refuses to,
 i have something like this:
 
 [^a-zA-ZåäöÅÄÖ0-9-_ ]
 
 But this dosent seem to work, anyone got any ideas?

It seems your message is in Windows-1252 encoding. Make sure you are not
using an encoding in your PHP source code editor that is different from
the encoding of your input data.


-- 

Regards,
Manuel Lemos

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

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

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



Fw: [PHP] regular pattern to match XXX

2006-02-18 Thread Satyam
- Original Message - 
From: Patrick [EMAIL PROTECTED]




im trying to get my regular pattern to allow åäöÅÄÖ but it refuses to,
i have something like this:

[^a-zA-ZåäöÅÄÖ0-9-_ ]

But this dosent seem to work, anyone got any ideas?



Just an idea, try putting a backslash before the non-ASCII characters, 
perhaps that will force the function to take them literally instead of 
making who knows what assumption about them.  And let me know if it works 
because we use diacritical marks in Spanish, who know when I might need it.


Satyam

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



[PHP] Re: Retrieve the Http Host from the Http Header

2006-02-18 Thread Cristian MARIN

To know what exactly URL was asked use this:

'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'?'.$_SERVER['QUERY_STRING']

However when a rewritten URL was used with mod_rewrite Apache module my 
code above will simply show you the transformed URL. The real requested 
URL in this situation is located into a different location:


$_SERVER['REDIRECT_URL']

Regards,
Cristian MARIN
-
Developer Designer Division
[EMAIL PROTECTED]
http://www.interaktonline.com/

Ministério Público wrote:

I need a way to retrieve the URL typed by anyone visiting the website, so
that I can rerout them to the apropriate folder, does anyone know how to do
this?
 I got a message saying that I should use the phpinfo and use the variables
that are given as response, but the problem is that the variable that is
usefull is the HTTP HEADER HOST and I dont know how to retrieve it. I thank
anyone who can help.
Rodrigo

  


Re: [PHP] Re: isset or array_key_exists?

2006-02-18 Thread Robert Cummings

On Sat, 2006-02-18 at 12:39, Rafael wrote:
   Actually, it doesn't have much sense that it creates a variable (or 
 index), though it had sense why wouldn't be so easily detected, so I 
 printed the array after the loops and there's no new keys.  I think that 
 if that was the case, it was definitely a bug that has been corrected 
 (PHP 4.4.0)
 *Note: I guess that's because isset() is not a function, but a keyword
 
   That was very ilustrative Rob, thanks for the info (it's the kind of 
 thing I shouldn't forget)
 
 Satyam wrote:
 [···]
  isset is a keyword in PHP
  array_key_exists() is a function.
 
  Keywords are much faster than functions due tot he overhead functions
  occur for setting up the stack.
 
  If you don't care about null values, use isset(). If you do, use
  array_key_exists().
 
  The reason isset() doesn't return true for null entries has been
  described in the past. The official stance was that null is not a value.
 
 [···]
  
  Accessing a non-existing element, doesn't create it? Thus, using isset 
  to evaluate whether an element exists creates it, though with a null 
  value.  If you make a first pass on the array with isset, a second pass 
  with array_key_exists would give true for all of them though isset would 
  give the same results as in the first pass.  I think this happened to me 
  once when I went through an array with isset or isempty or some such to 
  make some calculations and then on the second pass, when I printed it, I 
  got lots of empty cells that were created empty in the first pass.

For the curious:

?php

function myempty( $value )
{
if( empty( $value ) )
{
return true;
}

return false;
}

$foo = array( 1 = 1 );

if( isset( $foo[2] ) )
{
echo 'WTF! :)';
}

print_r( $foo );

if( !empty( $foo[2] ) )
{
echo 'WTF! :)';
}

print_r( $foo );

if( !myempty( $foo[2] ) )
{
echo 'WTF! :)';
}

print_r( $foo );

?

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.  |
`'

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



Re: [PHP] Recursive permissions

2006-02-18 Thread tedd

On 2/18/06, tedd [EMAIL PROTECTED] wrote:

 Hi gang:

 Question: I know you can set a directory to have certain permissions,
 but how do you set the permissions to be recursive? In other words,
 for example, if you set the directory to be 755, then everything
 placed within that directory will also be 755.


http://php.net/manual/en/function.umask.php

--
Kim Christensen



Kim:

Thanks, but are you sure about that?

That looks like a function that simply takes the old permission 
settings and stores them until you're finished setting new 
permissions to a file/directory and then you can safely restore the 
old permissions to what they were.


What I'm looking for is how to set the permissions for a directory 
such that all files in it will have the same permissions.


I use GoLive and in their file FTP access settings they have a 
recursive checkbox. If the checkbox is not checked, then whatever 
permission setting I give to a directory is just to the directory. 
However, if it the recursive checkbox is checked, then all files 
placed in the directory will have the directory's permissions. 
Perhaps this is something limited to GoLive and not an option in 
setting chmod's via php's built-in functions.


I am aware of how to change the contents of a directory to a specific 
chmod using a recursive php routine, but I was looking for a simpler 
way.


tedd

--

http://sperling.com/

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



[PHP] Re: regular pattern to match åäö

2006-02-18 Thread Rafael

Just a couple of questions/points to make all clear:
a) are you aware that the ^ at the beggining inverts its meaning?
b) if you want to allow (or not fail with) -, put it as the fist
   (or last?) character of the class, since it is used to define
   ranges, and this avoids misinterpreting its meaning
c) what regex family functions are you using and what would be the
   complete expression?

Patrick wrote:

im trying to get my regular pattern to allow åäöÅÄÖ but it refuses to,
i have something like this:

[^a-zA-ZåäöÅÄÖ0-9-_ ]

But this dosent seem to work, anyone got any ideas?

--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
[EMAIL PROTECTED]
http://www.innox.com.mx

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



[PHP] ignore this test

2006-02-18 Thread 2dogs
just testing my news connection 

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



[PHP] Handling of lengthy server operation in php

2006-02-18 Thread Adrian
Hi everybody,

I have been trying to find a solution to this issue on other newsgroups but
haven't had any luck so far.

My config: Apache 2.0.54, PHP 5.1.2 on Win XP (or 2003).

Here is the outline of my application:

The user submits a form to the server, which is then processed by a php
script. This script calls exec to start a Win32 console which passes some
information to a Windows process, and then returns, thus allowing the php
script to continue. In the meantime, the service keeps working. When it's
done, it creates a file to signal that new data is available. The php script
sees this file, picks up the data and sends it to the user.

Everytbing works if all this happens synchronously, meaning the php script
waits for the windows service to finish before doing anything else. But this
means that the user doesn't see any feedback as to the status of the
operation (and it can be quite lenghty), and it can't cancel it either. So
in order to increase useability, I need the server needs to be able to
perform some concurrent tasks:
1. monitor the status of the Windows service processing
2. provide user feedback about its status
3. listen for user commands, such as cancel, or back, in order to cancel the
current processing

I tried various ideas, using header( ... ) to start other scripts etc, but
so far nothing worked - things always happen synchronously (start
processing, wait for it to finish, show result) which is not what a user
would expect. Also, I would prefer to do everything on the server instead of
using js for example in the browser.

Any help would be really appreciated.

Thanks,

Adrian

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



[PHP] Re: Handling of lengthy server operation in php

2006-02-18 Thread Manuel Lemos
Hello,

on 02/19/2006 02:00 AM Adrian said the following:
 I tried various ideas, using header( ... ) to start other scripts etc, but
 so far nothing worked - things always happen synchronously (start
 processing, wait for it to finish, show result) which is not what a user
 would expect. Also, I would prefer to do everything on the server instead of
 using js for example in the browser.

What you can do is something usually known as job queuing. It consists
of having a queue, which can be a file on the disk or a database table.
To queue a job, you just add a new record to that job table. Then have a
background process handle it ASAP, and update its status as it
progresses. When the job is marked as done, the requester can delete its
record, while the background task proceeds to the next enqueued job.

Here you may read more about this concept of queueing:

http://www.meta-language.net/metabase-faq.html#performance

-- 

Regards,
Manuel Lemos

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

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

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



[PHP] PHP/LDAP Authentication

2006-02-18 Thread Golden Butler


I'm currently running OpenLDAP with some users populated in the 
database.  I would like to use PHP to create a web page where my ldap 
users can enter their username and password credentials to log into our 
intranet.  Can someone point me to some expample scripts, articles, or 
sites.  Thanks.

- Delamatrix