唉……不知道为什么,注册功能出现了问题。
自己修改重新修改了一下博客注册函数的部分代码,把原先合并在一起的提交注册信息和处理注册信息的一个函数分开了,写成了两段,成功解决了注册的问题。
解决方法:
打开cp.php,把89~174行删除。
在89行添加上以下代码:
-
- if ($_GET["action"] == "register") {
- if ($options["closereg"]) {
- redirect("禁止注册新用户", $referer);
- }
- if (!submitcheck("submit", 1)) {
- if ($sax_uid && $sax_pw && $sax_group && $sax_hash) {
- redirect("您已经处于登陆状态", $referer);
- }
- cpheader();
- include template("register");
- cpfooter();
- }
- }
在78行添加上以下代码:
-
- if ($_POST["action"] == "doregister") {
-
- $username = trim($_POST["username"]);
- $password = $_POST["password"];
- $confirmpassword = $_POST["confirmpassword"];
- $email = trim($_POST["email"]);
- $url = trim($_POST["url"]);
- $referer = trim($_POST["referer"]);
-
- if (!isurl($url)) {
- redirect("网站URL错误");
- }
-
- if(!$username || strlen($username) > 20) {
- redirect("用户名为空或者超过20字节.", $reg_url);
- }
- if ($options["censoruser"]) {
- $options["censoruser"] = str_replace(",", ",", $options["censoruser"]);
- $banname = explode(",",$options["censoruser"]);
- foreach($banname as $value){
- if (strpos($username,$value) !== false){
- redirect("此用户名包含不可接受字符或被管理员屏蔽,请选择其它用户名.", $reg_url);
- }
- }
- }
- $name_key = array("","&"," ",""",""","/","*",",","<",">","
"," ","
","#","$","(",")","%","@","+","?",";","^");
- foreach($name_key as $value){
- if (strpos($username,$value) !== false){
- redirect("此用户名包含不可接受字符或被管理员屏蔽,请选择其它用户名.", $reg_url);
- }
- }
-
- if (!$password || strlen($password) < 8) {
- redirect("密码不能为空并且密码长度不能小于8位.",$reg_url);
- }
- if ($password != $confirmpassword) {
- redirect("请确认输入的密码一致.", $reg_url);
- }
- if (strpos($newpassword,"
") !== false || strpos($password,"
") !== false || strpos($password," ") !== false) {
- redirect("密码包含不可接受字符.", $reg_url);
- }
- $username = char_cv($username);
- $r = $DB->fetch_one_array("SELECT userid FROM {$db_prefix}users WHERE username="$username" LIMIT 1");
- if($r["userid"]) {
- redirect("该用户名已被注册.");
- }
- $email = char_cv($email);
- $r = $DB->fetch_one_array("SELECT userid FROM {$db_prefix}users WHERE email="$email" LIMIT 1");
- if($r["userid"]) {
- redirect("该E-mail已被注册.");
- }
- $password = md5($password);
- $DB->query("INSERT INTO {$db_prefix}users (username, password, logincount, loginip, logintime, email, url, regdateline, regip, groupid, lastip, lastvisit, lastactivity) VALUES ("$username", "$password", "1", "$onlineip", "$timestamp", "$email", "$url", "$timestamp", "$onlineip", "3", "$onlineip", "$timestamp", "$timestamp")");
- $sax_uid = $DB->insert_id();
- $DB->unbuffered_query("UPDATE {$db_prefix}statistics SET user_count=user_count+1");
-
- scookie("sax_auth", authcode("$sax_uid $password 1"), $login_life);
-
- updatesession();
-
- require_once(SABLOG_ROOT."include/func/cache.func.php");
- statistics_recache();
- redirect("注册成功.", $options["url"]);
- }
保存即可!——-HJin in Sablog Plus Team!