Re: [PHP] PHP version check

2005-10-27 Thread Richard Davey
Hi Andrew,

Friday, October 28, 2005, 7:41:21 AM, you wrote:

> How can I query for PHP version?

phpversion() !

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] PHP5 class constants

2005-10-27 Thread Chris

Dragan Stanojevic - Nevidljivi wrote:


Jasper Bryant-Greene wrote:


On Fri, 2005-10-28 at 01:02 +0200, Dragan Stanojevic - Nevidljivi wrote:
[snip]
 


and it works fine, I cannot define a constant by expression, like:

class Foo {
   const AAA = 1 << 0;
   const BBB = 1 << 1;
   const CCC = 1 << 2;
   const DDD = 1 << 3;
}

Well now, is this a bug, and I should file it, or is it, and why, 
normal?
  



Not a bug. Read manual.


From http://php.net/oop5.constants comes the following:


 


Oh, thanks Jasper...

Pitty though, code would be a lot cleaner if the constant setting 
would allow it (put evaluated value in constant).


bye,
N::

That constant is the same throughout all instances of the object, So you 
can't calculate the value based on instantiated info.


Though I suppose you could make an argument for using expressions that 
consist of only constant values.


Chris

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



Re: [PHP] PHP5 class constants

2005-10-27 Thread Dragan Stanojevic - Nevidljivi

Jasper Bryant-Greene wrote:


On Fri, 2005-10-28 at 01:02 +0200, Dragan Stanojevic - Nevidljivi wrote:
[snip]
 


and it works fine, I cannot define a constant by expression, like:

class Foo {
   const AAA = 1 << 0;
   const BBB = 1 << 1;
   const CCC = 1 << 2;
   const DDD = 1 << 3;
}

Well now, is this a bug, and I should file it, or is it, and why, normal?
   



Not a bug. Read manual.


From http://php.net/oop5.constants comes the following:
 


Oh, thanks Jasper...

Pitty though, code would be a lot cleaner if the constant setting would 
allow it (put evaluated value in constant).


bye,
N::

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



Re: [PHP] PHP5 class constants

2005-10-27 Thread Jasper Bryant-Greene
On Fri, 2005-10-28 at 01:02 +0200, Dragan Stanojevic - Nevidljivi wrote:
[snip]
> and it works fine, I cannot define a constant by expression, like:
> 
> class Foo {
> const AAA = 1 << 0;
> const BBB = 1 << 1;
> const CCC = 1 << 2;
> const DDD =1 << 3;
> }
> 
> Well now, is this a bug, and I should file it, or is it, and why, normal?

Not a bug. Read manual.

>From http://php.net/oop5.constants comes the following:

"The value must be a constant expression, not (for example) a variable,
a class member, result of a mathematical operation or a function call."

-- 
Jasper Bryant-Greene
General Manager
Album Limited

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

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



Re: [PHP] regex and global vars problem

2005-10-27 Thread Tom Rogers
Hi,

Thursday, October 27, 2005, 3:15:30 AM, you wrote:
JG> I am having a problem with a couple of function I have written to check
JG> for a type of string, attempt to fix it and pass it back to the main
JG> function.  Any help is appreciated.

I would do it with a small class like this:

is_valid = 
preg_match('/^(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})$/',$mac,$parts)){
  array_shift($parts); //lose the first bit
  $this->mac = implode(':',$parts);
}
  }
}

//test
$mac_list = 
array("00-aa-11-bb-22-cc","00:aa:11:bb:22:cc","zz:00:11:22:ff:xx","00 aa 11 bb 
22 cc");

foreach($mac_list as $mac){
  $mactest = new mac($mac);
  echo "In:$mac";
  if($mactest->is_valid){
echo " valid $mactest->mac\n";
  }else{
echo " NOT valid\n";
  }
}

-- 
regards,
Tom

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



Re: [PHP] Using PHP for accsess control, preventing access to staticfiles

2005-10-27 Thread Jeffrey Sambells
I ran into a similar problem and came up with a slightly different  
solution...


As an alternative to passing the file directly through PHP, if you  
are running apache, you could DENY access to all files in a directory  
and then use PHP to dynamically update a local .htaccess file with  
valid sessions and use something like mod_security or a simple cookie/ 
query_string check to see if the requested file has a valid session.  
Then apache would handle the download as normal so users could use  
whatever download mechanism they want.


- jeff

~~
Jeffrey Sambells
Director of Research and Development
Zend Certified Engineer (ZCE)

We-Create Inc.
[EMAIL PROTECTED] email
519.745.7374 office
519.897.2552 mobile

~~
Get Mozilla Firefox at
http://spreadfirefox.com

On 27-Oct-05, at 5:45 PM, Dan Trainor wrote:


Ben wrote:


Dan Trainor said the following on 10/27/2005 01:34 PM:



Ben wrote:


Move the files outside the document root so that they aren't  
available

via a direct URL, then create a 'file access page' in php that will
check for the session variable and either send or not send the file
based on whether the user has access.

- Ben





Ben -

I knew this, but it was the "send or not send" thing that I was
concerned about ;)




Sounds like you need to have a look here:
http://ca3.php.net/manual/en/ref.filesystem.php

and specifically here:
http://ca3.php.net/manual/en/function.fpassthru.php

and so you can set the proper headers:
http://ca3.php.net/manual/en/function.filetype.php

The on-line manual is your friend :-).

Also, you will want to be _very_ careful about ensuring that the file
you are sending is in fact the file you want to be sending (ie
/etc/passwd would be a no-no).

- Ben




Ben -

Yes, I've been playing with passthru() today, and it's quite
interesting.  I think it's going to work.  I made a little pass- 
through

(pardon the pun) scriupt to do exactly what I'm looking for.

I've already started working on a set of sanity checks and such for  
the

requested files to prevent such malicious activity.

I want to thank you all again for your help.

Thanks!
-dant

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






Re: [PHP] foreach / unset

2005-10-27 Thread Niels Ganser
Why should this be "unsafe" (whatever the heck that means) in any way? Of 
course you can do it.

Regards,
Niels.

[sorry for mailing to your private address. wrong button :)]

> Anyway, can you do *this* safely as a DOCUMENTED FEATURE:
>
> foreach($array as $k => $v){
>   if (...) unset($array[$k]);
> }

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



[PHP] PHP5 class constants

2005-10-27 Thread Dragan Stanojevic - Nevidljivi

Hi guys,

I think I've found a bug. I have a bunch of constants, and I'd like to 
present them as flags. While I can do


class Foo {
   const AAA = 1;
   const BBB = 2;
   const CCC = 4;
   const DDD = 8;
}

and it works fine, I cannot define a constant by expression, like:

class Foo {
   const AAA = 1 << 0;
   const BBB = 1 << 1;
   const CCC = 1 << 2;
   const DDD =1 << 3;
}

Well now, is this a bug, and I should file it, or is it, and why, normal?

bye,
N::

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



[PHP] Decompressing a string with zlib problems

2005-10-27 Thread Graham Anderson

I am having problems decompressing a zlib'd string located in a file.

In the file headers, the compression says that it is  zlib.
But, when I  'gzinflate' the string, I get the error: gzinflate():  
data error in 
Is the below NOT a zlib or some strange variant ?

anyone know ?
g

$hex="C0636D766403DE789C95533B4E0331109D2408C44FA200125084568212D153 
2040A2A02012120D05142636BB26B677659B20B8000D05D7E00674882B7EC1018019 
67974D365060E569C76F3CEF4D66BD008D779DA67D0050BA9F707CC2CBFDE43301A07E1A 
5003FA956B6433BEDFFB89A87E6CD5011AF3DEB21EC667BE173C1BA567A156D67E7DFEC3 
772207C086E0DEE1B32D94F36545AE1B6AEB4673C9308834FFE3BF031C227613AE2CE575 
A2ACCBAC6759A6824AADF6BA769259E945B46FA4665EA626EA08948D0E99E14A60597D4A 
4B734936B10E36AD188941CF5F61E5ED6D17361C6D98928E6C1606366FAD7DDCA08B92CC 
4507CC0F19C0061F18B4B9159743D39923913C7E74FE827ADE74DEF1A133EDBF270A2DE7 
C30C8B5C31BF366A7447F91F2C62EE6E909A7928B96E5A79071FDD948B8ADFBB13CCE435 
D339B78A10BFF406B04C2F642443510BD1AB9CA77809910CF3057955155FEAE1D5A99264 
A6C6DAA07A5915A50EE2CA51BA93CD6BEEE9B6CD1AA605B73A4F9DE7F4FA93BBB1D004E8 
302EA21BE993E848F6C58967B1888E2DCD6F2553D7B14EFB5290C40E6A6CE9F0F1CE75FD 
6D665243839ACE14BB0DCADFAFDD8C76003C";


// Convert the hex to a string
$string = pack("H*", $hex);

//echo it
echo "the compressed string is:". "\r\n";
echo $string;


//decompress the string
$uncompressed =gzinflate($string);
echo "the uncompressed string is: ".$uncompressed;

?>

The Output SHOULD look something like this:
 ftypqt   qt  fimoovlmvhdøá8øá 
[EMAIL PROTECTED] 

trak\tkhdøá8øá 
[EMAIL PROTECTED] 
$edtselstXnmdia mdhdøá 
8øá8XXH?hdlrmhlrsprtappl¡Sprite  
Animation Media Handlerminf  
[EMAIL PROTECTED] 
le Alias Data Handler$dinfdref 
alisêstbl,stsd



The compressed output is:

the compressed string is:
??t?+p??g?M6P`?i?ow"?-??eE??Fs?0?4??"v?,?u??ˬgY??J???v?Y?E?o?f^?&J`Y}JKsI6?6??A? 
_a??m6m???l6o?}ܠ???E?Cә#?<~t??z?t??3?'

-??
   ?\1?6jtG?,b?n??y(?nZy 9?L/d$CQ
ѫ??x?
߯݌v

[PHP] foreach / unset

2005-10-27 Thread Richard Lynch
Somewhere in the manual (damned if I can find it now) it says (or used
to say) that you can or can't safely do this:

while (list($k, $v) = each($array)){
  if (...) unset($array[$k]);
}

I don't even remember if it's safe or not, but I swear I saw it not
that long ago...

Anyway, can you do *this* safely as a DOCUMENTED FEATURE:

foreach($array as $k => $v){
  if (...) unset($array[$k]);
}

I'm sure I could test it and maybe find out if "it works" but is it
documented behaviour I can rely on?  I'm sure not finding this in the
manual now that I go looking for it, though I know I saw it there
before.

PS
I'm being dragged kicking and screaming into using this new-fangled
'foreach' thing instead of while/list/each, and I don't really care
for it so far. :-)

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

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



Re: [PHP] Using PHP for accsess control, preventing access to staticfiles

2005-10-27 Thread Dan Trainor
Ben wrote:
> Dan Trainor said the following on 10/27/2005 01:34 PM:
> 
>> Ben wrote:
>>
>>> Move the files outside the document root so that they aren't available
>>> via a direct URL, then create a 'file access page' in php that will
>>> check for the session variable and either send or not send the file
>>> based on whether the user has access.
>>>
>>> - Ben
>>>
>>
>>
>> Ben -
>>
>> I knew this, but it was the "send or not send" thing that I was
>> concerned about ;)
> 
> 
> Sounds like you need to have a look here:
> http://ca3.php.net/manual/en/ref.filesystem.php
> 
> and specifically here:
> http://ca3.php.net/manual/en/function.fpassthru.php
> 
> and so you can set the proper headers:
> http://ca3.php.net/manual/en/function.filetype.php
> 
> The on-line manual is your friend :-).
> 
> Also, you will want to be _very_ careful about ensuring that the file
> you are sending is in fact the file you want to be sending (ie
> /etc/passwd would be a no-no).
> 
> - Ben
> 

Ben -

Yes, I've been playing with passthru() today, and it's quite
interesting.  I think it's going to work.  I made a little pass-through
(pardon the pun) scriupt to do exactly what I'm looking for.

I've already started working on a set of sanity checks and such for the
requested files to prevent such malicious activity.

I want to thank you all again for your help.

Thanks!
-dant

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



[PHP] Re: Trouble using DOM component with PHP 4.4.0

2005-10-27 Thread James Benson
The best solution is not to change your host at all but to change your 
local version of PHP to 4,




PHP4 DOM - http://php.net/manual/en/ref.domxml.php
PHP5 DOM - http://php.net/manual/en/ref.dom.php


The PHP5 and PHP4 extensions are not compatible with each other.



~James




Andrew Kachalo wrote:


Hi all!

I'm experiencing problems with using DOM component in PHP 4.4.0.

It works just fine on my localhost with PHP 5.0, but on host server PHP 
4.4.0 used, and can't be updated to 5.0 for several reasons. Is there 
any guided instruction how to make code using DOM (DOMDocument class, 
etc.) component work?


Please guide me what can I do to make my code work without changing it?

Thank You!

==
Best Regards
Andrew Kachalo
http://www.geocities.com/andrew_kachalo/


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



Re: [PHP] Trouble using DOM component with PHP 4.4.0

2005-10-27 Thread Andrew Kachalo
And what DOM library, which is compatible with PHP 5.0 and PHP 4.4 can 
I use to avoid the conflict I currently have?


On жовт 27, 2005, at 23:32, Alessandro Rossini wrote:

Please guide me what can I do to make my code work without changing 
it?


DOM implementation in PHP5 is completely new, and you can't have the 
same in
PHP4. I think that the most reasonable solution will be change the 
hosting to

another with PHP5 support...

Best regards.
--
Alessandro 'Aronnax' Rossini

web -> www.aronnax.it
e-mail -> [EMAIL PROTECTED]
icq -> 2442698
ZeroNotice IT Solutions -> www.zeronotice.com


==
Best Regards
Andrew Kachalo
http://www.geocities.com/andrew_kachalo/


Re: [PHP] Using PHP for accsess control, preventing access to staticfiles

2005-10-27 Thread Ben

Dan Trainor said the following on 10/27/2005 01:34 PM:

Ben wrote:

Move the files outside the document root so that they aren't available
via a direct URL, then create a 'file access page' in php that will
check for the session variable and either send or not send the file
based on whether the user has access.

- Ben




Ben -

I knew this, but it was the "send or not send" thing that I was
concerned about ;)


Sounds like you need to have a look here:
http://ca3.php.net/manual/en/ref.filesystem.php

and specifically here:
http://ca3.php.net/manual/en/function.fpassthru.php

and so you can set the proper headers:
http://ca3.php.net/manual/en/function.filetype.php

The on-line manual is your friend :-).

Also, you will want to be _very_ careful about ensuring that the file 
you are sending is in fact the file you want to be sending (ie 
/etc/passwd would be a no-no).


- Ben

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



Re: [PHP] Using PHP for accsess control, preventing access to staticfiles

2005-10-27 Thread Dan Trainor
Ben wrote:
> Dan Trainor said the following on 10/27/2005 10:39 AM:
> 
>> Jason Motes wrote:
> 
> 
 However, how do people protect against the downloading of real files,
 ones which are not parsed by PHP?  .WMV, .MOV, .ZIP, .EXE and so on?  I
 want to protect access to these as well, and if a visitor just types in
 a URL and is able to access the file because my access control
 mechanism
 simply doesn't work on those types of files, what should be the
 solution
 here?
> 
> 
> 
> 
>> I'd like to keep the application as portable as possible; thus, I cannot
>> use any kind of htaccess hackery because I want this PHP application to
>> run on IIS, as well.
> 
> 
> Move the files outside the document root so that they aren't available
> via a direct URL, then create a 'file access page' in php that will
> check for the session variable and either send or not send the file
> based on whether the user has access.
> 
> - Ben
> 

Ben -

I knew this, but it was the "send or not send" thing that I was
concerned about ;)

Thanks
-dant

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



Re: [PHP] Trouble using DOM component with PHP 4.4.0

2005-10-27 Thread Alessandro Rossini
> Please guide me what can I do to make my code work without changing it?

DOM implementation in PHP5 is completely new, and you can't have the same in 
PHP4. I think that the most reasonable solution will be change the hosting to 
another with PHP5 support...

Best regards.
-- 
Alessandro 'Aronnax' Rossini

web -> www.aronnax.it
e-mail -> [EMAIL PROTECTED]
icq -> 2442698
ZeroNotice IT Solutions -> www.zeronotice.com


pgpsBawVULEi4.pgp
Description: PGP signature


[PHP] Re: regex and global vars problem

2005-10-27 Thread Al

Jason Gerfen wrote:
I am having a problem with a couple of function I have written to check 
for a type of string, attempt to fix it and pass it back to the main 
function.  Any help is appreciated.


if( ( eregi( 
"^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$", 
$mac ) ) || ( !eregi( "^[0-9a-fA-F]$", $mac ) ) {

 return 0;
} else {
 return 1;
}
}

/*
* check validity of MAC & do replacements if necessary
*/
function fix_mac( $mac ) {
global $mac;

if( eregi( "^[0-9A-Fa-f-\:]$", $mac ) ) {
$mac1 = $mac;
echo "MAC: $mac1";
   }

   /* strip the dash & replace with a colon */
if( eregi( 
"^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$", 
$mac ) ) {

 $mac1 = preg_replace( "/\-/", ":", $mac );
 echo "MAC: $mac1";
   }
  /* add a colon for every two characters */
if( eregi( "^[0-9A-Fa-f]{12}$", $mac ) ) {
 /* split up the MAC and assign new var names */
 @list( $mac_1, $mac_2, $mac_3, $mac_4, $mac_5, $mac_6 ) = @str_split( 
$mac, 2 );

 /* put it back together with the required colons */
 $mac1 = $mac_1 . ":" . $mac_2 . ":" . $mac_3 . ":" . $mac_4 . ":" . 
$mac_5 . ":" . $mac_6;

 echo "MAC: $mac1";
}
return $mac1;
}

// do our checks to make sure we are using these damn things right
$mac1 = "00aa11bb22cc";
$mac2 = "00-aa-11-bb-22-cc";
$mac3 = "00:aa:11:bb:22:cc";
$mac4 = "zz:00:11:22:ff:xx";

if( chk_mac( $mac1 ) != 0 ) {
$mac = fix_mac( $mac1 );
   echo $mac1 . " converted to " . $mac . "";
} else {
echo "$mac1 is valid.";
}

if( chk_mac( $mac2 ) != 0 ) {
$mac = fix_mac( $mac2 );
   echo $mac2 . " converted to " . $mac . "";
} else {
echo "$mac2 is valid.";
}

if( chk_mac( $mac3 ) != 0 ) {
$mac = fix_mac( $mac3 );
   echo $mac3 . " converted to " . $mac . "";
} else {
echo "$mac3 is valid.";
}

if( chk_mac( $mac4 ) != 0 ) {
$mac = fix_mac( $mac4 );
   echo $mac4 . " converted to " . $mac . "";
} else {
echo "$mac4 is valid.";
}


?>



For what it's worth..

I'm moderately good with regex; but, I wouldn't even try to get an expression like yours to work properly, with all 
possiblities and exceptions.


Suggest breaking it up into several separate tests.

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



[PHP] Re: Strange array access problem

2005-10-27 Thread Al

Ken Tozier wrote:
I'm having a major problem with what seems, on it's face, to be a  
really basic array function.


What happens is on the browser end, I've written some javascript code  
that packages up javascript variables in native PHP format and sends  
the packed variables to a PHP script on the server via a POST and  
XMLHTTP. On the server end, the PHP script grabs the packed variables  
out of the $_POST, strips slashes and uses the "unserialize" command.


Here's the function that gets the post data
$unpacked_data= GetDataFromPOST();

And here's a var_dump of $unpacked_data as it appears in the browser
 array(1) { ["handler"]=>  array(1) { ["0"]=>  string(9)  "databases" } }

I'm able to get the "handler with no problem like so:
$parts= $unpacked_data['handler'];

Which yields the following var_dump
array(1) { ["0"]=>  string(9) "databases" }

Here's where the problem starts. I've had no luck whatsoever trying  to 
get  items of $parts. I've tried all of the following and each of  them 
return NULL


$part_1 = $parts[0];
$part_1 = $parts['0'];
$part_1 = $parts["0"];
$part_1 = $parts[48]; <- ASCII character for zero

In desperation, I also tried this

foreach($parts as $key => $value)
{
var_dump($key);
// => string(1) "0"
var_dump($value);
// => string(9) "databases"

$parts_1 = $parts[$key];
// => NULL;
}

But no luck

I also checked the type and size of the key like so
foreach($parts as $key => $value)
{
   echo gettype($key);
// => string

echo sizeof($key);
// => 1
}

Anyone have any insights as to what the heck is going on here? This  
should be a piece of cake but It's stopped me cold for a full day and  a 
half


Thanks for any help

Ken



Why the serialize/unserialize()?  Don't serialize() on the client's and see what happens if you just print_r($_POST) as 
received?


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



[PHP] Re: How to account for misspellings and alternatives in searching?

2005-10-27 Thread James Benson

Not sure about the numbers but soundex could be useful

http://php.net/soundex



James


Chris W. Parker wrote:

Hello,

On my site right now if someone searches for "511" (a misspelling of the
manufacturer 5.11) they are not presented with the right products
because 511 is not found anywhere in the database.

I've got a few ideas on how to solve this but I want to find one that
requires as little administrative overhead as possible.

1. I could add a field to the db for each product that would be used for
associated words for a product as well as misspellings.

PROS: Very customizable on an individual product level.
CONS: Would need to be updated for each and every product individually.

2. Make a field for each manufacturer's record for alternate
spellings/keywords.

PROS: Little administrative overhead.
CONS: Is only manufacturer name based and could not account for specific
products.

3. Both #1 and #2.

PROS: Flexible.
CONS: Lots of administrative overhead.

4. A one-to-many table that associates individual words with product
skus. This one is pretty much the opposite of #1 with one key
difference: the interface. It would be probably be easier to enter a
desired word and then choose each sku from a multi-select dropdown than
it would be to go from product to product entering one word at a time.

5. I'm not sure how this would be accomplished from a technical
standpoint but it would be nice to have the program know that when
someone types in "511" they really meant "5.11". Or (hopefully this
isn't a bad example) if they type in "dessert" (as in cake and icecream)
they really meant "desert" (as in snakes and sand).

In my case that wouldn't be a bad assumption since our site will never
contain the word desert unless it's a misspelling.


What does everyone think? What other options are out there?



Chris.


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



[PHP] How to account for misspellings and alternatives in searching?

2005-10-27 Thread Chris W. Parker
Hello,

On my site right now if someone searches for "511" (a misspelling of the
manufacturer 5.11) they are not presented with the right products
because 511 is not found anywhere in the database.

I've got a few ideas on how to solve this but I want to find one that
requires as little administrative overhead as possible.

1. I could add a field to the db for each product that would be used for
associated words for a product as well as misspellings.

PROS: Very customizable on an individual product level.
CONS: Would need to be updated for each and every product individually.

2. Make a field for each manufacturer's record for alternate
spellings/keywords.

PROS: Little administrative overhead.
CONS: Is only manufacturer name based and could not account for specific
products.

3. Both #1 and #2.

PROS: Flexible.
CONS: Lots of administrative overhead.

4. A one-to-many table that associates individual words with product
skus. This one is pretty much the opposite of #1 with one key
difference: the interface. It would be probably be easier to enter a
desired word and then choose each sku from a multi-select dropdown than
it would be to go from product to product entering one word at a time.

5. I'm not sure how this would be accomplished from a technical
standpoint but it would be nice to have the program know that when
someone types in "511" they really meant "5.11". Or (hopefully this
isn't a bad example) if they type in "dessert" (as in cake and icecream)
they really meant "desert" (as in snakes and sand).

In my case that wouldn't be a bad assumption since our site will never
contain the word desert unless it's a misspelling.


What does everyone think? What other options are out there?



Chris.

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



Re: [PHP] Using PHP for accsess control, preventing access to staticfiles

2005-10-27 Thread Ben

Dan Trainor said the following on 10/27/2005 10:39 AM:

Jason Motes wrote:



However, how do people protect against the downloading of real files,
ones which are not parsed by PHP?  .WMV, .MOV, .ZIP, .EXE and so on?  I
want to protect access to these as well, and if a visitor just types in
a URL and is able to access the file because my access control mechanism
simply doesn't work on those types of files, what should be the solution
here?





I'd like to keep the application as portable as possible; thus, I cannot
use any kind of htaccess hackery because I want this PHP application to
run on IIS, as well.


Move the files outside the document root so that they aren't available 
via a direct URL, then create a 'file access page' in php that will 
check for the session variable and either send or not send the file 
based on whether the user has access.


- Ben

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



Re: [PHP] Using PHP for accsess control, preventing access to static files

2005-10-27 Thread Dan Trainor
Jason Motes wrote:
>>
>> I'm designing a controlled access system in PHP, and it's coming along
>> quite well.  It's very simple, and just sets a session varibale, such as
>> $_SESSION['authenticated'] = 1, not a whole lot.
>>
>> Now I run a small sniplet of code on the top of each HTML and PHP file,
>> which checks for this variable, and either allows or denys access to the
>> page.
>>
>> However, how do people protect against the downloading of real files,
>> ones which are not parsed by PHP?  .WMV, .MOV, .ZIP, .EXE and so on?  I
>> want to protect access to these as well, and if a visitor just types in
>> a URL and is able to access the file because my access control mechanism
>> simply doesn't work on those types of files, what should be the solution
>> here?
>>
>> It's been suggested to use readfile() to accomplish this, by forwarding
>> content from outside of the document root - but this just sounds odd.
>> On top of being (what I think would be) incredibly slow, it just doesn't
>> sound "right".
>>
> 
> I had a similar issue.  I ended up using a .htaccess so that you could
> not open the file directly.  If checked for the referrer.  This is not
> the most secure way to do it.  I know it can be spoofed.
> 
> IndexIgnore *
> SetEnvIfNoCase Referer "^http://example.com/viewer.php"; local_ref=1
> Order Allow,Deny
> Allow from env=local_ref
> 
> Jason Motes
> php at imotes.com
> 

Thanks for the reply, Jason -

I'd like to keep the application as portable as possible; thus, I cannot
use any kind of htaccess hackery because I want this PHP application to
run on IIS, as well.

Thanks
-dant

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



Re: [PHP] Using PHP for accsess control, preventing access to static files

2005-10-27 Thread Jason Motes


I'm designing a controlled access system in PHP, and it's coming along
quite well.  It's very simple, and just sets a session varibale, such as
$_SESSION['authenticated'] = 1, not a whole lot.

Now I run a small sniplet of code on the top of each HTML and PHP file,
which checks for this variable, and either allows or denys access to the
page.

However, how do people protect against the downloading of real files,
ones which are not parsed by PHP?  .WMV, .MOV, .ZIP, .EXE and so on?  I
want to protect access to these as well, and if a visitor just types in
a URL and is able to access the file because my access control mechanism
simply doesn't work on those types of files, what should be the solution
here?

It's been suggested to use readfile() to accomplish this, by forwarding
content from outside of the document root - but this just sounds odd.
On top of being (what I think would be) incredibly slow, it just doesn't
sound "right".



I had a similar issue.  I ended up using a .htaccess so that you could 
not open the file directly.  If checked for the referrer.  This is not 
the most secure way to do it.  I know it can be spoofed.


IndexIgnore *
SetEnvIfNoCase Referer "^http://example.com/viewer.php"; local_ref=1
Order Allow,Deny
Allow from env=local_ref

Jason Motes
php at imotes.com

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



[PHP] Using PHP for accsess control, preventing access to static files

2005-10-27 Thread Dan Trainor
Hello, all -

I'm designing a controlled access system in PHP, and it's coming along
quite well.  It's very simple, and just sets a session varibale, such as
$_SESSION['authenticated'] = 1, not a whole lot.

Now I run a small sniplet of code on the top of each HTML and PHP file,
which checks for this variable, and either allows or denys access to the
page.

However, how do people protect against the downloading of real files,
ones which are not parsed by PHP?  .WMV, .MOV, .ZIP, .EXE and so on?  I
want to protect access to these as well, and if a visitor just types in
a URL and is able to access the file because my access control mechanism
simply doesn't work on those types of files, what should be the solution
here?

It's been suggested to use readfile() to accomplish this, by forwarding
content from outside of the document root - but this just sounds odd.
On top of being (what I think would be) incredibly slow, it just doesn't
sound "right".

Thanks!
-dant

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



Re: [PHP] php / openLdap

2005-10-27 Thread Björn Bartels
Hello !

ldap_add is expecting an ARRAY OF STRINGS (according to LDAP-specs) as
third parameter.
but your $info["objectclass"] is an array itself... maybe you try to
implode it into one string...

cheers, hope that helps...

bb

>Hello all,
>
>I have a problem with ldap function :/
>
>Here is my ldap :
>- dc=arzur,dc=local
>- ou=Annuaire
>+ cn=Benjamin DUPUIS
>+ cn=Emeric GIRARD
>+ cn=Fabrice DEPIL
>+ cn=Fabrice GAUSSEN
>+ cn=Jérôme LE MANSEC
>+ cn=Olivier MATHE
>+ cn=Sylvain BOUBOUNELLE
>
>Here is a LDIF file, (export of phpldapadmin) :*
>*dn:cn=Benjamin1 DUPUIS1,ou=Annuaire,dc=arzur,dc=local
>cn: Benjamin1 DUPUIS1
>objectClass: top
>objectClass: person
>objectClass: organizationalPerson
>objectClass: inetOrgPerson
>objectClass: mozillaAbPersonObsolete
>sn: DUPUIS
>
>/***/
>My connection/search work fine
>$ds = @ldap_connect("localhost");
>@ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 );
>@ldap_set_option( $ds, LDAP_OPT_REFERRALS, 0);
>
>if ($ds) {
>$r=ldap_bind($ds,"cn=Manager,dc=arzur,dc=local","toto");
>$sr=ldap_search($ds,"ou=Exterieur,dc=arzur,dc=local", "mail=*");
>$info = ldap_get_entries($ds, $sr);
>
>echo 'Nom PrénomMail';
>for ($i=0; $i<$info["count"]; $i++) {
>echo '';
>echo '' . $info[$i]["cn"][0] . '';
>echo '' . $info[$i]["mail"][0] . '}
>ldap_close($ds);
>}
>else {
>echo 'Impossible de se connecter au serveur LDAP.';
>}
>/***/
>But ldap_add not working with error Warning: ldap_add(): Add: Undefined
>attribute type in /srv/www/htdocs/gestioninterne/CLDAP.php on line 70
>
>Here's the code :
>if ( (isset ($_POST['envoi']) ) && ($_POST['envoi']=="ok")) {
>$ds = ldap_connect("localhost");
>ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 );
>ldap_set_option( $ds, LDAP_OPT_REFERRALS, 0);
>$r=ldap_bind($ds,"cn=Manager,dc=arzur,dc=local","toto");
>
>$cn=$_POST['givenName'].' '.$_POST['sn'];
>$info["cn"]="$cn"; // Prenom NOM
>$info["objectClass"][0]="mozillaAbPersonObselete";
>/*$info["objectClass"][0]="top";
>$info["objectClass"][1]="person";
>$info["objectClass"][2]="organizationalPerson";
>$info["objectClass"][3]="inetOrgPerson";
>$info["objectClass"][4]="mozillaAbPersonObselete";*/
>$info["sn"]=$_POST['sn']; // Nom
>
>$cn.=",ou=Exterieur,dc=arzur,dc=local";
>$cnFinal="cn=".$cn;
>echo

>>$cnFinal,'$info[objectClass]',$info["objectClass"],'$info[sn]=',$info["sn"],'$info[cn]=',$info["cn"];
>$r=ldap_add($ds,$cnFinal,$info);
>ldap_close($ds);
>}
>
>/*/
>Here's the result of my echo :
>cn=Benjamin BOUBOUNELLE,ou=Exterieur,dc=arzur,dc=local
>$info[objectClass]Array
>$info[sn]=BOUBOUNELLE
>$info[cn]=Benjamin BOUBOUNELLE
>*Warning*: ldap_add(): Add: Undefined attribute type in
>*/srv/www/htdocs/gestioninterne/CLDAP.php* on line *70
>
>*/*/
>
>Anyone can help me, I'm on since 10 hours :(
>
>Regards
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Björn Bartels
-Development/IT-Services-

--
dbusiness.de gmbh
digital business & printing gmbh

Greifswalder Str. 152
D-10409 Berlin

Fon: [0.30] 4.21.19.95
Fax: [0.30] 4.21.19.74

www.dbusiness.de
[EMAIL PROTECTED]
ftp://dbusiness.dyndns.org

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

Re: [PHP] zipped files

2005-10-27 Thread Clive

Thanks its working

clive

James Lobley wrote:

These are the relevant sections from my code:
 


include("e:/bin/pclzip.php");
$provpath_dec = 'E:/Prov/Processed_Files/';
$provpath_unzip = 'E:/data/prov/';

$filename = '20051026202333.zip';

$archive = new PclZip($provpath_dec . $filename);
$archive->extract(PCLZIP_OPT_PATH, $provpath_unzip);


 
As you'd probably guess from the paths shown, this is running on a 
windoze box.
 
James


 
On 10/27/05, *Clive* <[EMAIL PROTECTED] > 
wrote:


Hi,

I found that class but could not get it to work. Well it seem to work,
as I could view the files information, but the extract() didn't do
anything. I checked the writes for the directory the zip file was in and
it did have wright rights. Maybe you can post a code snippet.

thanks

clive

James Lobley wrote:
 > This is the class I use:
 > http://www.phpconcept.net/pclzip/man/en/index.php
 >
 >
 >  On 10/26/05, Clive <[EMAIL PROTECTED]
> wrote:
 >
 >>Hi
 >>
 >>does any one have code/examples for unzipping a file thats been
uploaded
 >>to a server. I would prefer a class rather than something that uses
 >> zip.lib as it may not be configured on the server.
 >>
 >>clive
 >>
 >>--
 >>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




--

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



[PHP] php / openLdap

2005-10-27 Thread Poil

Hello all,

I have a problem with ldap function :/

Here is my ldap :
-dc=arzur,dc=local
   - ou=Annuaire
   + cn=Benjamin DUPUIS
   + cn=Emeric GIRARD
   + cn=Fabrice DEPIL
   + cn=Fabrice GAUSSEN
   + cn=Jérôme LE MANSEC
   + cn=Olivier MATHE
   + cn=Sylvain BOUBOUNELLE

Here is a LDIF file, (export of phpldapadmin) :*
*dn:cn=Benjamin1 DUPUIS1,ou=Annuaire,dc=arzur,dc=local
cn: Benjamin1 DUPUIS1
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: mozillaAbPersonObsolete
sn: DUPUIS

/***/
My connection/search work fine
$ds = @ldap_connect("localhost");
@ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 );
@ldap_set_option( $ds, LDAP_OPT_REFERRALS, 0);

if ($ds) {
   $r=ldap_bind($ds,"cn=Manager,dc=arzur,dc=local","toto");
   $sr=ldap_search($ds,"ou=Exterieur,dc=arzur,dc=local", "mail=*");
   $info = ldap_get_entries($ds, $sr);

   echo 'Nom PrénomMail';
   for ($i=0; $i<$info["count"]; $i++) {
   echo '';
   echo '' . $info[$i]["cn"][0] . '';
   echo '' . $info[$i]["mail"][0] . '} 
else {

   echo 'Impossible de se connecter au serveur LDAP.';
}
/***/
But ldap_add not working with error Warning: ldap_add(): Add: Undefined 
attribute type in /srv/www/htdocs/gestioninterne/CLDAP.php on line 70


Here's the code :
if ( (isset ($_POST['envoi']) ) && ($_POST['envoi']=="ok")) {
   $ds = ldap_connect("localhost");
   ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 );
   ldap_set_option( $ds, LDAP_OPT_REFERRALS, 0);
   $r=ldap_bind($ds,"cn=Manager,dc=arzur,dc=local","toto");

   $cn=$_POST['givenName'].' '.$_POST['sn'];  
   $info["cn"]="$cn"; // Prenom NOM

   $info["objectClass"][0]="mozillaAbPersonObselete";
   /*$info["objectClass"][0]="top";
   $info["objectClass"][1]="person";
   $info["objectClass"][2]="organizationalPerson";
   $info["objectClass"][3]="inetOrgPerson";
   $info["objectClass"][4]="mozillaAbPersonObselete";*/
   $info["sn"]=$_POST['sn']; // Nom

   $cn.=",ou=Exterieur,dc=arzur,dc=local";
   $cnFinal="cn=".$cn;
   echo 
$cnFinal,'$info[objectClass]',$info["objectClass"],'$info[sn]=',$info["sn"],'$info[cn]=',$info["cn"];

   $r=ldap_add($ds,$cnFinal,$info);
   ldap_close($ds);
}

/*/
Here's the result of my echo :
cn=Benjamin BOUBOUNELLE,ou=Exterieur,dc=arzur,dc=local
$info[objectClass]Array
$info[sn]=BOUBOUNELLE
$info[cn]=Benjamin BOUBOUNELLE
*Warning*: ldap_add(): Add: Undefined attribute type in 
*/srv/www/htdocs/gestioninterne/CLDAP.php* on line *70


*/*/

Anyone can help me, I'm on since 10 hours :(

Regards

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



Re: [PHP] zipped files

2005-10-27 Thread Clive

Thanks

Im going to give it a try.

clive

James Lobley wrote:

These are the relevant sections from my code:

include("e:/bin/pclzip.php");
$provpath_dec = 'E:/Prov/Processed_Files/';
$provpath_unzip = 'E:/data/prov/';

$filename = '20051026202333.zip';

$archive = new PclZip($provpath_dec . $filename);
$archive->extract(PCLZIP_OPT_PATH, $provpath_unzip);

 As you'd probably guess from the paths shown, this is running on a windoze
box.
 James

 On 10/27/05, Clive <[EMAIL PROTECTED]> wrote:


Hi,

I found that class but could not get it to work. Well it seem to work,
as I could view the files information, but the extract() didn't do
anything. I checked the writes for the directory the zip file was in and
it did have wright rights. Maybe you can post a code snippet.

thanks

clive

James Lobley wrote:


This is the class I use:
http://www.phpconcept.net/pclzip/man/en/index.php


On 10/26/05, Clive <[EMAIL PROTECTED]> wrote:



Hi

does any one have code/examples for unzipping a file thats been uploaded
to a server. I would prefer a class rather than something that uses
zip.lib as it may not be configured on the server.

clive

--
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







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



[PHP] Re: php session variables limited to 1 character -- please help

2005-10-27 Thread Oliver Grätz
Zac Smith schrieb:
> http://www.triptrivia.com/step2-debug.php?State=abc

404

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



Re: [PHP] zipped files

2005-10-27 Thread James Lobley
These are the relevant sections from my code:

include("e:/bin/pclzip.php");
$provpath_dec = 'E:/Prov/Processed_Files/';
$provpath_unzip = 'E:/data/prov/';

$filename = '20051026202333.zip';

$archive = new PclZip($provpath_dec . $filename);
$archive->extract(PCLZIP_OPT_PATH, $provpath_unzip);

 As you'd probably guess from the paths shown, this is running on a windoze
box.
 James

 On 10/27/05, Clive <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I found that class but could not get it to work. Well it seem to work,
> as I could view the files information, but the extract() didn't do
> anything. I checked the writes for the directory the zip file was in and
> it did have wright rights. Maybe you can post a code snippet.
>
> thanks
>
> clive
>
> James Lobley wrote:
> > This is the class I use:
> > http://www.phpconcept.net/pclzip/man/en/index.php
> >
> >
> > On 10/26/05, Clive <[EMAIL PROTECTED]> wrote:
> >
> >>Hi
> >>
> >>does any one have code/examples for unzipping a file thats been uploaded
> >>to a server. I would prefer a class rather than something that uses
> >>zip.lib as it may not be configured on the server.
> >>
> >>clive
> >>
> >>--
> >>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
>
>


[PHP] compiling php5 on winxp

2005-10-27 Thread Luka

I'm using VC6++ and the VC2003 Toolkit

I downloaded a dev tree from:

http://ftp.emini.dk/pub/php/win32/dev/php_build/

the compile keeps failing with:

 Creating library Release_TS\php5ts.lib and object Release_TS\php5ts.exp

sunfuncs.obj : error LNK2001: unresolved external symbol __ftol2

uuencode.obj : error LNK2001: unresolved external symbol __ftol2



now the only post about this that i could find was this being related to 
the toolkit




and that this could shoult be added to the beginning of a number of your 
C++ files:




#if (_MSC_VER >= 1300) && (WINVER < 0x0500)
//VC7 or later, building with pre-VC7 runtime libraries
extern "C" long _ftol( double ); //defined by VC6 C libs
extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource ); }
#endif

the other post said that adding CFLAGS=/QIfist

does anyone know to do any of the following
or fix the above problem.
the basic compilation faq under windows just isn't...helping me a lot.
So if anyone has a link with perhaps a downloadable sourcetree with the 
needed headers and libraries

to compile the php5 and php4 branch do help :)

well any help on the above problem would be greatly appreciated.
#endif







[PHP] Sending E-Mail - Setting O/S User

2005-10-27 Thread Cabbar Duzayak
Hi,

When someone sends an e-mail using php, exim sets the following 2
headers (along with others of course):

Received:from x.x.x.x (EHLO host.mydomain.com) (x.x.x.x) by
mta151.mail.dcn.yahoo.com with SMTP; Wed, 24 Sep 2005 10:29:04 -0700

Received:   from  by host.mydomain.com with local (Exim 4.52)
id 3ABiAO-00019o-KL for [EMAIL PROTECTED]; Thu, 27 Oct 2005 13:29:03
+0300

Here, the  is picked up from the operation system, and it is
the user that owns the process, which is the process that initiates
sending out this e-mail.

Is there a way to specify a certain user instead of the owner of the
current process, or is there a way to configure exim such that, it
won't pick up the owner of that process for this header, but a
specific user that I explicitly specify through configuration?

Thanks...

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



Re: [PHP] Detailed Report

2005-10-27 Thread Danny
Thank you very much
I think it will work, because my problem seems to be with "if" operators and
order...
 Thanks again

 On 10/27/05, Adrian Bruce <[EMAIL PROTECTED]> wrote:
>
> ok, so i assume that customers is a grouping of some sort and that in
> some cases you may come accross a row like "Staff | John | A36 |LA ".
> It may not be a perfect way of doinig it but this is what i would
> generally try:
>
> while ($row = mysql_fetch_array($resultset, MYSQL_NUM)){
> if($row[0] == $group){
> echo" $row[1] | $row[2]";
> }
> else{
> echo"$row[0]$row[1] | $row[2] | $row[3]";
> }
> $group = $row[0];
> }
>
> Ade
>
> Danny wrote:
>
> > Thanks for your help Adrian, but the problem is that I need to show
> > row[0] once (Customers text are repeated), and below the details of
> > the records
> >
> > Your solution shows:
> >
> > Customers | John | A36 | New York
> > Customers | Jason | B45 | Los Angeles
> > (...)
> > And I need
> > Customers
> > John | A36 | New York
> > Jason | B45 | Los Angeles
> >
> > (...)
> >
> >
> >
> > (...)
> >
> >
> >
> >
> >
> >
> > On 10/27/05, *Adrian Bruce* <[EMAIL PROTECTED]
> > > wrote:
> >
> >
> > load each row of the resultset into an array $row using
> > mysql_fetch_array(), each field in the result set row will be
> > held in
> > the corresponding array element.
> >
> > while ($row = mysql_fetch_array($resultset, MYSQL_NUM)){
> > echo"$row[0] | $row[1] | $row[2]";
> > }
> >
> > Hope this helps,
> > Ade
> >
> > Danny wrote:
> >
> > >Hi All,
> > > I´ve got a connection, to a MySQL db, and get the following
> > >ResultSet(Category | Name | Code | City)
> > > Customers | John | A36 | New York
> > >Customers | Jason | B45 | Los Angeles
> > >Customers | Max | A36 | Paris
> > >Providers | John | A36 | London
> > >Providers | Mark | B67 | Madrid
> > >And I need the report in the following format:
> > > Customers
> > >John - A36 - New York
> > >Jason - B45 - Los Angeles
> > >Max - A36 - Paris
> > > Providers
> > >John - A36 - London
> > >Mark - B67 - Madrid
> > > Any one can help? I´m a bit stalled
> > > thx
> > >regards.
> > >--
> > >
> > >
> > >
> >
> > --
> > PHP General Mailing List ( http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> >
> > --
> > dpc
>
>


--
dpc


Re: [PHP] Detailed Report

2005-10-27 Thread tomasz abramowicz

if your db is built correctly you could use
UNION or JOIN(S) to build the correct query.
otherwise look into DISTINCT(ROW) and/or creating
temporary tables.
formatting the info later is, as adrian illustrated,
up to you.

t.

ps. all the above depends on your mysql server version and
configuration.

Danny wrote:

Thanks for your help Adrian, but the problem is that I need to show row[0]
once (Customers text are repeated), and below the details of the records
 Your solution shows:
 Customers | John | A36 | New York
Customers | Jason | B45 | Los Angeles
(...)
And I need
Customers
John | A36 | New York
Jason | B45 | Los Angeles
 (...)
   (...)


 On 10/27/05, Adrian Bruce <[EMAIL PROTECTED]> wrote:



load each row of the resultset into an array $row using
mysql_fetch_array(), each field in the result set row will be held in
the corresponding array element.

while ($row = mysql_fetch_array($resultset, MYSQL_NUM)){
echo"$row[0] | $row[1] | $row[2]";
}

Hope this helps,
Ade

Danny wrote:



Hi All,
I´ve got a connection, to a MySQL db, and get the following
ResultSet(Category | Name | Code | City)
Customers | John | A36 | New York
Customers | Jason | B45 | Los Angeles
Customers | Max | A36 | Paris
Providers | John | A36 | London
Providers | Mark | B67 | Madrid
And I need the report in the following format:
Customers
John - A36 - New York
Jason - B45 - Los Angeles
Max - A36 - Paris
Providers
John - A36 - London
Mark - B67 - Madrid
Any one can help? I´m a bit stalled
thx
regards.
--





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






--
dpc



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



Re: [PHP] Detailed Report

2005-10-27 Thread Adrian Bruce
ok, so i assume that customers is a grouping of some sort and that in 
some cases you may come accross a row like "Staff | John | A36 |LA ".  
It may not be a perfect way of doinig it but this is what i would 
generally try:


  while ($row = mysql_fetch_array($resultset, MYSQL_NUM)){
   if($row[0] == $group){
echo" $row[1] | $row[2]"; 
  }

  else{
 echo"$row[0]$row[1] | $row[2] | $row[3]";
  }
   $group = $row[0];
}

Ade

Danny wrote:

Thanks for your help Adrian, but the problem is that I need to show 
row[0] once (Customers text are repeated), and below the details of 
the records
 
Your solution shows:
 
Customers | John | A36 | New York

Customers | Jason | B45 | Los Angeles
(...)
And I need
Customers
John | A36 | New York
Jason | B45 | Los Angeles
 
(...)
 
 
 
(...)
 
 
 



 
On 10/27/05, *Adrian Bruce* <[EMAIL PROTECTED] 
> wrote:



load each row of the resultset into an array $row using
mysql_fetch_array(), each field in the result set  row will  be
held in
the corresponding array element.

while ($row = mysql_fetch_array($resultset, MYSQL_NUM)){
   echo"$row[0] | $row[1] | $row[2]";
}

Hope this helps,
Ade

Danny wrote:

>Hi All,
> I´ve got a connection, to a MySQL db, and get the following
>ResultSet(Category | Name | Code | City)
> Customers | John | A36 | New York
>Customers | Jason | B45 | Los Angeles
>Customers | Max | A36 | Paris
>Providers | John | A36 | London
>Providers | Mark | B67 | Madrid
>And I need the report in the following format:
> Customers
>John - A36 - New York
>Jason - B45 - Los Angeles
>Max - A36 - Paris
> Providers
>John - A36 - London
>Mark - B67 - Madrid
> Any one can help? I´m a bit stalled
> thx
>regards.
>--
>
>
>

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




--
dpc 


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



Re: [PHP] Detailed Report

2005-10-27 Thread Danny
Thanks for your help Adrian, but the problem is that I need to show row[0]
once (Customers text are repeated), and below the details of the records
 Your solution shows:
 Customers | John | A36 | New York
Customers | Jason | B45 | Los Angeles
(...)
And I need
Customers
John | A36 | New York
Jason | B45 | Los Angeles
 (...)
   (...)


 On 10/27/05, Adrian Bruce <[EMAIL PROTECTED]> wrote:
>
>
> load each row of the resultset into an array $row using
> mysql_fetch_array(), each field in the result set row will be held in
> the corresponding array element.
>
> while ($row = mysql_fetch_array($resultset, MYSQL_NUM)){
> echo"$row[0] | $row[1] | $row[2]";
> }
>
> Hope this helps,
> Ade
>
> Danny wrote:
>
> >Hi All,
> > I´ve got a connection, to a MySQL db, and get the following
> >ResultSet(Category | Name | Code | City)
> > Customers | John | A36 | New York
> >Customers | Jason | B45 | Los Angeles
> >Customers | Max | A36 | Paris
> >Providers | John | A36 | London
> >Providers | Mark | B67 | Madrid
> >And I need the report in the following format:
> > Customers
> >John - A36 - New York
> >Jason - B45 - Los Angeles
> >Max - A36 - Paris
> > Providers
> >John - A36 - London
> >Mark - B67 - Madrid
> > Any one can help? I´m a bit stalled
> > thx
> >regards.
> >--
> >
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
dpc


Re: [PHP] Detailed Report

2005-10-27 Thread Adrian Bruce


load each row of the resultset into an array $row using 
mysql_fetch_array(), each field in the result set  row will  be held in 
the corresponding array element.


while ($row = mysql_fetch_array($resultset, MYSQL_NUM)){
   echo"$row[0] | $row[1] | $row[2]";
}

Hope this helps,
Ade

Danny wrote:


Hi All,
I´ve got a connection, to a MySQL db, and get the following
ResultSet(Category | Name | Code | City)
Customers | John | A36 | New York
Customers | Jason | B45 | Los Angeles
Customers | Max | A36 | Paris
Providers | John | A36 | London
Providers | Mark | B67 | Madrid
And I need the report in the following format:
Customers
John - A36 - New York
Jason - B45 - Los Angeles
Max - A36 - Paris
Providers
John - A36 - London
Mark - B67 - Madrid
Any one can help? I´m a bit stalled
thx
regards.
--

 



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



[PHP] Detailed Report

2005-10-27 Thread Danny
Hi All,
 I´ve got a connection, to a MySQL db, and get the following
ResultSet(Category | Name | Code | City)
 Customers | John | A36 | New York
Customers | Jason | B45 | Los Angeles
Customers | Max | A36 | Paris
Providers | John | A36 | London
Providers | Mark | B67 | Madrid
And I need the report in the following format:
 Customers
John - A36 - New York
Jason - B45 - Los Angeles
Max - A36 - Paris
 Providers
John - A36 - London
Mark - B67 - Madrid
 Any one can help? I´m a bit stalled
 thx
regards.
--


[PHP] Problem upgrading from 5.0.2 and 5.05

2005-10-27 Thread Karlos Zafra
My system was runig apache 2.0.52+php5.0.2 under Windows Xp without any
problem. Today i've decided to upgrade to 5.0.5 but after unzipping the
files in the C:\php folder where it was installed de .0.2 version Apache
complained about not finding "php5apache2.dll".

The message from the command line:

Syntax error on line 179 of C:/'...'/Apache2/conf/httpd.conf: Cannot load
C:/PHP/php5apache2.dll into server: Especified process not found.


Re: [PHP] regex and global vars problem

2005-10-27 Thread Jasper Bryant-Greene
On Thu, 2005-10-27 at 00:00 +0200, Jochem Maas wrote:
> gonna jump on your thread there Jasper, I would
> like to comment on your function and ask you a question:
> 
> which is 'better' (for what), preg_*() or ereg[i]*()?

I prefer preg_*(), but I used eregi() because I couldn't be bothered
figuring out his regexp (it looked right, and it worked) and that's what
he used :)

It's a matter of personal taste, mainly.

[snip]
> >  > function fix_mac( $mac ) {
> > 
> > if( eregi(
> > 
> > "^[0-9A-Fa-f]{2}\-" .
> > "[0-9A-Fa-f]{2}\-" .
> > "[0-9A-Fa-f]{2}\-" .
> > "[0-9A-Fa-f]{2}\-" .
> > "[0-9A-Fa-f]{2}\-" .
> > "[0-9A-Fa-f]{2}$",
> 
> this string concatenation looks a bit naff.
> although on second thoughts I can see why you did it this way.
> down to personal choice :-).

I don't like it either, but that bit already worked, so I left it
functionally as-is, and I had to make it shorter so as to not wrap
stupidly in the email.

> the use of double quotes means strictly speaking
> you should be escaping the backslash and dollar sign (and the
> parentheseses?) although i would recommend single quotes.

Agreed.

> I would have used preg_match(), something like
[snip]

So would I, if I had been writing the function from scratch.

> white space is nice but too many blank lines lead to overscroll ;-)

Another matter of personal taste. I love whitespace and my scroll wheel
has its acceleration turned up very high, so scrolling doesn't really
bother me :)

-- 
Jasper Bryant-Greene
General Manager
Album Limited

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

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



Re: [PHP] regex and global vars problem

2005-10-27 Thread Richard Heyes

Jochem Maas wrote:

Richard Heyes wrote:


Jochem Maas wrote:
 > gonna jump on your thread there Jasper, I would
 > like to comment on your function and ask you a question:
 >
 > which is 'better' (for what), preg_*() or ereg[i]*()?

preg_*, for anything. They're faster, and more versatile.



cool cheers.

I guess your the same Richard Heyes of 'TreeMenu' class 'fame'?
still use that very often :-)


Dunno about "fame", some would say "Infamy", but yes, the very same.

--
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] regex and global vars problem

2005-10-27 Thread Jochem Maas

Richard Heyes wrote:

Jochem Maas wrote:
 > gonna jump on your thread there Jasper, I would
 > like to comment on your function and ask you a question:
 >
 > which is 'better' (for what), preg_*() or ereg[i]*()?

preg_*, for anything. They're faster, and more versatile.


cool cheers.

I guess your the same Richard Heyes of 'TreeMenu' class 'fame'?
still use that very often :-)





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



Re: [PHP] regex and global vars problem

2005-10-27 Thread Richard Heyes

Jochem Maas wrote:
> gonna jump on your thread there Jasper, I would
> like to comment on your function and ask you a question:
>
> which is 'better' (for what), preg_*() or ereg[i]*()?

preg_*, for anything. They're faster, and more versatile.

--
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] zipped files

2005-10-27 Thread Clive



Richard Lynch wrote:

On Wed, October 26, 2005 5:44 am, Clive wrote:


does any one have code/examples for unzipping a file thats been
uploaded
to a server. I would prefer a class rather than something that uses
zip.lib as it may not be configured on the server.



$path = "/full/path/to/uploaded/file.zip";
exec("/full/path/to/bin/unzip $path", $output, $error);
if ($error){
  die("OS Error: $error\n" . nl2br($output));
}
$unzipped = str_replace(".zip", '', $path);
$file = file_get_contents($unzipped);



Is the unzip command standerd on linux systems?

What happens if the app is run on a windows machine. I Suppose I will 
have to include support for pkunzip or whatever its called nowadays.


clive

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



Re: [PHP] Perl style

2005-10-27 Thread Søren Schimkat
Quoting rouvas <[EMAIL PROTECTED]>:

> Simpler(?) approach:
>
> $element5 = current(array_splice(split(',',$csvstring),5,1));
>
> This is fun!


Indeed... and this looks just fine. A great solution. Thanks. :-)


-Søren


>
> -Stathis
>
> On Wednesday 26 October 2005 17:08, Jochem Maas wrote:
> > Søren Schimkat wrote:
> > > Hi guys
> > >
> > > I would like to convert this ..
> > >
> > >
> > > $tmparray = split(',', $csvstring);
> >
> > don't use split() here - there is no need for regexp.
> > use explode() instead.
> >
> > > $element5 = $tmparray[5];
> > >
> > >
> > > . to something like this:
> > >
> > >
> > > $element5 = (split(',', $csvstring))[5];
> >
> > $csvstring = "1,2,3,4,5,6";
> > echo "route "; // humor me
> > echo $element5 = current(array_reverse(array_slice(explode(",",
> > $csvstring), 0, 6))); echo $element5 = end(array_slice(explode(",",
> > $csvstring), 0, 6));
> >
> > not as short as perl - unfortunately there is no valid
> > syntax that allows dereferenced access to array elements (AFAIK).
> >
> > > . but I just can't find the correct syntax. It is Perl style - i know,
> > > but I just love this syntax. :-)
> > >
> > > Does anyonw know the correct syntax?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
mvh Søren Schimkat
www.schimkat.dk

---
www.dyrenes-venner.dk/densorteliste.asp

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



Re: [PHP] zipped files

2005-10-27 Thread Clive

Hi,

I found that class but could not get it to work. Well it seem to work, 
as I could view the files information, but the extract() didn't do 
anything. I checked the writes for the directory the zip file was in and 
it did have wright rights. Maybe you can post a code snippet.


thanks

clive

James Lobley wrote:

This is the class I use:
http://www.phpconcept.net/pclzip/man/en/index.php


 On 10/26/05, Clive <[EMAIL PROTECTED]> wrote:


Hi

does any one have code/examples for unzipping a file thats been uploaded
to a server. I would prefer a class rather than something that uses
zip.lib as it may not be configured on the server.

clive

--
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