JS - ExtendForm.js
JS
var Ly = {
createElement : function(target, config){
var target = target || 'div';
var config = config || {};
var tag = document.createElement(target);
for(var p in config){
if(p.toLowerCase() == 'style'){
tag.style.cssText = config[p];
}else if(p.toLowerCase() == 'class' || p.toLowerCase() == 'cls'){
tag.className = config[p];
}else if(p.toLowerCase() == 'innerhtml'){
tag.innerHtml = config[p];
}else{
tag.setAttribute(p, config[p]);
}
}
try{
return tag;
}finally{
tag = null;
}
}
};
var ExtendForm = {
params : {},
form : null,
config : {},
create : function () {
document.body.appendChild(this.form = Ly.createElement('form', {
action : this.config.action,
method : this.config.method,
target : this.config.target
}));
return this;
},
init : function (config) {
config = config || {};
this.config = {
action : config.action || '?',
method : config.method || 'post',
target : config.target || '_self'
};
return this;
},
bind : function (data) {
if(typeof data != 'object'){
return null;
}
this.params = {};
for(var p in data){
switch (typeof data[p]){
case 'string':
case 'number':
this.params[p] = data[p];
break;
case 'object':
if(data[p].constructor === Array){
this.params[p] = data[p].join(',');
}
break;
case 'boolean':
this.params[p] = data[p];
break;
}
}
return this;
},
send :function () {
if(!this.params){
return null;
}
this.create();
for(var p in this.params){
this.form.appendChild(Ly.createElement('input', {
type : 'hidden',
name : p,
value : this.params[p]
}));
}
this.form.submit();
this.clear();
return this;
},
clear : function () {
var inputs = this.form.childNodes;
for(var i = inputs.length-1;i>-1;--i){
this.form.removeChild(inputs[i]);
inputs[i] && (inputs[i] = null);
}
document.body.removeChild(this.form);
this.form = null;
}
};
ExtendForm.init({
action : 'http://demo.xiaowiba.com/demo/result.php',
target : '_blank',
method : 'post'
}).bind({
param : '小尾巴'
}).send();
JS - 正则表达式
;
(function(root, factory) {
if (typeof exports === /object/ && typeof module != /undefined/) {
module.exports = factory();
} else if (typeof define === /function/ && define.amd) {
define(factory);
} else {
root.RegexExpress = factory();
}
}(this, function(root, undefined) {
var RegexExpress = function() {}
var config = {
//汉字
isZH_CN: /^[\u4e00-\u9fa5]{0,}$/,
//英文和数字
isEnOrDigit: /^[A-Za-z0-9]+$/,
//长度为3-20的所有字符,
isChar3_20: /^.{3,20}$/,
//由26个英文字母组成的字符串
isEn: /^[A-Za-z]+$/,
//由26个大写英文字母组成的字符串
isEnAndUpper: /^[A-Z]+$/,
//由26个小写英文字母组成的字符串
isEnAndLower: /^[a-z]+$/,
//由数字、26个英文字母或者下划线组成的字符串:^\w+$ 或 ^\w{3,20}$
isDigitOrEnOr_Fixed: /^\w+$/,
//中文、英文、数字包括下划线
isZhOrEnOrDigitOr_Fixed: /^[\u4E00-\u9FA5A-Za-z0-9_]+$/,
//中文、英文、数字但不包括下划线等符号 ^[\u4E00-\u9FA5A-Za-z0-9]+$ 或 ^[\u4E00-\u9FA5A-Za-z0-9]{2,20}$
isZhOrEnOrDigitFixed: /^[\u4E00-\u9FA5A-Za-z0-9]+$/,
//输入含有^%&/,;=?$\
isContainIllegalChar: /[^%&\/,;=?$\x22]+/,
//Email地址
isEmail: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
//域名
isDomain: /[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\/.?/,
//[a-zA-z]+://[^\s]* 或 ^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$
isInternetURL: /^http:\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$/,
//手机号码
isPhone: /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/,
//身份证号(15位、18位数字)
isIDCard: /^\d{15}|\d{18}$/,
//^([0-9]){7,18}(x|X)?$ 或 ^\d{8,18}|[0-9x]{8,18}|[0-9X]{8,18}?$
isShortIDCard: /^([0-9]){7,18}(x|X)?$/,
//帐号是否合法(字母开头,允许5-16字节,允许字母数字下划线)
isIllegalUserName: /^[a-zA-Z][a-zA-Z0-9_]{4,15}$/,
//密码(以字母开头,长度在6~18之间,只能包含字母、数字和下划线)
isPwd: /^[a-zA-Z]\w{5,17}$/,
//强密码(必须包含大小写字母和数字的组合,不能使用特殊字符,长度在8-10之间)
isPowerPwd: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$/,
//日期格式
isDate: /^\d{4}-\d{1,2}-\d{1,2}/,
//(01~09和10~12)
isMonth: /^(0?[1-9]|1[0-2])$/,
//一个月的31天(01~09和10~31)
isDay: /^((0?[1-9])|((1|2)[0-9])|30|31)$/,
//金钱
isMoney: /^([0-9]+|[0-9]{1,3}(,[0-9]{3})*)(.[0-9]{1,2})?$/,
//xml
isXml: /^([a-zA-Z]+-?)+[a-zA-Z0-9]+\\.[x|X][m|M][l|L]$/,
//(包括汉字在内,可以用来计算字符串的长度(一个双字节字符长度计2,ASCII字符计1))
isDoubleByte: /[^\x00-\xff]/,
//空白字符
isWritespace: /[\s+]/,
// (腾讯QQ号从10000开始)
isQQ: /[1-9][0-9]{4,}/,
//(中国邮政编码为6位数字)
isZipCode: /[1-9]\d{5}(?!\d)/,
//IP
isIpaddress: /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/,
};
RegexExpress.prototype = {
isZH_CN: function(str) {
return config.isZH_CN.test(str);
},
isEnOrDigit: function(str) {
return config.isEnOrDigit.test(str);
},
isChar3_20: function(str) {
return config.isChar3_20.test(str);
},
isEn: function(str) {
return config.isEn.test(str);
},
isEnAndUpper: function(str) {
return config.isEnAndUpper.test(str);
},
isEnAndLower: function(str) {
return config.isEnAndLower.test(str);
},
isDigitOrEnOr_Fixed: function(str) {
return config.isDigitOrEnOr_Fixed.test(str);
},
isZhOrEnOrDigitOr_Fixed: function(str) {
return config.isZhOrEnOrDigitOr_Fixed.test(str);
},
isZhOrEnOrDigitFixed: function(str) {
return config.isZhOrEnOrDigitFixed.test(str);
},
isContainIllegalChar: function(str) {
return config.isContainIllegalChar.test(str);
},
isEmail: function(str) {
return config.isEmail.test(str);
},
isDomain: function(str) {
return config.isDomain.test(str);
},
isInternetURL: function(str) {
return config.isInternetURL.test(str);
},
isPhone: function(str) {
return config.isPhone.test(str);
},
isIDCard: function(str) {
return config.isIDCard.test(str);
},
isShortIDCard: function(str) {
return config.isShortIDCard.test(str);
},
isIllegalUserName: function(str) {
return config.isIllegalUserName.test(str);
},
isPwd: function(str) {
return config.isPwd.test(str);
},
isPowerPwd: function(str) {
return config.isPowerPwd.test(str);
},
isDate: function(str) {
return config.isDate.test(str);
},
isMonth: function(str) {
return config.isMonth.test(str);
},
isDay: function(str) {
return config.isDay.test(str);
},
isMoney: function(str) {
return config.isMoney.test(str);
},
isXml: function(str) {
return config.isXml.test(str);
},
isDoubleByte: function(str) {
return config.isDoubleByte.test(str);
},
isWritespace: function(str) {
return config.isWritespace.test(str);
},
isQQ: function(str) {
return config.isQQ.test(str);
},
isZipCode: function(str) {
return config.isZipCode.test(str);
},
isIpaddress: function(str) {
return config.isIpaddress.test(str);
},
}
return RegexExpress;
}));
Typecho - 关闭评论
footer.php
<?php //$this->need('component/comments.php'); ?>
最近好多随机英文字符评论,暂时先关闭评论了,过年前再打开。
JS - 获取昨天、今天的日期
获取昨天日期
function yesterday() {
var timenow = new Date();
timenow.setDate(timenow.getDate() - 1); //设置天数 -1 天,昨天的日期
var y = timenow.getFullYear();//年
var m = timenow.getMonth() + 1;//月
m = m < 10 ? '0' + m : m;
var d = timenow.getDate();//日
d = d < 10 ? ('0' + d) : d;
var yesterdayTime = y + '/' + m + '/' + d;//yyyy/mm/dd格式
return yesterdayTime;
}
apache - 映射
Alias /imgSrc/ “/sdzw/ibp/upload/ptlogin/”
<Directory “/sdzw/ibp/upload/ptlogin/”>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</ Directory>