/**
  * Uninstalls node components and returns next node.
  *
  * @param	string		$node
  * @return	string
  */
 public function uninstall($node)
 {
     $nodes = $this->nodeBuilder->getNodeData($node);
     // invoke node-specific actions
     foreach ($nodes as $data) {
         $nodeData = unserialize($data['nodeData']);
         switch ($data['nodeType']) {
             case 'package':
                 $this->uninstallPackage($nodeData);
                 break;
             case 'pip':
                 $this->executePIP($nodeData);
                 break;
         }
     }
     // mark node as completed
     $this->nodeBuilder->completeNode($node);
     $node = $this->nodeBuilder->getNextNode($node);
     // update options.inc.php if uninstallation is completed
     if ($node == '') {
         OptionEditor::resetCache();
     }
     // return next node
     return $node;
 }
Exemplo n.º 2
0
 public function setApiKey($apiKey)
 {
     $db = WCF::getDB();
     $query = "update wcf" . WCF_N . "_option SET optionValue = ? WHERE optionName = 'wbb_tapatalk_api_key'";
     $statement = $db->prepareStatement($query);
     $statement->execute(array($apiKey));
     if ($db->getErrorNumber() != 00) {
         return false;
     }
     OptionEditor::rebuild();
     return true;
 }
 /**
  * @see \wcf\system\event\IEventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     $this->eventObj = $eventObj;
     // set variables required for the smartbanner feature
     $functionCallAfterWindowLoad = 0;
     $app_forum_name = WCF::getLanguage()->get(PAGE_TITLE);
     $board_url = WCF::getPath('wbb');
     $tapatalk_dir = WBB_TAPATALK_DIR;
     $tapatalk_dir_url = $board_url . $tapatalk_dir;
     $app_location_url = $this->getSchemeURL($page_type);
     $app_banner_message = defined('WBB_TAPATALK_APP_BANNER_MESSAGE') ? WBB_TAPATALK_APP_BANNER_MESSAGE : WCF::getLanguage()->get('wcf.user.3rdparty.tapatalk.app_banner_message');
     $app_ios_id = StringUtil::trim(defined('WBB_TAPATALK_APP_IOS_ID') ? WBB_TAPATALK_APP_IOS_ID : '');
     $app_android_id = StringUtil::trim(defined('WBB_TAPATALK_APP_ANDROID_ID') ? WBB_TAPATALK_APP_ANDROID_ID : '');
     $app_kindle_url = StringUtil::trim(defined('WBB_TAPATALK_APP_KINDLE_URL') ? WBB_TAPATALK_APP_KINDLE_URL : '');
     // for full view ads
     $api_key = StringUtil::trim(defined('WBB_TAPATALK_API_KEY') ? WBB_TAPATALK_API_KEY : '');
     $app_ads_enable = defined('WBB_TAPATALK_APP_FULL_BANNER') ? WBB_TAPATALK_APP_FULL_BANNER : 1;
     $app_banner_enable = defined('WBB_TAPATALK_APP_SMART_BANNER') ? WBB_TAPATALK_APP_SMART_BANNER : 1;
     $twitterfacebook_card_enabled = defined('WBB_TAPATALK_APP_FACEBOOK_TWITTER_DEEP_LINKING') ? WBB_TAPATALK_APP_FACEBOOK_TWITTER_DEEP_LINKING : 1;
     $banner_control = defined('WBB_TAPATALK_BANNER_CONTROL') ? WBB_TAPATALK_BANNER_CONTROL : 1;
     if (WBB_TAPATALK_BANNER_LAST_CHECK == 0 || TIME_NOW - WBB_TAPATALK_BANNER_LAST_CHECK > 1) {
         try {
             // fetch access_token
             $request = new HTTPRequest('https://tapatalk.com/get_forum_info.php', array(), array('key' => md5(StringUtil::trim(WBB_TAPATALK_API_KEY)), 'url' => $board_url));
             $request->execute();
             $reply = $request->getReply();
             $response = $reply['body'];
         } catch (\Exception $e) {
             die($e->getMessage());
         }
         if (!empty($response)) {
             $result = explode(':', $response);
             if ($result[0] == 'banner_control') {
                 if ($banner_control != $result[1]) {
                     $options = array('wbb_tapatalk_banner_last_check' => TIME_NOW, 'wbb_tapatalk_banner_control' => $banner_control);
                     OptionEditor::import($options);
                 }
             }
         }
     }
     if (!$banner_control) {
         $app_ads_enable = $app_banner_enable = 1;
     }
     if (file_exists(WBB_TAPATALK_DIR . '/smartbanner/head.inc.php')) {
         include WBB_TAPATALK_DIR . '/smartbanner/head.inc.php';
     }
     if (isset($app_head_include)) {
         // rebuild the output HTML since we must place the meta tags for Twitter somewhere else
         WCF::getTPL()->assign(array('tapatalkSmartbanner' => isset($app_banner_head) ? $app_banner_head : '', 'tapatalkTwitterAppCard' => isset($app_head_include) ? $app_head_include : ''));
     }
 }
	/**
	 * Uninstalls node components and returns next node.
	 * 
	 * @param	string		$node
	 * @return	string
	 */
	public function uninstall($node) {
		$nodes = $this->nodeBuilder->getNodeData($node);
		
		// invoke node-specific actions
		foreach ($nodes as $data) {
			$nodeData = unserialize($data['nodeData']);
			
			switch ($data['nodeType']) {
				case 'package':
					$this->uninstallPackage($nodeData);
				break;
				
				case 'pip':
					$this->executePIP($nodeData);
				break;
			}
		}
		
		// mark node as completed
		$this->nodeBuilder->completeNode($node);
		$node = $this->nodeBuilder->getNextNode($node);
		
		// perform post-uninstall actions
		if ($node == '') {
			// update options.inc.php if uninstallation is completed
			OptionEditor::resetCache();
			
			// clear cache
			CacheHandler::getInstance()->flushAll();
			
			// reset language cache
			LanguageFactory::getInstance()->clearCache();
			LanguageFactory::getInstance()->deleteLanguageCache();
			
			// reset stylesheets
			StyleHandler::resetStylesheets();
			
			// rebuild application paths
			ApplicationHandler::rebuild();
		}
		
		if ($this->requireRestructureVersionTables) {
			$this->restructureVersionTables();
		}		
		
		// return next node
		return $node;
	}
	/**
	 * Installs node components and returns next node.
	 * 
	 * @param	string		$node
	 * @return	wcf\system\package\PackageInstallationStep
	 */
	public function install($node) {
		$nodes = $this->nodeBuilder->getNodeData($node);
		
		// invoke node-specific actions
		foreach ($nodes as $data) {
			$nodeData = unserialize($data['nodeData']);
			
			switch ($data['nodeType']) {
				case 'package':
					$step = $this->installPackage($nodeData);
				break;
				
				case 'pip':
					$step = $this->executePIP($nodeData);
				break;
				
				case 'optionalPackages':
					$step = $this->selectOptionalPackages($node, $nodeData);
				break;
				
				default:
					die("Unknown node type: '".$data['nodeType']."'");
				break;
			}
			
			if ($step->splitNode()) {
				$this->nodeBuilder->cloneNode($node, $data['sequenceNo']);
				break;
			}
		}
		
		// mark node as completed
		$this->nodeBuilder->completeNode($node);
		
		// assign next node
		$node = $this->nodeBuilder->getNextNode($node);
		$step->setNode($node);
		
		// perform post-install/update actions
		if ($node == '') {
			// update options.inc.php
			OptionEditor::resetCache();
			
			if ($this->action == 'install') {
				// save localized package infos
				$this->saveLocalizedPackageInfos();
				
				// remove all cache files after WCFSetup
				if (!PACKAGE_ID) {
					CacheHandler::getInstance()->flushAll();
				}
				
				// rebuild application paths
				ApplicationHandler::rebuild();
				ApplicationEditor::setup();
			}
			
			// remove template listener cache
			TemplateListenerCacheBuilder::getInstance()->reset();
			TemplateListenerCodeCacheBuilder::getInstance()->reset();
				
			// reset language cache
			LanguageFactory::getInstance()->clearCache();
			LanguageFactory::getInstance()->deleteLanguageCache();
			
			// reset stylesheets
			StyleHandler::resetStylesheets();
		}	
		
		if ($this->requireRestructureVersionTables) {
			$this->restructureVersionTables();
		}			
		
		return $step;
	}
Exemplo n.º 6
0
 /**
  * Loads the options file, automatically created if not exists.
  */
 protected function loadOptions()
 {
     $filename = WCF_DIR . 'options.inc.php';
     // create options file if doesn't exist
     if (!file_exists($filename) || filemtime($filename) <= 1) {
         OptionEditor::rebuild();
     }
     require_once $filename;
 }
Exemplo n.º 7
0
 /**
  * Includes the options file.
  * If the option file doesn't exist, the rebuild of it is started.
  * 
  * @param	string		$filename
  */
 protected function loadOptions($filename = null, $packageID = 1)
 {
     if ($filename === null) {
         $filename = WCF_DIR . 'options.inc.php';
     }
     // create options file if doesn't exist
     if (!file_exists($filename) || filemtime($filename) <= 1) {
         \wcf\data\option\OptionEditor::rebuildFile($filename, $packageID);
     }
     require_once $filename;
 }
<?php

use wcf\data\option\OptionEditor;
/**
 * @author	Alexander Ebert
 * @copyright	2001-2015 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @category	Community Framework
 */
$options = array('cache_source_type' => CACHE_SOURCE_TYPE == 'no' ? 'disk' : CACHE_SOURCE_TYPE, 'last_update_time' => TIME_NOW, 'url_legacy_mode' => 1, 'url_to_lowercase' => 0, 'user_cleanup_notification_lifetime' => USER_CLEANUP_NOTIFICATION_LIFETIME == 60 ? 14 : USER_CLEANUP_NOTIFICATION_LIFETIME, 'wcf_uuid' => sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)));
// clear recaptcha keys if public key and private key match WoltLab's OEM key
if (RECAPTCHA_PUBLICKEY === '6LfOlMYSAAAAADvo3s4puBAYDqI-6YK2ybe7BJE5' && RECAPTCHA_PRIVATEKEY === '6LfOlMYSAAAAAKR3m_EFxmDv1xS8PCfeaSZ2LdG9') {
    $options['recaptcha_publickey'] = '';
    $options['recaptcha_privatekey'] = '';
}
OptionEditor::import($options);
OptionEditor::resetCache();
	/**
	 * @see	wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
	 */
	protected function saveOption($option, $categoryName, $existingOptionID = 0) {
		// default values
		$optionName = $optionType = $defaultValue = $validationPattern = $selectOptions = $enableOptions = $permissions = $options = '';
		$showOrder = null;
		$hidden = $supportI18n = $requireI18n = 0;
		
		// get values
		if (isset($option['name'])) $optionName = $option['name'];
		if (isset($option['optiontype'])) $optionType = $option['optiontype'];
		if (isset($option['defaultvalue'])) $defaultValue = WCF::getLanguage()->get($option['defaultvalue']);
		if (isset($option['validationpattern'])) $validationPattern = $option['validationpattern'];
		if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions'];
		if (isset($option['showorder'])) $showOrder = intval($option['showorder']);
		if (isset($option['hidden'])) $hidden = intval($option['hidden']);
		$showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
		if (isset($option['selectoptions'])) $selectOptions = $option['selectoptions'];
		if (isset($option['permissions'])) $permissions = $option['permissions'];
		if (isset($option['options'])) $options = $option['options'];
		if (isset($option['supporti18n'])) $supportI18n = $option['supporti18n'];
		if (isset($option['requirei18n'])) $requireI18n = $option['requirei18n'];
		
		// collect additional tags and their values
		$additionalData = array();
		foreach ($option as $tag => $value) {
			if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
		}
		
		// build update or create data
		$data = array(
			'categoryName' => $categoryName,
			'optionType' => $optionType,
			'validationPattern' => $validationPattern,
			'selectOptions' => $selectOptions,
			'showOrder' => $showOrder,
			'enableOptions' => $enableOptions,
			'hidden' => $hidden,
			'permissions' => $permissions,
			'options' => $options,
			'supportI18n' => $supportI18n,
			'requireI18n' => $requireI18n,
			'additionalData' => serialize($additionalData)
		);
		
		// try to find an existing option for updating
		$sql = "SELECT	*
			FROM	wcf".WCF_N."_".$this->tableName."
			WHERE	optionName = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array(
			$optionName
		));
		$row = $statement->fetchArray();
		
		// result was 'false' thus create a new item
		if (!$row) {
			$data['optionName'] = $optionName;
			$data['packageID'] = $this->installation->getPackageID();
			$data['optionValue'] = $defaultValue;
			
			OptionEditor::create($data);
		}
		else {
			// editing an option from a different package
			if ($row['packageID'] != $this->installation->getPackageID()) {
				throw new SystemException("Option '".$optionName."' already exists, but is owned by a different package");
			}
			
			// update existing item
			$optionObj = new Option(null, $row);
			$optionEditor = new OptionEditor($optionObj);
			$optionEditor->update($data);
		}
	}
 /**
  * Installs node components and returns next node.
  *
  * @param	string		$node
  * @return	PackageInstallationStep
  */
 public function install($node)
 {
     $nodes = $this->nodeBuilder->getNodeData($node);
     // invoke node-specific actions
     foreach ($nodes as $data) {
         $nodeData = unserialize($data['nodeData']);
         switch ($data['nodeType']) {
             case 'package':
                 $step = $this->installPackage($nodeData);
                 break;
             case 'pip':
                 $step = $this->executePIP($nodeData);
                 break;
             case 'optionalPackages':
                 $step = $this->selectOptionalPackages($node, $nodeData);
                 break;
             default:
                 die("Unknown node type: '" . $data['nodeType'] . "'");
                 break;
         }
         if ($step->splitNode()) {
             $this->nodeBuilder->cloneNode($node, $data['sequenceNo']);
             break;
         }
     }
     // mark node as completed
     $this->nodeBuilder->completeNode($node);
     // assign next node
     $node = $this->nodeBuilder->getNextNode($node);
     $step->setNode($node);
     // update options.inc.php and save localized package infos
     if ($node == '') {
         OptionEditor::resetCache();
         if ($this->action == 'install') {
             $this->saveLocalizedPackageInfos();
         }
     }
     return $step;
 }
 /**
  * @see	wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
  */
 protected function saveOption($option, $categoryName, $existingOptionID = 0)
 {
     // default values
     $optionName = $optionType = $defaultValue = $validationPattern = $selectOptions = $enableOptions = $permissions = $options = '';
     $showOrder = null;
     $hidden = $supportI18n = $requireI18n = 0;
     // get values
     if (isset($option['name'])) {
         $optionName = $option['name'];
     }
     if (isset($option['optiontype'])) {
         $optionType = $option['optiontype'];
     }
     if (isset($option['defaultvalue'])) {
         $defaultValue = WCF::getLanguage()->get($option['defaultvalue']);
     }
     if (isset($option['validationpattern'])) {
         $validationPattern = $option['validationpattern'];
     }
     if (isset($option['enableoptions'])) {
         $enableOptions = $option['enableoptions'];
     }
     if (isset($option['showorder'])) {
         $showOrder = intval($option['showorder']);
     }
     if (isset($option['hidden'])) {
         $hidden = intval($option['hidden']);
     }
     $showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
     if (isset($option['selectoptions'])) {
         $selectOptions = $option['selectoptions'];
     }
     if (isset($option['permissions'])) {
         $permissions = $option['permissions'];
     }
     if (isset($option['options'])) {
         $options = $option['options'];
     }
     if (isset($option['supporti18n'])) {
         $supportI18n = $option['supporti18n'];
     }
     if (isset($option['requirei18n'])) {
         $requireI18n = $option['requirei18n'];
     }
     // check if optionType exists
     $className = 'wcf\\system\\option\\' . StringUtil::firstCharToUpperCase($optionType) . 'OptionType';
     if (!class_exists($className)) {
         throw new SystemException("unable to find class '" . $className . "'");
     }
     // collect additional tags and their values
     $additionalData = array();
     foreach ($option as $tag => $value) {
         if (!in_array($tag, self::$reservedTags)) {
             $additionalData[$tag] = $value;
         }
     }
     // build update or create data
     $data = array('categoryName' => $categoryName, 'optionType' => $optionType, 'validationPattern' => $validationPattern, 'selectOptions' => $selectOptions, 'showOrder' => $showOrder, 'enableOptions' => $enableOptions, 'hidden' => $hidden, 'permissions' => $permissions, 'options' => $options, 'supportI18n' => $supportI18n, 'requireI18n' => $requireI18n, 'additionalData' => serialize($additionalData));
     // try to find an existing option for updating
     $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_" . $this->tableName . "\n\t\t\tWHERE\toptionName = ?\n\t\t\t\tAND packageID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($optionName, $this->installation->getPackageID()));
     $row = $statement->fetchArray();
     // result was 'false' thus create a new item
     if (!$row) {
         $data['optionName'] = $optionName;
         $data['packageID'] = $this->installation->getPackageID();
         $data['optionValue'] = $defaultValue;
         OptionEditor::create($data);
     } else {
         // update existing item
         $optionObj = new Option(null, $row);
         $optionEditor = new OptionEditor($optionObj);
         $optionEditor->update($data);
     }
 }
 /**
  * Installs node components and returns next node.
  * 
  * @param	string		$node
  * @return	\wcf\system\package\PackageInstallationStep
  */
 public function install($node)
 {
     $nodes = $this->nodeBuilder->getNodeData($node);
     // invoke node-specific actions
     foreach ($nodes as $data) {
         $nodeData = unserialize($data['nodeData']);
         switch ($data['nodeType']) {
             case 'package':
                 $step = $this->installPackage($nodeData);
                 break;
             case 'pip':
                 $step = $this->executePIP($nodeData);
                 break;
             case 'optionalPackages':
                 $step = $this->selectOptionalPackages($node, $nodeData);
                 break;
             default:
                 die("Unknown node type: '" . $data['nodeType'] . "'");
                 break;
         }
         if ($step->splitNode()) {
             $this->nodeBuilder->cloneNode($node, $data['sequenceNo']);
             break;
         }
     }
     // mark node as completed
     $this->nodeBuilder->completeNode($node);
     // assign next node
     $tmp = $node;
     $node = $this->nodeBuilder->getNextNode($node);
     $step->setNode($node);
     // perform post-install/update actions
     if ($node == '') {
         // update "last update time" option
         $sql = "UPDATE\twcf" . WCF_N . "_option\n\t\t\t\tSET\toptionValue = ?\n\t\t\t\tWHERE\toptionName = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array(TIME_NOW, 'last_update_time'));
         // update options.inc.php
         OptionEditor::resetCache();
         if ($this->action == 'install') {
             // save localized package infos
             $this->saveLocalizedPackageInfos();
             // remove all cache files after WCFSetup
             if (!PACKAGE_ID) {
                 CacheHandler::getInstance()->flushAll();
                 $sql = "UPDATE\twcf" . WCF_N . "_option\n\t\t\t\t\t\tSET\toptionValue = ?\n\t\t\t\t\t\tWHERE\toptionName = ?";
                 $statement = WCF::getDB()->prepareStatement($sql);
                 $statement->execute(array(StringUtil::getUUID(), 'wcf_uuid'));
                 if (WCF::getSession()->getVar('__wcfSetup_developerMode')) {
                     $statement->execute(array(1, 'enable_debug_mode'));
                 }
                 // update options.inc.php
                 OptionEditor::resetCache();
             }
             // rebuild application paths
             ApplicationHandler::rebuild();
             ApplicationEditor::setup();
         }
         // remove template listener cache
         TemplateListenerCodeCacheBuilder::getInstance()->reset();
         // reset language cache
         LanguageFactory::getInstance()->clearCache();
         LanguageFactory::getInstance()->deleteLanguageCache();
         // reset stylesheets
         StyleHandler::resetStylesheets();
         // clear user storage
         UserStorageHandler::getInstance()->clear();
         // rebuild config files for affected applications
         $sql = "SELECT\t\tpackage.packageID\n\t\t\t\tFROM\t\twcf" . WCF_N . "_package_installation_queue queue,\n\t\t\t\t\t\twcf" . WCF_N . "_package package\n\t\t\t\tWHERE\t\tqueue.processNo = ?\n\t\t\t\t\t\tAND package.packageID = queue.packageID\n\t\t\t\t\t\tAND package.packageID <> ?\n\t\t\t\t\t\tAND package.isApplication = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->queue->processNo, 1, 1));
         while ($row = $statement->fetchArray()) {
             Package::writeConfigFile($row['packageID']);
         }
         EventHandler::getInstance()->fireAction($this, 'postInstall');
         // remove archives
         $sql = "SELECT\tarchive\n\t\t\t\tFROM\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\tWHERE\tprocessNo = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->queue->processNo));
         while ($row = $statement->fetchArray()) {
             @unlink($row['archive']);
         }
         // delete queues
         $sql = "DELETE FROM\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\tWHERE\t\tprocessNo = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->queue->processNo));
     }
     if ($this->requireRestructureVersionTables) {
         $this->restructureVersionTables();
     }
     return $step;
 }