当前位置: 首页>>代码示例>>PHP>>正文


PHP Validate::isUrl方法代码示例

本文整理汇总了PHP中Validate::isUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isUrl方法的具体用法?PHP Validate::isUrl怎么用?PHP Validate::isUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validate的用法示例。


在下文中一共展示了Validate::isUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: logHttpReferer

 public static function logHttpReferer()
 {
     global $cookie;
     if (!isset($cookie->id_connections) or !Validate::isUnsignedId($cookie->id_connections)) {
         return false;
     }
     if (!isset($_SERVER['HTTP_REFERER']) and !Configuration::get('TRACKING_DIRECT_TRAFFIC')) {
         return false;
     }
     $source = new ConnectionsSource();
     if (isset($_SERVER['HTTP_REFERER']) and Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER'])) {
         if (preg_replace('/^www./', '', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)) and !strncmp(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH), parse_url('http://' . Tools::getHttpHost(false, false) . __PS_BASE_URI__, PHP_URL_PATH), strlen(__PS_BASE_URI__))) {
             return false;
         }
         if (Validate::isAbsoluteUrl(strval($_SERVER['HTTP_REFERER']))) {
             $source->http_referer = strval($_SERVER['HTTP_REFERER']);
             $source->keywords = trim(SearchEngine::getKeywords(strval($_SERVER['HTTP_REFERER'])));
             if (!Validate::isMessage($source->keywords)) {
                 return false;
             }
         }
     }
     $source->id_connections = intval($cookie->id_connections);
     $source->request_uri = Tools::getHttpHost(false, false);
     if (isset($_SERVER['REDIRECT_URL'])) {
         $source->request_uri .= strval($_SERVER['REDIRECT_URL']);
     } elseif (isset($_SERVER['REQUEST_URI'])) {
         $source->request_uri .= strval($_SERVER['REQUEST_URI']);
     }
     if (!Validate::isUrl($source->request_uri)) {
         unset($source->request_uri);
     }
     return $source->add();
 }
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:34,代码来源:ConnectionsSource.php

示例2: getContent

 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();
 }
开发者ID:sealence,项目名称:local,代码行数:26,代码来源:blockrss.php

示例3: resolveFile

 /**
  * Resolves an file path for a row
  */
 public function resolveFile($row = array(), $column = '', $default = '')
 {
     if (!empty($column) && array_key_exists($column, $row)) {
         $value = trim($row[$column]);
         if (!empty($value) && Validate::isUrl($row[$column]) !== true) {
             $row[$column] = Server::getBaseUrl($row[$column]);
         }
     }
     return $row;
 }
开发者ID:rainner,项目名称:biscuit-php,代码行数:13,代码来源:Row.php

示例4: testDatabaseSettings

    /**
     * Check database configuration and try a connection
     *
     * @param string $server
     * @param string $database
     * @param string $login
     * @param string $password
     * @param string $prefix
     * @param string $engine
     * @param bool $clear
     * @return array List of errors
     */
    public function testDatabaseSettings($server, $database, $login, $password, $prefix, $clear = false)
    {
        $errors = array();
        // Check if fields are correctly typed
        if (!$server || !Validate::isUrl($server)) {
            $errors[] = $this->language->l('Server name is not valid');
        }
        if (!$database) {
            $errors[] = $this->language->l('You must enter a database name');
        }
        if (!$login) {
            $errors[] = $this->language->l('You must enter a database login');
        }
        if ($prefix && !Validate::isTablePrefix($prefix)) {
            $errors[] = $this->language->l('Tables prefix is invalid');
        }
        if (!$errors) {
            $dbtype = ' (' . Db::getClass() . ')';
            // Try to connect to database
            switch (Db::checkConnection($server, $login, $password, $database, true)) {
                case 0:
                    if (!Db::checkEncoding($server, $login, $password)) {
                        $errors[] = $this->language->l('Cannot convert database data to utf-8') . $dbtype;
                    }
                    // Check if a table with same prefix already exists
                    if (!$clear && Db::hasTableWithSamePrefix($server, $login, $password, $database, $prefix)) {
                        $errors[] = $this->language->l('At least one table with same prefix was already found, please change your prefix or drop your database');
                    }
                    if (!Db::checkAutoIncrement($server, $login, $password)) {
                        $errors[] = $this->language->l('The values of auto_increment increment and offset must be set to 1');
                    }
                    if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix)) !== true) {
                        $errors[] = $this->language->l(sprintf('Your database login does not have the privileges to create table on the database "%s". Ask your hosting provider:', $database));
                        if ($create_error != false) {
                            $errors[] = $create_error;
                        }
                    }
                    break;
                case 1:
                    $errors[] = $this->language->l('Database Server is not found. Please verify the login, password and server fields') . $dbtype;
                    break;
                case 2:
                    $error = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database) . $dbtype;
                    if ($this->createDatabase($server, $database, $login, $password, true)) {
                        $error .= '<p>' . sprintf('<input type="button" value="%s" class="button" id="btCreateDB">', $this->language->l('Attempt to create the database automatically')) . '</p>
						<script type="text/javascript">bindCreateDB();</script>';
                    }
                    $errors[] = $error;
                    break;
            }
        }
        return $errors;
    }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:65,代码来源:database.php

示例5: testDatabaseSettings

 /**
  * Check database configuration and try a connection
  *
  * @param string $server
  * @param string $database
  * @param string $login
  * @param string $password
  * @param string $prefix
  * @param string $engine
  * @param bool $clear
  * @return array List of errors
  */
 public function testDatabaseSettings($server, $database, $login, $password, $prefix, $engine, $clear = false)
 {
     $errors = array();
     // Check if fields are correctly typed
     if (!$server || !Validate::isUrl($server)) {
         $errors[] = $this->language->l('Server name is not valid');
     }
     if (!$database) {
         $errors[] = $this->language->l('You must enter a database name');
     }
     if (!$login) {
         $errors[] = $this->language->l('You must enter a database login');
     }
     if ($prefix && !Validate::isTablePrefix($prefix)) {
         $errors[] = $this->language->l('Tables prefix is invalid');
     }
     if (!Validate::isMySQLEngine($engine)) {
         $errors[] = $this->language->l('Wrong engine chosen for MySQL');
     }
     if (!$errors) {
         $dbtype = ' (' . Db::getClass() . ')';
         // Try to connect to database
         switch (Db::checkConnection($server, $login, $password, $database, true, $engine)) {
             case 0:
                 if (!Db::checkEncoding($server, $login, $password)) {
                     $errors[] = $this->language->l('Cannot convert database data to utf-8') . $dbtype;
                 }
                 // Check if a table with same prefix already exists
                 if (!$clear && Db::hasTableWithSamePrefix($server, $login, $password, $database, $prefix)) {
                     $errors[] = $this->language->l('At least one table with same prefix was already found, please change your prefix or drop your database');
                 }
                 if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix, $engine)) !== true) {
                     $errors[] = $this->language->l(sprintf('Your database login don\'t have the privileges to create table on the database "%s". Ask your hosting provider:', $database));
                     if ($create_error != false) {
                         $errors[] = $create_error;
                     }
                 }
                 break;
             case 1:
                 $errors[] = $this->language->l('Database Server is not found. Please verify the login, password and server fields') . $dbtype;
                 break;
             case 2:
                 $errors[] = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database) . $dbtype;
                 break;
             case 4:
                 $errors[] = $this->language->l('Engine innoDB is not supported by your MySQL server, please use MyISAM') . $dbtype;
                 break;
         }
     }
     return $errors;
 }
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:63,代码来源:database.php

示例6: getContent

 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitBlockRss')) {
         $errors = array();
         $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');
         } 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 = @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();
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:44,代码来源:blockrss.php

示例7: logHttpReferer

 public static function logHttpReferer(Cookie $cookie = null)
 {
     if (!$cookie) {
         $cookie = Context::getContext()->cookie;
     }
     if (!isset($cookie->id_connections) || !Validate::isUnsignedId($cookie->id_connections)) {
         return false;
     }
     // If the referrer is not correct, we drop the connection
     if (isset($_SERVER['HTTP_REFERER']) && !Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER'])) {
         return false;
     }
     // If there is no referrer and we do not want to save direct traffic (as opposed to referral traffic), we drop the connection
     if (!isset($_SERVER['HTTP_REFERER']) && !Configuration::get('TRACKING_DIRECT_TRAFFIC')) {
         return false;
     }
     $source = new ConnectionsSource();
     // There are a few more operations if there is a referrer
     if (isset($_SERVER['HTTP_REFERER'])) {
         // If the referrer is internal (i.e. from your own website), then we drop the connection
         $parsed = parse_url($_SERVER['HTTP_REFERER']);
         $parsed_host = parse_url(Tools::getProtocol() . Tools::getHttpHost(false, false) . __PS_BASE_URI__);
         if (!isset($parsed['host']) || (!isset($parsed['path']) || !isset($parsed_host['path']))) {
             return false;
         }
         if (preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)) && !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__))) {
             return false;
         }
         $source->http_referer = substr($_SERVER['HTTP_REFERER'], 0, ConnectionsSource::$uri_max_size);
         $source->keywords = substr(trim(SearchEngine::getKeywords($_SERVER['HTTP_REFERER'])), 0, ConnectionsSource::$uri_max_size);
     }
     $source->id_connections = (int) $cookie->id_connections;
     $source->request_uri = Tools::getHttpHost(false, false);
     if (isset($_SERVER['REQUEST_URI'])) {
         $source->request_uri .= $_SERVER['REQUEST_URI'];
     } elseif (isset($_SERVER['REDIRECT_URL'])) {
         $source->request_uri .= $_SERVER['REDIRECT_URL'];
     }
     if (!Validate::isUrl($source->request_uri)) {
         $source->request_uri = '';
     }
     $source->request_uri = substr($source->request_uri, 0, ConnectionsSource::$uri_max_size);
     return $source->add();
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:44,代码来源:ConnectionsSource.php

示例8: checkDB

 /**
  * checkDB will call to the 
  * 
  * @param string $srv 
  * @param string $login 
  * @param string $password 
  * @param string $name 
  * @param string $posted 
  * @return void
  */
 public static function checkDB($srv, $login, $password, $name, $posted = true)
 {
     // Don't include theses files if classes are already defined
     if (!class_exists('Validate', false)) {
         include_once INSTALL_PATH . '/../classes/Validate.php';
         eval('class Validate extends ValidateCore{}');
     }
     if (!class_exists('Db', false)) {
         include_once INSTALL_PATH . '/../classes/Db.php';
         eval('abstract class Db extends DbCore{}');
     }
     if (!class_exists('MySQL', false)) {
         include_once INSTALL_PATH . '/../classes/MySQL.php';
         eval('class MySQL extends MySQLCore{}');
     }
     if ($posted) {
         // Check POST data...
         $data_check = array(!isset($_GET['server']) or empty($_GET['server']) or !Validate::isUrl($_GET['server']), !isset($_GET['engine']) or empty($_GET['engine']) or !Validate::isMySQLEngine($_GET['engine']), !isset($_GET['name']) or empty($_GET['name']) or !Validate::isUnixName($_GET['name']), !isset($_GET['login']) or empty($_GET['login']) or !Validate::isUnixName($_GET['login']), !isset($_GET['password']), (!isset($_GET['tablePrefix']) or !Validate::isTablePrefix($_GET['tablePrefix'])) && !empty($_GET['tablePrefix']));
         foreach ($data_check as $data) {
             if ($data) {
                 return 8;
             }
         }
     }
     switch (MySQL::tryToConnect(trim($srv), trim($login), trim($password), trim($name))) {
         case 0:
             if (MySQL::tryUTF8(trim($srv), trim($login), trim($password))) {
                 return true;
             }
             return 49;
             break;
         case 1:
             return 25;
             break;
         case 2:
             return 24;
             break;
         case 3:
             return 50;
             break;
     }
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:52,代码来源:ToolsInstall.php

示例9: run

 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     if ($opt = $arguments->getOpt('list-metas', false)) {
         $this->list_metas();
     } elseif ($arguments->getOpt('show-status', false)) {
         $this->show_status();
     } elseif ($baseUri = $arguments->getOpt('base-uri', null)) {
         if (!Validate::isUrl($baseUri)) {
             echo "Error: '{$baseUri}' is not a valid URI\n";
             exit(1);
         }
         $status = $this->update_base_uri($baseUri);
     } else {
         $arguments->show_command_usage('seo');
         exit(1);
     }
     exit(0);
 }
开发者ID:rodrisan,项目名称:ps-cli,代码行数:20,代码来源:seo.php

示例10: logHttpReferer

 public static function logHttpReferer(Cookie $cookie = null)
 {
     if (!$cookie) {
         $cookie = Context::getContext()->cookie;
     }
     if (!isset($cookie->id_connections) || !Validate::isUnsignedId($cookie->id_connections)) {
         return false;
     }
     if (!isset($_SERVER['HTTP_REFERER']) && !Configuration::get('TRACKING_DIRECT_TRAFFIC')) {
         return false;
     }
     $source = new ConnectionsSource();
     if (isset($_SERVER['HTTP_REFERER']) && Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER'])) {
         $parsed = parse_url($_SERVER['HTTP_REFERER']);
         $parsed_host = parse_url(Tools::getProtocol() . Tools::getHttpHost(false, false) . __PS_BASE_URI__);
         if (preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)) && !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__))) {
             return false;
         }
         if (Validate::isAbsoluteUrl(strval($_SERVER['HTTP_REFERER']))) {
             $source->http_referer = substr(strval($_SERVER['HTTP_REFERER']), 0, ConnectionsSource::$uri_max_size);
             $source->keywords = trim(SearchEngine::getKeywords(strval($_SERVER['HTTP_REFERER'])));
             if (!Validate::isMessage($source->keywords)) {
                 return false;
             }
         }
     }
     $source->id_connections = (int) $cookie->id_connections;
     $source->request_uri = Tools::getHttpHost(false, false);
     if (isset($_SERVER['REDIRECT_URL'])) {
         $source->request_uri .= strval($_SERVER['REDIRECT_URL']);
     } elseif (isset($_SERVER['REQUEST_URI'])) {
         $source->request_uri .= strval($_SERVER['REQUEST_URI']);
     }
     if (!Validate::isUrl($source->request_uri)) {
         $source->request_uri = '';
     }
     $source->request_uri = substr($source->request_uri, 0, ConnectionsSource::$uri_max_size);
     return $source->add();
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:39,代码来源:ConnectionsSource.php

示例11: getContent

 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();
 }
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:37,代码来源:blockrss.php

示例12: dirname

*  @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
require_once dirname(__FILE__) . '/../../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../../init.php';
if (class_exists('SeurLib') == false) {
    include_once _PS_MODULE_DIR_ . 'seur/classes/SeurLib.php';
}
$token = Tools::getValue('token');
$admin_token = Tools::getAdminToken('AdminSeur' . (int) Tab::getIdFromClassName('AdminSeur') . (int) Tools::getValue('id_employee'));
$admin_token_15 = Tools::getAdminToken('AdminSeur15' . (int) Tab::getIdFromClassName('AdminSeur15') . (int) Tools::getValue('id_employee'));
if ($token != $admin_token && $token != $admin_token_15) {
    exit;
}
$back = Tools::getValue('back');
if (!Validate::isUrl($back)) {
    exit;
}
try {
    $sc_options = array('connection_timeout' => 30);
    $soap_client = new SoapClient((string) Configuration::get('SEUR_URLWS_M'), $sc_options);
    $merchant_data = SeurLib::getMerchantData();
    $data = array('in0' => $merchant_data['nif_dni'], 'in1' => $merchant_data['franchise'], 'in2' => $merchant_data['user'], 'in3' => $merchant_data['pass']);
    $response = $soap_client->generacionPDFDetalleNoFecha($data);
    if ($response->out == 'NO SE PUDIERON RECUPERAR DATOS PARA LA GENERACION DEL MANIFIESTO') {
        $url = $back . '&token=' . urlencode(Tools::getValue('token')) . '&codigo=-1&error=' . urlencode((string) $response->out);
        die(Tools::redirectAdmin($url));
    } elseif ($response->out == 'ERROR USUARIO/PASSWORD ERRONEOS') {
        $url = $back . '&token=' . urlencode(Tools::getValue('token')) . '&codigo=-1&error=' . urlencode((string) $response->out);
        die(Tools::redirectAdmin($url));
    } else {
开发者ID:tomideru,项目名称:PrestaShop-modules,代码行数:31,代码来源:createPackingList.php

示例13: getContent

 public function getContent()
 {
     $this->_html = '';
     // Add a link
     if (Tools::isSubmit('submitLinkAdd')) {
         if (Tools::getValue('text_' . Configuration::get('PS_LANG_DEFAULT')) != true || Tools::getValue('url') != true) {
             $this->_html .= $this->displayError($this->l('You must fill in all fields.'));
         } elseif (!Validate::isUrl(str_replace('http://', '', Tools::getValue('url')))) {
             $this->_html .= $this->displayError($this->l('Bad URL'));
         } else {
             if ($this->addLink()) {
                 $this->_html .= $this->displayConfirmation($this->l('The link has been added.'));
             } else {
                 $this->_html .= $this->displayError($this->l('An error occurred during link creation.'));
             }
         }
     } elseif (Tools::isSubmit('submitTitle')) {
         if (Tools::getValue('title_' . Configuration::get('PS_LANG_DEFAULT')) != true) {
             $this->_html .= $this->displayError($this->l('"title" field cannot be empty.'));
         } elseif (!preg_match('/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i', Tools::getValue('title_url')) && !preg_match('/#/', Tools::getValue('title_url'))) {
             $this->_html .= $this->displayError($this->l('The \'URL\' field is invalid'));
         } elseif (!Validate::isGenericName(Tools::getValue('title_' . Configuration::get('PS_LANG_DEFAULT')))) {
             $this->_html .= $this->displayError($this->l('The \'title\' field is invalid'));
         } elseif (!$this->updateTitle()) {
             $this->_html .= $this->displayError($this->l('An error occurred during title updating.'));
         } else {
             $this->_html .= $this->displayConfirmation($this->l('The block title has been updated.'));
         }
     } elseif (Tools::isSubmit('deletetmblocklink1') && Tools::getValue('id')) {
         if (!is_numeric(Tools::getValue('id')) || !$this->deleteLink()) {
             $this->_html .= $this->displayError($this->l('An error occurred during link deletion.'));
         } else {
             $this->_html .= $this->displayConfirmation($this->l('The link has been deleted.'));
         }
     }
     if (Tools::getValue('submitOrderWay') != false) {
         if (Configuration::updateValue('PS_TMBLOCKLINK1_ORDERWAY', (int) Tools::getValue('orderWay'))) {
             $this->_html .= $this->displayConfirmation($this->l('Sort order updated'));
         } else {
             $this->_html .= $this->displayError($this->l('An error occurred during sort order set-up.'));
         }
     }
     $this->_html .= $this->renderForm();
     $this->_html .= $this->renderList();
     return $this->_html;
 }
开发者ID:carloslastresDev,项目名称:HealthyTaiwan_UsingPrestaShop,代码行数:46,代码来源:tmblocklink1.php

示例14: _postProcess

 private function _postProcess()
 {
     global $currentIndex, $cookie;
     if (Tools::isSubmit('submitPayPal')) {
         $template_available = array('A', 'B', 'C');
         if (!Validate::isUnsignedInt(Tools::getValue('payment_method')) or (int) Tools::getValue('payment_method') > 2) {
             $this->_errors[] = $this->l('Invalid solution');
         }
         if (Tools::getValue('email_paypal') == NULL and Tools::getValue('api_username') == NULL and Tools::getValue('api_signature') == NULL) {
             $this->_errors[] = $this->l('Indicate account information.');
         }
         if (Tools::getValue('email_paypal') != NULL and !Validate::isEmail(Tools::getValue('email_paypal'))) {
             $this->_errors[] = $this->l('E-mail invalid');
         }
         if (Tools::getValue('banner_url') != NULL and !Validate::isUrl(Tools::getValue('banner_url'))) {
             $this->_errors[] = $this->l('URL for banner is invalid');
         } elseif (Tools::getValue('banner_url') != NULL and strpos(Tools::getValue('banner_url'), 'https://') === false) {
             $this->_errors[] = $this->l('URL for banner must use HTTPS protocol');
         }
         if (!in_array(Tools::getValue('template_paypal'), $template_available)) {
             $this->_errors[] = $this->l('PayPal template invalid.');
         }
         if (Tools::getValue('paypal_capture') == 1 and (Tools::getValue('api_username') == NULL or Tools::getValue('api_signature') == NULL)) {
             $this->_errors[] = $this->l('Cannot use Authorization / capture without API Credentials.');
         }
         if (Tools::getValue('payment_method') == _PAYPAL_INTEGRAL_EVOLUTION_ and (Tools::getValue('api_username') == NULL or Tools::getValue('api_signature') == NULL)) {
             $this->_errors[] = $this->l('Cannot use this solution without API Credentials.');
         }
         if (Tools::isSubmit('paypal_express') and (Tools::getValue('api_username') == NULL or Tools::getValue('api_signature') == NULL)) {
             $this->_errors[] = $this->l('Cannot use PayPal Express without API Credentials.');
         }
         if (!sizeof($this->_errors)) {
             Configuration::updateValue('PAYPAL_SANDBOX', (int) Tools::getValue('sandbox_mode'));
             Configuration::updateValue('PAYPAL_BUSINESS', trim(Tools::getValue('email_paypal')));
             Configuration::updateValue('PAYPAL_HEADER', Tools::getValue('banner_url'));
             Configuration::updateValue('PAYPAL_API_USER', trim(Tools::getValue('api_username')));
             Configuration::updateValue('PAYPAL_API_PASSWORD', trim(Tools::getValue('api_password')));
             Configuration::updateValue('PAYPAL_API_SIGNATURE', trim(Tools::getValue('api_signature')));
             Configuration::updateValue('PAYPAL_EXPRESS_CHECKOUT', (int) Tools::isSubmit('paypal_express'));
             Configuration::updateValue('PAYPAL_DEBUG_MODE', (int) Tools::isSubmit('paypal_debug'));
             Configuration::updateValue('PAYPAL_CAPTURE', (int) Tools::getValue('paypal_capture'));
             Configuration::updateValue('PAYPAL_PAYMENT_METHOD', (int) Tools::getValue('payment_method'));
             Configuration::updateValue('PAYPAL_TEMPLATE', Tools::getValue('template_paypal'));
             if (Tools::getValue('payment_method') == _PAYPAL_INTEGRAL_EVOLUTION_) {
                 $method = 'Paypal Integrale Evolution';
             } elseif (Tools::getValue('payment_method') == _PAYPAL_INTEGRAL_) {
                 $method = 'Paypal Integrale';
             } elseif (Tools::getValue('payment_method') == _PAYPAL_OPTION_PLUS_) {
                 $method = 'Paypal Integrale';
             } else {
                 $method = '';
             }
             $this->_html = $this->displayConfirmation($this->l('Settings updated') . '<img src="http://www.prestashop.com/modules/paypal.png?email=' . urlencode(Tools::getValue('email_paypal')) . '&mode=' . (Tools::getValue('sandbox_mode') ? 0 : 1) . '&method=' . urlencode($method) . '" style="float:right" />');
         } else {
             $error_msg = '';
             foreach ($this->_errors as $error) {
                 $error_msg .= $error . '<br />';
             }
             $this->_html = $this->displayError($error_msg);
         }
     }
     if (Tools::isSubmit('submitPayPalValidation')) {
         if (!($response = $this->_updatePaymentStatusOfOrder((int) Tools::getValue('id_order'))) or !sizeof($response)) {
             $this->_html .= '<p style="color:red;">' . $this->l('Error obtaining payment status.') . '</p>';
         } else {
             if ($response['ACK'] == 'Success') {
                 if ($response['PAYMENTSTATUS'] == 'Completed' or $response['PAYMENTSTATUS'] == 'Reversed' or $response['PAYMENTSTATUS'] == 'Pending' and $response['PENDINGREASON'] == 'authorization') {
                     Tools::redirectAdmin($currentIndex . '&id_order=' . (int) Tools::getValue('id_order') . '&vieworder&paypal=validationOk&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
                 } else {
                     $this->_html .= '<p><b>' . $this->l('Status') . ':</b> ' . $response['PAYMENTSTATUS'] . ' (' . $this->l('Reason:') . ' ' . $response['PENDINGREASON'] . ')</p>';
                 }
             } else {
                 $this->_html .= '<p style="color:red;">' . $this->l('Error from PayPal: ') . $response['L_LONGMESSAGE0'] . ' (#' . $response['L_ERRORCODE0'] . ')</p>';
             }
         }
     }
     if (Tools::isSubmit('submitPayPalCapture')) {
         if (!($response = $this->_doCapture((int) Tools::getValue('id_order'))) or !sizeof($response)) {
             $this->_html .= '<p style="color:red;">' . $this->l('Error when making capture request') . '</p>';
         } else {
             if ($response['ACK'] == 'Success') {
                 if ($response['PAYMENTSTATUS'] == 'Completed') {
                     Tools::redirectAdmin($currentIndex . '&id_order=' . (int) Tools::getValue('id_order') . '&vieworder&paypal=captureOk&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
                 } else {
                     Tools::redirectAdmin($currentIndex . '&id_order=' . (int) Tools::getValue('id_order') . '&vieworder&paypal=captureError&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
                 }
             } else {
                 $this->_html .= '<p style="color:red;">' . $this->l('Error from PayPal: ') . $response['L_LONGMESSAGE0'] . ' (#' . $response['L_ERRORCODE0'] . ')</p>';
             }
         }
     }
     if (Tools::isSubmit('submitPayPalRefund')) {
         if (!($response = $this->_doTotalRefund((int) Tools::getValue('id_order'))) or !sizeof($response)) {
             $this->_html .= '<p style="color:red;">' . $this->l('Error when making refund request') . '</p>';
         } else {
             if ($response['ACK'] == 'Success') {
                 if ($response['REFUNDTRANSACTIONID'] != '') {
                     Tools::redirectAdmin($currentIndex . '&id_order=' . (int) Tools::getValue('id_order') . '&vieworder&paypal=refundOk&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
                 } else {
                     Tools::redirectAdmin($currentIndex . '&id_order=' . (int) Tools::getValue('id_order') . '&vieworder&paypal=refundError&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
//.........这里部分代码省略.........
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:101,代码来源:paypal.php

示例15: preProcess

 private function preProcess()
 {
     if (Tools::isSubmit('submitModule')) {
         self::$ID_MERCHANT = Tools::getValue('idMerchant') !== '' ? Tools::getValue('idMerchant') : self::$ID_MERCHANT;
         self::$ACCEPTED_URL = Validate::isUrl(Tools::getValue('acceptedUrl')) ? Tools::getValue('acceptedUrl') : self::$ACCEPTED_URL;
         self::$CANCELLED_URL = Validate::isUrl(Tools::getValue('cancelledUrl')) ? Tools::getValue('cancelledUrl') : self::$CANCELLED_URL;
         self::$TESTING = (int) isset($_POST['testing']);
         self::$MORE_SETTINGS['flexwin_color'] = Tools::getValue('flexwin_color');
         self::$MORE_SETTINGS['logo_color'] = Tools::getValue('logo_color');
         self::$MORE_SETTINGS['k1'] = Tools::getValue('k1');
         self::$MORE_SETTINGS['k2'] = Tools::getValue('k2');
         Configuration::updateValue('DIBS_ID_MERCHANT', self::$ID_MERCHANT);
         Configuration::updateValue('DIBS_ACCEPTED_URL', self::$ACCEPTED_URL);
         Configuration::updateValue('DIBS_CANCELLED_URL', self::$CANCELLED_URL);
         Configuration::updateValue('DIBS_TESTING', self::$TESTING);
         Configuration::updateValue('DIBS_MORE_SETTINGS', Tools::htmlentitiesUTF8(serialize(self::$MORE_SETTINGS)));
         $data_sync = '';
         if (self::$ID_MERCHANT !== '' and self::$TESTING !== 1 and self::$MORE_SETTINGS['k1'] !== '' and self::$MORE_SETTINGS['k2'] !== '') {
             $data_sync = '<img src="http://api.prestashop.com/modules/dibs.png?site_id=' . urlencode(self::$ID_MERCHANT) . '" style="float:right" />';
         }
         return '<div class="conf confirm"><img src="../img/admin/ok.gif"/>' . $this->l('Configuration updated') . $data_sync . '</div>';
     }
     return '';
 }
开发者ID:rtajmahal,项目名称:PrestaShop-modules,代码行数:24,代码来源:dibs.php


注:本文中的Validate::isUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。