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


PHP Tools::strlen方法代码示例

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


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

示例1: renderContent

 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;
 }
开发者ID:ekachandrasetiawan,项目名称:BeltcareCom,代码行数:30,代码来源:image.php

示例2: SendSocketHTTP

 private function SendSocketHTTP()
 {
     // init infos
     if (self::__TM4B_SMS_HTTP_METHOD__ == "GET") {
         $script = self::__TM4B_SMS_HTTP_SERVICE__ . '?' . $this->_httpQS;
     } else {
         $script = self::__TM4B_SMS_HTTP_SERVICE__;
     }
     // Build HTTP Header
     $header = self::__TM4B_SMS_HTTP_METHOD__ . " " . $script . " HTTP/1.1\r\n";
     $header .= "Host: " . self::__TM4B_SMS_HTTP_HOST__ . "\r\n";
     $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
     $header .= "Content-Length: " . Tools::strlen($this->_httpQS) . "\r\n";
     $header .= "Connection: close\r\n\r\n";
     $header .= $this->_httpQS . "\r\n";
     // Socket connection
     $socket = fsockopen(self::__TM4B_SMS_HTTP_HOST__, 80, $errno, $errstr);
     if ($socket) {
         fputs($socket, $header);
         // Send header
         while (!feof($socket)) {
             $response[] = fgets($socket);
             // Grab return codes
         }
         fclose($socket);
     } else {
         $response = false;
     }
     return $response;
 }
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:30,代码来源:Tm4bSms.php

示例3: validate

 protected function validate(YousticeShopRegistration $registration)
 {
     if (Tools::strlen(trim($registration->getCompanyName())) == 0) {
         return 'company_name_required';
     }
     if (Tools::strlen(trim($registration->getFirstName())) == 0) {
         return 'first_name_required';
     }
     if (Tools::strlen(trim($registration->getLastName())) == 0) {
         return 'last_name_required';
     }
     if (!filter_var($registration->getEmail(), FILTER_VALIDATE_EMAIL)) {
         return 'email_invalid';
     }
     if (!filter_var($registration->getShopUrl(), FILTER_VALIDATE_URL)) {
         return 'shop_url_invalid';
     }
     if (Tools::strlen($registration->getPassword()) < 6) {
         return 'password_less_than_6_characters';
     }
     if ($registration->getPassword() !== $registration->getVerifyPasswordValue()) {
         return 'passwords_do_not_match';
     }
     return true;
 }
开发者ID:devyoustice,项目名称:yousticeresolutionsystem,代码行数:25,代码来源:RegisterCommand.php

示例4: loadFromRawBytes

 public function loadFromRawBytes($image = '')
 {
     if (Tools::strlen($image) > 0) {
         $this->image = $this->resize($image, 300, 300);
     }
     return $this;
 }
开发者ID:devyoustice,项目名称:yousticeresolutionsystem,代码行数:7,代码来源:Image.php

示例5: curlConnection

 private function curlConnection($method, $url, $timeout, $charset, array $data = null)
 {
     if (Tools::strtoupper($method) === 'POST') {
         $postFields = $data ? http_build_query($data, '', '&') : "";
         $contentLength = "Content-length: " . Tools::strlen($postFields);
         $methodOptions = array(CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postFields);
     } else {
         $contentLength = null;
         $methodOptions = array(CURLOPT_HTTPGET => true);
     }
     $options = array(CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded; charset=" . $charset, $contentLength, 'lib-description: php:' . PagSeguroLibrary::getVersion(), 'language-engine-description: php:' . PagSeguroLibrary::getPHPVersion()), CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_CONNECTTIMEOUT => $timeout);
     if (!is_null(PagSeguroLibrary::getModuleVersion())) {
         array_push($options[CURLOPT_HTTPHEADER], 'module-description: ' . PagSeguroLibrary::getModuleVersion());
     }
     if (!is_null(PagSeguroLibrary::getCMSVersion())) {
         array_push($options[CURLOPT_HTTPHEADER], 'cms-description: ' . PagSeguroLibrary::getCMSVersion());
     }
     $options = $options + $methodOptions;
     $curl = curl_init();
     curl_setopt_array($curl, $options);
     $resp = curl_exec($curl);
     $info = curl_getinfo($curl);
     $error = curl_errno($curl);
     $errorMessage = curl_error($curl);
     curl_close($curl);
     $this->setStatus((int) $info['http_code']);
     $this->setResponse((string) $resp);
     if ($error) {
         throw new Exception("CURL can't connect: {$errorMessage}");
     } else {
         return true;
     }
 }
开发者ID:kennedimalheiros,项目名称:prestashop,代码行数:33,代码来源:PagSeguroHttpConnection.class.php

示例6: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     header('HTTP/1.1 404 Not Found');
     header('Status: 404 Not Found');
     if (in_array(Tools::strtolower(substr($_SERVER['REQUEST_URI'], -3)), array('png', 'jpg', 'gif'))) {
         $this->context->cookie->disallowWriting();
         if ((bool) Configuration::get('PS_REWRITING_SETTINGS')) {
             preg_match('#([0-9]+)(\\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/(.+)\\.(png|jpg|gif)$#', $_SERVER['REQUEST_URI'], $matches);
         }
         if ((!isset($matches[2]) || empty($matches[2])) && !(bool) Configuration::get('PS_REWRITING_SETTINGS')) {
             preg_match('#/([0-9]+)(\\-[_a-zA-Z]*)\\.(png|jpg|gif)$#', $_SERVER['REQUEST_URI'], $matches);
         }
         if (is_array($matches) && !empty($matches[2]) && Tools::strtolower(substr($matches[2], -8)) != '_default' && is_numeric($matches[1])) {
             $matches[2] = substr($matches[2], 1, Tools::strlen($matches[2])) . '_default';
             if (!isset($matches[4])) {
                 $matches[4] = '';
             }
             header('Location: ' . $this->context->link->getImageLink($matches[4], $matches[1], $matches[2]), true, 302);
             exit;
         }
         header('Content-Type: image/gif');
         readfile(_PS_IMG_DIR_ . '404.gif');
         exit;
     } elseif (in_array(Tools::strtolower(substr($_SERVER['REQUEST_URI'], -3)), array('.js', 'css'))) {
         $this->context->cookie->disallowWriting();
         exit;
     }
     parent::initContent();
     $this->setTemplate(_PS_THEME_DIR_ . '404.tpl');
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:34,代码来源:PageNotFoundController.php

示例7: __construct

 public function __construct()
 {
     $this->name = 'payplug';
     $this->tab = 'payments_gateways';
     $this->version = '1.0.1';
     $this->author = 'PayPlug';
     $this->module_key = '1ee28a8fb5e555e274bd8c2e1c45e31a';
     parent::__construct();
     // For 1.6
     $this->bootstrap = true;
     // Backward compatibility
     if (version_compare(_PS_VERSION_, '1.5', '<')) {
         require _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php';
     }
     // Add warning if prestashop is an older version than 1.4
     if (version_compare(_PS_VERSION_, '1.4', '<')) {
         $this->warning = $this->l('Sorry Payplug is not compatible with Prestashop for versions < 1.4. Please delete the payplug directory in the Prestashop modules directory for your Prestashop system to get back to normal.');
     }
     $this->currencies = true;
     $this->currencies_mode = 'checkbox';
     // Change descriptionn and display name
     $this->displayName = $this->l('PayPlug – Simple and secure online payments');
     $this->description = $this->l('The simplest online payment solution: no setup fees, no fixed fees, and no merchant account required!');
     $this->confirmUninstall = $this->l('Are you sure you wish to uninstall this module and delete your settings?');
     if (version_compare(_PS_VERSION_, '1.5', '<')) {
         $cookie_admin = new Cookie('psAdmin', Tools::substr($_SERVER['PHP_SELF'], Tools::strlen(__PS_BASE_URI__), -10));
         if (Tools::getValue('tab') == 'AdminPayment' && Tools::getValue('token') != Tools::getAdminTokenLite('AdminPayment')) {
             // Force admin status
             $this->context->cookie->profile = $cookie_admin->profile;
             $url = 'index.php?tab=AdminPayment';
             $url .= '&token=' . Tools::getAdminTokenLite('AdminPayment');
             Tools::redirectAdmin($url);
         }
     }
 }
开发者ID:202-ecommerce,项目名称:payplug,代码行数:35,代码来源:payplug.php

示例8: isShort

 /**
  * Validate is short
  *
  * @param string $str_data;
  * @return bool
  */
 public static function isShort($str_data)
 {
     if (Tools::strlen($str_data) < 6) {
         return true;
     }
     return false;
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:13,代码来源:GlobKurierValidator.php

示例9: getFirstProductStatus

 public function getFirstProductStatus()
 {
     if (isset($this->data['products']) && count($this->data['products'])) {
         $status = $this->data['products'][0]['status'];
         return Tools::strlen($status) ? $status : 'Problem reported';
     }
     return '';
 }
开发者ID:devyoustice,项目名称:yousticeresolutionsystem,代码行数:8,代码来源:OrderReport.php

示例10: psmFindSignature

 function psmFindSignature($content, $start_signature, $end_signature)
 {
     if (($start = strpos($content, $start_signature)) !== false && ($end = strpos($content, $end_signature, $start)) !== false) {
         $length = Tools::strlen($start_signature);
         return Tools::substr($content, $start + $length, $end - $start - $length);
     }
     return false;
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:8,代码来源:psm_helper.php

示例11: idRandomGenerator

 public static function idRandomGenerator()
 {
     $str = 'abcdefghijkmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
     for ($i = 0, $idGenerated = ''; $i < 5; $i++) {
         $idGenerated .= Tools::substr($str, mt_rand(0, Tools::strlen($str) - 1), 1);
     }
     return $idGenerated;
 }
开发者ID:kennedimalheiros,项目名称:prestashop,代码行数:8,代码来源:encryptionIdPagSeguro.php

示例12: init

 public function init()
 {
     parent::init();
     if (Tools::isSubmit('storedelivery') && (int) Tools::getValue('storedelivery') != 0) {
         //Save cookie only if previous id_adress wasn't a store
         $cookie = new Cookie('storedelivery');
         $cookie->__set('id_address_delivery', $this->context->cart->id_address_delivery);
         $store = new Store(Tools::getValue('storedelivery'));
         //Test if store address exist in address table
         Tools::strlen($store->name) > 32 ? $storeName = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($storeName = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
         $sql = 'SELECT id_address FROM ' . _DB_PREFIX_ . 'address WHERE alias=\'' . addslashes($storeName) . '\' AND address1=\'' . addslashes($store->address1) . '\' AND address2=\'' . addslashes($store->address2) . '\' AND postcode=\'' . $store->postcode . '\' AND city=\'' . addslashes($store->city) . '\' AND id_country=\'' . addslashes($store->id_country) . '\' AND active=1 AND deleted=0';
         $id_address = Db::getInstance()->getValue($sql);
         //Create store adress if not exist for this user
         if (empty($id_address)) {
             $country = new Country($store->id_country, $this->context->language->id);
             $address = new Address();
             $address->id_country = $store->id_country;
             $address->id_state = $store->id_state;
             $address->country = $country->name;
             Tools::strlen($store->name) > 32 ? $address->alias = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($address->alias = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
             Tools::strlen($store->name) > 32 ? $address->lastname = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($address->lastname = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
             $address->firstname = " ";
             $address->address1 = $store->address1;
             $address->address2 = $store->address2;
             $address->postcode = $store->postcode;
             $address->city = $store->city;
             $address->phone = $store->phone;
             $address->deleted = 0;
             //create an address non deleted to register them in order
             $address->add();
             $id_address = $address->id;
         }
         //Update cart info
         $cart = $this->context->cart;
         $cart->id_address_delivery = $id_address;
         $cart->update();
         //Change address of all product in cart else we are redirect on step Carrier because of function autostep or OrderController
         Db::getInstance()->update('cart_product', array('id_address_delivery' => (int) $id_address), $where = 'id_cart = ' . $this->context->cart->id);
         //Change post carrier option else bad default carrier is saved by fonction processCarrier of ParentOrderController
         $array = array_values(Tools::getValue('delivery_option'));
         $_POST['delivery_option'] = array($id_address => $array[0]);
     } else {
         $cookie = new Cookie('storedelivery');
         $id_address_delivery = $cookie->__get('id_address_delivery');
         if ($id_address_delivery != false && $this->context->cart->id_address_delivery != $id_address_delivery && Tools::isSubmit('storedelivery')) {
             $this->context->cart->id_address_delivery = $cookie->__get('id_address_delivery');
             $this->context->cart->update();
             //Change address of all product in cart else we are redirect on step Carrier because of function autostep or OrderController
             Db::getInstance()->update('cart_product', array('id_address_delivery' => (int) $cookie->__get('id_address_delivery')), $where = 'id_cart = ' . $this->context->cart->id);
             //Change post carrier option else bad default carrier is saved by fonction processCarrier of ParentOrderController
             $array = array_values(Tools::getValue('delivery_option'));
             $_POST['delivery_option'] = array($cookie->__get('id_address_delivery') => $array[0]);
             $cookie->__unset('id_address_delivery');
         }
     }
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:56,代码来源:OrderController.php

示例13: smartyTruncate

function smartyTruncate($params, &$smarty)
{
    $text = isset($params['strip']) ? strip_tags($params['text']) : $params['text'];
    $length = $params['length'];
    $sep = isset($params['sep']) ? $params['sep'] : '...';
    if (Tools::strlen($text) > $length + Tools::strlen($sep)) {
        $text = substr($text, 0, $length) . $sep;
    }
    return isset($params['encode']) ? Tools::htmlentitiesUTF8($text, ENT_NOQUOTES) : $text;
}
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:10,代码来源:smarty.config.inc.php

示例14: randomImageName

 public function randomImageName()
 {
     $length = 6;
     $characters = "0123456789abcdefghijklmnopqrstuvwxyz";
     $rand = '';
     for ($i = 0; $i < $length; $i++) {
         $rand = $rand . $characters[mt_rand(0, Tools::strlen($characters) - 1)];
     }
     return $rand;
 }
开发者ID:Rohit-jn,项目名称:hotelcommerce,代码行数:10,代码来源:HotelImage.php

示例15: request

 /**
  * Make a request to the Syspay API
  * @param  Syspay_Merchant_Request $request The request to send to the API
  * @return mixed The response to the request
  * @throws Syspay_Merchant_RequestException If the request could not be processed by the API
  */
 public function request(Syspay_Merchant_Request $request)
 {
     $this->body = $this->headers = $this->data = null;
     $headers = array('Accept: application/json', 'X-Wsse: ' . $this->generateAuthHeader($this->username, $this->secret));
     $url = rtrim($this->baseUrl, '/') . '/' . ltrim($request->getPath(), '/');
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     // TODO: verify ssl and provide certificate in package
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     $method = Tools::strtoupper($request->getMethod());
     // Per-method special handling
     switch ($method) {
         case 'PUT':
         case 'POST':
             $body = Tools::jsonEncode($request->getData());
             array_push($headers, 'Content-Type: application/json');
             array_push($headers, 'Content-Length: ' . Tools::strlen($body));
             curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
             break;
         case 'GET':
             $queryParams = $request->getData();
             if (is_array($queryParams)) {
                 $url .= '?' . http_build_query($queryParams);
             }
             break;
         case 'DELETE':
             break;
         default:
             throw new Exception('Unsupported method given: ' . $method);
     }
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     $response = curl_exec($ch);
     if ($response === false) {
         throw new Exception(curl_error($ch), curl_errno($ch));
     }
     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     list($headers, $body) = explode("\r\n\r\n", $response, 2);
     $this->headers = $headers;
     $this->body = $body;
     if (!in_array($httpCode, array(200, 201))) {
         throw new Syspay_Merchant_RequestException($httpCode, $headers, $body);
     }
     $decoded = Tools::jsonDecode($body);
     if ($decoded instanceof stdClass && isset($decoded->data) && $decoded->data instanceof stdClass) {
         $this->data = $decoded->data;
         return $request->buildResponse($decoded->data);
     } else {
         throw new Syspay_Merchant_UnexpectedResponseException('Unable to decode response from json', $body);
     }
     return false;
 }
开发者ID:antho-girard,项目名称:syspay,代码行数:61,代码来源:Client.php


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