[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/admin/ -> process_email.php (source)

   1  #!/usr/bin/php -f
   2  <?php // $Id: process_email.php,v 1.5.4.1 2008/01/24 02:17:17 scyrma Exp $
   3  define('FULLME','cron'); // prevent warnings
   4  //error_reporting(0);
   5  //ini_set('display_errors',0);
   6  require_once(dirname(dirname(__FILE__)).'/config.php');
   7  $tmp = explode('@',$_ENV['RECIPIENT']);
   8  $address = $tmp[0];
   9  
  10  // BOUNCE EMAILS TO NOREPLY
  11  if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress) {
  12      $user->email = $_ENV['SENDER'];
  13  
  14      if (!validate_email($user->email)) {
  15          die();
  16      }
  17      
  18      $site = get_site();
  19      $subject = get_string('noreplybouncesubject','moodle',format_string($site->fullname));
  20      $body = get_string('noreplybouncemessage','moodle',format_string($site->fullname))."\n\n";
  21      
  22      $fd = fopen('php://stdin','r');
  23      if ($fd) {
  24          while(!feof($fd)) {
  25              $body .=  fgets($fd);
  26          }
  27          fclose($fd);
  28      }
  29      
  30      $user->id = 0; // to prevent anything annoying happening
  31      
  32      $from->firstname = null;
  33      $from->lastname = null;
  34      $from->email = '<>';
  35      $from->maildisplay = true;
  36      
  37      email_to_user($user,$from,$subject,$body);
  38      die ();
  39  }
  40  /// ALL OTHER PROCESSING
  41  // we need to split up the address
  42  $prefix = substr($address,0,4);
  43  $mod = substr($address,4,2);
  44  $modargs = substr($address,6,-16);
  45  $hash = substr($address,-16);
  46  
  47  if (substr(md5($prefix.$mod.$modargs.$CFG->siteidentifier),0,16) != $hash) {
  48      die("HASH DIDN'T MATCH!\n");
  49  }
  50  list(,$modid) = unpack('C',base64_decode($mod.'=='));
  51  
  52  if ($modid == '0') { // special
  53      $modname = 'moodle';
  54  }
  55  else {
  56      $modname = get_field("modules","name","id",$modid);
  57      include_once('mod/'.$modname.'/lib.php');
  58  }
  59  $function = $modname.'_process_email';
  60  
  61  if (!function_exists($function)) {
  62      die(); 
  63  }
  64  $fd = fopen('php://stdin','r');
  65  if (!$fd) {
  66      exit();
  67  }
  68  
  69  while(!feof($fd)) {
  70      $body .= fgets($fd);
  71  }
  72  
  73  $function($modargs,$body); 
  74  
  75  fclose($handle);
  76  
  77  
  78  
  79  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7