[ Index ]

PHP Cross Reference of Eventum

title

Body

[close]

/misc/ -> process_mail_queue.php (source)

   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4 encoding=utf-8: */
   3  // +----------------------------------------------------------------------+
   4  // | Eventum - Issue Tracking System                                      |
   5  // +----------------------------------------------------------------------+
   6  // | Copyright (c) 2003, 2004, 2005, 2006, 2007 MySQL AB                              |
   7  // |                                                                      |
   8  // | This program is free software; you can redistribute it and/or modify |
   9  // | it under the terms of the GNU General Public License as published by |
  10  // | the Free Software Foundation; either version 2 of the License, or    |
  11  // | (at your option) any later version.                                  |
  12  // |                                                                      |
  13  // | This program is distributed in the hope that it will be useful,      |
  14  // | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
  15  // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
  16  // | GNU General Public License for more details.                         |
  17  // |                                                                      |
  18  // | You should have received a copy of the GNU General Public License    |
  19  // | along with this program; if not, write to:                           |
  20  // |                                                                      |
  21  // | Free Software Foundation, Inc.                                       |
  22  // | 59 Temple Place - Suite 330                                          |
  23  // | Boston, MA 02111-1307, USA.                                          |
  24  // +----------------------------------------------------------------------+
  25  // | Authors: João Prado Maia <jpm@mysql.com>                             |
  26  // +----------------------------------------------------------------------+
  27  //
  28  // @(#) $Id: process_mail_queue.php 3266 2007-03-06 20:18:51Z glen $
  29  
  30  ini_set("memory_limit", "256M");
  31  
  32  require_once(dirname(__FILE__) . "/../init.php");
  33  require_once (APP_INC_PATH . "db_access.php");
  34  require_once (APP_INC_PATH . "class.mail_queue.php");
  35  
  36  // determine if this script is being called from the web or command line
  37  $fix_lock = false;
  38  if (isset($_SERVER['HTTP_HOST'])) {
  39      // web
  40      if (@$_GET['fix-lock'] == 1) {
  41          $fix_lock = true;
  42      }
  43  } else {
  44      // command line
  45      if (in_array('--fix-lock', $argv)) {
  46          $fix_lock = true;
  47      }
  48  }
  49  
  50  // if requested, clear the lock
  51  if ($fix_lock) {
  52      Mail_Queue::removeProcessFile();
  53      echo "The lock file was removed successfully.\n";
  54      exit;
  55  }
  56  
  57  if (!Mail_Queue::isSafeToRun()) {
  58      $pid = Lock::getProcessID('process_mail_queue');
  59      echo "ERROR: There is already a process (pid=$pid) of this script running. ";
  60      echo "If this is not accurate, you may fix it by running this script with '--fix-lock' as the only parameter.\n";
  61      exit;
  62  }
  63  
  64  // handle only pending emails
  65  $limit = 50;
  66  Mail_Queue::send('pending', $limit);
  67  
  68  // handle emails that we tried to send before, but an error happened...
  69  $limit = 50;
  70  Mail_Queue::send('error', $limit);
  71  
  72  Mail_Queue::removeProcessFile();


Generated: Wed Dec 19 21:21:33 2007 Cross-referenced by PHPXref 0.7