diff --git a/README.md b/README.md index 44f6bd5..01c4cf8 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,11 @@ 一个轻量化的留言板 / 记事本 / 社交系统 / 博客,没有明确的作用定义,一切都随心所欲。 -- 演示 demo:https://pigeon.ssr.wine/ +- 演示 demo:https://pigeon.ssr.wine/ (已关闭,请看下面这个) - 博客示例:https://tql.ink/ +> 上面链接为本人博客,可以测试发布内容,无意义内容请设置仅自己可见,或者发布后删除,避免影响版面整洁。 + ## 简介 你是否有些临时的想法,或者一小段代码,想找一个地方记下来? @@ -52,6 +54,8 @@ php install.php 安装程序是没有界面的,请通过命令行执行 `install.php`,而不是通过网页访问它。 +> 如需手动安装(不使用安装程序),请 [点击这里阅读安装方法](https://github.com/kasuganosoras/Pigeon/wiki/Install#%E6%89%8B%E5%8A%A8%E5%AE%89%E8%A3%85-pigeon) + ## 未来计划 - [x] 管理员后台系统(已实现) diff --git a/install.php b/install.php index 943878d..f48816d 100755 --- a/install.php +++ b/install.php @@ -23,6 +23,16 @@ echo "是否启用注册功能 (y/n)> "; $enable_registe = trim(fgets(STDIN)); $enable_registe = empty($enable_registe) ? "y" : strtolower($enable_registe); + +// https://github.com/kasuganosoras/Pigeon/issues/31 +$enable_smtp = 'false'; +$smtp_host = ""; +$smtp_port = 25; +$smtp_user = ""; +$smtp_pass = ""; +$smtp_name = ""; +$smtp_mail = ""; + if($enable_registe == "y") { $enable_registe = 'true'; echo "是否启用注册邮箱验证 (y/n)> "; @@ -45,17 +55,11 @@ echo "请输入 SMTP 邮箱 (noreply@example.com)> "; $smtp_mail = trim(fgets(STDIN)); $smtp_mail = empty($smtp_mail) ? "noreply@example.com" : $smtp_mail; - } else { - $enable_smtp = 'false'; - $smtp_host = ""; - $smtp_port = 25; - $smtp_user = ""; - $smtp_pass = ""; - $smtp_name = ""; } } else { $enable_registe = 'false'; } + echo "请输入站点名称 (Pigeon)> "; $sitename = trim(fgets(STDIN)); $sitename = empty($sitename) ? "Pigeon" : $sitename; diff --git a/pigeon/loader.php b/pigeon/loader.php index 8a4cae1..d0b263e 100755 --- a/pigeon/loader.php +++ b/pigeon/loader.php @@ -1,89 +1,52 @@ guid(); -} -// 判断传入参数 s -if(isset($_GET['s'])) { - switch($_GET['s']) { - case 'timeline': - if(isset($_GET['page']) && preg_match("/^[0-9]{0,6}$/", $_GET['page'])) { - $pigeon->before = null; - $pigeon->search = null; - if(isset($_GET['time']) && preg_match("/^[0-9\:\- ]+$/", $_GET['time'])) { - $beforeTime = strtotime($_GET['time']); - $pigeon->before = $beforeTime ? $beforeTime : null; - } - if(isset($_GET['search']) && $_GET['search'] !== '') { - $pigeon->search = mysqli_real_escape_string($pigeon->conn, $_GET['search']); - } - $pigeon->isLogin = (isset($_SESSION['user']) && $_SESSION['user'] !== ''); - $pigeon->isAjax = (isset($_GET['ajax']) && $_GET['ajax'] == '1'); - if(isset($_GET['user']) && preg_match("/^[A-Za-z0-9\_\-]{0,32}$/", $_GET['user'])) { - $pigeon->getTimeline($_GET['user'], true, Intval($_GET['page'])); - } else { - $pigeon->getTimeline(null, true, Intval($_GET['page'])); - } - } - break; - case 'login': - $error = ""; - $alert = "danger"; - if(isset($_POST['username']) && isset($_POST['password'])) { - if(!isset($_POST['seid']) || $_POST['seid'] !== $_SESSION['seid']) { - $pigeon->Exception("CSRF 验证失败,请尝试重新登录。"); - } - if($pigeon->config['recaptcha_key'] !== '') { - if(!isset($_POST['g-recaptcha-response']) || !$pigeon->recaptcha_verify($_POST['g-recaptcha-response'])) { - $error = "Recaptcha 验证失败。"; + SESSION_START(); + // 加载函数库 + include(ROOT . "/pigeon/function.php"); + include(ROOT . "/pigeon/parsedown.php"); + // 实例化 Pigeon + $pigeon = new Pigeon(); + // 生成 SESSION ID + if(!isset($_SESSION['seid'])) { + $_SESSION['seid'] = $pigeon->guid(); + } + // 判断传入参数 s + if(isset($_GET['s'])) { + switch($_GET['s']) { + case 'timeline': + if(isset($_GET['page']) && preg_match("/^[0-9]{0,6}$/", $_GET['page'])) { + $pigeon->before = null; + $pigeon->search = null; + if(isset($_GET['time']) && preg_match("/^[0-9\:\- ]+$/", $_GET['time'])) { + $beforeTime = strtotime($_GET['time']); + $pigeon->before = $beforeTime ? $beforeTime : null; } - } - $username = mysqli_real_escape_string($pigeon->conn, $_POST['username']); - $login_ip = mysqli_real_escape_string($pigeon->conn, $_SERVER['REMOTE_ADDR']); - $rs = mysqli_fetch_array(mysqli_query($pigeon->conn, "SELECT * FROM `users` WHERE `username`='{$username}'")); - if($rs) { - if($rs['status'] !== '200') { - switch($rs['status']) { - case "401": - $error = "您需要先验证邮箱才能登陆,点击重新发送邮件。"; - break; - case "403": - $error = "您的账号已被封禁。"; - break; - default: - $error = "您的账号为异常状态,请联系管理员。"; - } + if(isset($_GET['search']) && $_GET['search'] !== '') { + $pigeon->search = mysqli_real_escape_string($pigeon->conn, $_GET['search']); + } + $pigeon->isLogin = (isset($_SESSION['user']) && $_SESSION['user'] !== ''); + $pigeon->isAjax = (isset($_GET['ajax']) && $_GET['ajax'] == '1'); + if(isset($_GET['user']) && preg_match("/^[A-Za-z0-9\_\-]{0,32}$/", $_GET['user'])) { + $pigeon->getTimeline($_GET['user'], true, Intval($_GET['page'])); } else { - if(password_verify($_POST['password'], $rs['password'])) { - if($error == '') { - mysqli_query($pigeon->conn, "UPDATE `users` SET `latest_ip`='{$login_ip}', `latest_time`='" . time() . "' WHERE `id`='{$rs['id']}'"); - $_SESSION['user'] = $rs['username']; - $_SESSION['email'] = $rs['email']; - $_SESSION['token'] = $rs['token']; - ?> - -
-