public function register_hook() { $hook = hook(); $hook->add('UserRegister_Register_before', function ($code) { if ($code === 0 && !allowed_register()) { return -11; } return $code; }); switch (site_mode()) { case "https": if (!is_ssl()) { header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); redirect("https://" . substr(URL_NOW, 6), "header", 301); } $hook->add('get_url', function () { return site_url_ssl(); }); $hook->add("get_file_url", function () { return site_static_url_ssl(); }); break; case "all": if (is_ssl()) { $hook->add('get_url', function () { return site_url_ssl(); }); $hook->add("get_file_url", function () { return site_static_url_ssl(); }); } else { $hook->add('get_url', function () { return site_url(); }); $hook->add("get_file_url", function () { return site_static_url(); }); } break; default: if (is_ssl()) { header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); redirect("http://" . substr(URL_NOW, 7), "header", 301); } $hook->add('get_url', function () { return site_url(); }); $hook->add("get_file_url", function () { return site_static_url(); }); } $hook->add("UserRegister_CodeMsg", function ($msg, $code) { if ($code == -11) { return _("User register already closed."); } return $msg; }); if (!login_captcha()) { //将验证码检测返回TRUE $hook->add("UserLogin_Captcha", function () { return true; }); } if (email_notice()) { $hook->add('UserRegister_Register_success', function ($user_id) { lib()->load('MailTemplate'); $user = User::getUser($user_id); $mt = new MailTemplate("new_user_registered.html"); $mt->setUserInfo($user->getInfo()); $mt->mailSend(site_title() . " Manager", admin_email()); }); } if (strtolower(default_avatar_config()) == "gravatar") { $hook->add("Avatar_convert", function ($avatar) { if (strtolower($avatar) == "{default}") { return "{gravatar}"; } return $avatar; }); } }
<input type="email" name="admin_email" class="form-control" value="<?php echo admin_email(); ?> " id="inputAdminEmail" placeholder="邮箱地址"> <p class="help-block">用于网站的系统提示等通知</p> </div> </div> <div class="form-group"> <label for="inputSiteMode" class="col-sm-2 control-label">网站模式</label> <div class="col-sm-10"> <select name="site_mode" class="form-control" id="inputSiteMode"> <?php echo html_option(['http' => 'http', 'https' => 'https', 'all' => '兼容两者'], site_mode()); ?> </select> <p class="help-block">网站的自定义网址前缀,必须以斜杠结尾</p> </div> </div> <div class="form-group"> <label for="inputSiteUrl" class="col-sm-2 control-label">网站地址</label> <div class="col-sm-10"> <input type="url" name="site_url" class="form-control" value="<?php echo site_url(); ?> " id="inputSiteUrl" placeholder="url">