Example #1
0
 protected function __construct()
 {
     $this->Profiler = new Profiler();
     if (get_magic_quotes_gpc()) {
         General::cleanArray($_SERVER);
         General::cleanArray($_COOKIE);
         General::cleanArray($_GET);
         General::cleanArray($_POST);
     }
     include CONFIG;
     self::$Configuration = new Configuration(true);
     self::$Configuration->setArray($settings);
     DateTimeObj::setDefaultTimezone(self::$Configuration->get('timezone', 'region'));
     self::$_lang = self::$Configuration->get('lang', 'symphony') ? self::$Configuration->get('lang', 'symphony') : 'en';
     // Legacy support for __LANG__ constant
     define_safe('__LANG__', self::lang());
     define_safe('__SYM_DATE_FORMAT__', self::$Configuration->get('date_format', 'region'));
     define_safe('__SYM_TIME_FORMAT__', self::$Configuration->get('time_format', 'region'));
     define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . ' ' . __SYM_TIME_FORMAT__);
     $this->initialiseLog();
     GenericExceptionHandler::initialise();
     GenericErrorHandler::initialise(self::$Log);
     $this->initialiseCookie();
     $this->initialiseDatabase();
     if (!$this->initialiseExtensionManager()) {
         throw new SymphonyErrorPage('Error creating Symphony extension manager.');
     }
     Lang::loadAll($this->ExtensionManager);
 }
Example #2
0
 /**
  * Override the default Symphony constructor to initialise the Log, Config
  * and Database objects for installation/update. This allows us to use the
  * normal accessors.
  */
 protected function __construct()
 {
     if (get_magic_quotes_gpc()) {
         General::cleanArray($_SERVER);
         General::cleanArray($_COOKIE);
         General::cleanArray($_GET);
         General::cleanArray($_POST);
     }
     // Include the default Config for installation.
     include INSTALL . '/includes/config_default.php';
     $this->initialiseConfiguration($settings);
     // Initialize date/time
     define_safe('__SYM_DATE_FORMAT__', self::Configuration()->get('date_format', 'region'));
     define_safe('__SYM_TIME_FORMAT__', self::Configuration()->get('time_format', 'region'));
     define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . self::Configuration()->get('datetime_separator', 'region') . __SYM_TIME_FORMAT__);
     DateTimeObj::setSettings(self::Configuration()->get('region'));
     // Initialize language
     $this->initialiseLang();
     // Initialize logs
     $this->initialiseLog(INSTALL_LOGS . '/install');
     // Initialize database
     $this->initialiseDatabase();
     // Initialize error handlers
     GenericExceptionHandler::initialise(Symphony::Log());
     GenericErrorHandler::initialise(Symphony::Log());
 }
Example #3
0
 /**
  * Creates a lock file if one does not already exist with a certain
  * time to live (TTL) at a specific path. If a lock already exists,
  * false will be returned otherwise boolean depending if a lock
  * file was created successfully or not.
  *
  * @param string $id
  *  The name of the lock file, which gets obfuscated using
  *  generateLockFileName.
  * @param integer $ttl
  *  The length, in seconds, that the lock should exist for. Defaults
  *  to 5.
  * @param string $path
  *  The path the lock should be written, defaults to the current
  *  working directory
  * @return boolean
  */
 public static function acquire($id, $ttl = 5, $path = '.')
 {
     $lockFile = self::__generateLockFileName($id, $path);
     // If this thread already has acquired the lock, return true.
     if (isset(self::$lockFiles[$lockFile])) {
         $age = time() - self::$lockFiles[$lockFile]['time'];
         return $age < $ttl ? false : true;
     }
     // Disable log temporarily because we actually depend on fopen()
     // failing with E_WARNING here and we do not want Symphony to throw
     // errors or spam logfiles.
     try {
         GenericErrorHandler::$logDisabled = true;
         $lock = fopen($lockFile, 'xb');
         GenericErrorHandler::$logDisabled = false;
         self::$lockFiles[$lockFile] = array('time' => time(), 'ttl' => $ttl);
         fclose($lock);
         return true;
     } catch (Exception $ex) {
         // If, for some reason, lock file was not unlinked before,
         // remove it if it is old enough.
         if (file_exists($lockFile)) {
             $age = time() - filemtime($lockFile);
             if ($age > $ttl) {
                 unlink($lockFile);
             }
         }
         // Return false anyway - just in case two or more threads
         // do the same check and unlink at the same time.
         return false;
     }
 }
 protected function __construct()
 {
     $this->Profiler = new Profiler();
     if (get_magic_quotes_gpc()) {
         General::cleanArray($_SERVER);
         General::cleanArray($_COOKIE);
         General::cleanArray($_GET);
         General::cleanArray($_POST);
     }
     include CONFIG;
     self::$Configuration = new Configuration(true);
     self::$Configuration->setArray($settings);
     define_safe('__LANG__', self::$Configuration->get('lang', 'symphony') ? self::$Configuration->get('lang', 'symphony') : 'en');
     define_safe('__SYM_DATE_FORMAT__', self::$Configuration->get('date_format', 'region'));
     define_safe('__SYM_TIME_FORMAT__', self::$Configuration->get('time_format', 'region'));
     define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . ' ' . __SYM_TIME_FORMAT__);
     $this->initialiseLog();
     GenericExceptionHandler::initialise();
     GenericErrorHandler::initialise($this->Log);
     $this->initialiseCookie();
     try {
         Lang::init(LANG . '/lang.%s.php', __LANG__);
     } catch (Exception $e) {
         trigger_error($e->getMessage(), E_USER_ERROR);
     }
     $this->initialiseDatabase();
     if (!$this->initialiseExtensionManager()) {
         throw new SymphonyErrorPage('Error creating Symphony extension manager.');
     }
     DateTimeObj::setDefaultTimezone(self::$Configuration->get('timezone', 'region'));
 }
Example #5
0
 /**
  * The Symphony constructor initialises the class variables of Symphony.
  * It will set the DateTime settings, define new date constants and initialise
  * the correct Language for the currently logged in Author. If magic quotes
  * are enabled, Symphony will sanitize the `$_SERVER`, `$_COOKIE`,
  * `$_GET` and `$_POST` arrays. The constructor loads in
  * the initial Configuration values from the `CONFIG` file
  */
 protected function __construct()
 {
     self::$Profiler = Profiler::instance();
     self::$Profiler->sample('Engine Initialisation');
     if (get_magic_quotes_gpc()) {
         General::cleanArray($_SERVER);
         General::cleanArray($_COOKIE);
         General::cleanArray($_GET);
         General::cleanArray($_POST);
     }
     $this->initialiseConfiguration();
     define_safe('__SYM_DATE_FORMAT__', self::Configuration()->get('date_format', 'region'));
     define_safe('__SYM_TIME_FORMAT__', self::Configuration()->get('time_format', 'region'));
     define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . self::Configuration()->get('datetime_separator', 'region') . __SYM_TIME_FORMAT__);
     DateTimeObj::setSettings(self::Configuration()->get('region'));
     // Initialize language management
     Lang::initialize();
     $this->initialiseLog();
     GenericExceptionHandler::initialise(self::Log());
     GenericErrorHandler::initialise(self::Log());
     $this->initialiseDatabase();
     $this->initialiseExtensionManager();
     $this->initialiseCookie();
     // If the user is not a logged in Author, turn off the verbose error messages.
     if (!self::isLoggedIn() && is_null($this->Author)) {
         GenericExceptionHandler::$enabled = false;
     }
     // Set system language
     Lang::set(self::$Configuration->get('lang', 'symphony'));
 }
Example #6
0
 /**
  * Setter for the Symphony Log and Error Handling system
  *
  * @since Symphony 2.6.0
  */
 public static function initialiseErrorHandler()
 {
     // Initialise logging
     self::initialiseLog();
     GenericExceptionHandler::initialise(self::Log());
     GenericErrorHandler::initialise(self::Log());
 }
 /**
  * The Symphony constructor initialises the class variables of Symphony.
  * It will set the DateTime settings, define new date constants and initialise
  * the correct Language for the currently logged in Author. If magic quotes
  * are enabled, Symphony will sanitize the `$_SERVER`, `$_COOKIE`,
  * `$_GET` and `$_POST` arrays. The constructor loads in
  * the initial Configuration values from the `CONFIG` file
  */
 protected function __construct()
 {
     $this->Profiler = Profiler::instance();
     $this->Profiler->sample('Engine Initialisation');
     if (get_magic_quotes_gpc()) {
         General::cleanArray($_SERVER);
         General::cleanArray($_COOKIE);
         General::cleanArray($_GET);
         General::cleanArray($_POST);
     }
     // Includes the existing CONFIG file and initialises the Configuration
     // by setting the values with the setArray function.
     include CONFIG;
     self::$Configuration = new Configuration(true);
     self::$Configuration->setArray($settings);
     DateTimeObj::setDefaultTimezone(self::$Configuration->get('timezone', 'region'));
     define_safe('__SYM_DATE_FORMAT__', self::$Configuration->get('date_format', 'region'));
     define_safe('__SYM_TIME_FORMAT__', self::$Configuration->get('time_format', 'region'));
     define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . self::$Configuration->get('datetime_separator', 'region') . __SYM_TIME_FORMAT__);
     // Initialize language management
     Lang::initialize();
     $this->initialiseLog();
     GenericExceptionHandler::initialise(self::$Log);
     GenericErrorHandler::initialise(self::$Log, self::$Configuration->get('strict_error_handling', 'symphony'));
     $this->initialiseDatabase();
     $this->initialiseExtensionManager();
     $this->initialiseCookie();
     // If the user is not a logged in Author, turn off the verbose error
     // messages.
     if (!self::isLoggedIn() && is_null($this->Author)) {
         GenericExceptionHandler::$enabled = false;
     }
     // Set system language
     Lang::set(self::$Configuration->get('lang', 'symphony'));
 }
Example #8
0
 public static function isErrorsEnabled($type)
 {
     if (is_null(self::$_enabledErrorTypes)) {
         self::$_enabledErrorTypes = array();
         $bit = ini_get('error_reporting');
         while ($bit > 0) {
             for ($i = 0, $n = 0; $i <= $bit; $i = 1 * pow(2, $n), $n++) {
                 $end = $i;
             }
             self::$_enabledErrorTypes[] = $end;
             $bit = $bit - $end;
         }
     }
     return in_array($type, self::$_enabledErrorTypes);
 }
 /**
  * Initialise will set the error handler to be the `__CLASS__::handler`
  * function.
  *
  * @param Log|null $Log (optional)
  *  An instance of a Symphony Log object to write errors to
  */
 public static function initialise(Log $Log = null)
 {
     if (!is_null($Log)) {
         self::$_Log = $Log;
     }
     set_error_handler(array(__CLASS__, 'handler'), error_reporting());
 }
Example #10
0
 protected function __construct()
 {
     self::$Configuration = new Configuration();
     DateTimeObj::setDefaultTimezone(self::Configuration()->core()->region->timezone);
     self::$_lang = self::Configuration()->core()->symphony->lang ? self::Configuration()->core()->symphony->lang : 'en';
     define_safe('__SYM_DATE_FORMAT__', self::Configuration()->core()->region->{'date-format'});
     define_safe('__SYM_TIME_FORMAT__', self::Configuration()->core()->region->{'time-format'});
     define_safe('__SYM_DATETIME_FORMAT__', sprintf('%s %s', __SYM_DATE_FORMAT__, __SYM_TIME_FORMAT__));
     define_safe('ADMIN_URL', sprintf('%s/%s', URL, trim(self::Configuration()->core()->symphony->{'administration-path'}, '/')));
     $this->initialiseLog();
     GenericExceptionHandler::initialise();
     GenericErrorHandler::initialise(self::$Log);
     $this->initialiseCookie();
     $this->initialiseDatabase();
     Extension::init();
     Cache::setDriver(self::Configuration()->core()->{'cache-driver'});
     Lang::loadAll(true);
 }
 public static function initialise(Log $Log = NULL)
 {
     self::$enabled = true;
     if (!is_null($Log)) {
         self::$_Log = $Log;
     }
     set_error_handler(array(__CLASS__, 'handler'));
 }
{
    //echo $error_message . "\r\n";
}
$newsletter_id = $_SERVER['argv'][1];
$process_auth = $_SERVER['argv'][2];
$_SERVER['HTTP_HOST'] = $_SERVER['argv'][3];
// Generic Symphony includes & defines
define('DOCROOT', realpath(rtrim(dirname(__FILE__) . '/../../../', '\\/')));
define('DOMAIN', rtrim(rtrim($_SERVER['HTTP_HOST'], '\\/') . dirname($_SERVER['PHP_SELF']), '.\\/'));
define('HTTP_HOST', $_SERVER['HTTP_HOST']);
require_once DOCROOT . '/symphony/lib/boot/bundle.php';
//Inside bundle.php, the error_reporting is set again, but we don't want to be stopped by any other than fatal errors.
error_reporting(0);
require_once DOCROOT . '/symphony/lib/core/class.symphony.php';
require_once DOCROOT . '/symphony/lib/core/class.administration.php';
GenericErrorHandler::$enabled = false;
// ENM Specific includes & defines
define_safe('ENM_DIR', DOCROOT . '/extensions/email_newsletter_manager');
define_safe('ETM_DIR', DOCROOT . '/extensions/email_template_manager');
require_once ENM_DIR . '/lib/class.sendermanager.php';
require_once ENM_DIR . '/lib/class.recipientgroupmanager.php';
require_once ENM_DIR . '/lib/class.emailnewslettermanager.php';
require_once ENM_DIR . '/lib/class.emailbackgroundprocess.php';
// Needed to __construct() the Symphony class.
// This in turn is needed to get the Symphony::Database() functions working.
$thing = Administration::instance();
try {
    $newsletter = EmailNewsletterManager::create($newsletter_id);
    if (is_a($newsletter, 'EmailNewsletter')) {
        $newsletter->setPId(getmypid());
        $sending_settings = $newsletter->getSender()->about();
 /**
  * Initialise will set the error handler to be the `__CLASS__` handler
  * function and will set this `$_Log` variable to a Log instance
  *
  * @param Log|null $Log (optional)
  *  An instance of a Symphony Log object to write errors to
  * @param string $raise
  *  Whether to raise E_WARNING as an Exception
  */
 public static function initialise(Log $Log = null, $raise = false)
 {
     if (!is_null($Log)) {
         self::$_Log = $Log;
     }
     self::$raise = $raise == 'yes' ? true : false;
     set_error_handler(array(__CLASS__, 'handler'), error_reporting());
 }