Lufer

  • 首页
  • 编程
  • 学习笔记
  • 日常折腾
Lufer
Code the World
  1. 首页
  2. 日常折腾
  3. 正文

自建Chevereto图床并设置邀请码注册

2021年3月5日 1192点热度 0人点赞 0条评论

之前一直在用imgchr.com的图床,但是近期发现无法上传图片,访问倒是正常。

为了防止这个图床哪天崩了,决定还是把图放在自己手里比较安全。

搜了一圈发现imgchr就是用chevereto搭建的,chevereto是一个开源的免费软件,那不如自己搭一个,正好搭在自己的NAS上,做个穿透即可。

群晖安装Chevereto

这里才用了什么值得买上zhouningyi01的教程,链接如下。但是有些许不同。

https://post.smzdm.com/p/a3gvxnon/

下载Chevereto代码

https://github.com/Chevereto/Chevereto-Free

选择Download ZIP

群晖安装环境

在群晖的套件中心添加图中的套件,其中PHP7.2不需要手动安装,在装其他套件时会提示安装。

打开群晖的 Web Station 套件,点击 PHP 设置,如果有就点编辑,如果没有条目就点击新增,然后选择PHP7.2,将下方的扩展名全部打勾,然后确定保存。

把下载的Chevereto压缩包上传到NAS的web目录下并解压

给Chevereto文件夹权限,右键-属性-权限,然后新增,用户组选 Everyone,并给与管理、读取、写入权限,然后勾上应用到这个文件夹、子文件夹及文件后保存。

打开群晖的phpMyAdmin,新建一个数据库,数据库名称可以自定义。

打开 Web Station 设置虚拟主机,根据需要选择基于名称或基于端口,因为我需要做内网穿透和HTTPS,所以选择了基于名称,这样在勾选HSTS后可以自动进行HTTP到HTTPS的跳转。如果没有这种需求可以选择基于端口。文档根目录选择到chevereto的目录,并选择对应的后端服务器和PHP版本。

新建一个文本文档,将 “新建文本文档.txt” 重命名为”settings.php“之后传到 web/chevereto/app 文件夹下,缺少这一步的话打开网站会提示:Chevereto can’t create the app/settings.php file. You must manually create this file。

打开群晖IP地址:端口号打开管理页面然后填入数据库信息开始安装。

最后一项如果选择personal则只能自己使用,如果选择community则允许其他用户注册。

至此安装完成。

添加邀请码注册

修改 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'] != '你要设置的邀请码') {
    $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>
标签: Chevereto Docker 群晖
最后更新:2023年7月10日

Lufer

新的一天开始啦

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

文章目录
  • 群晖安装Chevereto
    • 下载Chevereto代码
    • 群晖安装环境
  • 添加邀请码注册

COPYRIGHT © 2022 lufer.cc.

Theme Kratos Made By Seaton Jiang

鲁ICP备2021045819号