in reply to Transfering Varriables
//extract all varriable names from template file and save names to arr +ay. $clean_vars = gleen_vars(); //extract outgoing mail format from template file. $fd = fopen ($template, "r") or die("Could not open template file"); $mail_out = fread ($fd, filesize($template)); fclose ($fd); //replace varribles in template with varriables from input. $i="0"; $replaced_var = "$$clean_vars"; echo $replaced_var[2][2]; while($clean_vars[2][$i]){ str_replace("%$clean_vars[$i]%","$replaced_var[2][$i]",$mail_out); echo $clean_vars[2][$i]; echo $replaced_var[2][$i]; echo "<br><br>"; $i++; } echo $replaced_var[2][2]; echo $mail_out; break; //seperate out the header information and create varriables to, and fr +om. list($header,$mail_out) = preg_split("%Begin Email%",$mail_out,2); list($to,$from) = preg_split("/[\n]+/",$header); list($crap,$to)=split(":",$to); list($crap,$from)=split(":",$from); //output to mailer deamon sndmail($to,$from,$title,$mail_out); logdata($to,$from,$title,1); /********************************************************************* +***********************/ /* + */ /* gleen_vars function: reads and puts incomming arrays (from template + file) into an array */ /* + */ /********************************************************************* +***********************/ function gleen_vars() { $template = "template.php"; $fd = fopen ("$template", "r") or die("Could not open template fil +e"); $contents = fread ($fd, filesize($template)); fclose ($fd); if(preg_match_all ("/(%) ([_0-9a-zA-Z]*) (%)/x", "$contents", $pre +_vars, PREG_PATTERN_ORDER)){ return($pre_vars); }else{ error("No varriables defined in the template script: $template") +; return(0); } }
|
|---|