cnitblog.com/lxasp - - 有一种信念叫做编程
|
posts - 61, comments - 34, trackbacks - 0, articles - 0
|
|
win7禁用zip文件夹的注册表文件 Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CompressedFolder\CLSID] @="{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}-"
[HKEY_CLASSES_ROOT\CompressedFolder\ShellEx\DropHandler] @="{ed9d80b9-d157-457b-9192-0e7280313bf0}-"
[HKEY_CLASSES_ROOT\CompressedFolder\ShellEx\StorageHandler] @="{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}-"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.zip\CLSID] @="{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}-"
[HKEY_CLASSES_ROOT\CABFolder\CLSID] @="{0CD7A5C0-9F37-11CE-AE65-08002B2E1262}-"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.cab\CLSID] @="{0CD7A5C0-9F37-11CE-AE65-08002B2E1262}-" 将php作为文本文件打开的注册表文件 Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.php] "PerceivedType"="text" @="aspfile"
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>/*原生JavaScript仿jQuery的$取元素的超级迷你版*/</title>
<meta name="author" content="(pkmaster|pk4321)"/>
</head>
<body>
<div id="d1"></div>
<script>
/*原生JavaScript仿jQuery的$取元素的超级迷你版*/
(function(window, UND) {
if(window.V===UND){
var document=window.document,_GTN='getElementsByTagName'
,$=function(t){
return function(p){
return (!t)?document.getElementById(p):(!p)?document[_GTN](t)[0]:p[_GTN](t);
}
};
V=$();V.$=$;
V.K=function(v){return"function"==typeof(v)?5:"string"==typeof(v)?8:0};
V.cint=function(s){return parseInt(s,10)};
};
})(this);
</script>
<script>
/*
使用方法:
◇返回ID对应的单个元素的“单对象”:
V.$()(第二对括号:“ID”字符串) == V(ID“字符串”)
◇返回TAG对应的元素数组的首个“单对象”:
V.$(第一对括号:TAG“字符串”)()
◇返回某个父母元素的对象内部的TAG对应的“对象数组”:
V.$(第一对括号:TAG“字符串”)(第二对括号:“TAG”所在的父母元素的“对象”而不是ID“字符串”)
*/
V('d1').innerHTML=V.K(V)+V.$('title')().innerHTML+V.$('script')(V.$('body')())[1].innerHTML;
</script>
</body>
</html>
<script id="tpl" type="text/html">
<ul>
<% for (var i = 0, l = data.list.length; i < l; i ++) { %>
<li>用户: <%=data.list[i].user%> / 网站:<%=data.list[i].site%>'tmp'%</li>//
<% };var j=(i===2)?i:'j'; /*只能这样注释不能用双斜杠哦!*/ %><%=j%>
</ul>
</script>
<div id="view"></div>
<script>
$=function(n){return document.getElementById(n)};
function tpl (str) {
return new Function("data", "_", /*定义函数的参数,"data"=输入数据,"_"=输出结果字符串*/
"_='';_+=" + "'" /*构造函数体内容*/
+ str.replace(/[\r\t\n]/g, " ") /*替换全部回车符、换行符和制表符,这样有一个问题是脚本内不能出现双斜杠注释*/
.replace(/'(?=[^%]*%>)/g,"\t") /*将脚本代码内的单引号临时替换为制表符*/
.split("'").join("\\'") /*将脚本代码外的单引号转换为"输出结果字符串"内的单引号*/
.split("\t").join("'") /*将脚本代码内的制表符替换回去为单引号*/
.replace(/<%=(.+?)%>/g, "';_+=$1;_+='") /*用数据替换模板的<%=xxx%>变量*/
.split("<%").join("';") /*将起始标签替换为"输出结果字符串"的结尾并开始新的"脚本代码部分"*/
.split("%>").join("_+='") /*将结束标签替换为开始新的"输出结果字符串"*/
+ "'; return _;" /*加上"输出结果字符串"的结尾,并返回*/
);
}
$('view').innerHTML=tpl($('tpl').innerHTML)({list:[{user:"u1",site:"s1"},{user:"u2",site:"s2"}]});
</script>
其实<%%>这种标签在ASP/JSP环境下都有使用,容易造成冲突,建议换成<##>。其实#号在编程语言里使用率算底的,通常也就CSS用得多一些。用文本编辑器的替换功能将以上代码的全部%替换为#也是很方便的哦!修改后的代码如下:
<script id="tpl" type="text/html">
<ul>
<# for (var i = 0, l = ul.li.length; i < l; i ++) { #>
<li>用户: <#=ul.li[i].user#> / 网站:<#=ul.li[i].site#>'tmp'#</li>//
<# };var j=(i===2)?i:'j'; /*禁用双斜杠注释*/ #><#=j#>
</ul>
</script>
<div id="view"></div>
<script>
$=function(n){return document.getElementById(n)};
function tpl (str,dat) {
if(typeof(dat)==="undefined")dat="ul";
return new Function(dat, "_", /*定义函数的参数,"data"=输入数据,"_"=输出结果字符串*/
"_='';_+=" + "'" /*构造函数体内容*/
+ str.replace(/[\r\t\n]/g, " ") /*替换全部回车符、换行符和制表符,这样有一个问题是脚本内不能出现双斜杠注释*/
.replace(/'(?=[^#]*#>)/g,"\t") /*将脚本代码内的单引号临时替换为制表符*/
.split("'").join("\\'") /*将脚本代码外的单引号转换为"输出结果字符串"内的单引号*/
.split("\t").join("'") /*将脚本代码内的制表符替换回去为单引号*/
.replace(/<#=(.+?)#>/g, "';_+=$1;_+='") /*用数据替换模板的<#=xxx#>变量*/
.split("<#").join("';") /*将起始标签替换为"输出结果字符串"的结尾并开始新的"脚本代码部分"*/
.split("#>").join("_+='") /*将结束标签替换为开始新的"输出结果字符串"*/
+ "'; return _;" /*加上"输出结果字符串"的结尾,并返回*/
);
}
$('view').innerHTML=tpl($('tpl').innerHTML)({li:[{user:"u1",site:"s1"},{user:"u2",site:"s2"}]});
</script>
( function(window,document,UN){
document.ready = ( function(){
var readyList,
OBJ="object",OBJF="function",OBJA="array",STRC="complete",STRR="onreadystatechange",STRD="DOMContentLoaded",
// The ready event handler and self cleanup method
DOMContentLoaded = function() {
if ( document.addEventListener ) {
document.removeEventListener( STRD, DOMContentLoaded, false );
ReadyObj.ready();
} else if ( document.readyState === STRC ) {
// we're here because readyState === "complete" in oldIE
// which is good enough for us to call the dom ready!
document.detachEvent( STRR, DOMContentLoaded );
ReadyObj.ready();
}
},
ReadyObj = {
// Is the DOM ready to be used? Set to true once it occurs.
isReady: false,
// A counter to track how many items to wait for before
// the ready event fires. See #6781
readyWait: 1,
// Hold (or release) the ready event
holdReady: function( hold ) {
if ( hold ) {
ReadyObj.readyWait++;
} else {
ReadyObj.ready( true );
}
},
// Handle when the DOM is ready
ready: function( wait ) {
// Either a released hold or an DOMready/load event and not yet ready
if ( (wait === true && !--ReadyObj.readyWait) || (wait !== true && !ReadyObj.isReady) ) {
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
if ( !document.body ) {
return setTimeout( ReadyObj.ready, 1 );
}
// Remember that the DOM is ready
ReadyObj.isReady = true;
// If a normal DOM Ready event fired, decrement, and wait if need be
if ( wait !== true && --ReadyObj.readyWait > 0 ) {
return;
}
// If there are functions bound, to execute
readyList.resolveWith( document, [ ReadyObj ] );
// Trigger any bound ready events
//if ( ReadyObj.fn.trigger ) {
// ReadyObj( document ).trigger( "ready" ).unbind( "ready" );
//}
}
},
bindReady: function() {
if ( readyList ) {
return;
}
readyList = ReadyObj._Deferred();
// Catch cases where $(document).ready() is called after the
// browser event has already occurred.
if ( document.readyState === STRC ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
setTimeout( ReadyObj.ready, 1 );
// Mozilla, Opera and webkit nightlies currently support this event
} else if ( document.addEventListener ) {
// Use the handy event callback
document.addEventListener( STRD, DOMContentLoaded, false );
// A fallback to window.onload, that will always work
window.addEventListener( "load", ReadyObj.ready, false );
// If IE event model is used
} else if ( document.attachEvent ) {
// ensure firing before onload,
// maybe late but safe also for iframes
document.attachEvent( STRR, DOMContentLoaded );
// A fallback to window.onload, that will always work
window.attachEvent( "onload", ReadyObj.ready );
// If IE and not a frame
// continually check to see if the document is ready
var top = false;
try {
top = window.frameElement == null && document.documentElement;
} catch(e) {}
if ( top && top.doScroll ) {
( function doScrollCheck() {
if ( !ReadyObj.isReady ) {
try {
// Use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
top.doScroll("left");
} catch(e) {
return setTimeout( doScrollCheck, 50 );
}
// and execute any waiting functions
ReadyObj.ready();
}
})();
}
}
},
_Deferred: function() {
var // callbacks list
callbacks = [],
// stored [ context , args ]
fired,
// to avoid firing when already doing so
firing,
// flag to know if the deferred has been cancelled
cancelled,
// the deferred itself
deferred = {
// done( f1, f2, )
done: function() {
if ( !cancelled ) {
var args = arguments,
i,
length,
elem,
type,
_fired,
class2type = {};
class2type["["+OBJ+" Function]"] = OBJF;
class2type["["+OBJ+" Array]"] = OBJA;
if ( fired ) {
_fired = fired;
fired = 0;
}
for ( i = 0, length = args.length; i < length; i++ ) {
elem = args[ i ];
type=(elem == null ? String( elem ) : class2type[ Object.prototype.toString.call(elem) ] || OBJ);
if ( type === OBJA ) {
deferred.done.apply( deferred, elem );
} else if ( type === OBJF ) {
callbacks.push( elem );
}
}
if ( _fired ) {
deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
}
}
return this;
},
// resolve with given context and args
resolveWith: function( context, args ) {
if ( !cancelled && !fired && !firing ) {
// make sure args are available (#8421)
args = args || [];
firing = 1;
try {
while( callbacks[ 0 ] ) {
callbacks.shift().apply( context, args ); //shifts a callback, and applies it to document
}
}
finally {
fired = [ context, args ];
firing = 0;
}
}
return this;
},
// resolve with this as context and given arguments
resolve: function() {
deferred.resolveWith( this, arguments );
return this;
},
// Has this deferred been resolved?
isResolved: function() {
return !!( firing || fired );
},
// Cancel
cancel: function() {
cancelled = 1;
callbacks = [];
return this;
}
};
return deferred;
}
};
return function( fn ) {
// Attach the listeners
ReadyObj.bindReady();
// Add the callback
readyList.done( fn ); //readyList is result of _Deferred()
};
})();
})( this,document);
以上代码用js压缩后才1.6KB。使用示例:
<script src="docready.js"></script>
<script>/*<![CDATA[/*pkmaster@2015q4*/
$=function(n){return document.getElementById(n)};
document.ready(function(){
$('fo1').innerHTML="HELLO document.ready ok!!";
});
try{
$('fo1').innerHTML="not use document.ready fail?";
}catch(e){
document.write('fail!');
}
//]]></script>
<pre>
很多行很多的文本
</pre>
<div id="fo1">fo1</div>
var chsSplitSize = function(inputstr,size) {
var inarr = inputstr.split(""),strcurr,strnext,asccurr,ascnext,posonebase=0,lastzerobase=0,chsnext=false,i,j,k=0,ou=[],s;
inarr.push("");
for(i=0;i<inarr.length-1;i++){
strcurr=inarr[i];strnext=inarr[i+1];
try {
asccurr = strcurr.charCodeAt(0);
ascnext = strnext.charCodeAt(0);
} catch (e) {};
if (asccurr > 255){
posonebase+=2;
}else{
posonebase++;
};
if (ascnext > 255){
chsnext=true;
}else{
chsnext=false;
};
if(chsnext&&(posonebase-lastzerobase)==(size-1)){
s="";
for(j=k;j<=i;j++){
s+=inarr[j];
}
k=i+1;
lastzerobase=posonebase;
if(s.length>0)ou.push(s);
}else if((posonebase-lastzerobase)==size){
s="";
for(j=k;j<=i;j++){
s+=inarr[j];
}
k=i+1;
lastzerobase=posonebase;
if(s.length>0)ou.push(s);
}
}
if((posonebase-lastzerobase)<=size){
s="";
for(j=k;j<=i;j++){
s+=inarr[j];
}
k=i+1;
lastzerobase=posonebase;
if(s.length>0)ou.push(s);
}
return ou;
};
// 123456789012345678901
var s="",arr=chsSplitSize("一二三234我的额1额56789四五六七",12);
for(var i=0;i<arr.length;i++){
s+='<div>'+arr[i]+'</div>\n';
}
alert(s);
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <title>html5兼容xml的编写更少代码的规范</title> <style> *{margin:0;padding:0} </style> </head> <body> <pre> 第一行DOCTYPE大写,html小写 ; <br/>无子节点的标签,结束/>标签前不要额外空格 ; &#169; 特殊字符用数字编码,而不用名字&copy; ; 标志型属性用readonly="1" disabled="1" selected="1" checked="1" ; 属性值一律使用双引号括起来 ; 脚本代码如果有服务器脚本的单独分开 ; 脚本代码格式如本文档的示例 ; 按钮一律使用<button而不用<input type="button" </pre>
http://javascript-minifier.com http://cssminifier.com
<br/> <hr/>
<form id="form1" method="post" action="#"> <div class="fmfs"> <div class="fmf"><label>表单控件字段22</label><br/> <input type="text" id="i22" readonly="1"/> <button type="button" id="i22b" class="b" onclick="alert('i22')"></button> </div> </div> </form>
版权字符 &#169;
<script>/*<![CDATA[/*pkmaster@2015q2*/ (function(WN,DC,UN){ var php=WN.$P?WN.$P:$P={}; <?php echo 'php["hello"]="hello world";'?> })(this,document); //]]></script>
<script>/*<![CDATA[/*pkmaster@2015q2*/ (function(WN,DC,UN){ var php=WN.$P?WN.$P:$P={}; DC.getElementById("i22").value=(UN!==php["hello"]?php["hello"]:""); alert(UN!==php["und"]?php["und"]:"0"); })(this,document); //]]></script>
</body> </html> 页面内javascript代码书写示例:
(function(Win,Doc,Und){ var php=Win.$P?Win.$P:$P={}; php['v1']='1'; })(this,document);
(function(Win,Doc,Und){ var php=Win.$P?Win.$P:$P={}; php['v2']='2'; })(this,document);
(function(Win,Doc,Und){ var php=Win.$P?Win.$P:$P={}; alert(php['v2']===Und?php['v1']:!1); })(this,document);
从github上找来的js,自己写了个hta方便使用而已。
自己修改增强了对含有服务器代码的html文件的精简,即html里的 <? ?> <% %>里的代码原封不动。
HTM标签内有PHP/ASP代码,加注释后缀: <img <?php echo 'alt="禁用换行和中文"' //php?> <%=ASP(VBS) 'rem%> /*[tag]*/ />
minjshtm.cab.zip
专用win7+ie9的 virtualbox虚拟机(建议选版本4.3.16)镜像下载链接: http://pan.baidu.com/s/1qWxbPN2 密码:dxzq
<!DOCTYPE html> <html> <head> <title>正则表达式判断密码复杂度(原生JavaScript)</title> </head> <body> <form id="form1" method="post" action="#"> <div class="fmfs"> <div class="fmf"><label>创建密码(至少6位):</label><br /><input type="password" id="i1" name="password" onblur="var r=this.value.length>=6?pwdRank(this.value):0;this.style.backgroundColor=(r==1?'#ccc':r==2?'#ff0':r==3?'#0f0':r==4?'#0ff':r==5?'#00f':'#fff');" /></div> <div class="fmf"><label>重复密码:</label><br /><input type="password" id="i2" name="password1" /></div> </div> </form> <pre> <script> /** * 正则表达式判断密码复杂度(原生JavaScript) * * @param {String} 输入明文密码 * * @return {Number} 返回 1,2,3,4,5 个级别权重的复杂度 * * @example * document.write( * pwdRank("ABCdefg1234")+'\n'+ * pwdRank("aaBB11__CCDDee")+'\n'+ * pwdRank("aaBB11__CCDD")+'\n'+ * pwdRank("abA1_")+'\n'+ * pwdRank("11_")+'\n'+ * pwdRank("111aaaAAA111aaaAAA")+'\n'+ * pwdRank("AAA___AAA___AAA__")+'\n'+ * pwdRank("0123456789123")+'\n'+ * pwdRank("012345678912346789")+'\n' * ); */ pwdRank=function(w){ //取字符串长度 var l=w.length, f=function(x,s){ //正则表达式判断函数 return ((eval('/'+x+'/').test(s))?1:0) }, //求和获得4种密码字符组合方式 z=f('[0-9]',w)+f('[a-z]',w)+f('[A-Z]',w)+f('[\\W_]',w), //只有一种组合情况下长度11位或以上才加权重 --避免0123456789这种弱密码 r=(l>10&&z==1)?z+1:z; //任何组合情况下但有多个重复字符串减权重 if(r>1&&f('^(?:(\\w+)\\1+)+$|(\\w)\\2{2,}',w))r--; //多种组合长度12位或以上加权重,一种组合13位或以上加权重 if((l>11&&z>1)||(l>12&&z==1))r++; //长度14位或以上再加权重 if(l>13&&r<5)r++; return r; };
document.write( pwdRank("ABCdefg1234")+'\n'+ pwdRank("aaBB11__CCDDee")+'\n'+ pwdRank("aaBB11__CCDD")+'\n'+ pwdRank("abA1_")+'\n'+ pwdRank("11_")+'\n'+ pwdRank("111aaaAAA111aaaAAA")+'\n'+ pwdRank("AAA___AAA___AAA__")+'\n'+ pwdRank("0123456789123")+'\n'+ pwdRank("012345678912346789")+'\n' );
</script>
1=很弱 2=普通 3=中等 4=较强 5=很强 </pre> </body> </html>
function isIDCardCn(idValue) { if (idValue.length != 18) return !1; var verifyGmsfhLast = function(sVal) { if (sVal.length != 18) return !1; var wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1], vi = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2], ai = [17], sum = 0, remaining = 0, verifyNum = "", i, m; for (i = 0; i < 17; i++) { ai[i] = parseInt(sVal.substring(i, i + 1), 10) } for (m = 0; m < ai.length; m++) { sum = sum + wi[m] * ai[m] } remaining = sum % 11; if (remaining == 2) { verifyNum = "X" } else { verifyNum = vi[remaining] } return verifyNum == sVal.substring(17, 18).toUpperCase() }, a = idValue.match(/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([\dXx])$/); if (a != null) { var D = new Date(a[2] + "/" + a[3] + "/" + a[4]), B = D.getFullYear() == a[2] && (D.getMonth() + 1) == a[3] && D.getDate() == a[4] if (!B) return !1; } return verifyGmsfhLast(idValue) } !function(s) { var i,r = ""; for (i = 0; i < 100; i++) { if (i < 10 && isIDCardCn(s + '0' + i)) { r += s + '0' + i + "<br>" } else { if (isIDCardCn(s + i)) r += s + i + "<br>" } } for (i = 0; i < 10; i++) { if (isIDCardCn(s + i + "x")) r += s + i + 'X' + "<br>" } document.write(r); }("1122331999112233");
RewriteRule ^(.*)$ index.php?/$1 [L]
缺少个?号,现在新版的PHP一般都是FastCGI运行的了,所以一般都会出现错误: No input file specified.
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
|
|