Ejemplo n.º 1
0
 /**
  * Save the configuration record
  *
  * @author RickG
  * @return boolean True is successful, false otherwise
  */
 function store(&$data)
 {
     JRequest::checkToken() or jexit('Invalid Token, in store config');
     //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_'));
     //ATM we want to ensure that only one config is used
     $config = VmConfig::loadConfig();
     unset($config->_params['pdf_invoice']);
     // parameter remove and replaced by inv_os
     $config->setParams($data);
     $confData = array();
     $query = 'SELECT * FROM `#__virtuemart_configs`';
     $this->_db->setQuery($query);
     if ($this->_db->loadResult()) {
         $confData['virtuemart_config_id'] = 1;
     } else {
         $confData['virtuemart_config_id'] = 0;
     }
     $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
     foreach ($urls as $urlkey) {
         $url = trim($config->get($urlkey));
         $length = strlen($url);
         if (strrpos($url, '/') != $length - 1) {
             $config->set($urlkey, $url . '/');
             vmInfo('Corrected media url ' . $urlkey . ' added missing /');
         }
     }
     /*		$path = trim($config->get('forSale_path'));
     		$length = strlen($path);
     		if(strrpos($url,DS)!=($length-1)){
     			if(is_dir()){
     				$config->set('forSale_path',$path.DS);
     				vmInfo('Corrected safe path added missing '.DS);
     			} else {
     
     			}
     		}
     */
     $safePath = trim($config->get('forSale_path'));
     if (!empty($safePath)) {
         $length = strlen($safePath);
         if (strrpos($safePath, DS) != $length - 1) {
             $safePath = $safePath . DS;
             $config->set('forSale_path', $safePath);
             vmInfo('Corrected safe path added missing ' . DS);
         }
     }
     if (!class_exists('shopfunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $safePath = shopFunctions::checkSafePath($safePath);
     if (!empty($safePath)) {
         $exists = JFolder::exists($safePath . 'invoices');
         if (!$exists) {
             $created = JFolder::create($safePath . 'invoices');
             if ($created) {
                 vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED');
             } else {
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     $confData['config'] = $config->toString();
     // 		vmdebug('config to store',$confData);
     $confTable = $this->getTable('configs');
     if (!$confTable->bindChecknStore($confData)) {
         vmError($confTable->getError());
     }
     // Load the newly saved values into the session.
     $config = VmConfig::loadConfig(true);
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->createLanguageTables();
     return true;
 }
Ejemplo n.º 2
0
 static function checkSafePath($safePath = 0)
 {
     if ($safePath == 0) {
         $safePath = VmConfig::get('forSale_path', 0);
         if (self::$tested) {
             return $safePath;
         }
     }
     $warn = FALSE;
     $uri = JFactory::getURI();
     $configlink = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
     VmConfig::loadJLang('com_virtuemart');
     if (empty($safePath)) {
         $warn = 'COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET';
     } else {
         //jimport('joomla.filesystem.folder');
         if (!class_exists('JFolder')) {
             require_once JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php';
         }
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             $warn = 'COM_VIRTUEMART_WARN_SAFE_PATH_WRONG';
         } else {
             if (!is_writable($safePath)) {
                 VmConfig::loadJLang('com_virtuemart_config');
                 VmError('COM_VIRTUEMART_WARN_SAFE_PATH_NOT_WRITEABLE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath, $configlink);
             } else {
                 if (!is_writable(self::getInvoicePath($safePath))) {
                     VmConfig::loadJLang('com_virtuemart_config');
                     VmError('COM_VIRTUEMART_WARN_SAFE_PATH_INV_NOT_WRITEABLE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath, $configlink);
                 }
             }
         }
     }
     if ($warn) {
         $suggestedPath = shopFunctions::getSuggestedSafePath();
         VmConfig::loadJLang('com_virtuemart_config');
         VmWarn($warn, vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath, $configlink);
         return FALSE;
     }
     return $safePath;
 }
Ejemplo n.º 3
0
 static function checkSafePath($safePath = 0)
 {
     if ($safePath == 0) {
         $safePath = VmConfig::get('forSale_path', 0);
         if (self::$tested) {
             return $safePath;
         }
     }
     $warn = FALSE;
     $uri = JFactory::getURI();
     $configlink = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
     VmConfig::loadJLang('com_virtuemart');
     if (empty($safePath)) {
         $warn = 'COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET';
     } else {
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             $warn = 'COM_VIRTUEMART_WARN_SAFE_PATH_WRONG';
         } else {
             if (!is_writable($safePath)) {
                 VmConfig::loadJLang('com_virtuemart_config');
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NOT_WRITEABLE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath, $configlink);
             } else {
                 if (!is_writable(self::getInvoicePath($safePath))) {
                     VmConfig::loadJLang('com_virtuemart_config');
                     VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_INV_NOT_WRITEABLE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath, $configlink);
                 }
             }
         }
     }
     if ($warn) {
         self::$tested = true;
         $suggestedPath = shopFunctions::getSuggestedSafePath();
         VmConfig::loadJLang('com_virtuemart_config');
         VmWarn($warn, JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath, $configlink);
         return FALSE;
     }
     return $safePath;
 }
Ejemplo n.º 4
0
 /**
  * Save the configuration record
  *
  * @author Max Milbers
  * @return boolean True is successful, false otherwise
  */
 function store(&$data)
 {
     vRequest::vmCheckToken();
     //We create a fresh config
     $config = VmConfig::loadConfig(false, true);
     //We load the config file
     $_raw = self::readConfigFile(FALSE);
     $_value = join('|', $_raw);
     //We set the config file values as parameters into the config
     $config->setParams($_value);
     //We merge the array from the file with the array from the form
     //in case it the form has the same key as the file, the value is taken from the form
     $config->_params = array_merge($config->_params, $data);
     //We need this to know if we should delete the cache
     $browse_cat_orderby_field = $config->get('browse_cat_orderby_field');
     $cat_brws_orderby_dir = $config->get('cat_brws_orderby_dir');
     $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
     foreach ($urls as $urlkey) {
         $url = trim($config->get($urlkey));
         $length = strlen($url);
         if ($length <= 1) {
             vmdebug('Urlkey was TOO SHORT ' . $urlkey . ' = ' . $url . ' and length ' . $length, $_raw[$urlkey]);
             unset($config->_params[$urlkey]);
             continue;
         }
         if (strrpos($url, '/') != $length - 1) {
             $config->set($urlkey, $url . '/');
             vmInfo('Corrected media url ' . $urlkey . ' added missing /');
         }
     }
     //If empty it is not sent by the form, other forms do it by using a table to store,
     //the config is like a big xparams and so we check some values for this form manually
     /*$toSetEmpty = array('active_languages','inv_os','email_os_v','email_os_s');
     		foreach($toSetEmpty as $item){
     			if(!isset($data[$item])) {
     				$config->set($item,array());
     			}
     		}*/
     $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5');
     foreach ($checkCSVInput as $csValueKey) {
         $csValue = $config->get($csValueKey);
         if (!empty($csValue)) {
             $sequenceArray = explode(',', $csValue);
             foreach ($sequenceArray as &$csV) {
                 $csV = (int) trim($csV);
             }
             $csValue = implode(',', $sequenceArray);
             $config->set($csValueKey, $csValue);
         }
     }
     if (!class_exists('JFolder')) {
         require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php';
     }
     $safePath = trim($config->get('forSale_path'));
     if (!empty($safePath)) {
         if (DS != '/' and strpos($safePath, '/') !== false) {
             $safePath = str_replace('/', DS, $safePath);
             vmInfo('Corrected safe path, replaced / by ' . DS);
         }
         $length = strlen($safePath);
         if (strrpos($safePath, DS) != $length - 1) {
             $safePath = $safePath . DS;
             vmInfo('Corrected safe path, added missing ' . DS);
         }
         $config->set('forSale_path', $safePath);
     } else {
         VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
         /*	$safePath = JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'vmfiles';
         
         			$exists = JFolder::exists($safePath);
         			if(!$exists){
         				$created = JFolder::create($safePath);
         				$safePath = $safePath.DS;
         				if($created){
         					vmInfo('COM_VIRTUEMART_SAFE_PATH_DEFAULT_CREATED',$safePath);
         					// create htaccess file
         					$fileData = "order deny, allow\ndeny from all\nallow from none";
         					JLoader::import('joomla.filesystem.file');
         					$fileName = $safePath.DS.'.htaccess';
         					$result = JFile::write($fileName, $fileData);
         					if (!$result) {
         						VmWarn('COM_VIRTUEMART_HTACCESS_DEFAULT_NOT_CREATED',$safePath,$fileData);
         					}
         					$config->set('forSale_path',$safePath);
         				} else {
         					VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE',vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
         				}
         			}*/
     }
     if (!class_exists('shopfunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $safePath = shopFunctions::checkSafePath($safePath);
     if (!empty($safePath)) {
         $exists = JFolder::exists($safePath . 'invoices');
         if (!$exists) {
             $created = JFolder::create($safePath . 'invoices');
             if ($created) {
                 vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED');
             } else {
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     $active_langs = $config->get('active_languages');
     if (empty($active_langs)) {
         $config->set('active_languages', array(VmConfig::$vmlangTag));
     }
     //ATM we want to ensure that only one config is used
     $confData = array();
     $confData['virtuemart_config_id'] = 1;
     $confData['config'] = $config->toString();
     $confTable = $this->getTable('configs');
     if (!$confTable->bindChecknStore($confData)) {
         vmError($confTable->getError());
     }
     VmConfig::loadConfig(true);
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->createLanguageTables();
     /* This conditions is not enough, if the language changes we need to recall the cache.
     		$newbrowse_cat_orderby_field = $config->get('browse_cat_orderby_field');
     		$newcat_brws_orderby_dir = $config->get('cat_brws_orderby_dir');
     		if($browse_cat_orderby_field!=$newbrowse_cat_orderby_field or $newcat_brws_orderby_dir!=$cat_brws_orderby_dir){
     			$cache = JFactory::getCache('com_virtuemart_cats','callback');
     			$cache->clean();
     		}*/
     $cache = JFactory::getCache('com_virtuemart_cats', 'callback');
     $cache->clean();
     $cache = JFactory::getCache('com_virtuemart_rss', 'callback');
     $cache->clean();
     $cache = JFactory::getCache('convertECB', 'callback');
     $cache->clean();
     $cache = JFactory::getCache('_virtuemart');
     $cache->clean();
     $cache = JFactory::getCache('com_plugins');
     $cache->clean();
     $cache = JFactory::getCache('_system');
     $cache->clean();
     $cache = JFactory::getCache('page');
     $cache->clean();
     return true;
 }
Ejemplo n.º 5
0
 static function checkSafePath($safePath = 0)
 {
     if ($safePath == 0) {
         $safePath = VmConfig::get('forSale_path', 0);
     }
     if (empty($safePath)) {
         $suggestedPath = shopFunctions::getSuggestedSafePath();
         $uri = JFactory::getURI();
         $configlink = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
         VmWarn('COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath, $configlink);
         return FALSE;
     } else {
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             $uri = JFactory::getURI();
             $configlink = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
             $suggestedPath = shopFunctions::getSuggestedSafePath();
             VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_WRONG', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath, $configlink);
             return FALSE;
         } else {
             return $safePath;
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * Save the configuration record
  *
  * @author Max Milbers
  * @return boolean True is successful, false otherwise
  */
 function store(&$data, $replace = FALSE)
 {
     JRequest::checkToken() or jexit('Invalid Token, in store config');
     //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_'));
     //ATM we want to ensure that only one config is used
     $config = VmConfig::loadConfig(TRUE);
     $browse_cat_orderby_field = $config->get('browse_cat_orderby_field');
     $cat_brws_orderby_dir = $config->get('cat_brws_orderby_dir');
     $config->setParams($data, $replace);
     $confData = array();
     $query = 'SELECT * FROM `#__virtuemart_configs`';
     $this->_db->setQuery($query);
     if ($this->_db->loadResult()) {
         $confData['virtuemart_config_id'] = 1;
     } else {
         $confData['virtuemart_config_id'] = 0;
     }
     $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
     foreach ($urls as $urlkey) {
         $url = trim($config->get($urlkey));
         $length = strlen($url);
         if (strrpos($url, '/') != $length - 1) {
             $config->set($urlkey, $url . '/');
             vmInfo('Corrected media url ' . $urlkey . ' added missing /');
         }
     }
     //If empty it is not sent by the form, other forms do it by using a table to store,
     //the config is like a big xparams and so we check some values for this form manually
     /*$toSetEmpty = array('active_languages','inv_os','email_os_v','email_os_s');
     		foreach($toSetEmpty as $item){
     			if(!isset($data[$item])) {
     				$config->set($item,array());
     			}
     		}*/
     $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5');
     foreach ($checkCSVInput as $csValueKey) {
         $csValue = $config->get($csValueKey);
         if (!empty($csValue)) {
             $sequenceArray = explode(',', $csValue);
             foreach ($sequenceArray as &$csV) {
                 $csV = (int) trim($csV);
             }
             $csValue = implode(',', $sequenceArray);
             $config->set($csValueKey, $csValue);
         }
     }
     $safePath = trim($config->get('forSale_path'));
     if (!empty($safePath)) {
         if (DS != '/' and strpos($safePath, '/') !== false) {
             $safePath = str_replace('/', DS, $safePath);
             vmdebug('$safePath', $safePath);
         }
         $length = strlen($safePath);
         if (strrpos($safePath, DS) != $length - 1) {
             $safePath = $safePath . DS;
             vmInfo('Corrected safe path added missing ' . DS);
         }
         $config->set('forSale_path', $safePath);
     } else {
         $safePath = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'vmfiles';
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             $created = JFolder::create($safePath);
             $safePath = $safePath . DS;
             if ($created) {
                 vmInfo('COM_VIRTUEMART_SAFE_PATH_DEFAULT_CREATED', $safePath);
                 /* create htaccess file */
                 $fileData = "order deny, allow\ndeny from all\nallow from none";
                 JLoader::import('joomla.filesystem.file');
                 $fileName = $safePath . DS . '.htaccess';
                 $result = JFile::write($fileName, $fileData);
                 if (!$result) {
                     VmWarn('COM_VIRTUEMART_HTACCESS_DEFAULT_NOT_CREATED', $safePath, $fileData);
                 }
                 $config->set('forSale_path', $safePath);
             } else {
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     if (!class_exists('shopfunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $safePath = shopFunctions::checkSafePath($safePath);
     if (!empty($safePath)) {
         $exists = JFolder::exists($safePath . 'invoices');
         if (!$exists) {
             $created = JFolder::create($safePath . 'invoices');
             if ($created) {
                 vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED');
             } else {
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     $confData['config'] = $config->toString();
     $confTable = $this->getTable('configs');
     if (!$confTable->bindChecknStore($confData)) {
         vmError($confTable->getError());
     }
     // Load the newly saved values into the session.
     $config = VmConfig::loadConfig(true);
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->createLanguageTables();
     $newbrowse_cat_orderby_field = $config->get('browse_cat_orderby_field');
     $newcat_brws_orderby_dir = $config->get('cat_brws_orderby_dir');
     if ($browse_cat_orderby_field != $newbrowse_cat_orderby_field or $newcat_brws_orderby_dir != $cat_brws_orderby_dir) {
         $cache = JFactory::getCache('com_virtuemart_cats', 'callback');
         $cache->clean();
     }
     return true;
 }
Ejemplo n.º 7
0
 /**
  * This functions interprets the String that is entered in the calc_value_mathop field
  * The first char is the signum of the function. The more this function can be enhanced
  * maybe with function that works like operators, the easier it will be to make more complex disount/commission/profit formulas
  * progressive, nonprogressive and so on.
  *
  * @copyright Copyright (c) 2009 VirtueMart Team. All rights reserved.
  * @author Max Milbers
  * @param 	$mathop 	String reprasentation of the mathematical operation, valid ('+','-','+%','-%')
  * @param	$value 	float	The value that affects the price
  * @param 	$currency int	the currency which should be used
  * @param	$price 	float	The price to calculate
  */
 function interpreteMathOp($rule, $price)
 {
     $mathop = $rule['calc_value_mathop'];
     $value = (double) $rule['calc_value'];
     $currency = $rule['calc_currency'];
     //$mathop, $value, $price, $currency='')
     $coreMathOp = array('+', '-', '+%', '-%');
     if (!$this->_revert) {
         $plus = '+';
         $minus = '-';
     } else {
         $plus = '-';
         $minus = '+';
     }
     //vmdebug(' interpreteMathOp',$mathop,$rule['calc_name']);
     //vmTrace(' interpreteMathOp');
     if (in_array($mathop, $coreMathOp)) {
         $sign = substr($mathop, 0, 1);
         $calculated = false;
         if (strlen($mathop) == 2) {
             $cmd = substr($mathop, 1, 2);
             if ($cmd == '%') {
                 if (!$this->_revert) {
                     $calculated = $price * $value / 100.0;
                 } else {
                     if (!empty($value)) {
                         if ($sign == $plus) {
                             $calculated = abs($price / (1 - 100.0 / $value));
                         } else {
                             $calculated = abs($price / (1 + 100.0 / $value));
                         }
                     } else {
                         vmdebug('interpreteMathOp $value is empty ' . $rule->calc_name);
                     }
                     // 							vmdebug('interpreteMathOp $price'.$price.' $value '.$value.' $sign '.$sign.' '.$plus.' $calculated '.$calculated);
                 }
             }
         } else {
             if (strlen($mathop) == 1) {
                 $calculated = $this->_currencyDisplay->convertCurrencyTo($currency, $value);
             }
         }
         // 				vmdebug('interpreteMathOp',$price,$calculated,$plus);
         if ($sign == $plus) {
             return $price + (double) $calculated;
         } else {
             if ($sign == $minus) {
                 return $price - (double) $calculated;
             } else {
                 VmWarn('Unrecognised mathop ' . $mathop . ' in calculation rule found');
                 return $price;
             }
         }
     } else {
         JPluginHelper::importPlugin('vmcalculation');
         $dispatcher = JDispatcher::getInstance();
         $calculated = $dispatcher->trigger('interpreteMathOp', array($this, $mathop, $value, $price, $currency, $this->_revert));
         $calculated = $dispatcher->trigger('plgVmInterpreteMathOp', array($this, $rule, $price, $this->_revert));
         //vmdebug('result of plgVmInterpreteMathOp',$calculated);
         if ($calculated) {
             foreach ($calculated as $calc) {
                 if ($calc) {
                     return $calc;
                 }
             }
         } else {
             VmWarn('Unrecognised mathop ' . $mathop . ' in calculation rule found, seems you created this rule with plugin not longer accesible (deactivated, uninstalled?)');
             return $price;
         }
     }
 }
Ejemplo n.º 8
0
 /**
  * Sets the file information and paths/urls and so on.
  *
  * @author Max Milbers
  * @param unknown_type $filename
  * @param unknown_type $url
  * @param unknown_type $path
  */
 function setFileInfo($type = 0)
 {
     $this->file_url_folder = '';
     $this->file_path_folder = '';
     $this->file_url_folder_thumb = '';
     if ($this->file_is_forSale == 0 and $type != 'forSale') {
         $this->file_url_folder = $this->getMediaUrlByView($type);
         $this->file_url_folder_thumb = $this->file_url_folder . 'resized/';
         $this->file_path_folder = str_replace('/', DS, $this->file_url_folder);
     } else {
         $safePath = VmConfig::get('forSale_path', 0);
         if (empty($safePath)) {
             $lastIndex = strrpos(JPATH_ROOT, DS);
             $suggestedPath = substr(JPATH_ROOT, 0, $lastIndex) . DS . 'vmfiles';
             VmWarn('COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath);
             return false;
         }
         $this->file_path_folder = $safePath;
         $this->file_url_folder = $this->file_path_folder;
         //str_replace(DS,'/',$this->file_path_folder);
         $this->file_url_folder_thumb = VmConfig::get('forSale_path_thumb');
     }
     //Clean from possible injection
     while (strpos($this->file_path_folder, '..') !== false) {
         $this->file_path_folder = str_replace('..', '', $this->file_path_folder);
     }
     $this->file_path_folder = preg_replace('#[/\\\\]+#', DS, $this->file_path_folder);
     if (empty($this->file_url)) {
         $this->file_url = $this->file_url_folder;
         $this->file_name = '';
         $this->file_extension = '';
     } else {
         if (!class_exists('JFile')) {
             require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php';
         }
         // 				$lastIndexOfSlash= strrpos($this->file_url,'/');
         // 				$name = substr($this->file_url,$lastIndexOfSlash+1);
         $name = str_replace($this->file_url_folder, '', $this->file_url);
         if (!empty($name) && $name !== '/') {
             $this->file_name = JFile::stripExt($name);
             //Ensure using right directory
             if ($this->file_is_forSale == 0) {
                 $file_url = $this->getMediaUrlByView($type) . $this->file_name;
             } else {
                 $file_url = vmConfig::get('forSale_path');
             }
             if (JFile::exists($file_url)) {
                 $this->file_url = $file_url;
             }
             $this->file_extension = strtolower(JFile::getExt($name));
         }
     }
     if ($this->file_is_downloadable) {
         $this->media_role = 'file_is_downloadable';
     }
     if ($this->file_is_forSale) {
         $this->media_role = 'file_is_forSale';
     }
     if (empty($this->media_role)) {
         $this->media_role = 'file_is_displayable';
     }
     // 		vmdebug('$this->media_role',$this->media_role);
     $this->determineFoldersToTest();
     if (!empty($this->file_url) && empty($this->file_url_thumb)) {
         $this->displayMediaThumb('', true, '', false);
     }
 }
Ejemplo n.º 9
0
 function display($tpl = null)
 {
     // Load the helper(s)
     $this->loadHelper('image');
     $this->loadHelper('html');
     $model = VmModel::getModel();
     $usermodel = VmModel::getModel('user');
     JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48');
     $this->addStandardEditViewCommands();
     $config = VmConfig::loadConfig();
     unset($config->_params['pdf_invoice']);
     // parameter remove and replaced by inv_os
     $this->assignRef('config', $config);
     $mainframe = JFactory::getApplication();
     $this->assignRef('joomlaconfig', $mainframe);
     $userparams = JComponentHelper::getParams('com_users');
     $this->assignRef('userparams', $userparams);
     $templateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT'));
     $this->assignRef('jTemplateList', $templateList);
     $vmLayoutList = $model->getLayoutList('virtuemart');
     $this->assignRef('vmLayoutList', $vmLayoutList);
     // Outcommented to revert rev. 2916
     //		$vendorList = ShopFunctions::renderVendorList(VmConfig::get('default_virtuemart_vendor_id'));
     //		// We must replace the fieldname and ID 'virtuemart_vendor_id' to 'default_vendor'
     //		$vendorList = preg_replace('/"virtuemart_vendor_id"/', '"default_virtuemart_vendor_id"', $vendorList);
     //		$this->assignRef('vendorList', $vendorList);
     $categoryLayoutList = $model->getLayoutList('category');
     $this->assignRef('categoryLayoutList', $categoryLayoutList);
     $productLayoutList = $model->getLayoutList('productdetails');
     $this->assignRef('productLayoutList', $productLayoutList);
     $noimagelist = $model->getNoImageList();
     $this->assignRef('noimagelist', $noimagelist);
     $orderStatusModel = VmModel::getModel('orderstatus');
     $orderStates = $orderStatusModel->getOrderStatusList();
     $orderStatusList = array();
     $orderStatusList[0] = JText::_('COM_VIRTUEMART_NONE');
     foreach ($orderStates as $orderState) {
         $orderStatusList[$orderState->order_status_code] = JText::_($orderState->order_status_name);
     }
     $this->assignRef('orderStatusList', $orderStatusList);
     /*
     		$oderstatusModel = VmModel::getModel('Orderstatus');
     		$orderStatusList = $oderstatusModel->getOrderStatusList();
     		$this->assignRef('orderStatusList', $orderStatusList);
     */
     $currConverterList = $model->getCurrencyConverterList();
     $this->assignRef('currConverterList', $currConverterList);
     $moduleList = $model->getModuleList();
     $this->assignRef('moduleList', $moduleList);
     //$contentLinks = $model->getContentLinks();
     //$this->assignRef('contentLinks', $contentLinks);
     $activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages'));
     $this->assignRef('activeLanguages', $activeLanguages);
     $orderByFields = $model->getProductFilterFields('browse_orderby_fields');
     $this->assignRef('orderByFields', $orderByFields);
     $searchFields = $model->getProductFilterFields('browse_search_fields');
     $this->assignRef('searchFields', $searchFields);
     $aclGroups = $usermodel->getAclGroupIndentedTree();
     $this->assignRef('aclGroups', $aclGroups);
     if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) {
         $imagePath = VmConfig::get('vmtemplate') . '/images/availability/';
     } else {
         $imagePath = '/components/com_virtuemart/assets/images/availability/';
     }
     $this->assignRef('imagePath', $imagePath);
     $safePath = VmConfig::get('forSale_path', 0);
     $lastIndex = strrpos(JPATH_ROOT, DS);
     $suggestedPath = substr(JPATH_ROOT, 0, $lastIndex) . DS . 'vmfiles';
     if (empty($safePath)) {
         VmWarn('COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath);
     } else {
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_WRONG', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath);
         }
     }
     parent::display($tpl);
 }
Ejemplo n.º 10
0
 /**
  * Save the configuration record
  *
  * @author Max Milbers
  * @return boolean True is successful, false otherwise
  */
 function store(&$data)
 {
     vRequest::vmCheckToken();
     if (!vmAccess::manager('config')) {
         vmWarn('Insufficient permissions to delete product');
         return false;
     }
     //We create a fresh config
     $config = tsmConfig::loadConfig(false, true);
     //We load the config file
     $_raw = self::readConfigFile(FALSE);
     $_value = join('|', $_raw);
     //We set the config file values as parameters into the config
     $config->setParams($_value);
     //We merge the array from the file with the array from the form
     //in case it the form has the same key as the file, the value is taken from the form
     $config->_params = array_merge($config->_params, $data);
     //We need this to know if we should delete the cache
     $browse_cat_orderby_field = $config->get('browse_cat_orderby_field');
     $cat_brws_orderby_dir = $config->get('cat_brws_orderby_dir');
     $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
     foreach ($urls as $urlkey) {
         $url = trim($config->get($urlkey));
         $length = strlen($url);
         if ($length <= 1) {
             vmdebug('Urlkey was TOO SHORT ' . $urlkey . ' = ' . $url . ' and length ' . $length, $_raw[$urlkey]);
             unset($config->_params[$urlkey]);
             continue;
         }
         if (strrpos($url, '/') != $length - 1) {
             $config->set($urlkey, $url . '/');
             vmInfo('Corrected media url ' . $urlkey . ' added missing /');
         }
     }
     $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5');
     foreach ($checkCSVInput as $csValueKey) {
         $csValue = $config->get($csValueKey);
         if (!empty($csValue)) {
             $sequenceArray = explode(',', $csValue);
             foreach ($sequenceArray as &$csV) {
                 $csV = (int) trim($csV);
             }
             $csValue = implode(',', $sequenceArray);
             $config->set($csValueKey, $csValue);
         }
     }
     if (!class_exists('JFolder')) {
         require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php';
     }
     $safePath = trim($config->get('forSale_path'));
     if (!empty($safePath)) {
         if (DS != '/' and strpos($safePath, '/') !== false) {
             $safePath = str_replace('/', DS, $safePath);
             vmInfo('Corrected safe path, replaced / by ' . DS);
         }
         $length = strlen($safePath);
         if (strrpos($safePath, DS) != $length - 1) {
             $safePath = $safePath . DS;
             vmInfo('Corrected safe path, added missing ' . DS);
         }
         $p = VMPATH_ROOT . DS;
         if (strtolower($safePath) == strtolower($p)) {
             $safePath = '';
             vmError('Do not use as safepath your tsmart root folder');
         }
         $config->set('forSale_path', $safePath);
     } else {
         VmWarn('com_tsmart_WARN_SAFE_PATH_NO_INVOICE', tsmText::_('com_tsmart_ADMIN_CFG_MEDIA_FORSALE_PATH'));
         /*	$safePath = VMPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_tsmart'.DS.'vmfiles';
         
         			$exists = JFolder::exists($safePath);
         			if(!$exists){
         				$created = JFolder::create($safePath);
         				$safePath = $safePath.DS;
         				if($created){
         					vmInfo('com_tsmart_SAFE_PATH_DEFAULT_CREATED',$safePath);
         					// create htaccess file
         					$fileData = "order deny, allow\ndeny from all\nallow from none";
         					JLoader::import('joomla.filesystem.file');
         					$fileName = $safePath.DS.'.htaccess';
         					$result = JFile::write($fileName, $fileData);
         					if (!$result) {
         						VmWarn('com_tsmart_HTACCESS_DEFAULT_NOT_CREATED',$safePath,$fileData);
         					}
         					$config->set('forSale_path',$safePath);
         				} else {
         					VmWarn('com_tsmart_WARN_SAFE_PATH_NO_INVOICE',vmText::_('com_tsmart_ADMIN_CFG_MEDIA_FORSALE_PATH'));
         				}
         			}*/
     }
     if (!class_exists('shopfunctions')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $safePath = shopFunctions::checkSafePath($safePath);
     if (!empty($safePath)) {
         $exists = JFolder::exists($safePath . 'invoices');
         if (!$exists) {
             $created = JFolder::create($safePath . 'invoices');
             if ($created) {
                 vmInfo('com_tsmart_SAFE_PATH_INVOICE_CREATED');
             } else {
                 VmWarn('com_tsmart_WARN_SAFE_PATH_NO_INVOICE', tsmText::_('com_tsmart_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     $active_langs = $config->get('active_languages');
     if (empty($active_langs)) {
         $config->set('active_languages', array(tsmConfig::$vmlangTag));
     }
     //ATM we want to ensure that only one config is used
     $confData = array();
     $confData['tsmart_config_id'] = 1;
     $confData['config'] = $config->toString();
     $confTable = $this->getTable('configs');
     $confTable->bindChecknStore($confData);
     tsmConfig::loadConfig(true);
     if (!class_exists('GenericTableUpdater')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->createLanguageTables();
     $cache = JFactory::getCache();
     $cache->clean('com_tsmart_cats');
     $cache->clean('mod_tsmart_product');
     $cache->clean('mod_tsmart_category');
     $cache->clean('com_tsmart_rss');
     $cache->clean('com_tsmart_cat_manus');
     $cache->clean('convertECB');
     $cache->clean('_tsmart');
     $cache->clean('com_plugins');
     $cache->clean('_system');
     $cache->clean('page');
     return true;
 }
 /**
  * Save the configuration record
  *
  * @author RickG
  * @return boolean True is successful, false otherwise
  */
 function store(&$data, $replace = FALSE)
 {
     JSession::checkToken() or JSession::checkToken('get') or jexit('Invalid Token, in store config');
     //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_'));
     //ATM we want to ensure that only one config is used
     $config = VmConfig::loadConfig(TRUE);
     unset($config->_params['pdf_invoice']);
     // parameter remove and replaced by inv_os
     $config->setParams($data, $replace);
     $confData = array();
     $query = 'SELECT * FROM `#__virtuemart_configs`';
     $this->_db->setQuery($query);
     if ($this->_db->loadResult()) {
         $confData['virtuemart_config_id'] = 1;
     } else {
         $confData['virtuemart_config_id'] = 0;
     }
     $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
     foreach ($urls as $urlkey) {
         $url = trim($config->get($urlkey));
         $length = strlen($url);
         if (strrpos($url, '/') != $length - 1) {
             $config->set($urlkey, $url . '/');
             vmInfo('Corrected media url ' . $urlkey . ' added missing /');
         }
     }
     //If empty it is not sent by the form, other forms do it by using a table to store,
     //the config is like a big xparams and so we check some values for this form manually
     /*$toSetEmpty = array('active_languages','inv_os','email_os_v','email_os_s');
     		foreach($toSetEmpty as $item){
     			if(!isset($data[$item])) {
     				$config->set($item,array());
     			}
     		}*/
     $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5');
     foreach ($checkCSVInput as $csValueKey) {
         $csValue = $config->get($csValueKey);
         if (!empty($csValue)) {
             $sequenceArray = explode(',', $csValue);
             foreach ($sequenceArray as &$csV) {
                 $csV = (int) trim($csV);
             }
             $csValue = implode(',', $sequenceArray);
             $config->set($csValueKey, $csValue);
         }
     }
     $safePath = trim($config->get('forSale_path'));
     if (!empty($safePath)) {
         $length = strlen($safePath);
         if (strrpos($safePath, DS) != $length - 1) {
             $safePath = $safePath . DS;
             $config->set('forSale_path', $safePath);
             vmInfo('Corrected safe path added missing ' . DS);
         }
     }
     if (!class_exists('shopfunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $safePath = shopFunctions::checkSafePath($safePath);
     if (!empty($safePath)) {
         $exists = JFolder::exists($safePath . 'invoices');
         if (!$exists) {
             $created = JFolder::create($safePath . 'invoices');
             if ($created) {
                 vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED');
             } else {
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     $confData['config'] = $config->toJson();
     // 		vmdebug('config to store',$confData);
     $confTable = $this->getTable('configs');
     if (!$confTable->bindChecknStore($confData)) {
         vmError($confTable->getError());
     }
     // Load the newly saved values into the session.
     $config = VmConfig::loadConfig(true);
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->createLanguageTables();
     return true;
 }