Hallo Jörg,
hier:
function VarSub(&$ph_string) {
$ph_pstring = $ph_string;
while (ereg("\{\{([^}]*)\}\}", $ph_pstring, $ph_regs)) {
$ph_pstring = str_replace($ph_regs[0], „“, $ph_pstring);
$ph_SubVar = $ph_regs[1];
// If $$ph_SubVar is an array, break it down
ereg("^([A-Za-z0-9_]*)(([[A-Za-z0-9_]*])*)$", $ph_SubVar, $ph_regs2);
$ph_SubVar = $ph_regs2[1];
global $$ph_SubVar;
$ph_indices = split("][", ereg_replace("^[|]$", „“, $ph_regs2[2]));
$ph_SubVal = $$ph_SubVar; $ph_idx = 0;
while (is_array($ph_SubVal))
$ph_SubVal = $ph_SubVal[$ph_indices[$ph_idx++]];
$ph_string = str_replace($ph_regs[0], $ph_SubVal, $ph_string);
}
}
if (!isset($ph_ForceDec)) $ph_ForceDec = true;
/*
Unset any ph_ variables to prevent anyone from trying to sneak something in */
while (list($ph_var, $ph_val) = each($GLOBALS))
if (ereg("^ph_", $ph_var) && !ereg("^ph_ForceDec$", $ph_var)) {
unset($$ph_var);
unset($ph_var);
}
reset($GLOBALS);
define(„ph_DECLARE“, „{{FORM}}“);
/*
Record the configuration variables passed from the form, then unset them */
if ($ph_ForceDec) {
while (list($ph_var, $ph_val) = each($GLOBALS))
if (ereg("^PHORM_", $ph_var)) {
$ph_varHold[$ph_var] = $ph_val;
unset($$ph_var);
}
}
reset($GLOBALS);
if (!$PHORM_LOGQUOT) $PHORM_LOGQUOT = „’“;
if (!$PHORM_LDELIM) $PHORM_LDELIM = „\t“;
/*
Restore $PHORM_NAME and process the configuration file */
$PHORM_NAME = $ph_varHold[„PHORM_NAME“];
$ph_Config = basename($PHORM_NAME).".phm";
if ($ph_debug3) echo " NS: Config file $ph_Config
";
if (!is_readable($ph_Config)) {
$ph_Errs[‚020‘] = "### - Unable to open configuration file $ph_Config.
\n";
$ph_Abort = true;
}
else {
include ("$ph_Config");
}
/*
Check the Referer */
if ($PHORM_REFERER && !$ph_Abort) {
if ($ph_debug3) echo " NS: Referer
";
ereg(„https?://([^/]*)/([^?]*)“, $HTTP_REFERER, $ph_regs);
$ph_RefHost = $ph_regs[1]; $ph_RefPath = $ph_regs[2];
if (!ereg("|$ph_RefHost|", $PHORM_REFERER)
&& !ereg("|$ph_RefHost/$ph_RefPath|", $PHORM_REFERER)) {
$ph_Errs[‚080‘] =
„### - Invalid access. [$HTTP_REFERER].“;
$ph_Abort = true;
}
}
/*
Restore only the declared PHORM_ variables from the form */
if ($ph_ForceDec && is_array($ph_varHold))
while (list($ph_var, $ph_val) = each($ph_varHold))
if ($$ph_var == „{{FORM}}“) $$ph_var = $ph_varHold[$ph_var];
/* If there’s no ack template, redirect back to the calling form. Note that
if $HTTP_REFERER is empty, the visitor will get a „302 Found“ result
(from Apache, anyway) */
if (!$PHORM_ACK && !$ph_Abort) {
if (!$HTTP_REFERER) {
$ph_Alerts[060] =
"### - Warning: No ack template specified, and $HTTP_REFERER ".
„is empty. Visitor received 302 Found status message.\n“;
}
Header(„Location:blush:HTTP_REFERER“);
}
/*
Check required fields */
if ($PHORM_REQ && !$ph_Abort) {
if ($ph_debug3) echo „NS: PHORM_REQ“;
$ph_ReqVars = explode(" ", $PHORM_REQ);
while (list(,$ph_ReqVar) = each($ph_ReqVars))
if (!$$ph_ReqVar)
$ph_VarList.= " $ph_ReqVar
";
if ($ph_VarList) {
$ph_Errs[‚REQ‘] =
„Gehen Sie bitte zurück - diese müssen noch ausgefüllt werden:
$ph_VarList“;
$ph_Abort = true;
}
}
/*
Open the acknowledgement template file. */
if ($PHORM_ACK && !$ph_Abort) {
if ($ph_debug3) echo "NS: Open Ack Template $PHORM_ACK.
";
if (!$ph_af = @fopen($PHORM_ACK,„r“)) {
$ph_Errs[‚070‘] =
"### - Unable to open acknowledgement template file $PHORM_ACK.
\n";
$ph_Abort = true;
}
}
/*
Open the mail template file. */
if ($PHORM_TMPL && !$ph_Abort) {
if ($ph_debug3) echo "NS: Open Mail Template $PHORM_TMPL.
";
if (!$ph_tf = @fopen($PHORM_TMPL,„r“)) {
$ph_Alerts[‚101‘] = "### - Unable to open mail template file $PHORM_TMPL.
\n";
}
}
/*
Open the log file */
if ($PHORM_LOG && $PHORM_LOGVAR && !$ph_Abort) {
if ($ph_debug3) echo " NS: Open Log File $lPHORM_LOG.
";
if (!$ph_lf = @fopen($PHORM_LOG, „a“)) {
$ph_Alerts[‚080‘] = „### - Unable to open the text log file $PHORM_LOG.“;
$PHORM_LOG = „“;
}
}
/*
Log to text file */
if ($PHORM_LOG && $PHORM_LOGVAR && !$ph_Abort) {
if ($ph_debug2) echo " JS: Log to text file $PHORM_LOG.
„;
$ph_LogVars = explode(“ „, $PHORM_LOGVAR);
$ph_idx = 0;
$ph_LogLine = „“;
while (list(,$ph_LogVar) = each($ph_LogVars)) {
if (ereg(“’", $ph_LogVar)) $ph_Quote = $PHORM_LOGQUOT; else $ph_Quote = „“;
$ph_LogVar = str_replace("’", „“, $ph_LogVar);
// If $$ph_LogVar is an array, break it down
ereg("^([A-Za-z0-9_]*)(([[A-Za-z0-9_]*])*)$", $ph_LogVar, $ph_regs);
$ph_LogVar = $ph_regs[1];
$ph_indices = split("][", ereg_replace("^[|]$", „“, $ph_regs[2]));
$ph_Value = $$ph_LogVar; $ph_idx = 0;
while (is_array($ph_Value))
$ph_Value = $ph_Value[$ph_indices[$ph_idx++]];
$ph_LogLine.= $ph_Quote.$ph_Value.$ph_Quote.$PHORM_LDELIM;
}
fputs($ph_lf, $ph_LogLine."\n");
}
/*
Read the mail template file and mail it to the user */
if ($ph_tf && !$ph_Abort) {
if ($ph_debug2) echo "Mail Template $PHORM_TMPL
";
if (!$EMail) $EMail = $PHORM_TO;
$ph_Message = „“;
while(!feof($ph_tf)) {
$ph_tline = fgets($ph_tf, 1024);
// Parse the line for variable replacements.
VarSub($ph_tline);
$ph_Message.= $ph_tline;
} // (!feof($ph_tf))
fclose($ph_tf);
$ph_Headers = „From: $EMail\r\n“.
„X-Mailer: PHP3/$ph_Vers\r\n“;
Mail($PHORM_TO,
$PHORM_SUBJECT,
$ph_Message,
$ph_Headers);
} // if ($ph_tf)
/*
Read the ack template and output it. */
if ($ph_af && !$ph_Abort) {
if ($ph_debug2) echo " JS: Ack Template $PHORM_ACK
";
while(!feof($ph_af)) {
$ph_aline = fgets($ph_af, 1024);
// Add our tag at the end of the file.
if ((ereg("