$fromemail, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $conf['smtpUser'], 'password' => $conf['smtpPass'])); $mail = $smtp->send($to, $headers, $message); if (PEAR::isError($mail)) errormsg($mail->getMessage()); } elseif($conf['smtpEnable'] == 0){ if(trim($to) != "") mail(trim($to), stripslashes($subject), stripslashes($message), $headers); } } } function writestandard() { global $message, $theDomain, $ignoreempty; $message="Here is the information collected:\n\n"; foreach($_POST as $varname => $varval) { if($ignoreempty===true && empty($varval)) continue; 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, $ignoreempty; $thearray = Array(); if($fp = @fopen($thefile, 'r')) { while($data = fgets($fp, 1024)) { $data = chop($data); foreach($_POST as $varname => $varval) { if($ignoreempty===true && empty($varval)) continue; 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 $conf['excludeFields']; foreach($conf['excludeFields'] as $field) { $field = trim($field); if(strcmp(strtolower($field), strtolower($theVar)) == 0) $req = true; } return $req; } function checkreferal() { global $conf['referrals'], $theDomain; $valid = false; foreach($conf['referrals'] as $ref) { $ref = trim($ref); if(strcmp($theDomain, $ref) == 0) { $valid = true; break; } } if(!$valid) badreferer($theDomain); } function errormail($errormsg) { if (validemail($conf['errorTo'])) mail($conf['errorTo'], 'Error on form', $errormsg, $headers); } function fillrecipients() { global $recipients; $recipients = explode(",", $_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) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) return true; else return false; } function writeStyles() { global $errMsgStyle, $errDetStyle; echo ""; } ?>