$fromemail, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $smtpUser, 'password' => $smtpPass)); $mail = $smtp->send($to, $headers, $message); if (PEAR::isError($mail)) errormsg($mail->getMessage()); } elseif($smtpEnable == 0){ if(trim($to) != "") mail(trim($to), stripslashes($subject), stripslashes($message), $headers); } } } function writestandard() { global $message, $theDomain; $message="Here is the information collected:\n\n"; foreach($_POST as $varname => $varval) { if(is_array($varval)) $varval = implode(", ",$varval); if(!exclude($varname)) { $message .= "$varname: "; if(count($varval) > 1) { for($i = 0; $i < count($varval); $i++) if($i < count($varval) - 1) $message .= "$varval[$i], "; else $message .= "$varval[$i]"; } else { $message .= "$varval"; } $message .= "\n"; } } } function writetemplate($thefile) { global $message, $theDomain; $thearray = Array(); if($fp = @fopen($thefile, 'r')) { while($data = fgets($fp, 1024)) { $data = chop($data); foreach($_POST as $varname => $varval) { if(is_array($varval)) $varval = implode(", ",$varval); $data = str_replace("[$varname]", $varval, $data); } $message .= $data . "\n"; } fclose($fp); } } function redirect() { global $redirectURL; header("Location: " . $redirectURL); } function exclude($theVar) { $req = false; global $excludeFields; foreach($excludeFields as $field) { $field = trim($field); if(strcmp(strtolower($field), strtolower($theVar)) == 0) $req = true; } return $req; } function checkreferal() { global $referals, $theDomain; $valid = false; foreach($referals as $ref) { $ref = trim($ref); if(strcmp($theDomain, $ref) == 0) { $valid = true; break; } } if(!$valid) badreferer($theDomain); } function errormail($errormsg) { if (validemail($errorTo)) mail($errorTo, 'Error on Accu-Trim Form', $errormsg, $headers); } function fillrecipients() { global $recipients; $recipients = split(",", $_POST['recipient']); } function missingfield($field) { writeStyles(); echo "
"; echo "The Missing Field:"; echo "$field"; echo "
"; errormail("The Missing Field:".$field); exit; } function badreferer($ref) { writeStyles(); echo ""; echo "This domain is not authorized for use of this script:"; echo "$ref"; echo "
"; errormail("This domain is not authorized for use of this script:".$ref); exit; } function bademail($email) { writeStyles(); echo ""; echo "The email address you provided is not a valid email address:"; echo "$email"; echo "
"; errormail("The email address you provided is not a valid email address:".$email); exit; } function errormsg($msg) { writeStyles(); echo ""; echo "$msg"; echo "
"; errormail("An Error Has Occured:".$msg); exit; } function getdomain($url) { $host = parse_url($url, PHP_URL_HOST); $host = preg_replace("(www\.)","",$host); return $host; #preg_match("/^(http:\/\/)?([^\/]+)/i", $url, $matches); #$host = $matches[2]; #preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches); #return $matches[0]; } function validemail($email) { // define a regular expression for "normal" addresses $normal = "^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$"; // define a regular expression for "strange looking" but syntactically valid addresses $validButRare = "^[a-z0-9,!#\$%&'\*\+/=\?\^_`\{\|}~-]+(\.[a-z0-9,!#\$%&'\*\+/=\?\^_`\{\|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,})$"; if (eregi($normal, $email)) return true; else if (eregi($validButRare, $email)) return true; else return false; } function writeStyles() { global $errMsgStyle, $errDetStyle; echo ""; } ?>