php-general Digest 2 May 2010 08:11:32 -0000 Issue 6723

Topics (messages 304820 through 304840):

Re: Getting root privs
        304820 by: Shawn McKenzie

Re: Two color rows in table inside while iteration -- just say no to mod
        304821 by: Richard Quadling

Re: Any One See where this is going wrong?
        304822 by: Gary
        304825 by: Richard Quadling
        304829 by: tedd
        304831 by: Adam Richardson
        304832 by: Gary
        304837 by: Adam Richardson
        304838 by: Brandon Rampersad

Re: SharePoint
        304823 by: Richard Quadling

Re: A stupid question about classes
        304824 by: Andre Polykanine
        304826 by: Richard Quadling
        304830 by: Andre Polykanine

Re: multi dimensional array question
        304827 by: Richard Quadling

Re: Project TIME calculated, in PHP
        304828 by: Richard Quadling
        304840 by: Peter Lind

wondering how to catch notice errors properly
        304833 by: Rene Veerman
        304834 by: Rene Veerman

Re: Object or such for building a directory tree?
        304835 by: Michelle Konzack

pecl install pam and the current bug
        304836 by: fakessh

Re: Two color rows in table inside while iteration
        304839 by: Paul M Foster

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 04/30/2010 09:53 AM, Nilesh Govindarajan wrote:
> That was what my basic idea about implementing it, but just put up a
> discussion here to see if there is really any other method except sudo-
> and there is that cron one as suggested by Jim Lucas.
> 

Use the sudoers file to allow your apache user to run specific commands
with optional wildcard parameters:

http://linuxmanpages.com/man5/sudoers.5.php

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
On 30 April 2010 21:20, Daevid Vincent <dae...@daevid.com> wrote:
>> -----Original Message-----
>> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
>>
>> Modulus is the most elegant solution I reckon. Imagine if you only
>> needed to highlight every 3rd row, or 4th? Easy to change the modulus
>> for it, not so easy to re-work a binary switch.
>>
>> -----Original Message-----
>> From: Richard Quadling [mailto:rquadl...@googlemail.com]
>>
>> The modulus is a good option when there are more than 2 states.
>>
>> Say a 5 row fade ...
>>
>> $a=0;
>> while ($row=mysql_fetch_...){
>> echo "<tr class=??????\"alternate-row-".(1 + (++$a%5))."\"><..."
>> }
>>
>> giving alternate-row-1, alternate-row-2, alternate-row-3,
>> alternate-row-4 and alternate-row-5
>
> Okay, how many tables do you EVER see with more than TWO colors? Come on
> now.
>
> Show me some URL's to REAL sites (not some contrived examples) that use
> multiple row colors or fades in a rotating fashion. Not talking about a
> highlight roll-over, nor am I talking about highlighting rows of certain
> criteria in different colors, as both of those are not the problem for this
> solution. I'm talking about a straight up table that cycles each row more
> than 2 colors.
>
> 99% of your tables are 2 colors, and flipping a bit (i.e. Boolean) is WAY
> faster to compute than modulus and also easier to understand.
>
> http://www.youtube.com/watch?v=pXhKzY0BKwY  ;-) (I say that out of love!)
>
> d
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Ha. OK, I actually do use a bit toggle for assigning a CSS class to
the alternative rows. But I did once use % where the table represented
a top10 list.



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
"Adam Richardson" <simples...@gmail.com> wrote in message 
news:aanlktil-gwsrxmbbwkcv7gic_ybzv9t4s7eurhpyd...@mail.gmail.com...
> >
>> If the OP does clean his $_POST before putting the results in his 
>> database,
>> his database will look like 'poo' if the wrong person comes along.
>
>
> Gary had mentioned in his initial post he was testing on a local machine 
> and
> would add the checks after resolving this issue.
>
>
>>
>
> Also, the OP's code reads:
>
>  ($image_type == 'image/pjpeg') || ($image_type == 'image/png') &&
>
> That should be:
>
>  ($image_type == 'image/jpeg') || ($image_type == 'image/png') &&
>
>
> Tedd, Gary's original code does include jpeg AND pjpeg types (if you omit
> pjpeg's, you'll miss some images.)
>
> That said, Gary, Tedd did point out some important issues with the logic 
> in
> your code.
>
> Additionally, you were asked politely to not top post, but you continued 
> to
>> do so. If you expect us to help you but you won't accommodate a simple, 
>> and
>> appropriate request, then don't expect any more help from me.
>
>
>> bye!
>
>
> Where was he asked to avoid top-posting in this thread?
>
> What is top posting?
>
>
> Gary, top-posting is when you add your content to an email thread at the 
> top
> (as opposed to the bottom) of the email message.  The preferred method of
> this list's admins is that you add your reply to the bottom of the message
> thread.  So, in future posts, please try to remember to add your message 
> to
> the bottom of the thread instead of the top.  Thanks :)
>
> Gary, what is the INSERT line for the images table supposed to be (it 
> looks
> like it got mangled in your copying and pasting?)
>
> $sqlStatements = "INSERT INTO guns( id,manufacturer, type, model,
>
> caliber, condition, price, description, image_file_name,submitted
>
> ,available) VALUES ('','$manufacturer', '$type', '$model', '$caliber',
>
> '$condition', '$price', '$description','$image_file_name', ' ',
>
> '$available');
>
>
>> INSERT INTO images (id, image_file) VALUES('','$image_file')";
>
>
>>  $sqlResult = $batchconnection->multi_query($sqlStatements);
>
>  if($sqlResult == true) {
>
>      echo "Successfully Inserted Records";
>
>  } else {
>
>      echo "Some Error Occured While Inserting Records";
>
> }
>
>
> Adam
>
> -- 
> Nephtali:  PHP web framework that functions beautifully
> http://nephtaliproject.com
>
>
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 5077 (20100501) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>

Adam

Thank thank you for your reply.

This is the code for the INSERT

 $sqlStatements = "INSERT INTO guns (manufacturer, type, model, caliber, 
condition, price, description, image_file_name, available) VALUES 
('$manufacturer', '$type', 
'$model','$caliber','$condition','$price','$description','$image_file_name','$available');

 INSERT INTO images(id, image_file) VALUES ('', '$image_file')";

This seems to be the stopping point because when I intentionaly create 
errors (connecting to db) then the error message I created shows up.  None 
of the data is being inserted into the DB.

This script works fine in another DB on the same server.

 $sqlStatements = "INSERT INTO images(caption, where_taken,description, 
file_name, image_file) VALUES ('$caption','$where_taken','$description', 
'$file_name','$image_file');

INSERT INTO keywords (image_id,fox, wolves, wildlife, scenic, birds, eagles, 
deer, small_mammals, large_mammals, dogs, cats, flowers, insects, bear, 
moose) 
VALUES('','$fox','$wolves','$wildlife','$scenic','$birds','$eagles','$deer', 
'$small_mammals', '$large_mammals','$dogs', '$cats', '$flowers', '$insects', 
'$bear', '$moose')";

As far as the whole "top posting".  I have been posting on this board for 2 
years (give or take), in fact have had a number of exchanges with tedd, (so 
I was a little surprised at his response). I have never heard the term top 
posting, I had not been asked not to top post.  Jim Lucas had at the bottom 
of his reply.

Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

However I read that as a signature line, not a request.

So, sorry if I offended.

Adam

Again, thank you for your response, I appriciate any help you might be able 
to offer.

Gary 



__________ Information from ESET Smart Security, version of virus signature 
database 5077 (20100501) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--- End Message ---
--- Begin Message ---
Top Posting is putting your reply BEFORE the question.

A bit like this!



On 1 May 2010 17:37, Gary <gwp...@ptd.net> wrote:
> What is top posting?
>
> Gary

Why is it bad?

Because you read the reply before the reason for the reply and that
makes our head hurt.

Eventually people actually stop replying to known top posters.

It makes their heads hurt.

So.

In the interest of not hurting any, intentional or otherwise, please
bottom post.

And snip out non relevant content in your reply as not everyone is on
super fast broadband and downloading the many many layers of reply can
be annoying.

Regards,

Richard.

--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
At 3:18 PM -0400 5/1/10, Gary wrote:
As far as the whole "top posting".  I have been posting on this board for 2
years (give or take), in fact have had a number of exchanges with tedd, (so
I was a little surprised at his response). I have never heard the term top
posting, I had not been asked not to top post.

Okay, so now you know and everything is peachy.

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
>
>  $sqlStatements = "INSERT INTO guns (manufacturer, type, model, caliber,
>
condition, price, description, image_file_name, available) VALUES

('$manufacturer',
> '$type', 
> '$model','$caliber','$condition','$price','$description','$image_file_name','$available');

 INSERT INTO images(id, image_file) VALUES ('', '$image_file')";


Gary, the second insert has what appears to be a troublesome bit of code:

VALUES ('', '$image_file')";

Shouldn't it read:

INSERT INTO images(image_file) VALUES ('$image_file')";

That's assuming you have id set to auto-increment, so no id in the first or
second set of parentheses.  Additionally, the ", before the $image_file var
would cause issues, too.

Adam
-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
"Adam Richardson" <simples...@gmail.com> wrote in message 
news:aanlktinqixxb9oipu4op2xztrze_vwpbymaywziwb...@mail.gmail.com...
> >
>>  $sqlStatements = "INSERT INTO guns (manufacturer, type, model, caliber,
>>
> condition, price, description, image_file_name, available) VALUES
>
> ('$manufacturer',
>> '$type', 
>> '$model','$caliber','$condition','$price','$description','$image_file_name','$available');
>
> INSERT INTO images(id, image_file) VALUES ('', '$image_file')";
>
>
> Gary, the second insert has what appears to be a troublesome bit of code:
>
> VALUES ('', '$image_file')";
>
> Shouldn't it read:
>
> INSERT INTO images(image_file) VALUES ('$image_file')";
>
> That's assuming you have id set to auto-increment, so no id in the first 
> or
> second set of parentheses.  Additionally, the ", before the $image_file 
> var
> would cause issues, too.
>
> Adam
> -- 
> Nephtali:  PHP web framework that functions beautifully
> http://nephtaliproject.com
>
>
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 5078 (20100501) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>

Adam

The second INSERT is part of a multi_query, and yes there is a 
auto-increment field in front named id,  it is the foreign key that links 
the tables.

I had removed, and just tried again, but the same result.

I have tried it so many ways my fingers and eyes are about to bleed. It 
makes not sense how it works in one but not the other.

I cant see to get the error called out.

Thanks again.

Gary




__________ Information from ESET Smart Security, version of virus signature 
database 5078 (20100501) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--- End Message ---
--- Begin Message ---
On Sat, May 1, 2010 at 6:54 PM, Gary <gwp...@ptd.net> wrote:

>
> "Adam Richardson" <simples...@gmail.com> wrote in message
> news:aanlktinqixxb9oipu4op2xztrze_vwpbymaywziwb...@mail.gmail.com...
> > >
> >>  $sqlStatements = "INSERT INTO guns (manufacturer, type, model, caliber,
> >>
> > condition, price, description, image_file_name, available) VALUES
> >
> > ('$manufacturer',
> >> '$type',
> >>
> '$model','$caliber','$condition','$price','$description','$image_file_name','$available');
> >
> > INSERT INTO images(id, image_file) VALUES ('', '$image_file')";
> >
> >
> > Gary, the second insert has what appears to be a troublesome bit of code:
> >
> > VALUES ('', '$image_file')";
> >
> > Shouldn't it read:
> >
> > INSERT INTO images(image_file) VALUES ('$image_file')";
> >
> > That's assuming you have id set to auto-increment, so no id in the first
> > or
> > second set of parentheses.  Additionally, the ", before the $image_file
> > var
> > would cause issues, too.
> >
> > Adam
> > --
> > Nephtali:  PHP web framework that functions beautifully
> > http://nephtaliproject.com
> >
> >
> >
> > __________ Information from ESET Smart Security, version of virus
> > signature database 5078 (20100501) __________
> >
> > The message was checked by ESET Smart Security.
> >
> > http://www.eset.com
> >
> >
>
> Adam
>
> The second INSERT is part of a multi_query, and yes there is a
> auto-increment field in front named id,  it is the foreign key that links
> the tables.
>
> I had removed, and just tried again, but the same result.
>
> I have tried it so many ways my fingers and eyes are about to bleed. It
> makes not sense how it works in one but not the other.
>
> I cant see to get the error called out.
>
> Thanks again.
>
> Gary
>
>
>
>
> __________ Information from ESET Smart Security, version of virus signature
> database 5078 (20100501) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
And you also removed the double quote and the comma next to it (sorry, just
making sure?)  That is to say, you copied the line of code I sent?

$sqlStatements = "INSERT INTO guns( *id,*manufacturer, type, model, //
*id,*should be removed
caliber, condition, price, description, image_file_name,submitted
,available) VALUES ('*',*'$manufacturer', '$type', '$model', '$caliber',
   // the *",* combo should be removed
'$condition', '$price', '$description','$image_file_name', ' ',
'$available');

INSERT INTO images (*id,* image_file) VALUES('','$image_file')";          //
the *id,* should be removed AND the *",* combo should be removed

Also, have you tried directly echoing out the error (e.g., *echo
mysql_error();*  if it's mysql you're using, or the comparable method in the
library you're using.)

If that didn't work, I'd break up the multi-query into 2 separate queries to
better troubleshoot the issue.  I like using PDO and setting it up so it
throws exceptions when something goes wrong (additionally, I like using the
prepared statements, too.)  Have you been trying that?

I'm still hopeful you'll get this figured out before there's any blood-loss
;)

Feel free to send back the new code after the edits if you still have
issues.

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
yeah, try using the PDO instead

On Sat, May 1, 2010 at 9:14 PM, Adam Richardson <simples...@gmail.com>wrote:

> On Sat, May 1, 2010 at 6:54 PM, Gary <gwp...@ptd.net> wrote:
>
> >
> > "Adam Richardson" <simples...@gmail.com> wrote in message
> > news:aanlktinqixxb9oipu4op2xztrze_vwpbymaywziwb...@mail.gmail.com...
> > > >
> > >>  $sqlStatements = "INSERT INTO guns (manufacturer, type, model,
> caliber,
> > >>
> > > condition, price, description, image_file_name, available) VALUES
> > >
> > > ('$manufacturer',
> > >> '$type',
> > >>
> >
> '$model','$caliber','$condition','$price','$description','$image_file_name','$available');
> > >
> > > INSERT INTO images(id, image_file) VALUES ('', '$image_file')";
> > >
> > >
> > > Gary, the second insert has what appears to be a troublesome bit of
> code:
> > >
> > > VALUES ('', '$image_file')";
> > >
> > > Shouldn't it read:
> > >
> > > INSERT INTO images(image_file) VALUES ('$image_file')";
> > >
> > > That's assuming you have id set to auto-increment, so no id in the
> first
> > > or
> > > second set of parentheses.  Additionally, the ", before the $image_file
> > > var
> > > would cause issues, too.
> > >
> > > Adam
> > > --
> > > Nephtali:  PHP web framework that functions beautifully
> > > http://nephtaliproject.com
> > >
> > >
> > >
> > > __________ Information from ESET Smart Security, version of virus
> > > signature database 5078 (20100501) __________
> > >
> > > The message was checked by ESET Smart Security.
> > >
> > > http://www.eset.com
> > >
> > >
> >
> > Adam
> >
> > The second INSERT is part of a multi_query, and yes there is a
> > auto-increment field in front named id,  it is the foreign key that links
> > the tables.
> >
> > I had removed, and just tried again, but the same result.
> >
> > I have tried it so many ways my fingers and eyes are about to bleed. It
> > makes not sense how it works in one but not the other.
> >
> > I cant see to get the error called out.
> >
> > Thanks again.
> >
> > Gary
> >
> >
> >
> >
> > __________ Information from ESET Smart Security, version of virus
> signature
> > database 5078 (20100501) __________
> >
> > The message was checked by ESET Smart Security.
> >
> > http://www.eset.com
> >
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> And you also removed the double quote and the comma next to it (sorry, just
> making sure?)  That is to say, you copied the line of code I sent?
>
> $sqlStatements = "INSERT INTO guns( *id,*manufacturer, type, model, //
> *id,*should be removed
> caliber, condition, price, description, image_file_name,submitted
> ,available) VALUES ('*',*'$manufacturer', '$type', '$model', '$caliber',
>   // the *",* combo should be removed
> '$condition', '$price', '$description','$image_file_name', ' ',
> '$available');
>
> INSERT INTO images (*id,* image_file) VALUES('','$image_file')";
>  //
> the *id,* should be removed AND the *",* combo should be removed
>
> Also, have you tried directly echoing out the error (e.g., *echo
> mysql_error();*  if it's mysql you're using, or the comparable method in
> the
> library you're using.)
>
> If that didn't work, I'd break up the multi-query into 2 separate queries
> to
> better troubleshoot the issue.  I like using PDO and setting it up so it
> throws exceptions when something goes wrong (additionally, I like using the
> prepared statements, too.)  Have you been trying that?
>
> I'm still hopeful you'll get this figured out before there's any blood-loss
> ;)
>
> Feel free to send back the new code after the edits if you still have
> issues.
>
> Adam
>
> --
> Nephtali:  PHP web framework that functions beautifully
> http://nephtaliproject.com
>



-- 
A Brandon_R Production

--- End Message ---
--- Begin Message ---
On 1 May 2010 07:59, Robbert van Andel <robb...@vafam.com> wrote:
> I've been trying to connect to our SharePoint server's webservices
> with PHP. I downloaded the nusoap library and have been trying to make
> a connection using sample code from various websites. I keep getting
> the following error:
>
> <h1>You are not authorized to view this page</h1>
> You do not have permission to view this directory or page using the
> credentials that you supplied because your Web browser is sending a
> WWW-Authenticate header field that the Web server is not configured to
> accept.
> <h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server
> configuration.<br>Internet Information Services (IIS)</h2>
>
> My code looks like this:
>
> require_once('/usr/share/php/nusoap/nusoap.php');
>
> /*  Your username and password, separated by a colon
>    Domain may be optional, depending on your setup */
> $auth = "username:password";
>
> /*  Location of the Lists.asmx file
>    If the list is in a subsite, the subsite must be in the path */
> $wsdl = "http://domain.com/depts/is/private/_vti_bin/Lists.asmx?WSDL";;
>
> /*  GUID of the list */
> $guid = "Shared Documents";
>
> /* Setup NuSOAP
>   Sharepoint requires NTLM Authorization
>   You need a fairly recent version of CURL installed for this  */
> try {
>        $client = new nusoap_client($wsdl,true);
>        $client->setCredentials("","","ntlm");
>        $client->setUseCurl(true);
>        $client->useHTTPPersistentConnection();
>        $client->setCurlOption(CURLOPT_USERPWD, $auth);
>        //$client->soap_defencoding = 'UTF-8';
>
>
>        $xml = '
> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>  <soap:Body>
>    <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/";>
>      <listName>' . $guid . '</listName>
>      <viewName>All Documents</viewName>
>      <query>
>        <xsd:schema>schema</xsd:schema>xml</query>
>      <viewFields>
>        <xsd:schema>schema</xsd:schema>xml</viewFields>
>      <rowLimit>string</rowLimit>
>      <queryOptions>
>        <xsd:schema>schema</xsd:schema>xml</queryOptions>
>      <webID>string</webID>
>    </GetListItems>
>  </soap:Body>
> </soap:Envelope>
>        ';
>
>        $result = $client->call("GetListItems",$xml);
>        if(isset($fault)) {
>                echo "<p>Error: " . $fault . "</p>\n";
>        }
>        echo "<pre>\$result = " .
> htmlspecialchars(print_r($result,true)) . "</pre>\n";
>  }
> catch(Exception $e) {
>
>        echo "<p>" . $e->getMessage() . "</p>\n";
> }
>
>
> Our SharePoint server uses integrated authentication. I've tried
> several permutations of the username, including just the username,
> domain\username and usern...@domain. All are returning the same error.
> My guess is that PHP is sending the username/password combination in a
> way that SharePoint doesn't like.
>
> Has anyone been able to connect to SharePoint's web services and if so, how?
>
> Thanks
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I've not tried cURL, but I have managed to get PHP to talk through an
NTLM proxy.

See my user note on
http://docs.php.net/manual/en/function.stream-context-get-default.php

Unfortunately, the link to an old site I had is dead.

But it was just some long windedness about http://ntlmaps.sourceforge.net/

Though you can use the Way Back When Machine (please make sure your ad
blockers are working - sorry!!!!) :
http://web.archive.org/web/20080427012158/http://rquadling.php1h.com/php_ntlm.php

If you go down this route, then also take a look at
http://web.archive.org/web/20080501043118/rquadling.php1h.com/python_ntlm.php
which is more on the same.


What this all means that you use the NTLMAPS proxy to do the NTLM
authentication for you.


But, hopefully, all of this isn't needed and that PHP now supports
NTLM authentication within cURL. Ideally, it should also be available
for regular stream contexts.

Richard.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
Hello Nilesh,

So could you illustrate a bit the __construct() function, please?
Should I pass those variables as parameters of that function? And what
if I need to change their values?)
Thanks!
-- 
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

----- Original message -----
From: Nilesh Govindarajan <li...@itech7.com>
To: php-gene...@lists.php.net <php-gene...@lists.php.net>
Date: Saturday, May 1, 2010, 8:16:37 PM
Subject: [PHP] A stupid question about classes

On 05/01/2010 10:23 PM, Andre Polykanine wrote:
> Hello everyone,
> Just a basic question.
> I have my class starting like this:
>
> Class OireMail {
> // these are required
> public $smtp_server="";
> public $domain="";
> public $from="";
> public $login="";
> public $pass="";
>
> And then go the function themselves.
> I was told that it's better to put the initial variables in the
> __construct() function. What are the advantages of doing that and if I
> need to do it, how would I call the class from another file then?
> Thanks!
>

The advantages of initializing the variables in __construct() is that 
whenever an object of the class is created, the variables have the 
values you expect.

If you don't put them in __construct(), you will have to create another 
method which will have to be called after you have created the object 
using the new operator.

Ultimately its the same thing, __construct() is called automatically, 
only that's the difference.

-- 
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
???? ???? ???? !
?? ????: ?????? ???? !

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


--- End Message ---
--- Begin Message ---
On 1 May 2010 20:38, Andre Polykanine <an...@oire.org> wrote:
> Hello Nilesh,
>
> So could you illustrate a bit the __construct() function, please?
> Should I pass those variables as parameters of that function? And what
> if I need to change their values?)
> Thanks!

<?php
// The generic class which can act standalone.
Class OireMail {
        // these are required
        public $smtp_server="";
        public $domain="";
        public $from="";
        public $login="";
        public $pass="";

        public function __construct($smtp_server = '', $domain = '', $from =
'', $login = '', $pass = '') {
                $this->stmp_server = $smtp_server;
                $this->domain = $domain;
                $this->from = $from;
                $this->login = $login;
                $this->pass = $pass;
        }
}

// Let's create a generic email class and supply all the params.
$Mail = new OireMail('Server', 'Domain', 'f...@domain.com', 'login',
'Passw0rd');


// A more specialised version of the class with all the required params pre set.
Class SpecialisedOireMail extends OireMail {
        public function __construct() {
                parent::__construct('SpecServer', 'SpecDomain',
's...@specdomain.com', 'SpecLogin', 'SpecPassw0rd');
        }
}

// Let's create a specialised version. Note - no need to supply params
as the sub-class deals with that.
$SpecMail = new SpecialisedOireMail();

var_dump($Mail, $SpecMail);
?>

outputs ...

object(OireMail)#1 (6) {
  ["smtp_server"]=>
  string(0) ""
  ["domain"]=>
  string(6) "Domain"
  ["from"]=>
  string(15) "f...@domain.com"
  ["login"]=>
  string(5) "login"
  ["pass"]=>
  string(8) "Passw0rd"
  ["stmp_server"]=>
  string(6) "Server"
}
object(SpecialisedOireMail)#2 (6) {
  ["smtp_server"]=>
  string(0) ""
  ["domain"]=>
  string(10) "SpecDomain"
  ["from"]=>
  string(19) "s...@specdomain.com"
  ["login"]=>
  string(9) "SpecLogin"
  ["pass"]=>
  string(12) "SpecPassw0rd"
  ["stmp_server"]=>
  string(10) "SpecServer"
}


Hope that helps.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
Hello Richard,

thanks a lot!

-- 
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

----- Original message -----
From: Richard Quadling <rquadl...@googlemail.com>
To: Andre Polykanine <an...@oire.org>
Date: Saturday, May 1, 2010, 10:49:49 PM
Subject: [PHP] A stupid question about classes

On 1 May 2010 20:38, Andre Polykanine <an...@oire.org> wrote:
> Hello Nilesh,
>
> So could you illustrate a bit the __construct() function, please?
> Should I pass those variables as parameters of that function? And what
> if I need to change their values?)
> Thanks!

<?php
// The generic class which can act standalone.
Class OireMail {
        // these are required
        public $smtp_server="";
        public $domain="";
        public $from="";
        public $login="";
        public $pass="";

        public function __construct($smtp_server = '', $domain = '', $from =
'', $login = '', $pass = '') {
                $this->stmp_server = $smtp_server;
                $this->domain = $domain;
                $this->from = $from;
                $this->login = $login;
                $this->pass = $pass;
        }
}

// Let's create a generic email class and supply all the params.
$Mail = new OireMail('Server', 'Domain', 'f...@domain.com', 'login',
'Passw0rd');


// A more specialised version of the class with all the required params pre set.
Class SpecialisedOireMail extends OireMail {
        public function __construct() {
                parent::__construct('SpecServer', 'SpecDomain',
's...@specdomain.com', 'SpecLogin', 'SpecPassw0rd');
        }
}

// Let's create a specialised version. Note - no need to supply params
as the sub-class deals with that.
$SpecMail = new SpecialisedOireMail();

var_dump($Mail, $SpecMail);
?>

outputs ...

object(OireMail)#1 (6) {
  ["smtp_server"]=>
  string(0) ""
  ["domain"]=>
  string(6) "Domain"
  ["from"]=>
  string(15) "f...@domain.com"
  ["login"]=>
  string(5) "login"
  ["pass"]=>
  string(8) "Passw0rd"
  ["stmp_server"]=>
  string(6) "Server"
}
object(SpecialisedOireMail)#2 (6) {
  ["smtp_server"]=>
  string(0) ""
  ["domain"]=>
  string(10) "SpecDomain"
  ["from"]=>
  string(19) "s...@specdomain.com"
  ["login"]=>
  string(9) "SpecLogin"
  ["pass"]=>
  string(12) "SpecPassw0rd"
  ["stmp_server"]=>
  string(10) "SpecServer"
}


Hope that helps.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling


--- End Message ---
--- Begin Message ---
On 30 April 2010 23:57, Nick Balestra <n...@beyounic.com> wrote:
> us_census = array('NY' => array('New York' => 8008278),
>                                   'CA' => array('Los Angeles' => 3694820,
>                                                                 'San Diego' 
> => 1223400),
>                                   'IL' => array('Chicago' => 2896016),
>                                   'TX' => array('Houston' => 1953631,
>                                                                 'Dallas' => 
> 1188580,
>                                                                 'San Antonio' 
> => 1144646),
>                                   'PA' => array('Philadelphia' => 1517550),
>                                   'AZ' => array('Phoenix' => 1321045),
>                                   'MI' => array('Detroit' => 951270));

<?php
$us_census = array ( ... );

function Sum($a, $b) {
        return $a + (is_array($b) ? array_reduce($b, 'Sum') : $b);
}

echo array_reduce($us_census, 'Sum');
?>

outputs ...

23899236

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
On 1 May 2010 18:48, justino garcia <jgarciaitl...@gmail.com> wrote:
> tImeArrived = CDate(InputBox("Enter START time:", "Start time", "9:00 AM"))
> TimeLeft = CDate(InputBox("Enter END time:", "End time", "1:24 PM"))
> Minutes = DateDiff("n", TimeArrived, TimeLeft)
> Hours = Int(Minutes / 60)
> Minutes = Minutes - (Hours * 60)
> TotalTime = Format(Hours, "0") & ":" & Format(Minutes, "00")
>
> I did something like this in VBA, but I want to create something for PHP.
>
> How can  extract an am or pm from the input string, convert to 24 hours for
> calculations, then convert back to 12 hour am/pm format in PHP?
>

$Start_AM_PM = date('A', strtotime($_POST['StartTime']));
$End_am_pm = date('a', strtotime($_POST['EndTime']));

http://docs.php.net/manual/en/function.date.php
and
http://docs.php.net/manual/en/function.strtotime.php
>
> I want to be able to put 9:00 am as Time Arrived, and 1:00 PM as Time Left,
> then it puts in the subject the total time i worked on X project.
>
> IN VBA thier is time diff function, how do I create something like that that
> will create a email message, that is then sent to a suplied email, (i.e. our
> ticket system).
>
> Basically I want to transform my VBA code to PHP, so I can run a similar
> idea on my Blackberry so other technicians in our office can send a proper
> email on a blackberry while on call in the road.
>
>
>
> This is what I did in VBA
>
> " Dim OutlookMessage As Outlook.MailItem
> Set OutlookMessage = Application.CreateItem(olMailItem)
> MsgBox ("Welecome To Support Email")
> custname = InputBox("Enter Cust name ", "Enter Cust Name", "Put Cust Name")
> job = InputBox("Work done", "Work", "Short Discrption")
>
> TimeArrived = CDate(InputBox("Enter START time:", "Start time", "9:00 AM"))
> TimeLeft = CDate(InputBox("Enter END time:", "End time", "1:24 PM"))
> Minutes = DateDiff("n", TimeArrived, TimeLeft)
> Hours = Int(Minutes / 60)
> Minutes = Minutes - (Hours * 60)
> TotalTime = Format(Hours, "0") & ":" & Format(Minutes, "00")
>
>
> OutlookMessage.Subject = custname & ": " & Date & "  " & job
> OutlookMessage.To = "b...@blah.com"
> OutlookMessage.CC = "bla...@blah.com"
> OutlookMessage.Body = custname & " " & Chr(13) & Date & Chr(13) & "A: " &
> TimeArrived & Chr(13) & "E:" & TimeLeft & Chr(13) & "Total: " & TotalTime &
> " " & Chr(13)
>
> --
> "
> THanks
> Justin
> IT-TECH
>



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
On 1 May 2010 22:02, Richard Quadling <rquadl...@googlemail.com> wrote:
> On 1 May 2010 18:48, justino garcia <jgarciaitl...@gmail.com> wrote:
>> tImeArrived = CDate(InputBox("Enter START time:", "Start time", "9:00 AM"))
>> TimeLeft = CDate(InputBox("Enter END time:", "End time", "1:24 PM"))
>> Minutes = DateDiff("n", TimeArrived, TimeLeft)
>> Hours = Int(Minutes / 60)
>> Minutes = Minutes - (Hours * 60)
>> TotalTime = Format(Hours, "0") & ":" & Format(Minutes, "00")
>>
>> I did something like this in VBA, but I want to create something for PHP.
>>
>> How can  extract an am or pm from the input string, convert to 24 hours for
>> calculations, then convert back to 12 hour am/pm format in PHP?
>>

Consider the DateTime class, might suit your needs.
http://dk2.php.net/manual/en/class.datetime.php

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

--- End Message ---
--- Begin Message ---
I have an custom error handler that i initialize as such;

error_reporting(E_ALL);
$oldError_handler = set_error_handler("nonFatalErrorHandler");

with this, notices are still displayed as single line visible html.
i'd like to catch the notices and push them into a db.
any ideas on how i do that?

-- 
---------------------------------
Greetings from Rene7705,

My free open source webcomponents:
  http://code.google.com/u/rene7705/
  http://mediabeez.ws/downloads (and demos)

http://www.facebook.com/rene7705
---------------------------------

--- End Message ---
--- Begin Message ---
On Sun, May 2, 2010 at 1:06 AM, Rene Veerman <rene7...@gmail.com> wrote:
> I have an custom error handler that i initialize as such;
>
> error_reporting(E_ALL);
> $oldError_handler = set_error_handler("nonFatalErrorHandler");
>
> with this, notices are still displayed as single line visible html.
> i'd like to catch the notices and push them into a db.
> any ideas on how i do that?
>
http://www.codeunit.co.za/2009/09/09/php-how-to-catch-a-script-warning-or-notice/

has the answer :)


> --
> ---------------------------------
> Greetings from Rene7705,
>
> My free open source webcomponents:
>  http://code.google.com/u/rene7705/
>  http://mediabeez.ws/downloads (and demos)
>
> http://www.facebook.com/rene7705
> ---------------------------------
>



-- 
---------------------------------
Greetings from Rene7705,

My free open source webcomponents:
  http://code.google.com/u/rene7705/
  http://mediabeez.ws/downloads (and demos)

http://www.facebook.com/rene7705
---------------------------------

--- End Message ---
--- Begin Message ---
Hello tedd,

Am 2010-05-01 11:54:45, hacktest Du folgendes herunter:
> Now on to your problem. You want to take a multidimensional array
> that contains the names of directories and names of the files
> contained therein and show them in a file tree where you can open
> and close the nodes of the tree to show contents -- is that correct?

Yes for the File-Browser.  The IMAP  Browser  need  only  the  directory
structure, but...

> It's pretty simple to populate an array in PHP to contain
> directories and files. To do this via PHP can produce something like
> this:
> 
> http://php1.net/b/file-browser

But where is the PHP script?  There is no link to download the ZIP.

> I'm not happy with the result because it doesn't show a file tree
> complete with clickable nodes.

Yeah...  This is what I am missing too.

> While I am sure it's possible to do this in PHP, I was thinking that
> javascript might provide a better functional solution (i.e.,
> client-side with less trips to the server). Namely have PHP create
> the array and then have javascript show it.
> 
> This is what I found:
> 
> http://labs.abeautifulsite.net/projects/js/jquery/fileTree/demo/

But it uses AJAX which I can not use.  I must check it again, because  I
need a custom connector and have only to output this:

<ul class="jqueryFileTree" style="display: none;">
    <li class="directory collapsed"><a href="#" rel="/this/folder/">Folder 
Name</a></li>
    (additional folders here)
    <li class="file ext_txt"><a href="#" 
rel="/this/folder/filename.txt">filename.txt</a></li>
    (additional files here)
</ul>

which I, more or less, have already.
This mean, for IMAP I have simply to s/./_/g

Thanks, Greetings and nice Day/Evening
    Michelle Konzack
    Systemadministrator

-- 
##################### Debian GNU/Linux Consultant ######################
   Development of Intranet and Embedded Systems with Debian GNU/Linux

<http://www.itsystems.tamay-dogan.net/>  <http://www.flexray4linux.org/>
<http://www.debian.tamay-dogan.net/>         <http://www.can4linux.org/>

Attachment: signature.pgp
Description: Digital signature


--- End Message ---
--- Begin Message ---
hello list
hello guru of php


it is php pecl install pam.
and bugs that prevented the driver from running pam
the driver does not work
I site bug
http://pecl.php.net/bugs/bug.php?id=16995

thanks for advice

--- End Message ---
--- Begin Message ---
On Fri, Apr 30, 2010 at 01:52:25PM -0400, tedd wrote:

> At 10:34 AM -0400 4/30/10, Paul M Foster wrote:
>> On Thu, Apr 29, 2010 at 05:34:38PM -0400, tedd wrote:
>>
>>  > Please critically review my example.
>>
>> +1
>>
>> This thread came up before, and tedd's solution was the least complex,
>> as far as I could tell. I shamelessly stole his code and regularly use
>> it in my own projects. ;-}
>>
>> Paul
>
> Paul:
>
> Thanks for the plug.
>
> All the code I provide on this list and on my various web sites is
> for free for anyone, except for "governments" (i.e., local, state,
> federal, other), to use, review, and/or comment as they wish without
> any obligation to me. Oh, as for "governments" if you want a copy of
> anything please contact me directly, I have a few forms for you to
> fill out.

If you think about it, that's pretty hilarious. Normally, doing anything
with the government requires *you* to fill out a few forms. Making
*them* do it to use your stuff is humorously appropriate.

Paul

-- 
Paul M. Foster

--- End Message ---

Reply via email to