home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2006 October / wn148cd2.iso / Windows / Travailler / SecretMaker / secretmakersetup.exe / help / w2dfgw.php < prev   
PHP Script  |  2005-12-23  |  4KB  |  180 lines

  1. <?
  2.  
  3. function postVars($myKey) {
  4.  
  5.     // Gibt die HTTP-Post-Variablen zurⁿck
  6.  
  7.     global $HTTP_POST_VARS;
  8.  
  9.     if (isset($HTTP_POST_VARS[$myKey])) {
  10.         return ($HTTP_POST_VARS[$myKey]);
  11.     }
  12.     else {
  13.         return ("");
  14.     }
  15. }
  16.  
  17. function quoted_printable_encode($input) {
  18.  
  19.     // MIME-Encoding
  20.  
  21.     $line_max = 76;
  22.     $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
  23.     $lines = split("\n", $input);
  24.     $eol = "\n";
  25.     $escape = "=";
  26.     $output = "";
  27.  
  28.     for ($j=0;$j<count($lines);$j++) {
  29.         $line = $lines[$j];
  30.         $linlen = strlen($line);
  31.         $newline = "";
  32.         for($i = 0; $i < $linlen; $i++) {
  33.             $c = substr($line, $i, 1);
  34.             $dec = ord($c);
  35.             if ( ($dec == 32) && ($i == ($linlen - 1)) ) { 
  36.                 $c = "=20"; 
  37.             } elseif ( ($dec == 61) || ($dec==46) || ($dec < 32 ) || ($dec > 126) ) { 
  38.                 $h2 = floor($dec/16); $h1 = floor($dec%16); 
  39.                 $c = $escape.$hex["$h2"].$hex["$h1"]; 
  40.             }
  41.             if ( (strlen($newline) + strlen($c)) >= $line_max ) { 
  42.                 $output .= $newline.$escape.$eol; 
  43.                 $newline = "";
  44.             }
  45.             $newline .= $c;
  46.         } 
  47.         $output .= $newline;
  48.         if ($j<count($lines)-1) $output .= $eol;
  49.     }
  50.     return trim($output);
  51. }
  52.  
  53. function createHTMLMail() {
  54.  
  55.     // erzeugt eine HTML-Mail
  56.  
  57.     global $HTTP_POST_VARS;
  58.     reset($HTTP_POST_VARS);
  59.     
  60.     $i=1;
  61.     
  62.     $mymail="";
  63.     
  64.     // Header
  65.     
  66.     $mymail.= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
  67.     $mymail.= "<html>\n";
  68.     $mymail.= "<head>\n";
  69.     
  70.     $mymail.="<META http-equiv=Content-Type content=text/html; charset=iso-8859-1>\n";
  71.     
  72.     $mymail.= "</head>\n";
  73.     $mymail.= "<body bgcolor=\"#ffffff\" text=\"#333333\" link=\"#333333\">\n";
  74.  
  75.     $mymail.= "<style>\n";
  76.     $mymail.= "  td {font-family : Tahoma, Verdana, Geneva, Arial, Helvetica, sans-serif; font-size : 11px; color : #333333; }\n";
  77.     $mymail.= "</style>\n";
  78.     $mymail.="<table width=100% border=0 cellpadding=4>\n";
  79.  
  80.     $mymail.="<tr>";
  81.     $mymail.="<td colspan=2><strong>The following message was sent to you:</strong></td>\n";
  82.     $mymail.="</tr>\n";
  83.     
  84.     while (list($key, $val) = each ($HTTP_POST_VARS))
  85.     {
  86.         switch ($key)
  87.         {
  88.             case "x":
  89.             case "y":
  90.             case "fgwemail":
  91.             case "fgwsubject":
  92.             case "fgwreturnurl":
  93.                 break;
  94.                default:
  95.                 $mymail.="<tr>";
  96.                 $mymail.="<td><strong>".$key.":</strong></td>\n";
  97.                 $mymail.="<td width=100%>".$val."</td>\n";
  98.                 $mymail.="</tr>\n";
  99.         }
  100.     }
  101.  
  102.     $mymail.="</table>\n";
  103.  
  104.     return $mymail;
  105. }
  106.  
  107. function createTextMail() {
  108.  
  109.     global $HTTP_POST_VARS;
  110.     reset($HTTP_POST_VARS);
  111.  
  112.     $mymail="";
  113.     while (list($key, $val) = each ($HTTP_POST_VARS))
  114.     {
  115.         switch ($key)
  116.         {
  117.             case "x":
  118.             case "y":
  119.             case "fgwemail":
  120.             case "fgwsubject":
  121.             case "fgwreturnurl":
  122.                 break;
  123.                default:
  124.                 $mymail.=$key." ";
  125.                 $mymail.=$val."\n";
  126.         }
  127.     }
  128.     
  129.     $mymail.="\n";
  130.  
  131.     return $mymail;
  132. }
  133.     
  134. function createMimeMail() {
  135.     $mymime="This is a multi-part message in MIME format.\n\n";
  136.     $mymime.="----WEB2DATEGATEWAY\n";
  137.     $mymime.="Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n";
  138.     $mymime.="Content-Transfer-Encoding: quoted-printable\n\n";
  139.     $mymime.=quoted_printable_encode(createTextMail())."\n";
  140.     $mymime.="----WEB2DATEGATEWAY\n";
  141.     $mymime.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n";
  142.     $mymime.="Content-Transfer-Encoding: quoted-printable\n\n";
  143.     $mymime.=quoted_printable_encode(createHTMLMail())."\n";
  144.     $mymime.="----WEB2DATEGATEWAY--\n";
  145.     return $mymime;
  146. }
  147.  
  148. function deSlash(&$element) {
  149.  
  150.     // Fⁿr Stripslash
  151.  
  152.     $element=stripslashes($element);
  153. }
  154.  
  155. // Hauptprogramm
  156.  
  157. // Die magischen Quotes eliminieren...
  158.  
  159. reset($HTTP_POST_VARS);
  160.  
  161. if (get_magic_quotes_gpc()) {
  162.     array_walk($HTTP_POST_VARS, "deSlash");
  163. }
  164.  
  165. $fgwemail=postVars("fgwemail");
  166. $fgwsubject=postVars("fgwsubject");
  167. $fgwreturnurl=postVars("fgwreturnurl");
  168.  
  169. if (!$fgwemail) {
  170.     die ("ERROR: NO RETURN-EMAIL-ADRESS");
  171. }
  172. if (!$fgwreturnurl) {
  173.     die ("ERROR: NO RETURN-URL");
  174. }
  175.  
  176. mail ($fgwemail, $fgwsubject, createMimeMail(), "MIME-Version: 1.0\nContent-Type: multipart/alternative;\n\tboundary=\"--WEB2DATEGATEWAY\"\nX-Mailer: web to date Gateway Version 1.0");
  177. header("Location: ".$fgwreturnurl);
  178.  
  179. ?>
  180.