OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 7 Feb 2008 19:42:59 -0000 Issue 5280

php-general-digest-helplists.php.net
Date: Thu Feb 07 2008 - 13:42:59 CST


php-general Digest 7 Feb 2008 19:42:59 -0000 Issue 5280

Topics (messages 268850 through 268898):

Re: Exception handling in PHP
        268850 by: Paul Scott
        268852 by: Prabath Kumarasinghe
        268853 by: Paul Scott
        268860 by: Richard Heyes
        268861 by: Richard Heyes

Re: Passing object reference to session
        268851 by: Jochem Maas
        268854 by: Michael Moyle
        268859 by: Jochem Maas

Re: Recommended ORM for PHP
        268855 by: Zoltán Németh
        268880 by: Manuel Lemos
        268886 by: Nathan Nobbe

Re: PHP Source code protection
        268856 by: Per Jessen
        268857 by: Per Jessen
        268858 by: Richard Heyes
        268894 by: Casey

Re: Multiple MySQL INSERT into loop
        268862 by: Colin Guthrie
        268863 by: Paul Scott
        268891 by: Jim Lucas

PHP setup
        268864 by: Louie Henry
        268865 by: Jochem Maas
        268870 by: Dare Williams
        268875 by: Nathan Nobbe
        268876 by: Daniel Brown
        268887 by: Robert Cummings

problem with imagefontwidth function, It looks to be unavailable...
        268866 by: Legolas wood
        268867 by: Jochem Maas
        268882 by: Daniel Brown
        268888 by: David Giragosian

Re: date() and wrong timezone (or time)
        268868 by: Jochem Maas
        268873 by: Martin Marques
        268879 by: Daniel Brown
        268884 by: David Giragosian
        268889 by: Eric Butera

Re: Schedule tasks from server
        268869 by: David Robley

Re: shopping carts
        268871 by: Eric Butera
        268872 by: Jason Pruim
        268874 by: Eric Butera
        268877 by: Nathan Nobbe
        268878 by: Daniel Brown
        268883 by: Eric Butera
        268885 by: Eric Butera

Re: PHP/mySQL question about groups
        268881 by: Andrew Ballard
        268890 by: Warren Vail

Directory
        268892 by: Steve Marquez
        268893 by: Paul Scott
        268895 by: Jim Lucas

Profiling with register_tick_function / declare
        268896 by: McNaught, Scott
        268898 by: Shawn McKenzie

urgently help required in integration of PHP and Geronimo
        268897 by: puneetjain

Administrivia:

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

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

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

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

attached mail follows:


On Wed, 2008-02-06 at 23:37 -0800, Prabath Kumarasinghe wrote:
> Does that mean for every exception do we have to write
> our custom exception and describe it from our own
> message
>

No, it means that when you want to throw a meaningful exception, you
need to type in a message. I mentioned custom exceptions, because that
is what I do, as I multilingualise my messages and do other things with
the exception, like display an XHTML page to the users.

--Paul

All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm

attached mail follows:


Understood, Thanks Paul

Cheers
Prabath
--- Paul Scott <pscottuwc.ac.za> wrote:

>
> On Wed, 2008-02-06 at 23:37 -0800, Prabath
> Kumarasinghe wrote:
> > Does that mean for every exception do we have to
> write
> > our custom exception and describe it from our own
> > message
> >
>
> No, it means that when you want to throw a
> meaningful exception, you
> need to type in a message. I mentioned custom
> exceptions, because that
> is what I do, as I multilingualise my messages and
> do other things with
> the exception, like display an XHTML page to the
> users.
>
> --Paul
>
> > All Email originating from UWC is covered by
> disclaimer
>
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
>
>

      ____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping

attached mail follows:


On Thu, 2008-02-07 at 00:20 -0800, Prabath Kumarasinghe wrote:
> Understood, Thanks Paul
>

Pleasure, but please don't top post, it makes it really hard to follow a
thread easily. Most people on this list take time out from their really
busy day jobs to help out, and the more time that everyone can save
them, the better.

--Paul

All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm

attached mail follows:


> Does that mean for every exception do we have to write
> our custom exception and describe it from our own
> message

If you mean "Do I have to write custom exception classes?", the no. You
could just use the PHP Exception class.

Eg.

class DBException extends Exception {}

try {
     $connection = mysql_connect(...);

     if (!$connection) {
         throw new DBException('Failed to connect to database');
     }

// Database exception handling code
} catch (DBException $e) {
     // ...

// Generic Exception handling code (The Exception c
} catch Exception $e {
     // ...
}

That's from memory, so there may be a few errors.

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and Helpdesk software for £299 hosted for you -
no installation, no maintenance, new features automatic and free

              ** New Helpdesk demo now available **

attached mail follows:


// ...
> That's from memory, so there may be a few errors.

Seems there was. Try this:

class DBException extends Exception {}

try {
     $connection = mysql_connect(...);

     if (!$connection) {
         throw new DBException('Failed to connect to database');
     }

// Database exception handling code
} catch (DBException $e) {
     // ...

// Generic Exception handling code (The Exception class is
// built in to PHP)
} catch (Exception $e) {
     // ...
}

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and Helpdesk software for £299 hosted for you -
no installation, no maintenance, new features automatic and free

              ** New Helpdesk demo now available **

attached mail follows:


Michael Moyle schreef:
> Hi,
>
> I am new to the list and have a question that inspired me to join the
> list as I can not find any answer online.
>
> When a object reference is passed to the $_SESSION array what happens to

let's assume php5. all objects are reference like, they behave from a user POV
as objects would in php4 if you passed them by reference explicitly.

that said they're not really references - there is a Sara Golemon article which
explains it ... not that I truely understand the inner machinations of the engine.

> the object? Is the object serialized and saved in session (in this case
> file)? Or just the reference with the object in memory remaining on the
> heap?

php is 'share nothing' architecture ... everything disappears at the end of a
request - nothing remains in memory.

an object stored in $_SESSION will be automatically serialized and saved where ever
the session data is saved (usually to disk).

the only thing to remember is that you must have the class of the object stored in
$_SESSION loaded *before* you restart the session otherwise php will generate an
object of class stdClass.

>

attached mail follows:


Jochem,

On Thu, 2008-02-07 at 09:11 +0100, Jochem Maas wrote:
> Michael Moyle schreef:
> > Hi,
> >
> > I am new to the list and have a question that inspired me to join the
> > list as I can not find any answer online.
> >
> > When a object reference is passed to the $_SESSION array what happens to
>
> let's assume php5. all objects are reference like, they behave from a user POV
> as objects would in php4 if you passed them by reference explicitly.
>
> that said they're not really references - there is a Sara Golemon article which
> explains it ... not that I truely understand the inner machinations of the engine.
>
Thanks. I believe the article is :

http://blog.libssh2.org/index.php?/archives/51-Youre-being-lied-to..html

> > the object? Is the object serialized and saved in session (in this case
> > file)? Or just the reference with the object in memory remaining on the
> > heap?
>
> php is 'share nothing' architecture ... everything disappears at the end of a
> request - nothing remains in memory.
>
> an object stored in $_SESSION will be automatically serialized and saved where ever
> the session data is saved (usually to disk).

That's right. That makes perfect sense.

>
> the only thing to remember is that you must have the class of the object stored in
> $_SESSION loaded *before* you restart the session otherwise php will generate an
> object of class stdClass.

Indeed. That has happened to me before.

--
best regards,
Michael

attached mail follows:


Michael Moyle schreef:
> Jochem,
>
> On Thu, 2008-02-07 at 09:11 +0100, Jochem Maas wrote:
>> Michael Moyle schreef:
>>> Hi,
>>>
>>> I am new to the list and have a question that inspired me to join the
>>> list as I can not find any answer online.
>>>
>>> When a object reference is passed to the $_SESSION array what happens to
>> let's assume php5. all objects are reference like, they behave from a user POV
>> as objects would in php4 if you passed them by reference explicitly.
>>
>> that said they're not really references - there is a Sara Golemon article which
>> explains it ... not that I truely understand the inner machinations of the engine.
>>
> Thanks. I believe the article is :
>
> http://blog.libssh2.org/index.php?/archives/51-Youre-being-lied-to..html

yup, that's the one ... good stuff, Sara knows her **** :-)

attached mail follows:


2008. 02. 6, szerda keltezéssel 18.50-kor Manuel Lemos ezt írta:
> on 02/06/2008 11:10 AM js said the following:
> > Hi list,
> >
> > When creating a LAMP app, I always start by writing ORM myself.
> > It's fun but it usually takes a long time.
> > Besides, that always results in a toy-system,
> > I mean, that has not so many features, not so efficient non-bug-free.
> >
> > I started to think that now is the time to throw away my rubbish
> > and use more effective Open source ORM.
> >
> > So my question is what ORM are you using?
> > What ORM do you recommend?
> > There're lots of Web app frameworks out there
> > but I could't find simple ORM in PHP.
>
> A similar question was asked here a couple of days ago.
>
> I will be repeating myself, but what I said was that I use Metatsorage
> which is an ORM class generator tool. It is a different approach than
> others you may find. It generates persistent object classes that are
> smaller and more efficient.

that's exactly the same method all the ORMs we mentioned earlier
(Doctrine, Propel, Qcodo) work. all these generate classes. ;P

aside from that, metastorage might be as good as any of the others of
course

greets
Zoltán Németh

>
> You may find more about Metastorage here:
>
> http://www.meta-language.net/metastorage.html
>
> Here you may find a small example application:
>
> http://www.meta-language.net/metanews.html
>
> Here you may see some screenshots of the Web user interface of the
> generator tool and screenshots of the applications:
>
> http://www.meta-language.net/screenshots.html
>
> --
>
> Regards,
> Manuel Lemos
>
> PHP professionals looking for PHP jobs
> http://www.phpclasses.org/professionals/
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>

attached mail follows:


Hello

on 02/07/2008 07:26 AM Zoltán Németh said the following:
>>> When creating a LAMP app, I always start by writing ORM myself.
>>> It's fun but it usually takes a long time.
>>> Besides, that always results in a toy-system,
>>> I mean, that has not so many features, not so efficient non-bug-free.
>>>
>>> I started to think that now is the time to throw away my rubbish
>>> and use more effective Open source ORM.
>>>
>>> So my question is what ORM are you using?
>>> What ORM do you recommend?
>>> There're lots of Web app frameworks out there
>>> but I could't find simple ORM in PHP.
>> A similar question was asked here a couple of days ago.
>>
>> I will be repeating myself, but what I said was that I use Metatsorage
>> which is an ORM class generator tool. It is a different approach than
>> others you may find. It generates persistent object classes that are
>> smaller and more efficient.
>
> that's exactly the same method all the ORMs we mentioned earlier
> (Doctrine, Propel, Qcodo) work. all these generate classes. ;P
>
> aside from that, metastorage might be as good as any of the others of
> course

I don't know about Doctrine and QCodo, but once I looked at Propel and
the way it works was not exactly better than Metastorage generated
classes from my point of view.

What happens is that Propel relies on fat base classes that the
generated persistent object classes need to inherit to do the actual
Object-relational mapping.

Metastorage generates self-contained code. This means the generated
classes are root classes that do only what you need. The generated code
does the necessary database calls directly to store and retrieve objects.

It does not call base classes like Propel generated classes that waste
time composing SQL queries at run-time. Metastorage generated classes
already have the necessary SQL built-in to execute the queries without
further analysis at run-time.

Another aspect is that Metastorage features what is called report
classes. These are classes that perform queries that you define and
generates SQL and PHP at compile time to retrieve data from the
persistent objects for read-only purposes.

For instance, if you want to send a newsletter to a million subscribers
and you just need the e-mail address and names of the subscribers, you
can tell Metastorage to generate a report class that queries the users
objects and retrives just the name and e-mail address. The report
classes return arrays just like plain SELECT queries.

If you use the Propel approach you would need to retrieve 1 million
objects of the users class just to pick the name and e-mail address,
which is totally inefficient in terms of memory and very slow.

There are more differences between Metastorage and Propel (and probably
others approach). I just wanted to make the point that the fact that
approaches use generated code, it does not mean that all provide the
same efficiency.

If you are interested about more differences in the approaches, you may
check the Metastorage documentaion:

http://www.metastorage.net/

--

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

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

attached mail follows:


On Feb 7, 2008 10:15 AM, Manuel Lemos <mlemosacm.org> wrote:

> What happens is that Propel relies on fat base classes that the
> generated persistent object classes need to inherit to do the actual
> Object-relational mapping.

this is so that there is a customizable layer that will not be impacted by
subsequent regeneration. qcodo has the same concept and i suspect
doctrine does as well.

Metastorage generates self-contained code. This means the generated
> classes are root classes that do only what you need.

Then they must themselves be 'fat'; using inheritance to encapsulate common
functionality is obviously a sound technique.

> The generated code
> does the necessary database calls directly to store and retrieve objects.

So does propel.

> It does not call base classes like Propel generated classes that waste
> time composing SQL queries at run-time. Metastorage generated classes
> already have the necessary SQL built-in to execute the queries without
> further analysis at run-time.

It has *all* the necessay sql embedded in it? i find this hard to believe.
say
for example i run a query without a limit clause; then i want to run the
same
query with a limit clause; it is simply impractical to pre-write 2 queries,
one
with a limit clause and one without it into the code at compile time.
moreover
i sincerely doubt this is the approach theyve taken because if you just sit
and
think about it for a second, with even a small number of tables the
permutations
on the set of all possible queries would be staggering. such classes that
would
encapsulate said number of permutations would be way beyond 'fat',
i would imagine. so im guessing metastorage does some sort of query
composition at runtime.

> Another aspect is that Metastorage features what is called report
> classes. These are classes that perform queries that you define and
> generates SQL and PHP at compile time to retrieve data from the
> persistent objects for read-only purposes.

so you save some time building queries at runtime for special cases;
thats kind of nice; but i dont think it takes much time to actually build
a query anyway.

For instance, if you want to send a newsletter to a million subscribers
> and you just need the e-mail address and names of the subscribers, you
> can tell Metastorage to generate a report class that queries the users
> objects and retrives just the name and e-mail address. The report
> classes return arrays just like plain SELECT queries.

thats great, arrays are a little more lean than objects; but obviously they
are not wrapped with any additional functionality; such as the ability to
fetch
the value of a record in a related table or alter the current value.

> If you use the Propel approach you would need to retrieve 1 million
> objects of the users class just to pick the name and e-mail address,
> which is totally inefficient in terms of memory and very slow.

well lets just remember that even though arrays are just data and therefore
less expensive in terms of memory and quicker to iterate; there would still
be 1 million arrays of data.

> There are more differences between Metastorage and Propel (and probably
> others approach). I just wanted to make the point that the fact that
> approaches use generated code, it does not mean that all provide the
> same efficiency.

i would like to see some benchmarks of propel vs. metastorage. i would do
them myself except that i simply dont have time to do a proper experiment in
the near future. i will certainly consider an analysis of metastorage for a
rainy
day though.

-nathan

attached mail follows:


John Taylor-Johnston wrote:

> I'm not sure where PHP stands on this politically. But I believe in
> Open Source, which allows you to encode your code. But why? At heart
> I'm a purist GNU. Stallman was right when he first tried to fix a
> faulty printer.

I too believe in Open Source, but there are times when the only way to
protect your competitive advantage is to hide your code.

/Per Jessen, Zürich

attached mail follows:


Richard Lynch wrote:

> After you get your PHP code all worked out, re-write it as a custom
> PHP extension -- or even just the core of it, and send them a .so or
> .dll to install.

Interesting option. Does require more effort, but if you rewrite the
whole thing in C, you might gain some performance too. Of course, once
you've done that, you might even leave PHP out of it, and just run it
as a binary.

/Per Jessen, Zürich

attached mail follows:


Greg Donald wrote:
> On 2/6/08, Richard Heyes <richardhphpguru.org> wrote:
>> There's the Zend Encoder at www.zend.com. Though it may be called
>> something else now.
>
> Pointless.
>
> http://www.phprecovery.com/

Pointless? I think it is exactly the answer to the original persons
question.

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and Helpdesk software for £299 hosted for you -
no installation, no maintenance, new features automatic and free

attached mail follows:


On Feb 7, 2008 1:50 AM, Richard Heyes <richardhphpguru.org> wrote:
> Greg Donald wrote:
> > On 2/6/08, Richard Heyes <richardhphpguru.org> wrote:
> >> There's the Zend Encoder at www.zend.com. Though it may be called
> >> something else now.
> >
> > Pointless.
> >
> > http://www.phprecovery.com/
>
> Pointless? I think it is exactly the answer to the original persons
> question.
>
> --
> Richard Heyes
> http://www.websupportsolutions.co.uk
>
> Knowledge Base and Helpdesk software for £299 hosted for you -
> no installation, no maintenance, new features automatic and free
>

Why not just translate it to C#?

--
-Casey

attached mail follows:


Rob G wrote:
> //BEGIN EXAMPLE
>
>
>
> mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_1',
> '$entry_1', '$name_1')");
>
>
>
> mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_2',
> '$entry_2', '$name_2')");
>
>
>
> mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_3',
> '$entry_3', '$name_3')");
>
>
>
> //END EXAMPLE
>
>
> I'd like to put this into a loop, so that the variable that are being
> defined as the VALUES change as needed.
>
>
>
> //BEGIN EXAMPLE
> while ($i<16)
> {
> $i++;
> mysql_query ("INSERT INTO testimonials (id,quote,name) VALUES ('$id_1',
> '$entry_1', '$name_1')");)");
> }
>
> //END EXAMPLE
>
> What I'm trying to figure out, is exactly how I need to format my entry
> within the VALUES section, so that it will change based on the value of $i.

Simplest way would be to define your data in an array instead:

e.g. $data = array(1 => array('id' => x, 'entry' => y, 'name' => z), ...).

Then you can do:
mysql_query ("INSERT INTO testimonials (id,quote,name) VALUES
('".$data[$i]['id']."','".$data[$i]['entry']."','".$data[$i]['name']."');");

(normal rules about escaping data should apply to the above - e.g. pass
unsafe values through mysql_real_escape_string rather than put the
quotes in yourself)

Of course if you are inserting a lot of data with mysql, it's *much*
faster to use the extended instert syntax:

INSERT INTO table (col1, col2) VALUES (val1a, val1b),(val2a, val2b),(...);

HTHs

Col

attached mail follows:


On Thu, 2008-02-07 at 10:55 +0000, Colin Guthrie wrote:
> Simplest way would be to define your data in an array instead:
>
> e.g. $data = array(1 => array('id' => x, 'entry' => y, 'name' => z), ...).
>

And of course to tie it all into a transaction that can be rolled back
in case of problems.

--Paul

All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm

attached mail follows:


Rob G wrote:
> I'm working on this, and am not sure how the variable syntax needs to be
> here.
>
> This is what I have done manually.
>
> //BEGIN EXAMPLE
> mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_1',
> '$entry_1', '$name_1')");
>
> mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_2',
> '$entry_2', '$name_2')");
>
> mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_3',
> '$entry_3', '$name_3')");
>
> //BEGIN EXAMPLE
> while ($i<16) {
> $i++;
> mysql_query ("INSERT INTO testimonials (id,quote,name) VALUES ('$id_1',
> '$entry_1', '$name_1')");)");

You are looking for variable variables

http://us3.php.net/manual/en/language.variables.variable.php

example of what is going on.

<?php

# Variable Variables Test

$id_0 = 'zero';
$id_1 = 'one';
$id_2 = 'two';
$id_3 = 'three';

for ( $i=0; $i<4; $i++ ) {
        echo ${'id_'.$i};
}

?>

So, for what you are wanting to do. I would do something like this.

<?php

#
# Your other code here
#

for ( $i=1; $i<=16; $i++ ) {

        $SQL = "INSERT INTO testimonials (id,quote,name)
             VALUES (
                  '".${'id_'.$i}."',
                  '".${'entry_'.$i}."',
                  '".${'name_'.$i}."'
                 )
               ";

         echo $SQL;

# mysql_query ( $SQL );

}

?>

> }
> //END EXAMPLE
>
>
> What I'm trying to figure out, is exactly how I need to format my entry
> within the VALUES section, so that it will change based on the value of $i.

--
Jim Lucas

    "Some men are born to greatness, some achieve greatness,
        and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
     by William Shakespeare

attached mail follows:


Good Day All

 

I am running windows xp pro and using built in IIS as my web-server. And I
installed PHP 5.2.5. I also installed MySQL 5.0.37. Now PHP is working, how
ever I having problems with the configuration with MySQL.

I used phpinfo(), and I notice this

doc_root no value no value

extension_dir C:\php5 C:\php5

 

I did edit my php.ini file:

include_path ="C:\PHP;C:\PHP\ext"

doc_root ="C:\Inetpub\wwwroot"

extension_dir ="C:\PHP\ext"

 

And windows systems paths I have C:\PHP; and it shows up in the path
command.

 

I do not understand why it’s not using the php.ini file or what I am doing
wrong.

 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.19.21/1263 - Release Date: 06/02/2008
8:14 PM
 

attached mail follows:


Louie Henry schreef:
> Good Day All
>
>
>
> I am running windows xp pro and using built in IIS as my web-server. And I
> installed PHP 5.2.5. I also installed MySQL 5.0.37. Now PHP is working, how
> ever I having problems with the configuration with MySQL.
>
> I used phpinfo(), and I notice this
>
> doc_root no value no value
>
> extension_dir C:\php5 C:\php5

the output of phpinfo() also tells you where pp is loading in php.ini from (or
trying to load it in).

my guess is the php.ini your editing is not located where php is looking for it.

>
>
>
> I did edit my php.ini file:
>
> include_path ="C:\PHP;C:\PHP\ext"
>
> doc_root ="C:\Inetpub\wwwroot"
>
> extension_dir ="C:\PHP\ext"
>
>
>
> And windows systems paths I have C:\PHP; and it shows up in the path
> command.
>
>
>
> I do not understand why it’s not using the php.ini file or what I am doing
> wrong.
>
>
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.21/1263 - Release Date: 06/02/2008
> 8:14 PM
>
>

attached mail follows:


To solve this problem, I will advice you to probably remove all the former installation. Because PHP do have problem relating to IIS several times.
   
  so it better you install complete pack of PHP Application.
  You can use a PHP Application call WAMP SERVER. It's good PHP Application for deploying.
  WAMP means WINDOWS(os) - APACHE(webserver) - MYSQL(db) - PHP(platform).
  With this, I think you should be okie because there won't be any need to start a new configuration in PHP.INI file.
  You can get WAMP Server from: http://www.wampserver.com/en/download.php
   
   
  Regards.
  Williams

       
---------------------------------
Looking for last minute shopping deals? Find them fast with Yahoo! Search.

attached mail follows:


On Feb 7, 2008 8:47 AM, Dare Williams <darrenwillyyahoo.com> wrote:

> WAMP means WINDOWS(os) - APACHE(webserver) - MYSQL(db) - PHP(platform).

you know if youre running iis and mysql or mssql, its actually called the
WIMP stack ;)

-nathan

attached mail follows:


2008/2/7 Louie Henry <louiehenrybrktel.on.ca>:
> Good Day All

    What's up, Louie?

> I am running windows xp pro and using built in IIS as my web-server. And I
> installed PHP 5.2.5. I also installed MySQL 5.0.37. Now PHP is working, how
> ever I having problems with the configuration with MySQL.
[snip!]
> I do not understand why it's not using the php.ini file or what I am doing
> wrong.

    From your explanation of the steps you took, it sounds to me like
you forgot to restart your HTTP server (in this case, IIS). Restart
that and all should work as planned.

    Changes to configuration files (such as php.ini) are "read in" to
the servers (daemons) when they are executed, and can't be changed
dynamically. The same goes for MySQL, Apache, SSH, et cetera.

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


On Thu, 2008-02-07 at 09:52 -0500, Nathan Nobbe wrote:
> On Feb 7, 2008 8:47 AM, Dare Williams <darrenwillyyahoo.com> wrote:
>
> > WAMP means WINDOWS(os) - APACHE(webserver) - MYSQL(db) - PHP(platform).
>
>
> you know if youre running iis and mysql or mssql, its actually called the
> WIMP stack ;)

Such an apt name :)

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

attached mail follows:


Hi
Thank you for reading my post
I am trying to run a php based application using php5 and apache.
but I receive an error like:

*Fatal error*: Call to undefined function imagefontwidth() in */var/www/v603/includes/functions.php* on line *28*

when line 28 and its surrounding lines are:

## create an image not a text for the pin

    $font = 6;

    $width = imagefontwidth($font) * strlen($generated_pin);

    $height = ImageFontHeight($font);

 

    $im = imagecreate ($width,$height);

    $background_color = imagecolorallocate ($im, 219, 239, 249); //cell background

    $text_color = imagecolorallocate ($im, 0, 0,0);//text color

    imagestring ($im, $font, 0, 0, $generated_pin, $text_color);

    touch($image_url . 'uplimg/site_pin_' . $full_pin . '.jpg');

    imagejpeg($im, $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg');

 

    $image_output = '<img src="' . $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg">';

 

    imagedestroy($im);

 

    return $image_output;

Can you tell me what is wrong with this code and how I can resolve the
problem.

Thanks

attached mail follows:


Legolas wood schreef:
> Hi
> Thank you for reading my post
> I am trying to run a php based application using php5 and apache.
> but I receive an error like:
>
>
> *Fatal error*: Call to undefined function imagefontwidth() in */var/www/v603/includes/functions.php* on line *28*

that would tend to indicate that it's unavailable yes.
you don't have the [php] GD extension loaded (and probably not even installed)

php.net/gd

mostly likely you'll have to ask your sys admin to install/activate this
extension ... and if you have cheaphosting then likely the answer will be
"no we don't do that" - in which case find other hosting?

>
>
> when line 28 and its surrounding lines are:
>
> ## create an image not a text for the pin
>
> $font = 6;
>
> $width = imagefontwidth($font) * strlen($generated_pin);
>
> $height = ImageFontHeight($font);
>
>
>
> $im = imagecreate ($width,$height);
>
> $background_color = imagecolorallocate ($im, 219, 239, 249); //cell background
>
> $text_color = imagecolorallocate ($im, 0, 0,0);//text color
>
> imagestring ($im, $font, 0, 0, $generated_pin, $text_color);
>
> touch($image_url . 'uplimg/site_pin_' . $full_pin . '.jpg');
>
> imagejpeg($im, $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg');
>
>
>
> $image_output = '<img src="' . $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg">';
>
>
>
> imagedestroy($im);
>
>
>
> return $image_output;
>
>
>
> Can you tell me what is wrong with this code and how I can resolve the
> problem.
>
> Thanks
>

attached mail follows:


On Feb 7, 2008 8:23 AM, Jochem Maas <jochemiamjochem.com> wrote:
> Legolas wood schreef:
> > Hi
> > Thank you for reading my post
> > I am trying to run a php based application using php5 and apache.
> > but I receive an error like:
> >
> >
> > *Fatal error*: Call to undefined function imagefontwidth() in */var/www/v603/includes/functions.php* on line *28*
>
> mostly likely you'll have to ask your sys admin to install/activate this
> extension ... and if you have cheaphosting then likely the answer will be
> "no we don't do that" - in which case find other hosting?

    <plug shame="false" />
         PilotPig has GD, ImageMagick, and all kinds of other things
already installed, and will install any server software (when
reasonable) upon request at no charge. Check it out:
http://www.pilotpig.net/
    </plug>

    ;-P

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


On 2/7/08, Daniel Brown <parasanegmail.com> wrote:
>
> On Feb 7, 2008 8:23 AM, Jochem Maas <jochemiamjochem.com> wrote:
> > Legolas wood schreef:
> > > Hi
> > > Thank you for reading my post
> > > I am trying to run a php based application using php5 and apache.
> > > but I receive an error like:
> > >
> > >
> > > *Fatal error*: Call to undefined function imagefontwidth() in
> */var/www/v603/includes/functions.php* on line *28*
> >
> > mostly likely you'll have to ask your sys admin to install/activate this
> > extension ... and if you have cheaphosting then likely the answer will
> be
> > "no we don't do that" - in which case find other hosting?
>
> <plug shame="false" />
> PilotPig has GD, ImageMagick, and all kinds of other things
> already installed, and will install any server software (when
> reasonable) upon request at no charge. Check it out:
> http://www.pilotpig.net/
> </plug>
>
> ;-P
>
> --
> </Dan>

I can attest to what Daniel is saying about PilotPig. I've had a site
hosted there for about 5 months now and have been really happy with
everything: costs are reasonable, lots of modules available, respectful and
timely reponses to questions and/or concerns. Just a great overall
experience.

David

attached mail follows:


Martin Marques schreef:
> Nathan Nobbe escribió:
>> On Feb 6, 2008 6:13 AM, Martin Marques <martinmarquesminen.com.ar>
>> wrote:
>>
>>> I got an update from tzdata on a Debian server due to a daylight saving
>>> change here in Argentina.

I doubt that debian stable is pushing newer versions of TZ db, than that found in
php ... you don't mention your php version btw.

>>>
>>> The problem is that, even when the system sees the correct time, php
>>> keeps giving me the *old* hour.
>>>
>>> $ date
>>> mié feb 6 09:03:57 ARST 2008
>>> $ echo "<?php echo date('H:i') . \"\n\"; ?>"|php5
>>> 08:04
>>>
>>> What can my problem be?

what timezone does php think it's in? - output all stuff from date,
not just hour:minutes.

>>
>>
>> see what you have as the value for the date.timezone ini setting.
>
> I've already checked that, and it's not set.

it should be set to something, so fix that.

>
> Anyway, I found out that PHP uses an internal tz database (very bad
> IMHO) and it might be out of date.

there is a good reason for this being internal - and if you search the
internals mailing list archive you'll find plenty of discussion about it.

whether it's bad depends on whether you look at it from a phper's POV or a
sysadmin/package maintainers POV - there is no way to make everyone happy in this
situation AFAICT.

>

attached mail follows:


Jochem Maas escribió:
> Martin Marques schreef:
>> Nathan Nobbe escribió:
>>> On Feb 6, 2008 6:13 AM, Martin Marques <martinmarquesminen.com.ar>
>>> wrote:
>>>
>>>> I got an update from tzdata on a Debian server due to a daylight saving
>>>> change here in Argentina.
>
> I doubt that debian stable is pushing newer versions of TZ db, than that
> found in
> php ... you don't mention your php version btw.

The tzdata was from volatile.

# php -v
PHP 5.2.0-8+etch10 (cli) (built: Jan 18 2008 18:52:58)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

>>>>
>>>> The problem is that, even when the system sees the correct time, php
>>>> keeps giving me the *old* hour.
>>>>
>>>> $ date
>>>> mié feb 6 09:03:57 ARST 2008
>>>> $ echo "<?php echo date('H:i') . \"\n\"; ?>"|php5
>>>> 08:04
>>>>
>>>> What can my problem be?
>
> what timezone does php think it's in? - output all stuff from date,
> not just hour:minutes.

Already solved it. I installed timezonedb from pecl.

attached mail follows:


On Feb 7, 2008 8:34 AM, Jochem Maas <jochemiamjochem.com> wrote:
> Martin Marques schreef:
> >> see what you have as the value for the date.timezone ini setting.
> >
> > I've already checked that, and it's not set.
>
> it should be set to something, so fix that.

    All other points being valid, Jochem, I disagree with this. I've
never forced a setting on any of my PHP installations, and so far
(knock on wood) I've never had a problem. I think PHP does a fine job
of reading the server time and zone.

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


On 2/7/08, Daniel Brown <parasanegmail.com> wrote:
>
> On Feb 7, 2008 8:34 AM, Jochem Maas <jochemiamjochem.com> wrote:
> > Martin Marques schreef:
> > >> see what you have as the value for the date.timezone ini setting.
> > >
> > > I've already checked that, and it's not set.
> >
> > it should be set to something, so fix that.
>
> All other points being valid, Jochem, I disagree with this. I've
> never forced a setting on any of my PHP installations, and so far
> (knock on wood) I've never had a problem. I think PHP does a fine job
> of reading the server time and zone.
>
> --
> </Dan>

But I think Martin said, and my experience has taught me, that PHP 5 uses an
internal database of timezone info and does not reference OS time (I'm
assuming that's what you meant, Daniel, by "I think PHP does a fine job of
reading the server time and zone."). On one of the Linux web servers that I
maintain, I had the need to turn off daylight savings time, which was a
interesting task in itself. But I could never get PHP5 to honor the OS time
as it always changed when in DST. So I had add code to applications that ran
from that web server to test for DST and account for it in certain
displays. This was very different behavior form PHP4 where the same
applications ran just fine.

David

attached mail follows:


On Feb 6, 2008 6:13 AM, Martin Marques <martinmarquesminen.com.ar> wrote:
> I got an update from tzdata on a Debian server due to a daylight saving
> change here in Argentina.
>
> The problem is that, even when the system sees the correct time, php
> keeps giving me the *old* hour.
>
> $ date
> mié feb 6 09:03:57 ARST 2008
> $ echo "<?php echo date('H:i') . \"\n\"; ?>"|php5
> 08:04
>
> What can my problem be?
>
>
> BTW, I did a useless reboot (I knew it wouldn't help at all, but I did
> it anyway).
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

There was a discussion on internals a while ago about this problem
that explains why this is:

http://www.mail-archive.com/internalslists.php.net/msg32935.html

attached mail follows:


Pieter du Toit wrote:

> Hi people
>
> Is there a way that i can schedule tasks on my webserver that will
> automatically fire on a certain time and date, without anyone visiting the
> website?
>
> This domain is hosted by a ISP and not by me.
>
> Thanks

If you don't need close granularity in the timing of the jobs, try
www.webcron.org/

Cheers
--
David Robley

What if there were no hypothetical situations?
Today is Pungenday, the 38th day of Chaos in the YOLD 3174.

attached mail follows:


On Feb 6, 2008 7:28 PM, Jason Pruim <japruimraoset.com> wrote:
>
>
> On Feb 6, 2008, at 5:56 PM, Eric Butera wrote:
>
> > On Feb 6, 2008 4:18 PM, nihilism machine <nihilismmachinegmail.com>
> > wrote:
> >> Does anyone know of a shopping cart which allows you to add multiple
> >> custom fields to each product?
> >> --e
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> > Please do not use osCommerce.
>
> Umm, Can I ask why? I just downloaded it a few days ago to play with
> it on my server. I don't need it myself, but something good to have in
> the arsenal :)
>
>
>

I might have put my foot in my mouth, but probably not. I've used it
a few years ago and it was just a horrible mess of code. All the
end-user interfaces were pretty nasty too. At the end of the day
though it is your choice what software you use, but from my experience
it is a poor quality piece of software.

attached mail follows:


On Feb 7, 2008, at 9:01 AM, Eric Butera wrote:

> On Feb 6, 2008 7:28 PM, Jason Pruim <japruimraoset.com> wrote:
>>
>>
>> On Feb 6, 2008, at 5:56 PM, Eric Butera wrote:
>>
>>> On Feb 6, 2008 4:18 PM, nihilism machine <nihilismmachinegmail.com>
>>> wrote:
>>>> Does anyone know of a shopping cart which allows you to add
>>>> multiple
>>>> custom fields to each product?
>>>> --e
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>
>>> Please do not use osCommerce.
>>
>> Umm, Can I ask why? I just downloaded it a few days ago to play with
>> it on my server. I don't need it myself, but something good to have
>> in
>> the arsenal :)
>>
>>
>>
>
> I might have put my foot in my mouth, but probably not. I've used it
> a few years ago and it was just a horrible mess of code. All the
> end-user interfaces were pretty nasty too. At the end of the day
> though it is your choice what software you use, but from my experience
> it is a poor quality piece of software.
>

I haven't looked at the code of it yet... Just downloaded it,
installed it, and started playing from an end user stand point :)
figure if I can't tell the user how to use it, it doesn't matter what
kind of a rats nest the code is :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
japruimraoset.com

attached mail follows:


On Feb 7, 2008 9:11 AM, Jason Pruim <japruimraoset.com> wrote:
>
>
> On Feb 7, 2008, at 9:01 AM, Eric Butera wrote:
>
> > On Feb 6, 2008 7:28 PM, Jason Pruim <japruimraoset.com> wrote:
> >>
> >>
> >> On Feb 6, 2008, at 5:56 PM, Eric Butera wrote:
> >>
> >>> On Feb 6, 2008 4:18 PM, nihilism machine <nihilismmachinegmail.com>
> >>> wrote:
> >>>> Does anyone know of a shopping cart which allows you to add
> >>>> multiple
> >>>> custom fields to each product?
> >>>> --e
> >>>>
> >>>> --
> >>>> PHP General Mailing List (http://www.php.net/)
> >>>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>>
> >>>>
> >>>
> >>> Please do not use osCommerce.
> >>
> >> Umm, Can I ask why? I just downloaded it a few days ago to play with
> >> it on my server. I don't need it myself, but something good to have
> >> in
> >> the arsenal :)
> >>
> >>
> >>
> >
> > I might have put my foot in my mouth, but probably not. I've used it
> > a few years ago and it was just a horrible mess of code. All the
> > end-user interfaces were pretty nasty too. At the end of the day
> > though it is your choice what software you use, but from my experience
> > it is a poor quality piece of software.
> >
>
>
>
> I haven't looked at the code of it yet... Just downloaded it,
> installed it, and started playing from an end user stand point :)
> figure if I can't tell the user how to use it, it doesn't matter what
> kind of a rats nest the code is :)
>
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424
> www.raoset.com
> japruimraoset.com
>
>
>

While I agree that if the end user doesn't get it, then you don't get
paid... but quality matters if you have to extend/maintain/secure it.
Well, I guess not. Look at how wildly popular MySpace is.

attached mail follows:


On Feb 7, 2008 9:24 AM, Eric Butera <eric.buteragmail.com> wrote:

> While I agree that if the end user doesn't get it, then you don't get
> paid... but quality matters if you have to extend/maintain/secure it.
> Well, I guess not. Look at how wildly popular MySpace is.

im guessing most people who use oscommerce or zencart dont ever
look at the code, let alone extend it. a couple years back i setup a
zencart install for someone and i remember looking on the forums at
that time.. someone was trying to mod it a little and one of the core
devs said something like 'what are you doing, mucking around in the
code..'; i was somewhat shocked at that.

did you see the thread that started last night about a zencart module
and php arrays?? if thats indicative of the typical user (which i suspect
it is) i think these guys are safe to assume not many people are going
to extend their code. but thats no excuse for poor code (here i assume
the code is bad, but from a cursory glance it looks like zencart has
improved since i last used it [though ive not looked at the code much]).

if i were going to use it id almost certainly end up maintaining some sort
of forked version or perhaps just grabbing some functionality from it, like
maybe integration w/ a payment gateway or something. hopefully that
cant be too bad, and small enough to easily tweak in the event it needed
a face-lift.

-nathan

attached mail follows:


On Feb 7, 2008 9:24 AM, Eric Butera <eric.buteragmail.com> wrote:
> > > I might have put my foot in my mouth, but probably not. I've used it
> > > a few years ago and it was just a horrible mess of code. All the
> > > end-user interfaces were pretty nasty too. At the end of the day
> > > though it is your choice what software you use, but from my experience
> > > it is a poor quality piece of software.

    I agree. I think the problem was too many people throwing in
code, and not enough control and checking. In my opinion, osCommerce
can be equated to a cheetah: very nice, fast, and sleek when you see
it running, but tear it open and the guts are nasty.

> While I agree that if the end user doesn't get it, then you don't get
> paid... but quality matters if you have to extend/maintain/secure it.
> Well, I guess not. Look at how wildly popular MySpace is.

    Hey, I helped work on that, you bastard! ;-P

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


On Feb 7, 2008 10:04 AM, Daniel Brown <parasanegmail.com> wrote:
> Hey, I helped work on that, you bastard! ;-P

Congratulations. :)

attached mail follows:


On Feb 7, 2008 9:59 AM, Nathan Nobbe <quickshiftingmail.com> wrote:
> On Feb 7, 2008 9:24 AM, Eric Butera <eric.buteragmail.com> wrote:
>
> > While I agree that if the end user doesn't get it, then you don't get
> > paid... but quality matters if you have to extend/maintain/secure it.
> > Well, I guess not. Look at how wildly popular MySpace is.
>
>
> im guessing most people who use oscommerce or zencart dont ever
> look at the code, let alone extend it. a couple years back i setup a
> zencart install for someone and i remember looking on the forums at
> that time.. someone was trying to mod it a little and one of the core
> devs said something like 'what are you doing, mucking around in the
> code..'; i was somewhat shocked at that.
>
> did you see the thread that started last night about a zencart module
> and php arrays?? if thats indicative of the typical user (which i suspect
> it is) i think these guys are safe to assume not many people are going
> to extend their code. but thats no excuse for poor code (here i assume
> the code is bad, but from a cursory glance it looks like zencart has
> improved since i last used it [though ive not looked at the code much]).
>
> if i were going to use it id almost certainly end up maintaining some sort
> of forked version or perhaps just grabbing some functionality from it, like
> maybe integration w/ a payment gateway or something. hopefully that
> cant be too bad, and small enough to easily tweak in the event it needed
> a face-lift.
>
> -nathan
>
>

If you look at plugin architectures of projects such as drupal,
phorum, or serendipity you can see there are better ways of doing
things rather than messing up the source code. I recently found
Magento, and the code looked really promising, but it is just too
slow. Having to diff your project and upgrade changes is a horrible
thing each time a security patch comes out.

A big part of what I do is work on e-commerce solutitons for local
stores and such. Each one has wildly different needs that just cannot
be packaged up easily. So in the end I've implemented my own solution
because I felt that to be able to address clients needs properly I
needed a system where swapping out the hard parts were easier. Now
when somebody comes to us with their fancy new payment gateway I can
read the docs and integrate it fairly easy without breaking anything
because I know how the other parts work and can implement accordingly.

attached mail follows:


On Feb 7, 2008 1:20 AM, Warren Vail <warrenvailtech.net> wrote:
> I did some looking into performance issues many years ago at company that
> developed and marketed another database server, comparing the query plan to
> the actual code, and a query plan usually shows the processes that consume
> the major amount of time, disk I/O, index or table searches and such, but
> doesn't show time consumed comparing, discriminating, and totaling, mostly
> because they are negligible.
>
> On the other hand distinct depends on comparison of all columns and will
> have no help in reducing row counts unless accompanied by an order by
> clause, where as group by implys an orderby and can be faster if indexes are
> available for use in row ordering, and while the same totaling occurs,
> comparison is limited to the columns specified in the group by.

Does DISTINCT really compare all columns? I would think it would only
compare the columns explicitly included in the SELECT clause.

> The biggest impact on one or the other would be a well placed index, but for
> the most part they should be about the same.
>
> Warren Vail
>

I have seen discussions where in GROUP BY can be faster than DISTINCT
depending on whether the query uses things like correlated subqueries,
but this is not applicable in the current case. At any rate, I don't
want to stray the conversation any further away than I already have.

Andrew

attached mail follows:


You are correct, but that is what I meant by all columns (all those in the
query, and therefore subject to the distinct).

At this point different database engines work differently, without an order
by, some will use the primary sequence, some will scan table space (in other
words, without an order by [or group by], some engines will give you a
performance hit). It's always good practice to write your queries to help
your DB engine find an index.

Warren

> -----Original Message-----
> From: Andrew Ballard [mailto:aballardgmail.com]
> Sent: Thursday, February 07, 2008 7:16 AM
> To: PHP General list
> Subject: Re: [PHP] PHP/mySQL question about groups
>
> On Feb 7, 2008 1:20 AM, Warren Vail <warrenvailtech.net> wrote:
> > I did some looking into performance issues many years ago at company
> that
> > developed and marketed another database server, comparing the query plan
> to
> > the actual code, and a query plan usually shows the processes that
> consume
> > the major amount of time, disk I/O, index or table searches and such,
> but
> > doesn't show time consumed comparing, discriminating, and totaling,
> mostly
> > because they are negligible.
> >
> > On the other hand distinct depends on comparison of all columns and will
> > have no help in reducing row counts unless accompanied by an order by
> > clause, where as group by implys an orderby and can be faster if indexes
> are
> > available for use in row ordering, and while the same totaling occurs,
> > comparison is limited to the columns specified in the group by.
>
> Does DISTINCT really compare all columns? I would think it would only
> compare the columns explicitly included in the SELECT clause.
>
>
> > The biggest impact on one or the other would be a well placed index, but
> for
> > the most part they should be about the same.
> >
> > Warren Vail
> >
>
> I have seen discussions where in GROUP BY can be faster than DISTINCT
> depending on whether the query uses things like correlated subqueries,
> but this is not applicable in the current case. At any rate, I don't
> want to stray the conversation any further away than I already have.
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


Greetings,

Could someone please point me in the right direction? I am trying to have
PHP find out if a directory has files in it and then if it does, display and
include, if it does not, then not display the include.

I have looked at the Manual and did not really know where to look.

Thanks,

--
Steve M.

attached mail follows:


On Thu, 2008-02-07 at 12:30 -0600, Steve Marquez wrote:
> Could someone please point me in the right direction? I am trying to have
> PHP find out if a directory has files in it and then if it does, display and
> include, if it does not, then not display the include.

oooh, goodie! You get to play with my new favourite toys - SPL!

Try this:

public function lsDir($dir, $type='files')
{
        $iterator = new RecursiveDirectoryIterator($dir);
        foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file)
        {
                if ($file->isDir()) {
                        $dirs[] = $file->getPathname();
                } else {
                        $files[] = $file->getPathname();
                }
        }
        if($type = 'files')
        {
                return $files;
        }
        else {
                return $dirs;
        }
}

(untested - written from mind dump - so please test 1st)

Then, AFAIK SPL also has an __autoload that you can use.

> I have looked at the Manual and did not really know where to look.
>

http://www.php.net/spl

--Paul

--
------------------------------------------------------------.
| Chisimba PHP5 Framework - http://avoir.uwc.ac.za |
:------------------------------------------------------------:

All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm

attached mail follows:


Steve Marquez wrote:
> Greetings,
>
> Could someone please point me in the right direction?

Turn left at the next light...

> I am trying to have
> PHP find out if a directory has files in it and then if it does, display

Display what? The directory name, or the list of files?

> and include,

What do you mean by include? the include command from PHP?

if it does not, then not display the include.

Again, what do you mean exactly?

> I have looked at the Manual and did not really know where to look.

Which part of the manual did you look at?

Here are a few parts of the manual that I would start with.

This will get you a complete list of files, directories, etc... in a given directory
        http://us2.php.net/manual/en/function.glob.php

This class allows you retrieve and iterate through a directory listing.
        http://us2.php.net/manual/en/class.dir.php

Between the above two options, I recommend glob()

Now loop through the results with foreach or while .

        http://us3.php.net/manual/en/control-structures.foreach.php
        http://us3.php.net/manual/en/control-structures.while.php

run the following two commands on each value of the given array to determine
whether the given entry is a file, directory, or something else

This will allow you to determine if something is a file
        http://us2.php.net/manual/en/function.is-file.php

This will allow you to determine if something is a directory
        http://us2.php.net/manual/en/function.is-dir.php

if you found a directory, use this to change to that directory and start the
process all over again.

This will allow you to change your current working directory to a new directory
        http://us2.php.net/manual/en/function.chdir.php

Hope these help

> Thanks,
>
> --
> Steve M.
>

--
Jim Lucas

    "Some men are born to greatness, some achieve greatness,
        and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
     by William Shakespeare

attached mail follows:


Hi there,

 

Is it possible to make the declare(ticks=1) statement apply to *all*
functions executed in a php script, regardless of scope?

 

I wish to write a profiler script to basically dump all the function call
times through the execution of a script. So far, I can only get it to work
for functions called via global scope.

 

My code calls only one function from the global scope, and then a whole lot
of functions in classes are invoked. The tick function is only invoked once
from calling this one global function.

 

Here is my code:

 

<?php

declare(ticks = 1);

 

/**

 * Profiler

 *

 * version SVN: $Id$

 * author Scott McNaught

 */

class Profiler

{

      protected $m_arrProfileData = array();

      protected $m_strCurrentFunction = null;

      protected $m_iLastTime = null;

 

      /**

       * Begins profiling

       */

      public function start()

      {

            $this->m_iLastTime = time();

      }

 

      /**

       * Finishes profiling and dumps the results

       */

      public function end()

      {

            var_dump($this->m_arrProfileData);

            $this->m_arrProfileData = array();

            $this->m_strCurrentFunction = null;

      }

 

      public function tick()

      {

            $arrBacktrace = debug_backtrace();

            

            if (!isset($arrBacktrace[1]))

            {

                  return;

            }

            

            $strFunction = $arrBacktrace[1]['function'];

            

            if (isset($arrBacktrace[1]['class']))

            {

                  $strFunction = $arrBacktrace[1]['class'] . '::' .
$strFunction;

            }

            

            $iTime = microtime(true);

            

            if (!isset($this->m_arrProfileData[$strFunction]))

            {

                  $this->m_arrProfileData[$strFunction] = $iTime;

            }

            

            $this->m_arrProfileData[$strFunction] += $iTime -
$this->m_iLastTime;

            $this->m_iLastTime = $iTime;

            $this->m_strCurrentFunction = $strFunction;

      }

}

 

$pProfiler = new Profiler();

register_tick_function($pProfiler, 'tick'), true);

 

?>

 

 

Then from index.php.

 

<?php

 

if(isset($_GET['profile']))

{

      include('profiler.inc.php');

}

 

function execute()

{

      $pClass = new SomeClass();

      $pClass->someFunction();

}

 

execute(); // TICK IS CALLED FROM EXECUTING THIS

 

?>

 

So a tick is made from calling execute() from global scope, and that is it.
I want it to tick when someFunction() is called.

 

I would really appreciate any help that anyone can give me with this as I
have struggled with it for a while, and there is not much documentation
about this anywhere.

This could potentially benefit a lot of people if engineered right. I am
trying to make a profiler include file which will be able to be used with
one line of file.

 

This will allow people to:

. Get quick profiler results on demand by adding something to the
query string - eg - ?profile=1

. Get profile results for novices without having to mess around
installing php binaries such as APD / zend debugger etc

. Profile on demand on production servers without having to install
a resource intensive debugging module

 

Any help greatly appreciated.

 

Thanks,

 

Scott McNaught

 

attached mail follows:


McNaught, Scott wrote:
> Hi there,
>
>
>
> Is it possible to make the declare(ticks=1) statement apply to *all*
> functions executed in a php script, regardless of scope?
>
>
>
> I wish to write a profiler script to basically dump all the function call
> times through the execution of a script. So far, I can only get it to work
> for functions called via global scope.
>
>
>
> My code calls only one function from the global scope, and then a whole lot
> of functions in classes are invoked. The tick function is only invoked once
> from calling this one global function.
>
>
>
> Here is my code:
>
>
>
> <?php
>
> declare(ticks = 1);
>
>
>
> /**
>
> * Profiler
>
> *
>
> * version SVN: $Id$
>
> * author Scott McNaught
>
> */
>
> class Profiler
>
> {
>
> protected $m_arrProfileData = array();
>
> protected $m_strCurrentFunction = null;
>
> protected $m_iLastTime = null;
>
>
>
> /**
>
> * Begins profiling
>
> */
>
> public function start()
>
> {
>
> $this->m_iLastTime = time();
>
> }
>
>
>
> /**
>
> * Finishes profiling and dumps the results
>
> */
>
> public function end()
>
> {
>
> var_dump($this->m_arrProfileData);
>
> $this->m_arrProfileData = array();
>
> $this->m_strCurrentFunction = null;
>
> }
>
>
>
> public function tick()
>
> {
>
> $arrBacktrace = debug_backtrace();
>
>
>
> if (!isset($arrBacktrace[1]))
>
> {
>
> return;
>
> }
>
>
>
> $strFunction = $arrBacktrace[1]['function'];
>
>
>
> if (isset($arrBacktrace[1]['class']))
>
> {
>
> $strFunction = $arrBacktrace[1]['class'] . '::' .
> $strFunction;
>
> }
>
>
>
> $iTime = microtime(true);
>
>
>
> if (!isset($this->m_arrProfileData[$strFunction]))
>
> {
>
> $this->m_arrProfileData[$strFunction] = $iTime;
>
> }
>
>
>
> $this->m_arrProfileData[$strFunction] += $iTime -
> $this->m_iLastTime;
>
> $this->m_iLastTime = $iTime;
>
> $this->m_strCurrentFunction = $strFunction;
>
> }
>
> }
>
>
>
> $pProfiler = new Profiler();
>
> register_tick_function($pProfiler, 'tick'), true);
>
>
>
> ?>
>
>
>
>
>
> Then from index.php.
>
>
>
> <?php
>
>
>
> if(isset($_GET['profile']))
>
> {
>
> include('profiler.inc.php');
>
> }
>
>
>
> function execute()
>
> {
>
> $pClass = new SomeClass();
>
> $pClass->someFunction();
>
> }
>
>
>
> execute(); // TICK IS CALLED FROM EXECUTING THIS
>
>
>
> ?>
>
>
>
> So a tick is made from calling execute() from global scope, and that is it.
> I want it to tick when someFunction() is called.
>
>
>
> I would really appreciate any help that anyone can give me with this as I
> have struggled with it for a while, and there is not much documentation
> about this anywhere.
>
> This could potentially benefit a lot of people if engineered right. I am
> trying to make a profiler include file which will be able to be used with
> one line of file.
>
>
>
> This will allow people to:
>
> . Get quick profiler results on demand by adding something to the
> query string - eg - ?profile=1
>
> . Get profile results for novices without having to mess around
> installing php binaries such as APD / zend debugger etc
>
> . Profile on demand on production servers without having to install
> a resource intensive debugging module
>
>
>
> Any help greatly appreciated.
>
>
>
> Thanks,
>
>
>
> Scott McNaught
>
>
>
>
First off:

register_tick_function(array(&$pProfiler, 'tick'), true);

attached mail follows:


Hi,

I am facing problem in integration of PHP with Geronimo.

Environment:
========

PHP 5.2.5
OS: Redhat Enterprise Linux 3.6.9
Geromino version geronimo-tomcat6-jee5-2.0.2\
JDK 1.6/1.5

Step Performed:
==========

I have tried JavaBridge available on the sourgeforge. It working find for
normal php application. But I need to access few pages which is using
mbstring.so php extension. I am to use Japanese character set.

Exception:
======

Fatal error: Call to undefined function mb_language() in
/usr/puneet/geronimo-tomcat6-jee5-2.0.2/repository/default/collabo_gero/1202406746983/collabo_gero-1202406746983.war/sns/config.php
on line 403

Please help me to resolve this problem

Thanks,
Puneet Jain
--
View this message in context: http://www.nabble.com/urgently-help-required-in-integration-of-PHP-and-Geronimo-tp15341133p15341133.html
Sent from the PHP - General mailing list archive at Nabble.com.