PHP简单MVC架构
由于需要搭建一个简单的框架来进行API接口开发,所以简单的mvc框架当然是首选.最原始,最简洁的mvc框架.下面来介绍下.
一. 项目目录结构:app
|-controller 存放控制器文件
|-model 存放模型文件
|-view 存放视图文件
core
|-lib 存放自定义类库
|-config 存放配置文件
|--config.php 系统配置文件
|--conn.php 数据库连接文件
|--db_config.php 数据库配置文件
|-mysql_db.php 数据库类文件
|-runtime 缓存文件
db_caches 数据库缓存文件
logs日志文件
|-index.php 入口文件
| -dispatcher.php
| -loader.php
| -router.php
二.项目架构1.先介绍index.php,附源码:<?php //header("content-type:text/html;charset=utf-8"); /** 过滤sql语句的关键字*/ function strip_sql($string){ global $search_arr,$replace_arr; return is_array($string) ? array_map('strip_sql', $string) : preg_replace($search_arr, $replace_arr, $string); } function new_htmlspecialchars($string){return is_array($string) ? array_map('new_htmlspecialchars', $string) : htmlspecialchars($string,ENT_QUOTES); } function new_addslashes($string){if(!is_array($string)) return addslashes($string);foreach($string as $key => $val) $string[$key] = new_addslashes($val);return $string; } function new_stripslashes($string) {if(!is_array($string)) return stripslashes($string);foreach($string as $key => $val) $string[$key] = new_stripslashes($val);return $string; } function strip_textarea($string){return nl2br(str_replace(' ', ' ', htmlspecialchars($string, ENT_QUOTES))); } function strip_js($string, $js = 1){$string = str_replace(array("\n","\r","\""),array('','',"\\\""),$string);return $js==1 ? "document.write(\"".$string."\");\n" : $string; } //邮件格式验证的函数 function check_email($email) { if(!preg_match("/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/",$email)) { return false; } else return true; } //验证手机号码 function check_mobile($mobile) { $pattern = "/^1\d{10}$/"; if (preg_match($pattern,$mobile)) { Return true; } else { Return false; } } //获取GMTime function get_gmtime() { return (time() - date('Z')); } function to_date($utc_time, $format = 'Y-m-d H:i:s') { if (empty ( $utc_time )) { return ''; } $timezone = 8; $time = $utc_time + $timezone * 3600; return date ($format, $time ); } function to_timespan($str, $format = 'Y-m-d H:i:s') { $timezone = 8; $time = intval(strtotime($str)); if($time!=0) $time = $time - $timezone * 3600; return $time; } function get_http() { return (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; } function get_domain() { /* 协议 */ $protocol = get_http(); /* 域名或IP地址 */ if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { $host = $_SERVER['HTTP_X_FORWARDED_HOST']; } elseif (isset($_SERVER['HTTP_HOST'])) { $host = $_SERVER['HTTP_HOST']; } else { /* 端口 */ if (isset($_SERVER['SERVER_PORT'])) { $port = ':' . $_SERVER['SERVER_PORT']; if ((':80' == $port && 'http://' == $protocol) || (':443' == $port && 'https://' == $protocol)) { $port = ''; } } else { $port = ''; } if (isset($_SERVER['SERVER_NAME'])) { $host = $_SERVER['SERVER_NAME'] . $port; } elseif (isset($_SERVER['SERVER_ADDR'])) { $host = $_SERVER['SERVER_ADDR'] . $port; } } return $protocol . $host; } function get_host() { /* 域名或IP地址 */ if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { $host = $_SERVER['HTTP_X_FORWARDED_HOST']; } elseif (isset($_SERVER['HTTP_HOST'])) { $host = $_SERVER['HTTP_HOST']; } else { if (isset($_SERVER['SERVER_NAME'])) { $host = $_SERVER['SERVER_NAME']; } elseif (isset($_SERVER['SERVER_ADDR'])) { $host = $_SERVER['SERVER_ADDR']; } } return $host; } /* * 实现AES加密* $str : 要加密的字符串* $keys : 加密密钥* $iv : 加密向量* $cipher_alg : 加密方式*/function aes_ecryptdString($str,$keys="1034567890666450",$iv="1034567890123450",$cipher_alg=MCRYPT_RIJNDAEL_128){// $encrypted_string= base64_encode(bin2hex(mcrypt_encrypt($cipher_alg,$keys, $str, MCRYPT_MODE_CBC,$iv)));$encrypted_string= bin2hex(mcrypt_encrypt($cipher_alg,$keys, $str, MCRYPT_MODE_CBC,$iv));return $encrypted_string;}/* * 实现AES解密* $str : 要解密的字符串* $keys : 加密密钥* $iv : 加密向量* $cipher_alg : 加密方式*/function aes_decryptString($str,$keys="1034567890666450",$iv="1034567890123450",$cipher_alg=MCRYPT_RIJNDAEL_128){// $str= base64_decode($str);$decrypted_string= mcrypt_decrypt($cipher_alg,$keys,pack("H*",$str),MCRYPT_MODE_CBC,$iv);return $decrypted_string;} /** * 对数组进行转码操作 * @param $array * @param $in_charset * @param $out_charset */function iconv_array(&$array,$in_charset,$out_charset){if(UC_CHARSET!='utf-8'){foreach($array as $k=>$v){if(is_array($array[$k])){iconv_array($array[$k],$in_charset,$out_charset);}else{$array[$k] = iconv($in_charset,$out_charset,$array[$k]);}}}}/** * utf8字符转Unicode字符 * @param string $char 要转换的单字符 * @return void */function utf8_to_unicode($char){switch(strlen($char)){case 1:return ord($char);case 2:$n = (ord($char[0]) & 0x3f) << 6;$n += ord($char[1]) & 0x3f;return $n;case 3:$n = (ord($char[0]) & 0x1f) << 12;$n += (ord($char[1]) & 0x3f) << 6;$n += ord($char[2]) & 0x3f;return $n;case 4:$n = (ord($char[0]) & 0x0f) << 18;$n += (ord($char[1]) & 0x3f) << 12;$n += (ord($char[2]) & 0x3f) << 6;$n += ord($char[3]) & 0x3f;return $n;}}/** * utf8字符串分隔为unicode字符串 * @param string $str 要转换的字符串 * @param string $depart 分隔,默认为空格为单字 * @return string */function str_to_unicode_word($str,$depart=' '){$arr = array();$str_len = mb_strlen($str,'utf-8');for($i = 0;$i < $str_len;$i++){$s = mb_substr($str,$i,1,'utf-8');if($s != ' ' && $s != ' '){$arr[] = 'ux'.utf8_to_unicode($s);}}return implode($depart,$arr);}/** * utf8字符串分隔为unicode字符串 * @param string $str 要转换的字符串 * @return string */function str_to_unicode_string($str){$string = str_to_unicode_word($str,'');return $string;}//分词function div_str($str){require_once APP_ROOT_PATH."core/lib/words.php";$words = words::segment($str);$words[] = $str;return $words;}/** * @desc im:十进制数转换成三十六机制数 * @param (int)$num 十进制数 * return 返回:三十六进制数 */function get_code_bynum($num) {$num = intval($num);if ($num <= 0)return false;$codeArr = array("0","1","2","3","4","5","6","7","8","9",'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');$code = '';do {$key = ($num - 1) % 36;$code = $codeArr[$key] . $code;$num = floor(($num - $key) / 36);} while ($num > 0);return $code;}/** * @desc im:三十六进制数转换成十机制数 * @param (string)$str 三十六进制数 * return 返回:十进制数 */function get_num_bycode($str){$array=array("0","1","2","3","4","5","6","7","8","9","A", "B", "C", "D","E", "F", "G", "H", "I", "J", "K", "L","M", "N", "O","P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y","Z");$len=strlen($str);for($i=0;$i<$len;$i++){$index=array_search($str[$i],$array);$sum+=($index+1)*pow(36,$len-$i-1);}return $sum;}?>5.加载公共方法的文件./core/common.php 源码:
<?php/** * @file: user.php 用户控制层 * @version: 1.0 * @author: Sara * @create: 2012-12-17 10:15:00 * @update: 2012-12-17 10:15:00 * @access: http://blog.csdn.net/haiqiao_2010 * @copyright: 2012 http://blog.csdn.net/haiqiao_2010 All rights reserved. **/header('Content-Type: text/html; charset=utf-8');@require_once './core/config/conn.php';class user{/* * method __construct* paramemter string $a* return 提示信息/调用方法*/function __construct(){$action=@trim(@$_REQUEST['act']);if(empty($action)){$action="index";}else{if(!in_array($action,array('index','login','register','userUpdatePwd'))){ajax_return(array('recode'=>"0003",'msg'=>"非法操作",'data'=>$action));}}}/* * method index 非法调用* param* return*/public function index(){ajax_return(array('recode'=>"0003",'msg'=>"非法操作",'data'=>@$_REQUEST['act']));}/* * method login 用户登陆(支持邮箱+密码或者账号+密码)* param string $user_name,string $user_pwd,string $l_ip,string $city_name,float $l_xpoint,float $l_ypoint* return 返回成功/失败已经登陆信息*/public function login(){$data=json_decode(@$_REQUEST['req']);$user_name_or_email = trim(new_htmlspecialchars(new_addslashes(@$data->user_name)));$user_pwd = trim(new_htmlspecialchars(new_addslashes(@$data->user_pwd)));$log['l_ip'] = trim(new_htmlspecialchars(new_addslashes(@$data->l_ip)));$log['city_name'] = trim(new_htmlspecialchars(new_addslashes(@$data->city_name)));$log['l_xpoint'] = trim(new_htmlspecialchars(new_addslashes(@$data->l_xpoint)));$log['l_ypoint'] = trim(new_htmlspecialchars(new_addslashes(@$data->l_ypoint)));$log['l_type'] = intval(@$data->l_type);//用户登陆类型:默认为0,网站登陆,1为手机端IOS登陆,2为手机端android$log['l_version'] = trim(new_htmlspecialchars(new_addslashes(@$data->l_version)));if(empty($user_name_or_email)|| empty($user_pwd)){$r=array('recode'=>"0002",'msg'=>"参数错误",'data'=>'');}else{$user_data = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where (user_name='".$user_name_or_email."' or email = '".$user_name_or_email."') and is_delete = 0");if(!$user_data){$r=array('recode'=>"1014",'msg'=>"该用户不存在,请确认操作.",'data'=>'');}else{if($user_data['user_pwd'] != md5($user_pwd.$user_data['code'])&&$user_data['user_pwd']!=$user_pwd){$r=array('recode'=>"0012",'msg'=>"用户密码不对,请确认您的登陆信息.",'data'=>'');}elseif($user_data['is_effect'] != 1){$r=array('recode'=>"0011",'msg'=>"账号未被激活,暂时不能进行如下操作.",'data'=>'');}elseif($user_data['is_locking'] != 0){$r=array('recode'=>"0014",'msg'=>"账号已经被锁定,暂时不能进行如下操作.",'data'=>'');if(app_conf("SHOP_TEL")!='')$r['msg'].="若有疑问,请致电联系客服: <".app_conf("SHOP_TEL").">";}else{//im:查看会员分组是否能够升级$user_current_group = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user_group where id = ".intval($user_data['group_id']));$user_group = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user_group where score <=".intval($user_data['score'])." order by score desc");if($user_current_group['score']<$user_group['score']){$user_data['group_id'] = intval($user_group['id']);$GLOBALS['db']->query("update ".DB_PREFIX."user set group_id = ".$user_data['group_id']." where id = ".$user_data['id']);$pm_title = "您已经成为".$user_group['name']."";$pm_content = "恭喜您,您已经成为".$user_group['name']."。";if($user_group['discount']<1){$pm_content.="您将享有".($user_group['discount']*10)."折的购物优惠";}send_user_msg($pm_title,$pm_content,0,$user_data['id'],get_gmtime(),0,true,true);}//im:查看会员积分是否能够升级$user_current_level = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user_level where id = ".intval($user_data['level_id']));$user_level = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user_level where point <=".intval($user_data['point'])." order by point desc");if($user_current_level['point']<$user_level['point']){$user_data['level_id'] = intval($user_level['id']);$GLOBALS['db']->query("update ".DB_PREFIX."user set level_id = ".$user_data['level_id']." where id = ".$user_data['id']);$pm_title = "您已经成为".$user_level['name']."";$pm_content = "恭喜您,您已经成为".$user_level['name']."。";send_user_msg($pm_title,$pm_content,0,$user_data['id'],get_gmtime(),0,true,true);}if($user_current_level['point']>$user_level['point']){$user_data['level_id'] = intval($user_level['id']);$GLOBALS['db']->query("update ".DB_PREFIX."user set level_id = ".$user_data['level_id']." where id = ".$user_data['id']);$pm_title = "您已经降为".$user_level['name']."";$pm_content = "很报歉,您已经降为".$user_level['name']."。";send_user_msg($pm_title,$pm_content,0,$user_data['id'],get_gmtime(),0,true,true);}$log['l_time']=get_gmtime();$log['user_id']=$user_data['id'];//im:更新最后登陆信息$GLOBALS['db']->query("update ".DB_PREFIX."user set login_ip = '".$log['l_ip']."',login_time= ".$log['l_time'].",group_id=".intval($user_data['group_id'])." where id =".$user_data['id']);//添加登陆日志$GLOBALS['db']->autoExecute("im_user_login_log",$log);//检查是否为最新系统版本$log['l_type'] = intval(@$data->l_type);//用户登陆类型:默认为0,网站登陆,1为手机端IOS登陆,2为手机端androidswitch ($log['l_type'])//im_m_package:p_type:手机系统版本类型,默认为0 ios系统;为1 android系统{case "1":$package=$GLOBALS['db']->getRow("select p_version,p_url,is_must from im_m_package where is_effect=1 and p_type=0");break;case "2":$package=$GLOBALS['db']->getRow("select p_version,p_url,is_must from im_m_package where is_effect=1 and p_type=1");break;default:break;}if (@$package && strnatcmp($log['l_version'],$package['p_version'])<0){// $varreg="/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/";$varreg="/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i";if(!preg_match($varreg,$package['p_url']))//im:判断是否为超链接{$package['p_url']=URL_PATH.str_replace("./","",$package['p_url']);}$r=array('recode'=>"0015",'msg'=>"用户登陆成功.",'data'=>array('user_id'=>$user_data['id'],'user_name'=>$user_data['user_name'],'true_name'=>$user_data['true_name'],'email'=>is_null($user_data['email'])?"":$user_data['email'],'mobile'=>is_null($user_data['mobile'])?"":$user_data['mobile'],'l_time'=>to_date($log['l_time']),'p_version'=>$package['p_version'],'p_url'=>$package['p_url'],'is_must'=>$package['is_must']));}else{$r=array('recode'=>"0015",'msg'=>"用户登陆成功.",'data'=>array('user_id'=>$user_data['id'],'user_name'=>$user_data['user_name'],'true_name'=>$user_data['true_name'],'email'=>is_null($user_data['email'])?"":$user_data['email'],'mobile'=>is_null($user_data['mobile'])?"":$user_data['mobile'],'l_time'=>to_date($log['l_time']),'p_version'=>$log['l_version'],'p_url'=>"",'is_must'=>""));}}}}ajax_return($r);}/* * method register 用户注册* param int $type,string $user_name,string $user_pwd,string $email ,string mobile* return 返回成功/失败*/public function register(){//{"type":0,"user_name":"sara123","user_pwd":"123456","email":"sara123@qq.com","mobile":"13245678900","xpoint":"119.306938","ypoint":"26.069746","city_name":"\u5b81\u590f","ip":"192.168.1","l_type":"1","l_version":"1.0","verify_code":"123456","msg_id":"12"}// $data=json_encode(array(// "type"=>0,// "user_name"=>"sara123",// "user_pwd"=>"123456",// "email"=>"sara123@qq.com",// "mobile"=>"13245678900",// "xpoint"=>"119.306938",// "ypoint"=>"26.069746",// "city_name"=>"宁夏",// "ip"=>"192.168.1",// "l_type"=>"1",// "l_version"=>"1.0",// "verify_code"=>"123456",// "msg_id"=>12// ));$data=json_decode(@$_REQUEST['req']);$type = intval(@$data->type);//im:注册方式:默认为0:邮箱+账号;1为:手机号+账号$user_data['user_name'] = strtolower(trim(new_htmlspecialchars(new_addslashes(@$data->user_name))));$user_data["user_pwd"] = trim(new_htmlspecialchars(new_addslashes(@$data->user_pwd)));$user_data["email"] = trim(new_htmlspecialchars(new_addslashes(@$data->email)));$user_data["mobile"] = trim(new_htmlspecialchars(new_addslashes(@$data->mobile)));$user_data["xpoint"] = doubleval(@$data->xpoint);$user_data["ypoint"] = doubleval(@$data->ypoint);$city_name = trim(new_htmlspecialchars(new_addslashes(@$data->city_name)));$user_data["login_ip"] = trim(new_htmlspecialchars(new_addslashes(@$data->ip)));$l_type = intval(@$data->l_type);//用户登陆类型:默认为0,网站登陆,1为手机端IOS登陆,2为手机端android$l_version = trim(new_htmlspecialchars(new_addslashes(@$data->l_version)));if($user_data['user_name']==''|| !preg_match("/^[a-z\d]{3,20}$/i", $user_data['user_name'])){ajax_return(array('recode'=>"1001",'msg'=>"用户名不能为空,且为3-20个由字母和数字组成的字符串.".$data->user_name,'data'=>""));}else{if($GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."user where user_name = '".trim($user_data['user_name'])."'")>0){ajax_return(array('recode'=>"1006",'msg'=>"该用户名已经存在,请重新填写",'data'=>''));}else {$msg=get_pwd_strength($user_data['user_pwd']);if(!empty($msg)){ajax_return(array('recode'=>"1003",'msg'=>$msg,'data'=>''));}else{if($type==0){if(!check_email($user_data['email'])){ajax_return(array('recode'=>"1003",'msg'=>"邮箱格式不正确.",'data'=>''));}else{if($GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."user where email = '".trim($user_data['email'])."'")>0){ajax_return(array('recode'=>"1004",'msg'=>"该邮箱已经被注册过,请填写其他邮箱.",'data'=>''));}}}else{if(!check_mobile($user_data['mobile'])){ajax_return(array('recode'=>"1005",'msg'=>"手机号码格式错误,手机号码为11位.",'data'=>''));}else{$verify_code = trim(new_htmlspecialchars(new_addslashes(@$data->verify_code)));$msg_id = intval(@$data->msg_id);if ($msg_id<=0 || empty($verify_code)){ajax_return(array('recode'=>"0002",'msg'=>"参数错误",'data'=>''));}$verify_result=use_sms_code(0,0,$msg_id,0,$user_data["mobile"],$verify_code);if($verify_result['status']==0){ajax_return(array('recode'=>$verify_result['recode'],'msg'=>$verify_result['msg'],'data'=>''));}}}//验证结束开始插入数据$user_data['create_time'] = get_gmtime();$user_data['update_time'] = get_gmtime();//获取默认会员组, 即升级积分最小的会员组$user_data['group_id'] = $GLOBALS['db']->getOne("select id from ".DB_PREFIX."user_group order by score asc limit 1");//获取用户所在城市id$city = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."region_conf where name='".$city_name."'");if ($city){switch ($city['region_level']) {//im:1:国 2:省 3:市(县) 4:区(镇)case "2":$user_data['province_id']=$city['id'];break;case "3":$user_data['city_id']=$city['id'];$user_data['province_id'] = $city['pid'];break;default:break;}}//账号是否激活// $user_data['is_effect'] = empty($user_data['is_effect'])? app_conf("USER_VERIFY"):$user_data['is_effect'];$user_data['is_effect']=1;//手机端注册,默认账号为激活状态$user_data['code'] = ''; //默认不使用code, 该值用于其他系统导入时的初次认证$user_data['user_pwd'] = md5($user_data['user_pwd'].$user_data['code']);$user_data['register_type'] = 1;//register_type:im:用户注册的方式:默认为0,web端注册,1为手机端注册if($GLOBALS['db']->autoExecute(DB_PREFIX."user",$user_data,"INSERT")){$user_id = $GLOBALS['db']->insert_id();$register_money = app_conf('USER_REGISTER_MONEY');$register_score = app_conf('USER_REGISTER_SCORE');$register_point = app_conf('USER_REGISTER_POINT');if($register_money>0||$register_score>0){$user_get['score'] = $register_score;$user_get['money'] = $register_money;$user_get['point'] = $register_point;@require_once './app/modules/userModule.php';modify_account($user_get,intval($user_id),"在".to_date(get_gmtime())."注册成功");}//im:添加登陆日志$GLOBALS['db']->autoExecute("im_user_login_log",array('user_id'=>$user_id,'l_type'=>1,'l_ip'=>$user_data['login_ip'],'l_time'=>get_gmtime(),"city_name"=>$city_name,"l_xpoint"=>$user_data['xpoint'],"l_ypoint"=>$user_data['ypoint'],"l_type"=>$l_type,"l_version"=>$l_version));ajax_return(array('recode'=>"1009",'msg'=>"用户注册成功",'data'=>array('user_id'=>$user_id,"user_name"=>$user_data['user_name'],"email"=>is_null($user_data['email'])?"":$user_data['email'],"mobile"=>is_null($user_data['mobile'])?"":$user_data['mobile'],"create_time"=>to_date($user_data['create_time']))));}else{ajax_return(array('recode'=>"1008",'msg'=>"用户注册失败",'data'=>''));}}}}}/* * method userUpdatePwd 修改密码接口* parameter int $user_id* parameter string $old_pwd* parameter string $new_pwd* return 返回成功/失败*/function userUpdatePwd(){//{"user_id":0,"old_pwd":"111@qq.com","new_pwd":"13245678900"}// $data=json_encode(array(// "user_id"=>0,// "old_pwd"=>"sara123@qq.com",// "new_pwd"=>"13245678900"// ));$data=json_decode(@$_REQUEST['req']);$user_id = intval(@$data->user_id);$user_pwd = trim(new_htmlspecialchars(new_addslashes(@$data->old_pwd)));$new_pwd = trim(new_htmlspecialchars(new_addslashes(@$data->new_pwd)));if ($user_id<=0){$r=array('recode'=>"0002",'msg'=>"参数错误.",'data'=>'');}else{$msg=get_pwd_strength($new_pwd);if(!empty($msg)){$r=array('recode'=>"1002",'msg'=>$msg,'data'=>'');ajax_return($r);}else{$user_data = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id='".$user_id."'");if(!$user_data){$r=array('recode'=>"1014",'msg'=>"该用户不存在,请确认操作.",'data'=>'');}else{if($user_data['user_pwd'] != md5($user_pwd.$user_data['code'])&&$user_data['user_pwd']!=$user_pwd){$r=array('recode'=>"0012",'msg'=>"用户密码不对,请确认您的登陆信息.",'data'=>'');}elseif($user_data['is_effect'] != 1){$r=array('recode'=>"0011",'msg'=>"账号未被激活,暂时不能进行如下操作.",'data'=>'');}else if ($user_data['is_delete']==1){$r=array('recode'=>"1012",'msg'=>"该用户已被删除,请重新注册.",'data'=>'');}else{$user_data['user_pwd'] = $new_pwd;$new_pwd = md5($new_pwd.$user_data['code']);if($GLOBALS['db']->query("update ".DB_PREFIX."user set user_pwd = '".$new_pwd."',password_verify='' where id = ".$user_data['id'] )){$GLOBALS['db']->query("update ".DB_PREFIX."supplier_account set account_password = '".$new_pwd."' where user_id = ".$user_data['id'] );$r=array('recode'=>"0000",'msg'=>"操作成功.",'data'=>'');}else{$r=array('recode'=>"0001",'msg'=>"操作失败.",'data'=>'');}}}}}ajax_return($r);}}?>