示例#1
0
/**
 * Remove parameter from the URL query part
 *
 * @param string ... query
 * @param string ... parameters to remove
 * @return string modified query
 */
function fn_query_remove()
{
    $args = func_get_args();
    $url = array_shift($args);
    if (!empty($args)) {
        $url_object = new Url($url);
        $url_object->removeParams($args);
        $url = $url_object->build($url_object->getIsEncoded());
    }
    return $url;
}
示例#2
0
文件: exim.php 项目: arpad9/bygmarket
function fn_exim_get_image_url($product_id, $object_type, $pair_type, $get_icon, $get_detailed, $lang_code)
{
    $image_pair = fn_get_image_pairs($product_id, $object_type, $pair_type, true, true, $lang_code);
    $image_data = fn_image_to_display($image_pair, Registry::get('settings.Thumbnails.product_details_thumbnail_width'), Registry::get('settings.Thumbnails.product_details_thumbnail_height'));
    if (!empty($image_data['image_path'])) {
        $url = new Url($image_data['image_path']);
        $url->setProtocol(fn_get_storefront_protocol());
        return $url->build($url->getIsEncoded());
    }
    return '';
}
示例#3
0
 /**
  * Fixes vars in SERVER superglobal array
  * @param  array $server SERVER array
  * @return array fixed SERVER array
  */
 public static function fixServerVars($server)
 {
     if (!isset($server['HTTP_HOST'])) {
         $server['HTTP_HOST'] = 'localhost';
     }
     if (empty($server['HTTP_USER_AGENT'])) {
         $server['HTTP_USER_AGENT'] = '';
     }
     if (isset($server['HTTP_X_REWRITE_URL'])) {
         // for isapi_rewrite
         $server['REQUEST_URI'] = $server['HTTP_X_REWRITE_URL'];
     }
     if (!empty($server['QUERY_STRING'])) {
         $server['QUERY_STRING'] = defined('QUOTES_ENABLED') ? stripslashes($server['QUERY_STRING']) : $server['QUERY_STRING'];
         $server['QUERY_STRING'] = str_replace(array('"', "'"), array('', ''), $server['QUERY_STRING']);
     }
     // resolve symbolic links
     if (!empty($server['SCRIPT_FILENAME'])) {
         $server['SCRIPT_FILENAME'] = realpath($server['SCRIPT_FILENAME']);
     } else {
         $debug_backtrace = debug_backtrace();
         $debug_backtrace = end($debug_backtrace);
         if (isset($debug_backtrace['file'])) {
             $server['SCRIPT_FILENAME'] = realpath($debug_backtrace['file']);
         }
     }
     if (!isset($server['SCRIPT_NAME']) && isset($server['SCRIPT_FILENAME'])) {
         $server['SCRIPT_NAME'] = $server['SCRIPT_FILENAME'];
     }
     if (!empty($server['HTTP_ORIGIN'])) {
         $url = new Url($server['HTTP_ORIGIN']);
         $server['HTTP_ORIGIN'] = $url->build(false, true);
     }
     if (!empty($server['HTTP_REFERER'])) {
         $url = new Url($server['HTTP_REFERER']);
         $server['HTTP_REFERER'] = $url->build(false, true);
     }
     // PHP_AUTH_USER and PHP_AUTH_PW not available when using FastCGI (https://bugs.php.net/bug.php?id=35752)
     $http_auth = '';
     if (!empty($server['REDIRECT_HTTP_AUTHORIZATION'])) {
         $http_auth = base64_decode(substr($server['REDIRECT_HTTP_AUTHORIZATION'], 6));
     } elseif (!empty($server['HTTP_AUTHORIZATION'])) {
         $http_auth = base64_decode(substr($server['HTTP_AUTHORIZATION'], 6));
     }
     if (!empty($http_auth) && (empty($server['PHP_AUTH_USER']) || empty($server['PHP_AUTH_PW']))) {
         list($server['PHP_AUTH_USER'], $server['PHP_AUTH_PW']) = explode(':', $http_auth);
     }
     if (self::isWindows()) {
         foreach (array('PHP_SELF', 'SCRIPT_FILENAME', 'SCRIPT_NAME') as $var) {
             if (isset($server[$var])) {
                 $server[$var] = str_replace('\\', '/', $server[$var]);
             }
         }
     }
     return $server;
 }