php-general Digest 12 Jul 2008 21:00:56 -0000 Issue 5565

2008-07-12 Thread php-general-digest-help

php-general Digest 12 Jul 2008 21:00:56 - Issue 5565

Topics (messages 276683 through 276708):

Most popular per month
276683 by: Ryan S

IPv6 validation
276684 by: Yeti
276685 by: Kevin Waterson
276686 by: Bernhard Kohl
276690 by: Eric Butera
276691 by: Yeti
276701 by: Eric Butera
276708 by: Kevin Waterson

Re: OT - RE: [PHP] scalable web gallery
276687 by: David Giragosian
276689 by: tedd
276692 by: David Giragosian
276695 by: Daniel Brown
276697 by: David Giragosian
276702 by: Robert Cummings
276707 by: tedd

Re: case and accent - insensitive regular expression?
276688 by: tedd

Passing arguments as they are received to another function
276693 by: Luigi Perroti
276694 by: James Dempster
276698 by: Luigi Perroti
276699 by: James Dempster
276700 by: Luigi Perroti

Re: scalable web gallery
276696 by: Daniel Brown
276703 by: Robert Cummings
276704 by: tedd
276705 by: Robert Cummings
276706 by: Daniel Brown

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
Hey!
Thanks for replying!



snip
..
.
$perc50=(img50 int)/$total;

You can do it per day, per month, per year, per 28 days, per PMS cycle, 
per anything you want provided you have the data to do it.
/snip

:) this is the part where i am a bit confused actually, can you give me one or 
two examples and i'll work from there?


snip
Google had an pie chart thingie, check the archives of this list.
/snip

Thanks! Will do!

Cheers!
Ryan


  
---End Message---
---BeginMessage---
Hello community,

I have been working with alot of IPv6 lately.

Now i was wondering of what there might be the best way to validate an IPv6
address.

Couldn't think of any working regexp, since even ::1 or :: is valid
(localhost), so i tried it the following way:

?php
//RFC 4291
//http://tools.ietf.org/html/rfc4291
function validate_ipv6($value) {
 if (substr_count($value, :)  2) return false; // has to contain : at
least twice like in ::1 or 1234::abcd
 if (substr_count($value, ::)  1) return false; // only 1 double colon
allowed
 $groups = explode(':', $value);
 $num_groups = count($groups);
 if (($num_groups  8) || ($num_groups  3)) return false; // 3-8 groups of
0-4 digits (1 group has to be at leas 1 digit)
 $empty_groups = 0;
 foreach ($groups as $group) {
  $group = trim($group);
  if (!empty($group)  !(is_numeric($group)  ($group == 0))) {
  if (!preg_match('#([a-fA-F0-9]{0,4})#', $group)) return false;
  } else ++$empty_groups;
 }
 return ($empty_groups  $num_groups) ? true : false; // the unspecified
address :: is not valid in this case
}
var_dump(validate_ipv6(::)); // false (wanted result)
var_dump(validate_ipv6(::1)); // true
var_dump(validate_ipv6(1234::abcd)); // true
var_dump(validate_ipv6(2001:DB8:0:0:8:800:200C:417A)); // true
var_dump(validate_ipv6(0:0:0:0:0:0:0:1)); // true
var_dump(validate_ipv6(0:0:0:0:0:0:0:0)); // false (wanted result)
var_dump(validate_ipv6(:::::::)); // false
(wanted result)
var_dump(validate_ipv6(2001:0DB8::CD30::::)); // true
var_dump(validate_ipv6(FF01:0:0:0:0:0:0:101)); // true
var_dump(validate_ipv6(bananas)); // false
var_dump(validate_ipv6(1:2:3:4:5:6:7:8:9)); // false
?

anybody with better ideas?

Yeti
---End Message---
---BeginMessage---
This one time, at band camp, Yeti [EMAIL PROTECTED] wrote:

 Now i was wondering of what there might be the best way to validate an IPv6
 address.

from this url..
http://phpro.org/tutorials/Filtering-Data-with-PHP.html#9

?php

/*** an IP address ***/
$ip = 2001:0db8:85a3:08d3:1319:8a2e:0370:7334;

/*** try to validate as IPV6 address ***/
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE)
{
echo $ip is not a valid IP;
}
else
{
echo $ip is valid;
}
?
---End Message---
---BeginMessage---
Doesnt filter_var() require PHP5+ ?

I have quite some systems still running 4.4.8.

On 7/12/08, Kevin Waterson [EMAIL PROTECTED] wrote:

 This one time, at band camp, Yeti [EMAIL PROTECTED] wrote:

  Now i was wondering of what there might be the best way to validate an
 IPv6
  address.


 from this url..
 http://phpro.org/tutorials/Filtering-Data-with-PHP.html#9

 ?php

 /*** an IP address ***/
 $ip = 2001:0db8:85a3:08d3:1319:8a2e:0370:7334;

 /*** try to validate as IPV6 address ***/
 if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE)
 {
 echo $ip is not a valid IP;
 }
 else
 {
 echo $ip is valid;
 }
 ?


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

[PHP] case and accent - insensitive regular expression?

2008-07-12 Thread Giulio Mastrosanti

Hi,
I have a php page that asks user for a key ( or a list of keys ) and  
then shows a list of items matching the query.


every item in the list shows its data, and the list of keys it has ( a  
list of comma-separated words )


I would like to higlight, in the list of keys shown for every item,   
the words matching the query,


this can be easily achieved with a search and replace, for every  
search word, i search it in the key list and replace it adding a style  
tag to higlight it such as for example to have it in red color:


if ( @stripos($keylist,$keysearch!== false ) {
  $keylist = str_ireplace($keysearch,'span style=color: #FF'. 
$keysearch.'/span',$keylist);

}

but i have some problem with accented characters:

i have mysql with  character encoding utf8, and all the php pages are  
declared as utf8


mysql in configured to perform queries in  a case and accent  
insensitive way.
this mean that if you search for the word 'cafe', you have returned  
rows that contains in the keyword list 'cafe', but also 'café' with  
the accent. ( I think it has to do with 'collation' settings, but I'm  
not investigating at the moment because it is OK for me the way it  
works ).


now my problem is to find a way ( I imagine with some kind of regular  
expression ) to achieve in php a search and replace accent- 
insensitive, so that i can find the word 'cafe' in a string also if it  
is 'café', or 'CAFÉ', or 'CAFE',  and vice-versa.


hope the problem is clear and well-explained in english,

thank you for any tip,

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



[PHP] Most popular per month

2008-07-12 Thread Ryan S
Hey!
Thanks for replying!



snip
..
.
$perc50=(img50 int)/$total;

You can do it per day, per month, per year, per 28 days, per PMS cycle, 
per anything you want provided you have the data to do it.
/snip

:) this is the part where i am a bit confused actually, can you give me one or 
two examples and i'll work from there?


snip
Google had an pie chart thingie, check the archives of this list.
/snip

Thanks! Will do!

Cheers!
Ryan


  

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



[PHP] IPv6 validation

2008-07-12 Thread Yeti
Hello community,

I have been working with alot of IPv6 lately.

Now i was wondering of what there might be the best way to validate an IPv6
address.

Couldn't think of any working regexp, since even ::1 or :: is valid
(localhost), so i tried it the following way:

?php
//RFC 4291
//http://tools.ietf.org/html/rfc4291
function validate_ipv6($value) {
 if (substr_count($value, :)  2) return false; // has to contain : at
least twice like in ::1 or 1234::abcd
 if (substr_count($value, ::)  1) return false; // only 1 double colon
allowed
 $groups = explode(':', $value);
 $num_groups = count($groups);
 if (($num_groups  8) || ($num_groups  3)) return false; // 3-8 groups of
0-4 digits (1 group has to be at leas 1 digit)
 $empty_groups = 0;
 foreach ($groups as $group) {
  $group = trim($group);
  if (!empty($group)  !(is_numeric($group)  ($group == 0))) {
  if (!preg_match('#([a-fA-F0-9]{0,4})#', $group)) return false;
  } else ++$empty_groups;
 }
 return ($empty_groups  $num_groups) ? true : false; // the unspecified
address :: is not valid in this case
}
var_dump(validate_ipv6(::)); // false (wanted result)
var_dump(validate_ipv6(::1)); // true
var_dump(validate_ipv6(1234::abcd)); // true
var_dump(validate_ipv6(2001:DB8:0:0:8:800:200C:417A)); // true
var_dump(validate_ipv6(0:0:0:0:0:0:0:1)); // true
var_dump(validate_ipv6(0:0:0:0:0:0:0:0)); // false (wanted result)
var_dump(validate_ipv6(:::::::)); // false
(wanted result)
var_dump(validate_ipv6(2001:0DB8::CD30::::)); // true
var_dump(validate_ipv6(FF01:0:0:0:0:0:0:101)); // true
var_dump(validate_ipv6(bananas)); // false
var_dump(validate_ipv6(1:2:3:4:5:6:7:8:9)); // false
?

anybody with better ideas?

Yeti


Re: [PHP] IPv6 validation

2008-07-12 Thread Kevin Waterson
This one time, at band camp, Yeti [EMAIL PROTECTED] wrote:

 Now i was wondering of what there might be the best way to validate an IPv6
 address.

from this url..
http://phpro.org/tutorials/Filtering-Data-with-PHP.html#9

?php

/*** an IP address ***/
$ip = 2001:0db8:85a3:08d3:1319:8a2e:0370:7334;

/*** try to validate as IPV6 address ***/
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE)
{
echo $ip is not a valid IP;
}
else
{
echo $ip is valid;
}
?

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



Re: [PHP] IPv6 validation

2008-07-12 Thread Bernhard Kohl
Doesnt filter_var() require PHP5+ ?

I have quite some systems still running 4.4.8.

On 7/12/08, Kevin Waterson [EMAIL PROTECTED] wrote:

 This one time, at band camp, Yeti [EMAIL PROTECTED] wrote:

  Now i was wondering of what there might be the best way to validate an
 IPv6
  address.


 from this url..
 http://phpro.org/tutorials/Filtering-Data-with-PHP.html#9

 ?php

 /*** an IP address ***/
 $ip = 2001:0db8:85a3:08d3:1319:8a2e:0370:7334;

 /*** try to validate as IPV6 address ***/
 if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE)
 {
 echo $ip is not a valid IP;
 }
 else
 {
 echo $ip is valid;
 }
 ?


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




Re: [PHP] OT - RE: [PHP] scalable web gallery

2008-07-12 Thread David Giragosian
 Todd Boyd recently offered:

 Haven't taken a distributed computing class just yet, but I've still got
 a bit until I graduate, and these elective credits are burning a hole in
 my pocket...


The cost of public colleges and universities, as well as community colleges,
are truly astounding these days. I for one am quite happy learning from
books, web tutorials and the occasional ( ;-g ) mailing list thread.

--David.


Re: [PHP] case and accent - insensitive regular expression?

2008-07-12 Thread tedd

At 9:36 AM +0200 7/12/08, Giulio Mastrosanti wrote:

Hi,
I have a php page that asks user for a key ( or 
a list of keys ) and then shows a list of items 
matching the query.


every item in the list shows its data, and the 
list of keys it has ( a list of comma-separated 
words )


I would like to higlight, in the list of keys shown for every item,
the words matching the query,

this can be easily achieved with a search and 
replace, for every search word, i search it in 
the key list and replace it adding a style tag 
to higlight it such as for example to have it in 
red color:


if ( @stripos($keylist,$keysearch!== false ) {
  $keylist = str_ireplace($keysearch,'span 
style=color: 
#FF'.$keysearch.'/span',$keylist);

}

but i have some problem with accented characters:

i have mysql with  character encoding utf8, and 
all the php pages are declared as utf8


mysql in configured to perform queries in  a case and accent insensitive way.
this mean that if you search for the word 
'cafe', you have returned rows that contains in 
the keyword list 'cafe', but also 'café' with 
the accent. ( I think it has to do with 
'collation' settings, but I'm not investigating 
at the moment because it is OK for me the way it 
works ).


now my problem is to find a way ( I imagine with 
some kind of regular expression ) to achieve in 
php a search and replace accent-insensitive, so 
that i can find the word 'cafe' in a string also 
if it is 'café', or 'CAFÉ', or 'CAFE',  and 
vice-versa.


hope the problem is clear and well-explained in english,

thank you for any tip,

Giulio


Giulio:

Three things:

1. Your English is fine.

2. Try using mb_ereg_replace()

http://www.php.net/mb_ereg_replace

Place the accents you want to change in that and 
change them to whatever you want.


3. Change:

span style=color: #FF'.$keysearch.'/span'

to

span class=keysearch'.$keysearch.'/span'

and add

.keysearch
   {
   color: #FF;
   }

to your css.

Cheers,

tedd


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

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



Re: [PHP] OT - RE: [PHP] scalable web gallery

2008-07-12 Thread tedd

At 9:13 AM -0500 7/12/08, David Giragosian wrote:

 Todd Boyd recently offered:


 Haven't taken a distributed computing class just yet, but I've still got
 a bit until I graduate, and these elective credits are burning a hole in
 my pocket...


The cost of public colleges and universities, as well as community colleges,
are truly astounding these days. I for one am quite happy learning from
books, web tutorials and the occasional ( ;-g ) mailing list thread.

--David.


Yes, but college degrees are the bill of goods we've been sold. We 
are lead to believe that if our children (and us) go to colleges and 
get that sheepskin then everything will be great for the rest of our 
lives. But unfortunately, that's not true.


In the meantime, academia and politician still demand more funding 
waving the same banner of yesteryear -- Your children's education 
needs improving -- while continuing to fail miserably in the global 
arena.


Like with everything else, you really don't realize the problem until 
you bounce off the bottom. We just haven't reached that yet, but 
we're doing our level best to get there.


Cheers (I guess),

tedd

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

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



Re: [PHP] IPv6 validation

2008-07-12 Thread Eric Butera
On Sat, Jul 12, 2008 at 9:13 AM, Bernhard Kohl [EMAIL PROTECTED] wrote:
 Doesnt filter_var() require PHP5+ ?

 I have quite some systems still running 4.4.8.

 On 7/12/08, Kevin Waterson [EMAIL PROTECTED] wrote:

 This one time, at band camp, Yeti [EMAIL PROTECTED] wrote:

  Now i was wondering of what there might be the best way to validate an
 IPv6
  address.


 from this url..
 http://phpro.org/tutorials/Filtering-Data-with-PHP.html#9

 ?php

 /*** an IP address ***/
 $ip = 2001:0db8:85a3:08d3:1319:8a2e:0370:7334;

 /*** try to validate as IPV6 address ***/
 if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE)
 {
 echo $ip is not a valid IP;
 }
 else
 {
 echo $ip is valid;
 }
 ?


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




PHP4 has been deprecated forever now.  Step up to the plate and get
with 5, especially if you're still writing new code.

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



Re: [PHP] IPv6 validation

2008-07-12 Thread Yeti
It will still take some time until every provider has PHP5 running, at least
where I am from. I have many customers who want me to get their sites
running on some cheap webspace they got along with their internet
connection. Then you have to tell them it won't work because of some problem
with the versions. I would love to write code for PHP5+ only.

On 7/12/08, Eric Butera [EMAIL PROTECTED] wrote:

 On Sat, Jul 12, 2008 at 9:13 AM, Bernhard Kohl [EMAIL PROTECTED] wrote:
  Doesnt filter_var() require PHP5+ ?
 
  I have quite some systems still running 4.4.8.
 
  On 7/12/08, Kevin Waterson [EMAIL PROTECTED] wrote:
 
  This one time, at band camp, Yeti [EMAIL PROTECTED] wrote:
 
   Now i was wondering of what there might be the best way to validate an
  IPv6
   address.
 
 
  from this url..
  http://phpro.org/tutorials/Filtering-Data-with-PHP.html#9
 
  ?php
 
  /*** an IP address ***/
  $ip = 2001:0db8:85a3:08d3:1319:8a2e:0370:7334;
 
  /*** try to validate as IPV6 address ***/
  if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE)
  {
  echo $ip is not a valid IP;
  }
  else
  {
  echo $ip is valid;
  }
  ?
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


 PHP4 has been deprecated forever now.  Step up to the plate and get
 with 5, especially if you're still writing new code.



Re: [PHP] OT - RE: [PHP] scalable web gallery

2008-07-12 Thread David Giragosian
On 7/12/08, tedd [EMAIL PROTECTED] wrote:

 At 9:13 AM -0500 7/12/08, David Giragosian wrote:

  Todd Boyd recently offered:

  Haven't taken a distributed computing class just yet, but I've still got
  a bit until I graduate, and these elective credits are burning a hole in
  my pocket...


 The cost of public colleges and universities, as well as community
 colleges,
 are truly astounding these days. I for one am quite happy learning from
 books, web tutorials and the occasional ( ;-g ) mailing list thread.

 --David.


 Yes, but college degrees are the bill of goods we've been sold. We are lead
 to believe that if our children (and us) go to colleges and get that
 sheepskin then everything will be great for the rest of our lives. But
 unfortunately, that's not true.

 In the meantime, academia and politician still demand more funding waving
 the same banner of yesteryear -- Your children's education needs improving
 -- while continuing to fail miserably in the global arena.

 Like with everything else, you really don't realize the problem until you
 bounce off the bottom. We just haven't reached that yet, but we're doing our
 level best to get there.

 Cheers (I guess),

 tedd


We had an article in our local paper yesterday about the guy that made and
'starred' in the video that Daniel posted about here a couple of weeks ago
(Matt of 'Where in the World is Matt', fame). Seems his father didn't think
he was mature enough to be able to benefit from college, and he was advised
to do some traveling instead. That apparently led to an early version of the
current 15-minutes-of-fame video. When I read that, I thought, not everybody
is buying into the college degree to 'success' route. But that I'm sure is
the exception rather than the rule. I think the bigger problem, for
education and the USA at least, is that there are few middle-class jobs to
be prepared for, despite what you might learn in school. Learning for the
sake of learning is wonderful, and yes, I think it does benefit society by
broadening one's perspective, but as a path to financial success, defined
here as being able to support yourself and raise a family, I agree that a
college degree is a dicey undertaking for the expense.

(And to be clear, I've completed 10 years of post high school education.)

--David.


[PHP] Passing arguments as they are received to another function

2008-07-12 Thread Luigi Perroti
Hello, I'm trying to implement a few simple wrappers for some PHP functions.

Here's an example of what I'm trying to do:

function myWrapper() {
return defaultPhpFunction(func_get_args());
}

The example above is broken since I'm just passing an array to the original
function.

The only way to achieve the desired result that I've found is something like
this:

function myWrapper() {
$argsNumber = func_num_args();
if ($argsNumber == 1) {
return defaultPhpFunction(func_get_arg(0));
}
elseif ($argsNumber == 2) {
return defaultPhpFunction(func_get_arg(0), func_get_arg(1));
}
// ...
// ...
// ...
}

Since the above code is clumsy to say the least any advice would be welcome.
Thanks for your time!


Re: [PHP] Passing arguments as they are received to another function

2008-07-12 Thread James Dempster
You might want to take a look at
http://php.net/manual/en/function.call-user-func-array.php



On Sat, Jul 12, 2008 at 4:57 PM, Luigi Perroti [EMAIL PROTECTED]
wrote:

 Hello, I'm trying to implement a few simple wrappers for some PHP
 functions.

 Here's an example of what I'm trying to do:

 function myWrapper() {
return defaultPhpFunction(func_get_args());
 }

 The example above is broken since I'm just passing an array to the original
 function.

 The only way to achieve the desired result that I've found is something
 like
 this:

 function myWrapper() {
$argsNumber = func_num_args();
if ($argsNumber == 1) {
return defaultPhpFunction(func_get_arg(0));
}
elseif ($argsNumber == 2) {
return defaultPhpFunction(func_get_arg(0), func_get_arg(1));
}
// ...
// ...
// ...
 }

 Since the above code is clumsy to say the least any advice would be
 welcome.
 Thanks for your time!



Re: [PHP] OT - RE: [PHP] scalable web gallery

2008-07-12 Thread Daniel Brown
On Sat, Jul 12, 2008 at 11:36 AM, David Giragosian
[EMAIL PROTECTED] wrote:

 We had an article in our local paper yesterday about the guy that made and
 'starred' in the video that Daniel posted about here a couple of weeks ago
 (Matt of 'Where in the World is Matt', fame).

That was actually something I sent to just a few people directly.
However, if anyone wants to see it --- and I recommend it, because
it's geekily-neat --- you can view the video, entitled Dancing
2008, at this link:

http://www.wherethehellismatt.com/

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] scalable web gallery

2008-07-12 Thread Daniel Brown
On Fri, Jul 11, 2008 at 10:02 PM, tedd [EMAIL PROTECTED] wrote:

 For example, tedd.gif would compute to 4, whereas Rob.gif would be a meager
 3, and Daniel.gif would be a six (which is probably over-rated for him
 anyway).  :-)

Hope you didn't break a hip while making yourself laugh there, old man.  ;-P

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] OT - RE: [PHP] scalable web gallery

2008-07-12 Thread David Giragosian
On 7/12/08, Daniel Brown [EMAIL PROTECTED] wrote:

 On Sat, Jul 12, 2008 at 11:36 AM, David Giragosian
 [EMAIL PROTECTED] wrote:
 
  We had an article in our local paper yesterday about the guy that made
 and
  'starred' in the video that Daniel posted about here a couple of weeks
 ago
  (Matt of 'Where in the World is Matt', fame).

That was actually something I sent to just a few people directly.
 However, if anyone wants to see it --- and I recommend it, because
 it's geekily-neat --- you can view the video, entitled Dancing
 2008, at this link:

http://www.wherethehellismatt.com/


Oops. My mistake.

--David.


Re: [PHP] Passing arguments as they are received to another function

2008-07-12 Thread Luigi Perroti
On Sat, Jul 12, 2008 at 6:00 PM, James Dempster wrote:

 You might want to take a look at
 http://php.net/manual/en/function.call-user-func-array.php



Thank you very much for your suggestion.
I've looked into it but I guess this doesn't work with what I'm trying to
do, although what you suggested should indeed work perfectly with my
previous example.
Here's a snippet from the code that I'm having problems with:

class MainDatabase {
private static $mainDatabase = NULL;
private static $statement = NULL;
//...
//...
//...
public static function prepare($query) {
self::$mainDatabase-beginTransaction();
self::$statement = self::$mainDatabase-prepare($query);
}
public static function bindParam() {

self::$statement-call_user_func_array(array('PDOStatement','bindParam'),func_get_args());
// Results in:
// PHP Fatal error:  Call to undefined method
PDOStatement::call_user_func_array() ...
// I've also tried with
call_user_func_array('PDOStatement::fetchAll',func_get_args());
// but no luck, same error.
}
//...
//...
//...
}

I thought that a solution for the previous example would work in this
scenario too, but I guess this isn't the case.
Any further suggestions would be very welcome, thanks.


Re: [PHP] Passing arguments as they are received to another function

2008-07-12 Thread James Dempster
On the line where you have
self::$statement-call_user_func_array(array('PDOStatement','bindParam'),func_get_args());
try this

call_user_func_array(array(self::$statement,'bindParam'),func_get_args());

see if that works...?


On Sat, Jul 12, 2008 at 5:36 PM, Luigi Perroti [EMAIL PROTECTED]
wrote:

 On Sat, Jul 12, 2008 at 6:00 PM, James Dempster wrote:

  You might want to take a look at
  http://php.net/manual/en/function.call-user-func-array.php



 Thank you very much for your suggestion.
 I've looked into it but I guess this doesn't work with what I'm trying to
 do, although what you suggested should indeed work perfectly with my
 previous example.
 Here's a snippet from the code that I'm having problems with:

 class MainDatabase {
private static $mainDatabase = NULL;
private static $statement = NULL;
//...
//...
//...
public static function prepare($query) {
self::$mainDatabase-beginTransaction();
self::$statement = self::$mainDatabase-prepare($query);
}
public static function bindParam() {


 self::$statement-call_user_func_array(array('PDOStatement','bindParam'),func_get_args());
// Results in:
// PHP Fatal error:  Call to undefined method
 PDOStatement::call_user_func_array() ...
// I've also tried with
 call_user_func_array('PDOStatement::fetchAll',func_get_args());
// but no luck, same error.
}
//...
//...
//...
 }

 I thought that a solution for the previous example would work in this
 scenario too, but I guess this isn't the case.
 Any further suggestions would be very welcome, thanks.



Re: [PHP] Passing arguments as they are received to another function

2008-07-12 Thread Luigi Perroti
On Sat, Jul 12, 2008 at 6:42 PM, James Dempster [EMAIL PROTECTED] wrote:

 On the line where you have
 self::$statement-call_user_func_array(array('PDOStatement','bindParam'),func_get_args());
 try this

 call_user_func_array(array(self::$statement,'bindParam'),func_get_args());

 see if that works...?


Thanks, this is working fine. I only had to make the following adjustment:

  $args = func_get_args();
  call_user_func_array(array(self::$statement,'bindParam'),$args);

since func_get_args as an argument is allowed only on user defined
functions.

Thank you very much for your time!

Regards,
Luigi


Re: [PHP] IPv6 validation

2008-07-12 Thread Eric Butera
On Sat, Jul 12, 2008 at 11:24 AM, Yeti [EMAIL PROTECTED] wrote:
 It will still take some time until every provider has PHP5 running, at least
 where I am from. I have many customers who want me to get their sites
 running on some cheap webspace they got along with their internet
 connection. Then you have to tell them it won't work because of some problem
 with the versions. I would love to write code for PHP5+ only.

 On 7/12/08, Eric Butera [EMAIL PROTECTED] wrote:

 On Sat, Jul 12, 2008 at 9:13 AM, Bernhard Kohl [EMAIL PROTECTED] wrote:
  Doesnt filter_var() require PHP5+ ?
 
  I have quite some systems still running 4.4.8.
 
  On 7/12/08, Kevin Waterson [EMAIL PROTECTED] wrote:
 
  This one time, at band camp, Yeti [EMAIL PROTECTED] wrote:
 
   Now i was wondering of what there might be the best way to validate
   an
  IPv6
   address.
 
 
  from this url..
  http://phpro.org/tutorials/Filtering-Data-with-PHP.html#9
 
  ?php
 
  /*** an IP address ***/
  $ip = 2001:0db8:85a3:08d3:1319:8a2e:0370:7334;
 
  /*** try to validate as IPV6 address ***/
  if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE)
  {
  echo $ip is not a valid IP;
  }
  else
  {
  echo $ip is valid;
  }
  ?
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


 PHP4 has been deprecated forever now.  Step up to the plate and get
 with 5, especially if you're still writing new code.



I installed php5 on my local dev box years ago.  Since then, I've been
pulling down random sites off our servers and testing them and fixing
little gotchas.  Out of the hundreds of sites we host there were only
a few problems and once I figured out what those were it really became
quite easy to fix the issues with find and replace techniques.  Most
of it was limited to my oop code. ;)  So while I do understand this
argument, it is pretty old and needs to just stop.  Nobody was paying
my company to upgrade and fix code that busted in the transition.  It
is just the nature of the business.

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



Re: [PHP] OT - RE: [PHP] scalable web gallery

2008-07-12 Thread Robert Cummings
On Sat, 2008-07-12 at 10:43 -0400, tedd wrote:
 At 9:13 AM -0500 7/12/08, David Giragosian wrote:
   Todd Boyd recently offered:
 
   Haven't taken a distributed computing class just yet, but I've still got
   a bit until I graduate, and these elective credits are burning a hole in
   my pocket...
 
 The cost of public colleges and universities, as well as community colleges,
 are truly astounding these days. I for one am quite happy learning from
 books, web tutorials and the occasional ( ;-g ) mailing list thread.
 
 --David.
 
 Yes, but college degrees are the bill of goods we've been sold. We 
 are lead to believe that if our children (and us) go to colleges and 
 get that sheepskin then everything will be great for the rest of our 
 lives. But unfortunately, that's not true.

That may be why you went... but I triple major'd in drinking beer and
picking up chicks... hence the extra years I put in and all the
psychology electives ;)

It was well worth the investment... I met my wife there and our third
child will arrive in October.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] scalable web gallery

2008-07-12 Thread Robert Cummings
On Sat, 2008-07-12 at 12:03 -0400, Daniel Brown wrote:
 On Fri, Jul 11, 2008 at 10:02 PM, tedd [EMAIL PROTECTED] wrote:
 
  For example, tedd.gif would compute to 4, whereas Rob.gif would be a meager
  3, and Daniel.gif would be a six (which is probably over-rated for him
  anyway).  :-)
 
 Hope you didn't break a hip while making yourself laugh there, old man.  
 ;-P

Does it count if I broke a sweat?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] scalable web gallery

2008-07-12 Thread tedd

At 12:03 PM -0400 7/12/08, Daniel Brown wrote:

On Fri, Jul 11, 2008 at 10:02 PM, tedd [EMAIL PROTECTED] wrote:


 For example, tedd.gif would compute to 4, whereas Rob.gif would be a meager
 3, and Daniel.gif would be a six (which is probably over-rated for him
 anyway).  :-)


Hope you didn't break a hip while making yourself laugh there, 
old man.  ;-P


Hey, let's knock off that old shit, newlywed !

Just because you finally got laid doesn't mean you can beat me in 
memory loss. :-)


Cheers,

tedd

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

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



Re: [PHP] scalable web gallery

2008-07-12 Thread Robert Cummings
On Sat, 2008-07-12 at 14:37 -0400, tedd wrote:
 At 12:03 PM -0400 7/12/08, Daniel Brown wrote:
 On Fri, Jul 11, 2008 at 10:02 PM, tedd [EMAIL PROTECTED] wrote:
 
   For example, tedd.gif would compute to 4, whereas Rob.gif would be a 
  meager
   3, and Daniel.gif would be a six (which is probably over-rated for him
   anyway).  :-)
 
  Hope you didn't break a hip while making yourself laugh there, 
 old man.  ;-P
 
 Hey, let's knock off that old shit, newlywed !
 
 Just because you finally got laid doesn't mean you can beat me in 
 memory loss. :-)

Just because he got married doesn't mean he got laid :P

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] scalable web gallery

2008-07-12 Thread Daniel Brown
On Sat, Jul 12, 2008 at 2:37 PM, tedd [EMAIL PROTECTED] wrote:

 Hey, let's knock off that old shit, newlywed !

 Just because you finally got laid doesn't mean you can beat me in memory
 loss. :-)

That's lei'd, sir.

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] OT - RE: [PHP] scalable web gallery

2008-07-12 Thread tedd

At 2:35 PM -0400 7/12/08, Robert Cummings wrote:

On Sat, 2008-07-12 at 10:43 -0400, tedd wrote:
  Yes, but college degrees are the bill of goods we've been sold. We

 are lead to believe that if our children (and us) go to colleges and
 get that sheepskin then everything will be great for the rest of our
 lives. But unfortunately, that's not true.


That may be why you went... but I triple major'd in drinking beer and
picking up chicks... hence the extra years I put in and all the
psychology electives ;)

It was well worth the investment... I met my wife there and our third
child will arrive in October.

Cheers,
Rob.


Well, most of us can have kids without college instruction.  :-)

I didn't go to college to make money, I went for other reasons. But, 
that didn't stop me from making and spending a couple million. 
College should have taught me how to save.


Cheers,

tedd

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

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



Re: [PHP] IPv6 validation

2008-07-12 Thread Kevin Waterson
This one time, at band camp, Yeti [EMAIL PROTECTED] wrote:

 It will still take some time until every provider has PHP5 running, at least
 where I am from. I have many customers who want me to get their sites
 running on some cheap webspace they got along with their internet
 connection. Then you have to tell them it won't work because of some problem
 with the versions. I would love to write code for PHP5+ only.This is a 
 terrible excuse for using 

PHP 4. Today, July 13, marks 4 years since
the release of PHP 5.0. _4 YEARS_ to move applications and code to PHP5.

Its either apathy or incometence.
Kevin

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



Re: [PHP] IPv6 validation

2008-07-12 Thread Robert Cummings
On Sun, 2008-07-13 at 07:02 +1000, Kevin Waterson wrote:
 This one time, at band camp, Yeti [EMAIL PROTECTED] wrote:
 
  It will still take some time until every provider has PHP5 running, at least
  where I am from. I have many customers who want me to get their sites
  running on some cheap webspace they got along with their internet
  connection. Then you have to tell them it won't work because of some problem
  with the versions. I would love to write code for PHP5+ only.This is a 
  terrible excuse for using 
 
 PHP 4. Today, July 13, marks 4 years since
 the release of PHP 5.0. _4 YEARS_ to move applications and code to PHP5.
 
 Its either apathy or incometence.

I think apathy... for those who don't give a damn about OOP or the
advanced OOP features, PHP5 brought little to the table while often
requiring work to get your code there. Then followed multiple versions
each with their own quirks all the while tightening a noose of OOP
correctness around the developer who didn't care about some purists OOP
philosophies. Finally, and this isn't particularly true anymore, PHP5
was much slower in earlier versions.

And yes, I've modified my own code as things have progressed, but I
certainly do have clients that didn't want me wasting their money
converting their code-base (not originally written by me) to PHP5. And
yes, I've seen terrible things in the code that PHP5 certainly did
break. And again, yes, some of this was due to poor coding on the
original developer's part... but hey, it DID work in PHP4.

By forcing an end of life, PHP did a favour to all those developers who
couldn't really make the case to their bosses or clients by forcing it
upon them. The issue became much more salient at that point.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Most popular per month

2008-07-12 Thread Wolf

snip
..
.
$perc50=(img50 int)/$total;

You can do it per day, per month, per year, per 28 days, per PMS cycle, 
per anything you want provided you have the data to do it.

/snip

:) this is the part where i am a bit confused actually, can you give me one or 
two examples and i'll work from there?



What you have to do is get all the pictures viewed for a specific 
day/time frame (you said this was all tracked in a DB anyways) and then 
add up all the totals and perform the same calculations using the views 
all added over the days all added.


$img1=img1 int day1 +img1 int day2 +img1 int day3  img1 int day30
$total= img1 int day1 +img2 int day 1+img3 int day1 +...img50 int day30

$img1perc= $img1/$total


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



[PHP] PDO Question. Number of rows returned

2008-07-12 Thread Stephen

I am switching to PDO and can't find an equivalent to mysql_num_rows.

Am I missing something silly?

Or is there a change of thinking needed for PDO?

How should I determine how many rows a query returned?

Thanks
Stephen

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



Re: [PHP] Most popular per month

2008-07-12 Thread Brady Mitchell


On Jul 11, 2008, at 555PM, Ryan S wrote:
before the next days counter starts this data is stored in a table  
which has a simple structure like this

img_id1 int,img_id2 int  (etc till img_id10)


That sounds like a painful db structure to deal with if you want to  
add more images in the future. I'd suggest a structure more like:


img_id
date_viewed
counter

Where counter is simply the number of times the specified image was  
viewed on that day. I just finished writing a blog post about a  
similar requirement that may help - http://bradym.net/mysql/logging-requests-with-mysql 
.


Now the client wants a little extra functionality, and with me  
sucking at maths I need some help please, basically he now wants to  
have a chart with all the 50 images there and showing _via  
percentages_ instead of the present 1-10 display which ones are the  
most popular till date.


You get the percentage simply by dividing the number of requests for a  
specific image by the total number of requests for all images. So if  
you had the following data:


img1 - 50 views
img2 - 20 views
img3 - 15 views
img4 - 10 views
img5 - 5 views

To get the total, you would just add all those views together (100) in  
this case. Then for the percentages just divide each one by 100, ie:  
$img1_percent = 50 / 100;


Also, if i am not mistaken there was some charting software to  
display this kind of data in pie and line charts... anybody know  
what i am talking about? because i cant find such a link in my  
bookmarks.


There are several options for charting, here's a post I came across  
earlier in the week with some options: http://free-wiz.blogspot.com/2008/07/best-free-chart-apis.html 
.


Brady

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



[PHP] Saving loading time at counting rows

2008-07-12 Thread Joep Roebroek
I had this question, which I didn't really know where to ask, so I
thought to begin at this mailing list.

Very basicly said, I count the rows of a table which had approx 5
or more rows.

The problem is, there is a notable difference in loading time with
other pages. Is there a technique to estimate the number of rows
instead of exactly couting them? So that it saves loading time.

For example, when you search with google, you get an estimate of the
number of results, how do they do this?

Maybe this is not a question for the PHP Mailing list, but if not
where is a better place to ask this?

regards,

Joep

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



Re: [PHP] Saving loading time at counting rows

2008-07-12 Thread tedd

At 2:26 AM +0200 7/13/08, Joep Roebroek wrote:

I had this question, which I didn't really know where to ask, so I
thought to begin at this mailing list.

Very basicly said, I count the rows of a table which had approx 5
or more rows.

The problem is, there is a notable difference in loading time with
other pages. Is there a technique to estimate the number of rows
instead of exactly couting them? So that it saves loading time.

For example, when you search with google, you get an estimate of the
number of results, how do they do this?

Maybe this is not a question for the PHP Mailing list, but if not
where is a better place to ask this?

regards,

Joep


Joep:

If it was me and the number of rows were not critical, then I would 
do it once a day and store that count in a table where I needed an 
approximate number. Then loading that number for the rest of the day 
would be instant.


You don't need a cron job for that, just tie a date to the count 
entry and have each access to it compare the date with current date. 
If the date is 24 hours since the last update, then that lucky person 
has to wait a bit longer than most while a count is establish and 
recorded.


Cheers,

tedd


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

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



Re: [PHP] Saving loading time at counting rows

2008-07-12 Thread Robert Cummings
On Sat, 2008-07-12 at 23:22 -0400, tedd wrote:
 At 2:26 AM +0200 7/13/08, Joep Roebroek wrote:
 I had this question, which I didn't really know where to ask, so I
 thought to begin at this mailing list.
 
 Very basicly said, I count the rows of a table which had approx 5
 or more rows.

You are counting all the rows, or only rows mathcing a specific set of
criteria? Have you checked that you are indexing appropriate columns?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] PDO Question. Number of rows returned

2008-07-12 Thread Kevin Waterson
This one time, at band camp, Stephen [EMAIL PROTECTED] wrote:

 I am switching to PDO and can't find an equivalent to mysql_num_rows.
 
 Am I missing something silly?
 
 Or is there a change of thinking needed for PDO?
 
 How should I determine how many rows a query returned?

PDO returns an array, sizeof/count will get you home

Kevin
http://phpro.org

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