lyxcf
中级会员
 
UID 78421
精华
0
积分 309
帖子 205
金钱 309 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2006-8-16 来自 北京 角门北路
状态 离线
|
[推荐阅读] 谁有Seagull的中文学习资料
<? require './inc/config.php'; require './inc/func.inc.php'; $action=SafeRequest($_GET['action']);
//$GLOBALS['discuz_auth_key']='6cb20f469a265be0701e517a1772eca3'; //$discuz_auth_key = md5('PuJ3BGeRubtGFsr'.$_SERVER['HTTP_USER_AGENT']); function authcode($string, $operation, $key = '') { $key = $key ? $key : md5('PuJ3BGeRubtGFsr'.$_SERVER['HTTP_USER_AGENT']); $coded = ''; //print_r($GLOBALS);exit; //echo $key;exit; $keylength = strlen($key); $string = $operation == 'DECODE' ? base64_decode($string) : $string; for($i = 0; $i < strlen($string); $i += $keylength) { $coded .= substr($string, $i, $keylength) ^ $key; } $coded = $operation == 'ENCODE' ? str_replace('=', '', base64_encode($coded)) : $coded; return $coded; }
function dsetcookie($var, $value, $life = 0, $prefix = 1) { global $tablepre, $cookiedomain, $cookiepath, $timestamp, $_SERVER; setcookie(($prefix ? $tablepre : '').$var, $value, $life ? $timestamp + $life : 0, $cookiepath, $cookiedomain, $_SERVER['SERVER_PORT'] == 443 ? 1 : 0); }
function random($length, $numeric = 0) { mt_srand((double)microtime() * 1000000); if($numeric) { $hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1)); } else { $hash = ''; $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; $max = strlen($chars) - 1; for($i = 0; $i < $length; $i++) { $hash .= $chars[mt_rand(0, $max)]; } } return $hash; }
if ($action=='check'){ $user=SafeRequest($_POST['user']); $pass=md5($_POST['pass']); $cookietime=SafeRequest($_POST['cookietime']);
$sql="select * from dz_members where username='$user' and password='$pass'"; if ($db->num_rows($db->query($sql))>0){ $rs=$db->fetch_assoc($db->query($sql)); $uid=0; $seccode = rand(1000,9999); $ips=explode('.',$_SERVER["REMOTE_ADDR"]); $sid=random(6); setcookie('dz_sid',$sid,time()+86400); setcookie('dz_cookietime',2592000,time()+86400); //setcookie('aa',"bbb"); $sql1="INSERT INTO dz_sessions (sid, ip1, ip2, ip3, ip4, uid, username, groupid, styleid, invisible, action, lastactivity, lastolupdate, seccode, fid, tid, bloguid)VALUES ('$sid', '$ips[0]', '$ips[1]', '$ips[2]', '$ips[3]', '".$rs["uid"]."', '$username', '".$rs["groupid"]."', '".$rs["styleid"]."', '0', '1', '".time()."', '".time()."', '$seccode', '0', '0', '0')"; $db->query($sql1); $_SESSION['user']=$rs['username']; $_SESSION['pass']=$rs['password']; ShowMsg('登陆成功'); } } print_r($_SESSION); ?> <link href="./css/index.css" rel="stylesheet" /> <form method="POST" action="?action=check"> <table width="200" border="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td height="30" bgcolor="#f9f9f9">用户:<? GetInputText('user');?></td> </tr> <tr> <td height="30" bgcolor="#f9f9f9">密码:<input type="password" name="pass" class="input"></td> </tr> <tr> <td height="30" bgcolor="#F6F6F6"><? GetInputSubmit();?> <input name="cookietime" type="hidden" id="cookietime" value="86400" /> </td> </tr> </table> </form>
|
|