Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/process_email.php
Go to the documentation of this file.
00001 #!/usr/bin/php -f
00002 <?php
00003 
00004 //error_reporting(0);
00005 //ini_set('display_errors',0);
00006 require_once(dirname(dirname(__FILE__)).'/config.php');
00007 $tmp = explode('@',$_ENV['RECIPIENT']);
00008 $address = $tmp[0];
00009 
00010 // BOUNCE EMAILS TO NOREPLY
00011 if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress) {
00012     $user = new stdClass();
00013     $user->email = $_ENV['SENDER'];
00014 
00015     if (!validate_email($user->email)) {
00016         die();
00017     }
00018 
00019     $site = get_site();
00020     $subject = get_string('noreplybouncesubject','moodle',format_string($site->fullname));
00021     $body = get_string('noreplybouncemessage','moodle',format_string($site->fullname))."\n\n";
00022 
00023     $fd = fopen('php://stdin','r');
00024     if ($fd) {
00025         while(!feof($fd)) {
00026             $body .=  fgets($fd);
00027         }
00028         fclose($fd);
00029     }
00030 
00031     $user->id = 0; // to prevent anything annoying happening
00032 
00033     $from->firstname = null;
00034     $from->lastname = null;
00035     $from->email = '<>';
00036     $from->maildisplay = true;
00037 
00038     email_to_user($user,$from,$subject,$body);
00039     die ();
00040 }
00042 // we need to split up the address
00043 $prefix = substr($address,0,4);
00044 $mod = substr($address,4,2);
00045 $modargs = substr($address,6,-16);
00046 $hash = substr($address,-16);
00047 
00048 if (substr(md5($prefix.$mod.$modargs.$CFG->siteidentifier),0,16) != $hash) {
00049     die("HASH DIDN'T MATCH!\n");
00050 }
00051 list(,$modid) = unpack('C',base64_decode($mod.'=='));
00052 
00053 if ($modid == '0') { // special
00054     $modname = 'moodle';
00055 }
00056 else {
00057     $modname = $DB->get_field("modules", "name", array("id"=>$modid));
00058     include_once('mod/'.$modname.'/lib.php');
00059 }
00060 $function = $modname.'_process_email';
00061 
00062 if (!function_exists($function)) {
00063     die();
00064 }
00065 $fd = fopen('php://stdin','r');
00066 if (!$fd) {
00067     exit();
00068 }
00069 
00070 while(!feof($fd)) {
00071     $body .= fgets($fd);
00072 }
00073 
00074 $function($modargs,$body);
00075 
00076 fclose($fd);
00077 
00078 
00079 
00080 
 All Data Structures Namespaces Files Functions Variables Enumerations