public function setStatus($status)
 {
     if (Validate::isInt($status)) {
         $this->status = $status;
     }
     return $this;
 }
Beispiel #2
0
 public function getContent()
 {
     $this->_html = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitUpdate')) {
         if (Tools::getValue('STORE_DELIVERY_SEND_MAIL') !== false && Validate::isBool(Tools::getValue('STORE_DELIVERY_SEND_MAIL'))) {
             Configuration::updateValue('STORE_DELIVERY_SEND_MAIL', Tools::getValue('STORE_DELIVERY_SEND_MAIL'));
         }
         if (Tools::getValue('STORE_DELIVERY_CARRIER') != false && Validate::isInt(Tools::getValue('STORE_DELIVERY_CARRIER'))) {
             Configuration::updateValue('STORE_DELIVERY_CARRIER', Tools::getValue('STORE_DELIVERY_CARRIER'));
             $carrierObj = new Carrier((int) Tools::getValue('STORE_DELIVERY_CARRIER'));
             Configuration::updateValue('STORE_DELIVERY_CARRIER_REFERENCE', $carrierObj->id_reference);
         }
         if (Tools::getValue('STORE_DELIVERY_DISPLAY_MAP') !== false && Validate::isBool(Tools::getValue('STORE_DELIVERY_DISPLAY_MAP'))) {
             Configuration::updateValue('STORE_DELIVERY_DISPLAY_MAP', Tools::getValue('STORE_DELIVERY_DISPLAY_MAP'));
         }
         if (Tools::getValue('STORE_DELIVERY_HEIGHT_MAP') !== false && Validate::isString(Tools::getValue('STORE_DELIVERY_HEIGHT_MAP'))) {
             Configuration::updateValue('STORE_DELIVERY_HEIGHT_MAP', Tools::getValue('STORE_DELIVERY_HEIGHT_MAP'));
         }
         if (Tools::getValue('STORE_DELIVERY_WIDTH_MAP') !== false && Validate::isString(Tools::getValue('STORE_DELIVERY_WIDTH_MAP'))) {
             Configuration::updateValue('STORE_DELIVERY_WIDTH_MAP', Tools::getValue('STORE_DELIVERY_WIDTH_MAP'));
         }
         if (!Validate::isBool(Tools::getValue('STORE_DELIVERY_SEND_MAIL')) || !Validate::isInt(Tools::getValue('STORE_DELIVERY_CARRIER')) || !Validate::isBool(Tools::getValue('STORE_DELIVERY_DISPLAY_MAP')) || !Validate::isString(Tools::getValue('STORE_DELIVERY_HEIGHT_MAP')) || !Validate::isString(Tools::getValue('STORE_DELIVERY_WIDTH_MAP'))) {
             $this->_html .= '<div class="alert">' . $this->l('Error! An information is invalid') . '</div>';
         }
     }
     return $this->_displayForm();
 }
Beispiel #3
0
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_currency']) && Validate::isInt($filter['id_currency'])) {
            $where .= ' AND a.`id_currency`=' . intval($filter['id_currency']);
        }
        if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND a.`name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (!empty($filter['active']) && Validate::isInt($filter['active'])) {
            $where .= ' AND a.`active`=' . ((int) $filter['active'] == 1 ? '1' : '0');
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_currency` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'currency` a
				WHERE 1
				' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.* FROM `' . DB_PREFIX . 'currency` a
				WHERE 1
				' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => $result);
        return $rows;
    }
Beispiel #4
0
    public static function getRule($active = true, $p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        if (!Validate::isBool($active)) {
            die(Tools::displayError());
        }
        $where = '';
        if (!empty($filter['id_rule']) && Validate::isInt($filter['id_rule'])) {
            $where .= ' AND a.`id_rule`=' . intval($filter['id_rule']);
        }
        if (!empty($filter['entity']) && Validate::isCatalogName($filter['entity'])) {
            $where .= ' AND a.`entity` LIKE "%' . pSQL($filter['entity']) . '%"';
        }
        if (!empty($filter['rule_link']) && Validate::isCatalogName($filter['rule_link'])) {
            $where .= ' AND a.`rule_link` LIKE "%' . pSQL($filter['rule_link']) . '%"';
        }
        if (!empty($filter['id_entity']) && Validate::isInt($filter['id_entity'])) {
            $where .= ' AND a.`id_entity`=' . (int) $filter['id_entity'];
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `position` ASC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'rule` a
				WHERE 1 ' . $where);
        $result = Db::getInstance()->getAll('SELECT * FROM `' . DB_PREFIX . 'rule` a
				WHERE 1 ' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'rules' => $result);
        return $rows;
    }
Beispiel #5
0
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitBlockRss')) {
         $urlfeed = strval(Tools::getValue('urlfeed'));
         $title = strval(Tools::getValue('title'));
         $nbr = intval(Tools::getValue('nbr'));
         if ($urlfeed and !Validate::isUrl($urlfeed)) {
             $errors[] = $this->l('Invalid feed URL');
         } elseif (!$title or empty($title) or !Validate::isGenericName($title)) {
             $errors[] = $this->l('Invalid title');
         } elseif (!$nbr or $nbr <= 0 or !Validate::isInt($nbr)) {
             $errors[] = $this->l('Invalid number of feeds');
         } else {
             Configuration::updateValue('RSS_FEED_URL', $urlfeed);
             Configuration::updateValue('RSS_FEED_TITLE', $title);
             Configuration::updateValue('RSS_FEED_NBR', $nbr);
         }
         if (isset($errors) and sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $output . $this->displayForm();
 }
 public static function isItemsOrder($value)
 {
     $str_error = Tools::displayError('For the items');
     foreach ($value as $key => $item) {
         $str_error .= ' ' . $key . ' ';
         $str_error .= isset($item['name']) ? $item['name'] . ' ' : '';
         $str_error .= ' :';
         if (isset($item['total_ht']) && !Validate::isFloat($item['total_ht'])) {
             throw new TwengaFieldsException($str_error . Tools::displayError('The total HT must be a float value.'));
         }
         if (isset($item['quantity']) && !Validate::isInt($item['quantity'])) {
             throw new TwengaFieldsException($str_error . Tools::displayError('The quantity must be a integer value.'));
         }
         if (isset($item['sku']) && !is_string($item['sku']) && strlen($item['sku']) > 40) {
             throw new TwengaFieldsException($str_error . Tools::displayError('The sku must be a string with length less than 40 chars.'));
         }
         if (isset($item['name']) && !is_string($item['name'])) {
             throw new TwengaFieldsException($str_error . Tools::displayError('The name must be a string with length less than 100 chars.'));
         }
         if (isset($item['category_name']) && !is_string($item['category_name'])) {
             throw new TwengaFieldsException($str_error . Tools::displayError('The category name must be a string with length less than 100 chars.'));
         }
     }
     return true;
 }
Beispiel #7
0
 public function getContent()
 {
     $output = '';
     $errors = array();
     if (Tools::isSubmit('submitHomeFeatured')) {
         $nbr = Tools::getValue('HOME_FEATURED_NBR');
         if (!Validate::isInt($nbr) || $nbr <= 0) {
             $errors[] = $this->l('The number of products is invalid. Please enter a positive number.');
         }
         $cat = Tools::getValue('HOME_FEATURED_CAT');
         if (!Validate::isInt($cat) || $cat <= 0) {
             $errors[] = $this->l('The category ID is invalid. Please choose an existing category ID.');
         }
         $rand = Tools::getValue('HOME_FEATURED_RANDOMIZE');
         if (!Validate::isBool($rand)) {
             $errors[] = $this->l('Invalid value for the "randomize" flag.');
         }
         if (isset($errors) && count($errors)) {
             $output = $this->displayError(implode('<br />', $errors));
         } else {
             Configuration::updateValue('HOME_FEATURED_NBR', (int) $nbr);
             Configuration::updateValue('HOME_FEATURED_CAT', (int) $cat);
             Configuration::updateValue('HOME_FEATURED_RANDOMIZE', (bool) $rand);
             Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('homefeatured.tpl'));
             $output = $this->displayConfirmation($this->l('Your settings have been updated.'));
         }
     }
     return $output . $this->renderForm();
 }
Beispiel #8
0
 function processOrderStep($params)
 {
     global $cart, $smarty, $errors, $isVirtualCart, $orderTotal;
     $cart->recyclable = (isset($_POST['recyclable']) and !empty($_POST['recyclable'])) ? 1 : 0;
     if (isset($_POST['gift']) and !empty($_POST['gift'])) {
         if (!Validate::isMessage($_POST['gift_message'])) {
             $errors[] = Tools::displayError('invalid gift message');
         } else {
             $cart->gift = 1;
             $cart->gift_message = strip_tags($_POST['gift_message']);
         }
     } else {
         $cart->gift = 0;
     }
     $address = new Address(intval($cart->id_address_delivery));
     if (!Validate::isLoadedObject($address)) {
         die(Tools::displayError());
     }
     if (!($id_zone = Address::getZoneById($address->id))) {
         $errors[] = Tools::displayError('no zone match with your address');
     }
     if (isset($_POST['id_carrier']) and Validate::isInt($_POST['id_carrier']) and sizeof(Carrier::checkCarrierZone(intval($_POST['id_carrier']), intval($id_zone)))) {
         $cart->id_carrier = intval($_POST['id_carrier']);
     } elseif (!$isVirtualCart) {
         $errors[] = Tools::displayError('invalid carrier or no carrier selected');
     }
     Module::hookExec('extraCarrierDetailsProcess', array('carrier' => new Carrier($cart->id_carrier)));
     $cart->update();
 }
 public function postProcess()
 {
     if (Tools::isSubmit('submitAddconfiguration')) {
         $themeName = $this->_getThemeName();
         $modes = getSliderModes();
         $sliders = getSliders();
         foreach ($sliders as $sliderName => $sliderCaption) {
             foreach ($modes as $modeName => $modeCaption) {
                 $name = getSliderSettingsName($themeName, $sliderName, $modeName);
                 $value = Tools::getValue($name, '');
                 if (Validate::isInt($value) || empty($value)) {
                     $value = empty($value) ? '' : $value;
                     Configuration::updateValue($name, $value);
                 } else {
                     $this->errors[] = $this->l('Invalid value for slider "' . $sliderCaption . '" in "' . $modeCaption . '" mode');
                 }
             }
         }
         $sourceTemplates = getTemplates();
         foreach ($sourceTemplates as $type => $caption) {
             $name = getTemplateName($themeName, $type);
             $value = Tools::getValue($name, '');
             Configuration::updateValue($name, $value);
         }
         if (!count($this->errors)) {
             $this->confirmations[] = $this->l('The settings have been updated.');
         }
     }
     return parent::postProcess();
 }
Beispiel #10
0
 public function getContent()
 {
     $output = '';
     $errors = array();
     if (Tools::isSubmit('submitBlockTags')) {
         $tagsNbr = Tools::getValue('BLOCKTAGS_NBR');
         if (!strlen($tagsNbr)) {
             $errors[] = $this->l('Please complete the "Displayed tags" field.');
         } elseif (!Validate::isInt($tagsNbr) || (int) $tagsNbr <= 0) {
             $errors[] = $this->l('Invalid number.');
         }
         $tagsLevels = Tools::getValue('BLOCKTAGS_MAX_LEVEL');
         if (!strlen($tagsLevels)) {
             $errors[] = $this->l('Please complete the "Tag levels" field.');
         } elseif (!Validate::isInt($tagsLevels) || (int) $tagsLevels <= 0) {
             $errors[] = $this->l('Invalid value for "Tag levels". Choose a positive integer number.');
         }
         $randomize = Tools::getValue('BLOCKTAGS_RANDOMIZE');
         if (!strlen($randomize)) {
             $errors[] = $this->l('Please complete the "Randomize" field.');
         } elseif (!Validate::isBool($randomize)) {
             $errors[] = $this->l('Invalid value for "Randomize". It has to be a boolean.');
         }
         if (count($errors)) {
             $output = $this->displayError(implode('<br />', $errors));
         } else {
             Configuration::updateValue('BLOCKTAGS_NBR', (int) $tagsNbr);
             Configuration::updateValue('BLOCKTAGS_MAX_LEVEL', (int) $tagsLevels);
             Configuration::updateValue('BLOCKTAGS_RANDOMIZE', (bool) $randomize);
             $output = $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $output . $this->renderForm();
 }
Beispiel #11
0
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_onepage']) && Validate::isInt($filter['id_onepage'])) {
            $where .= ' AND a.`id_onepage`=' . intval($filter['id_onepage']);
        }
        if (!empty($filter['view_name']) && Validate::isEntityName($filter['view_name'])) {
            $where .= ' AND a.`view_name` LIKE "%' . pSQL($filter['view_name']) . '%"';
        }
        if (!empty($filter['meta_title']) && Validate::isGenericName($filter['meta_title'])) {
            $where .= ' AND a.`meta_title` LIKE "%' . pSQL($filter['meta_title']) . '%"';
        }
        if (!empty($filter['rewrite']) && Validate::isLinkRewrite($filter['rewrite'])) {
            $where .= ' AND a.`rewrite` LIKE "%' . pSQL($filter['rewrite']) . '%"';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_onepage` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'onepage` a
				WHERE 1 ' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.* FROM `' . DB_PREFIX . 'onepage` a
				WHERE 1 ' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => $result);
        return $rows;
    }
 public function setRootCategory($value)
 {
     if (!Validate::isInt($value)) {
         throw new PrestaShopException('Root category must be an integer value');
     }
     $this->_root_category = $value;
     return $this;
 }
 private function setLanguage()
 {
     if (isset($_GET['language']) and Validate::isInt($_GET['language'])) {
         $id_lang = intval($_GET['language']);
     }
     if (!isset($id_lang)) {
         $id_lang = $this->getIdByHAL();
     }
     $this->lang = $this->xml_file->lang[intval($id_lang)];
 }
Beispiel #14
0
 /**
  * 更新考试结果计算的状态
  * @param   int|array $id        需要更新的考试记录
  * @param   int       $status    更新的状态
  * @return  boolean
  */
 public static function updateCalculateExamResultStatus($id, $status)
 {
     if (!$id || !is_array($id) && !Validate::isInt($id)) {
         return false;
     }
     if (is_array($id)) {
         $where = "id IN (" . implode(',', $id) . ")";
     } else {
         $where = "id = {$id}";
     }
     return Fn::db()->update("rd_cron_task_exam_result", array('status' => intval($status)), $where);
 }
Beispiel #15
0
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_order']) && Validate::isInt($filter['id_order'])) {
            $where .= ' AND a.`id_order`=' . intval($filter['id_order']);
        }
        if (!empty($filter['reference']) && Validate::isInt($filter['reference'])) {
            $where .= ' AND a.`reference`=' . intval($filter['reference']);
        }
        if (!empty($filter['payment'])) {
            $where .= ' AND a.`payment` LIKE "%' . pSQL($filter['payment']) . '%"';
        }
        if (!empty($filter['id_cart']) && Validate::isCatalogName($filter['id_cart'])) {
            $where .= ' AND a.`id_cart` = ' . intval($filter['id_cart']);
        }
        if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
            $where .= ' AND u.`name` LIKE "%' . pSQL($filter['name']) . '%"';
        }
        if (!empty($filter['email']) && Validate::isInt($filter['email'])) {
            $where .= ' AND a.`email` LIKE "%' . pSQL($filter['email']) . '%"';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_order` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'order` a
				LEFT JOIN `' . DB_PREFIX . 'user` u ON (a.id_user = u.id_user)
				LEFT JOIN `' . DB_PREFIX . 'carrier` c ON (a.id_carrier = c.id_carrier)
				LEFT JOIN `' . DB_PREFIX . 'order_status` os ON (os.id_order_status = a.id_order_status)
				WHERE 1
				' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.*, m.name AS `payment`, u.name, c.name as carrier, os.name as status, os.color
				FROM `' . DB_PREFIX . 'order` a
				LEFT JOIN `' . DB_PREFIX . 'user` u ON (a.id_user = u.id_user)
				LEFT JOIN `' . DB_PREFIX . 'module` m ON (a.id_module = m.id_module)
				LEFT JOIN `' . DB_PREFIX . 'carrier` c ON (a.id_carrier = c.id_carrier)
				LEFT JOIN `' . DB_PREFIX . 'order_status` os ON (os.id_order_status = a.id_order_status)
				WHERE 1 
				' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => $result);
        return $rows;
    }
 protected function postImage($id)
 {
     if (isset($this->fieldImageSettings['name']) && isset($this->fieldImageSettings['dir'])) {
         if (!Validate::isInt(Tools::getValue('img_width')) || !Validate::isInt(Tools::getValue('img_height'))) {
             $this->errors[] = Tools::displayError('Width and height must be numeric values.');
         } else {
             if ((int) Tools::getValue('img_width') > 0 && (int) Tools::getValue('img_height') > 0) {
                 $width = (int) Tools::getValue('img_width');
                 $height = (int) Tools::getValue('img_height');
             } else {
                 $width = null;
                 $height = null;
             }
             return $this->uploadImage($id, $this->fieldImageSettings['name'], $this->fieldImageSettings['dir'] . '/', false, $width, $height);
         }
     }
     return !count($this->errors) ? true : false;
 }
Beispiel #17
0
 public function getContent()
 {
     $output = '';
     if (Tools::isSubmit('submitHomeFeatured')) {
         $nbr = (int) Tools::getValue('HOME_FEATURED_NBR');
         if (!$nbr or $nbr <= 0 or !Validate::isInt($nbr)) {
             $errors[] = $this->l('An invalid number of products has been specified.');
         } else {
             Configuration::updateValue('HOME_FEATURED_NBR', (int) $nbr);
         }
         if (isset($errors) and sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Your settings have been updated.'));
         }
     }
     return $output . $this->renderForm();
 }
Beispiel #18
0
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitHomeFeatured')) {
         $nbr = (int) Tools::getValue('nbr');
         if (!$nbr or $nbr <= 0 or !Validate::isInt($nbr)) {
             $errors[] = $this->l('Invalid number of products');
         } else {
             Configuration::updateValue('HOME_FEATURED_NBR', (int) $nbr);
         }
         if (isset($errors) and sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $output . $this->displayForm();
 }
    public static function getTransactions($idCart = null, $idDevice = null, $ipAddress = null)
    {
        $sql = '
			SELECT `' . self::$definition['primary'] . '` 
			FROM `' . _DB_PREFIX_ . self::$definition['table'] . '` 
			WHERE 1 ';
        if ($idCart && Validate::isInt($idCart)) {
            $sql .= ' AND `id_cart` = "' . $idCart . '" ';
        }
        if ($idDevice && Validate::isInt($idDevice)) {
            $sql .= ' AND `id_device` = "' . $idDevice . '" ';
        }
        if ($ipAddress && Validate::isInt($ipAddress)) {
            $sql .= ' AND `ip_address` = "' . $ipAddress . '" ';
        }
        $results = Db::getInstance()->ExecuteS($sql);
        return $results;
    }
Beispiel #20
0
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitBlockRss')) {
         $errors = array();
         $urlfeed = Tools::getValue('urlfeed');
         $title = Tools::getValue('title');
         $nbr = (int) Tools::getValue('nbr');
         if ($urlfeed and !Validate::isAbsoluteUrl($urlfeed)) {
             $errors[] = $this->l('Invalid feed URL');
         } elseif (!$title or empty($title) or !Validate::isGenericName($title)) {
             $errors[] = $this->l('Invalid title');
         } elseif (!$nbr or $nbr <= 0 or !Validate::isInt($nbr)) {
             $errors[] = $this->l('Invalid number of feeds');
         } elseif (stristr($urlfeed, $_SERVER['HTTP_HOST'] . __PS_BASE_URI__)) {
             $errors[] = $this->l('You have selected a feed URL on your own website. Please choose another URL');
         } elseif (!($contents = Tools::file_get_contents($urlfeed))) {
             $errors[] = $this->l('Feed is unreachable, check your URL');
         } else {
             try {
                 $xmlFeed = new XML_Feed_Parser($contents);
             } catch (XML_Feed_Parser_Exception $e) {
                 $errors[] = $this->l('Invalid feed:') . ' ' . $e->getMessage();
             }
         }
         if (!sizeof($errors)) {
             Configuration::updateValue('RSS_FEED_URL', $urlfeed);
             Configuration::updateValue('RSS_FEED_TITLE', $title);
             Configuration::updateValue('RSS_FEED_NBR', $nbr);
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         } else {
             $output .= $this->displayError(implode('<br />', $errors));
         }
     } else {
         $errors = array();
         if (stristr(Configuration::get('RSS_FEED_URL'), $_SERVER['HTTP_HOST'] . __PS_BASE_URI__)) {
             $errors[] = $this->l('You have selected a feed URL on your own website. Please choose another URL');
         }
         if (sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         }
     }
     return $output . $this->displayForm();
 }
 public function getContent()
 {
     $output = '';
     $errors = array();
     if (Tools::isSubmit('submitHomeFeatured')) {
         $nbr = (int) Tools::getValue('HOME_FEATURED_NBR');
         if (!$nbr || $nbr <= 0 || !Validate::isInt($nbr)) {
             $errors[] = $this->l('An invalid number of products has been specified.');
         } else {
             Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('homefeatured.tpl'));
             Configuration::updateValue('HOME_FEATURED_NBR', (int) $nbr);
         }
         if (isset($errors) && count($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Your settings have been updated.'));
         }
     }
     return $output . $this->renderForm();
 }
 public static function getPaypalLoginUsers($id_paypal_login_user = false, $id_customer = false, $refresh_token = false)
 {
     $sql = "\n\t\t\tSELECT `id_paypal_login_user` \n\t\t\tFROM `" . _DB_PREFIX_ . "paypal_login_user`\n\t\t\tWHERE 1\n\t\t";
     if ($id_paypal_login_user && Validate::isInt($id_paypal_login_user)) {
         $sql .= " AND `id_paypal_login_user` = '" . (int) $id_paypal_login_user . "' ";
     }
     if ($id_customer && Validate::isInt($id_customer)) {
         $sql .= " AND `id_customer` = '" . (int) $id_customer . "' ";
     }
     if ($refresh_token) {
         $sql .= " AND `refresh_token` = '" . $refresh_token . "' ";
     }
     $results = DB::getInstance()->executeS($sql);
     $logins = array();
     if ($results && count($results)) {
         foreach ($results as $result) {
             $logins[$result['id_paypal_login_user']] = new PaypalLoginUser((int) $result['id_paypal_login_user']);
         }
     }
     return $logins;
 }
Beispiel #23
0
    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_cms']) && Validate::isInt($filter['id_cms'])) {
            $where .= ' AND a.`id_cms`=' . intval($filter['id_cms']);
        }
        if (!empty($filter['title']) && Validate::isCatalogName($filter['title'])) {
            $where .= ' AND a.`title` LIKE "%' . pSQL($filter['title']) . '%"';
        }
        if (!empty($filter['rewrite']) && Validate::isCatalogName($filter['rewrite'])) {
            $where .= ' AND a.`rewrite` LIKE "%' . pSQL($filter['rewrite']) . '%"';
        }
        if (!empty($filter['active']) && Validate::isInt($filter['active'])) {
            $where .= ' AND a.`active`=' . ((int) $filter['active'] == 1 ? '1' : '0');
        }
        if (!empty($filter['is_top']) && Validate::isInt($filter['is_top'])) {
            $where .= ' AND a.`is_top`=' . ((int) $filter['is_top'] == 1 ? '1' : '0');
        }
        if (!empty($filter['id_cms_category']) && Validate::isInt($filter['id_cms_category']) && $filter['id_cms_category'] > 1) {
            $where .= ' AND a.`id_cms` IN (SELECT `id_cms` FROM `' . DB_PREFIX . 'cms_to_category` WHERE `id_cms_category`=' . intval($filter['id_cms_category']) . ')';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_cms` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'cms` a
				WHERE 1
				' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT * FROM `' . DB_PREFIX . 'cms` a
				WHERE 1
				' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => self::resetCMS($result));
        return $rows;
    }
 public function postProcess()
 {
     if (Tools::isSubmit('submitOrderNumber')) {
         if (!Validate::isInt($this->number_from)) {
             $this->errors[] = $this->l('Invalid "From" number');
         }
         if (!Validate::isInt($this->number_to)) {
             $this->errors[] = $this->l('Invalid "To" number');
         }
         if (!count($this->errors)) {
             $invoices = $this->getByNumberInterval($this->number_from, $this->number_to);
             if (count($invoices)) {
                 //generate XML
                 $this->generateCSV($invoices);
             } else {
                 $this->errors[] = $this->l('No invoice has been found for this period.');
             }
         }
     } else {
         parent::postProcess();
     }
 }
 public function getContent()
 {
     $output = '';
     $slider = '';
     $errors = array();
     if (Tools::isSubmit('submittmfeatureproducts')) {
         $nbr = (int) Tools::getValue('HOME_FEATURED_NBR_TM');
         $slider = (int) Tools::getValue('HOME_FEATURED_SLIDER');
         if (!$nbr || $nbr <= 0 || !Validate::isInt($nbr)) {
             $errors[] = $this->l('An invalid number of products has been specified.');
         } else {
             Configuration::updateValue('HOME_FEATURED_NBR_TM', (int) $nbr);
             Configuration::updateValue('HOME_FEATURED_SLIDER', (int) $slider);
         }
         if (isset($errors) && count($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Your settings have been updated.'));
         }
     }
     return $output . $this->renderForm();
 }
Beispiel #26
0
 public function __construct($name = null, $context = null)
 {
     $this->name = 'swipp';
     $this->tab = 'payments_gateways';
     $this->version = '0.2';
     $this->author = 'Christian Jensen';
     $this->controllers = array('payment', 'validation');
     $this->currencies = true;
     $this->currencies_mode = 'checkbox';
     $this->is_eu_compatible = 1;
     $this->bootstrap = true;
     parent::__construct($name, $context instanceof Context ? $context : NULL);
     $this->displayName = 'Swipp';
     $this->description = $this->l('Accept payments for your products via swipp transfer.');
     $this->confirmUninstall = $this->l('Are you sure about removing these details?');
     $this->SwippPhone = Configuration::get('SWIPP_PHONE');
     $this->SwippOwner = Configuration::get('SWIPP_OWNER');
     $this->_html = "";
     if (!isset($this->SwippPhone) || empty($this->SwippPhone)) {
         $this->warning .= (!empty($this->warning) ? '<br/>' : '') . $this->l('Swipp phone number must be configured before using this module.');
     }
     if (!isset($this->SwippOwner) || empty($this->SwippOwner)) {
         $this->warning .= (!empty($this->warning) ? '<br/>' : '') . $this->l('Swipp owner/user must be configured before using this module.');
     }
     $this->extra_mail_vars = array('{swipp_phone}' => $this->SwippPhone, '{swipp_owner}' => $this->SwippOwner);
     $this->_active = $this->active;
     $dkkC_id = Currency::getIdByIsoCode('DKK');
     if (Validate::isInt($dkkC_id)) {
         $dkkC = new Currency($dkkC_id);
         if ($dkkC->id != $dkkC_id || $dkkC->iso_code_num != 208) {
             $this->_active = false;
         } else {
             $this->_active = $dkkC->active;
         }
     } else {
         $this->_active = false;
     }
 }
 public function getContent()
 {
     $errors = array();
     $this->_html = '<h2>' . $this->displayName . '</h2>';
     /* Update values in DB */
     if (Tools::isSubmit('submitExportCSV')) {
         $send_copy = (int) Tools::getValue('send_copy');
         $email = (string) Tools::getValue('email');
         if (!Validate::isInt($send_copy) || !Validate::isString($email)) {
             $errors[] = $this->l('Invalid data');
         } else {
             Configuration::updateValue('PS_SCE_SEND_COPY', $send_copy);
             Configuration::updateValue('PS_SCE_EMAIL', $email);
         }
         if (isset($errors) && count($errors)) {
             $this->_html .= $this->displayError(implode('<br />', $errors));
         } else {
             $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     $this->displayForm();
     return $this->_html;
 }
 /**
  * 获取模板列表
  * @param   array   $param
  * @param   int     $page
  * @param   int     $perpage
  * @return  void
  */
 public static function get_evaluate_template_list($param = array(), $page = null, $perpage = null)
 {
     $sql = "SELECT * FROM rd_evaluate_template";
     $where = array();
     $bind = array();
     if ($param) {
         if (isset($param['template_type'])) {
             if (Validate::isInt($param['template_type'])) {
                 $where[] = "template_type = " . intval($param['template_type']);
             } else {
                 if (Validate::isJoinedIntStr($param['template_type'])) {
                     $where[] = "template_type IN ( " . $param['template_type'] . ")";
                 }
             }
         }
         if (!empty($param['template_name'])) {
             $where[] = "template_name LIKE ?";
             $bind[] = '%' . $param['template_name'] . '%';
         }
         if (!empty($param['template_subjectid'])) {
             $template_subjectid = $param['template_subjectid'];
             if (is_array($template_subjectid)) {
                 $template_subjectid = implode(',', $template_subjectid);
             }
             $where[] = "template_subjectid LIKE '%,{$template_subjectid},%'";
         }
     }
     if ($where) {
         $sql .= " WHERE " . implode(' AND ', $where);
     }
     $sql .= " ORDER BY template_id DESC";
     if ($page && $perpage) {
         $start = ($page - 1) * $perpage;
         $sql .= " LIMIT {$perpage} OFFSET {$start}";
     }
     return Fn::db()->fetchAll($sql, $bind);
 }
Beispiel #29
0
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitBlockRss')) {
         $urlfeed = strval(Tools::getValue('urlfeed'));
         $title = strval(Tools::getValue('title'));
         $nbr = (int) Tools::getValue('nbr');
         if ($urlfeed and !Validate::isUrl($urlfeed)) {
             $errors[] = $this->l('Invalid feed URL');
         } elseif (!$title or empty($title) or !Validate::isGenericName($title)) {
             $errors[] = $this->l('Invalid title');
         } elseif (!$nbr or $nbr <= 0 or !Validate::isInt($nbr)) {
             $errors[] = $this->l('Invalid number of feeds');
         } else {
             if (stristr($urlfeed, $_SERVER['HTTP_HOST'] . __PS_BASE_URI__)) {
                 $errors[] = $this->l('Error: You have selected a feed URL on your own website. Please choose another URL (eg. http://news.google.com/?output=rss).');
             }
             Configuration::updateValue('RSS_FEED_URL', $urlfeed);
             Configuration::updateValue('RSS_FEED_TITLE', $title);
             Configuration::updateValue('RSS_FEED_NBR', $nbr);
         }
         if (isset($errors) and sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         }
     } else {
         $errors = array();
         if (stristr(Configuration::get('RSS_FEED_URL'), $_SERVER['HTTP_HOST'] . __PS_BASE_URI__)) {
             $errors[] = $this->l('Error: You have selected a feed URL on your own website. Please choose another URL (eg. http://news.google.com/?output=rss).');
         }
         if (sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         }
     }
     return $output . $this->displayForm();
 }
Beispiel #30
0
 private function _postValidation()
 {
     $errors = array();
     /* Validation for Slider configuration */
     if (Tools::isSubmit('submitSlider')) {
         if (!Validate::isInt(Tools::getValue('CATESLIDER_SPEED')) || !Validate::isInt(Tools::getValue('CATESLIDER_PAUSE')) || !Validate::isInt(Tools::getValue('CATESLIDER_WIDTH')) || !Validate::isInt(Tools::getValue('CATESLIDER_HEIGHT'))) {
             $errors[] = $this->l('Invalid values');
         }
     } elseif (Tools::isSubmit('changeStatus')) {
         if (!Validate::isInt(Tools::getValue('id_slide'))) {
             $errors[] = $this->l('Invalid slide');
         }
     } elseif (Tools::isSubmit('submitSlide')) {
         /* Checks state (active) */
         if (!Validate::isInt(Tools::getValue('active_slide')) || Tools::getValue('active_slide') != 0 && Tools::getValue('active_slide') != 1) {
             $errors[] = $this->l('Invalid slide state');
         }
         /* Checks position */
         if (!Validate::isInt(Tools::getValue('position')) || Tools::getValue('position') < 0) {
             $errors[] = $this->l('Invalid slide position');
         }
         /* If edit : checks id_slide */
         if (Tools::isSubmit('id_slide')) {
             if (!Validate::isInt(Tools::getValue('id_slide')) && !$this->slideExists(Tools::getValue('id_slide'))) {
                 $errors[] = $this->l('Invalid id_slide');
             }
         }
         /* Checks title/url/legend/description/image */
         $languages = Language::getLanguages(false);
         foreach ($languages as $language) {
             if (Tools::strlen(Tools::getValue('title_' . $language['id_lang'])) > 255) {
                 $errors[] = $this->l('The title is too long.');
             }
             if (Tools::strlen(Tools::getValue('legend_' . $language['id_lang'])) > 255) {
                 $errors[] = $this->l('The legend is too long.');
             }
             if (Tools::strlen(Tools::getValue('url_' . $language['id_lang'])) > 255) {
                 $errors[] = $this->l('The URL is too long.');
             }
             if (Tools::strlen(Tools::getValue('description_' . $language['id_lang'])) > 4000) {
                 $errors[] = $this->l('The description is too long.');
             }
             if (Tools::strlen(Tools::getValue('url_' . $language['id_lang'])) > 0 && !Validate::isUrl(Tools::getValue('url_' . $language['id_lang']))) {
                 $errors[] = $this->l('The URL format is not correct.');
             }
             if (Tools::getValue('image_' . $language['id_lang']) != null && !Validate::isFileName(Tools::getValue('image_' . $language['id_lang']))) {
                 $errors[] = $this->l('Invalid filename');
             }
             if (Tools::getValue('image_old_' . $language['id_lang']) != null && !Validate::isFileName(Tools::getValue('image_old_' . $language['id_lang']))) {
                 $errors[] = $this->l('Invalid filename');
             }
         }
         /* Checks title/url/legend/description for default lang */
         $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
         if (Tools::strlen(Tools::getValue('title_' . $id_lang_default)) == 0) {
             $errors[] = $this->l('The title is not set.');
         }
         if (Tools::strlen(Tools::getValue('legend_' . $id_lang_default)) == 0) {
             $errors[] = $this->l('The legend is not set.');
         }
         if (Tools::strlen(Tools::getValue('url_' . $id_lang_default)) == 0) {
             $errors[] = $this->l('The URL is not set.');
         }
         if (!Tools::isSubmit('has_picture') && (!isset($_FILES['image_' . $id_lang_default]) || empty($_FILES['image_' . $id_lang_default]['tmp_name']))) {
             $errors[] = $this->l('The image is not set.');
         }
         if (Tools::getValue('image_old_' . $id_lang_default) && !Validate::isFileName(Tools::getValue('image_old_' . $id_lang_default))) {
             $errors[] = $this->l('The image is not set.');
         }
     } elseif (Tools::isSubmit('delete_id_slide') && (!Validate::isInt(Tools::getValue('delete_id_slide')) || !$this->slideExists((int) Tools::getValue('delete_id_slide')))) {
         $errors[] = $this->l('Invalid id_slide');
     }
     /* Display errors if needed */
     if (count($errors)) {
         $this->_html .= $this->displayError(implode('<br />', $errors));
         return false;
     }
     /* Returns if validation is ok */
     return true;
 }