#!/usr/bin/php * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is * free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The GNU General Public License can be found at * http://www.gnu.org/copyleft/gpl.html. * A copy is found in the textfile GPL.txt and important notices to the license * from the author is found in LICENSE.txt distributed with these scripts. * * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** * Cron stack for sending mails * * @author Kasper Skaarhoj * @author Stanislas Rolland * * @package TYPO3 * @subpackage tx_directmail * @version $Id: dmailerd.phpcron 7706 2007-12-28 14:27:35Z ivankartolo $ * */ error_reporting (E_ALL ^ E_NOTICE); if ($_SERVER['PHP_SELF']) { if (!defined('PATH_thisScript')) define('PATH_thisScript',str_replace('//','/', str_replace('\\','/', $_SERVER['PHP_SELF']))); } else { if (!defined('PATH_thisScript')) define('PATH_thisScript',str_replace('//','/', str_replace('\\','/', $_ENV['_']))); } if (!defined('PATH_site')) define('PATH_site', dirname(dirname(dirname(dirname(dirname(dirname(PATH_thisScript)))))).'/'); if (!defined('PATH_t3lib')) if (!defined('PATH_t3lib')) define('PATH_t3lib', PATH_site.'t3lib/'); define('PATH_typo3conf', PATH_site.'typo3conf/'); define('TYPO3_mainDir', 'typo3/'); if (!defined('PATH_typo3')) define('PATH_typo3', PATH_site.TYPO3_mainDir); if (!defined('PATH_tslib')) { if (@is_dir(PATH_site.'typo3/sysext/cms/tslib/')) { define('PATH_tslib', PATH_site.'typo3/sysext/cms/tslib/'); } elseif (@is_dir(PATH_site.'tslib/')) { define('PATH_tslib', PATH_site.'tslib/'); } } define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':''); define('TYPO3_MODE', 'BE'); require_once(PATH_t3lib.'class.t3lib_div.php'); require_once(PATH_t3lib.'class.t3lib_extmgm.php'); require_once(PATH_t3lib.'config_default.php'); require_once(PATH_typo3conf.'localconf.php'); /** * added some auth library. Might be needed by other extension */ require_once(PATH_t3lib.'class.t3lib_userauth.php'); require_once(PATH_t3lib.'class.t3lib_userauthgroup.php'); require_once(PATH_t3lib.'class.t3lib_beuserauth.php'); if (!defined ('TYPO3_db')) die ('The configuration file was not included.'); if (isset($_POST['GLOBALS']) || isset($_GET['GLOBALS'])) die('You cannot set the GLOBALS-array from outside this script.'); // Check if cronjob is already running: if (@file_exists (PATH_site.'typo3temp/tx_directmail_cron.lock')) { // If the lock is not older than 1 day, skip index creation: if (filemtime (PATH_site.'typo3temp/tx_directmail_cron.lock') > (time() - (60*60*24))) { die('TYPO3 Direct Mail Cron: Aborting, another process is already running!'.chr(10)); } else { echo('TYPO3 Direct Mail Cron: A .lock file was found but it is older than 1 day! Processing mails ...'.chr(10)); } } $lockfile = PATH_site.'typo3temp/tx_directmail_cron.lock'; touch ($lockfile); // Connect to the database require_once(PATH_t3lib.'class.t3lib_db.php'); $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB'); $result = $TYPO3_DB->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password); if (!$result) { unlink ($lockfile); die("Couldn't connect to database at ".TYPO3_db_host); } $TYPO3_DB->sql_select_db(TYPO3_db); // **************************************************** // Include tables customization (tables + ext_tables) // **************************************************** include (TYPO3_tables_script ? PATH_typo3conf.TYPO3_tables_script : PATH_t3lib.'stddb/tables.php'); // Extension additions if ($TYPO3_LOADED_EXT['_CACHEFILE']) { include (PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_tables.php'); } else { include (PATH_t3lib.'stddb/load_ext_tables.php'); } // extScript if (TYPO3_extTableDef_script) { include (PATH_typo3conf.TYPO3_extTableDef_script); } require_once(PATH_t3lib.'class.t3lib_cs.php'); require_once(PATH_t3lib.'class.t3lib_htmlmail.php'); require_once(t3lib_extMgm::extPath('direct_mail').'res/scripts/class.dmailer.php'); $htmlmail = t3lib_div::makeInstance('dmailer'); $htmlmail->start(); $htmlmail->runcron(); unlink ($lockfile); ?>