コード例 #1
0
 public function checkConfig()
 {
     // Check if the settings are all empty
     if (MagebridgeModelConfig::allEmpty() == true) {
         JError::raiseWarning(500, JText::sprintf('Check the online %s for more information.', MageBridgeHelper::getHelpText('quickstart')));
         return;
     }
     // Otherwise check all values
     $config = MagebridgeModelConfig::load();
     foreach ($config as $c) {
         if (isset($c['name']) && isset($c['value']) && ($message = MageBridge::getConfig()->check($c['name'], $c['value']))) {
             JError::raiseWarning(500, $message);
         }
     }
     return;
 }
コード例 #2
0
ファイル: config.php プロジェクト: apiceweb/MageBridgeCore
 /**
  * Method to check a specific configuratione-element
  * 
  * @param string $element
  * @param string $value
  * @return string|null
  */
 public static function check($element, $value = null)
 {
     // Reset an empty value to its original value
     if (empty($value)) {
         $value = MagebridgeModelConfig::load($element);
     }
     // Check for settings that should not be kept empty
     $nonempty = array('host', 'website', 'api_user', 'api_key');
     if (MagebridgeModelConfig::allEmpty() == false && in_array($element, $nonempty) && empty($value)) {
         return JText::sprintf('Setting "%s" is empty - Please configure it below', JText::_($element));
     }
     // Check host
     if ($element == 'host') {
         if (preg_match('/([^a-zA-Z0-9\\.\\-\\_\\:]+)/', $value) == true) {
             return JText::_('Hostname contains illegal characters. Note that a hostname is not an URL, but only a fully qualified domainname.');
         } else {
             if (gethostbyname($value) == $value && !preg_match('/([0-9\\.]+)/', $value)) {
                 return JText::sprintf('DNS lookup of hostname %s failed', $value);
             } else {
                 if (MagebridgeModelConfig::load('api_widgets') == true) {
                     $bridge = MageBridgeModelBridge::getInstance();
                     $data = $bridge->build();
                     if (empty($data)) {
                         $url = $bridge->getMagentoBridgeUrl();
                         return JText::sprintf('Unable to open a connection to <a href="%s" target="_new">%s</a>', $url, $url);
                     }
                 }
             }
         }
     }
     // Check supportkey
     if ($element == 'supportkey' && empty($value)) {
         return JText::sprintf('Please configure your support-key. Your support-key can be obtained from %s', MageBridgeHelper::getHelpText('subscriptions'));
     }
     // Check API widgets
     if ($element == 'api_widgets' && $value != 1) {
         return JText::_('API widgets are disabled');
     }
     // Check offline
     if ($element == 'offline' && $value == 1) {
         return JText::_('Bridge is disabled through settings');
     }
     // Check website
     if ($element == 'website' && !empty($value)) {
         if (is_numeric($value) == false) {
             return JText::sprintf('Website ID needs to be a numeric value. Current value is "%s"', $value);
         }
     }
     /**
     if ($element == 'storeview' && !empty($value)) {
     	if ( preg_match( '/([a-zA-Z0-9\.\-\_]+)/', $value ) == false ) {
     		return JText::_( 'Store-name contains illegal characters: '.$value );
     	} else {
     		$storeviews = MagebridgeModelConfig::getStoreNames();
     		if (!is_array($storeviews) && $storeviews != 0) {
     			return JText::_($storeviews);
     
     		} else {
     
     			$match = false;
     			if (!empty($storeviews)) {
     				foreach ($storeviews as $storeview) {
     					if ($storeview['value'] == $value) {
     						$match = true;
     						break;
     					}
     				}
     			}
     
     			if ($match == false) {
     				$msg = JText::sprintf( 'Store-names detected, but "%s" is not one of them', $value );
     				return $msg;
     			}
     		}
     	}
     }
     */
     // Check basedir
     if ($element == 'basedir') {
         if (empty($value)) {
             return null;
         }
         if (preg_match('/([a-zA-Z0-9\\.\\-\\_]+)/', $value) == false) {
             return JText::_('Basedir contains illegal characters');
         }
         $root = MageBridgeUrlHelper::getRootItem();
         $joomla_host = JFactory::getURI()->toString(array('host'));
         $magento_host = MagebridgeModelConfig::load('host');
         // Check whether the Magento basedir conflicts with the MageBridge alias
         if (!empty($root) && !empty($root->route) && $root->route == $value && $joomla_host == $magento_host) {
             return JText::_('Magento basedir is same as MageBridge alias, which is not possible');
         }
     }
     return null;
 }