php-general Digest 29 Apr 2009 23:59:59 -0000 Issue 6094

Topics (messages 292122 through 292136):

Re: E-Mail Verification - Yes, I know....
        292122 by: Simon
        292123 by: Al
        292124 by: Bob McConnell

Boolean Parameter to 3 Options?
        292125 by: Matt Neimeyer
        292126 by: João Cândido de Souza Neto
        292128 by: Philip Thompson
        292130 by: Shawn McKenzie
        292131 by: Matt Neimeyer

Programming Question
        292127 by: David Stoltz
        292129 by: Kyle Smith

Re: $_session/$_cookie trouble
        292132 by: Igor Escobar

file_get_contents doesn't work on one particular server
        292133 by: Brian Dunning
        292136 by: Shawn McKenzie

Static and/or Dynamic site scraping using PHP
        292134 by: 9el

Re: utf-8 ?
        292135 by: Reese

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
The SMTP or POP3 protocol (cant remember which) used to support the
ability to connect to the server and verify if a username exists
before delivering the mail.  But this feature was abused and was used
for spamming so it is now disabled on all major servers (it's probably
disabled by default in all servers anyway).

There is no way to verify (without sending an email) if the email will
be received in a mailbox.

Simon

On Tue, Apr 28, 2009 at 11:40 AM, Jay Blanchard <[email protected]> wrote:
> Our company wants to do e-mail verification and does not want to use the
> requests / response method (clicking a link in the e-mail to verify the
> address), which as we all know is the only way you can be truly sure. I
> found this;
>
> http://verify-email.org/
>
> Which seems to be the next best deal and it is written in PHP. Has
> anyone used this? Is anyone doing something similar? How do you handle
> errors? I know that some domains will not accept these requests.
>
> I think that this method would really work for us and cut down on the
> bogus e-mail addresses we're receiving though. Thoughts?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---


Jay Blanchard wrote:
Our company wants to do e-mail verification and does not want to use the
requests / response method (clicking a link in the e-mail to verify the
address), which as we all know is the only way you can be truly sure. I
found this;

http://verify-email.org/

Which seems to be the next best deal and it is written in PHP. Has
anyone used this? Is anyone doing something similar? How do you handle
errors? I know that some domains will not accept these requests.

I think that this method would really work for us and cut down on the
bogus e-mail addresses we're receiving though. Thoughts?

Use login smtp with authenticate

Include Domain Keys and SPF in your message header. Many incoming mail servers use them to verify mail. I've not had one email rejected since using them.
--- End Message ---
--- Begin Message ---
From: Simon
> 
> There is no way to verify (without sending an email) if the email will
> be received in a mailbox.

Even that is not a valid test. Most spam filters will discard messages
silently, that is without notifying either sender or recipient. So the
only real verification is when you receive an actual reply from the
recipient.

Bob McConnell

--- End Message ---
--- Begin Message ---
I have a function that currently takes a boolean value as a parameter.
But now I want to expand it to 3 options...  So if I have...

function doFooBar($doFoo = false)
   {
   if($doFoo)
      { echo "Did Foo"; }
   else
      { echo "Did Bar"; }
   }

Is it as "simple" as changing it like follows to avoid having to
change existing code that won't use the new values.

function doFooBar($doFoo = 0)
   {
   if($doFoo == 2)
      { echo "Did Baz"; }
   else if($doFoo == 1)
      { echo "Did Foo"; }
   else
      { echo "Did Bar"; }
   }

Something about that disturbs me. Perhaps because any time I think "Oh
it will be as simple as..." it usually isn't.

Thanks in advance!

Matt

--- End Message ---
--- Begin Message ---
Why not this:

function doFooBar($doFoo = 0)
   {
   switch ($doFoo) {
       case 2:
            echo "Did Baz";
        break;
       case 1:
            echo "Did Foo";
        break;
        default:
            echo "Did Bar";
        break;
    }
}

I think in this way you can avoid future problems in case you need to add 
other options in this param.

Hope helps.


"Matt Neimeyer" <[email protected]> escreveu na mensagem 
news:[email protected]...
>I have a function that currently takes a boolean value as a parameter.
> But now I want to expand it to 3 options...  So if I have...
>
> function doFooBar($doFoo = false)
>   {
>   if($doFoo)
>      { echo "Did Foo"; }
>   else
>      { echo "Did Bar"; }
>   }
>
> Is it as "simple" as changing it like follows to avoid having to
> change existing code that won't use the new values.
>
> function doFooBar($doFoo = 0)
>   {
>   if($doFoo == 2)
>      { echo "Did Baz"; }
>   else if($doFoo == 1)
>      { echo "Did Foo"; }
>   else
>      { echo "Did Bar"; }
>   }
>
> Something about that disturbs me. Perhaps because any time I think "Oh
> it will be as simple as..." it usually isn't.
>
> Thanks in advance!
>
> Matt 



--- End Message ---
--- Begin Message ---
On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote:

I have a function that currently takes a boolean value as a parameter.
But now I want to expand it to 3 options...  So if I have...

function doFooBar($doFoo = false)
  {
  if($doFoo)
     { echo "Did Foo"; }
  else
     { echo "Did Bar"; }
  }

Is it as "simple" as changing it like follows to avoid having to
change existing code that won't use the new values.

function doFooBar($doFoo = 0)
  {
  if($doFoo == 2)
     { echo "Did Baz"; }
  else if($doFoo == 1)
     { echo "Did Foo"; }
  else
     { echo "Did Bar"; }
  }

Something about that disturbs me. Perhaps because any time I think "Oh
it will be as simple as..." it usually isn't.

Thanks in advance!

Matt

Unless you're doing a strict comparison (===), it probably won't make a lot of difference. However, if you sent "true" to the function, I believe it will reach the last else condition. You may revisit all the locations you call it and update them appropriately.

Those are my initial thoughts....

~Philip


--- End Message ---
--- Begin Message ---
Philip Thompson wrote:
> On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote:
> 
>> I have a function that currently takes a boolean value as a parameter.
>> But now I want to expand it to 3 options...  So if I have...
>>
>> function doFooBar($doFoo = false)
>>   {
>>   if($doFoo)
>>      { echo "Did Foo"; }
>>   else
>>      { echo "Did Bar"; }
>>   }
>>
>> Is it as "simple" as changing it like follows to avoid having to
>> change existing code that won't use the new values.
>>
>> function doFooBar($doFoo = 0)
>>   {
>>   if($doFoo == 2)
>>      { echo "Did Baz"; }
>>   else if($doFoo == 1)
>>      { echo "Did Foo"; }
>>   else
>>      { echo "Did Bar"; }
>>   }
>>
>> Something about that disturbs me. Perhaps because any time I think "Oh
>> it will be as simple as..." it usually isn't.
>>
>> Thanks in advance!
>>
>> Matt
> 
> Unless you're doing a strict comparison (===), it probably won't make a
> lot of difference. However, if you sent "true" to the function, I
> believe it will reach the last else condition. You may revisit all the
> locations you call it and update them appropriately.
> 
> Those are my initial thoughts....
> 
> ~Philip
> 

No, true will match the first condition.  If you're using true and false
now and just want to add a second option then continue using true/false.
 Don't mix and match.  1 == true and 2 == true.

function doFooBar($doFoo = false)
{
   if($doFoo === 2) {
        //something
   }
   elseif($doFoo === true) {
        //something true
   }
   elseif($doFoo === false) {
        //something false
   }
}


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

--- End Message ---
--- Begin Message ---
On Wed, Apr 29, 2009 at 1:30 PM, Shawn McKenzie <[email protected]> wrote:
> Philip Thompson wrote:
>> On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote:
>>
>>> I have a function that currently takes a boolean value as a parameter.
>>> But now I want to expand it to 3 options...  So if I have...
>>>
>>> function doFooBar($doFoo = false)
>>>   {
>>>   if($doFoo)
>>>      { echo "Did Foo"; }
>>>   else
>>>      { echo "Did Bar"; }
>>>   }
>>>
>>> Is it as "simple" as changing it like follows to avoid having to
>>> change existing code that won't use the new values.
>>>
>>> function doFooBar($doFoo = 0)
>>>   {
>>>   if($doFoo == 2)
>>>      { echo "Did Baz"; }
>>>   else if($doFoo == 1)
>>>      { echo "Did Foo"; }
>>>   else
>>>      { echo "Did Bar"; }
>>>   }
>>>
>>> Something about that disturbs me. Perhaps because any time I think "Oh
>>> it will be as simple as..." it usually isn't.
>>>
>>> Thanks in advance!
>>>
>>> Matt
>>
>> Unless you're doing a strict comparison (===), it probably won't make a
>> lot of difference. However, if you sent "true" to the function, I
>> believe it will reach the last else condition. You may revisit all the
>> locations you call it and update them appropriately.
>>
>> Those are my initial thoughts....
>>
>> ~Philip
>>
>
> No, true will match the first condition.  If you're using true and false
> now and just want to add a second option then continue using true/false.
>  Don't mix and match.  1 == true and 2 == true.
>
> function doFooBar($doFoo = false)
> {
>   if($doFoo === 2) {
>        //something
>   }
>   elseif($doFoo === true) {
>        //something true
>   }
>   elseif($doFoo === false) {
>        //something false
>   }
> }
>

Ah. I somehow missed the direction of the typecasting. Not that the
documentation isn't completely explicit on the matter but for some
reason I was thinking that the bool got cast to 1 or 0... not that the
string/number got cast to a bool (following the standards there).

Good to know.

Thanks

Matt

--- End Message ---
--- Begin Message ---
Hi Folks,

I'm a PHP newbie - but this question really isn't about PHP per se',
it's more about programming in general, and how to do something...

I'm redesigning an ASP site with Dreamweaver CS4, so I'll be sticking to
using ASP technology....

The site will use horizontal navigation for the MAIN MENU which will be
static, but each page therein will have a vertical sub menu, probably
with 2-3 levels deep - which will need to be dynamic.

I'm trying to figure out a good way to organize and maintain the
submenus. I need each page to "know where it is" so the breadcrumb trail
can be accurate and dynamic. The page/menu will also need to know how to
display the correct submenu/level.....hopefully this all can be
dynamic....

I also want to avoid query string parameters, such as
page.asp?menu=1&submenu=3 type stuff.....

My current thought is to use URL rewriting and a database - but I'm not
sure if this is the best route....

Does anyone have any suggestions? HELP!

Thanks!

--- End Message ---
--- Begin Message ---
David Stoltz wrote:
Hi Folks,

I'm a PHP newbie - but this question really isn't about PHP per se',
it's more about programming in general, and how to do something...

I'm redesigning an ASP site with Dreamweaver CS4, so I'll be sticking to
using ASP technology....

The site will use horizontal navigation for the MAIN MENU which will be
static, but each page therein will have a vertical sub menu, probably
with 2-3 levels deep - which will need to be dynamic.

I'm trying to figure out a good way to organize and maintain the
submenus. I need each page to "know where it is" so the breadcrumb trail
can be accurate and dynamic. The page/menu will also need to know how to
display the correct submenu/level.....hopefully this all can be
dynamic....

I also want to avoid query string parameters, such as
page.asp?menu=1&submenu=3 type stuff.....

My current thought is to use URL rewriting and a database - but I'm not
sure if this is the best route....

Does anyone have any suggestions? HELP!

Thanks
At a very basic level I think a database is overkill. I would write some sort of include for the top most menu, that includes a function to generate the sub menus and a breadcrumb trail. This is psuedo-code, but here's the idea:

// Include top menu and some functions.
include('menu-lib.php');
// Build sub-menu, using my location.
echo build_sub_menu('Contact', 'Sales &quot; Marketing');

This way you can maintain all the menu/breadcrumb/etc in one file, and have the information you need in each page to generate it.

HTH,
- Kyle


--- End Message ---
--- Begin Message ---
A few days ago i had a problem similar to their and it was a problem with
files with BOM signature... maybe its your case.


Regards,
Igor Escobar
Systems Analyst & Interface Designer

--

Personal Blog
~ blog.igorescobar.com
Online Portifolio
~ www.igorescobar.com
Twitter
~ @igorescobar





On Tue, Apr 28, 2009 at 11:00 PM, Gary <[email protected]> wrote:

> Ok, working code.  I'm sure there is some left over code that is not
> actually working, but I have been playing frankenstein all day. Basically a
> vistor fills in 3 (only two set so far) inputs to see if they qualify for a
> rebate.  If they do, they can go on to file two to submit their
> information.
>
> This is my first project using $_cookie or $_session.  I have done an
> exercise or two in lessons using them, but this is my first attempt from
> scratch.
>
> File1 of 2
> <?php
> session_start();
> ?>
>
> <?php
> $_SESSION=array('$sale_value', 'assess_value');
>
>
> $sale_value=$_POST['sale'];
> $assess_value=$_POST['assess'];
>
> $mil_rate=.03965;
> $ratio=.51;
>
> $present_tax=($assess_value) * ($mil_rate);
> $correct_tax=($sale_value)*($ratio)*($mil_rate);
> $savings=($present_tax)-($correct_tax);
>
> if ($savings > 0.00){
> echo '<h2 style="margin:0;color:#ff0000;">Yes, Your property appears to
> qualify!</h2><br /><br />';
> }
> if ($savings < 0.00){
> echo '<h3 style="margin:0;">NO, Your property does not appear to qualify.
> </h3><br /><br />';
> }
> echo 'According to the information you have entered<br />';?><br />
> <?php
> echo "You believe your home would today sell for
> $".number_format($sale_value)."<br />";
> echo "Your current tax assessment is $".number_format($assess_value)."<br
> />";
> echo 'You live in <br /><br />';
> echo 'According to preliminary calculations<br /><br />';
> echo "You are currently paying now  $".number_format($present_tax, 2)."<br
> /><br />";
> echo "According to the information you have submitted, your taxes should be
> $ ".number_format($correct_tax, 2)."<br />";
> ?>
> <br/><?php
> if ($savings > 0.00){
> echo "According to our preliminary calculations, a successful assessment
> appeal could save you annually on your current real estate taxes. <b>$
> ".number_format($savings, 2)."</b> ";
> }
> if ($savings < 0.00){
> echo 'It does not appear that an appeal would be successful in saving you
> money this year. If property values in your area continue to decline, you
> may wish to revisit the issue next year.</h3><br /><br />';
> }
>
> $_SESSION['sale_value'] ='$sale_value';
> $_SESSION['assess_value'] ='$assess_value';
>
> ?>
> <p style="font-size:.8em; color:#666666;">If you feel you have entered
> incorrect information, hit your browsers back button to re-calculate with
> the new information</p><br />
> <p style="text-align:center; color:#FF0000; font-size:1.4em;"><b>Important
> Notice!</b></p>
> <p style="text-align:center; border:#990000 1px solid;">This <b>DOES
> NOT</b>
> constitute a legal opinion by !<br /> No information has been
> submitted.</p>
> <p>In order to proceed with an assessment appeal, you must contact my
> office
> that we may verify all pertinent information regarding your a real estate
> assessment appeal case</p>
>
> <p> To submit this information to , please complete the following form.</p>
>
> <form action="sendresult.inc.php" method="post">
> First Name <input name="fname" type="text" /><br /><br />
> Last Name <input name="lname" type="text" /><br /><br />
> Property Street Address <input name="street" type="text" /> <br /><br />
> Town or City <input name="town" type="text" /><br/><br />
> Zip Code <input name="zip" type="text" /><br /><br />
> County <input name="county" type="text" /><br /><br />
> Phone Number <input name="phone" type="text" /><br /><br />
> E-Mail Address <input name="email" type="text" /><br /><br />
> <input name="$assess_value" type="hidden" value="$assess_value">
> <input name="submit" type="submit" value="Submit">
> </form>
>
> File 2
>
> <?php
>
> ?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>Untitled Document</title>
> </head>
>
> <body>
> <?php
> $fname=STRIPSLASHES($_POST['fname']);
> $lname=STRIPSLASHES($_POST['lname']);
> $street=STRIPSLASHES($_POST['street']);
> $town=STRIPSLASHES($_POST['town']);
> $zip=STRIPSLASHES($_POST['zip']);
> $county=STRIPSLASHES($_POST['county']);
> $phone=STRIPSLASHES($_POST['phone']);
> $email=STRIPSLASHES($_POST['email']);
> $assess_value=$_COOKIE['assess_value'];
> $sale_value=$_COOKIE['sale_value'];
>
>
> echo "Thank you $fname for your submission!<br />";
> echo "You have submitted the following information.<br />";
> echo "Name:$fname  $lname<br />";
> echo "Address:$street $town  $zip<br />";
> echo "Phone Number: $phone<br />";
> echo "E-Mail Address: $email<br />";
> echo "You believe your home would sell for $"; echo
> $_COOKIE['sale_cookie'];
> ?><br /><?php
> echo "Your assessment value is $"; echo $_COOKIE['assess_cookie'];?><br
> /><?php
> echo "You live in $county<br />";
>
>
>
>
>
> ?>
> </body>
> </html>
>
>
>
> "Lists" <[email protected]> wrote in message news:[email protected]...
> > Andrew Hucks wrote:
> >> $sale_value would have worked if it hadn't been in single quotes, I
> >> believe. (Assuming it was populated.).
> >
> > Which it wasn't.. ;-) according to Gary's last post. He assigned it now
> > with 'sale'.. however, I think it should rather be in double quotes
> > ("sale") if he wants to get the posted value.
> >
> > echo $sale_value;
> >
> > now works because sale_value has been assigned a value.
> >
> > But:
> > echo $_COOKIE['sale_cookie'];
> >
> > I would guess will still not work.. until landing on the
> > next page, or reloading the first page.
> >
> >
> >  When you put it in quotes, you
> >> were making the cookie's value a string instead of a variable. So, the
> >> value would actually have literally been $sale_value, rather than the
> >> value for that variable. It is working with $_POST['sale'] because
> >> there are no single quotes. :-p.
> >
> >
> > Gary, if you want to post your "working" code, we could probably
> > tell you the "why's"... and it would also cater to my curiosity. ;-)
> >
> > Donovan
> >
> >
> > --
> >   =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o
> >   D. BROOKE                       EUCA Design Center
> >                                WebDNA Software Corp.
> >   WEB:> http://www.euca.us  |   http://www.webdna.us
> >   =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o
> >   WebDNA: [** Square Bracket Utopia **]
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message --- Howdy all - We have a production server that runs our script fine. We're setting up a test server, and this particular script returns a length of zero:

$ctx = stream_context_create(array('http' => array('timeout' => 1200))); // 20 minutes per file
$contents = file_get_contents($full_url, 0, $ctx);

You can paste the $full_url into a browser and it works fine (it's always a PDF document). It works fine with the same variables on the production server. Is there some configuration option that we've missed that's preventing it from working? Note that this is all https, and I did notice this difference in the phpinfo() but don't know if it's relevant:

Production server: PHP 5.2.6
Registered PHP streams: php, file, data, http, ftp, compress.zlib, compress.bzip2, https, ftps, zip

Test server: PHP 5.2.9-2
Registered PHP streams: php, file, data, http, ftp, compress.zlib



--- End Message ---
--- Begin Message ---
Brian Dunning wrote:
> Howdy all - We have a production server that runs our script fine. We're
> setting up a test server, and this particular script returns a length of
> zero:
> 
> $ctx = stream_context_create(array('http' => array('timeout' => 1200)));
> // 20 minutes per file
> $contents = file_get_contents($full_url, 0, $ctx);
> 
> You can paste the $full_url into a browser and it works fine (it's
> always a PDF document). It works fine with the same variables on the
> production server. Is there some configuration option that we've missed
> that's preventing it from working? Note that this is all https, and I
> did notice this difference in the phpinfo() but don't know if it's
> relevant:
> 
> Production server: PHP 5.2.6
> Registered PHP streams: php, file, data, http, ftp, compress.zlib,
> compress.bzip2, https, ftps, zip
> 
> Test server: PHP 5.2.9-2
> Registered PHP streams: php, file, data, http, ftp, compress.zlib
> 
> 

Most likely allow_url_fopen = Off in the test server php.ini.  If you
had error reporting on it would tell you.

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

--- End Message ---
--- Begin Message ---
I just got a project to do on PHP of scraping the body items from
static sites or just html sites.
Could you experts please suggest me some quick resources?

I have to make an WP plugin with the data as well.

Regards

Lenin

www.twitter.com/nine_L

--- End Message ---
--- Begin Message ---
Tom Worster wrote:
On 4/28/09 4:05 PM, "Reese" <[email protected]> wrote:

Granted, this isn't a PHP question but I'm curious, how does UTF-8 solve
this display issue?

if we're talking about web browsers, they are quite good at automatically
choosing fonts that can display the unicode characters it finds in a page.

Right, and I figured out the bit that was confusing me earlier: years
ago, I read that some encodings such as &#0147; and &#0148; (curly
quotes) should not be used, that &#8220; and &#8221; should be used
instead. I misremembered that, when I looked at the utf-8 charset here:

http://www.columbia.edu/kermit/utf8-t1.html

I stand apprised and enlightened. I found the encodings for letters G
with breve, S with cedilla, and lower case I w/out the dot, too.

Reese




--- End Message ---

Reply via email to