/**
	 * RunUpgrade
	 * Runs the fix_3744_fix_absolute_path upgrade
	 *
	 * @return Boolean Returns TRUE if successful, FALSE otherwise
	 */
	function RunUpgrade()
	{
		$stash = IEM_InterspireStash::getInstance();

		// Cannot run this upgrade as the event data does not exists
		if (!$stash->exists(InterspireEvent::DEFAULT_STORAGE_KEY)) {
			return true;
		}

		$data = array();

		// Try to read the data, if failed, do not continue
		try {
			$data = $stash->read(InterspireEvent::DEFAULT_STORAGE_KEY);
		} catch (Exception $e) {
			return true;
		}

		$newData = array();
		foreach ($data as $priority => $listeners_in_priority) {
			foreach ($listeners_in_priority as $index_in_priority => $listeners) {
				foreach ($listeners as $index => $listener) {
					if (isset($listener['file']) && !empty($listener['file'])) {
						$listener['file'] = preg_replace('/^' . preg_quote(IEM_PUBLIC_PATH, '/') . '/', '{%IEM_PUBLIC_PATH%}', $listener['file']);
					}

					$newData[$priority][$index_in_priority][$index] = $listener;
				}
			}
		}

		// Try to write the data, if failed, do not continue
		try {
			$data = $stash->write(InterspireEvent::DEFAULT_STORAGE_KEY, $newData, true);
		} catch (Exception $e) {
			return true;
		}

		return true;
	}
Пример #2
0
<?php

/**
 * This file contains procdeure and classes to enable "Event"
 *
 * @package interspire.iem
 * @subpackage eventdata
 */
/**
 * Include "Interspire Event" library
 */
require_once IEM_PATH . '/ext/interspire_event/interspireevent.php';
InterspireEvent::init(IEM_InterspireStash::getInstance(), false);
/**
 * Event data class for "IEM_SYSTEM_STARTUP_BEFORE" event
 *
 * This event is called before framework initialization.
 * It does not contains any data.
 *
 * @package interspire.iem
 * @subpackage eventdata
 */
class EventData_IEM_SYSTEM_STARTUP_BEFORE extends InterspireEventData
{
    /**
     * CONSTRUCTOR
     */
    public function __construct()
    {
        parent::__construct(false);
        $this->_eventName = 'IEM_SYSTEM_STARTUP_BEFORE';
Пример #3
0
	/**
	* Save
	* This function saves the current class vars to the settings file.
	* It checks to make sure the file is writable, then places the appropriate values in there and saves it. It uses a temporary name then copies that over the top of the old one, then removes the temporary file.
	*
	* @return Boolean Returns true if it worked, false if it fails.
	*/
	function Save()
	{

		require_once(SENDSTUDIO_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'interspire_addons.php');

		if (!is_writable($this->ConfigFile)) {
			return false;
		}

		$tmpfname = tempnam(TEMP_DIRECTORY, 'SS_');
		if (!$handle = fopen($tmpfname, 'w')) {
			return false;
		}

		$copy = true;
		if (is_file(TEMP_DIRECTORY . '/config.prev.php')) {
			if (!@unlink(TEMP_DIRECTORY . '/config.prev.php')) {
				$copy = false;
			}
		}

		if ($copy) {
			@copy($this->ConfigFile, TEMP_DIRECTORY . '/config.prev.php');
		}

		// the old config backups were in the includes folder so try to clean them up as part of this process.
		$config_prev = SENDSTUDIO_INCLUDES_DIRECTORY . '/config.prev.php';
		if (is_file($config_prev)) {
			@unlink($config_prev);
		}

		$contents = "<?php\n\n";

		gmt($this);

		$areas = $this->Areas;


		foreach ($areas['config'] as $area) {
			// See self::LoadSettings() on UTF8PATCH settings
			if ($area == 'DATABASE_UTF8PATCH') {
				if (!defined('SENDSTUDIO_DATABASE_UTF8PATCH')) {
					define('SENDSTUDIO_DATABASE_UTF8PATCH', 1);
				}
				$contents .= "define('SENDSTUDIO_DATABASE_UTF8PATCH', '" . SENDSTUDIO_DATABASE_UTF8PATCH . "');\n";
				continue;
			}
			$string = 'define(\'SENDSTUDIO_' . $area . '\', \'' . addslashes($this->Settings[$area]) . '\');' . "\n";
			$contents .= $string;
		}

		$contents .= "define('SENDSTUDIO_IS_SETUP', 1);\n";
		
		if (!defined('SENDSTUDIO_DEFAULTCHARSET')) {
			define('SENDSTUDIO_DEFAULTCHARSET', 'UTF-8');
		}
		$contents .= "define('SENDSTUDIO_DEFAULTCHARSET', '" . SENDSTUDIO_DEFAULTCHARSET . "');\n";

		$contents .= "\n\n";

		fputs($handle, $contents, strlen($contents));
		fclose($handle);
		chmod($tmpfname, 0644);

		if (!copy($tmpfname, $this->ConfigFile)) {
			return false;
		}
		unlink($tmpfname);

		$copy = true;
		if (is_file(TEMP_DIRECTORY . '/config.bkp.php')) {
			if (!@unlink(TEMP_DIRECTORY . '/config.bkp.php')) {
				$copy = false;
			}
		}

		if ($copy) {
			@copy($this->ConfigFile, TEMP_DIRECTORY . '/config.bkp.php');
		}

		// the old config backups were in the includes folder so try to clean them up as part of this process.
		$config_bkp = SENDSTUDIO_INCLUDES_DIRECTORY . '/config.bkp.php';
		if (is_file($config_bkp)) {
			@unlink($config_bkp);
		}

		unset($areas['config']);

		if (defined('APPLICATION_SHOW_WHITELABEL_MENU') && constant('APPLICATION_SHOW_WHITELABEL_MENU')) {
			$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "whitelabel_settings";
			$result = $this->Db->Query($query);
			foreach ($areas['whitelabel'] as $area) {
				// If settings are not set, do not continue
				if (!isset($this->Settings[$area])) {
					continue;
				}

				$value = $this->Settings[$area];

				if (strtolower($area) == 'update_check_enabled') {
					$subAction = 'uninstall';
					if ($value == '1') {
						$subAction = 'install';
					}
					$result = Interspire_Addons::Process('updatecheck', $subAction, array());
					continue;
				} elseif (strtolower($area) == 'lng_accountupgrademessage') {
					$agencyId = get_agency_license_variables();
					if(empty($agencyId['agencyid'])) {
						continue;
					}
				}

				if (is_bool($value)) {
					$value = (int)$value;
				}

				$query = "INSERT INTO " . SENDSTUDIO_TABLEPREFIX . "whitelabel_settings(name, value) VALUES ('" . $this->Db->Quote($area) . "', '" . $this->Db->Quote($value) . "')";
				$result = $this->Db->Query($query);
			}
			if ($this->WhiteLabelCache->exists('IEM_SETTINGS_WHITELABEL')) {
				$this->WhiteLabelCache->remove('IEM_SETTINGS_WHITELABEL');
			}
		}

		if (isset($areas['whitelabel'])) {
			unset($areas['whitelabel']);
		}

		$stash = IEM_InterspireStash::getInstance();
		if ($stash->exists('IEM_SYSTEM_SETTINGS')) {
			$stash->remove('IEM_SYSTEM_SETTINGS');
		}

		$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "config_settings";
		$result = $this->Db->Query($query);


		foreach ($areas as $area) {
			$value = isset($this->Settings[$area]) ? $this->Settings[$area] : '';



			if ($area == 'SYSTEM_DATABASE_VERSION') {
				$value = $this->Db->FetchOne("SELECT version() AS version");
			}
			if (is_bool($value)) {
				$value = (int)$value;
			}

			$query = "INSERT INTO " . SENDSTUDIO_TABLEPREFIX . "config_settings(area, areavalue) VALUES ('" . $this->Db->Quote($area) . "', '" . $this->Db->Quote($value) . "')";
			$result = $this->Db->Query($query);
		}


		return true;
	}