PHP Tools Examples

PHP Tools - 30 examples found. These are the top rated real world PHP examples of Tools extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 public function sendOrderReplay($data = NULL)
 {
     if (!$data || empty($data['content'])) {
         return 'Can not send empty data';
     }
     $data['send_url'] .= 'php/interface.php?m=clerk&c=UserQuiz&a=GetClientReply';
     $_utilFRGInterface = $this->_getGlobalData('Util_FRGInterface', 'object');
     $_utilFRGInterface->set_sendUrl($data['send_url']);
     $fileData = $data['file_img'];
     $isFile = is_file($fileData);
     if ($isFile) {
         $webPath = pathinfo($fileData);
         $data['ReplyFile'] = 'http://' . $_SERVER['HTTP_HOST'] . '/Upload/Service/' . date('Ymd', CURRENT_TIME) . '/' . $webPath["basename"];
     }
     unset($data['send_url'], $data['file_img']);
     $data['_sign'] = md5(TAKE_KEY . CURRENT_TIME);
     $data['_verifycode'] = CURRENT_TIME;
     $_utilFRGInterface->setPost($data);
     $data = $_utilFRGInterface->callInterface();
     $errorInfo = Tools::getLang('SEND_MSG', 'Control_WorkOrder');
     if ($data) {
         if ($data['msgno'] == 1) {
             return true;
         }
         $errorInfo = Tools::getLang('FRG_SEND_ERROR', 'Control_WorkOrder', array('data[message]' => $data['message']));
     }
     if ($isFile) {
         unlink($fileData);
     }
     return $errorInfo;
 }
 /**
  * Check then return multilingual fields for database interaction
  *
  * @return array Multilingual fields
  */
 public function getTranslationsFieldsChild()
 {
     parent::validateFieldsLang();
     $fieldsArray = array('title', 'url');
     $fields = array();
     $languages = Language::getLanguages(false);
     $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
     foreach ($languages as $language) {
         $fields[$language['id_lang']]['id_lang'] = (int) $language['id_lang'];
         $fields[$language['id_lang']][self::$definition['primary']] = (int) $this->id;
         foreach ($fieldsArray as $field) {
             if (!Validate::isTableOrIdentifier($field)) {
                 die(Tools::displayError());
             }
             if (isset($this->{$field}[$language['id_lang']]) and !empty($this->{$field}[$language['id_lang']])) {
                 $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']], true);
             } elseif (in_array($field, $this->fieldsRequiredLang)) {
                 $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage], true);
             } else {
                 $fields[$language['id_lang']][$field] = '';
             }
         }
     }
     return $fields;
 }
Example #3
0
   public function getContent()
   {
       // If we try to update the settings
       $output = '';
       if (isset($_POST['submitModule'])) {
           Configuration::updateValue('blocksocial_facebook', $_POST['facebook_url'] != '' ? $_POST['facebook_url'] : '');
           Configuration::updateValue('blocksocial_twitter', $_POST['twitter_url'] != '' ? $_POST['twitter_url'] : '');
           Configuration::updateValue('blocksocial_rss', $_POST['rss_url'] != '' ? $_POST['rss_url'] : '');
           $output = '<div class="conf confirm">' . $this->l('Configuration updated') . '</div>';
       }
       return '
	<h2>' . $this->displayName . '</h2>
	' . $output . '
	<form action="' . Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']) . '" method="post">
		<fieldset class="width2">				
			<label for="facebook_url">' . $this->l('Facebook URL: ') . '</label>
			<input type="text" id="facebook_url" name="facebook_url" value="' . Tools::safeOutput(Configuration::get('blocksocial_facebook') != "" ? Configuration::get('blocksocial_facebook') : "") . '" />
			<div class="clear">&nbsp;</div>		
			<label for="twitter_url">' . $this->l('Twitter URL: ') . '</label>
			<input type="text" id="twitter_url" name="twitter_url" value="' . Tools::safeOutput(Configuration::get('blocksocial_twitter') != "" ? Configuration::get('blocksocial_twitter') : "") . '" />
			<div class="clear">&nbsp;</div>		
			<label for="rss_url">' . $this->l('RSS URL: ') . '</label>
			<input type="text" id="rss_url" name="rss_url" value="' . Tools::safeOutput(Configuration::get('blocksocial_rss') != "" ? Configuration::get('blocksocial_rss') : "") . '" />
			<div class="clear">&nbsp;</div>						
			<br /><center><input type="submit" name="submitModule" value="' . $this->l('Update settings') . '" class="button" /></center>
		</fieldset>
	</form>';
   }
Example #4
0
 public function renderContent($args, $setting)
 {
     $t = array('name' => '', 'image_folder_path' => '', 'limit' => 12, 'columns' => 4);
     $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
     $url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__);
     $setting = array_merge($t, $setting);
     $oimages = array();
     if ($setting['image_folder_path']) {
         $path = _PS_ROOT_DIR_ . '/' . trim($setting['image_folder_path']) . '/';
         $path = str_replace("//", "/", $path);
         if (is_dir($path)) {
             $images = glob($path . '*.*');
             $exts = array('jpg', 'gif', 'png');
             foreach ($images as $cnt => $image) {
                 $ext = Tools::substr($image, Tools::strlen($image) - 3, Tools::strlen($image));
                 if (in_array(Tools::strtolower($ext), $exts)) {
                     if ($cnt < (int) $setting['limit']) {
                         $i = str_replace("\\", "/", '' . $setting['image_folder_path'] . "/" . basename($image));
                         $i = str_replace("//", "/", $i);
                         $oimages[] = $url . $i;
                     }
                 }
             }
         }
     }
     $images = array();
     $setting['images'] = $oimages;
     $output = array('type' => 'image', 'data' => $setting);
     return $output;
 }
Example #5
0
 protected function _prepareHook($params)
 {
     $languages = Language::getLanguages(true, $this->context->shop->id);
     if (!count($languages)) {
         return false;
     }
     $link = new Link();
     if ((int) Configuration::get('PS_REWRITING_SETTINGS')) {
         $default_rewrite = array();
         if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int) Tools::getValue('id_product'))) {
             $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product);
             foreach ($rewrite_infos as $infos) {
                 $default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']);
             }
         }
         if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int) Tools::getValue('id_category'))) {
             $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category);
             foreach ($rewrite_infos as $infos) {
                 $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']);
             }
         }
         if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int) Tools::getValue('id_cms')) || ($id_cms_category = (int) Tools::getValue('id_cms_category')))) {
             $rewrite_infos = isset($id_cms) && !isset($id_cms_category) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
             foreach ($rewrite_infos as $infos) {
                 $arr_link = isset($id_cms) && !isset($id_cms_category) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
                 $default_rewrite[$infos['id_lang']] = $arr_link;
             }
         }
         $this->smarty->assign('lang_rewrite_urls', $default_rewrite);
     }
     return true;
 }
Example #6
0
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'cheque') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $mailVars = array('{cheque_name}' => Configuration::get('CHEQUE_NAME'), '{cheque_address}' => Configuration::get('CHEQUE_ADDRESS'), '{cheque_address_html}' => str_replace("\n", '<br />', Configuration::get('CHEQUE_ADDRESS')));
     $this->module->validateOrder((int) $cart->id, Configuration::get('PS_OS_CHEQUE'), $total, $this->module->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
Example #7
0
   public function getContent()
   {
       $html = '';
       // If we try to update the settings
       if (isset($_POST['submitModule'])) {
           Configuration::updateValue('blockcontactinfos_company', isset($_POST['company']) && $_POST['company'] != '' ? $_POST['company'] : Configuration::get('PS_SHOP_NAME'));
           Configuration::updateValue('blockcontactinfos_address', isset($_POST['address']) && $_POST['address'] != '' ? $_POST['address'] : '');
           Configuration::updateValue('blockcontactinfos_phone', isset($_POST['phone']) && $_POST['phone'] != '' ? $_POST['phone'] : '');
           Configuration::updateValue('blockcontactinfos_email', isset($_POST['email']) && $_POST['email'] != '' ? $_POST['email'] : Configuration::get('PS_SHOP_EMAIL'));
           $html .= '<div class="confirm">' . $this->l('Configuration updated') . '</div>';
       }
       $html .= '
	<h2>' . $this->displayName . '</h2>
	<form action="' . Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']) . '" method="post">
		<fieldset>	
			<p><label for="company">' . $this->l('Company name') . ' :</label>
			<input type="text" id="company" name="company" value="' . Tools::safeOutput(Configuration::get('blockcontactinfos_company')) . '" /></p>
			<p><label for="address">' . $this->l('Address') . ' :</label>
			<textarea id="address" name="address" cols="60" rows="4">' . Tools::safeOutput(Configuration::get('blockcontactinfos_address')) . '</textarea></p>
			<p><label for="phone">' . $this->l('Phone number') . ' :</label>
			<input type="text" id="phone" name="phone" value="' . Tools::safeOutput(Configuration::get('blockcontactinfos_phone')) . '" /></p>
			<p><label for="email">' . $this->l('Email') . ' :</label>
			<input type="text" id="email" name="email" value="' . Tools::safeOutput(Configuration::get('blockcontactinfos_email')) . '" />	</p>
			<div class="margin-form">
				<input type="submit" name="submitModule" value="' . $this->l('Update settings') . '" class="button" /></center>
			</div>
		</fieldset>
	</form>
	';
       return $html;
   }
 /**
  * displays available actions in the top of the order list
  */
 public function displayTop()
 {
     $header = "<fieldset>";
     $header .= "<div id='header_sceau'>\n\t\t\t\t<div class='sceau_control'>\n\t\t\t\t\t<a href='index.php?tab=AdminSceau&action=ResendOrders&token=" . Tools::getAdminTokenLite('AdminSceau') . "'>\n\t\t\t\t\t\t<img src='" . _PS_BASE_URL_ . __PS_BASE_URI__ . "modules/fianetsceau/img/sceauresend14.png'/>" . $this->l('Resend orders') . "\n\t\t\t\t\t</a>\n\t\t\t\t</div>\n\t\t\t</div>";
     $header .= '</fieldset>';
     echo $header;
 }
 private function rev_uploader()
 {
     $key = Tools::getValue('security_key');
     if (empty($key) || Tools::encrypt(GlobalsRevSlider::MODULE_NAME) != $key) {
         echo json_encode(array('error_on' => 1, 'error_details' => 'Security Error'));
         die;
     }
     $targetFolder = ABSPATH . '/uploads/';
     $randnum = rand(00, 9999999);
     $sds_time = time();
     $NewFileName = $randnum . '-' . $sds_time;
     //$verifyToken = md5('unique_salt' . $_POST['timestamp']);
     if (!empty($_FILES)) {
         $tempFile = $_FILES['Filedata']['tmp_name'];
         //$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
         $targetPath = $targetFolder;
         //$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
         // Validate the file type
         $fileTypes = array('jpg', 'jpeg', 'gif', 'png');
         // File extensions
         $fileParts = pathinfo($_FILES['Filedata']['name']);
         if (in_array($fileParts['extension'], $fileTypes)) {
             // $worked = UniteFunctionsWPRev::import_media_img($tempFile, $targetPath, $randnum.$_FILES['Filedata']['name']);
             $worked = UniteFunctionsWPRev::import_media_img($tempFile, $targetPath, $NewFileName . '.' . $fileParts['extension']);
             if (!empty($worked)) {
                 echo '1';
             }
         } else {
             echo '0';
         }
     }
 }
 public function displayForm()
 {
     // Get default Language
     $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     // Init Fields form array
     $fields_form[0]['form'] = array('legend' => array('title' => $this->l('Settings')), 'input' => array(array('type' => 'text', 'label' => $this->l('ID Facebook:'), 'name' => 'facebookgraph_id', 'size' => '100', 'desc' => $this->l('A Facebook Platform application ID that administers this page.')), array('type' => 'text', 'label' => $this->l('Name shop:'), 'name' => 'facebookgraph_name', 'size' => '100', 'desc' => $this->l('Name of this shop.')), array('type' => 'text', 'label' => $this->l('Url shop:'), 'name' => 'facebookgraph_url', 'size' => '100', 'desc' => $this->l('The canonical URL of this shop.')), array('type' => 'text', 'label' => $this->l('Type shop:'), 'name' => 'facebookgraph_type', 'size' => '100', 'desc' => $this->l('The type of this shop.')), array('type' => 'text', 'label' => $this->l('Title:'), 'name' => 'facebookgraph_title', 'size' => '100', 'desc' => $this->l('The title of this shop.')), array('type' => 'text', 'label' => $this->l('Description:'), 'name' => 'facebookgraph_description', 'size' => '100', 'desc' => $this->l('A one to two sentence description of this shop.')), array('type' => 'text', 'label' => $this->l('Image url:'), 'name' => 'facebookgraph_image', 'size' => '100', 'desc' => $this->l('An image URL which should represent your shop within the graph. The image must be at least 50px by 50px (though minimum 200px by 200px is preferred) and have a maximum aspect ratio of 3:1. We support PNG, JPEG and GIF formats.'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     $helper = new HelperForm();
     // Module, t    oken and currentIndex
     $helper->module = $this;
     $helper->name_controller = $this->name;
     $helper->token = Tools::getAdminTokenLite('AdminModules');
     $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
     // Language
     $helper->default_form_language = $default_lang;
     $helper->allow_employee_form_lang = $default_lang;
     // Title and toolbar
     $helper->title = $this->displayName;
     $helper->show_toolbar = true;
     // false -> remove toolbar
     $helper->toolbar_scroll = true;
     // yes - > Toolbar is always visible on the top of the screen.
     $helper->submit_action = 'submit' . $this->name;
     $helper->toolbar_btn = array('save' => array('desc' => $this->l('Save'), 'href' => AdminController::$currentIndex . '&configure=' . $this->name . '&save' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules')), 'back' => array('href' => AdminController::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list')));
     // Load current value
     $helper->fields_value['facebookgraph_id'] = Configuration::get('facebookgraph_id');
     $helper->fields_value['facebookgraph_type'] = Configuration::get('facebookgraph_type');
     $helper->fields_value['facebookgraph_title'] = Configuration::get('facebookgraph_title');
     $helper->fields_value['facebookgraph_url'] = Configuration::get('facebookgraph_url');
     $helper->fields_value['facebookgraph_name'] = Configuration::get('facebookgraph_name');
     $helper->fields_value['facebookgraph_image'] = Configuration::get('facebookgraph_image');
     $helper->fields_value['facebookgraph_description'] = Configuration::get('facebookgraph_description');
     return $helper->generateForm($fields_form);
 }
 public function initContent()
 {
     $this->errors[] = $this->trans('Controller not found', array(), 'Admin.Notifications.Error');
     $tpl_vars['controller'] = Tools::getvalue('controllerUri', Tools::getvalue('controller'));
     $this->context->smarty->assign($tpl_vars);
     parent::initContent();
 }
Example #12
0
function upgrade_module_0_9($module)
{
    $module_path = $module->getLocalPath();
    $img_folder_path = $module->getLocalPath() . 'img';
    $fixture_img_path = $module->getLocalPath() . 'img' . DIRECTORY_SEPARATOR . 'fixtures';
    if (!Tools::file_exists_cache($img_folder_path)) {
        mkdir($img_folder_path);
    }
    if (!Tools::file_exists_cache($fixture_img_path)) {
        mkdir($fixture_img_path);
    }
    $files = scandir($module->getLocalPath());
    foreach ($files as $file) {
        if (strncmp($file, 'advertising', 11) == 0) {
            if ($file == 'advertising.jpg') {
                copy($module_path . $file, $fixture_img_path . DIRECTORY_SEPARATOR . $file);
            } else {
                copy($module_path . $file, $img_folder_path . DIRECTORY_SEPARATOR . $file);
            }
            unlink($module_path . $file);
        }
    }
    Tools::clearCache(Context::getContext()->smarty, $module->getTemplatePath('blockadvertising.tpl'));
    return true;
}
    public static function displayHelp($label, $iso_lang, $country, $ps_version)
    {
        $infos = HelpAccess::retrieveInfos($label, $iso_lang, $country, $ps_version);
        if (array_key_exists('image', $infos) && $infos['image'] != 'none') {
            echo '
			        <a class="help-button" href="#" onclick="showHelp(\'' . HelpAccess::URL . '\',\'' . $label . '\',\'' . $iso_lang . '\',\'' . $ps_version . '\',\'' . $infos['version'] . '\',\'' . $country . '\');" title="' . Tools::htmlentitiesUTF8($infos['tooltip']) . '">
			        <img id="help-' . $label . '" src="../img/admin/' . Tools::htmlentitiesUTF8($infos['image']) . '" alt="" class="middle" style="margin-top: -5px"/> ' . Tools::displayError('HELP') . '
			        </a>

		          ';
            if (!empty($infos['tooltip'])) {
                echo ' <script type="text/javascript">
			            $(document).ready(function() {
              			      $("a.help-button").cluetip({
				              	splitTitle: "|",
				              	cluetipClass: "help-button",
				                showTitle: false,
				                arrows: true,
				                dropShadow: false,
				                positionBy: "auto"
			                  });
			            });
		              </script>';
            }
        }
    }
Example #14
0
 public function createEntityCustomer($identifier, array $data, array $data_lang)
 {
     if ($identifier == 'John') {
         $data['passwd'] = Tools::encrypt('123456789');
     }
     return $this->createEntity('customer', $identifier, 'Customer', $data, $data_lang);
 }
Example #15
0
   public function hookAdminStatsModules($params)
   {
       $totalVisits = $this->getTotalVisits();
       $totalGuests = $this->getTotalGuests();
       if (Tools::getValue('export')) {
           $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => 3));
       }
       $this->_html = '
	<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
		<p><center>
			<img src="../img/admin/down.gif" />' . $this->l('A visit corresponds to an internet user coming to your shop. Until the end of their session, only one visit is counted.') . '
			' . $this->l('A visitor is an unknown person, who has not registered or logged on, surfing on your shop. A visitor can come and visit your shop many times.') . '
		</center></p>
		<div style="margin-top:20px"></div>
		<p>' . $this->l('Total visits:') . ' ' . $totalVisits . '</p>
		<p>' . $this->l('Total visitors:') . ' ' . $totalGuests . '</p>
		' . ($totalVisits ? ModuleGraph::engine(array('layers' => 2, 'type' => 'line', 'option' => 3)) . '<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>' : '') . '
		
	</fieldset>
	<br class="clear" />
	<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
			<h2>' . $this->l('Determine the interest of a visit') . '</h2>
			' . $this->l('The visitors\' evolution graph strongly resembles the visits\' graph, but provides additional information:') . '<br />
			<ul>
				<li>' . $this->l('If this is the case, congratulations, your website is well planned and pleasing.') . '</li>
				<li>' . $this->l('Otherwise, the conclusion is not so simple. The problem can be aesthetic or ergonomic, or else the offer is not sufficient. It is also possible that these visitors mistakenly came here without particular interest for your shop; this phenomenon often happens with the search engines.') . '</li>
			</ul>
			' . $this->l('This information is mostly qualitative: you have to determine the interest of a disjointed visit.') . '<br />
	</fieldset>';
       return $this->_html;
   }
Example #16
0
   public function display()
   {
       global $cookie, $currentIndex;
       echo '<div style="float:left;width:600px">';
       $this->getList((int) $cookie->id_lang, !Tools::getValue($this->table . 'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table . 'Orderway') ? 'DESC' : NULL);
       $this->displayList();
       echo '</div>';
       echo '
	<fieldset style="float:left;width:280px"><legend><img src="../img/admin/pdf.gif" alt="" /> ' . $this->l('Print PDF') . '</legend>
		<form action="' . $currentIndex . '&token=' . $this->token . '" method="post">
			<label style="width:90px">' . $this->l('From:') . ' </label>
			<div class="margin-form" style="padding-left:100px">
				<input type="text" size="4" maxlength="10" name="date_from" value="' . date('Y-m-01') . '" style="width: 120px;" />
				<p class="clear">' . $this->l('Format: 2007-12-31 (inclusive)') . '</p>
			</div>
			<label style="width:90px">' . $this->l('To:') . ' </label>
			<div class="margin-form" style="padding-left:100px">
				<input type="text" size="4" maxlength="10" name="date_to" value="' . date('Y-m-t') . '" style="width: 120px;" />
				<p class="clear">' . $this->l('Format: 2008-12-31 (inclusive)') . '</p>
			</div>
			<div class="margin-form" style="padding-left:100px">
				<input type="submit" value="' . $this->l('Generate PDF file') . '" name="submitPrint" class="button" />
			</div>
		</form>
	</fieldset><div class="clear">&nbsp;</div>';
   }
 protected function canonicalRedirection()
 {
     global $link, $cookie;
     if (Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') {
         // Automatically redirect to the canonical URL if needed
         if (isset($this->php_self) && !empty($this->php_self)) {
             // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
             $canonicalURL = $link->getPageLink($this->php_self, $this->ssl, $cookie->id_lang);
             if (!Tools::getValue('ajax') && !preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', ($this->ssl && _PS_SSL_ENABLED_ ? 'https://' : 'http://') . urldecode($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']))) {
                 if ($_SERVER['REQUEST_URI'] == __PS_BASE_URI__) {
                     header('HTTP/1.0 303 See Other');
                     header('Cache-Control: no-cache');
                 } else {
                     header('HTTP/1.0 301 Moved Permanently');
                     header('Cache-Control: no-cache');
                 }
                 $params = '';
                 $excludedKey = array('isolang', 'id_lang');
                 foreach ($_GET as $key => $value) {
                     if (!in_array($key, $excludedKey)) {
                         $params .= ($params == '' ? '?' : '&') . $key . '=' . $value;
                     }
                 }
                 Module::hookExec('frontCanonicalRedirect');
                 if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) {
                     die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . $params . '">' . $canonicalURL . $params . '</a>');
                 }
                 Tools::redirectLink($canonicalURL . $params);
             }
         }
     }
 }
Example #18
0
 public function createChan($chanName)
 {
     try {
         // get channel order
         $chan_order = $this->ts3->channelGetById($this->cfg['base'])->getProperty('channel_order');
         // Tools::Log('info', 'Got the order');
         // create a channel and get its ID
         $top_cid = $this->ts3->channelCreate(array("channel_name" => $chanName, "channel_order" => $chan_order, "channel_flag_permanent" => TRUE));
         // Tools::Log('info', 'Created the channel');
         // create cpacer and get its ID
         $cpacer_cid = $this->ts3->channelCreate(array("channel_name" => "[" . $this->cfg['spacerOper'] . "spacer" . mt_rand(1, 99999) . "]" . $this->cfg['spacer'], "channel_flag_permanent" => TRUE, "channel_order" => $top_cid, "channel_flag_maxclients_unlimited" => false, "channel_maxclients" => 0));
         // Tools::Log('info', 'Created the spacer');
         // set permissions (WIP)
         foreach ($this->cfg['permissions'] as $permission => $value) {
             $this->ts3->channelGetById($top_cid)->permAssignByName($permission, $value);
         }
         // Tools::Log('info', 'Setted permissions');
         // get token
         $token = $this->ts3->channelGroupGetById($this->cfg['chanAdmin'])->tokenCreate($top_cid);
         // Tools::Log('info', $token);
         return $token;
     } catch (Exception $e) {
         Tools::Log('error', 'Error', array($e));
         return false;
     }
 }
 public function initContent()
 {
     $this->errors[] = Tools::displayError('Controller not found');
     $tpl_vars['controller'] = Tools::getvalue('controllerUri', Tools::getvalue('controller'));
     $this->context->smarty->assign($tpl_vars);
     parent::initContent();
 }
Example #20
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     $this->display_column_left = false;
     parent::initContent();
     $this->context->smarty->assign(array('total' => $this->context->cart->getOrderTotal(true, Cart::BOTH), 'this_path' => $this->module->getPathUri(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/'));
     $this->setTemplate('validation.tpl');
 }
Example #21
0
 public function initContent()
 {
     if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         parent::initContent();
         $this->productSort();
         $nb_products = (int) ProductSale::getNbSales();
         $this->pagination($nb_products);
         if (!Tools::getValue('orderby')) {
             $this->orderBy = 'sales';
         }
         $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
         $this->addColorsToProductList($products);
         /************************* /Images Array ******************************/
         if (method_exists('Product', 'getProductsImgs')) {
             $image_array = array();
             for ($i = 0; $i < $nb_products; $i++) {
                 if (isset($products[$i]['id_product'])) {
                     $image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']);
                 }
             }
             $this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
         }
         /************************* /Images Array ******************************/
         $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nb_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
         $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
     } else {
         Tools::redirect('index.php?controller=404');
     }
 }
Example #22
0
 public function connect($address = "", $port = "")
 {
     global $merchantAddress;
     if ($this->connected) {
         $this->close();
     }
     $a = Tools::address($merchantAddress);
     if (empty($port) || !is_integer($port)) {
         $port = intval($a['port']);
     }
     if (empty($address)) {
         $address = $a['address'];
     }
     $address = gethostbyname($address);
     $this->address = $address;
     $this->port = $port;
     $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
     if ($this->socket === false) {
         return false;
     }
     $result = socket_connect($this->socket, $this->address, $this->port);
     if ($result === false) {
         return false;
     }
     $this->connectmessage = @socket_read($this->socket, 1024 * 1024, PHP_NORMAL_READ);
     $this->connected = true;
     return true;
 }
 public function hookDisplayHome($params)
 {
     !isset($params['tpl']) && ($params['tpl'] = 'hookHome');
     $config = Tools::jsonDecode(Configuration::get($this->name), true);
     $this->smarty->assign($config);
     return $this->display(__FILE__, $params['tpl'] . '.tpl');
 }
Example #24
0
 /**
  * For a given {id_product, id_product_attribute and id_shop}, gets the stock available id associated
  *
  * @param int $id_product
  * @param int $id_product_attribute Optional
  * @param int $id_shop Optional
  * @return int
  */
 public function updateWs()
 {
     if ($this->depends_on_stock) {
         return WebserviceRequest::getInstance()->setError(500, Tools::displayError('You can\'t update stock available when it\'s depend on stock'));
     }
     return $this->update();
 }
Example #25
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     $this->display_column_left = false;
     $this->display_column_right = false;
     parent::initContent();
     $cart = $this->context->cart;
     $client = $this->context->customer;
     $invoice_address = new Address((int) $cart->id_address_invoice);
     $state = new State((int) $invoice_address->id_state);
     $arreglo_meses = array();
     for ($i = 1; $i <= 12; $i++) {
         $arreglo_meses[] = sprintf("%02s", $i);
     }
     $arreglo_anyos = array();
     $anyo_actual = date("Y", time());
     for ($i = 0; $i < 12; $i++) {
         $arreglo_anyos[] = substr($anyo_actual + $i, -2);
     }
     session_start();
     $arreglo_errores = array();
     if (is_array($_SESSION['errores'])) {
         foreach ($_SESSION['errores'] as $key => $value) {
             $arreglo_errores[$key] = $value;
         }
     }
     unset($_SESSION['errores']);
     $this->context->smarty->assign(array('nbProducts' => $cart->nbProducts(), 'monto' => $cart->getOrderTotal(true, Cart::BOTH), 'this_path' => $this->module->getPathUri(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/', 'nombre' => $client->firstname, 'apellidos' => $client->lastname, 'cp' => $invoice_address->postcode, 'monto' => $cart->getOrderTotal(true, Cart::BOTH), 'email' => $client->email, 'telefono' => $invoice_address->phone, 'celular' => $invoice_address->phone_mobile, 'calleyNumero' => $invoice_address->address1, 'colonia' => '', 'municipio' => $invoice_address->city, 'estado' => $state->name, 'pais' => $invoice_address->country, 'anyos' => $arreglo_anyos, 'meses' => $arreglo_meses, 'errores' => $arreglo_errores));
     $this->setTemplate('payment_execution.tpl');
 }
Example #26
0
   public function hookAdminStatsModules($params)
   {
       $engineParams = array('id' => 'id_customer', 'title' => $this->displayName, 'columns' => $this->_columns, 'defaultSortColumn' => $this->_defaultSortColumn, 'defaultSortDirection' => $this->_defaultSortDirection, 'emptyMessage' => $this->_emptyMessage, 'pagingMessage' => $this->_pagingMessage);
       if (Tools::getValue('export')) {
           $this->csvExport($engineParams);
       }
       $this->_html = '
	<div class="blocStats"><h2 class="icon-' . $this->name . '"><span></span>' . $this->displayName . '</h2>
		' . $this->engine($engineParams) . '
	<p><a class="button export-csv" href="' . htmlentities($_SERVER['REQUEST_URI']) . '&export=1"><span>' . $this->l('CSV Export') . '</span></a></p>
	</div><br />
	<div class="blocStats"><h2 class="icon-guide"><span></span>' . $this->l('Guide') . '</h2>
		<h2 >' . $this->l('Develop clients\' loyalty') . '</h2>
		<p class="space">
			' . $this->l('Keeping a client is more profitable than gaining a new one. Thus, it is necessary to develop their loyalty, in other words to make them want to come back to your webshop.') . ' <br />
			' . $this->l('Word of mouth is also a means to of getting new, satisfied clients; a dissatisfied one won\'t attract new clients.') . '<br />
			' . $this->l('In order to achieve this goal you can organize: ') . '
			<ul>
				<li>' . $this->l('Punctual operations: commercial rewards (personalized special offers, product or service offered),
					non commercial rewards (priority handling of an order or a product), pecuniary rewards (bonds, discount coupons, payback).') . '</li>
				<li>' . $this->l('Sustainable operations: loyalty points or cards, which not only justify communication between merchant and client,
					 but also offer advantages to clients (private offers, discounts).') . '</li>
			</ul>
			' . $this->l('These operations encourage clients to buy products and visit your webshop regularly.') . ' <br />
		</p><br />
	</div>';
       return $this->_html;
   }
 public function __construct()
 {
     $this->bootstrap = true;
     $this->className = 'Configuration';
     $this->table = 'configuration';
     parent::__construct();
     // Prevent classes which extend AdminPreferences to load useless data
     if (get_class($this) == 'AdminPreferencesController') {
         $round_mode = array(array('value' => PS_ROUND_HALF_UP, 'name' => $this->trans('Round up away from zero, when it is half way there (recommended)', array(), 'Admin.ShopParameters.Feature')), array('value' => PS_ROUND_HALF_DOWN, 'name' => $this->trans('Round down towards zero, when it is half way there', array(), 'Admin.ShopParameters.Feature')), array('value' => PS_ROUND_HALF_EVEN, 'name' => $this->trans('Round towards the next even value', array(), 'Admin.ShopParameters.Feature')), array('value' => PS_ROUND_HALF_ODD, 'name' => $this->trans('Round towards the next odd value', array(), 'Admin.ShopParameters.Feature')), array('value' => PS_ROUND_UP, 'name' => $this->trans('Round up to the nearest value', array(), 'Admin.ShopParameters.Feature')), array('value' => PS_ROUND_DOWN, 'name' => $this->trans('Round down to the nearest value', array(), 'Admin.ShopParameters.Feature')));
         $activities1 = array(0 => $this->trans('-- Please choose your main activity --', array(), 'Install'), 2 => $this->trans('Animals and Pets', array(), 'Install'), 3 => $this->trans('Art and Culture', array(), 'Install'), 4 => $this->trans('Babies', array(), 'Install'), 5 => $this->trans('Beauty and Personal Care', array(), 'Install'), 6 => $this->trans('Cars', array(), 'Install'), 7 => $this->trans('Computer Hardware and Software', array(), 'Install'), 8 => $this->trans('Download', array(), 'Install'), 9 => $this->trans('Fashion and accessories', array(), 'Install'), 10 => $this->trans('Flowers, Gifts and Crafts', array(), 'Install'), 11 => $this->trans('Food and beverage', array(), 'Install'), 12 => $this->trans('HiFi, Photo and Video', array(), 'Install'), 13 => $this->trans('Home and Garden', array(), 'Install'), 14 => $this->trans('Home Appliances', array(), 'Install'), 15 => $this->trans('Jewelry', array(), 'Install'), 1 => $this->trans('Lingerie and Adult', array(), 'Install'), 16 => $this->trans('Mobile and Telecom', array(), 'Install'), 17 => $this->trans('Services', array(), 'Install'), 18 => $this->trans('Shoes and accessories', array(), 'Install'), 19 => $this->trans('Sport and Entertainment', array(), 'Install'), 20 => $this->trans('Travel', array(), 'Install'));
         $activities2 = array();
         foreach ($activities1 as $value => $name) {
             $activities2[] = array('value' => $value, 'name' => $name);
         }
         $fields = array('PS_SSL_ENABLED' => array('title' => $this->trans('Enable SSL', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('If you own an SSL certificate for your shop\'s domain name, you can activate SSL encryption (https://) for customer account identification and order processing.', array(), 'Admin.ShopParameters.Help'), 'hint' => $this->trans('If you want to enable SSL on all the pages of your shop, activate the "Enable on all the pages" option below.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'));
         $fields['PS_SSL_ENABLED_EVERYWHERE'] = array('title' => $this->trans('Enable SSL on all pages', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('When enabled, all the pages of your shop will be SSL-secured.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0', 'disabled' => Tools::getValue('PS_SSL_ENABLED', Configuration::get('PS_SSL_ENABLED')) ? false : true);
         $fields = array_merge($fields, array('PS_TOKEN_ENABLE' => array('title' => $this->trans('Increase front office security', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Enable or disable token in the Front Office to improve PrestaShop\'s security.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0', 'visibility' => Shop::CONTEXT_ALL), 'PS_ALLOW_HTML_IFRAME' => array('title' => $this->trans('Allow iframes on HTML fields', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Allow iframes on text fields like product description. We recommend that you leave this option disabled.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_USE_HTMLPURIFIER' => array('title' => $this->trans('Use HTMLPurifier Library', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Clean the HTML content on text fields. We recommend that you leave this option enabled.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_PRICE_ROUND_MODE' => array('title' => $this->trans('Round mode', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('You can choose among 6 different ways of rounding prices. "Round up away from zero ..." is the recommended behavior.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $round_mode, 'identifier' => 'value'), 'PS_ROUND_TYPE' => array('title' => $this->trans('Round type', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('You can choose when to round prices: either on each item, each line or the total (of an invoice, for example).', array(), 'Admin.ShopParameters.Help'), 'cast' => 'intval', 'type' => 'select', 'list' => array(array('name' => $this->trans('Round on each item', array(), 'Admin.ShopParameters.Feature'), 'id' => Order::ROUND_ITEM), array('name' => $this->trans('Round on each line', array(), 'Admin.ShopParameters.Feature'), 'id' => Order::ROUND_LINE), array('name' => $this->trans('Round on the total', array(), 'Admin.ShopParameters.Feature'), 'id' => Order::ROUND_TOTAL)), 'identifier' => 'id'), 'PS_PRICE_DISPLAY_PRECISION' => array('title' => $this->trans('Number of decimals', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Choose how many decimals you want to display', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text', 'class' => 'fixed-width-xxl'), 'PS_DISPLAY_SUPPLIERS' => array('title' => $this->trans('Display brands and suppliers', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Enable brands and suppliers pages on your front office even when their respective modules are disabled.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_DISPLAY_BEST_SELLERS' => array('title' => $this->trans('Display best sellers', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Enable best sellers page on your front office even when its respective module is disabled.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_MULTISHOP_FEATURE_ACTIVE' => array('title' => $this->trans('Enable Multistore', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('The multistore feature allows you to manage several e-shops with one Back Office. If this feature is enabled, a "Multistore" page will be available in the "Advanced Parameters" menu.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_ALL), 'PS_SHOP_ACTIVITY' => array('title' => $this->trans('Main Shop Activity', array(), 'Admin.ShopParameters.Feature'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $activities2, 'identifier' => 'value')));
         // No HTTPS activation if you haven't already.
         if (!Tools::usingSecureMode() && !Configuration::get('PS_SSL_ENABLED')) {
             $fields['PS_SSL_ENABLED']['type'] = 'disabled';
             $fields['PS_SSL_ENABLED']['disabled'] = '<a class="btn btn-link" href="https://' . Tools::getShopDomainSsl() . Tools::safeOutput($_SERVER['REQUEST_URI']) . '">' . $this->trans('Please click here to check if your shop supports HTTPS.', array(), 'Admin.ShopParameters.Feature') . '</a>';
         }
         $this->fields_options = array('general' => array('title' => $this->trans('General', array(), 'Admin.Global'), 'icon' => 'icon-cogs', 'fields' => $fields, 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions'))));
     }
 }
Example #28
0
 public function renderForm()
 {
     $fields_form = array('form' => array('legend' => array('title' => $this->l('Homepage categories'), 'icon' => ''), 'input' => array(array('type' => 'cat_choice', 'label' => '', 'name' => 'cats')), 'submit' => array('name' => 'submitBlockhomecats', 'title' => $this->l('Save'))));
     $lang = $this->context->language;
     if ($selectedCats = Configuration::get('MOD_BLOCKHOMECATS_CATS')) {
         $selectedCats = explode(',', $selectedCats);
         foreach ($selectedCats as $index => $id_category) {
             $selectedCats[$index] = new Category($id_category, $this->context->language->id);
         }
     } else {
         $selectedCats = null;
     }
     $helper = new HelperForm();
     $helper->show_toolbar = false;
     $helper->default_form_language = $lang->id;
     $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
     $helper->module = $this;
     $helper->identifier = 'id_blocklink';
     $helper->submit_action = 'submit';
     $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name;
     $helper->token = Tools::getAdminTokenLite('AdminModules');
     $helper->fields_value = array('text' => 'text');
     $categories = Category::getNestedCategories(2, $this->context->language->id, false);
     $helper->tpl_vars = array('allCats' => $this->getAllCats(current($categories)), 'selectedCats' => $selectedCats);
     return $helper->generateForm(array($fields_form));
 }
 private function detail()
 {
     $nav = new navModel();
     $article = new articleModel();
     $product = new productModel();
     if (isset($_GET['id']) && !empty($_GET['id'])) {
         //Tools::dump($_GET);
         $article->id = $_GET['id'];
         $article->updateArticle();
         $oneArticle = $article->getOneArticle();
         $product->cid = $oneArticle->cid;
         //Tools::dump($product->cid);
         //Tools::dump($product->getAllProductsByCID());
         $this->smarty->assign("oneArticle", $oneArticle);
         $nav->id = $oneArticle->nid;
         $subNav = $nav->getOneNav();
         $this->smarty->assign("subNav", $subNav);
         $nav->id = $subNav->pid;
         $mainNav = $nav->getOneNav();
         $this->smarty->assign("mainNav", $mainNav);
         $this->smarty->assign("recommend", $product->getAllProductsByCID());
         //Tools::dump($mainNav);
     } else {
         Tools::Redirect("", "home.php");
     }
 }
  public function hookAdminStatsModules($params)
  {
      if (Module::isInstalled('blocknewsletter')) {
          $totals = $this->getTotals();
          if (Tools::getValue('export')) {
              $this->csvExport(array('type' => 'line', 'layers' => 3));
          }
          $this->_html = '
	<div class="panel-heading">
		' . $this->displayName . '
	</div>
	<div class="row row-margin-bottom">
		<div class="col-lg-12">
			<div class="col-lg-8">
				' . $this->engine(array('type' => 'line', 'layers' => 3)) . '
			</div>
			<div class="col-lg-4">
				<ul class="list-unstyled">
					<li>' . $this->l('Customer registrations:') . ' ' . (int) $totals['customers'] . '</li>
					<li>' . $this->l('Visitor registrations: ') . ' ' . (int) $totals['visitors'] . '</li>
					<li>' . $this->l('Both:') . ' ' . (int) $totals['both'] . '</li>
				</ul>
				<hr/>
				<a class="btn btn-default export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI'] . '&export=1') . '">
					<i class="icon-cloud-upload"></i> ' . $this->l('CSV Export') . '
				</a>
			</div>
		</div>
	</div>';
      } else {
          $this->_html = '<p>' . $this->l('The "Newsletter block" module must be installed.') . '</p>';
      }
      return $this->_html;
  }