From: Tony M. <cl...@us...> - 2004-04-04 04:35:44
|
Update of /cvsroot/phpwebsite-comm/modules/mailto/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11811/mailto/class Modified Files: Mailto.php Log Message: Fixed e-mail checking bugaboo. Now checking allows bypass it's only to catch blatant errors. Also fixed a validation bug where it would preload your e-mail address after warning you instead of what you changed it to. Index: Mailto.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/mailto/class/Mailto.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Mailto.php 4 Apr 2004 00:24:30 -0000 1.4 --- Mailto.php 4 Apr 2004 04:23:17 -0000 1.5 *************** *** 175,184 **** if($this->_reqlogin == 0) { if(isset($_SESSION['OBJ_user']->username)) { ! $form->add("MT_FROM", "text", $_SESSION['OBJ_user']->username." <".$_SESSION['OBJ_user']->email.">"); } else { $form->add("MT_FROM", "text", $this->_from); } } else { ! $form->add("MT_FROM", "hidden", $_SESSION['OBJ_user']->username." <".$_SESSION['OBJ_user']->email.">"); } $form->setSize("MT_FROM", 30); --- 175,189 ---- if($this->_reqlogin == 0) { if(isset($_SESSION['OBJ_user']->username)) { ! /* Only load it if it has not been loaded yet */ ! if(!isset($_REQUEST["MT_FROM"])) { ! $form->add("MT_FROM", "text", $_SESSION['OBJ_user']->email); ! } else { ! $form->add("MT_FROM", "text", $this->_from); ! } } else { $form->add("MT_FROM", "text", $this->_from); } } else { ! $form->add("MT_FROM", "hidden", $_SESSION['OBJ_user']->email); } $form->setSize("MT_FROM", 30); *************** *** 206,210 **** if($this->_reqlogin <> 0) { ! $tags["MT_FROM"] = $_SESSION['OBJ_user']->username." <".$_SESSION['OBJ_user']->email.">"; } --- 211,215 ---- if($this->_reqlogin <> 0) { ! $tags["MT_FROM"] = $_SESSION['OBJ_user']->email; } *************** *** 323,327 **** if(is_string($address)) { if(strlen($address) > 0) { ! $this->_address = PHPWS_Text::parseOutput($address); return TRUE; } else { --- 328,332 ---- if(is_string($address)) { if(strlen($address) > 0) { ! $this->_address = $address; return TRUE; } else { *************** *** 337,341 **** function setSubject($subject) { if(strlen($subject) > 0) { ! $this->_address = PHPWS_Text::parseOutput($subject); return TRUE; } else { --- 342,346 ---- function setSubject($subject) { if(strlen($subject) > 0) { ! $this->_address = $subject; return TRUE; } else { *************** *** 347,351 **** function setMessage($msg) { if(strlen($msg) > 0) { ! $this->_message = PHPWS_Text::parseOutput($msg); return TRUE; } else { --- 352,356 ---- function setMessage($msg) { if(strlen($msg) > 0) { ! $this->_message = $msg; return TRUE; } else { *************** *** 357,361 **** function getAddress() { if(isset($this->_address) && strlen($this->_address) > 0) { ! return PHPWS_Text::parseOutput($this->_address); } else { return NULL; --- 362,366 ---- function getAddress() { if(isset($this->_address) && strlen($this->_address) > 0) { ! return $this->_address; } else { return NULL; *************** *** 364,381 **** function setFrom($from) { ! if (strstr("<", $from) && !strstr(">", $from)) $from .= ">"; ! if (!(list($name, $email) = split("<", $from, 2))) $email = $from; ! $email = str_replace(">", "", $email); ! if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2}[mtgvu]?$", $email, $check)) { ! if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) { $this->_from = $from; return true; } else { ! $message = $_SESSION["translate"]->it("E-mail address does not appear to be set up properly"); return new PHPWS_Error("mailto", "PHPWS_Mailto::mailit", $message); - // echo 'MX record not found for email: '.$email; } } else { ! $message = $_SESSION["translate"]->it("E-mail address is badly formed. It must be either of the form <i>Your Name <yo...@na...></i> or <i>yo...@na...</i>. Please correct it and try again."); return new PHPWS_Error("mailto", "PHPWS_Mailto::mailit", $message); } --- 369,384 ---- function setFrom($from) { ! if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,4}[mtgvu]?$", $from, $check) || $from == $_SESSION["save_from"]) { ! if (getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) || $from == $_SESSION["save_from"] ) { $this->_from = $from; return true; } else { ! $_SESSION["save_from"] = $from; ! $message = $_SESSION["translate"]->it("E-mail address does not appear to be set up properly. Check the e-mail and if it's correct, press the [Mail it!] button again to send it. Otherwise correct the e-mail address then resend it."); return new PHPWS_Error("mailto", "PHPWS_Mailto::mailit", $message); } } else { ! $_SESSION["save_from"] = $from; ! $message = $_SESSION["translate"]->it("E-mail address is badly formed. It must be of the form <i>yo...@na...</i>. If you are sure it is correct, press [Mail it!] again, otherwise, please correct it and try again."); return new PHPWS_Error("mailto", "PHPWS_Mailto::mailit", $message); } *************** *** 384,388 **** function getFrom() { if(isset($this->_from) && strlen($this->_from) > 0) { ! return PHPWS_Text::parseOutput($this->_from); } else { return NULL; --- 387,391 ---- function getFrom() { if(isset($this->_from) && strlen($this->_from) > 0) { ! return $this->_from; } else { return NULL; *************** *** 392,396 **** function getSubject() { if(isset($this->_subject) && strlen($this->_subject) > 0) { ! return PHPWS_Text::parseOutput($this->_subject); } else { return NULL; --- 395,399 ---- function getSubject() { if(isset($this->_subject) && strlen($this->_subject) > 0) { ! return $this->_subject; } else { return NULL; |