Skip to content

Commit

Permalink
reg还没弄完
Browse files Browse the repository at this point in the history
  • Loading branch information
hiaduan committed Aug 27, 2011
1 parent fdba1ae commit b78f64d
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 59 deletions.
26 changes: 26 additions & 0 deletions css/dev.common.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ blockquote:before, blockquote:after, q:before, q:after { content: ''; content: n
* */


/*
* Hack Start
* */

/* 伪类,兼容主流浏览器 */
.cleanfix: after {
clear: both;
height: 0;
content: ".";
display: block;
font-size: 0;
visibility: hidden;
}

/* 兼容IE6 */
* html .clearfix{zoom: 1;}

/* 兼容IE7 */
*:first-child + html .clearfix{zoom: 1;}


/*
* Hack Start
* */


a {
color: #3366CC;
cursor: pointer;
Expand Down
19 changes: 19 additions & 0 deletions css/dev.reg.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#warp {
min-height: 500px;
}

.reg-box {
margin-top: 20px;
overflow: hidden;
}

#reg-slide {
float: left;
width: 500px;
height: 440px;
display: inline;
}
#reg-action {
display: block;
width: 460px;
}
40 changes: 29 additions & 11 deletions dev/conf/nginx_duanyong
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,42 @@ server {
#gzip-disable "MSID [1-6]\.";


#禁止访问dev目录或以dev开关的任何文件
location ~ ^/dev {
deny all;
}

#img、css与js文件永久缓存
location /img/ {
#rewrite /img/(*)([.v0-9]).(*)$ /img/$1.$2 break;
#rewrite /img/(*)([.v0-9]).(*)$ /img/$1.$2 break;

return 403;
return 403;
}

location /js/ {
#rewrite /js/(*)([.v0-9]).(*)$ /js/$1.$2 break;
#rewrite /js/(*)([.v0-9]).(*)$ /js/$1.$2 break;

return 403;
return 403;
}

location /css/ {
#rewrite /css/(*)([.v0-9]).(*)$ /css/$1.$2 break;
#rewrite /css/(*)([.v0-9]).(*)$ /css/$1.$2 break;
expires max;
access_log off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";

return 403;
return 403;
}


# This block will catch static file requests, such as images, css, js
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
# Some basic cache-control for static files to be sent to the browser
expires max;
access_log off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
# Some basic cache-control for static files to be sent to the browser
expires max;
access_log off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}


Expand All @@ -60,5 +69,14 @@ server {
fastcgi_pass unix:/tmp/php.socket;
fastcgi_index index.php;
}


#对于访问地址/home
# 1、先判断是否有home.shtml或home.html,跳转
# 2、先判断是否有home.php,跳转
# 3、先判断是目录home,跳转
#
# N、返回404
try_files $uri.html $uri.shtml $uri.php $uri/ $uri;
}

4 changes: 2 additions & 2 deletions db/devdb.user.php → dev/db/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
////////////////////////////////////////////////////////////////////////////////

function a_user_by_username($username) {
if (a_bad_string($username)) {
return a_log();
if (a_bad_username($username)) {
return a_log();
}

return a_db_query("select * from `user` where `username`='{$username}' limit 1;");
Expand Down
69 changes: 53 additions & 16 deletions devinc.bad.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
// devinc.bad.php
// 判断错误的函数,参数错误返回true,正确返回false
//
// a_bad_username($username, &$var)
// 判断用户名是否正确
//
// a_bad_password($password, &$var)
// 判断用户名是否正确
//
//
// a_bad_id($id)
// 判断数字是否正确(大于0)
Expand Down Expand Up @@ -34,17 +40,49 @@
//
////////////////////////////////////////////////////////////////////////////////

function a_bad_username($username, &$var=false) {
//是为手机号码或者邮件地址正确
//用户名检查,包括格式及长度
function a_bad_username(&$username, &$var=false) {
//长度检查
$len = strlen($username);

if ($len <= 0
|| $len > 25
) {
return true;
}


//格式检查
if (!a_bad_email($username, $var)
|| !a_bad_mobile($username, $var)
) {
//手机号码或邮件地址
return false;
}

return true;
}


//密码检查,只检查长度6到25位
function a_bad_password(&$password, &$var=false) {
$len = mb_strlen($password);

if ($len < 6
|| $len > 25
) {
return true;
}

if ($var !== false) {
$var = $username;
$var = $password;
}

return false;
}


function a_bad_id($id, &$var=false) {
function a_bad_id(&$id, &$var=false) {
if(!is_numeric($id)
|| ( $id = intval($id) ) <= 0
) {
Expand All @@ -59,7 +97,7 @@ function a_bad_id($id, &$var=false) {
}


function a_bad_0id($id, &$var=false) {
function a_bad_0id(&$id, &$var=false) {
if(!is_numeric($id)
|| ( $id = intval($id) ) < 0
) {
Expand All @@ -74,7 +112,7 @@ function a_bad_0id($id, &$var=false) {
}


function a_bad_string($str, &$var=false) {
function a_bad_string(&$str, &$var=false) {
if (!is_string($str)
|| $str !== strval($str)
|| empty($str)
Expand All @@ -91,7 +129,7 @@ function a_bad_string($str, &$var=false) {
}


function a_bad_0string($str, &$var=false) {
function a_bad_0string(&$str, &$var=false) {
if (!is_string($str)
|| $str !== strval($str)
) {
Expand Down Expand Up @@ -142,13 +180,13 @@ function a_bad_table_id($table, $id, &$var=false) {
}


function a_bad_file($file) {
function a_bad_file(&$file) {
return !( file_exists($file) && is_readable($file) );
}


function a_bad_email($email, &$var=false) {
if (false === filter_var($email, FILTER_VALIDATE_EMAIL)) {
function a_bad_email(&$email, &$var=false) {
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
return true;
}

Expand All @@ -160,17 +198,16 @@ function a_bad_email($email, &$var=false) {
}


function a_bad_mobile($mobile, &$var=false) {
if (a_bad_id($mobile)
|| strlen($mobile) !== 11
) {
function a_bad_mobile(&$mobile, &$var=false) {

if (strlen($mobile) !== 11) {
return true;
}

static $regx;

if (!$regx) {
$regx = "/^[13|15]\d{9}$/";
$regx = "/^[13|15]\d+$/";
}

if (!preg_match($regx, $mobile)) {
Expand Down Expand Up @@ -212,7 +249,7 @@ function a_bad_user($uid, &$user=false) {
}

//可能没有数据
if (a_bad_table_id("user", $uid, $user) ) {
if (a_bad_table_id('user', $uid, $user) ) {

return false;
}
Expand Down
4 changes: 2 additions & 2 deletions devwatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function a_watch_general_js($js) {
}

//得到所有的dev.base.js dev.base.xxxx.js
$all = glob(JS_DIR . 'dev.' . str_replace($js, '.js', '') . '*.js');
$all = glob(JS_DIR . 'dev.' . str_replace('.js', '', $js) . '*.js');

foreach ($all as $file) {
if (!is_readable($file)
Expand Down Expand Up @@ -280,7 +280,7 @@ function a_watch_general_css($css) {


//得到所有的dev.base.css dev.base.xxxx.css
$all = glob(CSS_DIR . 'dev.' . str_replace($css, '.css', '') . '*.css');
$all = glob(CSS_DIR . 'dev.' . str_replace('.css', '', $css) . '*.css');

foreach ($all as $file) {
if (!is_readable($file)
Expand Down
2 changes: 1 addition & 1 deletion error.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<meta content="您手上的心情布袋" name="description"/>

{css name="base"}
{css name="common"}
</head>
<body>
{* 导入header *}
Expand Down
3 changes: 1 addition & 2 deletions home/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<meta content="您手上的心情布袋" name="description"/>

{css name="base, index"}
{js name="layout, index"}
{css name="common"}
</head>
<body>
{* 导入header *}
Expand Down
4 changes: 4 additions & 0 deletions js/dev.base.inupt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

function input_tip(input, text, css) {

}
31 changes: 15 additions & 16 deletions reg.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
*
* */

require_once __DIR__ . "/devinc.all.php";
require_once ROOT_DIR . "/db/devdb.user.php";
require_once ROOT_DIR . "/user/devapi.user.php";
require_once __DIR__ . '/devinc.all.php';
require_once ROOT_DIR . '/user/devapi.user.php';
require_once ROOT_DIR . '/dev/db/user.php';



$arg = array();
$user = array();


if (a_bad_username($_POST["username"], $user["username"])) {
if (a_bad_username($_POST["username"], $user['username'])) {
//没有填写账户
exit(a_action_msg("请填写您的手机或者邮箱做为登录账号"));
exit(a_action_msg('请填写您的手机或者邮箱做为登录账号'));
}

if (a_bad_string($_POST["password"], $user["password"])) {
if (a_bad_password($_POST["password"], $user['password'])) {
//没有填写密码
exit(a_action_msg("请填写你的登录密码"));
exit(a_action_msg('请填写你的登录密码'));
}


Expand All @@ -33,26 +33,25 @@


//检查数据库中的值是否存在
if (a_user_by_username($user["username"])) {
exit(a_action_msg("对不起,此账号已被注册,请重新输入新的账号"));
if (a_user_by_username($user['username'])) {
exit(a_action_msg('对不起,此账号已被注册,请重新输入新的账号'));
}


$user["regip"] = a_action_ip();
$user["ctime"] = a_action_time();
$user["password"] = md5($user["password"]);
$user['regip'] = a_action_ip();
$user['ctime'] = a_action_time();
$user['password'] = md5($user['password']);


// 插入数据
if (false === a_db("user:insert", $user)) {
if (false === a_db('user:insert', $user)) {
//注册失败
exit(a_server_error());
}



//一切正常,可以注册
$arg["err"] = 0;
$arg['err'] = 0;


exit(a_action_redirect("/index.shtml", "注册成功,稍后回到首页", 1));
exit(a_action_redirect('/home', '注册成功,稍后回到首页'));
Loading

0 comments on commit b78f64d

Please sign in to comment.