本文整理汇总了PHP中fn_strlen函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_strlen函数的具体用法?PHP fn_strlen怎么用?PHP fn_strlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fn_strlen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: fn_simple_encode_str
/**
* Encode plain text string
* Example: $result = fn_simple_encode_str('test'); // returns "uftu"
*
* @param type $str
* @return type
*/
function fn_simple_encode_str($str)
{
$encoded_str = '';
for ($i = 0; $i < fn_strlen($str); $i++) {
$chr = ord($str[$i]);
$encoded_str .= chr(++$chr);
}
return $encoded_str;
}
开发者ID:askzap,项目名称:ultimate,代码行数:16,代码来源:utf8.functions.php
示例2: smarty_modifier_truncate
/**
* Smarty truncate modifier plugin
*
* Type: modifier<br>
* Name: truncate<br>
* Purpose: Truncate a string to a certain length if necessary,
* optionally splitting in the middle of a word, and
* appending the $etc string or inserting $etc into the middle.
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php
* truncate (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param integer
* @param string
* @param boolean
* @param boolean
* @return string
*/
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
{
if ($length == 0) {
return '';
}
if (Registry::get('runtime.customization_mode.translation') && preg_match('/(\\[lang name\\=[\\w-]+?( [pre\\-ajx]*)?\\])(.*?)(\\[\\/lang\\])/is', $string, $matches)) {
list(, $pre, , $string, $post) = $matches;
} else {
$pre = $post = '';
}
if (fn_strlen($string) > $length) {
$length -= min($length, fn_strlen($etc));
if (!$break_words && !$middle) {
$string = preg_replace('/\\s+?(\\S+)?$/u', '', fn_substr($string, 0, $length + 1));
}
if (!$middle) {
return fn_substr($string, 0, $length) . $etc;
} else {
return fn_substr($string, 0, $length / 2) . $etc . fn_substr($string, -$length / 2);
}
} else {
return $string;
}
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:42,代码来源:modifier.truncate.php
示例3: fn_dispatch
/**
* Dispathes the execution control to correct controller
*
* @return nothing
*/
function fn_dispatch($controller = '', $mode = '', $action = '', $dispatch_extra = '', $area = AREA)
{
Debugger::checkpoint('After init');
$auth = $_SESSION['auth'];
$controller = empty($controller) ? Registry::get('runtime.controller') : $controller;
$mode = empty($mode) ? Registry::get('runtime.mode') : $mode;
$action = empty($action) ? Registry::get('runtime.action') : $action;
$dispatch_extra = empty($dispatch_extra) ? Registry::get('runtime.dispatch_extra') : $dispatch_extra;
fn_set_hook('before_dispatch', $controller, $mode, $action, $dispatch_extra, $area);
$view = Registry::get('view');
$run_controllers = true;
$external = false;
$status = CONTROLLER_STATUS_NO_PAGE;
// CSRF protection
if (fn_is_csrf_protection_enabled($auth) && !fn_csrf_validate_request(array('server' => $_SERVER, 'request' => $_REQUEST, 'session' => $_SESSION, 'controller' => $controller, 'mode' => $mode, 'action' => $action, 'dispatch_extra' => $dispatch_extra, 'area' => $area, 'auth' => $auth))) {
fn_set_notification('E', __('error'), __('text_csrf_attack'));
fn_redirect(fn_url());
}
// If $config['http_host'] was different from the domain name, there was redirection to $config['http_host'] value.
if (strtolower(Registry::get('config.current_host')) != strtolower(REAL_HOST) && $_SERVER['REQUEST_METHOD'] == 'GET' && !defined('CONSOLE')) {
if (!empty($_SERVER['REDIRECT_URL'])) {
$qstring = $_SERVER['REDIRECT_URL'];
} else {
if (!empty($_SERVER['REQUEST_URI'])) {
$qstring = $_SERVER['REQUEST_URI'];
} else {
$qstring = Registry::get('config.current_url');
}
}
$curent_path = Registry::get('config.current_path');
if (!empty($curent_path) && strpos($qstring, $curent_path) === 0) {
$qstring = substr_replace($qstring, '', 0, fn_strlen($curent_path));
}
fn_redirect(Registry::get('config.current_location') . $qstring, false, true);
}
$upload_max_filesize = Bootstrap::getIniParam('upload_max_filesize');
$post_max_size = Bootstrap::getIniParam('post_max_size');
if (!defined('AJAX_REQUEST') && isset($_SERVER['CONTENT_LENGTH']) && ($_SERVER['CONTENT_LENGTH'] > fn_return_bytes($upload_max_filesize) || $_SERVER['CONTENT_LENGTH'] > fn_return_bytes($post_max_size))) {
$max_size = fn_return_bytes($upload_max_filesize) < fn_return_bytes($post_max_size) ? $upload_max_filesize : $post_max_size;
fn_set_notification('E', __('error'), __('text_forbidden_uploaded_file_size', array('[size]' => $max_size)));
fn_redirect($_SERVER['HTTP_REFERER']);
}
// If URL contains session ID, remove it
if (!defined('AJAX_REQUEST') && !empty($_REQUEST[Session::getName()]) && $_SERVER['REQUEST_METHOD'] == 'GET') {
fn_redirect(fn_query_remove(Registry::get('config.current_url'), Session::getName()));
}
// If demo mode is enabled, check permissions FIX ME - why did we need one more user login check?
if ($area == 'A') {
if (Registry::get('config.demo_mode') == true) {
$run_controllers = fn_check_permissions($controller, $mode, 'demo');
if ($run_controllers == false) {
fn_set_notification('W', __('demo_mode'), __('demo_mode_content_text'), 'K', 'demo_mode');
if (defined('AJAX_REQUEST')) {
exit;
}
fn_delete_notification('changes_saved');
$status = CONTROLLER_STATUS_REDIRECT;
$_REQUEST['redirect_url'] = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : fn_url('');
}
} else {
$run_controllers = fn_check_permissions($controller, $mode, 'admin', '', $_REQUEST);
if ($run_controllers == false) {
if (defined('AJAX_REQUEST')) {
$_info = Debugger::isActive() || fn_is_development() ? ' ' . $controller . '.' . $mode : '';
fn_set_notification('W', __('warning'), __('access_denied') . $_info);
exit;
}
$status = CONTROLLER_STATUS_DENIED;
}
}
}
if ($_SERVER['REQUEST_METHOD'] != 'POST' && !defined('AJAX_REQUEST')) {
if ($area == 'A' && empty($_REQUEST['keep_location']) && !defined('CONSOLE')) {
if (!defined('HTTPS') && Registry::get('settings.Security.secure_admin') == 'Y') {
fn_redirect(Registry::get('config.https_location') . '/' . Registry::get('config.current_url'));
} elseif (defined('HTTPS') && Registry::get('settings.Security.secure_admin') != 'Y') {
fn_redirect(Registry::get('config.http_location') . '/' . Registry::get('config.current_url'));
}
} elseif ($area == 'C') {
$secure_controllers = fn_get_secure_controllers();
// if we are not on https but controller is secure, redirect to https
if (!defined('HTTPS') && (Registry::get('settings.Security.secure_storefront') == 'full' || isset($secure_controllers[$controller]) && $secure_controllers[$controller] == 'active')) {
fn_redirect(Registry::get('config.https_location') . '/' . Registry::get('config.current_url'), false, true);
}
// if we are on https and the controller is insecure, redirect to http
if (defined('HTTPS') && Registry::get('settings.Security.secure_storefront') != 'full' && !isset($secure_controllers[$controller]) && Registry::get('settings.Security.keep_https') != 'Y') {
fn_redirect(Registry::get('config.http_location') . '/' . Registry::get('config.current_url'), false, true);
}
}
}
LastView::instance()->prepare($_REQUEST);
$controllers_cascade = array();
$controllers_list = array('init');
if ($run_controllers == true) {
$controllers_list[] = $controller;
//.........这里部分代码省略.........
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:101,代码来源:fn.control.php
示例4: fn_basename
function fn_basename($path, $suffix = '', $encoding = 'UTF-8')
{
$basename = explode("/", $path);
$basename = end($basename);
if (!empty($suffix) && fn_substr($basename, 0 - fn_strlen($suffix, $encoding), fn_strlen($basename, $encoding), $encoding) == $suffix) {
$basename = fn_substr($basename, 0, 0 - fn_strlen($suffix, $encoding), $encoding);
}
/* Remove query params
Original: http://somehost.com/images/test.jpg?12345678
Bad result: test.jpg?12345678
Correct result: test.jpg
*/
list($basename) = explode('?', $basename);
return $basename;
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:15,代码来源:fn.fs.php
示例5: fn_get_state_name
exit;
}
// gateway_fast_registration
$post_data['firstname'] = $order_info['b_firstname'];
$post_data['lastname'] = $order_info['b_lastname'];
$post_data['pay_from_email'] = $order_info['email'];
//$post_data['pay_from_email'] = rand(). "@" . rand() . ".com"; // uncomment to test hide login feature
$post_data['address'] = $order_info['b_address'];
$post_data['address2'] = $order_info['b_address_2'];
$post_data['postal_code'] = $order_info['b_zipcode'];
$post_data['city'] = $order_info['b_city'];
$post_data['state'] = fn_get_state_name($order_info['b_state'], $order_info['b_country']);
if (empty($post_data['state'])) {
$post_data['state'] = $order_info['b_state'];
}
if (fn_strlen($post_data['state']) > 50) {
$post_data['state'] = fn_substr($post_data['state'], 0, 47) . '...';
}
$post_data['country'] = db_get_field('SELECT code_A3 FROM ?:countries WHERE code=?s', $order_info['b_country']);
$post_data['phone_number'] = $order_info['phone'];
if ($processor_data['processor_params']['quick_checkout'] == 'Y') {
$post_data['payment_methods'] = !empty($processor_data['processor_params']['payment_methods']) ? '' : 'ACC';
$post_data['hide_login'] = '1';
} else {
$post_data['payment_methods'] = 'WLT';
$post_data['hide_login'] = !empty($suffix) ? '1' : '0';
}
// split_gateway
if (!empty($processor_data['processor_params']['payment_methods'])) {
$post_data['payment_methods'] .= (!empty($post_data['payment_methods']) ? ',' : '') . $processor_data['processor_params']['payment_methods'];
}
开发者ID:ambient-lounge,项目名称:site,代码行数:31,代码来源:skrill_ewallet.php
示例6: fn_sales_repors_format_description
function fn_sales_repors_format_description($value, $limit, $id)
{
if (strlen($value) > fn_strlen($value)) {
$limit /= 2;
}
return fn_strlen($value) > $limit ? $id . fn_substr($value, 0, $limit) . "..." : $id . $value;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:7,代码来源:fn.sales_reports.php
示例7: fn_format_long_string
function fn_format_long_string($str, $length)
{
if (fn_strlen($str) <= $length) {
return $str;
}
$length = $length - 3;
return fn_substr($str, 0, $length) . '...';
}
开发者ID:arpad9,项目名称:bygmarket,代码行数:8,代码来源:fn.common.php
示例8: fn_log_event
function fn_log_event($type, $action, $data = array())
{
$object_primary_keys = array('users' => 'user_id', 'orders' => 'order_id', 'products' => 'product_id', 'categories' => 'category_id');
$update = false;
$content = array();
$actions = Registry::get('settings.Logging.log_type_' . $type);
$cut_log = Registry::ifGet('log_cut', false);
Registry::del('log_cut');
$cut_data = Registry::ifGet('log_cut_data', false);
Registry::del('log_cut_data');
if (empty($actions) || $action && !empty($actions) && empty($actions[$action]) || !empty($cut_log)) {
return false;
}
if (!empty($_SESSION['auth']['user_id'])) {
$user_id = $_SESSION['auth']['user_id'];
} else {
$user_id = 0;
}
if ($type == 'users' && $action == 'logout' && !empty($data['user_id'])) {
$user_id = $data['user_id'];
}
if ($user_id) {
$udata = db_get_row("SELECT firstname, lastname, email FROM ?:users WHERE user_id = ?i", $user_id);
}
$event_type = 'N';
// notice
if (!empty($data['backtrace'])) {
$_btrace = array();
$func = '';
foreach (array_reverse($data['backtrace']) as $v) {
if (!empty($v['file'])) {
$v['file'] = fn_get_rel_dir($v['file']);
}
if (empty($v['file'])) {
$func = $v['function'];
continue;
} elseif (!empty($func)) {
$v['function'] = $func;
$func = '';
}
$_btrace[] = array('file' => !empty($v['file']) ? $v['file'] : '', 'line' => !empty($v['line']) ? $v['line'] : '', 'function' => $v['function']);
}
$data['backtrace'] = serialize($_btrace);
} else {
$data['backtrace'] = '';
}
if ($type == 'general') {
if ($action == 'deprecated') {
$content['deprecated_function'] = $data['function'];
}
$content['message'] = $data['message'];
} elseif ($type == 'orders') {
$order_status_descr = fn_get_simple_statuses(STATUSES_ORDER, true, true);
$content = array('order' => '# ' . $data['order_id'], 'id' => $data['order_id']);
if ($action == 'status') {
$content['status'] = $order_status_descr[$data['status_from']] . ' -> ' . $order_status_descr[$data['status_to']];
}
} elseif ($type == 'products') {
$product = db_get_field("SELECT product FROM ?:product_descriptions WHERE product_id = ?i AND lang_code = ?s", $data['product_id'], Registry::get('settings.Appearance.backend_default_language'));
$content = array('product' => $product . ' (#' . $data['product_id'] . ')', 'id' => $data['product_id']);
if ($action == 'low_stock') {
// log stock - warning
$event_type = 'W';
}
} elseif ($type == 'categories') {
$category = db_get_field("SELECT category FROM ?:category_descriptions WHERE category_id = ?i AND lang_code = ?s", $data['category_id'], Registry::get('settings.Appearance.backend_default_language'));
$content = array('category' => $category . ' (#' . $data['category_id'] . ')', 'id' => $data['category_id']);
} elseif ($type == 'database') {
if ($action == 'error') {
$content = array('error' => $data['error']['message'], 'query' => $data['error']['query']);
$event_type = 'E';
}
} elseif ($type == 'requests') {
if (!empty($cut_data)) {
$data['data'] = preg_replace("/\\<(" . implode('|', $cut_data) . ")\\>(.*?)\\<\\/(" . implode('|', $cut_data) . ")\\>/s", '<${1}>******</${1}>', $data['data']);
$data['data'] = preg_replace("/%3C(" . implode('|', $cut_data) . ")%3E(.*?)%3C%2F(" . implode('|', $cut_data) . ")%3E/s", '%3C${1}%3E******%3C%2F${1}%3E', $data['data']);
$data['data'] = preg_replace("/(" . implode('|', $cut_data) . ")=(.*?)(&)/s", '${1}=******${3}', $data['data']);
}
$content = array('url' => $data['url'], 'request' => fn_strlen($data['data']) < LOG_MAX_DATA_LENGTH && preg_match('//u', $data['data']) ? $data['data'] : '', 'response' => fn_strlen($data['response']) < LOG_MAX_DATA_LENGTH && preg_match('//u', $data['response']) ? $data['response'] : '');
} elseif ($type == 'users') {
if (!empty($data['time'])) {
if (empty($_SESSION['log']['login_log_id'])) {
return false;
}
$content = db_get_field('SELECT content FROM ?:logs WHERE log_id = ?i', $_SESSION['log']['login_log_id']);
$content = unserialize($content);
$minutes = ceil($data['time'] / 60);
$hours = floor($minutes / 60);
if ($hours) {
$minutes -= $hours * 60;
}
if ($hours || $minutes) {
$content['loggedin_time'] = ($hours ? $hours . ' |hours| ' : '') . ($minutes ? $minutes . ' |minutes|' : '');
}
if (!empty($data['timeout']) && $data['timeout']) {
$content['timeout'] = true;
}
$update = $_SESSION['log']['login_log_id'];
} else {
if (!empty($data['user_id'])) {
//.........这里部分代码省略.........
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:101,代码来源:fn.log.php
示例9: updateLangVar
/**
* @param array $lang_data
* @param string $lang_code
* @param array $params
* @return array List of updated lang_names
*/
public static function updateLangVar($lang_data, $lang_code = DESCR_SL, $params = array())
{
$error_flag = false;
$result = array();
fn_set_hook('update_lang_values', $lang_data, $lang_code, $error_flag, $params, $result);
foreach ($lang_data as $k => $v) {
if (!empty($v['name'])) {
preg_match("/(^[a-zA-z0-9][a-zA-Z0-9_\\.]*)/", $v['name'], $matches);
if (fn_strlen($matches[0]) == fn_strlen($v['name'])) {
$v['lang_code'] = $lang_code;
$res = db_query("REPLACE INTO ?:language_values ?e", $v);
if ($res) {
$result[] = $v['name'];
}
} elseif (!$error_flag) {
fn_set_notification('E', __('warning'), __('warning_lanvar_incorrect_name'));
$error_flag = true;
}
}
}
return $result;
}
开发者ID:ambient-lounge,项目名称:site,代码行数:28,代码来源:Values.php
示例10: fn_substr
/**
* substr() with full UTF-8 support
*
* @param string $string The input string.
* @param integer $start If start is non-negative, the returned string will start at the start 'th position in string , counting from zero. If start is negative, the returned string will start at the start 'th character from the end of string.
* @param integer $length If length is given and is positive, the string returned will contain at most length characters beginning from start (depending on the length of string ). If length is given and is negative, then that many characters will be omitted from the end of string (after the start position has been calculated when a start is negative). If start denotes a position beyond this truncation, an empty string will be returned.
* @param integer $encoding The encoding parameter is the character encoding. If it is omitted, UTF-8 character encoding value will be used.
* @return mixed Returns the extracted part of string or false if string is less than or equal to start characters long
*/
function fn_substr($string, $start, $length = null, $encoding = 'UTF-8')
{
if (empty($encoding)) {
$encoding = 'UTF-8';
}
if ($length === null) {
return fn_substr($string, $start, fn_strlen($string, $encoding), $encoding);
}
if (function_exists('iconv_substr')) {
// there was strange bug in iconv_substr when use negative length parameter
// so we recalculate start and length here
if ($length < 0) {
$length = ceil($length);
$len = iconv_strlen($string, $encoding);
if ($start < 0) {
$start += $len;
}
$length += $len - $start;
}
return iconv_substr($string, $start, $length, $encoding);
} elseif (function_exists('mb_substr')) {
return mb_substr($string, $start, $length, $encoding);
} else {
preg_match_all('/./su', $string, $ar);
return join('', array_slice($ar[0], $start, $length));
}
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:36,代码来源:fn.common.php
示例11: fn_searchanise_get_products_before_select
function fn_searchanise_get_products_before_select(&$params, &$join, &$condition, &$u_condition, &$inventory_condition, &$sortings, &$total, &$items_per_page, &$lang_code, &$having)
{
// disable by core
if (AREA == 'A' || fn_se_check_disabled() || !empty($params['having']) || !empty($params['disable_searchanise']) || empty($params['search_performed']) || !empty($params['block_data']) || empty($params['q']) && fn_se_get_simple_setting('use_navigation') !== 'Y' || fn_se_get_import_status(fn_se_get_company_id(), $lang_code) != 'done' || !empty($params['pid']) || !empty($params['b_id']) || !empty($params['item_ids']) || !empty($params['feature']) || !empty($params['downloadable']) || !empty($params['tracking']) || !empty($params['shipping_freight_from']) || !empty($params['shipping_freight_to']) || !empty($params['exclude_pid']) || !empty($params['get_query']) || !empty($params['only_short_fields']) || isset($params['supplier_id']) || isset($params['amount_to']) || isset($params['amount_from']) || isset($params['q']) && Registry::get('settings.General.search_objects') || isset($params['compact']) && $params['compact'] == 'Y' || !empty($_REQUEST['sort_by']) && !in_array($_REQUEST['sort_by'], fn_se_get_valid_sortings()) || !empty($params['force_get_by_ids']) && empty($params['pid']) && empty($params['product_id'])) {
return;
}
// disable by addons
if (!empty($params['rating']) || !empty($params['bestsellers']) || !empty($params['also_bought_for_product_id']) || !empty($params['for_required_product']) || !empty($params['ppcode']) && $params['ppcode'] == 'Y' || isset($params['tag']) && fn_string_not_empty($params['tag']) || Registry::ifGet('addons.age_verification.status', 'D') == 'A' || Registry::ifGet('addons.vendor_data_premoderation.status', 'D') == 'A' || !empty($params['picker_for']) && $params['picker_for'] == 'gift_certificates') {
return;
}
list($restrict_by, $query_by, $union) = fn_se_prepare_request_params($params);
//
// Categories
//
if (!empty($params['cid'])) {
$cids = is_array($params['cid']) ? $params['cid'] : array($params['cid']);
$c_condition = '';
if (AREA == 'C') {
$_c_statuses = array('A', 'H');
// Show enabled categories
$cids = db_get_fields("SELECT a.category_id FROM ?:categories as a WHERE a.category_id IN (?n) AND a.status IN (?a)", $cids, $_c_statuses);
$c_condition = db_quote('AND a.status IN (?a) AND (' . fn_find_array_in_set(Tygh::$app['session']['auth']['usergroup_ids'], 'a.usergroup_ids', true) . ')', $_c_statuses);
}
$sub_categories_ids = db_get_fields("SELECT a.category_id FROM ?:categories as a LEFT JOIN ?:categories as b ON b.category_id IN (?n) WHERE a.id_path LIKE CONCAT(b.id_path, '/%') ?p", $cids, $c_condition);
$sub_categories_ids = fn_array_merge($cids, $sub_categories_ids, false);
if (empty($sub_categories_ids)) {
$params['force_get_by_ids'] = true;
$params['pid'] = $params['product_id'] = 0;
return;
}
if (!empty($params['subcats']) && $params['subcats'] == 'Y') {
$restrict_by['category_id'] = join('|', $sub_categories_ids);
} else {
$restrict_by['category_id'] = join('|', $cids);
}
}
//
// Sortings
//
if (!empty($_REQUEST['search_performed']) && empty($_REQUEST['sort_by']) && SE_USE_RELEVANCE_AS_DEFAULT_SORTING == 'Y') {
$params['sort_by'] = 'relevance';
$params['sort_order'] = 'asc';
}
if (!empty($params['sort_by']) && !in_array($params['sort_by'], fn_se_get_valid_sortings())) {
return;
}
if ($params['sort_by'] == 'product') {
$sort_by = 'title';
} elseif ($params['sort_by'] == 'relevance') {
$params['sort_order'] = 'asc';
$sort_by = 'relevance';
} else {
$sort_by = $params['sort_by'];
}
$sort_order = $params['sort_order'] == 'asc' ? 'asc' : 'desc';
//
// Items_per_page
//
$items_per_page = empty($params['items_per_page']) ? 10 : (int) $params['items_per_page'];
if (!empty($params['limit'])) {
$max_results = $params['limit'];
} else {
$max_results = $items_per_page;
}
$get_items = true;
$get_facets = false;
if (!fn_allowed_for('ULTIMATE:FREE') && AREA == 'C' && !empty($params['dispatch']) && in_array($params['dispatch'], fn_se_get_facet_valid_locations()) && fn_se_check_product_filter_block() == true) {
$get_facets = true;
}
$request_params = array('sortBy' => $sort_by, 'sortOrder' => $sort_order, 'union' => $union, 'queryBy' => $query_by, 'restrictBy' => $restrict_by, 'items' => $get_items == true ? 'true' : 'false', 'facets' => $get_facets == true ? 'true' : 'false', 'maxResults' => $max_results, 'startIndex' => ($params['page'] - 1) * $items_per_page);
if ($request_params['sortBy'] == 'null') {
unset($request_params['sortBy']);
}
if (!empty($params['q']) && fn_strlen($params['q']) > 0) {
$request_params['q'] = $params['q'];
$request_params['suggestions'] = 'true';
$request_params['query_correction'] = 'false';
$request_params['suggestionsMaxResults'] = 1;
} else {
$request_params['q'] = '';
}
$result = fn_searchanise_send_search_request($request_params, $lang_code);
if ($result == false) {
//revert to standart sorting
if ($params['sort_by'] == 'relevance') {
$params['sort_by'] = '';
}
Registry::set('runtime.se_use_relevance_sorting', false);
return;
}
if (!empty($result['suggestions']) && count($result['suggestions']) > 0) {
$params['suggestion'] = reset($result['suggestions']);
}
if (!empty($result['items'])) {
foreach ($result['items'] as $product) {
$params['pid'][] = $product['product_id'];
}
if ($params['sort_by'] == 'relevance') {
$sortings['relevance'] = "FIELD(products.product_id, '" . join("','", $params['pid']) . "')";
$params['sort_order'] = 'asc';
//.........这里部分代码省略.........
开发者ID:ambient-lounge,项目名称:site,代码行数:101,代码来源:func.php
示例12: fn_update_user
//.........这里部分代码省略.........
return false;
}
// Check if this user needs login/password
if (fn_user_need_login($user_data['user_type'])) {
// Check if user_login already exists
// FIXME
if (!isset($user_data['email'])) {
$user_data['email'] = db_get_field("SELECT email FROM ?:users WHERE user_id = ?i", $user_id);
}
$is_exist = fn_is_user_exists($user_id, $user_data);
if ($is_exist) {
fn_set_notification('E', __('error'), __('error_user_exists'), '', 'user_exist');
return false;
}
// Check the passwords
if (!empty($user_data['password1']) || !empty($user_data['password2'])) {
$original_password = trim($user_data['password1']);
$user_data['password1'] = !empty($user_data['password1']) ? trim($user_data['password1']) : '';
$user_data['password2'] = !empty($user_data['password2']) ? trim($user_data['password2']) : '';
}
// if the passwords are not set and this is not a forced password check
// we will not update password, otherwise let's check password
if (!empty(Tygh::$app['session']['auth']['forced_password_change']) || !empty($user_data['password1']) || !empty($user_data['password2'])) {
$valid_passwords = true;
if ($user_data['password1'] != $user_data['password2']) {
$valid_passwords = false;
fn_set_notification('E', __('error'), __('error_passwords_dont_match'));
}
// PCI DSS Compliance
if (fn_check_user_type_admin_area($user_data['user_type'])) {
$msg = array();
// Check password length
$min_length = Registry::get('settings.Security.min_admin_password_length');
if (fn_strlen($user_data['password1']) < $min_length || fn_strlen($user_data['password2']) < $min_length) {
$valid_passwords = false;
$msg[] = str_replace("[number]", $min_length, __('error_password_min_symbols'));
}
// Check password content
if (Registry::get('settings.Security.admin_passwords_must_contain_mix') == 'Y') {
$tmp_result = preg_match('/\\d+/', $user_data['password1']) && preg_match('/\\D+/', $user_data['password1']) && preg_match('/\\d+/', $user_data['password2']) && preg_match('/\\D+/', $user_data['password2']);
if (!$tmp_result) {
$valid_passwords = false;
$msg[] = __('error_password_content');
}
}
if ($msg) {
fn_set_notification('E', __('error'), implode('<br />', $msg));
}
// Check last 4 passwords
if (!empty($user_id)) {
$prev_passwords = !empty($current_user_data['last_passwords']) ? explode(',', $current_user_data['last_passwords']) : array();
if (!empty(Tygh::$app['session']['auth']['forced_password_change'])) {
// if forced password change - new password can't be equal to current password.
$prev_passwords[] = $current_user_data['password'];
}
if (in_array(fn_generate_salted_password($user_data['password1'], $current_user_data['salt']), $prev_passwords)) {
$valid_passwords = false;
fn_set_notification('E', __('error'), __('error_password_was_used'));
} else {
if (count($prev_passwords) >= 5) {
array_shift($prev_passwords);
}
$user_data['last_passwords'] = implode(',', $prev_passwords);
}
}
}
开发者ID:ambient-lounge,项目名称:site,代码行数:67,代码来源:fn.users.php
示例13: fn_basename
function fn_basename($path, $suffix = '', $encoding = 'UTF-8')
{
$basename = explode("/", $path);
$basename = end($basename);
if (!empty($suffix) && fn_substr($basename, 0 - fn_strlen($suffix, $encoding), fn_strlen($basename, $encoding), $encoding) == $suffix) {
$basename = fn_substr($basename, 0, 0 - fn_strlen($suffix, $encoding), $encoding);
}
return $basename;
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:9,代码来源:fn.fs.php
示例14: fn_sales_repors_format_description
function fn_sales_repors_format_description($value, $limit, $id)
{
return $limit !== null && fn_strlen($value) > $limit ? $id . fn_substr($value, 0, $limit) . "..." : $id . $value;
}
开发者ID:ambient-lounge,项目名称:site,代码行数:4,代码来源:fn.sales_reports.php
示例15: fn_ult_update_lang_values
function fn_ult_update_lang_values(&$lang_data, &$lang_code, &$error_flag, &$params, &$result)
{
if (Registry::get('runtime.company_id')) {
foreach ($lang_data as $k => $v) {
if (!empty($v['name'])) {
preg_match("/(^[a-zA-z0-9][a-zA-Z0-9_]*)/", $v['name'], $matches);
if (fn_strlen($matches[0]) == fn_strlen($v['name'])) {
$v['lang_code'] = $lang_code;
$v['company_id'] = Registry::get('runtime.company_id');
db_query("REPLACE INTO ?:ult_language_values ?e", $v);
// Check if variable not exists in General language variables
$exists = db_get_field('SELECT value FROM ?:language_values WHERE name = ?s AND lang_code = ?s', $v['name'], $lang_code);
if (!isset($exists) || empty($exists)) {
// Create language variable with empty content for other companies
$lang_data[$k]['value'] = '';
}
} elseif (!$error_flag) {
fn_set_notification('E', __('warning'), __('warning_lanvar_incorrect_name'));
$error_flag = true;
}
$result[] = $v['name'];
}
if (!isset($params['clear']) || $params['clear']) {
unset($lang_data[$k]);
}
}
} else {
$overwrite = array();
foreach ($lang_data as $k => $v) {
if (!empty($v['name']) && !empty($v['overwrite']) && $v['overwrite'] == 'Y') {
$overwrite[] = $v['name'];
}
}
if (!empty($overwrite)) {
db_query('DELETE FROM ?:ult_language_values WHERE name IN (?a) AND lang_code = ?s', $overwrite, $lang_code);
}
}
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:38,代码来源:fn.ultimate.php
注:本文中的fn_strlen函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论