Example #1
0
 /**
  * Asign value for each input of Data form
  */
 public function getConfigFieldsValues($data = null)
 {
     $languages = Language::getLanguages(false);
     $fields_values = array();
     $obj = isset($data['params']) ? $data['params'] : array();
     foreach ($this->fields_form as $k => $f) {
         foreach ($f['form']['input'] as $j => $input) {
             if (isset($input['lang'])) {
                 foreach ($languages as $lang) {
                     $fields_values[$input['name']][$lang['id_lang']] = isset($obj[$input['name'] . '_' . $lang['id_lang']]) ? Tools::stripslashes($obj[$input['name'] . '_' . $lang['id_lang']]) : $input['default'];
                 }
             } else {
                 if (isset($obj[trim($input['name'])])) {
                     $value = $obj[trim($input['name'])];
                     if ($input['name'] == 'image' && $value) {
                         $thumb = __PS_BASE_URI__ . 'modules/' . $this->name . '/img/' . $value;
                         $this->fields_form[$k]['form']['input'][$j]['thumb'] = $thumb;
                     }
                     $fields_values[$input['name']] = Tools::stripslashes($value);
                 } else {
                     $v = Tools::getValue($input['name'], Configuration::get($input['name']));
                     $fields_values[$input['name']] = $v ? $v : $input['default'];
                 }
             }
         }
     }
     if (isset($data['id_leowidgets'])) {
         $fields_values['id_leowidgets'] = $data['id_leowidgets'];
     }
     return $fields_values;
 }
Example #2
0
 public function renderContent($args, $setting)
 {
     # validate module
     unset($args);
     $t = array('name' => '', 'html' => '');
     $setting = array_merge($t, $setting);
     $ac = array();
     $languageID = Context::getContext()->language->id;
     $text_link = $link = '';
     for ($i = 1; $i <= 10; $i++) {
         if (isset($setting['text_link_' . $i . '_' . $languageID]) && trim($setting['text_link_' . $i . '_' . $languageID])) {
             $text_link = isset($setting['text_link_' . $i . '_' . $languageID]) ? html_entity_decode($setting['text_link_' . $i . '_' . $languageID], ENT_QUOTES, 'UTF-8') : 'No Link Title';
             if (isset($setting['link_' . $i . '_' . $languageID])) {
                 $link = trim($setting['link_' . $i . '_' . $languageID]);
             } else {
                 $link = trim($setting['link_' . $i]);
             }
             $ac[] = array('text' => Tools::stripslashes($text_link), 'link' => $link);
         }
     }
     $setting['id'] = rand();
     $setting['links'] = $ac;
     //echo '<pre>';print_r($setting);die;
     $output = array('type' => 'links', 'data' => $setting);
     return $output;
 }
Example #3
0
 public function renderContent($args, $setting)
 {
     # validate module
     unset($args);
     $header = '';
     $content = '';
     $cs = array();
     $languageID = Context::getContext()->language->id;
     for ($i = 1; $i <= $setting['nbcusthtml']; $i++) {
         $title = isset($setting['title_' . $i . '_' . $languageID]) ? $setting['title_' . $i . '_' . $languageID] : '';
         $header = isset($setting['header_' . $i . '_' . $languageID]) ? $setting['header_' . $i . '_' . $languageID] : '';
         if (!empty($header) && !empty($title)) {
             $content = isset($setting['content_' . $i . '_' . $languageID]) ? Tools::stripslashes($setting['content_' . $i . '_' . $languageID]) : '';
             $cs[] = array('title' => trim($title), 'header' => trim($header), 'content' => trim($content));
         }
     }
     if ($setting['auto_play']) {
         $setting['interval'] = isset($setting['interval']) ? (int) $setting['interval'] : 4000;
     } else {
         $setting['interval'] = 'false';
     }
     $setting['startSlide'] = $setting['startSlide'] ? $setting['startSlide'] : '0';
     $setting['customercarousel'] = $cs;
     $setting['id'] = rand() + count($cs);
     $setting['random_number'] = rand(20, rand());
     $output = array('type' => 'customercarousel', 'data' => $setting);
     return $output;
 }
Example #4
0
 public static function cleanDocumentContent(&$document)
 {
     if (isset($document['original_content'])) {
         foreach ($document['original_content'] as &$text) {
             $text['original_phrase'] = Tools::stripslashes(str_replace("\\r\\n", '<br />', $text['original_phrase']));
         }
     }
 }
Example #5
0
 public function renderContent($args, $setting)
 {
     $t = array('name' => '', 'html' => '');
     $setting = array_merge($t, $setting);
     $languageID = Context::getContext()->language->id;
     $setting['html'] = isset($setting['htmlcontent_' . $languageID]) ? Tools::stripslashes($setting['htmlcontent_' . $languageID]) : '';
     $output = array('type' => 'html', 'data' => $setting);
     return $output;
 }
Example #6
0
 public function renderContent($args, $setting)
 {
     $t = array('name' => '', 'video_code' => '');
     $setting = array_merge($t, $setting);
     $html = $setting['video_code'];
     $html = html_entity_decode(Tools::stripslashes($html), ENT_QUOTES, 'UTF-8');
     $header = '';
     $content = $html;
     $output = array('type' => 'video', 'data' => $setting);
     return $output;
 }
Example #7
0
 public function renderContent($args, $setting)
 {
     $header = '';
     $content = '';
     $ac = array();
     $languageID = Context::getContext()->language->id;
     for ($i = 1; $i <= 6; $i++) {
         $header = isset($setting['header_' . $i . '_' . $languageID]) ? Tools::stripslashes($setting['header_' . $i . '_' . $languageID]) : '';
         if (!empty($header)) {
             $content = isset($setting['content_' . $i . '_' . $languageID]) ? Tools::stripslashes($setting['content_' . $i . '_' . $languageID]) : '';
             $ac[] = array('header' => $header, 'content' => trim($content));
         }
     }
     $setting['accordions'] = $ac;
     $setting['id'] = rand() + count($ac);
     $output = array('type' => 'accordion', 'data' => $setting);
     return $output;
 }
Example #8
0
 public function renderContent($args, $setting)
 {
     $content = '';
     $tabs = array();
     $languageID = Context::getContext()->language->id;
     for ($i = 1; $i <= $setting['nbtabhtml']; $i++) {
         $title = isset($setting['title_' . $i . '_' . $languageID]) ? Tools::stripslashes($setting['title_' . $i . '_' . $languageID]) : '';
         if (!empty($title)) {
             $content = isset($setting['content_' . $i . '_' . $languageID]) ? Tools::stripslashes($setting['content_' . $i . '_' . $languageID]) : '';
             $tabs[] = array('title' => trim($title), 'content' => trim($content));
         }
     }
     $setting['tabhtmls'] = $tabs;
     $setting['id'] = rand() + count($tabs);
     $output = array('type' => 'tabhtml', 'data' => $setting);
     //echo "<pre>";print_r($setting);die;
     return $output;
 }
Example #9
0
 public static function send()
 {
     $sql = 'SELECT `id_ebay_stat`, `tries`, `version`, `data`, `date_add`
         FROM ' . _DB_PREFIX_ . 'ebay_stat';
     $res = Db::getInstance()->executeS($sql);
     foreach ($res as $row) {
         $data = array('version' => $row['version'], 'data' => Tools::stripslashes($row['data']), 'date' => $row['date_add'], 'sig' => EbayStat::_computeSignature($row['version'], Tools::stripslashes($row['data']), $row['date_add']));
         $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($data)));
         $context = stream_context_create($opts);
         $ret = Tools::file_get_contents(self::$server . '/stats.php', false, $context);
         if ($ret == 'OK' || $row['tries'] > 0) {
             // if upload is OK or if it's the second try already
             $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'ebay_stat`
                 WHERE `id_ebay_stat` = ' . (int) $row['id_ebay_stat'];
         } else {
             $sql = 'UPDATE `' . _DB_PREFIX_ . 'ebay_stat`
                 SET `tries` = `tries` + 1
                 WHERE `id_ebay_stat` = ' . (int) $row['id_ebay_stat'];
         }
         Db::getInstance()->execute($sql);
     }
 }
Example #10
0
function smartsendMail($sname, $semailAddr, $scomment, $slink = null)
{
    $name = Tools::stripslashes($sname);
    $e_body = 'You have Received a New Comment In Your Blog Post From ' . $name . '. Comment: ' . $scomment . ' .Your Can reply Here : ' . $slink . '';
    $emailAddr = Tools::stripslashes($semailAddr);
    $comment = Tools::stripslashes($scomment);
    $subject = 'New Comment Posted';
    $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
    $to = Configuration::get('PS_SHOP_EMAIL');
    $contactMessage = "\n        \t\t\t\t{$comment} \n        \t\t\t\tName: {$name}\n        \t\t\t\tIP: " . (version_compare(_PS_VERSION_, '1.3.0.0', '<') ? $_SERVER['REMOTE_ADDR'] : Tools::getRemoteAddr());
    if (Mail::Send($id_lang, 'contact', $subject, array('{message}' => nl2br($e_body), '{email}' => $emailAddr), $to, null, $emailAddr, $name)) {
        return true;
    }
}
Example #11
0
 /**
  *
  */
 public function getWidgetContent($type, $data)
 {
     //			$method = 'renderWidget'.Tools::ucfirst($type).'Content';
     $args = array();
     $data = Tools::jsonDecode(call_user_func('base64' . '_decode', $data), true);
     $data['widget_heading'] = isset($data['widget_title_' . $this->langID]) ? Tools::stripslashes($data['widget_title_' . $this->langID]) : '';
     //echo $method;
     if (isset($this->engines[$type])) {
         $args = array();
         return $this->engines[$type]->renderContent($args, $data);
     }
     return false;
 }
 public function ajaxDoWidgetform()
 {
     if (Tools::getValue('wtype')) {
         $template = $this->createTemplate('widgetform.tpl');
         $data = Tools::getValue('data') ? unserialize(trim(Tools::getValue('data'))) : array();
         if (isset($data['widget'])) {
             foreach ($data['widget'] as $key => $value) {
                 $data['widget'][$key] = Tools::stripslashes($this->mcrypt->decode(str_replace(' ', '+', $value)));
             }
             $data['widget']['wkey'] = Tools::getValue('wkey');
         }
         $widget_data = isset($data['widget']) ? $data['widget'] : array();
         $form = $this->profile->renderForm(Tools::getValue('wtype'), array('params' => $widget_data));
         $template->assign(array('showed' => 1, 'wkey' => Tools::getValue('wkey'), 'form' => $form));
         return $template->fetch();
     }
 }
 protected function l($string, $class = 'AdminTab', $addslashes = false, $htmlentities = false)
 {
     if (!empty($class)) {
         $str = ErpIllicopresta::findTranslation('erpillicopresta', $string, 'AdminAdvancedOrder');
         $str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str;
         return str_replace('"', '&quot;', $addslashes ? addslashes($str) : Tools::stripslashes($str));
     }
 }
Example #14
0
 public static function ImageDelete()
 {
     $get_blog_image = SmartBlogPost::getBlogImage();
     $get_cate_image = BlogCategory::getCatImage();
     $category_types = BlogImageType::GetImageAllType('category');
     $posts_types = BlogImageType::GetImageAllType('post');
     $author_types = BlogImageType::GetImageAllType('author');
     foreach ($category_types as $image_type) {
         foreach ($get_cate_image as $cat_img) {
             $dir = _PS_MODULE_DIR_ . 'smartblog/images/category/' . $cat_img['id_smart_blog_category'] . '-' . Tools::stripslashes($image_type['type_name']) . '.jpg';
             if (file_exists($dir)) {
                 unlink($dir);
             }
         }
     }
     foreach ($posts_types as $image_type) {
         foreach ($get_blog_image as $blog_img) {
             $dir = _PS_MODULE_DIR_ . 'smartblog/images/' . $blog_img['id_smart_blog_post'] . '-' . Tools::stripslashes($image_type['type_name']) . '.jpg';
             if (file_exists($dir)) {
                 unlink($dir);
             }
         }
     }
     foreach ($author_types as $image_type) {
         $dir = _PS_MODULE_DIR_ . 'smartblog/images/avatar/avatar-' . Tools::stripslashes($image_type['type_name']) . '.jpg';
         if (file_exists($dir)) {
             unlink($dir);
         }
     }
 }
jquery/jquery-1.2.6.pack.js"></script>
		<script type="text/javascript" src="../js/admin.js"></script>
		<script type="text/javascript" src="../js/toggle.js"></script>
		<script type="text/javascript" src="../js/tools.js"></script>
		<script type="text/javascript" src="../js/ajax.js"></script>
		<link rel="shortcut icon" href="../img/favicon.ico" />
	</head>
	<body>
		<div id="container">
			<div style="float: left; margin-top: 11px;">
				<form action="index.php?tab=AdminSearch&token=<?php 
echo Tools::getAdminToken('AdminSearch' . intval(Tab::getIdFromClassName('AdminSearch')) . intval($cookie->id_employee));
?>
" method="post">
					<input type="text" name="bo_query" id="bo_query" style="width: 120px;" value="<?php 
echo isset($_POST['bo_query']) ? Tools::safeOutput(Tools::stripslashes($_POST['bo_query'])) : '';
?>
" /> <?php 
translate('in');
?>
					<select name="bo_search_type" id="bo_search_type" onchange="queryType();" style="font-size: 1em;">
						<option value="1"<?php 
echo (isset($_POST['bo_search_type']) and $_POST['bo_search_type'] == 1) ? ' selected="selected"' : '';
?>
><?php 
echo translate('catalog');
?>
</option>
						<option value="2"<?php 
echo (isset($_POST['bo_search_type']) and $_POST['bo_search_type'] == 2) ? ' selected="selected"' : '';
?>
Example #16
0
		</style>
	</head>
	<body ' . (!empty($employee->bo_color) ? 'style="background:' . Tools::htmlentitiesUTF8($employee->bo_color) . '"' : '') . '>
	<div id="top_container">
		<div id="container">
			<div id="header_infos"><span>
				<a id="header_shopname" href="index.php"><span>' . Configuration::get('PS_SHOP_NAME') . '</span></a><br />
				' . Tools::substr($employee->firstname, 0, 1) . '.&nbsp;' . htmlentities($employee->lastname, ENT_COMPAT, 'UTF-8') . '
				[ <a href="index.php?logout" id="header_logout"><span>' . translate('logout') . '</span></a> ]
				- <a href="' . __PS_BASE_URI__ . '" id="header_foaccess" target="_blank" title="' . translate('View my shop') . '"><span>' . translate('View my shop') . '</span></a>
				- <a href="index.php?tab=AdminEmployees&id_employee=' . (int) $cookie->id_employee . '&updateemployee&token=' . Tools::getAdminTokenLite('AdminEmployees') . '" style="font-size: 10px;"><img src="../img/admin/employee.gif" alt="" /> ' . translate('My preferences') . '</a>
			</span></div>
			<div id="header_search">
				<form method="post" action="index.php?tab=AdminSearch&token=' . Tools::getAdminTokenLite('AdminSearch') . '">
					<input type="text" name="bo_query" id="bo_query"
						value="' . Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))) . '"
					/>
					<select name="bo_search_type" id="bo_search_type">
						<option value="0">' . translate('everywhere') . '</option>
						<option value="1" ' . (Tools::getValue('bo_search_type') == 1 ? 'selected="selected"' : '') . '>' . translate('catalog') . '</option>
						<option value="2" ' . (Tools::getValue('bo_search_type') == 2 ? 'selected="selected"' : '') . '>' . translate('customers') . '</option>
						<option value="3" ' . (Tools::getValue('bo_search_type') == 3 ? 'selected="selected"' : '') . '>' . translate('orders') . '</option>
						<option value="4" ' . (Tools::getValue('bo_search_type') == 4 ? 'selected="selected"' : '') . '>' . translate('invoices') . '</option>
						<option value="5" ' . (Tools::getValue('bo_search_type') == 5 ? 'selected="selected"' : '') . '>' . translate('carts') . '</option>
					</select>
					<input type="submit" id="bo_search_submit" class="button" value="' . translate('Search') . '"/>
				</form>
			</div>
			<div id="header_quick">
				<script type="text/javascript">
				function quickSelect(elt)
Example #17
0
 public function getFrontTree($parent = 1, $edit = false, $params = array())
 {
     $this->parserMegaConfig($params);
     if ($edit) {
         $this->edit_string = ' data-id="%s" data-group="%s"  data-cols="%s" ';
     } else {
         $this->is_live_edit = false;
         $this->model_menu_widget = new PsMegamenuWidget();
         $this->model_menu_widget->setTheme(Context::getContext()->shop->getTheme());
         $this->model_menu_widget->lang_id = Context::getContext()->language->id;
         $this->model_menu_widget->loadWidgets();
         $this->model_menu_widget->loadEngines();
     }
     $this->edit_string_col = ' data-colwidth="%s" data-class="%s" ';
     $childs = $this->getChild(null, null, null, true);
     foreach ($childs as $child) {
         $child['megaconfig'] = $this->hasMegaMenuConfig($child);
         $child['megamenu_id'] = $child['id_psmegamenu'];
         $child['title'] = htmlentities(Tools::stripslashes($child['title']), ENT_COMPAT, 'UTF-8');
         if (isset($child['megaconfig']->group)) {
             $child['is_group'] = $child['megaconfig']->group;
         }
         if (isset($child['megaconfig']->submenu) && $child['megaconfig']->submenu == 0) {
             $child['menu_class'] = $child['menu_class'] . ' disable-menu';
         }
         $this->children[$child['id_parent']][] = $child;
     }
     $parent = 1;
     $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
     $this->image_base_url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST']) . _PSMEGAMENU_IMAGE_URL_;
     $this->shop_url = $this->image_base_url;
     $output = '';
     if ($this->hasChild($parent)) {
         $data = $this->getNodes($parent);
         $output = '<ul class="nav navbar-nav megamenu">';
         foreach ($data as $menu) {
             if (isset($menu['megaconfig']->align)) {
                 $menu['menu_class'] .= ' ' . $menu['megaconfig']->align;
             }
             if ($this->hasChild($menu['megamenu_id']) || $menu['type_submenu'] == 'html') {
                 $output .= '<li class="parent dropdown ' . $menu['menu_class'] . '" ' . $this->renderAttrs($menu) . '>
                 <a class="dropdown-toggle has-subhtml" data-toggle="dropdown" href="' . $this->getLink($menu) . '" target="' . $menu['target'] . '">';
                 if ($menu['icon_class']) {
                     $output .= '<span class="hasicon"><span class="' . $menu['icon_class'] . '"></span>';
                 } elseif ($menu['image'] && is_file(_PSMEGAMENU_IMAGE_DIR_ . $menu['image'])) {
                     $output .= '<span class="hasicon menu-icon" style="background:url(\'' . $this->image_base_url . $menu['image'] . '\') no-repeat;">';
                 }
                 $output .= '<span class="menu-title">' . $menu['title'] . '</span>';
                 if ($menu['text']) {
                     $output .= '<span class="sub-title">' . $menu['text'] . '</span>';
                 }
                 if ($menu['description']) {
                     $output .= '<span class="menu-desc">' . $menu['description'] . '</span>';
                 }
                 if ($menu['image'] && is_file(_PSMEGAMENU_IMAGE_DIR_ . $menu['image']) || $menu['icon_class']) {
                     $output .= '</span>';
                 }
                 $output .= '<b class="caret"></b></a>';
                 $output .= $this->genFrontTree($menu['megamenu_id'], 1, $menu);
                 $output .= '</li>';
             } elseif (!$this->hasChild($menu['megamenu_id']) && $menu['megaconfig'] && $menu['megaconfig']->rows) {
                 $output .= $this->genMegaMenuByConfig(1, $menu);
             } else {
                 $output .= '<li class="' . $menu['menu_class'] . '" ' . $this->renderAttrs($menu) . '>
                 <a href="' . $this->getLink($menu) . '" target="' . $menu['target'] . '">';
                 if ($menu['icon_class']) {
                     $output .= '<span class="hasicon"><span class="' . $menu['icon_class'] . '"></span>';
                 } elseif ($menu['image'] && is_file(_PSMEGAMENU_IMAGE_DIR_ . $menu['image'])) {
                     $output .= '<span class="hasicon menu-icon" style="background:url(\'' . $this->image_base_url . $menu['image'] . '\') no-repeat;">';
                 }
                 $output .= '<span class="menu-title">' . $menu['title'] . '</span>';
                 if ($menu['text']) {
                     $output .= '<span class="sub-title">' . $menu['text'] . '</span>';
                 }
                 if ($menu['description']) {
                     $output .= '<span class="menu-desc">' . $menu['description'] . '</span>';
                 }
                 if ($menu['image'] && is_file(_PSMEGAMENU_IMAGE_DIR_ . $menu['image']) || $menu['icon_class']) {
                     $output .= '</span>';
                 }
                 $output .= '</a></li>';
             }
         }
         $output .= '</ul>';
     }
     $this->menu_module = null;
     return $output;
 }
 public function ajaxProcessaddGallaryImage()
 {
     self::$currentIndex = 'index.php?tab=AdminSmartBlog&token=' . Tools::getAdminTokenLite('AdminSmartBlog');
     $smart_blog_post = new SmartBlogPost((int) Tools::getValue('id_smart_blog_post'));
     $legends = Tools::getValue('legend');
     if (!is_array($legends)) {
         $legends = (array) $legends;
     }
     if (!Validate::isLoadedObject($smart_blog_post)) {
         $files = array();
         $files[0]['error'] = Tools::displayError('Cannot add image because product creation failed.');
     }
     $image_uploader = new HelperImageUploader('file');
     $image_uploader->setAcceptTypes(array('jpeg', 'gif', 'png', 'jpg'))->setMaxSize($this->max_image_size);
     $files = $image_uploader->process();
     foreach ($files as &$file) {
         $image = new SmartBlogGallaryImage();
         $image->id_smart_blog_post = (int) $smart_blog_post->id;
         $image->position = SmartBlogGallaryImage::getHighestPosition($smart_blog_post->id) + 1;
         foreach ($legends as $key => $legend) {
             if (!empty($legend)) {
                 $image->legend[(int) $key] = $legend;
             }
         }
         if (($validate = $image->validateFieldsLang(false, true)) !== true) {
             $file['error'] = Tools::displayError($validate);
         }
         if (isset($file['error']) && (!is_numeric($file['error']) || $file['error'] != 0)) {
             continue;
         }
         if (!$image->add()) {
             $file['error'] = Tools::displayError('Error while creating additional image');
         } else {
             if (!($new_path = $image->getPathForCreation())) {
                 $file['error'] = Tools::displayError('An error occurred during new folder creation');
                 continue;
             }
             $error = 0;
             if (!ImageManager::resize($file['save_path'], $new_path . '.' . $image->image_format, null, null, 'jpg', false, $error)) {
                 switch ($error) {
                     case ImageManager::ERROR_FILE_NOT_EXIST:
                         $file['error'] = Tools::displayError('An error occurred while copying image, the file does not exist anymore.');
                         break;
                     case ImageManager::ERROR_FILE_WIDTH:
                         $file['error'] = Tools::displayError('An error occurred while copying image, the file width is 0px.');
                         break;
                     case ImageManager::ERROR_MEMORY_LIMIT:
                         $file['error'] = Tools::displayError('An error occurred while copying image, check your memory limit.');
                         break;
                     default:
                         $file['error'] = Tools::displayError('An error occurred while copying image.');
                         break;
                 }
                 continue;
             } else {
                 $imagesTypes = BlogImageType::GetImageAllType('post');
                 foreach ($imagesTypes as $imageType) {
                     if (!ImageManager::resize($file['save_path'], $new_path . '-' . Tools::stripslashes($imageType['type_name']) . '.' . $image->image_format, $imageType['width'], $imageType['height'], $image->image_format)) {
                         $file['error'] = Tools::displayError('An error occurred while copying image:') . ' ' . Tools::stripslashes($imageType['name']);
                         continue;
                     }
                 }
             }
             unlink($file['save_path']);
             //Necesary to prevent hacking
             unset($file['save_path']);
             Hook::exec('actionWatermark', array('id_smart_blog_post_mage' => $image->id, 'id_smart_blog_post' => $smart_blog_post->id));
             if (!$image->update()) {
                 $file['error'] = Tools::displayError('Error while updating status');
                 continue;
             }
             $file['status'] = 'ok';
             $file['id'] = $image->id;
             $file['position'] = $image->position;
             $file['cover'] = $image->cover;
             $file['legend'] = $image->legend;
             $file['path'] = $image->getExistingImgPath();
             $file['shops'] = array("{$this->context->shop->id}" => true);
             @unlink(_PS_TMP_IMG_DIR_ . 'smart_blog_post_' . (int) $smart_blog_post->id . '.jpg');
             @unlink(_PS_TMP_IMG_DIR_ . 'smart_blog_post__mini_' . (int) $smart_blog_post->id . '_' . $this->context->shop->id . '.jpg');
         }
     }
     die(Tools::jsonEncode(array($image_uploader->getName() => $files)));
 }
Example #19
0
 /**
  * This method is used to get the translation for email Object.
  * For an object is forbidden to use htmlentities,
  * we have to return a sentence with accents.
  *
  * @param string $string raw sentence (write directly in file)
  * @return mixed
  */
 public static function l($string, $id_lang = null, Context $context = null)
 {
     global $_LANGMAIL;
     if (!$context) {
         $context = Context::getContext();
     }
     if ($id_lang == null) {
         $id_lang = !isset($context->language) || !is_object($context->language) ? (int) Configuration::get('PS_LANG_DEFAULT') : (int) $context->language->id;
     }
     $iso_code = Language::getIsoById((int) $id_lang);
     $file_core = _PS_ROOT_DIR_ . '/mails/' . $iso_code . '/lang.php';
     if (Tools::file_exists_cache($file_core) && empty($_LANGMAIL)) {
         include $file_core;
     }
     $file_theme = _PS_THEME_DIR_ . 'mails/' . $iso_code . '/lang.php';
     if (Tools::file_exists_cache($file_theme)) {
         include $file_theme;
     }
     if (!is_array($_LANGMAIL)) {
         return str_replace('"', '&quot;', $string);
     }
     $key = str_replace('\'', '\\\'', $string);
     return str_replace('"', '&quot;', Tools::stripslashes(array_key_exists($key, $_LANGMAIL) && !empty($_LANGMAIL[$key]) ? $_LANGMAIL[$key] : $string));
 }
Example #20
0
 /**
  * Assign smarty variables for the header
  */
 public function initHeader()
 {
     // Multishop
     $is_multishop = Shop::isFeatureActive();
     // Quick access
     $quick_access = QuickAccess::getQuickAccesses($this->context->language->id);
     foreach ($quick_access as $index => $quick) {
         if ($quick['link'] == '../' && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $url = $this->context->shop->getBaseURL();
             if (!$url) {
                 unset($quick_access[$index]);
                 continue;
             }
             $quick_access[$index]['link'] = $url;
         } else {
             preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $admin_tab);
             if (isset($admin_tab[1])) {
                 if (strpos($admin_tab[1], '&')) {
                     $admin_tab[1] = substr($admin_tab[1], 0, strpos($admin_tab[1], '&'));
                 }
                 $token = Tools::getAdminToken($admin_tab[1] . (int) Tab::getIdFromClassName($admin_tab[1]) . (int) $this->context->employee->id);
                 $quick_access[$index]['link'] .= '&token=' . $token;
             }
         }
     }
     // Tab list
     $tabs = Tab::getTabs($this->context->language->id, 0);
     $current_id = Tab::getCurrentParentId();
     foreach ($tabs as $index => $tab) {
         if (!checkTabRights($tab['id_tab']) || $tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0 || $tab['class_name'] == 'AdminCarrierWizard') {
             unset($tabs[$index]);
             continue;
         }
         $img_cache_url = 'themes/' . $this->context->employee->bo_theme . '/img/t/' . $tab['class_name'] . '.png';
         $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . $img_cache_url);
         // retrocompatibility : change png to gif if icon not exists
         if (!$img_exists_cache) {
             $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . str_replace('.png', '.gif', $img_cache_url));
         }
         if ($img_exists_cache) {
             $path_img = $img = $img_exists_cache;
         } else {
             $path_img = _PS_IMG_DIR_ . 't/' . $tab['class_name'] . '.png';
             // Relative link will always work, whatever the base uri set in the admin
             $img = '../img/t/' . $tab['class_name'] . '.png';
         }
         if (trim($tab['module']) != '') {
             $path_img = _PS_MODULE_DIR_ . $tab['module'] . '/' . $tab['class_name'] . '.png';
             // Relative link will always work, whatever the base uri set in the admin
             $img = '../modules/' . $tab['module'] . '/' . $tab['class_name'] . '.png';
         }
         // retrocompatibility
         if (!file_exists($path_img)) {
             $img = str_replace('png', 'gif', $img);
         }
         // tab[class_name] does not contains the "Controller" suffix
         $tabs[$index]['current'] = $tab['class_name'] . 'Controller' == get_class($this) || $current_id == $tab['id_tab'];
         $tabs[$index]['img'] = $img;
         $tabs[$index]['href'] = $this->context->link->getAdminLink($tab['class_name']);
         $sub_tabs = Tab::getTabs($this->context->language->id, $tab['id_tab']);
         foreach ($sub_tabs as $index2 => $sub_tab) {
             // class_name is the name of the class controller
             if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool) $sub_tab['active'] && $sub_tab['class_name'] != 'AdminCarrierWizard') {
                 $sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']);
                 $sub_tabs[$index2]['current'] = $sub_tab['class_name'] . 'Controller' == get_class($this);
             } else {
                 unset($sub_tabs[$index2]);
             }
         }
         $tabs[$index]['sub_tabs'] = $sub_tabs;
     }
     if (Validate::isLoadedObject($this->context->employee)) {
         $accesses = Profile::getProfileAccesses($this->context->employee->id_profile, 'class_name');
         /* Hooks are volontary out the initialize array (need those variables already assigned) */
         $bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color;
         $this->context->smarty->assign(array('autorefresh_notifications' => Configuration::get('PS_ADMINREFRESH_NOTIFICATION'), 'help_box' => Configuration::get('PS_HELPBOX'), 'round_mode' => Configuration::get('PS_PRICE_ROUND_MODE'), 'brightness' => Tools::getBrightness($bo_color) < 128 ? 'white' : '#383838', 'bo_width' => (int) $this->context->employee->bo_width, 'bo_color' => isset($this->context->employee->bo_color) ? Tools::htmlentitiesUTF8($this->context->employee->bo_color) : null, 'show_new_orders' => Configuration::get('PS_SHOW_NEW_ORDERS') && $accesses['AdminOrders']['view'], 'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS') && $accesses['AdminCustomers']['view'], 'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES') && $accesses['AdminCustomerThreads']['view'], 'first_name' => Tools::substr($this->context->employee->firstname, 0, 1), 'last_name' => Tools::safeOutput($this->context->employee->lastname), 'employee' => $this->context->employee, 'search_type' => Tools::getValue('bo_search_type'), 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))), 'quick_access' => $quick_access, 'multi_shop' => Shop::isFeatureActive(), 'shop_list' => Helper::renderShopList(), 'shop' => $this->context->shop, 'shop_group' => new ShopGroup((int) Shop::getContextShopGroupID()), 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'is_multishop' => $is_multishop, 'multishop_context' => $this->multishop_context, 'default_tab_link' => $this->context->link->getAdminLink(Tab::getClassNameById((int) Context::getContext()->employee->default_tab)), 'employee_avatar' => ImageManager::thumbnail($this->context->employee->getImage(), 'employee' . '_' . (int) $this->context->employee->id . '.' . $this->imageType, 150, $this->imageType, true, true), 'collapse_menu' => isset($this->context->cookie->collapse_menu) ? (int) $this->context->cookie->collapse_menu : 0));
     } else {
         $this->context->smarty->assign('default_tab_link', $this->context->link->getAdminLink('AdminDashboard'));
     }
     $this->context->smarty->assign(array('img_dir' => _PS_IMG_, 'iso' => $this->context->language->iso_code, 'class_name' => $this->className, 'iso_user' => $this->context->language->iso_code, 'country_iso_code' => $this->context->country->iso_code, 'version' => _PS_VERSION_, 'lang_iso' => $this->context->language->iso_code, 'link' => $this->context->link, 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'base_url' => $this->context->shop->getBaseURL(), 'tab' => isset($tab) ? $tab : null, 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_ . '/../install'), 'pic_dir' => _THEME_PROD_PIC_DIR_, 'controller_name' => htmlentities(Tools::getValue('controller')), 'currentIndex' => self::$currentIndex, 'bootstrap' => $this->bootstrap, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT')));
 }
 public static function findTranslation($name, $string, $source)
 {
     $l_cache = array();
     static $modules;
     if (!is_array($modules)) {
         $file = _PS_MODULE_DIR_ . $name . '/translations/' . Context::getContext()->language->iso_code . '.php';
         $file_global = _PS_MODULE_DIR_ . $name . '/translations/global_' . Context::getContext()->language->iso_code . '.php';
         if (file_exists($file) && (include $file)) {
             if (!isset($_MODULE) && is_null($_MODULE)) {
                 $_MODULE = array();
             }
             $modules = !empty($modules) ? array_merge($modules, $_MODULE) : $_MODULE;
         }
         //include file global_[iso] that content global transtation as "Deletion successful"
         if (file_exists($file_global) && (include $file_global)) {
             if (!isset($_ERP_GLOBAL_MODULE) && is_null($_ERP_GLOBAL_MODULE)) {
                 $_ERP_GLOBAL_MODULE = array();
             }
             $modules = !empty($modules) ? array_merge($modules, $_ERP_GLOBAL_MODULE) : $_ERP_GLOBAL_MODULE;
         }
     }
     $cache_key = $name . '|' . $string . '|' . $source;
     if (!isset($l_cache[$cache_key])) {
         if (!is_array($modules)) {
             return $string;
         }
         $modules = array_change_key_case($modules);
         if (defined('_THEME_NAME_')) {
             $current_key = '<{' . Tools::strtolower($name) . '}' . Tools::strtolower(_THEME_NAME_) . '>' . Tools::strtolower($source) . '_' . md5($string);
         } else {
             $current_key = '<{' . Tools::strtolower($name) . '}default>' . Tools::strtolower($source) . '_' . md5($string);
         }
         $default_key = '<{' . Tools::strtolower($name) . '}prestashop>' . Tools::strtolower($source) . '_' . md5($string);
         $current_key = $default_key;
         if (isset($modules[$current_key])) {
             $ret = Tools::stripslashes($modules[$current_key]);
         } elseif (isset($modules[Tools::strtolower($current_key)])) {
             $ret = Tools::stripslashes($modules[Tools::strtolower($current_key)]);
         } elseif (isset($modules[$default_key])) {
             $ret = Tools::stripslashes($modules[$default_key]);
         } elseif (isset($modules[Tools::strtolower($default_key)])) {
             $ret = Tools::stripslashes($modules[Tools::strtolower($default_key)]);
         } else {
             $ret = Tools::stripslashes($string);
         }
         $l_cache[$cache_key] = $ret;
     }
     return $l_cache[$cache_key];
 }
Example #22
0
 public function getResult()
 {
     if ((int) Configuration::get('PAYPAL_SANDBOX') == 1) {
         $action_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate';
     } else {
         $action_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate';
     }
     $request = '';
     foreach ($_POST as $key => $value) {
         $value = urlencode(Tools::stripslashes($value));
         $request .= "&{$key}={$value}";
     }
     $handle = fopen(dirname(__FILE__) . '/log.txt', 'w+');
     fwrite($handle, $action_url . $request);
     return Tools::file_get_contents($action_url . $request);
 }
 public function ajaxProcessUpdateGallaryImagePosition()
 {
     $res = false;
     if ($json = Tools::getValue('json')) {
         $res = true;
         $json = Tools::stripslashes(pSQL($json));
         $images = Tools::jsonDecode($json, true);
         foreach ($images as $id => $position) {
             $img = new SmartBlogGallaryImage((int) $id);
             $img->position = (int) $position;
             $res &= $img->update();
         }
     }
     if ($res) {
         $this->jsonConfirmation($this->_conf[25]);
     } else {
         $this->jsonError(Tools::displayError('An error occurred while attempting to move this picture.'));
     }
 }
    public function export($id_shop = null, $header_colums)
    {
        $o_netreviews = new NetReviews();
        $duree = Tools::getValue('duree');
        $order_statut_list = array_map('intval', Tools::getValue('orderstates'));
        $order_statut_list = !empty($order_statut_list) ? implode(',', $order_statut_list) : null;
        if (!empty($id_shop)) {
            $file_name = Configuration::get('AV_CSVFILENAME', null, null, $id_shop);
            $delay = Configuration::get('AV_DELAY', null, null, $id_shop) ? Configuration::get('AV_DELAY', null, null, $id_shop) : 0;
        } else {
            $file_name = Configuration::get('AV_CSVFILENAME');
            $delay = Configuration::get('AV_DELAY') ? Configuration::get('AV_DELAY') : 0;
        }
        $avis_produit = Tools::getValue('productreviews');
        if (!empty($file_name)) {
            $file_path = _PS_MODULE_DIR_ . 'netreviews/Export_NetReviews_' . str_replace('/', '', Tools::stripslashes($file_name));
            if (file_exists($file_path)) {
                if (is_writable($file_path)) {
                    unlink($file_path);
                } else {
                    throw new Exception($o_netreviews->l('Writing on our server is not allowed. Please assign write permissions to the folder netreviews'));
                }
            } else {
                foreach (glob(_PS_MODULE_DIR_ . 'netreviews/Export_NetReviews_*') as $filename_to_delete) {
                    if (is_writable($filename_to_delete)) {
                        unlink($filename_to_delete);
                    }
                }
            }
        }
        $file_name = date('d-m-Y') . '-' . Tools::substr(md5(rand(0, 10000)), 1, 10) . '.csv';
        $file_path = _PS_MODULE_DIR_ . 'netreviews/Export_NetReviews_' . $file_name;
        $duree_sql = '';
        switch ($duree) {
            case '1w':
                $duree_sql = 'INTERVAL 1 WEEK';
                break;
            case '2w':
                $duree_sql = 'INTERVAL 2 WEEK';
                break;
            case '1m':
                $duree_sql = 'INTERVAL 1 MONTH';
                break;
            case '2m':
                $duree_sql = 'INTERVAL 2 MONTH';
                break;
            case '3m':
                $duree_sql = 'INTERVAL 3 MONTH';
                break;
            case '4m':
                $duree_sql = 'INTERVAL 4 MONTH';
                break;
            case '5m':
                $duree_sql = 'INTERVAL 5 MONTH';
                break;
            case '6m':
                $duree_sql = 'INTERVAL 6 MONTH';
                break;
            case '7m':
                $duree_sql = 'INTERVAL 7 MONTH';
                break;
            case '8m':
                $duree_sql = 'INTERVAL 8 MONTH';
                break;
            case '9m':
                $duree_sql = 'INTERVAL 9 MONTH';
                break;
            case '10m':
                $duree_sql = 'INTERVAL 10 MONTH';
                break;
            case '11m':
                $duree_sql = 'INTERVAL 11 MONTH';
                break;
            case '12m':
                $duree_sql = 'INTERVAL 12 MONTH';
                break;
            default:
                $duree_sql = 'INTERVAL 1 WEEK';
                break;
        }
        $all_orders = array();
        // Get orders with choosen date interval
        $where_id_shop = !empty($id_shop) ? 'AND o.id_shop = ' . (int) $id_shop : '';
        $select_id_shop = !empty($id_shop) ? ', o.id_shop' : '';
        $where_id_state = !empty($order_statut_list) ? ' AND o.current_state IN (' . $order_statut_list . ')' : '';
        $select_id_state = !empty($order_statut_list) ? ', o.current_state' : '';
        $qry_sql = '	SELECT lg.iso_code, o.id_order, o.total_paid, o.id_customer, o.date_add, c.firstname, c.lastname, c.email ' . $select_id_shop . $select_id_state . '
						FROM ' . _DB_PREFIX_ . 'orders o
						LEFT JOIN ' . _DB_PREFIX_ . 'customer c ON o.id_customer = c.id_customer
						LEFT JOIN ' . _DB_PREFIX_ . 'lang lg ON o.id_lang = lg.id_lang
						WHERE (TO_DAYS(DATE_ADD(o.date_add,' . $duree_sql . ')) - TO_DAYS(NOW())) >= 0
						' . $where_id_shop . $where_id_state;
        $item_list = Db::getInstance()->ExecuteS($qry_sql);
        foreach ($item_list as $item) {
            $all_orders[$item['id_order']] = array('ID_ORDER' => $item['id_order'], 'MONTANT_COMMANDE' => $item['total_paid'], 'DATE_ORDER' => date('d/m/Y', strtotime($item['date_add'])), 'ID_CUSTOMER' => array('ID_CUSTOMER' => $item['id_customer'], 'FIRST_NAME' => $item['firstname'], 'LAST_NAME' => $item['lastname'], 'EMAIL' => $item['email']), 'EMAIL_CLIENT' => '', 'NOM_CLIENT' => '', 'ORDER_STATE' => $item['current_state'], 'ISO_LANG' => $item['iso_code'], 'PRODUCTS' => array());
            $qry_sql = 'SELECT id_order, product_id, product_name FROM ' . _DB_PREFIX_ . 'order_detail WHERE id_order = ' . (int) $item['id_order'];
            $product_list = Db::getInstance()->ExecuteS($qry_sql);
            foreach ($product_list as $product) {
                $array_url = NetReviewsModel::getUrlsProduct($product['product_id']);
                $all_orders[$product['id_order']]['PRODUCTS'][] = array('ID_PRODUCT' => $product['product_id'], 'NOM_PRODUCT' => $product['product_name'], 'URL_PRODUCT' => $array_url['url_product'], 'URL_IMAGE_PRODUCT' => $array_url['url_image_product']);
            }
        }
        if (count($all_orders) > 0) {
            if ($csv = @fopen($file_path, 'w')) {
                fwrite($csv, $header_colums);
                foreach ($all_orders as $order) {
                    $count_products = count($order['PRODUCTS']);
                    if ($avis_produit == 1 && $count_products > 0) {
                        for ($i = 0; $i < $count_products; $i++) {
                            $line = '';
                            //reset the line
                            $line[] = $order['ID_ORDER'];
                            $line[] = $order['MONTANT_COMMANDE'];
                            $line[] = $order['ID_CUSTOMER']['EMAIL'];
                            $line[] = utf8_decode($order['ID_CUSTOMER']['LAST_NAME']);
                            $line[] = utf8_decode($order['ID_CUSTOMER']['FIRST_NAME']);
                            $line[] = $order['DATE_ORDER'];
                            $line[] = $delay;
                            $line[] = $order['PRODUCTS'][$i]['ID_PRODUCT'];
                            $line[] = '';
                            // Categorie du produit
                            $line[] = utf8_decode($order['PRODUCTS'][$i]['NOM_PRODUCT']);
                            $line[] = utf8_decode($order['PRODUCTS'][$i]['URL_PRODUCT']);
                            //Url fiche product
                            $line[] = utf8_decode($order['PRODUCTS'][$i]['URL_IMAGE_PRODUCT']);
                            //Url image fiche product
                            $line[] = $order['ORDER_STATE'];
                            //Etat de la commande
                            $line[] = $order['ISO_LANG'];
                            //Order lang
                            if (!empty($id_shop)) {
                                $line[] = $id_shop;
                            }
                            fwrite($csv, self::generateCsvLine($line));
                        }
                    } else {
                        $line = '';
                        //reset the line
                        $line[] = $order['ID_ORDER'];
                        $line[] = $order['ID_CUSTOMER']['EMAIL'];
                        $line[] = utf8_decode($order['ID_CUSTOMER']['LAST_NAME']);
                        $line[] = utf8_decode($order['ID_CUSTOMER']['FIRST_NAME']);
                        $line[] = $order['DATE_ORDER'];
                        $line[] = $delay;
                        $line[] = '';
                        $line[] = '';
                        // Product category
                        $line[] = '';
                        $line[] = '';
                        // URL
                        $line[] = '';
                        //Url image fiche product
                        $line[] = $order['ORDER_STATE'];
                        //Order state
                        $line[] = $order['ISO_LANG'];
                        //Order lang
                        if (!empty($id_shop)) {
                            $line[] = $id_shop;
                        }
                        fwrite($csv, self::generateCsvLine($line));
                    }
                }
                fclose($csv);
                if (file_exists($file_path)) {
                    Configuration::updateValue('AV_CSVFILENAME', $file_name);
                    return array($file_name, count($all_orders), $file_path);
                } else {
                    throw new Exception($o_netreviews->l('Unable to read/write export file'));
                }
            } else {
                throw new Exception($o_netreviews->l('Unable to read/write export file'));
            }
        } else {
            throw new Exception($o_netreviews->l('No order to export'));
        }
    }
    public function getContent()
    {
        $html = '';
        if (Tools::isSubmit('submitModule')) {
            Configuration::updateValue('AUTHORIZE_AIM_LOGIN_ID', Tools::getvalue('authorizeaim_login_id'));
            Configuration::updateValue('AUTHORIZE_AIM_KEY', Tools::getvalue('authorizeaim_key'));
            Configuration::updateValue('AUTHORIZE_AIM_DEMO', Tools::getvalue('authorizeaim_demo_mode'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_VISA', Tools::getvalue('authorizeaim_card_visa'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_MASTERCARD', Tools::getvalue('authorizeaim_card_mastercard'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_DISCOVER', Tools::getvalue('authorizeaim_card_discover'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_AX', Tools::getvalue('authorizeaim_card_ax'));
            Configuration::updateValue('AUTHORIZE_AIM_HOLD_REVIEW_OS', Tools::getvalue('authorizeaim_hold_review_os'));
            $html .= $this->displayConfirmation($this->l('Configuration updated'));
        }
        // For Hold for Review
        $orderStates = OrderState::getOrderStates((int) $this->context->cookie->id_lang);
        $html .= '<h2>' . $this->displayName . '</h2>
		<fieldset><legend><img src="../modules/' . $this->name . '/logo.gif" alt="" /> ' . $this->l('Help') . '</legend>
			<a href="http://api.prestashop.com/partner/authorize.net/" target="_blank" style="float: right;"><img src="../modules/' . $this->name . '/logo_authorize.png" alt="" /></a>
			<h3>' . $this->l('In your PrestaShop admin panel') . '</h3>
			- ' . $this->l('Fill the  Login ID  provided by Authorize.net') . '<br />
			- ' . $this->l('Fill the key field with the transaction key provided by Authorize.net') . '<br />
			<span style="color: red;" >- ' . $this->l('Warning: Your website must possess a SSL certificate to use the Authorize.net AIM payment system. You are responsible for the safety of your customers\' bank information. PrestaShop cannot be blamed for any security issue on your website.') . '</span><br />
			<br />
		</fieldset><br />
		<form action="' . Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']) . '" method="post">
			<fieldset class="width2">
				<legend><img src="../img/admin/contact.gif" alt="" />' . $this->l('Settings') . '</legend>
				<label for="authorizeaim_login_id">' . $this->l('Login ID') . '</label>
				<div class="margin-form"><input type="text" size="20" id="authorizeaim_login_id" name="authorizeaim_login_id" value="' . Configuration::get('AUTHORIZE_AIM_LOGIN_ID') . '" /></div>
				<label for="authorizeaim_key">' . $this->l('Key') . '</label>
				<div class="margin-form"><input type="text" size="20" id="authorizeaim_login_id" name="authorizeaim_key" value="' . Configuration::get('AUTHORIZE_AIM_KEY') . '" /></div>
				<label for="authorizeaim_demo_mode">' . $this->l('Mode:') . '</label>
				<div class="margin-form" id="authorizeaim_demo">
					<input type="radio" name="authorizeaim_demo_mode" value="0" style="vertical-align: middle;" ' . (!Tools::getValue('authorizeaim_demo_mode', Configuration::get('AUTHORIZE_AIM_DEMO')) ? 'checked="checked"' : '') . ' />
					<span style="color: #080;">' . $this->l('Production') . '</span>
					<input type="radio" name="authorizeaim_demo_mode" value="1" style="vertical-align: middle;" ' . (Tools::getValue('authorizeaim_demo_mode', Configuration::get('AUTHORIZE_AIM_DEMO')) ? 'checked="checked"' : '') . ' />
					<span style="color: #900;">' . $this->l('Test') . '</span>
				</div>
				<label for="authorizeaim_cards">' . $this->l('Cards:') . '</label>
				<div class="margin-form" id="authorizeaim_cards">
					<input type="checkbox" name="authorizeaim_card_visa" ' . (Configuration::get('AUTHORIZE_AIM_CARD_VISA') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/visa.gif" alt="visa" />
					<input type="checkbox" name="authorizeaim_card_mastercard" ' . (Configuration::get('AUTHORIZE_AIM_CARD_MASTERCARD') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/mastercard.gif" alt="visa" />
					<input type="checkbox" name="authorizeaim_card_discover" ' . (Configuration::get('AUTHORIZE_AIM_CARD_DISCOVER') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/discover.gif" alt="visa" />
					<input type="checkbox" name="authorizeaim_card_ax" ' . (Configuration::get('AUTHORIZE_AIM_CARD_AX') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/ax.gif" alt="visa" />
				</div>

				<label for="authorizeaim_hold_review_os">' . $this->l('Order status:  "Hold for Review" ') . '</label>
				<div class="margin-form">
								<select id="authorizeaim_hold_review_os" name="authorizeaim_hold_review_os">';
        // Hold for Review order state selection
        foreach ($orderStates as $os) {
            $html .= '
				<option value="' . (int) $os['id_order_state'] . '"' . ((int) $os['id_order_state'] == (int) Configuration::get('AUTHORIZE_AIM_HOLD_REVIEW_OS') ? ' selected' : '') . '>' . Tools::stripslashes($os['name']) . '</option>' . "\n";
        }
        return $html . '</select></div>
				<br /><center><input type="submit" name="submitModule" value="' . $this->l('Update settings') . '" class="button" /></center>
			</fieldset>
		</form>';
    }
 public function validation()
 {
     # LOG
     $message = '######################################' . "\r\n";
     $message .= '# Date Début Validation - ' . date("d/m/Y H:i:s") . "\r\n";
     $message .= '#### Module actif - ' . ($this->active ? 'TRUE' : 'FALSE') . "\r\n";
     $message .= '#### Variable POST :' . "\r\n";
     $message .= print_r($_POST, true);
     $message .= "\r\n";
     # ---
     $this->HipayLog($message);
     if (!$this->active) {
         return;
     }
     if (!array_key_exists('xml', $_POST)) {
         return;
     }
     if (_PS_MAGIC_QUOTES_GPC_) {
         $_POST['xml'] = Tools::stripslashes(Tools::getValue('xml'));
     }
     require_once dirname(__FILE__) . '/mapi/mapi_package.php';
     # LOG
     $this->HipayLog('#### Début HIPAY_MAPI_COMM_XML::analyzeNotificationXML' . "\r\n");
     # ---
     if (HIPAY_MAPI_COMM_XML::analyzeNotificationXML(Tools::getValue('xml'), $operation, $status, $date, $time, $transid, $amount, $currency, $id_cart, $data) === false) {
         file_put_contents('logs' . Configuration::get('HIPAY_UNIQID') . '.txt', '[' . date('Y-m-d H:i:s') . '] Analysis error: ' . htmlentities(Tools::getValue('xml')) . "\n", FILE_APPEND);
         return false;
     }
     # LOG
     $message = '#### Fin HIPAY_MAPI_COMM_XML::analyzeNotificationXML' . "\r\n";
     $message .= '#### Version Prestashop : ' . _PS_VERSION_;
     # ---
     $this->HipayLog($message);
     if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
         # LOG
         $this->HipayLog('#### ID Panier : ' . (int) $id_cart . "\r\n");
         # ---
         Context::getContext()->cart = new Cart((int) $id_cart);
     }
     $cart = new Cart((int) $id_cart);
     # LOG
     $message = '#### TOKEN : ' . Tools::getValue('token') . "\r\n";
     $message .= '#### SECURE KEY : ' . $cart->secure_key . "\r\n";
     $message .= '#### HIPAY SALT : ' . Configuration::get('HIPAY_SALT') . "\r\n";
     $message .= '#### CLE ENCRYPTE : ' . Tools::encrypt($cart->id . $cart->secure_key . Configuration::get('HIPAY_SALT')) . "\r\n";
     # ---
     $this->HipayLog($message);
     if (Tools::encrypt($cart->id . $cart->secure_key . Configuration::get('HIPAY_SALT')) != Tools::getValue('token')) {
         # LOG
         $this->HipayLog('#### TOKEN = CLE : NOK' . "\r\n");
         # ---
         file_put_contents('logs' . Configuration::get('HIPAY_UNIQID') . '.txt', '[' . date('Y-m-d H:i:s') . '] Token error: ' . htmlentities(Tools::getValue('xml')) . "\n", FILE_APPEND);
     } else {
         # LOG
         $message = '#### Opération : ' . trim($operation) . "\r\n";
         $message .= '#### Status : ' . trim(Tools::strtolower($status)) . "\r\n";
         # ---
         $this->HipayLog($message);
         if (trim($operation) == 'authorization' && trim(Tools::strtolower($status)) == 'waiting') {
             // Authorization WAITING
             $orderMessage = $operation . ": " . $status . "\ndate: " . $date . " " . $time . "\ntransaction: " . $transid . "\namount: " . (double) $amount . " " . $currency . "\nid_cart: " . (int) $id_cart;
             //$this->_createAuthorizationOrderState();
             $this->validateOrder((int) $id_cart, Configuration::get('HIPAY_WAITINGPAYMENT_OS'), (double) $amount, $this->displayName, $orderMessage, array(), NULL, false, $cart->secure_key);
             # LOG
             $this->HipayLog('######## AW - création Commande / status : ' . (int) Configuration::get('HIPAY_WAITINGPAYMENT_OS') . "\r\n");
             # ---
         } else {
             if (trim($operation) == 'authorization' && trim(Tools::strtolower($status)) == 'ok') {
                 // vérification si commande existante
                 $id_order = Order::getOrderByCartId((int) $id_cart);
                 # LOG
                 $this->HipayLog('######## AOK - ID Commande : ' . ($id_order ? $id_order : 'Pas de commande') . "\r\n");
                 # ---
                 if ($id_order !== false) {
                     // change statut si commande en attente de paiement
                     $order = new Order((int) $id_order);
                     if ((int) $order->getCurrentState() == (int) Configuration::get('HIPAY_WAITINGPAYMENT_OS')) {
                         // on affecte à la commande au statut paiement autorisé par HiPay
                         $statut_id = Configuration::get('HIPAY_AUTHORIZATION_OS');
                         $order_history = new OrderHistory();
                         $order_history->id_order = $id_order;
                         $order_history->changeIdOrderState($statut_id, $id_order);
                         $order_history->addWithemail();
                         # LOG
                         $this->HipayLog('######## AOK - Historique Commande / Change status : ' . (int) Configuration::get('HIPAY_AUTHORIZATION_OS') . "\r\n");
                         # ---
                     }
                 } else {
                     // on revérifie si la commande n'existe pas au cas où la capture soit arrivée avant
                     // sinon on ne fait rien
                     $id_order = Order::getOrderByCartId((int) $id_cart);
                     if ($id_order === false) {
                         // Authorization OK
                         $orderMessage = $operation . ": " . $status . "\ndate: " . $date . " " . $time . "\ntransaction: " . $transid . "\namount: " . (double) $amount . " " . $currency . "\nid_cart: " . (int) $id_cart;
                         //$this->_createAuthorizationOrderState();
                         $this->validateOrder((int) $id_cart, Configuration::get('HIPAY_AUTHORIZATION_OS'), (double) $amount, $this->displayName, $orderMessage, array(), NULL, false, $cart->secure_key);
                         # LOG
                         $this->HipayLog('######## AOK - création Commande / status : ' . (int) Configuration::get('HIPAY_AUTHORIZATION_OS') . "\r\n");
                         # ---
                     }
                 }
             } else {
                 if (trim($operation) == 'capture' && trim(Tools::strtolower($status)) == 'ok') {
                     // Capture OK
                     $orderMessage = $operation . ": " . $status . "\ndate: " . $date . " " . $time . "\ntransaction: " . $transid . "\namount: " . (double) $amount . " " . $currency . "\nid_cart: " . (int) $id_cart;
                     $id_order = Order::getOrderByCartId((int) $id_cart);
                     # LOG
                     $this->HipayLog('######## C*K - ID Commande : ' . ($id_order ? $id_order : 'Pas de commande') . "\r\n");
                     # ---
                     if ($id_order !== false) {
                         # LOG
                         $this->HipayLog('######## C*K - id_order existant' . "\r\n");
                         # ---
                         $order = new Order((int) $id_order);
                         # LOG
                         $this->HipayLog('######## C*K - objet order loadé' . "\r\n");
                         # ---
                         // si la commande est au statut Autorisation ok ou en attente de paiement
                         // on change le statut en paiement accepté
                         if ((int) $order->getCurrentState() == (int) Configuration::get('HIPAY_AUTHORIZATION_OS') || (int) $order->getCurrentState() == (int) Configuration::get('HIPAY_WAITINGPAYMENT_OS')) {
                             $statut_id = Configuration::get('PS_OS_PAYMENT');
                             $order_history = new OrderHistory();
                             $order_history->id_order = $id_order;
                             $order_history->changeIdOrderState($statut_id, $id_order);
                             $order_history->addWithemail();
                             # LOG
                             $this->HipayLog('######## C*K - Historique Commande / Change status : ' . (int) Configuration::get('PS_OS_PAYMENT') . "\r\n");
                             # ---
                         }
                     } else {
                         $this->validateOrder((int) $id_cart, Configuration::get('PS_OS_PAYMENT'), (double) $amount, $this->displayName, $orderMessage, array(), NULL, false, $cart->secure_key);
                         # LOG
                         $this->HipayLog('######## C*K - création Commande / status : ' . (int) Configuration::get('PS_OS_PAYMENT') . "\r\n");
                         # ---
                     }
                     // Commande que prestashop lance mais n'a aucune incidence dans le module...
                     // Ajouté en commentaire
                     // Configuration::updateValue('HIPAY_CONFIGURATION_OK', true);
                 } else {
                     if (trim($operation) == 'capture' && trim(Tools::strtolower($status)) == 'nok') {
                         // Capture NOK
                         $id_order = Order::getOrderByCartId((int) $id_cart);
                         # LOG
                         $this->HipayLog('######## CNOK - ID Commande : ' . ($id_order ? $id_order : 'Pas de commande') . "\r\n");
                         # ---
                         if ($id_order !== false) {
                             $order = new Order((int) $id_order);
                             if ((int) $order->getCurrentState() == (int) Configuration::get('HIPAY_AUTHORIZATION_OS')) {
                                 $statut_id = Configuration::get('PS_OS_ERROR');
                                 $order_history = new OrderHistory();
                                 $order_history->id_order = $id_order;
                                 $order_history->changeIdOrderState($statut_id, $id_order);
                                 $order_history->addWithemail();
                                 # LOG
                                 $this->HipayLog('######## CNOK - Historique Commande / Change status : ' . (int) Configuration::get('PS_OS_ERROR') . "\r\n");
                                 # ---
                             }
                         }
                     } elseif (trim($operation) == 'refund' and trim(Tools::strtolower($status)) == 'ok') {
                         /* Paiement remboursé sur Hipay */
                         if (!($id_order = Order::getOrderByCartId((int) $id_cart))) {
                             die(Tools::displayError());
                         }
                         $order = new Order((int) $id_order);
                         if (!$order->valid or $order->getCurrentState() === Configuration::get('PS_OS_REFUND')) {
                             die(Tools::displayError());
                         }
                         $statut_id = Configuration::get('PS_OS_REFUND');
                         $order_history = new OrderHistory();
                         $order_history->id_order = $id_order;
                         $order_history->changeIdOrderState($statut_id, $id_order);
                         $order_history->addWithemail();
                         # LOG
                         $this->HipayLog('######## ROK - Historique Commande / Change status : ' . (int) Configuration::get('PS_OS_REFUND') . "\r\n");
                         # ---
                     }
                 }
             }
         }
     }
     #
     # Patch LOG Pour les erreurs 500
     #
     $message = '# Date Fin Validation - ' . date("d/m/Y H:i:s") . "\r\n";
     $message .= '######################################' . "\r\n";
     $this->HipayLog($message);
     # ---------------------------------------------------------
     return true;
 }
Example #27
0
 /**
  * Assign smarty variables for the header
  */
 public function initHeader()
 {
     header('Cache-Control: no-store, no-cache');
     // Multishop
     $is_multishop = Shop::isFeatureActive();
     // Quick access
     $quick_access = QuickAccess::getQuickAccesses($this->context->language->id);
     foreach ($quick_access as $index => $quick) {
         if ($quick['link'] == '../' && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $url = $this->context->shop->getBaseURL();
             if (!$url) {
                 unset($quick_access[$index]);
                 continue;
             }
             $quick_access[$index]['link'] = $url;
         } else {
             preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $admin_tab);
             if (isset($admin_tab[1])) {
                 if (strpos($admin_tab[1], '&')) {
                     $admin_tab[1] = substr($admin_tab[1], 0, strpos($admin_tab[1], '&'));
                 }
                 $token = Tools::getAdminToken($admin_tab[1] . (int) Tab::getIdFromClassName($admin_tab[1]) . (int) $this->context->employee->id);
                 $quick_access[$index]['target'] = $admin_tab[1];
                 $quick_access[$index]['link'] .= '&token=' . $token;
             }
         }
     }
     //$link = preg_replace('/&token=[a-z0-9]{32}/', '', basename($_SERVER['REQUEST_URI']));
     //$currentPage = 'index.php?controller='.$this->context->controller->controller_name."&".$this->display.$this->table;
     // Tab list
     $tabs = Tab::getTabs($this->context->language->id, 0);
     $current_id = Tab::getCurrentParentId();
     foreach ($tabs as $index => $tab) {
         if (!Tab::checkTabRights($tab['id_tab']) || $tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0 || $tab['class_name'] == 'AdminCarrierWizard') {
             unset($tabs[$index]);
             continue;
         }
         $img_cache_url = 'themes/' . $this->context->employee->bo_theme . '/img/t/' . $tab['class_name'] . '.png';
         $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . $img_cache_url);
         // retrocompatibility : change png to gif if icon not exists
         if (!$img_exists_cache) {
             $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . str_replace('.png', '.gif', $img_cache_url));
         }
         if ($img_exists_cache) {
             $path_img = $img = $img_exists_cache;
         } else {
             $path_img = _PS_IMG_DIR_ . 't/' . $tab['class_name'] . '.png';
             // Relative link will always work, whatever the base uri set in the admin
             $img = '../img/t/' . $tab['class_name'] . '.png';
         }
         if (trim($tab['module']) != '') {
             $path_img = _PS_MODULE_DIR_ . $tab['module'] . '/' . $tab['class_name'] . '.png';
             // Relative link will always work, whatever the base uri set in the admin
             $img = '../modules/' . $tab['module'] . '/' . $tab['class_name'] . '.png';
         }
         // retrocompatibility
         if (!file_exists($path_img)) {
             $img = str_replace('png', 'gif', $img);
         }
         // tab[class_name] does not contains the "Controller" suffix
         $tabs[$index]['current'] = $tab['class_name'] . 'Controller' == get_class($this) || $current_id == $tab['id_tab'];
         $tabs[$index]['img'] = $img;
         $tabs[$index]['href'] = $this->context->link->getAdminLink($tab['class_name']);
         $sub_tabs = Tab::getTabs($this->context->language->id, $tab['id_tab']);
         foreach ($sub_tabs as $index2 => $sub_tab) {
             //check if module is enable and
             if (isset($sub_tab['module']) && !empty($sub_tab['module'])) {
                 $module = Module::getInstanceByName($sub_tab['module']);
                 if (is_object($module) && !$module->isEnabledForShopContext()) {
                     unset($sub_tabs[$index2]);
                     continue;
                 }
             }
             if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool) $sub_tab['active'] && $sub_tab['class_name'] != 'AdminCarrierWizard') {
                 $sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']);
                 $sub_tabs[$index2]['current'] = $sub_tab['class_name'] . 'Controller' == get_class($this) || $sub_tab['class_name'] == Tools::getValue('controller');
             } elseif ($sub_tab['class_name'] == 'AdminCarrierWizard' && $sub_tab['class_name'] . 'Controller' == get_class($this)) {
                 foreach ($sub_tabs as $i => $tab) {
                     if ($tab['class_name'] == 'AdminCarriers') {
                         break;
                     }
                 }
                 $sub_tabs[$i]['current'] = true;
                 unset($sub_tabs[$index2]);
             } else {
                 unset($sub_tabs[$index2]);
             }
         }
         $tabs[$index]['sub_tabs'] = $sub_tabs;
     }
     if (Validate::isLoadedObject($this->context->employee)) {
         $accesses = Profile::getProfileAccesses($this->context->employee->id_profile, 'class_name');
         /* Hooks are volontary out the initialize array (need those variables already assigned) */
         $bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color;
         $this->context->smarty->assign(array('autorefresh_notifications' => Configuration::get('PS_ADMINREFRESH_NOTIFICATION'), 'help_box' => Configuration::get('PS_HELPBOX'), 'round_mode' => Configuration::get('PS_PRICE_ROUND_MODE'), 'brightness' => Tools::getBrightness($bo_color) < 128 ? 'white' : '#383838', 'bo_width' => (int) $this->context->employee->bo_width, 'bo_color' => isset($this->context->employee->bo_color) ? Tools::htmlentitiesUTF8($this->context->employee->bo_color) : null, 'show_new_orders' => Configuration::get('PS_SHOW_NEW_ORDERS') && isset($accesses['AdminOrders']) && $accesses['AdminOrders']['view'], 'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS') && isset($accesses['AdminCustomers']) && $accesses['AdminCustomers']['view'], 'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES') && isset($accesses['AdminCustomerThreads']) && $accesses['AdminCustomerThreads']['view'], 'employee' => $this->context->employee, 'search_type' => Tools::getValue('bo_search_type'), 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))), 'quick_access' => $quick_access, 'multi_shop' => Shop::isFeatureActive(), 'shop_list' => Helper::renderShopList(), 'shop' => $this->context->shop, 'shop_group' => new ShopGroup((int) Shop::getContextShopGroupID()), 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'is_multishop' => $is_multishop, 'multishop_context' => $this->multishop_context, 'default_tab_link' => $this->context->link->getAdminLink(Tab::getClassNameById((int) Context::getContext()->employee->default_tab)), 'collapse_menu' => isset($this->context->cookie->collapse_menu) ? (int) $this->context->cookie->collapse_menu : 0));
     } else {
         $this->context->smarty->assign('default_tab_link', $this->context->link->getAdminLink('AdminDashboard'));
     }
     // Shop::initialize() in config.php may empty $this->context->shop->virtual_uri so using a new shop instance for getBaseUrl()
     $this->context->shop = new Shop((int) $this->context->shop->id);
     $this->context->smarty->assign(array('img_dir' => _PS_IMG_, 'iso' => $this->context->language->iso_code, 'class_name' => $this->className, 'iso_user' => $this->context->language->iso_code, 'country_iso_code' => $this->context->country->iso_code, 'version' => _PS_VERSION_, 'lang_iso' => $this->context->language->iso_code, 'full_language_code' => $this->context->language->language_code, 'link' => $this->context->link, 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'base_url' => $this->context->shop->getBaseURL(), 'tab' => isset($tab) ? $tab : null, 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_ . '/../install'), 'pic_dir' => _THEME_PROD_PIC_DIR_, 'controller_name' => htmlentities(Tools::getValue('controller')), 'currentIndex' => self::$currentIndex, 'bootstrap' => $this->bootstrap, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT'), 'display_addons_connection' => Tab::checkTabRights(Tab::getIdFromClassName('AdminModulesController'))));
     $module = Module::getInstanceByName('themeconfigurator');
     $lang = '';
     if (Configuration::get('PS_REWRITING_SETTINGS') && count(Language::getLanguages(true)) > 1) {
         $lang = Language::getIsoById($this->context->employee->id_lang) . '/';
     }
     if (is_object($module) && $module->active && (int) Configuration::get('PS_TC_ACTIVE') == 1 && $this->context->shop->getBaseURL()) {
         $this->context->smarty->assign('base_url_tc', $this->context->shop->getBaseUrl() . (Configuration::get('PS_REWRITING_SETTINGS') ? '' : 'index.php') . $lang . '?live_configurator_token=' . $module->getLiveConfiguratorToken() . '&id_employee=' . (int) $this->context->employee->id . '&id_shop=' . (int) $this->context->shop->id . (Configuration::get('PS_TC_THEME') != '' ? '&theme=' . Configuration::get('PS_TC_THEME') : '') . (Configuration::get('PS_TC_FONT') != '' ? '&theme_font=' . Configuration::get('PS_TC_FONT') : ''));
     }
 }
Example #28
0
jquery/jquery-1.2.6.pack.js"></script>
		<script type="text/javascript" src="../js/admin.js"></script>
		<script type="text/javascript" src="../js/toggle.js"></script>
		<script type="text/javascript" src="../js/tools.js"></script>
		<script type="text/javascript" src="../js/ajax.js"></script>
		<link rel="shortcut icon" href="../img/favicon.ico" />
	</head>
	<body>
		<div id="container">
			<div style="float: left; margin-top: 11px;">
				<form action="index.php?tab=AdminSearch&token=<?php 
echo Tools::getAdminToken('AdminSearch' . intval(Tab::getIdFromClassName('AdminSearch')) . intval($cookie->id_employee));
?>
" method="post">
					<input type="text" name="bo_query" id="bo_query" style="width: 120px;" value="<?php 
echo isset($_POST['bo_query']) ? Tools::stripslashes($_POST['bo_query']) : '';
?>
" /> <?php 
translate('in');
?>
					<select name="bo_search_type" id="bo_search_type" onchange="queryType();" style="font-size: 1em;">
						<option value="1"<?php 
echo (isset($_POST['bo_search_type']) and $_POST['bo_search_type'] == 1) ? ' selected="selected"' : '';
?>
><?php 
echo translate('catalog');
?>
</option>
						<option value="2"<?php 
echo (isset($_POST['bo_search_type']) and $_POST['bo_search_type'] == 2) ? ' selected="selected"' : '';
?>
Example #29
0
 public function processImageUpload($FILES)
 {
     if (isset($FILES['avatar']) && isset($FILES['avatar']['tmp_name']) && !empty($FILES['avatar']['tmp_name'])) {
         if (ImageManager::validateUpload($FILES['avatar'], 4000000)) {
             return $this->displayError($this->l('Invalid image'));
         } else {
             $ext = Tools::substr($FILES['avatar']['name'], strrpos($FILES['avatar']['name'], '.') + 1);
             $file_name = 'avatar.' . $ext;
             $path = _PS_MODULE_DIR_ . 'smartblog/images/avatar/' . $file_name;
             if (!move_uploaded_file($FILES['avatar']['tmp_name'], $path)) {
                 return $this->displayError($this->l('An error occurred while attempting to upload the file.'));
             } else {
                 $author_types = BlogImageType::GetImageAllType('author');
                 foreach ($author_types as $image_type) {
                     $dir = _PS_MODULE_DIR_ . 'smartblog/images/avatar/avatar-' . Tools::stripslashes($image_type['type_name']) . '.jpg';
                     if (file_exists($dir)) {
                         unlink($dir);
                     }
                 }
                 $images_types = BlogImageType::GetImageAllType('author');
                 foreach ($images_types as $image_type) {
                     ImageManager::resize($path, _PS_MODULE_DIR_ . 'smartblog/images/avatar/avatar-' . Tools::stripslashes($image_type['type_name']) . '.jpg', (int) $image_type['width'], (int) $image_type['height']);
                 }
             }
         }
     }
 }
Example #30
0
    public static function getModulesOnDisk($useConfig = false, $loggedOnAddons = false, $id_employee = false)
    {
        global $_MODULES;
        // Init var
        $module_list = array();
        $module_name_list = array();
        $modulesNameToCursor = array();
        $errors = array();
        // Get modules directory list and memory limit
        $modules_dir = Module::getModulesDirOnDisk();
        $modules_installed = array();
        $result = Db::getInstance()->executeS('
		SELECT m.name, m.version, mp.interest, module_shop.enable_device
		FROM `' . _DB_PREFIX_ . 'module` m
		' . Shop::addSqlAssociation('module', 'm') . '
		LEFT JOIN `' . _DB_PREFIX_ . 'module_preference` mp ON (mp.`module` = m.`name` AND mp.`id_employee` = ' . (int) $id_employee . ')');
        foreach ($result as $row) {
            $modules_installed[$row['name']] = $row;
        }
        foreach ($modules_dir as $module) {
            if (Module::useTooMuchMemory()) {
                $errors[] = Tools::displayError('All modules cannot be loaded due to memory limit restrictions, please increase your memory_limit value on your server configuration');
                break;
            }
            $iso = Tools::substr(Context::getContext()->language->iso_code, 0, 2);
            // Check if config.xml module file exists and if it's not outdated
            if ($iso == 'en') {
                $configFile = _PS_MODULE_DIR_ . $module . '/config.xml';
            } else {
                $configFile = _PS_MODULE_DIR_ . $module . '/config_' . $iso . '.xml';
            }
            $xml_exist = file_exists($configFile);
            $needNewConfigFile = $xml_exist ? @filemtime($configFile) < @filemtime(_PS_MODULE_DIR_ . $module . '/' . $module . '.php') : true;
            // If config.xml exists and that the use config flag is at true
            if ($useConfig && $xml_exist && !$needNewConfigFile) {
                // Load config.xml
                libxml_use_internal_errors(true);
                $xml_module = simplexml_load_file($configFile);
                foreach (libxml_get_errors() as $error) {
                    $errors[] = '[' . $module . '] ' . Tools::displayError('Error found in config file:') . ' ' . htmlentities($error->message);
                }
                libxml_clear_errors();
                // If no errors in Xml, no need instand and no need new config.xml file, we load only translations
                if (!count($errors) && (int) $xml_module->need_instance == 0) {
                    $file = _PS_MODULE_DIR_ . $module . '/' . Context::getContext()->language->iso_code . '.php';
                    if (Tools::file_exists_cache($file) && (include_once $file)) {
                        if (isset($_MODULE) && is_array($_MODULE)) {
                            $_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
                        }
                    }
                    $item = new stdClass();
                    $item->id = 0;
                    $item->warning = '';
                    foreach ($xml_module as $k => $v) {
                        $item->{$k} = (string) $v;
                    }
                    $item->displayName = Tools::stripslashes(Translate::getModuleTranslation((string) $xml_module->name, Module::configXmlStringFormat($xml_module->displayName), (string) $xml_module->name));
                    $item->description = Tools::stripslashes(Translate::getModuleTranslation((string) $xml_module->name, Module::configXmlStringFormat($xml_module->description), (string) $xml_module->name));
                    $item->author = Tools::stripslashes(Translate::getModuleTranslation((string) $xml_module->name, Module::configXmlStringFormat($xml_module->author), (string) $xml_module->name));
                    $item->is_eu_compatible = Tools::stripslashes(Translate::getModuleTranslation((string) $xml_module->name, Module::configXmlStringFormat($xml_module->is_eu_compatible), (string) $xml_module->name));
                    if (isset($xml_module->confirmUninstall)) {
                        $item->confirmUninstall = Translate::getModuleTranslation((string) $xml_module->name, html_entity_decode(Module::configXmlStringFormat($xml_module->confirmUninstall)), (string) $xml_module->name);
                    }
                    $item->active = 0;
                    $item->onclick_option = false;
                    $item->trusted = Module::isModuleTrusted($item->name);
                    $module_list[] = $item;
                    $module_name_list[] = '\'' . pSQL($item->name) . '\'';
                    $modulesNameToCursor[(string) $item->name] = $item;
                }
            }
            // If use config flag is at false or config.xml does not exist OR need instance OR need a new config.xml file
            if (!$useConfig || !$xml_exist || isset($xml_module->need_instance) && (int) $xml_module->need_instance == 1 || $needNewConfigFile) {
                // If class does not exists, we include the file
                if (!class_exists($module, false)) {
                    // Get content from php file
                    $filepath = _PS_MODULE_DIR_ . $module . '/' . $module . '.php';
                    $file = trim(Tools::file_get_contents(_PS_MODULE_DIR_ . $module . '/' . $module . '.php'));
                    if (substr($file, 0, 5) == '<?php') {
                        $file = substr($file, 5);
                    }
                    if (substr($file, -2) == '?>') {
                        $file = substr($file, 0, -2);
                    }
                    // If (false) is a trick to not load the class with "eval".
                    // This way require_once will works correctly
                    if (eval('if (false){	' . $file . ' }') !== false) {
                        require_once _PS_MODULE_DIR_ . $module . '/' . $module . '.php';
                    } else {
                        $errors[] = sprintf(Tools::displayError('%1$s (parse error in %2$s)'), $module, Tools::substr($filepath, Tools::strlen(_PS_ROOT_DIR_)));
                    }
                }
                // If class exists, we just instanciate it
                if (class_exists($module, false)) {
                    $tmp_module = new $module();
                    $item = new stdClass();
                    $item->id = $tmp_module->id;
                    $item->warning = $tmp_module->warning;
                    $item->name = $tmp_module->name;
                    $item->version = $tmp_module->version;
                    $item->tab = $tmp_module->tab;
                    $item->displayName = $tmp_module->displayName;
                    $item->description = Tools::stripslashes($tmp_module->description);
                    $item->author = $tmp_module->author;
                    $item->limited_countries = $tmp_module->limited_countries;
                    $item->parent_class = get_parent_class($module);
                    $item->is_configurable = $tmp_module->is_configurable = method_exists($tmp_module, 'getContent') ? 1 : 0;
                    $item->need_instance = isset($tmp_module->need_instance) ? $tmp_module->need_instance : 0;
                    $item->active = $tmp_module->active;
                    $item->trusted = Module::isModuleTrusted($tmp_module->name);
                    $item->currencies = isset($tmp_module->currencies) ? $tmp_module->currencies : null;
                    $item->currencies_mode = isset($tmp_module->currencies_mode) ? $tmp_module->currencies_mode : null;
                    $item->confirmUninstall = isset($tmp_module->confirmUninstall) ? html_entity_decode($tmp_module->confirmUninstall) : null;
                    $item->description_full = Tools::stripslashes($tmp_module->description_full);
                    $item->additional_description = isset($tmp_module->additional_description) ? Tools::stripslashes($tmp_module->additional_description) : null;
                    $item->compatibility = isset($tmp_module->compatibility) ? (array) $tmp_module->compatibility : null;
                    $item->nb_rates = isset($tmp_module->nb_rates) ? (array) $tmp_module->nb_rates : null;
                    $item->avg_rate = isset($tmp_module->avg_rate) ? (array) $tmp_module->avg_rate : null;
                    $item->badges = isset($tmp_module->badges) ? (array) $tmp_module->badges : null;
                    $item->url = isset($tmp_module->url) ? $tmp_module->url : null;
                    $item->is_eu_compatible = isset($tmp_module->is_eu_compatible) ? $tmp_module->is_eu_compatible : 0;
                    $item->onclick_option = method_exists($module, 'onclickOption') ? true : false;
                    if ($item->onclick_option) {
                        $href = Context::getContext()->link->getAdminLink('Module', true) . '&module_name=' . $tmp_module->name . '&tab_module=' . $tmp_module->tab;
                        $item->onclick_option_content = array();
                        $option_tab = array('desactive', 'reset', 'configure', 'delete');
                        foreach ($option_tab as $opt) {
                            $item->onclick_option_content[$opt] = $tmp_module->onclickOption($opt, $href);
                        }
                    }
                    $module_list[] = $item;
                    if (!$xml_exist || $needNewConfigFile) {
                        self::$_generate_config_xml_mode = true;
                        $tmp_module->_generateConfigXml();
                        self::$_generate_config_xml_mode = false;
                    }
                    unset($tmp_module);
                } else {
                    $errors[] = sprintf(Tools::displayError('%1$s (class missing in %2$s)'), $module, Tools::substr($filepath, Tools::strlen(_PS_ROOT_DIR_)));
                }
            }
        }
        // Get modules information from database
        if (!empty($module_name_list)) {
            $list = Shop::getContextListShopID();
            $sql = 'SELECT m.id_module, m.name, (
						SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'module_shop ms WHERE m.id_module = ms.id_module AND ms.id_shop IN (' . implode(',', $list) . ')
					) as total
					FROM ' . _DB_PREFIX_ . 'module m
					WHERE m.name IN (' . implode(',', $module_name_list) . ')';
            $results = Db::getInstance()->executeS($sql);
            foreach ($results as $result) {
                $moduleCursor = $modulesNameToCursor[$result['name']];
                $moduleCursor->id = $result['id_module'];
                $moduleCursor->active = $result['total'] == count($list) ? 1 : 0;
            }
        }
        // Get Default Country Modules and customer module
        $files_list = array(array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_ . self::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0), array('type' => 'addonsBought', 'file' => _PS_ROOT_DIR_ . self::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1), array('type' => 'addonsMustHave', 'file' => _PS_ROOT_DIR_ . self::CACHE_FILE_MUST_HAVE_MODULES_LIST, 'loggedOnAddons' => 0));
        foreach ($files_list as $f) {
            if (file_exists($f['file']) && ($f['loggedOnAddons'] == 0 || $loggedOnAddons)) {
                if (Module::useTooMuchMemory()) {
                    $errors[] = Tools::displayError('All modules cannot be loaded due to memory limit restrictions, please increase your memory_limit value on your server configuration');
                    break;
                }
                $file = $f['file'];
                $content = Tools::file_get_contents($file);
                $xml = @simplexml_load_string($content, null, LIBXML_NOCDATA);
                if ($xml && isset($xml->module)) {
                    foreach ($xml->module as $modaddons) {
                        $flag_found = 0;
                        foreach ($module_list as $k => &$m) {
                            if ($m->name == $modaddons->name && !isset($m->available_on_addons)) {
                                $flag_found = 1;
                                if ($m->version != $modaddons->version && version_compare($m->version, $modaddons->version) === -1 && !$m->is_eu_compatible) {
                                    $module_list[$k]->version_addons = $modaddons->version;
                                }
                            }
                        }
                        if ($flag_found == 0) {
                            $item = new stdClass();
                            $item->id = 0;
                            $item->warning = '';
                            $item->type = strip_tags((string) $f['type']);
                            $item->name = strip_tags((string) $modaddons->name);
                            $item->version = strip_tags((string) $modaddons->version);
                            $item->tab = strip_tags((string) $modaddons->tab);
                            $item->displayName = strip_tags((string) $modaddons->displayName);
                            $item->description = Tools::stripslashes(strip_tags((string) $modaddons->description));
                            $item->description_full = Tools::stripslashes(strip_tags((string) $modaddons->description_full));
                            $item->author = strip_tags((string) $modaddons->author);
                            $item->limited_countries = array();
                            $item->parent_class = '';
                            $item->onclick_option = false;
                            $item->is_configurable = 0;
                            $item->need_instance = 0;
                            $item->not_on_disk = 1;
                            $item->available_on_addons = 1;
                            $item->trusted = Module::isModuleTrusted($item->name);
                            $item->active = 0;
                            $item->description_full = Tools::stripslashes($modaddons->description_full);
                            $item->additional_description = isset($modaddons->additional_description) ? Tools::stripslashes($modaddons->additional_description) : null;
                            $item->compatibility = isset($modaddons->compatibility) ? (array) $modaddons->compatibility : null;
                            $item->nb_rates = isset($modaddons->nb_rates) ? (array) $modaddons->nb_rates : null;
                            $item->avg_rate = isset($modaddons->avg_rate) ? (array) $modaddons->avg_rate : null;
                            $item->badges = isset($modaddons->badges) ? (array) $modaddons->badges : null;
                            $item->url = isset($modaddons->url) ? $modaddons->url : null;
                            if (isset($modaddons->img)) {
                                if (!file_exists(_PS_TMP_IMG_DIR_ . md5($modaddons->name) . '.jpg')) {
                                    if (!file_put_contents(_PS_TMP_IMG_DIR_ . md5($modaddons->name) . '.jpg', Tools::file_get_contents($modaddons->img))) {
                                        copy(_PS_IMG_DIR_ . '404.gif', _PS_TMP_IMG_DIR_ . md5($modaddons->name) . '.jpg');
                                    }
                                }
                                if (file_exists(_PS_TMP_IMG_DIR_ . md5($modaddons->name) . '.jpg')) {
                                    $item->image = '../img/tmp/' . md5($modaddons->name) . '.jpg';
                                }
                            }
                            if ($item->type == 'addonsMustHave') {
                                $item->addons_buy_url = strip_tags((string) $modaddons->url);
                                $prices = (array) $modaddons->price;
                                $id_default_currency = Configuration::get('PS_CURRENCY_DEFAULT');
                                foreach ($prices as $currency => $price) {
                                    if ($id_currency = Currency::getIdByIsoCode($currency)) {
                                        $item->price = (double) $price;
                                        $item->id_currency = (int) $id_currency;
                                        if ($id_default_currency == $id_currency) {
                                            break;
                                        }
                                    }
                                }
                            }
                            $module_list[] = $item;
                        }
                    }
                }
            }
        }
        foreach ($module_list as $key => &$module) {
            if (defined('_PS_HOST_MODE_') && in_array($module->name, self::$hosted_modules_blacklist)) {
                unset($module_list[$key]);
            } elseif (isset($modules_installed[$module->name])) {
                $module->installed = true;
                $module->database_version = $modules_installed[$module->name]['version'];
                $module->interest = $modules_installed[$module->name]['interest'];
                $module->enable_device = $modules_installed[$module->name]['enable_device'];
            } else {
                $module->installed = false;
                $module->database_version = 0;
                $module->interest = 0;
            }
        }
        usort($module_list, create_function('$a,$b', 'return strnatcasecmp($a->displayName, $b->displayName);'));
        if ($errors) {
            if (!isset(Context::getContext()->controller) && !Context::getContext()->controller->controller_name) {
                echo '<div class="alert error"><h3>' . Tools::displayError('The following module(s) could not be loaded') . ':</h3><ol>';
                foreach ($errors as $error) {
                    echo '<li>' . $error . '</li>';
                }
                echo '</ol></div>';
            } else {
                foreach ($errors as $error) {
                    Context::getContext()->controller->errors[] = $error;
                }
            }
        }
        return $module_list;
    }