Ejemplo n.º 1
0
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 () {
    //去掉发送邮件发送功能
    return false;
Ejemplo n.º 2
0
 /**
  * @param $list array
  * @throws \Exception
  */
 public function set($list)
 {
     $data = [];
     $update = [];
     foreach ($list as $name => $value) {
         $name = trim($name);
         if ($name !== 'id' && in_array($name, self::$column_list)) {
             $data[$name] = $value;
             $update["user_" . $name] = $value;
             if (substr($name, -3) === '_ip') {
                 $update["user_" . $name] = Ip::getInstance()->ip2bin($value);
             }
         }
     }
     lib()->load('UserCheck');
     if (isset($update['user_aliases']) && empty($update['user_aliases'])) {
         throw new \Exception(_("Aliases can't set empty."));
     }
     if (isset($update['user_email']) && !UserCheck::CheckEmailChar($update['user_email'])) {
         throw new \Exception(_("Email verify check Error"));
     }
     if (isset($update['user_name']) && !UserCheck::CheckUsernameChar($update['user_name'])) {
         throw new \Exception(_("Username verify check Error"));
     }
     if (isset($update['user_password']) && !UserCheck::CheckPasswordChar($update['user_password'])) {
         throw new \Exception(_("Password verify check Error"));
     }
     if (isset($update['user_url']) && $update['user_url'] != "" && !filter_var($update['user_url'], FILTER_VALIDATE_URL)) {
         throw new \Exception(_("Url check error"));
     }
     if (count($update) > 0) {
         if (db()->update("users", $update, ['id' => $this->id]) === false) {
             throw new \Exception(_("Can't update User info.") . debug("SQL msg:" . implode(",", db()->error()['write'])));
         }
         foreach ($data as $n => $v) {
             $this->{$n} = $v;
         }
     }
 }