Chevereto 图床程序注册页面添加通过邀请码注册功能

网站优化评论7101字数 1222阅读模式

Chevereto 是一个图床程序,如果开启注册功能的话,那么所有人都可以在平台注册帐号,为了防止某些人上传非法照片,我们可以添加一个邀请码注册的权限,那么,如果想注册帐号,就需要先得到邀请码。可以根据下面的方法进行修改。

Chevereto 图床程序注册页面添加通过邀请码注册功能

修改 route.signup.php

修改 route.signup.php 文件,位置:/chevereto/app/routes/route.signup.php,找到下述代码:

// Input validations
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
    $input_errors['email'] = _s('Invalid email');
}
if (!CHV\User::isValidUsername($_POST['username'])) {
    $input_errors['username'] = _s('Invalid username');
}
if (!preg_match('/' . CHV\getSetting('user_password_pattern') . '/', $_POST['password'])) {
    $input_errors['password'] = _s('Invalid password');
}

之后追加:

//邀请码
if(!isset($_POST['invitationcode']) || $_POST['invitationcode'] != 'xxxxx') {
    $input_errors['invitationcode'] = _s('Invalid invitation code');
}

修改页面

修改 signup.php 文件,位置:/chevereto/app/themes/Peafowl/views/signup.php,找到 form 表单:

<form class="content-section" method="post" autocomplete="off" data-action="validate">

添加下述代码:

<div class="position-relative">
    <input name="invitationcode" tabindex="1" autocomplete="off" autocorrect="off" autocapitalize="off" type="input" placeholder="<?php _se('Invitation code'); ?>" class="input animate" required value="<?php echo get_safe_post()['invitationcode']; ?>">
    <div class="text-align-left red-warning"><?php echo get_input_errors()['invitationcode']; ?></div>
</div>

大功告成。

本文已通过「原本」原创作品认证,转载请注明文章出处及链接。

夏日阳光
  • 本文由 夏日阳光 发表于 2022年2月9日
  • 本文为夏日阳光原创文章,转载请务必保留本文链接:https://www.pieruo.com/203.html
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证