示例#1
0
/**
 * 提供给https项目使用的域名替换模板插件
 * 异常时返回原url
 * @param unknown $strUrl
 * @param string $app
 * @return string
 */
function smarty_modifier_getHttpsHost($strUrl, $tag = '')
{
    $strReplacedUrl = $strUrl;
    $ishttps = Wise_Utils::isHttps();
    if ($ishttps !== 1) {
        return $strReplacedUrl;
    }
    if (empty($strUrl)) {
        return $strReplacedUrl;
    }
    $arr = parse_url($strUrl);
    //url不符合规范,解析失败
    if (empty($arr) || !is_array($arr)) {
        return $strReplacedUrl;
    }
    $strScheme = $arr['scheme'];
    //非http开头的url
    if (empty($strScheme) || $strScheme != 'http') {
        return $strReplacedUrl;
    }
    $strHost = $arr['host'];
    $strDictRst = Wise_Utils::getValueFromDict($strHost, 'http_to_https');
    if (empty($strDictRst)) {
        return $strReplacedUrl;
    }
    $arr['scheme'] = 'https';
    $arr['host'] = $strDictRst;
    $strBuildUrl = Wise_Utils::antiParerUrl($arr);
    if (!empty($strBuildUrl)) {
        $strReplacedUrl = $strBuildUrl;
    }
    return $strReplacedUrl;
}
示例#2
0
function smarty_function_makeTimg($params)
{
    if (!is_string($params['src'])) {
        return;
    }
    $sec = time();
    $key = "wisetimgkey";
    $di = md5($key . $sec . $params['src']);
    $scheme = "http://";
    $host = "cdn01.baidu-img.cn";
    // 判断是否在https协议下
    $ishttps = Wise_Utils::isHttps();
    if ($ishttps == 1) {
        $strDictRst = Wise_Utils::getValueFromDict($host, 'http_to_https');
        if (!empty($strDictRst)) {
            $scheme = "https://";
            $host = $strDictRst;
        }
    }
    $url = $scheme . $host . "/timg?wisealaddin&sec={$sec}&di={$di}&";
    $url .= http_build_query($params, '', '&');
    return $url;
}
示例#3
0
 public static function timgUrl($src, $size = "4", $quality = 60, $params = array())
 {
     if (!is_string($src)) {
         return;
     }
     $sec = time();
     $key = "wisetimgkey";
     $di = md5($key . $sec . $src);
     $scheme = "http://";
     $host = "cdn01.baidu-img.cn";
     // 判断是否在https协议下
     $ishttps = Wise_Utils::isHttps();
     if ($ishttps == 1) {
         $strDictRst = Wise_Utils::getValueFromDict($host, 'http_to_https');
         if (!empty($strDictRst)) {
             $scheme = "https://";
             $host = $strDictRst;
         }
     }
     $baseurl = $scheme . $host . "/timg";
     $arrParams = Saf_SmartMain::getCgi();
     if (!empty($arrParams['sampling']) && !empty($arrParams['sampling']['sids'])) {
         $sids = $arrParams['sampling']['sids'];
         if (stripos($sids, '12850') !== false || stripos($sids, '12851') !== false) {
             $quality = 100;
         }
         if (stripos($sids, '12850') !== false && $_COOKIE['webp'] == "1") {
             $imgtype = 4;
         }
     }
     if ($imgtype) {
         $url = "{$baseurl}?wisealaddin&size={$size}&imgtype={$imgtype}&quality={$quality}&sec={$sec}&di={$di}";
     } else {
         $url = "{$baseurl}?wisealaddin&size={$size}&quality={$quality}&sec={$sec}&di={$di}";
     }
     if (is_array($params)) {
         foreach ($params as $key => $value) {
             $url .= "&{$key}={$value}";
         }
     }
     $url .= "&src=" . urlencode($src);
     return $url;
 }