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 3 Apr 2008 20:22:01 -0000 Issue 5384

php-general-digest-helplists.php.net
Date: Thu Apr 03 2008 - 15:22:01 CDT


php-general Digest 3 Apr 2008 20:22:01 -0000 Issue 5384

Topics (messages 272474 through 272505):

base64 encode question
        272474 by: Sn!per
        272475 by: Aschwin Wesselius

Re: Memory usage very high under AMD64?
        272476 by: Colin Guthrie
        272480 by: Aschwin Wesselius
        272481 by: Ed W
        272482 by: Aschwin Wesselius
        272484 by: Ed W
        272485 by: Colin Guthrie
        272486 by: Thiago Pojda

Re: autoload with namespace
        272477 by: Colin Guthrie
        272478 by: Larry Garfield
        272479 by: Colin Guthrie

mkdir/exec(cacls) question....
        272483 by: Constance.Kan

Question About PHP Includes
        272487 by: jwynacht
        272488 by: Daniel Brown
        272489 by: Daniel Brown
        272497 by: jwynacht

Cpoying mails from one IMAP server to an other IMAP server
        272490 by: Damian Hischier
        272495 by: Colin Guthrie

How to get a code review?
        272491 by: David Jourard
        272492 by: Daniel Brown
        272493 by: Robert Cummings
        272494 by: Nathan Nobbe
        272496 by: admin.buskirkgraphics.com
        272499 by: David Jourard
        272501 by: Nathan Nobbe
        272502 by: David Jourard
        272503 by: Nathan Nobbe

everything as classes
        272498 by: robert
        272500 by: Nathan Nobbe
        272504 by: Richard Heyes

Re: LDAP in php
        272505 by: pobox.verysmall.org

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:


Hi all, I have a short script that I want to store the last login time
and the host IP number (harcoded for the moment). Those two variables
are stored in $last_login, which is an array.

[rootsvr1 test]# cat lt.php
<?
$last_login = array('time' => time(), 'host' => "192.168.10.100");
$serialize_last_login = serialize($last_login);
print "$serialize_last_login\n";

$encoded_serialize_last_login = base64_encode($serialize_last_login);
print "encoded value is: $encoded_serialize_last_login\n\n";

?>
[rootsvr1 test]#

When I ran the script, I can see that $serialize_last_login have
different value for 'time'. But why does $encoded_serialize_last_login
always show the same value? Below is the output after running the
script for 3 times:

[rootsvr1 test]# php lt.php
a:2:{s:4:"time";i:1207208982;s:4:"host";s:14:"192.168.10.100";}
encoded value is:
YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4MjtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9

[rootsvr1 test]# php lt.php
a:2:{s:4:"time";i:1207208984;s:4:"host";s:14:"192.168.10.100";}
encoded value is:
YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4NDtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9

[rootsvr1 test]# php lt.php
a:2:{s:4:"time";i:1207208985;s:4:"host";s:14:"192.168.10.100";}
encoded value is:
YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4NTtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9

Please help

--
Roger

--
Sign Up for free Email at http://ureg.home.net.my/

attached mail follows:


Sn!per wrote:
> encoded value is:
> YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4MjtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9
>
> encoded value is:
> YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4NDtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9
>
> encoded value is:
> YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4NTtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9
>

Hi,

They are not the same!

If you look closely enough, only one digit in the value is different. So
the base64 encoded value has to differ only some values, not the whole
string.

4MjtzO is different than
4NDtzO is different than
4NTtzO

You see?

So, the whole string is different and thus unique.

Hope this helps!
--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other....'/

attached mail follows:


Hi Ed,

Long time no speak... keep running into you every now and then online :)
Hope you are well.

Ed W wrote:
> 45MB x2 is a lot less than 215MB...
>
> Also, I would expect the actual consumption to be less than 2x since not
> all the data will be doubled in size..?
>
> Any other suggestions on how to debug this 5x jump in memory usage?

I can't really give you any solid metrics as we don't use x86_64 in
production environement but on my test setup I frequently hit memory
limits in our apps before my colleagues (and the production) on my core
2 due x86_64 install.

I've also got some weird bug with session ids that I've never quite
nailed down - causes apache segv on my machine. I've never been able to
cut it down to a simple test case tho'..... :(

Col

attached mail follows:


Ed W wrote:
> 45MB x2 is a lot less than 215MB...
>
> Also, I would expect the actual consumption to be less than 2x since
> not all the data will be doubled in size..?
>
> Any other suggestions on how to debug this 5x jump in memory usage?
>
> Thanks
>
> Ed W
>
>
> Robert Cummings wrote:
>> 64 bit integers are twice as big as 32 bit integers.

Hi all,

I'm not an expert and have no real experience with programming in a
64-bit environment.

That said, I think a system will allocate not only space for 64-bit
values (in simple theory twice as much as 32-bit). 64-bit is simple a
factor, so calculations increase with this factor.

I think the memory goes into a square ratio (NxN) instead of just saying
double (Nx2). Again, I'm not a wizzkid with enough math experience. This
is just my simple and humble reasoning.
--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other....'/

attached mail follows:


Aschwin Wesselius wrote:
> Ed W wrote:
>> 45MB x2 is a lot less than 215MB...
>>
>> Also, I would expect the actual consumption to be less than 2x since
>> not all the data will be doubled in size..?
>>
>> Any other suggestions on how to debug this 5x jump in memory usage?
>>
>> Thanks
>>
>> Ed W
>>
>>
>> Robert Cummings wrote:
>>> 64 bit integers are twice as big as 32 bit integers.
>
> Hi all,
>
> I'm not an expert and have no real experience with programming in a
> 64-bit environment.
>
> That said, I think a system will allocate not only space for 64-bit
> values (in simple theory twice as much as 32-bit). 64-bit is simple a
> factor, so calculations increase with this factor.
>
> I think the memory goes into a square ratio (NxN) instead of just
> saying double (Nx2). Again, I'm not a wizzkid with enough math
> experience. This is just my simple and humble reasoning.
> --

RSS is staying approximately constant, ie the memory in use has not
changed much

VSZ, ie virtual memory has increased by more than 2x2=4. If someone has
some hard experience of both platforms then please add some experience
to this - however, I'm looking for some hard debugging knowhow on this,
not just some handwaving estimates please

Ed W

attached mail follows:


Ed W wrote:
> RSS is staying approximately constant, ie the memory in use has not
> changed much
>
> VSZ, ie virtual memory has increased by more than 2x2=4. If someone
> has some hard experience of both platforms then please add some
> experience to this - however, I'm looking for some hard debugging
> knowhow on this, not just some handwaving estimates please
>
> Ed W

Maybe still some handwaving, but my colleague forwarded me this link:

http://www.bit-tech.net/bits/2007/10/16/64-bit_more_than_just_the_ram/1

I hope that's still in your interest.

--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other....'/

attached mail follows:


Aschwin Wesselius wrote:
> Ed W wrote:
>> RSS is staying approximately constant, ie the memory in use has not
>> changed much
>>
>> VSZ, ie virtual memory has increased by more than 2x2=4. If someone
>> has some hard experience of both platforms then please add some
>> experience to this - however, I'm looking for some hard debugging
>> knowhow on this, not just some handwaving estimates please
>>
>> Ed W
>
> Maybe still some handwaving, but my colleague forwarded me this link:
>
> http://www.bit-tech.net/bits/2007/10/16/64-bit_more_than_just_the_ram/1
>
> I hope that's still in your interest.
>

Interesting, but I think I have come to the wrong forum? Where do the
programmers who implement PHP hang out? I really need to get under the
bonnet on this and find out what's happening - I'm not after speculation
(thanks to everyone who responded though)

Anyone got some hard details on how to debug this further - I'm looking
for under the hood kind of thoughts please

Ed W

attached mail follows:


Ed W wrote:
> Interesting, but I think I have come to the wrong forum? Where do the
> programmers who implement PHP hang out? I really need to get under the
> bonnet on this and find out what's happening - I'm not after speculation
> (thanks to everyone who responded though)

You probably want the -internals list Ed.

Col

attached mail follows:


Try those Internal lists.

You can check them out http://www.php.net/mailing-lists.php

Good luck!

-----Mensagem original-----
De: Ed W [mailto:listswildgooses.com]
Enviada em: quinta-feira, 3 de abril de 2008 07:08
Para: Aschwin Wesselius
Cc: Robert Cummings; php-generallists.php.net
Assunto: Re: [PHP] Memory usage very high under AMD64?

Aschwin Wesselius wrote:
> Ed W wrote:
>> RSS is staying approximately constant, ie the memory in use has not
>> changed much
>>
>> VSZ, ie virtual memory has increased by more than 2x2=4. If someone
>> has some hard experience of both platforms then please add some
>> experience to this - however, I'm looking for some hard debugging
>> knowhow on this, not just some handwaving estimates please
>>
>> Ed W
>
> Maybe still some handwaving, but my colleague forwarded me this link:
>
> http://www.bit-tech.net/bits/2007/10/16/64-bit_more_than_just_the_ram/
> 1
>
> I hope that's still in your interest.
>

Interesting, but I think I have come to the wrong forum? Where
do the programmers who implement PHP hang out? I really need
to get under the bonnet on this and find out what's happening -
I'm not after speculation (thanks to everyone who responded though)

Anyone got some hard details on how to debug this further - I'm
looking for under the hood kind of thoughts please

Ed W

attached mail follows:


Larry Garfield wrote:
> On Wednesday 02 April 2008, Jochem Maas wrote:
>
>>> there is one curiosity / caveat underlying the 5.3 implementation... so
>>> does the namespace get supplied to the autoload function as well as the
>>> class name? is it just one big string or are they separate?
>> one big string. how does php know before hand whether foo::get() is a
>> namespaced function call or a static class method call?
>
> I believe the decision from -internals was "seriously, who uses static methods
> and functions in the same code base that would use namespaces?" Of course, I
> would hope to be able to say "me!" once I am able to upgrade my work to 5.3,
> but the debate over the separator character is one of those guaranteed to
> start a flame war so I've just resigned myself to probably not being able to
> use namespaces in most places.

While namespaces are neat and tidy, I personally currently adopt regexp
based autoload wrapper.

I basically define one autoload method (to rule them all) that consults
a list of "registered" autoloaders via a regexp (typically just a class
name prefix). It then calls the relevant autoload function for that class.

Sure this probably has a little more overhead than a 5.3 namespace based
approach, but it achieves most of the same end goals for me.

When hacking on other 3rd party apps that include such stuff it's
usually trivial to rewrite their autoloader to be a registration call to
the "universal autoloader" rather than a definition. Obviously it
requires the app in question to have a structure to their classnames tho'.

Col.

attached mail follows:


On Thursday 03 April 2008, Colin Guthrie wrote:
> Larry Garfield wrote:

> > I believe the decision from -internals was "seriously, who uses static
> > methods and functions in the same code base that would use namespaces?"
> > Of course, I would hope to be able to say "me!" once I am able to upgrade
> > my work to 5.3, but the debate over the separator character is one of
> > those guaranteed to start a flame war so I've just resigned myself to
> > probably not being able to use namespaces in most places.
>
> While namespaces are neat and tidy, I personally currently adopt regexp
> based autoload wrapper.
>
> I basically define one autoload method (to rule them all) that consults
> a list of "registered" autoloaders via a regexp (typically just a class
> name prefix). It then calls the relevant autoload function for that class.
>
> Sure this probably has a little more overhead than a 5.3 namespace based
> approach, but it achieves most of the same end goals for me.
>
> When hacking on other 3rd party apps that include such stuff it's
> usually trivial to rewrite their autoloader to be a registration call to
> the "universal autoloader" rather than a definition. Obviously it
> requires the app in question to have a structure to their classnames tho'.
>
> Col.

See, I'm working on a different approach for Drupal. We're actually scanning
our own code base and building up an index of all classes (and functions!) in
the system, saving that to the database, and then the autoload implementation
just polls the database for the file that needs to be loaded and loads it.
The class itself can literally live almost anywhere. There's some more code
on top of that for caching and routing optimization and such, but that's the
basic idea and it's actually looking really sweet. :-) It should be landing
in HEAD very soon.

--
Larry Garfield AIM: LOLG42
larrygarfieldtech.com ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson

attached mail follows:


Larry Garfield wrote:
> See, I'm working on a different approach for Drupal. We're actually scanning
> our own code base and building up an index of all classes (and functions!) in
> the system, saving that to the database, and then the autoload implementation
> just polls the database for the file that needs to be loaded and loads it.
> The class itself can literally live almost anywhere. There's some more code
> on top of that for caching and routing optimization and such, but that's the
> basic idea and it's actually looking really sweet. :-) It should be landing
> in HEAD very soon.

This is actually very similar to another approach I'm taking too with my
projects.

I run "make" on the modules which takes several actions:
 * Extracts strings for i18n and merge in to the .po files etc.
 * Build up a list of what interfaces classes implement and/or what
classes they extend (because those base classes may implement an
interface(s) too!).

This parsed list of implementations is stored with the module (nothing
is enumerated to a DB at this stage).

In my code, as a module is loaded this list is also loaded and put into
an application wide structure.

This approach makes it incredibly simple to write Observer based design
patterns (e.g. you can ask the system for all classes that implement the
"ArticleSubmitted" interface - then instantiate or statically call as
appropriate). Modules can be turned off/disabled/uninstalled of course
and that means their implementation lists are not loaded and they will
not be called when an observable event occurs.

It's all very nice IMO and I certainly like working with it.

Col

attached mail follows:


Bishopsfield Road

Fareham

Hampshire

PO14 1NH

Tel: 01329 815200

Fax: 01329 822483
       
 
--------------------------------------------------------
The content of this e-mail is the sole responsibility of the sender - Fareham College accepts no responsibility for its accuracy or the views and opinions expressed herein, and also reserves the right to monitor all email sent/received on its business systems.
--------------------------------------------------------
Hi,

 

I'm having trouble using mkdir and cacls (via exec) . I have permission
denied for mkdir and nothing happens when I run cacls. Below is my
scenario.....

 

The web site is currently using "Integrated Windows authentication". And
I've used:
echo ($_SERVER['LOGON_USER'])
echo($_SERVER['AUTH_USER']);
echo($_SERVER['REMOTE_USER']);
to display the users in php and they displayed my username for all of
the above and I have admin rights.

The folders that I want to create subfolders have full control rights
for the Domain Admin groups (which I belong to) but it doesn't work.

I've even put myself with full control in the folder where I want to
make directory.

 

Ppan is an Active Direcoty user.

 

MKDIR

 

RUNNING SCRIPT SCRIPT HOSTED PERMFORMING TASK
PERFORMING TASK LOCATION RESULT

 

My local PC Svr_M creating a
directory Svr_S
Permission denied

My local PC Svr_M creating a
directory Svr_M
OK - directory created

My local PC My local PC creating a
directory Svr_S
OK - directory created

 

 

Exec(CACLS...)

 

RUNNING SCRIPT SCRIPT HOSTED PERMFORMING TASK
PERFORMING TASK LOCATION RESULT

 

My local PC Svr_M exec cacls
for user ppan Svr_S (\\Svr_S\CKTest\ppan)
nothing happened

My local PC Svr_M exec cacls
for user ppan Svr_M (\\Svr_M\CKTest\ppan) OK
- ppan added with full control

My local PC My local PC exec cacls for
user ppan My local PC (c:\ppan)
OK - ppan added with full control

 

But if the run the mkdir and cacls in the command prompt on Svr_M, it
works. Hence I suspect it's the user that IIS uses but it should be
using me. Can Mkdir and Exec execute scripts perform tasks across
networks?

 

Any suggestions would be very much appreciated - I've already spent
days/weeks "googling" and posting discussions on forums - still no joy!

 

Many thanks in advance.

 

Best regards,

Constance Kan 01329 815183

attached mail follows:


Hi,

I help maintain a Movable Type install for a non-profit organization. Things
have worked well with the site but the other day the home page went blank
and the rest of the pages lost all of their formatting. I've done some
debugging and it seems that some include statements are no longer working.
Here is the code:

<?php
ini_set("open_basedir",ini_get("include_path").":/some/absolute/path/to/httpdocs");
ini_set("include_path",ini_get("include_path").":/some/absolute/path/to/httpdocs/Includes");
$title = 'Some Non-Profit';
include('header.inc');

$rawevents= implode("\n",
file('//some/absolute/path/to/httpdocs/Includes/home_include-events'));
$events = stripmtpara($rawevents);
?>

<!-- ********* MAIN CONTENT SECTION ********** -->

<?php
        include('homeheader.inc');
?>

This code has worked forever so I'm not sure what's up. Based on my
debugging I've found that:

1. The lines starting with $rawevents and $events, when commented out, allow
the page to be rendered, but without the header information.

2. If I change the absolute paths in the ini_set statements to be relative
paths I get my header information.

I'm stumped...any ideas? I'm running PHP 5.2.5.

Thanks!

Jon
--
View this message in context: http://www.nabble.com/Question-About-PHP-Includes-tp16467560p16467560.html
Sent from the PHP - General mailing list archive at Nabble.com.

attached mail follows:


On Thu, Apr 3, 2008 at 11:22 AM, jwynacht <jonobjectevolution.com> wrote:
>
> Hi,
>
> I help maintain a Movable Type install for a non-profit organization. Things
> have worked well with the site but the other day the home page went blank
> and the rest of the pages lost all of their formatting. I've done some
> debugging and it seems that some include statements are no longer working.
> Here is the code:
>
> <?php
> ini_set("open_basedir",ini_get("include_path").":/some/absolute/path/to/httpdocs");
> ini_set("include_path",ini_get("include_path").":/some/absolute/path/to/httpdocs/Includes");
> $title = 'Some Non-Profit';
> include('header.inc');
[snip!]

    Have you tried removing error buffering on the include()
statement? Just remove the and see if there's any errors output on
the screen or to the log.

--
</Daniel P. Brown>
Dedicated servers starting $59.99/mo., VPS starting $19.99/mo.,
and shared hosting starting $2.50/mo.
Just ask!

attached mail follows:


On Thu, Apr 3, 2008 at 11:42 AM, Jon Wynacht <jonobjectevolution.com> wrote:
> Hi Dan,
>
> I just tried that and didn't see any errors on the screen or in my log
> file. I'm really quite stumped and am wondering if my ISP made some changes
> on their end?
>
> Thanks,
>
> Jon

    Please keep all replies on-list, Jon, so others may benefit when
searching the web and the archives.

    If you're on a shared host, that is most likely the reason it's
happening: your host likely made a change without informing you.
Since you can get everything to work with relative paths, but not
absolute paths, it sounds like your account has been chroot'd. If you
can't use relative paths for some reason, try speaking with your host
to have the chroot (jail) removed for that account.

--
</Daniel P. Brown>
Ask me about:
Dedicated servers starting $59.99/mo., VPS starting $19.99/mo.,
and shared hosting starting $2.50/mo.

attached mail follows:


Whoops....sorry abut the reply ;-(

Thanks for the advice...I'll start making the changes in the path.

Cheers,

Jon

On Apr 3, 2008, at 8:56 AM, Daniel Brown wrote:

> On Thu, Apr 3, 2008 at 11:42 AM, Jon Wynacht
> <jonobjectevolution.com> wrote:
>> Hi Dan,
>>
>> I just tried that and didn't see any errors on the screen or in
>> my log
>> file. I'm really quite stumped and am wondering if my ISP made
>> some changes
>> on their end?
>>
>> Thanks,
>>
>> Jon
>
> Please keep all replies on-list, Jon, so others may benefit when
> searching the web and the archives.
>
> If you're on a shared host, that is most likely the reason it's
> happening: your host likely made a change without informing you.
> Since you can get everything to work with relative paths, but not
> absolute paths, it sounds like your account has been chroot'd. If you
> can't use relative paths for some reason, try speaking with your host
> to have the chroot (jail) removed for that account.
>
> --
> </Daniel P. Brown>
> Ask me about:
> Dedicated servers starting $59.99/mo., VPS starting $19.99/mo.,
> and shared hosting starting $2.50/mo.

attached mail follows:


Hi list

I have to copy mails from one IMAP server to an other IMAP server. For that
purpose I want to write a PHP script.

Can anybody help me on that

Thank you very much for your help

Damian

attached mail follows:


Damian Hischier wrote:
> Hi list
>
> I have to copy mails from one IMAP server to an other IMAP server. For that
> purpose I want to write a PHP script.
>
> Can anybody help me on that
>
> Thank you very much for your help

If you really, really want to write your own go for it, but I've
migrated several IMAP servers in the past and the best tool I found for
it was imapsync. It's perl

More info here:
http://freshmeat.net/projects/imapsync/

Download from here:
http://www.linux-france.org/prj/imapsync/dist/

I used this to migrate several large accounts from UW to Cyrus and have
never looked back :)

Col

attached mail follows:


Hi,

I'm a perl programmer and I've written a registration/login program in Perl.

I've just finished writing a small program in php to check the login
cookie created by my perl program
 for any php html page.

Can anyone direct me to a list or forum where one can get a code review
of the php by other experienced
php programmers.

Thanks
David J.

attached mail follows:


On Thu, Apr 3, 2008 at 12:09 PM, David Jourard
<davidjbytesinteractive.com> wrote:
> Hi,
>
> I'm a perl programmer and I've written a registration/login program in
> Perl.
>
> I've just finished writing a small program in php to check the login cookie
> created by my perl program
> for any php html page.
>
> Can anyone direct me to a list or forum where one can get a code review of
> the php by other experienced
> php programmers.

    By "code review", what exactly do you mean? A look-over to see if
it's safe/secure?

    Really, that would be the job of the individual programmer. If
you're concerned about a specific issue or encountering a bug or
something of the like, though, feel free to post more details and a
code snippet. You're in the right place for all of that.

--
</Daniel P. Brown>
Ask me about:
Dedicated servers starting $59.99/mo., VPS starting $19.99/mo.,
and shared hosting starting $2.50/mo.
Unmanaged, managed, and fully-managed!

attached mail follows:


On Thu, 2008-04-03 at 12:09 -0400, David Jourard wrote:
> Hi,
>
> I'm a perl programmer and I've written a registration/login program in Perl.
>
> I've just finished writing a small program in php to check the login
> cookie created by my perl program
> for any php html page.
>
> Can anyone direct me to a list or forum where one can get a code review
> of the php by other experienced
> php programmers.

You could provide links to the source code and post the links here.
Pastebin is often used... http://www.pastebin.com

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

attached mail follows:


On Thu, Apr 3, 2008 at 10:09 AM, David Jourard <davidjbytesinteractive.com>
wrote:

> Can anyone direct me to a list or forum where one can get a code review of
> the php by other experienced
> php programmers.
>

how much code is there ?

-nathan

attached mail follows:


You can simply check the session or cookie

        if(!session_is_registered("user"))
        {
         echo "I cant see the session_register user";
        }else{
        echo "I see the session $user";
        }
User is an example of a session_register("user");
the user variable has been set in the session;

       if (isset($_COOKIE['user']))
        {
         echo "I cant see the COOKIE[user]";
        }else{
        echo "I see the cookie" . $_COOKIE['user'];
        }

User is an example of setcookie("user", $value);
the user value has been set in the cookie.

Please make sure if you use sessions to start the session in the php script by session_start(); on the first line of the php script.

I will look over your code if you want. You came to the right spot for php review. You can simply post your code here for a review by many experts.

Hi,

I'm a perl programmer and I've written a registration/login program in Perl.

I've just finished writing a small program in php to check the login
cookie created by my perl program
 for any php html page.

Can anyone direct me to a list or forum where one can get a code review
of the php by other experienced
php programmers.

Thanks
David J.

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

attached mail follows:


Nathan Nobbe wrote:
>
> how much code is there ?
>
> -nathan
200 lines

Robert Cummings
> You could provide links to the source code and post the links here.
> Pastebin is often used... http://www.pastebin.com
>
Thanks

http://pastebin.com/m6c8cb17c

Daniel Brown wrote:
> By "code review", what exactly do you mean? A look-over to see if
> it's safe/secure?
>
> Really, that would be the job of the individual programmer.
I work alone and this is basically my first program.

I'm interested in feedback as to

a. Am I using the variables correctly wrt global and local and passing
by reference etc.
b. Did I use the correct functions or are there better ones
c. Security - of course
d. Any suggestions on improving overall style.

e. Is it ok to put the include file in the cgi-bin with my perl scripts.

For many of you this is basic stuff probably but I want to make sure I'm
getting it right.

Note the login cookie is created by my perl script and the php program
simply has to check that the user is logged in.

Thanks
David J.

attached mail follows:


On Thu, Apr 3, 2008 at 10:41 AM, David Jourard <davidjbytesinteractive.com>
wrote:

> Nathan Nobbe wrote:
>
> > how much code is there ?
> >
> 200 lines

i think ur safe posting that on the list directly. sometimes people post
several thousand lines and those sort of things are overlooked.

I work alone and this is basically my first program.
>

i drink alone ;)

I'm interested in feedback as to
>
> a. Am I using the variables correctly wrt global and local and passing by
> reference etc.
> b. Did I use the correct functions or are there better ones
> c. Security - of course
> d. Any suggestions on improving overall style.
>
> e. Is it ok to put the include file in the cgi-bin with my perl scripts.
>
> For many of you this is basic stuff probably but I want to make sure I'm
> getting it right.
>
> Note the login cookie is created by my perl script and the php program
> simply has to check that the user is logged in.

drop it in a post and well have a look.

-nathan

attached mail follows:


Nathan Nobbe wrote:
> On Thu, Apr 3, 2008 at 10:09 AM, David Jourard
> <davidjbytesinteractive.com <mailto:davidjbytesinteractive.com>> wrote:
>
> Can anyone direct me to a list or forum where one can get a code
> review of the php by other experienced
> php programmers.
>
>
>
> how much code is there ?
>
> -nathan
I posted it at

http://pastebin.com/m6c8cb17c

Thank-you

David J.

attached mail follows:


On Thu, Apr 3, 2008 at 11:29 AM, David Jourard <davidjbytesinteractive.com>
wrote:

> I posted it at
>
> http://pastebin.com/m6c8cb17c
>

for the variable names, you might consider camelCase or underscores to
enhance readbility, for example

$htmlpathcomponents

would become

$htmlPathComponents (my preference) or

$html_path_components

i would recommend getting away from use of the global keyword in ur
methods. in GetSessionKey and VerifyLoginTicket, why not use a reference
parameter as you did in OpenParam

function VerifyLoginTicket($sessionticket, &$verifydata, &$returnMessages)
function GetSessionKey($id, &$List, &$returnMessages)

i would also recommend getting away from usage of the $GLOBALS array. it
has its place, but in general i would venture to say its best avoided.

also, method names are typically started w/ lower case letters, where as
capitalization is typically used for class names, so for example
VerfiyLoginTicket becomes verfiyLoginTicket

theres really no good reason for calling

return;

as the last line of a function that i can think of; you can safely omit that
statement (eg. last line in VerfiyLoginTicket)

im sure theres more to say here, but im pooped :O

-nathan

attached mail follows:


Along the lines of a previous post "How to get a code review", I am
curious if it is overkill to create everything in classes. For
example, a movie website where there is a class for the movie
datatype, class for getting/adding/deleting/updating movie's data to
the database, and class for displaying the data. (Of course there are
classes for general functionality like sql database connection etc.)
For listing movies alone there are at least 4 different inheritance
classes for chronological, alphabetic, category and keyword. Anyway
this is how I coded something similar but for Flash/Actionscript site
but I'm not sure about a PHP site. I appreciate your comments.
- robert

attached mail follows:


On Thu, Apr 3, 2008 at 10:33 AM, robert <roadtestedgmail.com> wrote:

> Along the lines of a previous post "How to get a code review", I am
> curious if it is overkill to create everything in classes. For example, a
> movie website where there is a class for the movie datatype, class for
> getting/adding/deleting/updating movie's data to the database, and class for
> displaying the data. (Of course there are classes for general functionality
> like sql database connection etc.) For listing movies alone there are at
> least 4 different inheritance classes for chronological, alphabetic,
> category and keyword. Anyway this is how I coded something similar but for
> Flash/Actionscript site but I'm not sure about a PHP site. I appreciate your
> comments.
> - robert

to each his own; i am somewhat of an oop zealot, but i will advise u to heed
the reality that php affords the use of functions in the global namespace
and this feature is often useful even if an application is oop-centric.

sometimes being able to just crank out a function and be done w/ it is nice
:) and other times it makes sense from a design perspective to offer
'convenience' functions in the global scope, which often times may actually
dip into functionality implemented in a class. this sort of stuff will be
getting a twist in days to come (php 5.3+) when we will be able to write
functions (that arent class members) and segregate them from the global
scope albiet namespaces.

-nathan

attached mail follows:


> Along the lines of a previous post "How to get a code review", I am
> curious if it is overkill to create everything in classes.

Everything, yes. Sometimes all you need is a quick and not so dirty
function. Though saying that, OO is generally thought of as the way to go.

> For example,
> a movie website where there is a class for the movie datatype, class for
> getting/adding/deleting/updating movie's data to the database, and class
> for displaying the data. (Of course there are classes for general
> functionality like sql database connection etc.) For listing movies
> alone there are at least 4 different inheritance classes for
> chronological, alphabetic, category and keyword. Anyway this is how I
> coded something similar but for Flash/Actionscript site but I'm not sure
> about a PHP site. I appreciate your comments.

Based on what you've described I would go with the following classes:

Movie

This class would handle fetching the movies data, updating it and/or
deleting it. Or you could have a static Movie method for deleting one,
eg Movie::Delete($id). Could also have a static Add() method which
creates a movie and returns a movie object.

DB Connection

There are plenty of database classes around (not least my own PEAR
replica - http://www.phpguru.org/article.php/121). Others include MDB2,
PDO, ADODB etc.

Movie Listing(s) (abstract?)
  |
  +- By name (alphabetical
  +- By category
  +- By keyword
  +- By date (chronological)

Here you'd have the code to show listings. With common code on the
parent movie listings class and with specific code on the appropriate
child class.

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv

attached mail follows:


Richard Lynch schrieb:
> You probably wouldn't run it through Apache, but you probably COULD
> run an LDAP server of sorts using http://php.net/sockets

Yes... this starts to sound as a solution...

Sorry, I hope I do not sound lazy, I just need a bit of a help to locate
the starting point.

I thought that there could be some way of php to listen to a port and
accept the LDAP request.

> Main problem is one of performance.
>
> The reason most people choose LDAP in the first place is to get
> blazing fast performance, because they NEED it.

I am 100% aware of the fact that LDAP is a read optimized database
(though I am not sure where this optimization goes when back end is
PostgreSQL, for example - the LDAP "commands" seem simple and re-writing
them into SQL can't be so much overhead; the explanation might be that
PostgreSQL powered LDAP is not as fast as... - whatever, I'm not an
expert and this analysis is not my goal, not now.).

> PHP is probably not going to give you blazing fast performance
> compared to an off-the-shelf LDAP server in C.

100% aware of that.

As we have this php/PostgreSQL application and intercepting LDAP
requests seems easy (though I do not know how to do it yet :) - I'm
tempted to write a small funny LDAP thing in php, which can power
Thunderbird address book (which, I think, can only read LDAP anyway,
when e-mail is composed).

And if all works fine and promising (and may be slow) - I can evaluate
the effort to plug a real LDAP into the whole system.

So php is just for prototyping and the result is curious, anyway.

> You may be able to leverage from the code in http://php.net/ldap to
> move most of the heavy lifting into an extension, or perhaps you could
> expand that extension to do so, and then you just have a simple PHP
> wrapper to handle the sockets part.
>
> That would help some, and possibly even come "close" to C performance,
> since the socket open/close/traffic/bandwidth is probably the limiting
> factor there, rather than a single PHP byte-code interpreted function
> call...

I'm not sure I understand well. Do you mean that I could use some of the
C code in http://php.net/ldap ... I am afraid this is beyond what I can.

But I'll play with the socket thing and see what php gets and how I can
re-write it internally and return, and how fast it is, and I'll drop a
line back.

> This is all just my expectations. Feel free to surprise me with
> actual test results. :-)

I'll try :) Thanks for the extensive ideas :) - was encouraging indeed.

Iv