验证码生成程序与使用方法
//调用此页面,如果下面的式子成立,则生成验证码图片
代码如下 | 复制代码 |
if($_get['action']=='verifycode'){ header('content-type: image/png'); //准备好随机数发生器种子 |
调用方法
代码如下 | 复制代码 |
<img src="code.php?action=verifycode" /> |
判断验证码是否输入正确
代码如下 | 复制代码 |
<? |
会员注册验证代码(php教程+mysql教程+ajax)
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="images/css教程.css" rel="stylesheet" type="text/css" />
<title>会员注册验证代码(php+mysql+ajax)</title>
<script language="网页特效" src="网页特效/common.网页特效"></script>
<script language="网页特效" src="js/prototype.js"></script>
<script language="javascript" src="js/passwordstrength.js"></script>
<script language="javascript">
var icon = '';
var ns = ["usr","pwd","repwd","eml"];
function changeusr(){
if($("checkbtn").disabled) $("checkbtn").disabled = false;
}
function checkusr(s){
var ma = ["用户名(4-16位)!","用户名由数字、英文、下划线、中杠线组成!"];
if(!limitlen(s,4,16)){
showinfo("usr",ma[0]);
return false;
}
if(!hasaccountchar(s)){
showinfo("usr",ma[1]);
return false;
}
showinfo("usr");
return true;
}
function checkpwd(s){
var ma = ["密码(6-16位)!","密码不能包含中文或全角符号!","两次输入的密码不一致!"];
ps教程.update(s);
if(!limitlen(s,6,16)){
showinfo("pwd",ma[0]);
return false;
}
if(haschinesechar(s)){
showinfo("pwd",ma[1]);
return false;
}
if(limitlen($f("repwdinput"),6,16)){
if(trim($f("repwdinput")) == trim(s)){
showinfo("pwd");
showinfo("repwd");
return true;
}else{
showinfo("pwd",ma[2]);
return false;
}
}
showinfo("pwd");
return true;
}
function checkpwd2(s){
var ma = ["确认密码(6-16位)!","密码不能包含中文或全角符号!","两次输入的密码不一致!"];
if(!limitlen(s,6,16)){
showinfo("repwd",ma[0]);
return false;
}
if(haschinesechar(s)){
showinfo("repwd",ma[1]);
return false;
}
if(limitlen($f("pwdinput"),6,16)){
if(trim($f("pwdinput")) == trim(s)){
showinfo("pwd");
showinfo("repwd");
return true;
}else{
showinfo("repwd",ma[2]);
return false;
}
}
showinfo("repwd");
return true;
}
function checkeml(s){
var ma = ["请输入常用邮件!","邮件格式不正确!"];
if(s.length < 5){
showinfo("eml",ma[0]);
return false;
}
if(!isemail(s)){
showinfo("eml",ma[1]);
return false;
}
showinfo("eml");
return true;
}
function showinfo(n,s){
var fdo = $(n+"framediv");
var ido = $(n+"infodiv");
if(typeof s == 'undefined'){
fdo.classname = "framedivpass";
ido.innerhtml = "<img src=images/duihao.jpg>";
}else{
fdo.classname = "framedivwarn";
ido.innerhtml = icon + s;
}
}
//======================================================;
function loadcheck(){
if(trim($f('usrinput')).length == 0) return;
$("checkbtn").disabled = true;
var o = $("checkdiv");
o.innerhtml = getloadinfo();
loadajaxdata("reg.php",{usr:$f('usrinput')},successcheck,errorcheck);
}
function successcheck(v){
var o = $("checkdiv");
o.innerhtml = getcheckhtml(v.responsetext);
}
function errorcheck(){
$("checkbtn").disabled = false;
var o = $("checkdiv");
o.innerhtml = geterrorinfo();
}
function getcheckhtml(s){
s = (s == "1")? "恭喜您,用户名可以注册!":"对不起,该用户名已经被注册!";
return s;
}
//======================================================;
function getloadinfo(){
return '正在加载数据...';
}
function geterrorinfo(){
return '数据加载失败!';
}
//======================================================;
function initpage(){
for(var i=0;i<ns.length;i++){
$(ns[i]+"input").value = "";
}
}
function checksignup() {
if ( document.formsignup.reauthnum.value == '' ) {
window.alert('请输入认证码!!');
document.formsignup.reauthnum.focus();
return false;
}
return true;
}
function isallow_jewellry(){
if(document.formsignup.agree.checked == false){
document.formsignup.submit.disabled = true;
}else if(document.formsignup.agree.checked == true){
document.formsignup.submit.disabled = false;
}
}
</script>
</head>
<body class="statusbar" onload="initpage();">
<table width="100%" class="wn_login_01">
<tr>
<td></td>
</tr>
</table>
<table width="100%">
<tr>
<td height="24"></td>
</tr>
</table>
<table width="721" align="center">
<tr>
<td height="97" class="hyzc-4"></td>
</tr>
</table>
<table width="721" align="center">
<tr>
<td height="22" class="hyzc-5"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="28"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td class="hyzc-8">请注册会员,只有会员才能发表贴子,游客可以回贴和使用快捷回复功能!</td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="25"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="45"></td>
<td width="420"><font class="hyzc-1-1">提示:</font><font class="hyzc-9">如果您已经注册了会员,请跳过此步骤,直接点这里</font></td>
<td width="248"><form id="form1" name="form1" method="post" action="">
<input type="image" name="imagefield" src="images/hyzc-3.jpg" />
</form>
</td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="18"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="30"></td>
<td width="653" height="1" class="hyzc-1-2"></td>
<td width="30"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="18"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<form id="form2" name="formsignup" method="post" action="" >
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="45"></td>
<td width="130"><font class="hyzc-1-1">填写登录名和密码</font> <font class="hyzc-6">*</font></td>
<td width="85" align="right">登录名:</td>
<td class="hyzc-1-5">
<span class="framedivnormal" id="usrframediv">
<input type="text" name="usrinput" id="usrinput" class="hyzc-1-3" onkeyup="checkusr(this.value);changeusr();" onfocus="checkusr(this.value);"> <span id="usrinfodiv" class="hyzc-6"></span></span>
</td>
<td width="4" class="hyzc-7"></td>
<tr><tr height=30><td class="hyzc-7"></td><td></td><td></td><td></td><td valign=bottom> <input name="checkbtn" type="button" id="checkbtn" onclick="loadcheck();" value="检测用户名是否可用"> <span id="checkdiv"></span></td><td class="hyzc-7"></td></tr>
</table>
<table width="721" border="0" align="center"><tr><td width="4" class="hyzc-7"></td><td width="713" height="8"></td><td width="4" class="hyzc-7"></td></table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="165"></td>
<td width="10"><font class="hyzc-6">*</font></td>
<td width="90" align="right">输入登录密码: </td>
<td><span class="framedivnormal" id="pwdframediv"> <input name="pwdinput" type="password" id="pwdinput" maxlength="16" onkeyup="checkpwd(this.value);" onfocus="checkpwd(this.value);" class="hyzc-1-3"> <span id="pwdinfodiv" class="hyzc-6"></span>
</span>
</td>
<td width="4" class="hyzc-7"></td>
</tr>
<tr height=30><td class="hyzc-7"></td><td></td><td></td><td></td><td><script language="javascript">
var ps = new passwordstrength();
ps.setsize("200","22");
</script></td><td class="hyzc-7"></td></tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="5"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="165"></td>
<td width="10"><font class="hyzc-6">*</font></td>
<td width="90" align="right">再次输入密码: </td>
<td >
<span class="framedivnormal" id="repwdframediv"><input name="repwdinput" type="password" id="repwdinput" maxlength="16" onkeyup="checkpwd2(this.value);" onfocus="checkpwd2(this.value);" class="hyzc-1-3">
<span id="repwdinfodiv" class="hyzc-6"></span>
</span>
</td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="5"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="30"></td>
<td width="653" height="1" class="hyzc-1-2"></td>
<td width="30"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="20"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="45"></td>
<td width="120"><font class="hyzc-1-1">填写个人资料信息</font></td>
<td width="10"><font class="hyzc-6">*</font></td>
<td width="90" align="right">邮箱: </td>
<td><span class="framedivnormal" id="emlframediv"><input name="emlinput" type="text" id="emlinput" onfocus="checkeml(this.value);" onkeyup="checkeml(this.value);" maxlength="40" class="hyzc-1-3">
<span id="emlinfodiv" class="hyzc-6"></span>
</span>
</td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="5"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="45"></td>
<td width="120"></td>
<td width="10"></td>
<td width="85" align="right">性别:</td>
<td width="175" class="hyzc-1-5"><input name="radiobutton" type="radio" value="radiobutton" checked="checked" />
男<input type="radio" name="radiobutton" value="radiobutton" />
女</td>
<td width="270"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="15"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="45"></td>
<td width="120"></td>
<td width="10"></td>
<td width="85" align="right">出生日期:</td>
<td width="225" class="hyzc-1-5">
<select name="select">
<option value="1">1900</option>
<option value="1">2009</option>
</select>年
<select name="select">
<option value="1">01</option>
<option value="1">02</option>
<option value="1">03</option>
<option value="1">04</option>
<option value="1">05</option>
<option value="1">06</option>
<option value="1">07</option>
<option value="1">08</option>
<option value="1">09</option>
<option value="1">10</option>
<option value="1">11</option>
<option value="1">12</option>
</select>月
<select name="select">
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
<option value="4">04</option>
<option value="5">05</option>
<option value="6">06</option>
<option value="7">07</option>
<option value="8">08</option>
<option value="9">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>日 </td>
<td width="220"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="15"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="45"></td>
<td width="120"></td>
<td width="10"><font class="hyzc-6">*</font></td>
<td width="85" align="right">验证码:</td>
<td width="112" class="hyzc-1-5">
<input type="text" name="reauthnum" class="hyzc-1-6" /> </td>
<td width="74"><img src="images/authimg.png"></td>
<td width="262"><a href="#" class="hyzc-3">看不清图片</a></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="20"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="30"></td>
<td width="653" height="1" class="hyzc-1-2"></td>
<td width="30"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="20"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="45"></td>
<td width="120"></td>
<td width="15"><font class="hyzc-6">*</font></td>
<td width="30"><input name="agree" type="checkbox" class="hyzc-1-7" value="1" checked="checked" onclick="isallow_jewellry()"/></td>
<td width="503">我已经看过并同意<a href="#" class="hyzc-1-8">《人民在线论坛网络服务使用协议》</a></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="15"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="45"></td>
<td width="110"></td>
<td width="558"><textarea name="textarea" class="hyzc-1-9" readonly="readonly">
</textarea></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="40"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="45"></td>
<td width="240"></td>
<td><input type="submit" name="submit" value="提交确认" tabindex="1" onclick='javascript:return checksignup()'></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" border="0" align="center">
<tr>
<td width="4" class="hyzc-7"></td>
<td width="713" height="40"></td>
<td width="4" class="hyzc-7"></td>
</tr>
</table>
<table width="721" align="center">
<tr>
<td class="wn_login_02_06"></td>
</tr>
</table>
</form>
</body>
</html>
下面为js文件代码
<script language="javascript" >
//js/common.js
//引用js/css文件;
function include(path,type,title){
var s,i,t;
if(arguments.length < 1){
return ;
}
if(arguments.length == 1){
type = "js";
}
switch(type.tolowercase()){
case "css":
t = document.getelementsbytagname("link");
for(i=0;i<t.length;i++){
if(t[i].href && t[i].href.indexof(path)!=-1){
return;
}
}
s=document.createelement("link");
s.rel="alternate stylesheet";
s.type="text/css";
s.href=path;
s.title=title;
s.disabled=false;
break;
case "js":
case "javascript":
default:
t = document.getelementsbytagname("script");
for(i=0;i<t.length;i++){
if(t[i].src && t[i].src.indexof(path)!=-1){
return;
}
}
s=document.createelement("script");
s.type="text/javascript";
s.src=path;
break;
}
var h=document.getelementsbytagname("head")[0];
h.appendchild(s);
}
//字符处理;
//去左右空格;
function trim(s){
return rtrim(ltrim(s));
}
//去左空格;
function ltrim(s){
return s.replace( /^s*/, "");
}
//去右空格;
function rtrim(s){
return s.replace( /s*$/, "");
}
//验证信息;
//空字符值;
function isempty(s){
s = trim(s);
return s.length == 0;
}
//email;
function isemail(s){
s = trim(s);
var p = /^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.){1,4}[a-z]{2,3}$/i;
return p.test(s);
}
//数字;
function isnumber(s){
return !isnan(s);
}
//颜色值;
function iscolor(s){
s = trim(s);
if (s.length !=7) return false;
return s.search(/#[a-fa-f0-9]{6}/) != -1;
}
//手机号码;
function ismobile(s){
s = trim(s);
var p = /13d{9}/;
return p.test(s);
}
//身份证;
function iscard(s){
s = trim(s);
var p = /^d{15}(d{2}[xx0-9])?$/;
return p.test(s);
}
//url;
function isurl(s){
s = trim(s).tolowercase();
var p = /^http://[a-za-z0-9]+.[a-za-z0-9]+[/=?%-&_~`@[]':+!]*([^<>""])*$/;
return p.test(s);
}
//phone;
function isphone(s){
s = trim(s);
var p = /^(((d{3}))|(d{3}-))?((0d{2,3})|0d{2,3}-)?[1-9]d{6,7}$/;
return p.test(s);
}
//zip;
function iszip(s){
s = trim(s);
var p = /^[1-9]d{5}$/;
return p.test(s);
}
//double;
function isdouble(s){
s = trim(s);
var p = /^[-+]?d+(.d+)?$/;
return p.test(s);
}
//integer;
function isinteger(s){
s = trim(s);
var p = /^[-+]?d+$/;
return p.test(s);
}
//english;
function isenglish(s){
s = trim(s);
var p = /^[a-za-z]+$/;
return p.test(s);
}
//中文;
function ischinese(s){
s = trim(s);
var p = /^[u0391-uffe5]+$/;
return p.test(s);
}
//双字节
function isdoublechar(s){
var p = /^[^x00-xff]+$/;
return p.test(s);
}
//含有中文字符
function haschinesechar(s){
var p = /[^x00-xff]/;
return p.test(s);
}
function hasaccountchar(s){
var p = /^[a-za-z0-9][a-za-z0-9_-]{0,15}$/;
return p.test(s);
}
function limitlen(s,min,max){
s=trim(s);
if(s=="") return false;
if((s.length<min)||(s.length>max))
return false;
else
return true;
}
//功能;
//延时事件;
function setdeferevent(type,action,time){
if (trim(time).length == 0) time = 1;
if (typeof(time)!="number") time = 1;
switch(type.tolowercase()){
case "go":
window.settimeout("window.location='"+ action +"'",time);
break;
case "alert":
window.settimeout("alert('"+ action +"')",time);
break;
case "js":
case "javascript":
window.settimeout("'"+ action.tostring() +"'",time);
break;
default:
alert("nothing will do!");
break
}
}
function addloadlistener(handler){
if (typeof window.addeventlistener != 'undefined')
window.addeventlistener('load', handler, false);
else if (typeof document.addeventlistener != 'undefined')
document.addeventlistener('load', handler, false);
else if (typeof window.attachevent != 'undefined')
window.attachevent('onload', handler);
};
function addeventlistener(element, eventtype, handler, capture)
{
try
{
if (element.addeventlistener)
element.addeventlistener(eventtype, handler, capture);
else if (element.attachevent)
element.attachevent("on" + eventtype, handler);
}
catch (e) {}
};
function removeeventlistener(element, eventtype, handler, capture)
{
try
{
if (element.removeeventlistener)
element.removeeventlistener(eventtype, handler, capture);
else if (element.detachevent)
element.detachevent("on" + eventtype, handler);
}
catch (e) {}
};
//image;
function preloadimages(){
var d = document;
if(d.images){
if(!d.p_i_a) d.p_i_a = new array();
var i,j=d.p_i_a.length,a=arguments;
for(i=0;i<a.length;i++){
d.p_i_a[j]= new image();
d.p_i_a[j++].src = a[i];
}
}
}
//ajax功能;
function loadajaxelement(e,u,p,f,l){
if(arguments.length < 3){
return ;
}
o = $(e);
o.innerhtml = l;
p = $h(p).toquerystring();
new ajax.updater(
{success: e},
u,
{method: 'get', parameters: p, onfailure: f});
}
function loadajaxdata(u,p,s,f){
if(arguments.length < 3){
return ;
}
p = $h(p).toquerystring();
new ajax.request(
u,
{method: 'get', parameters: p, onsuccess:s,onfailure: f});
}
function sendajaxelement(e,u,p,f,l){
if(arguments.length < 3){
return ;
}
o = $(e);
o.innerhtml = l;
p = $h(p).toquerystring();
new ajax.updater(
{success: e},
u,
{method: 'post', parameters: p, onfailure: f});
}
function sendajaxdata(u,p,s,f){
if(arguments.length < 3){
return ;
}
p = $h(p).toquerystring();
new ajax.request(
u,
{method: 'post', parameters: p, onsuccess:s,onfailure: f});
}
</script>
<script language="javascript" >
//js/prototype.js
/*
这个文章你可以到jquery官网去下载哦。或到
http://www.111cn.net/js/prototype.js 下载
*/
</script>
<script language="javascript" >
//js/passwordstrength.js
//密码强度;
function passwordstrength(showed){
this.showed = (typeof(showed) == "boolean")?showed:true;
this.styles = new array();
this.styles[0] = {backgroundcolor:"#ebebeb",borderleft:"solid 1px #ffffff",borderright:"solid 1px #bebebe",borderbottom:"solid 1px #bebebe"};
this.styles[1] = {backgroundcolor:"#ff4545",borderleft:"solid 1px #ffffff",borderright:"solid 1px #bb2b2b",borderbottom:"solid 1px #bb2b2b"};
this.styles[2] = {backgroundcolor:"#ffd35e",borderleft:"solid 1px #ffffff",borderright:"solid 1px #e9ae10",borderbottom:"solid 1px #e9ae10"};
this.styles[3] = {backgroundcolor:"#95eb81",borderleft:"solid 1px #ffffff",borderright:"solid 1px #3bbc1b",borderbottom:"solid 1px #3bbc1b"};
this.labels= ["弱","中","强"];
this.divname = "pwd_div_"+math.ceil(math.random()*100000);
this.minlen = 6;
this.width = "150px";
this.height = "16px";
this.content = "";
this.selectedindex = 0;
this.init();
}
passwordstrength.prototype.init = function(){
var s = '<table cellpadding="0" id="'+this.divname+'_table" cellspacing="0" style="width:'+this.width+';height:'+this.height+';">';
s += '<tr>';
for(var i=0;i<3;i++){
s += '<td id="'+this.divname+'_td_'+i+'" width="33%" align="center"><span style="font-size:1px"> </span><span id="'+this.divname+'_label_'+i+'" style="display:none;font-family: courier new, courier, mono;font-size: 12px;color: #000000;">'+this.labels[i]+'</span></td>';
}
s += '</tr>';
s += '</table>';
this.content = s;
if(this.showed){
document.write(s);
this.copytostyle(this.selectedindex);
}
}
passwordstrength.prototype.copytoobject = function(o1,o2){
for(var i in o1){
o2[i] = o1[i];
}
}
passwordstrength.prototype.copytostyle = function(id){
this.selectedindex = id;
for(var i=0;i<3;i++){
if(i == id-1){
this.$(this.divname+"_label_"+i).style.display = "inline";
}else{
this.$(this.divname+"_label_"+i).style.display = "none";
}
}
for(var i=0;i<id;i++){
this.copytoobject(this.styles[id],this.$(this.divname+"_td_"+i).style);
}
for(;i<3;i++){
this.copytoobject(this.styles[0],this.$(this.divname+"_td_"+i).style);
}
}
passwordstrength.prototype.$ = function(s){
return document.getelementbyid(s);
}
passwordstrength.prototype.setsize = function(w,h){
this.width = w;
this.height = h;
}
passwordstrength.prototype.setminlength = function(n){
if(isnan(n)){
return ;
}
n = number(n);
if(n>1){
this.minlength = n;
}
}
passwordstrength.prototype.setstyles = function(){
if(arguments.length == 0){
return ;
}
for(var i=0;i<arguments.length && i < 4;i++){
this.styles[i] = arguments[i];
}
this.copytostyle(this.selectedindex);
}
passwordstrength.prototype.write = function(s){
if(this.showed){
return ;
}
var n = (s == 'string') ? this.$(s) : s;
if(typeof(n) != "object"){
return ;
}
n.innerhtml = this.content;
this.copytostyle(this.selectedindex);
}
passwordstrength.prototype.update = function(s){
if(s.length < this.minlen){
this.copytostyle(0);
return;
}
var ls = -1;
if (s.match(/[a-z]/ig)){
ls++;
}
if (s.match(/[0-9]/ig)){
ls++;
}
if (s.match(/(.[^a-z0-9])/ig)){
ls++;
}
if (s.length < 6 && ls > 0){
ls--;
}
switch(ls) {
case 0:
this.copytostyle(1);
break;
case 1:
this.copytostyle(2);
break;
case 2:
this.copytostyle(3);
break;
default:
this.copytostyle(0);
}
}
</script>
//reg.php
<?php
$a="wyjboy";
if($a == "$usr"){
echo 0;
}else{
echo 1;
}
?>
function getbrowse()
{
$agent = $_server['http_user_agent'];
$browser = '';
$browserver = '';
$browser = array('lynx', 'mosaic', 'aol', 'opera', 'java', 'macweb', 'webexplorer', 'omniweb');
for($i = 0; $i <= 7; $i ++){
if(strpos($agent, $browsers[$i])){
$browser = $browsers[$i];
$browserver = '';
}
}
if(ereg('mozilla', $agent) && !ereg('msie', $agent)){
$temp = explode('(', $agent);
$part = $temp[0];
$temp = explode('/', $part);
$browserver = $temp[1];
$temp = explode(' ', $browserver);
$browserver = $temp[0];
$browserver = preg_replace('/([d.]+)/', '\1', $browserver);
$browserver = $browserver;
$browser = 'netscape navigator';
}
if(ereg('mozilla', $agent) && ereg('opera', $agent)) {
$temp = explode('(', $agent);
$part = $temp[1];
$temp = explode(')', $part);
$browserver = $temp[1];
$temp = explode(' ', $browserver);
$browserver = $temp[2];
$browserver = preg_replace('/([d.]+)/', '\1', $browserver);
$browserver = $browserver;
$browser = 'opera';
}
if(ereg('mozilla', $agent) && ereg('msie', $agent)){
$temp = explode('(', $agent);
$part = $temp[1];
$temp = explode(';', $part);
$part = $temp[1];
$temp = explode(' ', $part);
$browserver = $temp[2];
$browserver = preg_replace('/([d.]+)/','\1',$browserver);
$browserver = $browserver;
$browser = 'internet explorer';
}
if($browser != ''){
$browseinfo = $browser.' '.$browserver;
} else {
$browseinfo = false;
}
return $browseinfo;
}
//应用方法
//在ie中
echo getbrowse(); //internet explorer 6.0
//在firefox中
echo getbrowse() ;//netscape navigator 5.0
/*
*/
代码如下 | 复制代码 |
if(!function_exists('get_headers')) $var=preg_replace("/ .*$/",'',$var); |
/***************************************************************
* 树型结构操作类(如果可以写成存储过程最理想)
*
* ***************************************************************/
class treenode {
var $f_id = 'id';
var $f_pid = 'pid';
var $f_lft = 'lft';
var $f_rgt = 'rgt';
var $f_s = 'sequence';
var $f_level = 'lev';
var $f_child_num = 'child_num';
var $table;
var $db;
/**
* 构造函数
* @param string $table 表名
* @param object $dbhanle adodb数据库教程操作句柄
*/
function treenode($table, $dbhandle) {
$this->db = $dbhandle;
$this->table = $table;
//$this->db->debug = true;
}
/**
* 增加子节点
* @param array $data 节点数据
* @return bool
*/
function addchild($data){
$pid = $data[$this->f_pid];
$sql = "select max({$this->f_s}) from {$this->table} where {$this->f_pid}=$pid";
$data[$this->f_s] = $this->db->getone($sql) + 1;//得到待插入节点的序号
$sql = "select * from {$this->table} where {$this->f_id} = -1";
$rs = $this->db->execute($sql);
$sql = $this->db->getinsertsql($rs, $data);
$this->db->execute($sql); //插入节点数据
if(!$this->db->affected_rows()){
return false;
}
$this->buildtree(1,1); //重建节点左右值
$this->updatelevel(1); //生成节点级数值
return true;
}
/**
* 修改节点的数据
* @param int $id 节点id号
* @param array $data 节点数据
* @return bool
*/
相关文章
- 这篇文章主要介绍了C#开发Windows窗体应用程序的简单操作步骤,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-04-12
- 本文通过例子,讲述了C++调用C#的DLL程序的方法,作出了以下总结,下面就让我们一起来学习吧。...2020-06-25
- 这篇文章主要介绍了微信小程序 页面传值详解的相关资料,需要的朋友可以参考下...2017-03-13
- 本文通过两个示例讲解了一下Process类调用外部应用程序的基本用法,并简单讲解了StartInfo属性,有需要的朋友可以参考一下。...2020-06-25
- 最近想自学PHP ,做了个验证码,但不知道怎么搞的,总出现一个如下图的小红叉,但验证码就是显示不出来,原因如下 未修改之前,出现如下错误; (1)修改步骤如下,原因如下,原因是apache权限没开, (2)点击打开php.int., 搜索extension=ph...2013-10-04
- 大概有如下步骤 新建项目Bejs 新建文件package.json 新建文件Gruntfile.js 命令行执行grunt任务 一、新建项目Bejs源码放在src下,该目录有两个js文件,selector.js和ajax.js。编译后代码放在dest,这个grunt会...2014-06-07
- 这篇文章主要介绍了微信小程序 二维码生成工具 weapp-qrcode详解,教大家如何在项目中引入weapp-qrcode.js文件,通过实例代码给大家介绍的非常详细,需要的朋友可以参考下...2021-10-23
jQuery Real Person验证码插件防止表单自动提交
本文介绍的jQuery插件有点特殊,防自动提交表单的验证工具,就是我们经常用到的验证码工具,先给大家看看效果。效果图如下: 使用说明 需要使用jQuery库文件和Real Person库文件 同时需要自定义验证码显示的CSS样式 使用实例...2015-11-08- 这篇文章主要介绍了uniapp微信小程序:key失效的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-01-20
- 这篇文章主要为大家详细介绍了JS实现随机生成验证码,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-09-06
将c#编写的程序打包成应用程序的实现步骤分享(安装,卸载) 图文
时常会写用c#一些程序,但如何将他们和photoshop一样的大型软件打成一个压缩包,以便于发布....2020-06-25- 本文介绍两种使用 php 生成二维码的方法。 (1)利用google生成二维码的开放接口,代码如下: /** * google api 二维码生成【QRcode可以存储最多4296个字母数字类型的任意文本,具体可以查看二维码数据格式】 * @param strin...2015-10-21
- 这篇文章主要介绍了Java生成随机姓名、性别和年龄的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-10-01
- 本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
- 这篇文章主要介绍了微信小程序 网络请求(GET请求)详解的相关资料,需要的朋友可以参考下...2016-11-22
- 这篇文章主要为大家详细介绍了微信小程序自定义tabbar组件,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-03-14
- 这篇文章主要介绍了C#生成随机数功能,涉及C#数学运算与字符串操作相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25
- 这篇文章主要给大家介绍了关于微信小程序如何获取图片宽度与高度的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-10
- 通过jquery.cookie.js插件可以快速实现“点击获取验证码后60秒内禁止重新获取(防刷新)”的功能效果图:先到官网(http://plugins.jquery.com/cookie/)下载cookie插件,放到相应文件夹,代码如下:复制代码 代码如下: <!DOCTYPE ht...2015-03-15
- 关于生成唯一数字ID的问题,是不是需要使用rand生成一个随机数,然后去数据库查询是否有这个数呢?感觉这样的话有点费时间,有没有其他方法呢?当然不是,其实有两种方法可以解决。 1. 如果你只用php而不用数据库的话,那时间戳+随...2015-11-24