?? formprocessorpro.php
字號:
<?php
/*##############################################################################*/
/*# Form Mail: eMail Form Processor Pro #*/
/*# Version 4.0.2 #*/
/*##############################################################################*/
/*# Developer: MitriDAT #*/
/*# Last Modified 15.08.2003 #*/
/*##############################################################################*/
/*# COPYRIGHT NOTICE #*/
/*# Copyright 2000-2003, MitriDAT. All Rights Reserved. #*/
/*# #*/
/*# Please check ReadMe file for full details on installation #*/
/*##############################################################################*/
/*#*** *** DO NOT EDIT PAST THIS LINE *** ***#*/
/*##############################################################################*/
error_reporting(E_ALL ^E_NOTICE);
$Months= array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); array_unshift($Months, "");
$Weekdays= array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$base_path = "./";
$error_loop = 0;
$browser_out = 0;
$cfg_file = "formprocessorpro.cfg";
$mail_format = "plain";
//FIX 24/07/2003
if (!file_exists($cfg_file)) {
if ($HTTP_ENV_VARS["windir"]) {//windows
$cfg_file = str_replace('\\','/',dirname($HTTP_SERVER_VARS['PATH_TRANSLATED'])).'/formprocessorpro.cfg';
}
$cfg_file = str_replace('//','/',$cfg_file);
}
//FIX 24/07/2003
$cfg_form = "form.cfg";
$content_type = "Content-Type: text/html";
$multi_separator = ", ";
//##############################################################################
$HTTP_ENV_VARS['UPDATED'] = ' ';
// default message
if (($HTTP_SERVER_VARS['REQUEST_METHOD'] === 'GET') && (!$HTTP_SERVER_VARS['QUERY_STRING'])) {
$HTTP_ENV_VARS['UPDATED'] = '';
StartPage();
exit;
}
$lines = ReadFile2('Configuration File', $cfg_file);
foreach ($lines as $line) {
if (preg_match("/^(Referers)\s*=\s*(.+?)\s*(\x23|$)/",$line,$m)) {
$GLOBALS[$m[1]][] = $m[2];
}
else {
if (preg_match("/^(\w+)\s*=\s*(.+?)\s*(\x23|$)/",$line,$m))
{$GLOBALS[$m[1]] = "$m[2]";}
}
}
// we can inherit base-path from page sequence:
if ($HTTP_POST_VARS['base_path']) { $base_path = $HTTP_POST_VARS['base_path'] .'/';}
if ($HTTP_POST_VARS['_base_path']) { $base_path = $HTTP_POST_VARS['_base_path'] .'/';}
// The following reads the form config. TMP var - "base_path" still remains
//Say GoodBye to form hidden fields :)
$lines=ReadFile2('Form Configuration File', $base_path . $cfg_form);
foreach ($lines as $line) {
if (preg_match("/^(attachments_path|mail_format)\s*=\s*(.+?)\s*(\x23|$)/",$line,$m))
{$GLOBALS[$m[1]] = $m[2];}
if (preg_match("/^(\w+)\s*=\s*(.+?)\s*(\x23|$)/",$line,$m))
{
$GLOBALS["FORM"][$m[1]] = "$m[2]";
}
}
$attachments_path=$base_path.$attachments_path;
//# let's party
ParseForm();
CheckRef();
if (preg_match ("/(\/\/|\.)aol\.com/i", $HTTP_SERVER_VARS['HTTP_REFERER'])) $mail_format="plain";
if (preg_match ("/(\/\/|\.)not/i", $HTTP_SERVER_VARS['HTTP_REFERER'])) $mail_format="plain";
if (!$FORM['_format_decimals']) $FORM['_format_decimals'] = "0";
if (!$FORM['GMT_OFFSET']) $FORM['GMT_OFFSET'] = "0";
// DATE FORMATTING
if (!$date_format) $date_format = 'dd.mm.yyyy';
$date = $date_format;
list ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(strtotime($FORM['GMT_OFFSET']." hour"));
$mon++; $year+=1900; $syear="0".($year-2000);
if (strlen($mday)<2){$mday="0".$mday;}
$date= preg_replace("/weekday/i", $Weekdays[$wday], $date);
$date= preg_replace("/wee/ei", substr($Weekdays[$wday],0,3), $date);
$date= preg_replace("/month/i",$Months[$mon], $date);
$date= preg_replace("/mmm/ei",substr($Months[$mon],0,3), $date);
$mon = (strlen($mon)<2?"0":"").$mon; // "0" schreiben oder nicht?
$date= preg_replace("/yyyy/i", $year, $date);
$date= preg_replace("/yy/i", $syear, $date);
$date= preg_replace("/dd/i", $mday, $date);
$date= preg_replace("/mm/i", $mon, $date);
$HTTP_ENV_VARS['DATE_GMT'] = sprintf("%02d:%02d:%02d %s GMT %d",$hour,$min,$sec,$date,$FORM['GMT_OFFSET']);
// END DATE FORMATTING
srand(time());
$rnd1 = sprintf("%04d", floor(rand(0,10000)));
$rnd2 = sprintf("%04d", floor(rand(0,10000)));
if (!$FORM['unique_reference_number']) {$FORM['unique_reference_number'] = "$year$mon$mday-$rnd1-$rnd2";}
if (is_array($missing_values) || is_array($bad_emails) || is_array($only_digits) || is_array($only_words)) { Error('evil values'); }
foreach ($FORM as $key => $val)
{
$FORM[$key] = preg_replace("/\x22/", "'",$val);
}
foreach ($FORM as $key => $val)
{
$pn=$FORM['page_no']; $pn++;
//NOT
// start_email is hidden field in the form which email has to been sent after
if (preg_match("/^_send_email/", $key))
{
if (!$FORM["_browser_out".$pn]) {
$lines = ReadFile2('Email Template',$base_path.$FORM[$key]);
$lines = ParseText($lines);
$lines = ParseEmail($lines);
SendMailBySmtp($lines);
// BrowserOut(array("Mail ($val) was sent OK!<br>")) ;
}
}
else{if (preg_match("/^_out_file/", $key))
{
if (!$FORM["_browser_out".$pn]) {
$lines = ReadFile2('Log File',$base_path.$FORM[$key]);
$lines = ParseText($lines);
LogFile('LogFile Template',$lines);
}
}
else{if (preg_match("/^_browser_out".$FORM['page_no']."$/",$key) and $browser_out < 2)
{
// #NOT Loading template:
$browser_out++;
$lines = ReadFile2('Browser Template', $base_path.$FORM[$key]);
$lines = ParseText($lines);
// Appending POST variables as hidden fields
for ($i=0; $i<count($lines);$i++) {
if (preg_match("/(<\/form>)/i",$lines[$i])) {
$hfields="";
foreach ($FORM as $k => $v) {
if (preg_match("/^page_no/",$k)) {$v++;}
$hfields .= '<input type="hidden" name="'.$k.'" value="'.stripslashes($v).'">'."\n";
}
if (!$FORM[page_no]) {$hfields .= '<input type="hidden" name="page_no" value="1">'."\n";}
$lines[$i]=preg_replace("/(<\/form>)/i","$hfields\\1",$lines[$i]);
}
}
BrowserOut($lines);
}
else{if (preg_match("/^_redirect/",$key) and $browser_out < 2)
{
$browser_out++;
Header("Location: ".$FORM[$key]);
}
}}}
}
if (!$browser_out) {
$msg = get_data();
$HTTP_ENV_VARS['OUT_TITLE'] = "Submission Successful";
$HTTP_ENV_VARS['OUT_MSG'] = "Your submission was successful. Thank you.";
$msg = ParseText($msg);
BrowserOut($msg);
}
//clearing attached files
if (is_dir($attachments_path)) {
if ($dh = opendir($attachments_path)) {
while (($file = readdir($dh)) !== false) $files_list[] = $file;
closedir($dh);
$files_list = preg_grep( "/^\d{8}_(.*)_\._file$/", $files_list);
foreach ($files_list as $attachment_file) {
list($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($attachments_path.$attachment_file);
if (time() >= $mtime + $attachments_ttl) {unlink($attachments_path.$attachment_file);}
}
}
}
// end clearing attached files
exit;
function ParseEmail($arr)
{
global $attachments_path, $email, $mail_format;
$email= new mime_mail();
for ($i=0; $i<count($arr); $i++)
{
if (preg_match("/^Attachment: (.+)$/i",$arr[$i],$ma))
{
$files = split (',', $ma[1]);
foreach ($files as $attachment_file)
{
$attachment_file = trim($attachment_file);
if (preg_match("/([^\/\\:]*)$/",$attachment_file,$ma))
{
$attachment_file = $ma[1];
}
if (preg_match("/^\d{8}_(.*)_\._file$/",$attachment_file,$ma))
{$real_name = $ma[1];}
else {$real_name = $attachment_file;}
$email->add_attachment($attachments_path,$attachment_file,$real_name);
}
} else {
// Strip tags if mail format is plain, skipping service info lines
if (($mail_format == "plain") && (!preg_match("/^(From|To|Cc|Bcc):/i",$arr[$i])))
{
$arr[$i]=strip_tags($arr[$i]);
}
if (!preg_match("/^(to|from|b?cc|subject|attachment): (.+)$/i",$arr[$i],$ma))
{$email->add_html($arr[$i]);}
else {
$mail_param = $ma[1];
$mail_val = $ma[2];
$var_name = "mail_".strtolower($mail_param);
if ($var_name == "mail_cc" || $var_name == "mail_bcc" || $var_name == "mail_from") {
$email->headers.=$mail_param.": ".trim($mail_val)."\n";
}
}
}
}
$email->build_message($mail_format);
return $arr;
}//ParseEmail
function SendMailBySmtp($arr)
{
global $email, $mailserver;
foreach ($arr as $line)
{
if (preg_match("/^(to|from|bcc|cc|subject): (.+)$/i",$line, $ma))
{
$mail_param = $ma[1];
$mail_val = $ma[2];
if (preg_match("/<(.+)>/",$mail_val, $ma)) $mail_val = $ma[1];
$var_name = "mail_".strtolower($mail_param);
$$var_name = $mail_val;
}
}
$email->send($mailserver,$mail_to, $mail_from, $mail_subject);
}//SendMailBySmtp
function BrowserOut($arr)
{
global $content_type;
@Header($content_type);
foreach ($arr as $a) print $a;
}//BrowserOut
function ParseForm()
{
global $HTTP_ENV_VARS, $HTTP_POST_VARS, $HTTP_POST_FILES, $FORM, $missing_values,$bad_emails,$only_digits,$only_dig_and_dolar,$only_words,$attachments_path,$mail_format,$multi_separator,$max_file_size;
foreach ($HTTP_POST_VARS as $name => $value)
{
//FIX 07.07.2003
if ($mail_format == "html") {
$value = nl2br($value);
}
$FORM[$name] = $value;
if (preg_match("/^([rs]*[edwmcn]?[rs]*)".chr(95)."/",$name)) {
list($prefs, $key) = explode(chr(95), $name, 2);
if (preg_match("/s/i",$prefs) and $value) {
$value = trim($value);
$FORM[$name] = $value;
}
if (preg_match("/m/i",$prefs) and $value and is_array($value)) {
if ($FORM['_multi_separator']) $multi_separator = $FORM['_multi_separator'];
$value = join($multi_separator,$value);
$value = preg_replace("/^default$multi_separator/i","",$value);
$value = preg_replace("/^default/i","",$value);
$value = preg_replace("/".$multi_separator."$/i","",$value);
$FORM[$name] = $value;
}
if (preg_match("/n/i",$prefs) and $value) {
$value = str_replace("\n","",$value);
$value = str_replace("\r","",$value);
$FORM[$name] = $value;
}
if (preg_match("/r/i",$prefs) and !strlen($value))
{ $missing_values[] = $key;}
if (preg_match("/e/i",$prefs) and $value and isEmailBad($value))
{ $bad_emails[] = $key;}
if (preg_match("/d/i",$prefs) and $value and !preg_match("/^(\d+|\d+\.\d+)$/",$value))
{ $only_digits[] = $key;}
if (preg_match("/c/i",$prefs) and $value and !preg_match("/^(\$?\d+\$?|\$?\d+\.\d+\$?)$/",$value))
{ $only_dig_and_dolar[] = $key;}
if (preg_match("/w/i",$prefs) and $value and !preg_match("/\W/",$value))
{ $only_words[] = $key;}
}
}
foreach ($HTTP_POST_FILES as $key => $file) {
if (file_exists($file["tmp_name"])) {
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -