Example #1
0
		public function HandlePage()
		{
			// Should we redirect to the setup script?
			if (GetConfig('isSetup') == false) {
				header("Location: index.php");
				die();
			}

			if (isset($_REQUEST['ToDo'])) {
				$ToDo = $_REQUEST['ToDo'];
			} else {
				$ToDo = "";
			}

			if (!isset($_COOKIE['STORESUITE_CP_TOKEN']) &&
				$ToDo != 'processLogin' &&
				$ToDo != 'forgotPass' &&
				$ToDo != 'unblock' &&
				$ToDo != 'firstTimeLogin' &&
				$ToDo != 'drawLogo'
			) {
				if (isset($_COOKIE['RememberToken']) && !isset($_COOKIE['logout']) && (int)GetConfig('PCILoginIdleTimeMin') == 0) {
					// process auto login
					// if 'remember my details' was checked
					// if user somehow lost CP token and idle timer is off
					$_POST['remember'] = '1';
					$GLOBALS['ISC_CLASS_ADMIN_AUTH']->ProcessLogin($ToDo);
					die;
				}

				unset($_COOKIE['logout']);
				$GLOBALS['ISC_CLASS_ADMIN_AUTH']->displayLoginForm();
				die();
			}

			// Get the permissions for this user
			$arrPermissions = $GLOBALS["ISC_CLASS_ADMIN_AUTH"]->GetPermissions();

			switch ($ToDo) {
				case 'login':
					$GLOBALS['ISC_CLASS_ADMIN_AUTH']->displayLoginForm();
					break;
				case 'processLogin':
					$GLOBALS['ISC_CLASS_ADMIN_AUTH']->ProcessLogin();
					break;
				case 'forgotPass':
					$GLOBALS['ISC_CLASS_ADMIN_AUTH']->displayResetPasswordRequestForm();
					break;
				case 'unblock':
					$GLOBALS['ISC_CLASS_ADMIN_AUTH']->displayUnblockScreen();
					break;
				case 'logOut':
					$GLOBALS['ISC_CLASS_ADMIN_AUTH']->LogOut();
					break;
				case 'HelpRSS':
					$this->LoadHelpRSS();
					break;
				default:
				{
					if (!in_arrays($ToDo)) {
						// No permissions? Log them out and throw them to the login page
						if (empty($arrPermissions)) {
							$GLOBALS['ISC_CLASS_ADMIN_AUTH']->LogOut();
							die();
						}

						$this->template->assign('taskManagerScript', Interspire_TaskManager::getTriggerHtml('json'));

						if (!empty($ToDo)) {
							$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HandleSTSToDo($ToDo);
						}
						else {
							$class = GetClass('ISC_ADMIN_INDEX');
							$class->HandleToDo();
						}
					}
				}
			}
		}
	/**
	* Begins an actual export job sequence based on requested data -- the job class itself will validate most of this info before attempting an export
	*
	* @param array $data
	*/
	protected function _moduleExportCommenceCommon($data)
	{
		$keystore = Interspire_KeyStore::instance();

		// find a unique export id to use
		do {
			$id = md5(uniqid('',true));
		} while ($keystore->exists('email:module_export:id:' . $id));
		$keystore->set('email:module_export:id:' . $id, $id);

		$prefix = 'email:module_export:' . $id;

		if (!isset($data['exportSearch'])) {
			$data['exportSearch'] = array();
		}

		if (!isset($data['exportMap'])) {
			$data['exportMap'] = array();
		}

		$keystore->set($prefix . ':started', time());
		$keystore->set($prefix . ':abort', 0);
		$keystore->set($prefix . ':skip', 0);
		$keystore->set($prefix . ':type', $data['exportType']);
		$keystore->set($prefix . ':module', $data['exportModule']);
		$keystore->set($prefix . ':list', $data['exportList']);
		$keystore->set($prefix . ':search', ISC_JSON::encode($data['exportSearch']));
		$keystore->set($prefix . ':map', ISC_JSON::encode($data['exportMap']));
		$keystore->set($prefix . ':success_count', 0);
		$keystore->set($prefix . ':error_count', 0);
		$keystore->set($prefix . ':doubleoptin', $data['exportDoubleOptin']);
		$keystore->set($prefix . ':updateexisting', $data['exportUpdateExisting']);

		// so we can send an email later, or diagnose troublesome users
		$user = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetUser();
		$keystore->set($prefix . ':owner:id', $user['pk_userid']);
		$keystore->set($prefix . ':owner:username', $user['username']);
		$keystore->set($prefix . ':owner:email', $user['useremail']);

		$jobData = array(
			'id' => $id,
		);

		$json = array(
			'success' => (bool)Interspire_TaskManager::createTask('emailintegration', 'Job_EmailIntegration_ModuleExport', $jobData),
			'id' => $id,
		);

		if (isset($data['return']) && $data['return']) {
			return $json;
		}

		ISC_JSON::output($json);
	}
Example #3
0
	/**
	* Removes a subscriber from a specific list for this provider
	*
	* @param mixed $listId
	* @param Interspire_EmailIntegration_Subscription $subscription
	* @param bool $asynchronous
	* @return Interspire_EmailIntegration_RemoveSubscriberResult
	*/
	public function removeSubscriberFromList ($listId, Interspire_EmailIntegration_Subscription $subscription, $asynchronous = true)
	{
		/** @var ISC_LOG */
		$log = $GLOBALS['ISC_CLASS_LOG'];

		if ($asynchronous) {
			// queue job for later and return immediately
			Interspire_TaskManager::createTask('emailintegration', 'Job_EmailIntegration_RemoveSubscriberFromList', array(
				'module' => str_replace('emailintegration_', '', $this->GetId()),
				'listId' => $listId,
				'email' => $subscription->getSubscriptionEmail(),
			));
			return new Interspire_EmailIntegration_RemoveSubscriberResult($this->GetId(), $listId, true);
		}

		// run immediately
		$list = $this->getList($listId);
		if (!$list) {
			$log->LogSystemError(array('emailintegration', $this->GetName()), GetLang('EmailIntegrationRemoveSubscriberListDoesntExist', array(
				'email' => $subscription->getSubscriptionEmail(),
				'provider' => $this->GetName(),
				'list' => $listId,
			)));
			return new Interspire_EmailIntegration_RemoveSubscriberResult($this->GetId(), $listId, false, false);
		}

		$exists = $this->findListSubscriber($list['provider_list_id'], $subscription);
		if (is_array($exists)) {
			$exists = true;
		} else {
			$exists = false;
		}

		if ($exists) {
			$api = $this->getApiInstance();
			$success = $api->listUnsubscribe($listId, $subscription->getSubscriptionEmail(), true, false, false);
		} else {
			$success = true;
		}

		if ($success) {
			if ($exists) {
				$log->LogSystemSuccess(array('emailintegration', $this->GetName()), GetLang('EmailIntegrationSubscriberRemoved', array(
					'email' => $subscription->getSubscriptionEmail(),
					'provider' => $this->GetName(),
					'list' => $list['name'],
				)));
			} else {
				$log->LogSystemDebug(array('emailintegration', $this->GetName()), GetLang('EmailIntegrationRemoveSubscriberDoesntExist', array(
					'email' => $subscription->getSubscriptionEmail(),
					'provider' => $this->GetName(),
					'list' => $list['name'],
				)));
			}
		} else {
			$log->LogSystemError(array('emailintegration', $this->GetName()), GetLang('EmailIntegrationSubscriberRemoveFailed', array(
				'email' => $subscription->getSubscriptionEmail(),
				'provider' => $this->GetName(),
				'list' => $list['name'],
			)), $api->errorMessage);
		}

		return new Interspire_EmailIntegration_RemoveSubscriberResult($this->GetId(), $listId, false, $success, $exists);
	}
Example #4
0
	/**
	* requeue this export job so it can process the next batch
	*
	* @return mixed result of Interspire_TaskManager::createTask
	*/
	protected function _repeatExport()
	{
		$this->_logDebug('repeating');
		return Interspire_TaskManager::createTask('emailintegration', get_class($this), $this->args);
	}
Example #5
0
		public function SetPanelSettings()
		{
			$GLOBALS['FooterScripts'] = '';

			$GLOBALS['HideLogoutLink'] = 'display: none';
			if(CustomerIsSignedIn()) {
				$GLOBALS['HideLogoutLink'] = '';
			}

			if($_SERVER['REQUEST_METHOD'] == 'POST') {
				$baseURL = getConfig('ShopPathNormal');
			}
			else {
				$baseURL = getCurrentLocation();
			}

			if(strpos($baseURL, '?') === false) {
				$baseURL .= '?';
			}
			else {
				$baseURL .= '&';
			}

			$fullSiteLink = $baseURL.'fullSite=1';
			$GLOBALS['ISC_CLASS_TEMPLATE']->assign('FullSiteLink', $fullSiteLink);

			// Show Mobile Site link
			if(canViewMobileSite()) {
				$mobileSiteURL = preg_replace('/(&)?fullSite=\d*/i', '', $baseURL);
				$GLOBALS['MobileSiteURL'] = $mobileSiteURL.'fullSite=0';
				$GLOBALS['MobileSiteLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('MobileSiteLink');
			}

			// Show "All prices are in [currency code]"
			$currency = GetCurrencyById($GLOBALS['CurrentCurrency']);
			if(is_array($currency) && $currency['currencycode']) {
				$GLOBALS['AllPricesAreInCurrency'] = sprintf(GetLang('AllPricesAreInCurrency'), isc_html_escape($currency['currencyname']), isc_html_escape($currency['currencycode']));
			}

			if(GetConfig('DebugMode') == 1) {
				$end_time = microtime_float();
				$GLOBALS['ScriptTime'] = number_format($end_time - ISC_START_TIME, 4);
				$GLOBALS['QueryCount'] = $GLOBALS['ISC_CLASS_DB']->NumQueries;
				if (function_exists('memory_get_peak_usage')) {
					$GLOBALS['MemoryPeak'] = "Memory usage peaked at ".Store_Number::niceSize(memory_get_peak_usage(true));
				} else {
					$GLOBALS['MemoryPeak'] = '';
				}

				if (isset($_REQUEST['debug'])) {
					$GLOBALS['QueryList'] = "<ol class='QueryList' style='font-size: 13px;'>\n";
					foreach($GLOBALS['ISC_CLASS_DB']->QueryList as $query) {
						$GLOBALS['QueryList'] .= "<li style='line-height: 1.4; margin-bottom: 4px;'>".isc_html_escape($query['Query'])." &mdash; <em>".number_format($query['ExecutionTime'], 4)."seconds</em></li>\n";
					}
					$GLOBALS['QueryList'] .= "</ol>";
				}
				$GLOBALS['DebugDetails'] = "<p>Page built in ".$GLOBALS['ScriptTime']."s with ".$GLOBALS['QueryCount']." queries. ".$GLOBALS['MemoryPeak']."</p>";
			}
			else {
				$GLOBALS['DebugDetails'] = '';
			}

			// Do we have any live chat service code to show in the footer
			$modules = GetConfig('LiveChatModules');
			if(!empty($modules)) {
				$liveChatClass = GetClass('ISC_LIVECHAT');
				$GLOBALS['LiveChatFooterCode'] = $liveChatClass->GetPageTrackingCode('footer');
			}

			// Load our whitelabel file for the front end
			require_once ISC_BASE_PATH.'/includes/whitelabel.php';

			// Load the configuration file for this template
			$poweredBy = 0;
			require_once ISC_BASE_PATH.'/templates/'.GetConfig('template').'/config.php';
			if(isset($GLOBALS['TPL_CFG']['PoweredBy'])) {
				if(!isset($GLOBALS['ISC_CFG']['TemplatePoweredByLines'][$GLOBALS['TPL_CFG']['PoweredBy']])) {
					$GLOBALS['TPL_CFG']['PoweredBy'] = 0;
				}
				$poweredBy = $GLOBALS['TPL_CFG']['PoweredBy'];
			}

			// Showing the powered by?
			$GLOBALS['PoweredBy'] = '';
			if($GLOBALS['ISC_CFG']['DisableFrontEndPoweredBy'] == false && isset($GLOBALS['ISC_CFG']['TemplatePoweredByLines'][$poweredBy])) {
				$GLOBALS['PoweredBy'] = $GLOBALS['ISC_CFG']['TemplatePoweredByLines'][$poweredBy];
			}

			if(empty($GLOBALS['OptimizerConversionScript']) && empty($GLOBALS['OptimizerTrackingScript']) && empty($GLOBALS['OptimizerControlScript'])) {
				$this->setGwoCookieCrossDomain();
			}

			$GLOBALS['SitemapURL_HTML'] = isc_html_escape(SitemapLink());
			$GLOBALS['SNIPPETS']['SitemapLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('SitemapLink');

			if (Interspire_TaskManager::hasTasks()) {
				// hasTasks is only implemented for Internal so this will (should) never run for Resque-based task manager
				$GLOBALS['FooterScripts'] .= Interspire_TaskManager::getTriggerHtml('json');
			}

			if (ISC_CATEGORY::areCategoryFlyoutsEnabled()) {
				// this needs to be output from php into the body since it's based on config vars
				// @todo use the stuff gaston is working on instead

				// bgiframe fixes some IE-related issues with CSS menus (like hovering over SELECT elements)
				$GLOBALS['FooterScripts'] .= '<script type="text/javascript" src="'
					. GetConfig('AppPath') . '/javascript/superfish/js/jquery.bgiframe.min.js?'
					. GetConfig('JSCacheToken') . '"></script>' . "\n";
				$GLOBALS['FooterScripts'] .= '<script type="text/javascript" src="'
					. GetConfig('AppPath') . '/javascript/superfish/js/superfish.js?'
					. GetConfig('JSCacheToken') . '"></script>' . "\n";
				$GLOBALS['FooterScripts'] .= '<script type="text/javascript">
	$(function(){
		if (typeof $.fn.superfish == "function") {
			$("ul.sf-menu").superfish({
				delay: ' . ((float)GetConfig('categoryFlyoutMouseOutDelay') * 1000) . ',
				dropShadows: ' . isc_json_encode(GetConfig('categoryFlyoutDropShadow')) . ',
				speed: "fast"
			})
			.find("ul")
			.bgIframe();
		}
	})
</script>
';
			}

			if (GetConfig('FastCartAction') == 'popup' && GetConfig('ShowCartSuggestions')) {
				$GLOBALS['SNIPPETS']['FastCartThickBoxJs'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('FastCartThickBoxJs');
			}
		}
Example #6
0
	/**
	* Aborts an in-progress listing job
	*
	*/
	private function abortProductListingAction()
	{
		$jobId = $_POST['jobId'];
		$jobKey = 'ebay:list_products:id:' . $jobId;
		$abortFlag = 'ebay:list_products:' . $jobId . ':abort';

		$keystore = Interspire_KeyStore::instance();

		if ($keystore->exists($jobKey)) {
			$keystore->set($abortFlag, 1);

			// if the export job has crashed, the abort will never be detected and data will never be cleaned up
			Interspire_TaskManager::createTask('ebay', 'Job_Ebay_ListProducts', array(
				'id' => $jobId,
			));
		}
	}
Example #7
0
	public function updateSubscriptionIP ($email, $ip, $asynchronous = true)
	{
		if ($asynchronous) {
			// queue job for later and return immediately
			Interspire_TaskManager::createTask('emailintegration', 'Job_EmailIntegration_UpdateSubscriptionIP', array(
				'module' => $this->GetId(),
				'email' => $email,
				'ip' => $ip,
			));
			return true;
		}

		$api = $this->getApiInstance();

		/** @var ISC_LOG */
		$log = $GLOBALS['ISC_CLASS_LOG'];

		try {
			// get lists to update for this subscriber
			$lists = $api->getAllListsForEmailAddress($email);
			if (!$lists || !$lists->isSuccess()) {
				return false;
			}

			// update this subscriber's ip address on all lists
			foreach ($lists->getData()->children() as $list) {
				$result = $api->updateSubscriberIP($email, (string)$list->listid, $ip);
				if (!$result || !$result->isSuccess()) {
					return false;
				}
			}
		} catch (Interspire_EmailIntegration_EmailMarketer_Exception $exception) {
			$log->LogSystemError(array('emailintegration', $this->GetName()), GetLang(get_class($exception) . '_Message'));
			return false;
		}

		return true;
	}
Example #8
0
	/**
	* Summarise logs for a given session id, copying raw data from product_views into product_views_summary
	*
	* @param string $sessionHash
	* @return void
	*/
	public static function summariseLogs($sessionHash)
	{
		if (!self::isEnabled()) {
			// the setting is disabled; this also stops data tracking
			return;
		}

		// gather a dataset of products viewed in the given session and place it in a background task for summarising, remove it from product_views so it isn't re-processed
		$db = $GLOBALS['ISC_CLASS_DB'];

		$sql = "SELECT product FROM `[|PREFIX|]product_views` WHERE `session` = '" . $db->Quote($sessionHash) . "' ORDER BY product";
		$result = $db->Query($sql);
		$products = array();
		while ($row = $db->Fetch($result)) {
			$products[] = (int)$row['product'];
		}

		// trim the processed data
		self::discardSession($sessionHash);

		// only concerned with sessions that viewed more than 1 product
		if (count($products) > 1) {

			$job = array(
				'sessionId' => $sessionHash,
				'viewedProducts' => $products,
			);

			Interspire_TaskManager::createTask('productviews', 'Job_ProductViews_ProcessSession', $job);
		}
	}
Example #9
0
	/**
	* requeue this listing job so it can process the next batch
	*
	* @return mixed result of Interspire_TaskManager::createTask
	*/
	protected function _repeatListing()
	{
		return Interspire_TaskManager::createTask('ebay', get_class($this), $this->args);
	}
	/**
	 * Queues a new export background job, and stores a handle to the
	 * job's controller accessible via $this->exportTask().
	 *
	 * @return object A controller handle to the queued export job.
	 */
	public function pushExportTask()
	{
		$controller = Job_Controller::create($this->getId());
		$this->setCurrentExportId($controller->getId());

		Interspire_TaskManager::createTask('shoppingcomparison',
			'Job_ShoppingComparison_RunExport',
			array("module" => $this->getId(),
				"controller" => $controller->getId()));

		$this->logSuccess(GetLang('ShoppingComparisonLogNewExportJob'));

		return $controller;
	}
Example #11
0
<?php
define('NO_SESSION', true);
require_once(dirname(__FILE__) . '/admin/init.php');
Interspire_TaskManager::handleTriggerRequest();