/** * * Enter description here ... * @param string $filtermod * @param string $levelmod * @param bolean $rootPath */ private function setPath($filtermod, $levelmod = '', $rootPath = false) { if ($rootPath != false) { $rootPath = magixglobal_model_system::base_path(); } else { $rootPath = '/'; } if (!isset($filtermod)) { throw new Exception('Error filterPathImg :filtermod is not defined'); } switch ($filtermod) { case 'catalog': if ($levelmod == 'category') { $setPath = $rootPath . 'upload/catalogimg/category/'; } elseif ($levelmod == 'subcategory') { $setPath = $rootPath . 'upload/catalogimg/subcategory/'; } elseif ($levelmod == 'galery') { $setPath = $rootPath . 'upload/catalogimg/galery/'; } else { $setPath = $rootPath . 'upload/catalogimg/'; } break; case 'news': $setPath = $rootPath . 'upload/news/'; break; default: $setPath = $rootPath . $filtermod; break; } return $setPath; }
/** * Retourne le dossier racine de l'installation de magix cms pour l'écriture du fichier XML * @access private **/ private function dir_XML_FILE() { try { return magixglobal_model_system::base_path() . DIRECTORY_SEPARATOR; } catch (Exception $e) { magixglobal_model_system::magixlog('An error has occured :', $e); } }
/** * @param bool $configDir * @return string */ public static function basePathConfig($configDir = false) { if ($configDir != false) { $dir = $configDir . DIRECTORY_SEPARATOR; } else { $dir = ''; } return magixglobal_model_system::base_path() . PATHADMIN . DIRECTORY_SEPARATOR . 'i18n' . DIRECTORY_SEPARATOR . $dir; }
/** * Smarty {widget_cart_session} function plugin * * Type: function * Name: widget_cart_session * Date: 21 september 2012 * Update: 06 january 2014 * Purpose: * USAGE: {widget_cartpay_session} * Output: * @link http://www.magix-dev.be * @author Gerits Aurelien * @version 1.5 * @param array * @param Smarty * @return string */ function smarty_function_widget_cartpay_session($params, $template) { // plugins_Autoloader::register(); //chargement des function plugins $session = new frontend_model_session(); $session->_start_session('lang'); //if session key_cart if (isset($_SESSION['key_cart'])) { $token_cart = $_SESSION['key_cart']; } else { $token_cart = magixglobal_model_cryptrsa::tokenId(); } $array_sess = array('key_cart' => $token_cart); $session->session_run($array_sess); // $session->debug(); //@todo créer dans l'api une fonction public applicable dans les widgets. $modelSystem = new magixglobal_model_system(); if ($_GET['magixmod'] != 'cartpay') { frontend_model_smarty::getInstance()->configLoad($modelSystem->base_path() . 'plugins/cartpay/i18n/public_local_' . frontend_model_template::current_Language() . '.conf'); } }
/** * Parcourt le dossier des snippets HTML * @param $dir */ private function jsSnippet($dir) { $path = magixglobal_model_system::base_path() . PATHADMIN . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . $dir; $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS); $iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::LEAVES_ONLY); //extension $extensions = array("html"); // delimiteur $delimiter = "\n"; if (is_object($iterator)) { foreach ($iterator as $fileinfo) { // Compatibility with php < 5.3.6 if (version_compare(phpversion(), '5.3.6', '<')) { $getExtension = pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION); } else { $getExtension = $fileinfo->getExtension(); } if (in_array($getExtension, $extensions)) { $pos = strpos($fileinfo->getPathname(), PATHADMIN); $len = strlen($pos); if (stripos($_SERVER['HTTP_USER_AGENT'], 'win')) { $url = '/' . PATHADMIN . '/template/' . $dir . '/' . $fileinfo->getFilename(); } else { $url = DIRECTORY_SEPARATOR . substr($fileinfo->getPathname(), $pos); } $files[] = $delimiter . '{' . 'title:"' . $fileinfo->getBasename('.' . $getExtension) . '", url:"' . $url . '"}'; } } if (is_array($files)) { asort($files, SORT_REGULAR); $ouput = 'templates = ['; $ouput .= implode(',', $files); $ouput .= $delimiter . ']'; print $ouput; } } }
/** * @access private * return void */ public function directory_plugins() { return magixglobal_model_system::base_path() . self::PATHPLUGINS . DIRECTORY_SEPARATOR; }
private function setPath() { return magixglobal_model_system::base_path(); }
/** * Charge le theme selectionné ou le theme par défaut */ public function load_theme() { $db = parent::s_setting_id('theme'); if ($db['setting_value'] != null) { if ($db['setting_value'] == 'default') { $theme = $db['setting_value']; } elseif (file_exists(magixglobal_model_system::base_path() . '/skin/' . $db['setting_value'] . '/')) { $theme = $db['setting_value']; } else { try { $theme = 'default'; throw new Exception('template ' . $db['setting_value'] . ' is not found'); } catch (Exception $e) { magixglobal_model_system::magixlog('An error has occured :', $e); } } } else { $theme = 'default'; } return $theme; }
/** * Retourne au format JSON les permissions de dossier */ private function json_chmod() { $root = magixglobal_model_system::base_path(); $json[] = '{"var_caching":' . json_encode($this->chmod_var($root)) . ',"config":' . json_encode($this->chmod_config($root)) . ',"caching":' . json_encode($this->chmod_caching($root)) . '}'; print '[' . implode(',', $json) . ']'; }
/** * @access private * load sql file */ private function load_sql_file($version) { return magixglobal_model_system::base_path() . 'install' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . 'update.' . $version . '.sql'; }
/** * Charge le fichier version.xml courant * @return string */ private function load_local_file() { return magixglobal_model_system::base_path() . 'version.xml'; }
/** * @return string */ private function dirConfig() { return magixglobal_model_system::base_path() . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR; }
/** * Charge le theme selectionné ou le theme par défaut */ public function load_theme() { $db = self::$collectionsSetting->fetch('theme'); if ($db['setting_value'] != null) { if ($db['setting_value'] == 'default') { $theme = $db['setting_value']; } elseif (file_exists(magixglobal_model_system::base_path() . '/skin/' . $db['setting_value'] . '/')) { $theme = $db['setting_value']; } else { try { $theme = 'default'; throw new Exception('template ' . $db['setting_value'] . ' is not found'); } catch (Exception $e) { $logger = new debug_logger(MP_LOG_DIR); $logger->log('php', 'error', 'An error has occured : ' . $e->getMessage(), debug_logger::LOG_MONTH); } } } else { $theme = 'default'; } return $theme; }
/** * Création du fichier de configuration * @throws Exception */ private function create_config_file() { if (isset($this->M_DBHOST) && isset($this->M_DBUSER) && isset($this->M_DBPASSWORD) && isset($this->M_DBNAME)) { if (!is_writable(dirname(self::$configfile))) { throw new Exception(sprintf('Cannot write %s file.', self::$configfile)); } self::config_file_exist(); try { # Creates config.php file $full_conf = file_get_contents(self::$config_in); $writeconst = new magixcjquery_files_makefiles(); /** * create constante define in config file */ $writeconst->writeConstValue('M_DBDRIVER', $this->M_DBDRIVER, $full_conf); $writeconst->writeConstValue('M_DBHOST', $this->M_DBHOST, $full_conf); $writeconst->writeConstValue('M_DBUSER', $this->M_DBUSER, $full_conf); $writeconst->writeConstValue('M_DBPASSWORD', $this->M_DBPASSWORD, $full_conf); $writeconst->writeConstValue('M_DBNAME', $this->M_DBNAME, $full_conf); switch ($this->M_LOG) { case 'debug': $writeconst->writeConstValue('M_LOG', $this->M_LOG, $full_conf); break; case 'log': $writeconst->writeConstValue('M_LOG', $this->M_LOG, $full_conf); break; case 'false': $writeconst->writeConstValue('M_LOG', $this->M_LOG, $full_conf, false); } $writeconst->writeConstValue('M_TMP_DIR', magixglobal_model_system::base_path() . 'var' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'errors.log', $full_conf); $writeconst->writeConstValue('M_FIREPHP', $this->M_FIREPHP, $full_conf, false); $fp = fopen(self::$configfile, 'wb'); if ($fp === false) { throw new Exception(sprintf('Cannot write %s file.', self::$configfile)); } fwrite($fp, $full_conf); fclose($fp); //chmod(self::$configfile, 0666); app_model_smarty::getInstance()->display('config/request/success_add.tpl'); } catch (Exception $e) { magixcjquery_debug_magixfire::magixFireError($e); } } }
/** * Upload une image * @param files $img * @param dir $path * @param bool $debug * @return null|string */ public static function upload_img($img, $path, $debug = false) { $error = null; $firebug = new magixcjquery_debug_magixfire(); if (isset($_FILES[$img])) { if ($_FILES[$img]['error'] == UPLOAD_ERR_OK) { if (self::image_valid($_FILES[$img]['tmp_name']) === false) { $error .= 'Mauvais format d\'image (gif,png,jpeg uniquement)'; } else { if (!is_readable($_FILES[$img]["tmp_name"])) { $tmp_img = chmod($_FILES[$img]["tmp_name"], 0777); } else { $tmp_img = $_FILES[$img]["tmp_name"]; } //if(chmod($_FILES[$img]["tmp_name"],0777)){ if (is_uploaded_file($_FILES[$img]["tmp_name"])) { $source = $tmp_img; $cible = magixglobal_model_system::base_path() . $path . magixcjquery_url_clean::rplMagixString($_FILES[$img]["name"]); if (self::imgSizeMax($source, 2500, 2500) == false) { $error .= 'La taille maximum excéde'; } elseif (self::imgSizeMin($source, 5, 5) == false) { $error .= 'Le fichier est trop petit'; } else { if (!move_uploaded_file($source, $cible)) { $error .= 'Erreur de fichier temporaire'; } else { if ($debug != false) { $firebug->magixFireGroup('Upload image infos'); $firebug->magixFireLog('Success', 'Status'); $firebug->magixFireLog($source, 'Source'); $firebug->magixFireLog($cible, 'Cible'); $firebug->magixFireGroupEnd(); } } } } else { $error .= 'Erreur d\'écriture du disque'; } //} } } elseif (UPLOAD_ERR_INI_SIZE == true) { $error .= 'Le fichier est trop grand'; } elseif (UPLOAD_ERR_CANT_WRITE == true) { $error .= 'Erreur d\'écriture du disque'; } elseif (UPLOAD_ERR_FORM_SIZE == true) { $error .= 'Le fichier est trop grand: Taille maximum 2000x2000'; } } elseif (UPLOAD_ERR_NO_FILE == true) { $error .= 'Aucun fichier'; } else { $error .= 'Erreur d\'écriture du disque'; } if ($error != null) { $n = $firebug->magixFireGroup('Upload image analyse'); $n .= $firebug->magixFireLog($error); $n .= $firebug->magixFireGroupEnd(); } else { $n = NULL; } return $n; }
/** * @param $path * @param $filename * @return string */ private function pathConfigFile($path, $filename) { return magixglobal_model_system::base_path() . $path . $filename; }
/** * Retourne le chemin depuis la racine * @param $pathupload * @return string */ private function imgBasePath($pathupload) { return magixglobal_model_system::base_path() . $pathupload; }
/** * * Execute le plugin dans la partie public */ public function run() { if (magixcjquery_filter_request::isSession('key_cart')) { $session_key = $_SESSION['key_cart']; } else { $session_key = null; } if (isset($this->module)) { $this->activeMods = $this->module->load_module(false); } //Chargement des données de traduction $this->_loadConfigVars(); $create = frontend_controller_plugins::create(); $header = new magixglobal_model_header(); if (isset($this->mod) && isset($this->action)) { $cartMod = $this->activeMods[$this->mod]; $params = array('params' => $_GET['params'], 'controller' => $this->template); call_user_func(array($cartMod, $this->action), $params); } elseif (isset($this->add_cart)) { $this->add_item_cart($_POST, $session_key); } elseif (isset($this->delete_item)) { $this->delete_item_cart($this->item_to_delete, $create); } elseif (isset($this->json_cart)) { $this->template->assign('getDataConfig', $this->getConfigData()); $header->head_expires("Mon, 26 Jul 1997 05:00:00 GMT"); $header->head_last_modified(gmdate("D, d M Y H:i:s") . "GMT"); $header->pragma(); $header->cache_control("nocache"); $header->getStatus('200'); $header->html_header("UTF-8"); //$this->load_cart_ajax($this->json_cart); $cartData = $this->getItemCartData($this->json_cart); $this->template->assign('getItemCartData', $cartData); if (!empty($cartData)) { $this->template->assign('getItemPriceData', $this->getItemPriceData($this->json_cart)); $this->template->assign('setParamsData', array('remove' => 'true', 'editQuantity' => 'true')); $this->template->display('loop/cart.tpl'); } else { return false; } } elseif (isset($this->get_nbr_items)) { $this->load_cart_nbr_item($session_key); } elseif (isset($this->get_price_items)) { $this->load_cart_price_item($session_key); } elseif (isset($this->get_amount_to_pay)) { $prices = $this->load_cart_amount($this->get_amount_to_pay); $header->head_expires("Mon, 26 Jul 1997 05:00:00 GMT"); $header->head_last_modified(gmdate("D, d M Y H:i:s") . "GMT"); $header->pragma(); $header->cache_control("nocache"); $header->getStatus('200'); $header->html_header("UTF-8"); print $prices['amount_to_pay']; } elseif (isset($this->pstring1)) { $this->template->assign('getDataConfig', $this->getConfigData()); if ($this->pstring2 == 'process') { $this->getProcessOrder($create); } elseif (isset($this->pstring2)) { if ($this->pstring2 == 'success') { unset($_SESSION['key_cart']); $this->getNotify('success', false); } elseif ($this->pstring2 == 'refused') { unset($_SESSION['key_cart']); $this->getNotify('refused', false); } elseif ($this->pstring2 == 'cancel') { unset($_SESSION['key_cart']); $this->getNotify('cancel', false); } elseif ($this->pstring2 == 'exception') { unset($_SESSION['key_cart']); $this->getNotify('exception', false); } $create->display('payment_statut.tpl'); } else { if (isset($this->id_cart_to_send)) { $this->validate_cart($this->id_cart_to_send, $create); $this->load_cart_data($session_key, $create); $create->assign('getItemCartData', $this->getItemCartData($this->id_cart_to_send)); $create->assign('getItemPriceData', $this->getItemPriceData($this->id_cart_to_send)); $create->assign('setParamsData', array('remove' => 'false', 'editQuantity' => 'false')); $create->display('payment_resume.tpl'); } else { $this->load_cart_data($session_key, $create); $create->assign('getItemCartData', $this->getItemCartData($this->id_cart_to_send)); $create->assign('getItemPriceData', $this->getItemPriceData($this->id_cart_to_send)); $create->assign('setParamsData', array('remove' => 'false', 'editQuantity' => 'false')); $create->display('payment_resume.tpl'); } } } else { if (magixcjquery_filter_request::isSession('key_cart')) { if (isset($this->devis_to_send)) { //$this->validate_cart($this->id_cart_to_send,$create); $dataCart = $this->getItemPriceData($this->id_cart_to_send); parent::i_cart_order($this->id_cart_to_send, magixglobal_model_cryptrsa::uuid_generator(), $dataCart['amount_products'], $dataCart['shipping_ttc'], 'EUR', 'bank_wire'); $this->sendOrder($this->id_cart_to_send, $create, false); parent::u_transmission_cart($this->id_cart_to_send, 1); $this->getNotify('success', true); //Supprime la session du panier après envoi du mail si le système de devis est activé unset($_SESSION['key_cart']); //return; } elseif (isset($this->quantity_qty)) { $this->update_quantity_item(); } elseif (isset($this->attr)) { $this->update_attr_item(); } elseif (isset($_GET['testmail'])) { $cart = 1; if (!empty($_GET['testmail'])) { $testmail = intval($_GET['testmail']); $cart = is_int($testmail) ? $testmail : 1; } $this->sendOrder($cart, $create, true); } else { $this->modelSystem = new magixglobal_model_system(); frontend_model_template::addConfigFile(array($this->modelSystem->base_path() . 'plugins/cartpay/i18n/tools'), array('country_'), false); $data_cart = parent::s_cart_session($session_key); $id_cart = $data_cart['id_cart']; $this->load_cart_data($session_key, $create); $create->assign('getItemCartData', $this->getItemCartData($id_cart)); $create->assign('getItemPriceData', $this->getItemPriceData($id_cart)); $create->assign('setParamsData', array('remove' => 'true', 'editQuantity' => 'true')); // getDataConfig $getDataConfig = $this->getConfigData(); if ($getDataConfig['online_payment'] === '1') { $create->assign('setPaymentType', 'secure'); } else { $create->assign('setPaymentType', 'devis'); } $this->template->assign('getDataConfig', $getDataConfig); $this->template->assign('getItemsCountryData', $this->getItemsTvaData(array('fetch' => 'all', 'context' => 'country'))); $moduleJS = array(); $dynamicForm = false; if (!empty($this->activeMods)) { foreach ($this->activeMods as $name => $mod) { if (property_exists($mod, 'js_impact')) { if ($mod->js_impact) { $moduleJS[] = $name; } } if ($name == 'profil' && $getDataConfig['profil'] || $name != 'profil') { if (property_exists($mod, 'dynamicForm')) { if ($mod->dynamicForm) { $confdir = magixglobal_model_system::base_path() . 'plugins/' . $name . '/i18n/'; $lang = frontend_model_template::getLanguage(); if (file_exists($confdir)) { $translate = !empty($lang) ? $lang : 'fr'; frontend_model_smarty::getInstance()->configLoad($confdir . 'public_local_' . $translate . '.conf', null); $dynamicForm = $this->template->fetch('forms/order.tpl', $name); } } } } } } $this->template->assign('moduleJS', $moduleJS); $this->template->assign('dynamicForm', $dynamicForm); $create->display('index.tpl'); } } } }
/** * @param $dir * @return string */ private function pathCacheDir($dir) { return magixglobal_model_system::base_path() . 'var' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; }
/** * @param $app * @param $dir * @return string */ private function pathCacheDir($app, $dir) { switch ($app) { case 'public': $pathDir = magixglobal_model_system::base_path() . 'var' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; break; case 'admin': $pathDir = magixglobal_model_system::base_path() . PATHADMIN . DIRECTORY_SEPARATOR . 'caching' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; break; } return $pathDir; }
/** * @access private * Le dossier images des news */ private function dir_img_news() { return magixglobal_model_system::base_path() . '/upload/news/'; }
/** * @access private * Charge le theme selectionné ou le theme par défaut */ private function load_theme() { // Charge le théme courant dans la base de donnée $db = parent::s_current_theme(); if ($db['setting_value'] != null) { if ($db['setting_value'] == 'default') { if (file_exists(magixglobal_model_system::base_path() . '/skin/default/')) { $theme = 'default'; } } elseif (file_exists(magixglobal_model_system::base_path() . '/skin/' . $db['setting_value'] . '/')) { $theme = $db['setting_value']; } else { try { $theme = 'default'; throw new Exception('template ' . $db['setting_value'] . ' is not found'); } catch (Exception $e) { magixglobal_model_system::magixlog('An error has occured :', $e); } } } else { if (file_exists(magixglobal_model_system::base_path() . '/skin/default/')) { $theme = 'default'; } } return $theme; }