您正在使用 IPV4 [18.119.107.161] 访问本站,您本次已经查看了 1 页
用户名: 密 码: 验证码:     用QQ登录本站
首页 软件 编程 笑话 知识 公告 台风 日历 计算器
[公益]保护绿色环境,构建和谐社会       悟空收录网      

【腾讯云】 爆款2核2G3M云服务器首年 61元,叠加红包再享折上折      
[公益] 地球是我家,绿化靠大家      
2024年 劳动节 012
2024年 端午节 052
2025年 元 旦 257
2025年 春 节 285
 
您现在的位置:首页 >> PHP >> 内容
本类新增
本类热门
PHP实现保存网站用户密码到css文件
内容摘要: ?php/***完整调用示例:*1、combine.php?t=jb=publicfs=jslib.jquery,function**该例子调用的是网站根目录下的public/jslib/jquery.js和public/function.js**2、combine.php?t=jfs=jslib.jquery,function**该例子调用的是网站根目录下......
<?php

/**

*完整调用示例:

*1、combine.php?t=j&b=public&fs=jslib.jquery,function

*

*该例子调用的是网站根目录下的public/jslib/jquery.js和public/function.js

*

*2、combine.php?t=j&fs=jslib.jquery,function

*

*该例子调用的是网站根目录下的jslib/jquery.js和function.js

*

*3、combine.php?t=c&b=public.css&fs=common,index

*

*该例子调用的是网站根目录下的public/css/common.css和public/css/index.css

*

*4、combine.php?t=c&fs=css.common

*该例子调用的是网站根目录下的css/common.css

*

*注:多个文件名之间用,分隔;只有一个文件名最后不要有,

*用,分隔的多个文件会被压缩进一个文件,一次性传给浏览器

**/

$is_bad_request=false;

$cache=true;

$doc_root_uri=$_SERVER['DOCUMENT_ROOT'].'/';

$cachedir=$doc_root_uri.'public/cache';

//文件类型,j为js,c为css

$type=isset($_GET['t'])?($_GET['t']=='j'||$_GET['t']=='c'?$_GET['t']:''):'';

//存放js和css文件的基目录,例如:?b=public.js代表的是/public/js文件夹,出发点是网站根目录

//基目录参数不是必须的,如果有基目录那么这个基目录就会附加在文件名之前

$base=isset($_GET['b'])?($doc_root_uri.str_replace('.','/',$_GET['b'])):$doc_root_uri;

//文件名列表,文件名不带后缀名.比如基目录是

//文件名的格式是:基目录(如果有)+文件包名+文件名

//例如:类型是j,

//文件名public.js.jquery

//如果有基路径且为public,

//那么转换后的文件名就是/public/public/js/jquery.js

//如果没有基路径

//那么转换后的文件名就是/public/js/jquery.js

//多个文件名之间用,分隔

$fs=isset($_GET['fs'])?str_replace('.','/',$_GET['fs']):'';

$fs=str_replace(',','.'.($type=='j'?'js,':'css,'),$fs);

$fs=$fs.($type=='j'?'.js':'.css');

if($type==''||$fs==''){$is_bad_request=true;}

//die($base);

if($is_bad_request){header("HTTP/1.0503NotImplemented");}

$file_type=$type=='j'?'javascript':'css';

$elements=explode(',',preg_replace('/([^?]*).*/','1',$fs));

//Determinelastmodificationdateofthefiles

$lastmodified=0;

while(list(,$element)=each($elements)){

$path=$base.'/'.$element;

if(($type=='j'&&substr($path,-3)!='.js')||

($type=='c'&&substr($path,-4)!='.css')){

header("HTTP/1.0403Forbidden");

exit;

}

if(substr($path,0,strlen($base))!=$base||!file_exists($path)){

header("HTTP/1.0404NotFound");

exit;

}

$lastmodified=max($lastmodified,filemtime($path));

}

//SendEtaghash

$hash=$lastmodified.'-'.md5($fs);

header("Etag:"".$hash.""");

if(isset($_SERVER['HTTP_IF_NONE_MATCH'])&&

stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])=='"'.$hash.'"')

{

//Returnvisitandnomodifications,sodonotsendanything

header("HTTP/1.0304NotModified");

header("Content-Type:text/".$file_type);

header('Content-Length:0');

}

else

{

//Firsttimevisitorfilesweremodified

if($cache)

{

//Determinesupportedcompressionmethod

$gzip=strstr($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip');

$deflate=strstr($_SERVER['HTTP_ACCEPT_ENCODING'],'deflate');

//Determineusedcompressionmethod

$encoding=$gzip?'gzip':($deflate?'deflate':'none');

//CheckforbuggyversionsofInternetExplorer

if(!strstr($_SERVER['HTTP_USER_AGENT'],'Opera')&&

preg_match('/^Mozilla/4.0(compatible;MSIE([0-9].[0-9])/i',$_SERVER['HTTP_USER_AGENT'],$matches)){

$version=floatval($matches[1]);

if($version<6)

$encoding='none';

if($version==6&&!strstr($_SERVER['HTTP_USER_AGENT'],'EV1'))

$encoding='none';

}

//Trythecachefirsttoseeifthecombinedfileswerealreadygenerated

$cachefile='cache-'.$hash.'.'.$file_type.($encoding!='none'?'.'.$encoding:'');

if(file_exists($cachedir.'/'.$cachefile)){

if($fp=fopen($cachedir.'/'.$cachefile,'rb')){

if($encoding!='none'){

header("Content-Encoding:".$encoding);

}

header("Content-Type:text/".$file_type);

header("Content-Length:".filesize($cachedir.'/'.$cachefile));

fpassthru($fp);

fclose($fp);

exit;

}

}

}

//Getcontentsofthefiles

$contents='';

reset($elements);

while(list(,$element)=each($elements)){

$path=$base.'/'.$element;

$contents.="nn".file_get_contents($path);

}

//SendContent-Type

header("Content-Type:text/".$file_type);

if(isset($encoding)&&$encoding!='none')

{

//Sendcompressedcontents

$contents=gzencode($contents,9,$gzip?FORCE_GZIP:FORCE_DEFLATE);

header("Content-Encoding:".$encoding);

header('Content-Length:'.strlen($contents));

echo$contents;

}

else

{

//Sendregularcontents

header('Content-Length:'.strlen($contents));

echo$contents;

}

//Storecache

if($cache){

if($fp=fopen($cachedir.'/'.$cachefile,'wb')){

fwrite($fp,$contents);

fclose($fp);

}

}

}

版权声明:本内容来源于互联网,如有侵犯您的版权,请联系站长,本站收到您的信息后将及时处理。
上一篇:PHP正则判断一个变量是否为正整数的方法

 

下一篇:PHP调用OpenOffice实现word转PDF的方法

发布日期:2022/5/19
手机扫二维码直达本页
发布时间:13:11:11
点  击:4
录  入:齐天大圣
相关文章
Baidu
YiJiaCMS 7.3.8 build231228(MSSQL) 闽ICP备05000814号-1
本空间由腾讯云(轻量应用服务器)提供,Cloudflare提供加速防护
运行时间载入中.....