$option_setting = "INSERT INTO `options` (`option_name`,`option_value`,`option_autoload`)\nVALUES\n('site_title', '{title}', '1'),\n('site_desc', '{desc}', '1'),\n('site_url', '{url}', '1'),\n('admin_email', '{email}', '1'),\n('allowed_register', 'yes', '1'),\n('allowed_comment', 'yes', '1'),\n('default_avatar', 'default', '1'),\n('email_notice', 'yes', '1'),\n('site_style', 'default', '1'),\n('login_captcha', 'no', '1'),\n('picture_server', 'local', '1'),\n('image_thumbnail_width', '400', '1'),\n('image_thumbnail_height', '300', '1'),\n('image_hd_width', '1600', '1'),\n('image_display_width', '900', '1'),\n('comment_one_page', '5', '1'),\n('comment_order_desc', 'yes', '1'),\n('comment_deep', '8', '1'),\n('router_list', 'a:0:{}', '1'),\n('site_static_url', '{static_url}', '1'),\n('cdn', '', '1');"; $req = req()->_escape(); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); $post = $req->post('s'); foreach (['title', 'desc', 'url', 'email', 'static_url'] as $v) { if (!isset($post[$v]) || empty($post[$v])) { die("系统设置有空字段:" . $v); } } $user = $req->post('u'); lib()->load('UserCheck'); if (!\ULib\UserCheck::CheckUsernameChar($user['name'])) { die("用户名称检测错误"); } $user['pwd'] = \ULib\UserCheck::MakeHashChar($user['pwd']); $user['email'] = $post['email']; if (!\ULib\UserCheck::CheckEmailChar($user['email'])) { die("管理员邮箱格式不正确"); } $option_setting = str_replace(['{title}', '{desc}', '{url}', '{email}', '{static_url}'], [$post['title'], $post['desc'], $post['url'], $post['email'], $post['static_url']], $option_setting); $pdo = $sql->getWriter(); $pdo->exec("delete from `options` where `id` > 0"); $pdo->exec("alter table `options` auto_increment=1;"); $pdo->exec($option_setting); lib()->load('UserRegister', 'UserCheck', 'User'); hook()->add('UserRegister_Captcha', function () { //通过钩子去掉用户注册验证码 return true; }); hook()->add('MailTemplate_mailSend', function () {
public function user_add() { $req = req()->_plain(); if ($req->is_post()) { lib()->load("UserRegister", "UserCheck"); try { $ur = new UserRegister(); hook()->add('UserRegister_Captcha', function () { //通过钩子去掉用户注册验证码 return true; }); $id = $ur->Register($req->post('email'), UserCheck::MakeHashChar($req->post('password')), $req->post('name'), "ADMIN"); if ($id > 0) { $this->rt_msg['status'] = true; $this->rt_msg['content'] = $id; } else { $this->rt_msg['msg'] = $ur->CodeMsg($id); } } catch (\Exception $ex) { $this->rt_msg['msg'] = $ex->getMessage(); } } else { $this->rt_msg['msg'] = "必须以POST方式提交数据"; } }
/** * 根据明文创建一个可供表单提交的HASH密码 * @param $str */ public function make_hash_char($str = NULL) { lib()->load('UserCheck'); $str = trim($str); if (empty($str)) { $this->rt_msg['msg'] = "提交的字符有误"; } else { $this->rt_msg['status'] = true; $this->rt_msg['content'] = UserCheck::MakeHashChar($str); } }