Exemple #1
0
 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;
         });
     }
 }
Exemple #2
0
				<p class="help-block">评论CSS最大的嵌套层数</p>
			</div>
		</div>

		<div class="form-group">
			<label for="inputAvatar" class="col-sm-2 control-label">网站默认头像</label>

			<div class="col-sm-10">
				<select name="default_avatar" class="form-control">
					<option value="default"<?php 
echo strtolower(default_avatar_config()) == "default" ? " selected" : "";
?>
>网站默认头像</option>
					<option value="gravatar"<?php 
echo strtolower(default_avatar_config()) == "gravatar" ? " selected" : "";
?>
>Gavatar头像</option>
				</select>

				<p class="help-block">针对用户创建一个默认的头像,访问<a href="http://en.gravatar.com/">Gavatar</a></p>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label">用户注册</label>

			<div class="col-sm-10">
				<div class="checkbox">
					<label>
						<input name="allowed_register" value="yes" type="checkbox"<?php