mirror of
https://gitee.com/tawords/tawords
synced 2025-09-12 21:31:39 +08:00
2020.08.25
This commit is contained in:
20
.htaccess
Normal file
20
.htaccess
Normal file
@@ -0,0 +1,20 @@
|
||||
# 默认索引页面(不能这样设置,这样首页省略不带index.php时会403错误)
|
||||
# DirectoryIndex index.php, index.html, index.htm
|
||||
|
||||
# 定义404错误页面
|
||||
RewriteEngine on
|
||||
#if requested resource isn't a file and isn't a directory, then serve local error script
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule .* ./prompt/404.php [L]
|
||||
|
||||
|
||||
# 定义403错误页面(只支持绝对路径,不然会把文字显示在屏幕上,路径不需要打“”)
|
||||
ErrorDocument 403 "403 Forbidden"
|
||||
# ErrorDocument 404 "404 Not Found"
|
||||
|
||||
|
||||
# 关闭目录浏览
|
||||
Options -Indexes
|
||||
# 打开目录浏览
|
||||
# Options +Indexes
|
11
config.php
11
config.php
@@ -8,9 +8,16 @@ return array(
|
||||
),
|
||||
'page' => array(
|
||||
'title' => "在线背单词(开发中)", // 网站名称
|
||||
'iconpath' => "./img/vocabulary.png", // 网站图标
|
||||
'homepage' => "//".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/",
|
||||
'keywords' => "背单词, 记单词, 单词, recite words, memorize words, english words, words, 艾宾浩斯, 记忆曲线, 遗忘曲线, Ebbinghaus, memory curve, forgetting Curve, 记忆规律, 在线背单词", // 关键词【建议慎用或不使用】
|
||||
'description' => "XX在线背单词系统遵循科学记忆规律,背诵过程中为您呈现直观的单词记忆曲线图,通过不断重复在遗忘边缘的词汇加深您对单词的记忆,使您单词记忆过程事半功倍,快乐而不枯燥。", // 网站简介
|
||||
'iconpath' => "./img/icon.png", // 网站图标路径
|
||||
'thumbnail' => "./img/thumbnail.jpg", // 缩略图路径
|
||||
'author' => "张小弟之家", // 作者信息
|
||||
'copyright' => "© ".date('Y')." 张小弟之家 保留所有权利", // 版权信息
|
||||
'revisit_time' => "7 days", // 希望搜索引擎重访的天数
|
||||
'homepage' => "https://www.only4.work/recite-words/", //"//".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/", // 这个有问题!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!其他目录获取的不是网站首页,会多出一个二级目录!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!暂时写死,后期找到解决办法再说!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
/* 例如:【//www.only4.work/recite-words/】 */
|
||||
|
||||
'serverpath' => __DIR__, // 网站主页目录(不是URL)
|
||||
'record_code' => // 备案代码
|
||||
<<<EOF
|
||||
|
10
css/index.html
Normal file
10
css/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
BIN
function/captcha-font-Geneva.ttf
Normal file
BIN
function/captcha-font-Geneva.ttf
Normal file
Binary file not shown.
85
function/captcha.php
Normal file
85
function/captcha.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*
|
||||
* 页面: 验证码生成
|
||||
* 版本号: 1.0.0
|
||||
* 修改时间: 2020.08.23
|
||||
* 备注: $_SESSION['vCode']为生成的验证码
|
||||
*/
|
||||
|
||||
// JS获取验证码所带参数示范:idcodeimg.src = "idcode.php?t=" + Math.round(new Date() / 1000);
|
||||
|
||||
|
||||
// 获取URL传入参数
|
||||
if(!isset($_GET["t"])/* 时间戳 */ || (time() - $_GET["t"]) > 3 * 60){
|
||||
echo "哎呀,验证码过期啦"; exit();
|
||||
}else{
|
||||
output();
|
||||
}
|
||||
|
||||
// 绘制验证码 图片
|
||||
function output() {
|
||||
session_start();//开启会话
|
||||
|
||||
/**
|
||||
* php生成验证码
|
||||
* @param $width 画布宽
|
||||
* @param $height 画布高
|
||||
* @param $vcodelen 验证码长度
|
||||
* @param $pointnum 干扰像素点数量
|
||||
* @param $linenum 干扰线条数量
|
||||
*
|
||||
* 思路:创建验证码画布,生成并填充背景色,生成验证码内容/干扰像素点/线,填充到画布,输出。
|
||||
*/
|
||||
$width = 140;
|
||||
$height = 35;
|
||||
$vcodelen = 4;
|
||||
$pointnum = 100;
|
||||
$linenum = 2;
|
||||
// 创建画布
|
||||
$image = imagecreatetruecolor($width, $height);
|
||||
// 创建色块
|
||||
$bgcolor = imagecolorallocate($image, 255, 255, 255);
|
||||
// 填充画布背景色
|
||||
imagefill($image, 0, 0, $bgcolor);
|
||||
// 验证码内容
|
||||
$new_number='';
|
||||
// 记录验证码数字
|
||||
for ($i=0; $i < $vcodelen; $i++) {
|
||||
// 字体大小
|
||||
$fontsize = rand(14,18);
|
||||
// 字体颜色,颜色在限定范围内随机
|
||||
$fontcolor = imagecolorallocate($image, rand(0,120), rand(0,120), rand(0,120));
|
||||
$data = '0123456789';//abcdefghijklmnopqrstuvwxyz
|
||||
// 验证码内容在以上字符串内随机截取
|
||||
$fontcontent = substr($data, rand(0,strlen($data)-1),1);
|
||||
// 字符串显示位置
|
||||
$x = ($i*$width/4) + rand(0,10);
|
||||
$y = 20 + rand(0,10);
|
||||
// 字符串填充图片
|
||||
// imagestring的字体大小可选1-5,字体再大需要用imagettftext函数(需要字体文件)
|
||||
// imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor); // 字体大小为1-5
|
||||
imagettftext($image, $fontsize, 0, $x, $y, $fontcolor, '/captcha-font-Geneva.ttf', $fontcontent); // 字体大小大于5
|
||||
$new_number.=$fontcontent;
|
||||
}
|
||||
// 干扰像素点
|
||||
for ($i=0; $i < $pointnum; $i++) {
|
||||
$pointcolor = imagecolorallocate($image, rand(0,120), rand(0,120), rand(0,120));
|
||||
// 画布填充像素点函数
|
||||
imagesetpixel($image, rand(0,$width), rand(0,$height), $pointcolor);
|
||||
}
|
||||
// 干扰线条
|
||||
for ($i=0; $i < $linenum; $i++) {
|
||||
$linecolor = imagecolorallocate($image, rand(0,120), rand(0,120), rand(0,120));
|
||||
// 画布填充线条函数
|
||||
imageline($image, rand(0,$width), rand(0,$height), rand(0,$width), rand(0,$height), $linecolor);
|
||||
}
|
||||
// 图片输出格式
|
||||
header('content-type: image/png'); // 说明欲输出的图片类型格式
|
||||
// 输出验证码图片
|
||||
imagepng($image); // 函数用来建立一张 PNG 格式图形
|
||||
// 销毁画布
|
||||
imagedestroy($image); // 销毁图像,释放与 $img 关联的内存
|
||||
|
||||
$_SESSION['captcha'] = $new_number;
|
||||
//将获取的随机数验证码写入到SESSION变量中
|
||||
}
|
4
function/get-captcha-code-test-only.php
Normal file
4
function/get-captcha-code-test-only.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
// 这个PHP很危险,正式发布时一定不可以公开!否则验证码形同虚设
|
||||
session_start();
|
||||
echo $_SESSION['captcha'];
|
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
// 隐藏Notice提示
|
||||
// error_reporting(E_ALL ^ E_NOTICE);
|
||||
|
||||
// error_reporting(E_ALL^E_NOTICE^E_WARNING);
|
||||
|
||||
// 隐藏所有提示
|
||||
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_ERROR ^ E_COMPILE_ERROR);
|
||||
|
||||
|
||||
/*
|
||||
经常见到error_reporting(7)直意为:设定错误讯息回报的等级。
|
||||
|
||||
value constant
|
||||
1 E_ERROR
|
||||
2 E_WARNING
|
||||
4 E_PARSE
|
||||
8 E_NOTICE
|
||||
16 E_CORE_ERROR
|
||||
32 E_CORE_WARNING
|
||||
64 E_COMPILE_ERROR
|
||||
128 E_COMPILE_WARNING
|
||||
256 E_USER_ERROR
|
||||
512 E_USER_WARNING
|
||||
1024 E_USER_NOTICE
|
||||
2047 E_ALL
|
||||
2048 E_STRICT
|
||||
|
||||
然而7=1+2+4
|
||||
就是出错时显示1 E_ERROR 2 E_WARNING 4 E_PARSE
|
||||
|
||||
复制代码 代码如下:
|
||||
|
||||
<?php
|
||||
//禁用错误报告
|
||||
error_reporting(0);
|
||||
//报告运行时错误
|
||||
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
||||
//报告所有错误
|
||||
error_reporting(E_ALL);
|
||||
?>
|
||||
*/
|
10
function/index.html
Normal file
10
function/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@@ -9,7 +9,7 @@ class mysql {
|
||||
function __construct() // 建立数据库连接 通过mysqli连接Mysql - 采用面向对象的写法来完成数据库的连接
|
||||
{
|
||||
// 定义config.php文件路径
|
||||
$config_file = __DIR__ . "/../config.php";
|
||||
$config_file = dirname(__DIR__) . "/config.php";
|
||||
|
||||
// 判断config.php文件是否可读
|
||||
// if(!is_readable($config_file)) { die("config.php文件没有读取权限!<br />"); }
|
||||
|
@@ -1,2 +0,0 @@
|
||||
<?php
|
||||
phpinfo();
|
10
function/statistics/index.html
Normal file
10
function/statistics/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@@ -2,13 +2,13 @@
|
||||
// 获取URL传入参数
|
||||
|
||||
/* DEMO
|
||||
$url = 'http://www.baidu.com/index.php?m=content&c=index&a=lists&catid=6&area=0&author=0&h=0®ion=0&s=1&page=1';
|
||||
$url = 'http://www.baidu.com/index.php?m=content&c=index';
|
||||
$arr = parse_url($url);// var_dump($arr);
|
||||
// array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(13) "www.baidu.com" ["path"]=> string(10) "/index.php" ["query"]=> string(73) "m=content&c=index&a=lists&catid=6&area=0&author=0&h=0®ion=0&s=1&page=1" }
|
||||
// array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(13) "www.baidu.com" ["path"]=> string(10) "/index.php" ["query"]=> string(73) "m=content&c=index" }
|
||||
$arr_query = convertUrlQuery($arr['query']);// var_dump($arr_query);
|
||||
// array(10) { ["m"]=> string(7) "content" ["c"]=> string(5) "index" ["a"]=> string(5) "lists" ["catid"]=> string(1) "6" ["area"]=> string(1) "0" ["author"]=> string(1) "0" ["h"]=> string(1) "0" ["region"]=> string(1) "0" ["s"]=> string(1) "1" ["page"]=> string(1) "1" }
|
||||
// array(10) { ["m"]=> string(7) "content" ["c"]=> string(5) "index" }
|
||||
// var_dump(getUrlQuery($arr_query));
|
||||
// string(73) "m=content&c=index&a=lists&catid=6&area=0&author=0&h=0®ion=0&s=1&page=1"
|
||||
// string(73) "m=content&c=index"
|
||||
|
||||
var_dump($arr_query);
|
||||
|
||||
|
40
function/users/flag-json.php
Normal file
40
function/users/flag-json.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
$arr = array(
|
||||
// 登录相关 v1.0.2
|
||||
"10000" => "登录成功",
|
||||
"10010" => "验证码输入错误,请重试", // 验证码输入错误
|
||||
"10011" => "验证码已经失效,请重试", // 验证码已经失效
|
||||
"10012" => "验证码未输入",
|
||||
"10020" => "用户名或密码错误",
|
||||
"10021" => "用户名未输入",
|
||||
"10022" => "密码未输入",
|
||||
"10030" => "您已登录", // 已登录帐号,但未确定是否为当前帐号
|
||||
"10031" => "您已登录当前帐号,无需再次登录", // 已登录当前帐号
|
||||
"10032" => "当前登录帐号与您正在登录的账号不同,请先注销后再登陆", // 已登录其他帐号
|
||||
"10040" => "系统未知错误",
|
||||
"10041" => "服务器原因登录失败",
|
||||
"10050" => "无效token",
|
||||
// 注册相关 v1.0.1
|
||||
"20000" => "注册成功",
|
||||
"20010" => "验证码输入错误,请重试", // 验证码输入错误
|
||||
"20011" => "验证码已经失效,请重试", // 验证码已经失效
|
||||
"20012" => "验证码未输入",
|
||||
"20020" => "用户名已存在",
|
||||
"20021" => "用户名未输入",
|
||||
"20022" => "密码未输入",
|
||||
"20023" => "确认密码未输入",
|
||||
"20024" => "两次密码不相同",
|
||||
"20025" => "昵称未输入",
|
||||
"20026" => "用户名太短、太长或含有特殊字符",
|
||||
"20032" => "已登录其他帐号,请退出后再注册", // 已登录其他帐号
|
||||
"20040" => "系统未知错误",
|
||||
"20041" => "服务器原因注册失败",
|
||||
"20050" => "无效token",
|
||||
);
|
||||
echo json_encode($arr);
|
||||
|
||||
// if(!isset($_GET['flag']) || !array_key_exists($_GET['flag'], $arr))
|
||||
// echo json_encode($arr);
|
||||
// else
|
||||
// echo json_encode(array($_GET['flag'] => $arr[$_GET['flag']]));
|
||||
// // echo $arr[$_GET['flag']];
|
19
function/users/get-status.php
Normal file
19
function/users/get-status.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
* get.php(判断登录状态):未登录显示登录注册选项,用户登陆后切换显示成昵称和注销选项
|
||||
* flag:
|
||||
* true 用户已登录
|
||||
* false 用户未登录
|
||||
*/
|
||||
|
||||
/*开启会话*/
|
||||
session_start();
|
||||
|
||||
if (isset($_SESSION['username'])){
|
||||
/* 判断用户会话里用户名是否存在,即用户是否登录*/
|
||||
$json['username']=$_SESSION['username'];
|
||||
$json['nickname']=$_SESSION['nickname'];
|
||||
$json['flag']=true;/*用户已经登录,标志flag为true*/
|
||||
}else
|
||||
$json['flag']=false;/*用户还未登录,标志flag为false*/
|
||||
echo json_encode($json);/*返回json*/
|
10
function/users/index.html
Normal file
10
function/users/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
176
function/users/login.html.bak
Normal file
176
function/users/login.html.bak
Normal file
@@ -0,0 +1,176 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>登录 / 注册</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- 新 Bootstrap 核心 CSS 文件 -->
|
||||
<!--<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">-->
|
||||
<link href="./css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<li class="toggle"><a data-toggle="modal" href="#loginer">登录</a></li>
|
||||
<li class="toggle"><a data-toggle="modal" href="#register">注册</a></li>
|
||||
|
||||
<li class="toggle hidden"><a id="nicheng" href="./login.html"></a></li>
|
||||
<li class="toggle hidden"><a id="logout" href="./login.html">注销</a></li>
|
||||
|
||||
<!-- 登录 -->
|
||||
<div id="loginer" class="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title">请登录</h4>
|
||||
</div>
|
||||
<form id="form_login" class="form-horizontal">
|
||||
<div class="modal-body">
|
||||
<div class="form-group has-feedback">
|
||||
<label class="col-sm-3 control-label" for="zh1">用户名:</label>
|
||||
<div class="col-sm-9 require">
|
||||
<input type="text" class="form-control" name="username" id="zh1" pattern="\w{6,10}" value="111111" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label class="col-sm-3 control-label" for="pw1">密码:</label>
|
||||
<div class="col-sm-9 require">
|
||||
<input type="password" pattern="\w{6,10}" class="form-control" name="pwd" id="pw1" value="111111" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label class="col-sm-3 control-label" for="yzm">验证码:</label>
|
||||
<div class="col-sm-5 require">
|
||||
<input type="text" pattern="\d{4}" class="form-control" name="yzm" id="yzm" required>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<img id="idcodeimg" src="" alt="验证码">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label id="info" class="col-sm-4 control-label pull-left"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary">登录</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 注册 -->
|
||||
<div id="register" class="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabe2"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title">请注册</h4>
|
||||
</div>
|
||||
<form id="form_regist" class="form-horizontal">
|
||||
<div class="modal-body">
|
||||
<div class="form-group has-feedback">
|
||||
<label class="col-sm-3 control-label" for="zh2">用户名:</label>
|
||||
<div class="col-sm-9 require">
|
||||
<input type="text" class="form-control" name="username" id="zh2" pattern="\w{6,10}" value="111111" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label class="col-sm-3 control-label" for="pw2">密码:</label>
|
||||
<div class="col-sm-9 require">
|
||||
<input type="password" pattern="\w{6,10}" class="form-control" name="pwd" id="pw2" value="111111">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label class="col-sm-3 control-label" for="pw3">确认密码:</label>
|
||||
<div class="col-sm-9 require">
|
||||
<input type="password" pattern="\w{6,10}" class="form-control" name="repwd" id="pw3" value="111111">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label class="col-sm-3 control-label" for="lc">昵称:</label>
|
||||
<div class="col-sm-9 require">
|
||||
<input type="text" pattern="\S{2,10}" class="form-control" name="nc" id="lc" value="111111">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label id="wanner" class="col-sm-4 control-label pull-left"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary">注册</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="js/jquery 2.1.3.min.js"></script>
|
||||
<script src="js/bootstrap 3.3.7.min.js"></script>
|
||||
|
||||
<script>
|
||||
function toggle(){
|
||||
$.getJSON("php/get.php",function (res) {
|
||||
//获取当前用户是否登录
|
||||
if(res['flag']){//用户已经登录,显示昵称和注销选项
|
||||
$('li.toggle').toggleClass('hidden');
|
||||
$('#nicheng').html(res['nc'])
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#form_login').submit(function (e) {/*登录*/
|
||||
e.preventDefault();/*阻止表单默认事件,页面全局刷新*/
|
||||
var data=$('#form_login').serialize();/*将表单里的数据包装起来*/
|
||||
$.getJSON('php/login.php',data,function (res) {
|
||||
/*data:将表单里的数据传给php,回调函数接受php返回来的值*/
|
||||
if(res==3){//用户名、密码、验证码都输入正确
|
||||
toggle();/*修改首页选项菜单*/
|
||||
$('#loginer').modal('hide');/*关闭模态框*/
|
||||
}else if(res==2){
|
||||
$('#info').html('用户名或密码有误')
|
||||
}else {
|
||||
$('#info').html('验证码有误')
|
||||
}
|
||||
})
|
||||
});
|
||||
$('#logout').click(function () {
|
||||
confirm('确定要注销?');
|
||||
$.getJSON('php/logout.php',function (res) {
|
||||
if(res)toggle();
|
||||
})
|
||||
})
|
||||
$('#form_regist').submit(function (e) {
|
||||
e.preventDefault();
|
||||
var data=$('#form_regist').serialize();
|
||||
$.getJSON('php/regist.php',data,function (res) {
|
||||
if(res==3){
|
||||
toggle();
|
||||
$('#register').modal('hide');
|
||||
}else if (res==2) {
|
||||
$('#wanner').html('两次密码不一致,请重试!')
|
||||
}else if (res==1) {
|
||||
$('#wanner').html('用户名冲突,请重试!')
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
$('#idcodeimg').click(function () { refreshidcode() });
|
||||
|
||||
function refreshidcode() {
|
||||
idcodeimg.src = "./php/idcode.php?t=" + Math.round(new Date() / 1000) + "&r=" + Math.random();
|
||||
}
|
||||
refreshidcode();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
93
function/users/login.php
Normal file
93
function/users/login.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
error_reporting(E_ALL || ~E_NOTICE); //显示除去 E_NOTICE 之外的所有错误信息
|
||||
/*
|
||||
* login.php(登录):根据标志flag判断登录操作是否成功或哪里出错
|
||||
* flag: 【v1.0.2】
|
||||
* 10000 登录成功 √
|
||||
* 10010 验证码输入错误 √
|
||||
* 10011 验证码已经失效 √
|
||||
* 10012 验证码未输入 √
|
||||
* 10020 用户名或密码错误 √
|
||||
* 10021 用户名未输入 √
|
||||
* 10022 密码未输入 √
|
||||
* 10023 用户名太长或含有特殊字符 × !!!!!密码特殊字符问题
|
||||
* 10030 已登录帐号,但未确定是否为当前帐号 √
|
||||
* 10031 已登录当前帐号 √
|
||||
* 10032 已登录其他帐号 √
|
||||
* 10040 系统未知错误 √
|
||||
* 10041 服务器原因登录失败 ×
|
||||
* 10050 无效token √
|
||||
*/
|
||||
|
||||
/*开启会话*/
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
// 验证 token
|
||||
$token = isset($_SESSION['login_token']) ? $_SESSION['login_token'] : "";
|
||||
if ($token && $_POST['token'] === $token) {
|
||||
// 删除 token
|
||||
} else {
|
||||
// 记录潜在的 CSRF 攻击.
|
||||
echoflag(10050); // 无效token
|
||||
}
|
||||
|
||||
if(isset($_SESSION['username']) && trim($_SESSION['username']) != ""){ // 用户已经登录
|
||||
if(!isset($_POST['username']) || trim($_POST['username']) == ""){ // 用户名没有输入
|
||||
echoflag(10030); // 已登录帐号,但未确定是否为当前帐号
|
||||
}else{
|
||||
if($_SESSION['username'] == $_POST['username'])
|
||||
echoflag(10031); // 已登录当前帐号
|
||||
else
|
||||
echoflag(10032); // 已登录其他帐号
|
||||
}
|
||||
}
|
||||
|
||||
// 获取表单提交的数据
|
||||
if(!isset($_POST['username']) || trim($_POST['username']) == "")
|
||||
echoflag(10021); // 用户名未输入
|
||||
elseif(!isset($_POST['password']) || trim($_POST['password']) == "")
|
||||
echoflag(10022); // 密码未输入
|
||||
elseif(!isset($_POST['captcha']) || trim($_POST['captcha']) == "")
|
||||
echoflag(10012); // 验证码未输入
|
||||
|
||||
$user = $_POST['username']; /* 用户名 */
|
||||
$pwd = $_POST['password']; /* 密码 */
|
||||
$yzm = $_POST['captcha']; /* 验证码 */
|
||||
|
||||
|
||||
if(!isset($_SESSION['captcha']))
|
||||
echoflag(10011); // 验证码已经失效
|
||||
elseif($yzm!=$_SESSION['captcha']){
|
||||
echoflag(10010); // 验证码输入错误
|
||||
}else{
|
||||
// 连接MySQL数据库
|
||||
require_once dirname(__DIR__)."/mysql.php";
|
||||
$mysql = new mysql();
|
||||
|
||||
$result = $mysql -> query("select * from `users` where username='$user' and password='$pwd'");
|
||||
|
||||
// 函数 num_rows() 判断返回的数据。如果查询的结果>0表示查询成功,即用户登录成功
|
||||
if ( !(isset($result -> num_rows) && $result -> num_rows > 0) )
|
||||
echoflag(10020); // 用户名或密码错误
|
||||
else{
|
||||
$row = $result -> fetch_assoc();/* 读取从数据库获取的数据 */
|
||||
/*将用户名和昵称存在服务器,可以多个页面使用*/
|
||||
$_SESSION['username'] = $row['username'];
|
||||
$_SESSION['nickname'] = $row['nickname'];
|
||||
echoflag(10000); // 用户登录成功
|
||||
}
|
||||
}
|
||||
|
||||
// 按照正常逻辑不可能走到这一步,走到这一步一定是出鬼了
|
||||
echoflag(10040); // 系统未知错误
|
||||
|
||||
function echoflag($flag) {
|
||||
echo $flag;
|
||||
// token 暂时不清除
|
||||
// if(isset($_SESSION['login_token'])) unset($_SESSION['login_token']); // 清除 login_token
|
||||
if(isset($_SESSION['captcha'])) unset($_SESSION['captcha']); // 清除验证码
|
||||
if(isset($mysql)) unset($mysql); // 关闭数据库连接
|
||||
session_write_close(); // 结束当前session,保存session数据。
|
||||
exit();
|
||||
}
|
49
function/users/logout.php
Normal file
49
function/users/logout.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
* logout.php(注销登录):直接销毁会话变量,然后get.php里面获取不到username和nc即判断用户已注销
|
||||
*/
|
||||
session_start();
|
||||
unset($_SESSION['username']); // 销毁用户名
|
||||
unset($_SESSION['password']); // 销毁密码
|
||||
unset($_SESSION['nickname']); // 销毁昵称
|
||||
|
||||
unset($_SESSION['captcha']); // 销毁验证码
|
||||
|
||||
echo json_encode(true); // 返回结果
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
// // 初始化会话。
|
||||
// // 如果要使用会话,别忘了现在就调用:
|
||||
// session_start();
|
||||
|
||||
// // 重置会话中的所有变量
|
||||
// $_SESSION = array();
|
||||
|
||||
// // 如果要清理的更彻底,那么同时删除会话 cookie
|
||||
// // 注意:这样不但销毁了会话中的数据,还同时销毁了会话本身
|
||||
// if (ini_get("session.use_cookies")) {
|
||||
// $params = session_get_cookie_params();
|
||||
// setcookie(session_name(),"", -1,
|
||||
// $params["path"], $params["domain"],
|
||||
// $params["secure"], $params["httponly"]
|
||||
// );
|
||||
// }
|
||||
|
||||
// // 最后,销毁会话
|
||||
// session_destroy();
|
||||
?>
|
||||
<?php
|
||||
// //开启 Session
|
||||
// session_start();
|
||||
// // 删除所有 Session 变量
|
||||
// $_SESSION = array();
|
||||
// //判断 cookie 中是否保存 Session ID
|
||||
// if(isset($_COOKIE[session_name()])){
|
||||
// setcookie(session_name(),'',time()-3600, '/');
|
||||
// }
|
||||
// //彻底销毁 Session
|
||||
// session_destroy();
|
||||
?>
|
120
function/users/mysql-query-users.php.bak
Normal file
120
function/users/mysql-query-users.php.bak
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
// $login = new login();
|
||||
// echo $login -> user['password'];
|
||||
|
||||
class login {
|
||||
|
||||
// 变量名 与 数据表列 对应关系
|
||||
public $user = array(
|
||||
"name" => "username", // 用户名
|
||||
"nickname" => "nickname", // 昵称
|
||||
"password" => "password", // 密码
|
||||
);
|
||||
|
||||
public $mysql;
|
||||
|
||||
function __construct() {
|
||||
/*
|
||||
* connect.php(连接数据库):
|
||||
*/
|
||||
// 连接MySQL数据库
|
||||
require "mysql.php";
|
||||
$this -> mysql = new mysql();
|
||||
|
||||
session_start();/*开启会话*/
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
|
||||
}
|
||||
|
||||
public function login() {
|
||||
/*
|
||||
* login.php(登录):根据标志flag判断登录操作是否成功或哪里出错
|
||||
* flag: 1 验证码输入错误
|
||||
* 2 用户名或密码错误
|
||||
* 3 用户登录成功
|
||||
*/
|
||||
$user=$_GET['username'];/*获取登录表单提交过来的数据*/
|
||||
$pwd=$_GET['password'];
|
||||
$yzm=$_GET['captcha']; /* 验证码 */
|
||||
if(isset($_SESSION['vCode'])/* 判断验证码是否因为输入错误已经失效 */ && $yzm==$_SESSION['vCode']){/*当用户输入的验证码和图片验证码相同时*/
|
||||
$result=$link->query("select * from `users` where username='$user' and password='$pwd'");
|
||||
$link = null;
|
||||
$row = $result->fetch();/*读取从数据库获取的数据*/
|
||||
if ($row) {/*如果数据存在,即用户登录成功*/
|
||||
$_SESSION['username'] = $row['username'];
|
||||
/*将用户名和昵称存在服务器,可以多个页面使用*/
|
||||
$_SESSION['nickname'] = $row['nickname'];
|
||||
$flag=3;
|
||||
}else{/*用户名或密码错误*/
|
||||
$flag=2;
|
||||
}
|
||||
}else{/*验证码输入错误*/
|
||||
unset($_SESSION['vCode']);
|
||||
$flag=1;
|
||||
}
|
||||
echo $flag;
|
||||
unset($_SESSION['vCode']);
|
||||
}
|
||||
|
||||
public function get() {
|
||||
/*
|
||||
* get.php(判断登录状态):未登录显示登录注册选项,用户登陆后切换显示成昵称和注销选项
|
||||
*/
|
||||
include_once ("connect.php");
|
||||
session_start();/*开启会话*/
|
||||
if (isset($_SESSION['username'])){
|
||||
/* 判断用户会话里用户名是否存在,即用户是否登录*/
|
||||
$json['nickname']=$_SESSION['nickname'];/*把昵称存起来,一会返回给首页*/
|
||||
$json['flag']=true;/*用户已经登录,标志flag为true*/
|
||||
}else
|
||||
$json['flag']=false;/*用户还未登录,标志flag为false*/
|
||||
echo json_encode($json);/*返回json*/
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
/*
|
||||
* logout.php(注销登录):直接销毁会话变量,然后get.php里面获取不到username和nc即判断用户已注销
|
||||
*/
|
||||
session_start();
|
||||
unset($_SESSION['username']);//销毁用户名
|
||||
unset($_SESSION['nc']);//销毁昵称
|
||||
echo json_encode(true);//返回结果
|
||||
}
|
||||
|
||||
public function regist() {
|
||||
/*
|
||||
* regist.php(注册):根据设置标志flag的值判断注册的三种状态
|
||||
* flag: 1 用户名已存在
|
||||
* 2 两次密码不相同
|
||||
* 3 注册成功
|
||||
* 4 服务器原因注册失败
|
||||
*/
|
||||
include_once ("connect.php");
|
||||
$user=$_GET['username'];//获取表单提交的数据
|
||||
$pwd=$_GET['password'];
|
||||
$repwd=$_GET['password_confirm'];
|
||||
$nc=$_GET['username'];//$_GET['nickname']; // 昵称(暂时先用用户名代替)
|
||||
$row=$link->query("select * from `users` where username='$user'");
|
||||
/*查询数据库中是否存在用户名相同的用户*/
|
||||
if ($row->rowCount()){
|
||||
$flag=1;/*存在用户名相同,即用户名冲突*/
|
||||
}else if ($pwd!=$repwd){
|
||||
$flag=2;/*两次密码不相同*/
|
||||
}else{/*插入数据进数据库*/
|
||||
$row=$link->exec("insert into `users`(`username`, `nickname`, `password`) values('$user','$pwd','$nc')");
|
||||
// $row=$link->exec("insert into `users`(`username`, `nickname`, `password`) values('$user','$pwd','$nc')");
|
||||
if($row){
|
||||
session_start();/*打开会话,将用户名和昵称存起来*/
|
||||
$_SESSION['username']=$user;
|
||||
$_SESSION['nickname']=$nc;
|
||||
$flag=3;/*注册成功*/
|
||||
}else{
|
||||
$flag=4;/*服务器原因注册失败*/
|
||||
var_dump($row);
|
||||
}
|
||||
}
|
||||
echo $flag;
|
||||
}
|
||||
}
|
104
function/users/regist.php
Normal file
104
function/users/regist.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/*
|
||||
* regist.php(注册):根据设置标志flag的值判断注册的三种状态
|
||||
* flag:【v1.0.2】
|
||||
* 20000 注册成功 √
|
||||
* 20010 验证码输入错误 √
|
||||
* 20011 验证码已经失效 √
|
||||
* 20012 验证码未输入 √
|
||||
* 20020 用户名已存在 √
|
||||
* 20021 用户名未输入 √
|
||||
* 20022 密码未输入 √
|
||||
* 20023 确认密码未输入 √
|
||||
* 20024 两次密码不相同 √
|
||||
* 20025 昵称未输入 √
|
||||
* 20026 用户名太短、太长或含有特殊字符 √
|
||||
* 20027 昵称太短、太长或含有特殊字符 × !!!!!密码特殊字符问题
|
||||
* 20032 已登录其他帐号 √
|
||||
* 20040 系统未知错误 √
|
||||
* 20041 服务器原因注册失败 √
|
||||
* 20050 无效token √
|
||||
*/
|
||||
|
||||
/*开启会话*/
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
// 验证 token
|
||||
$token = isset($_SESSION['register_token']) ? $_SESSION['register_token'] : "";
|
||||
if ($token && $_POST['token'] === $token) {
|
||||
// 删除 token
|
||||
} else {
|
||||
// 记录潜在的 CSRF 攻击.
|
||||
echoflag(20050); // 无效token
|
||||
}
|
||||
|
||||
if(isset($_SESSION['username']) && trim($_SESSION['username']) != ""){ // 用户已经登录
|
||||
echoflag(20032); // 已登录其他帐号
|
||||
}
|
||||
|
||||
// 获取表单提交的数据
|
||||
if(!isset($_POST['username']) || trim($_POST['username']) == "")
|
||||
echoflag(20021); // 用户名未输入
|
||||
elseif(!isset($_POST['password']) || trim($_POST['password']) == "")
|
||||
echoflag(20022); // 密码未输入
|
||||
elseif(!isset($_POST['password_confirm']) || trim($_POST['password_confirm']) == "")
|
||||
echoflag(20023); // 确认密码未输入
|
||||
elseif(!isset($_POST['captcha']) || trim($_POST['captcha']) == "")
|
||||
echoflag(20012); // 验证码未输入
|
||||
if(!isset($_POST['nickname']) || trim($_POST['nickname']) == "")
|
||||
echoflag(20025); // 昵称未输入
|
||||
|
||||
$user = $_POST['username']; /* 用户名 */
|
||||
$pwd = $_POST['password']; /* 密码 */
|
||||
$repwd=$_POST['password_confirm']; /* 确认密码 */
|
||||
$yzm = $_POST['captcha']; /* 验证码 */
|
||||
$nc=$_POST['nickname']; /* 昵称 */
|
||||
|
||||
if($pwd != $repwd)
|
||||
echoflag(20024); // 两次密码不相同
|
||||
|
||||
if(!preg_match("/^[0-9a-zA-Z]{4,21}$/",$user))
|
||||
echoflag(20026); // 用户名太短、太长或含有特殊字符
|
||||
|
||||
|
||||
if(!isset($_SESSION['captcha']))
|
||||
echoflag(20011); // 验证码已经失效
|
||||
elseif($yzm!=$_SESSION['captcha']){
|
||||
echoflag(20010); // 验证码输入错误
|
||||
}else{
|
||||
// 连接MySQL数据库
|
||||
require_once dirname(__DIR__)."/mysql.php";
|
||||
$mysql = new mysql();
|
||||
|
||||
$result = $mysql -> query("select * from `users` where username='$user'");
|
||||
|
||||
// 函数 num_rows() 判断返回的数据。如果查询的结果>0,即用户已经存在
|
||||
if ( (isset($result -> num_rows) && $result -> num_rows > 0) )
|
||||
echoflag(20020); // 用户名已存在
|
||||
else{
|
||||
$result = $mysql -> conn -> query("insert into `users`(`username`, `password`, `nickname`) values('$user','$pwd','$nc')");
|
||||
|
||||
if($result === TRUE){
|
||||
// 将用户名和昵称存起来
|
||||
$_SESSION['username']=$user;
|
||||
$_SESSION['nickname']=$nc;
|
||||
echoflag(20000); // 注册成功
|
||||
}else{
|
||||
echoflag(20041); // 服务器原因注册失败
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 按照正常逻辑不可能走到这一步,走到这一步一定是出鬼了
|
||||
echoflag(20040); // 系统未知错误
|
||||
|
||||
function echoflag($flag) {
|
||||
echo $flag;
|
||||
// token 暂时不清除
|
||||
// if(isset($_SESSION['register_token'])) unset($_SESSION['register_token']); // 清除 register_token
|
||||
if(isset($_SESSION['captcha'])) unset($_SESSION['captcha']); // 清除验证码
|
||||
if(isset($mysql)) unset($mysql); // 关闭数据库连接
|
||||
session_write_close(); // 结束当前session,保存session数据。
|
||||
exit();
|
||||
}
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
10
img/index.html
Normal file
10
img/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
BIN
img/thumbnail.jpg
Normal file
BIN
img/thumbnail.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 113 KiB |
111
index.php
111
index.php
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// 开启GZIP压缩
|
||||
// ************************* 开启GZIP压缩 *************************
|
||||
// 参考:https://blog.csdn.net/weixin_39106791/article/details/88529222
|
||||
if( !headers_sent() && // 如果页面头部信息还没有输出
|
||||
extension_loaded("zlib") && // 而且php已经加载了zlib扩展
|
||||
@@ -8,15 +8,40 @@ strstr($_SERVER["HTTP_ACCEPT_ENCODING"],"gzip")) //而且浏览器接受GZIP
|
||||
ini_set('zlib.output_compression', 'On');
|
||||
ini_set('zlib.output_compression_level', '9'); // 1~9 数字越大压缩越好,所耗服务器性能也越高
|
||||
}
|
||||
else{echo '不支持gzip';}
|
||||
else{ /* echo '不支持gzip'; */ }
|
||||
|
||||
// 隐藏错误提示
|
||||
// require_once "function/hide-error-msg.php";
|
||||
// ************************* 隐藏错误提示 *************************
|
||||
// error_reporting(E_ALL ^ E_NOTICE); // 隐藏Notice提示
|
||||
// error_reporting(E_ALL^E_NOTICE^E_WARNING);
|
||||
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_ERROR ^ E_COMPILE_ERROR); // 隐藏所有提示
|
||||
/*
|
||||
value constant
|
||||
1 E_ERROR
|
||||
2 E_WARNING
|
||||
4 E_PARSE
|
||||
8 E_NOTICE
|
||||
16 E_CORE_ERROR
|
||||
32 E_CORE_WARNING
|
||||
64 E_COMPILE_ERROR
|
||||
128 E_COMPILE_WARNING
|
||||
256 E_USER_ERROR
|
||||
512 E_USER_WARNING
|
||||
1024 E_USER_NOTICE
|
||||
2047 E_ALL
|
||||
2048 E_STRICT
|
||||
|
||||
// 计算统计信息 Begin
|
||||
//禁用错误报告
|
||||
error_reporting(0);
|
||||
//报告运行时错误
|
||||
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
||||
//报告所有错误
|
||||
error_reporting(E_ALL);
|
||||
*/
|
||||
|
||||
// ************************* 计算统计信息 Begin *************************
|
||||
require_once "function/statistics/begin.php";
|
||||
|
||||
// 引入配置文件
|
||||
// ************************* 引入配置文件 *************************
|
||||
$config = require "config.php";
|
||||
|
||||
// 网站标题
|
||||
@@ -28,7 +53,7 @@ $statistical_code = $config["page"]["statistical_code"];
|
||||
// 备案代码
|
||||
$record_code = $config["page"]["record_code"];
|
||||
|
||||
// 获取URL传入参数
|
||||
// ************************* 获取URL传入参数 *************************
|
||||
if(trim($_SERVER["QUERY_STRING"]) != ""){
|
||||
require_once "function/url-query-pause.php";
|
||||
$arr_query = convertUrlQuery($_SERVER["QUERY_STRING"]);
|
||||
@@ -77,18 +102,73 @@ unset($arr_query);
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<?php /* 手机端显示缩放
|
||||
width:可视区域的宽度,值可为数字或关键词device-width
|
||||
height:同width
|
||||
intial-scale:页面首次被显示是可视区域的缩放级别,取值1.0则页面按实际尺寸显示,无任何缩放
|
||||
maximum-scale=1.0, minimum-scale=1.0;可视区域的缩放级别,
|
||||
maximum-scale用户可将页面放大的程序,1.0将禁止用户放大到实际尺寸之上。
|
||||
user-scalable:是否可对页面进行缩放,no 禁止缩放
|
||||
|
||||
|
||||
width 设置layout viewport 的宽度,为一个正整数,或字符串"width-device"
|
||||
initial-scale 设置页面的初始缩放值,为一个数字,可以带小数
|
||||
minimum-scale 允许用户的最小缩放值,为一个数字,可以带小数
|
||||
maximum-scale 允许用户的最大缩放值,为一个数字,可以带小数
|
||||
height 设置layout viewport 的高度,这个属性对我们并不重要,很少使用
|
||||
user-scalable 是否允许用户进行缩放,值为"no"或"yes", no 代表不允许,yes代表允许
|
||||
|
||||
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0">(默认写法,在iOS9中要想起作用,得加上"shrink-to-fit=no")-->
|
||||
*/?>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" />
|
||||
<!-- 当为 always 时,从当前页面跳转到的页面可以通过document.referrer获得当前页面地址,为 never 时则不行 -->
|
||||
<meta name="referrer" content="always">
|
||||
<!-- 默认使用浏览器极速内核(强制Chromium内核,作用于360浏览器、QQ浏览器等国产双核浏览器) -->
|
||||
<meta name="renderer" content="webkit" />
|
||||
<!-- 强制Chromium内核,作用于其他双核浏览器 -->
|
||||
<meta name="force-rendering" content="webkit" />
|
||||
<!-- X-UA-Compatible是IE8的一个专有<meta>属性,它告诉IE8采用何种IE版本去渲染网页。
|
||||
Edge模式通知IE以最高级别的可用模式显示内容,即如果你有IE9的话说明你有IE789,那么就调用高版本的那个 -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<!-- robots用来告诉搜索机器人哪些页面需要索引,哪些页面不需要索引 -->
|
||||
<meta name="robots" content="nofollow">
|
||||
<?php /* 具体参数如下: 默认是all。
|
||||
信息参数为all:文件将被检索,且页面上的链接可以被查询;
|
||||
信息参数为none:文件将不被检索,且页面上的链接不可以被查询;
|
||||
信息参数为index:文件将被检索;
|
||||
信息参数为follow:页面上的链接可以被查询;
|
||||
信息参数为noindex:文件将不被检索,但页面上的链接可以被查询;
|
||||
信息参数为nofollow:文件将被检索,但页面上的链接不可以被查询;
|
||||
*/?>
|
||||
<!-- 网站标题 -->
|
||||
<title><?= $title; ?></title>
|
||||
<!-- 网站logo -->
|
||||
<?php //前者必须,后者可以省略,前者不能使用动态图片,后者可以?>
|
||||
<link rel="shortcut icon" href="<?= $config["page"]["iconpath"]; ?>" />
|
||||
<link rel="icon" href="<?= $config["page"]["iconpath"]; ?>" />
|
||||
<!-- 分享的标题 -->
|
||||
<meta itemprop="name" content="<?= $title; ?>"/>
|
||||
<meta name="shareimage" itemprop="image" content="<?= $config["page"]["iconpath"]; ?>" />
|
||||
<meta name="keywords" content="<?= $config["page"]["keywords"]; ?>" />
|
||||
<meta name="description" itemprop="description" content="<?= $config["page"]["description"]; ?>" />
|
||||
<!-- author 作者 -->
|
||||
<meta name="author" content="<?= $config["page"]["author"]; ?>">
|
||||
<!-- 网站版权信息 -->
|
||||
<meta name="copyright" content="<?= $config["page"]["copyright"]; ?>">
|
||||
<!-- 希望搜索引擎重访的天数 --><?php // 假设revisit-after设置的5天,并不能让搜索引擎每5天来一次访问,搜索引擎只会按照原来比5天更长的间隔时间访问我们的网页 ?>
|
||||
<meta name="revisit-after" content="<?= $config["page"]["revisit_time"]; ?>" >
|
||||
|
||||
<!-- 这个是百度官方给的禁止转码声明。在网页中添加了这一条,百度就不会移动搜索中将网站转码,并呈现给移动端用户 -->
|
||||
<meta http-equiv="Cache-Control" content="no-transform">
|
||||
<!-- 设置这个之后通过手机百度搜索打开网页时,百度会为你的网页进行转码 -->
|
||||
<meta http-equiv="Cache-Control" content="no-siteapp">
|
||||
|
||||
<!-- 将http请求转成https请求:页面所有 HTTP 资源,会被替换为 HTTPS 地址再发起请求;页面所有站内链接,点击后会被替换为 HTTPS 地址再跳转 -->
|
||||
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />
|
||||
|
||||
<!-- MDUI CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/mdui@1.0.0/dist/css/mdui.min.css" integrity="sha384-2PJ2u4NYg6jCNNpv3i1hK9AoAqODy6CdiC+gYiL2DVx+ku5wzJMFNdE3RoWfBIRP" crossorigin="anonymous" />
|
||||
|
||||
<!-- 网站 logo 及标题 -->
|
||||
<link rel="shortcut icon" href="<?= $config["page"]["iconpath"]; ?>" type="image/x-icon">
|
||||
<title><?= $title; ?></title>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
||||
|
||||
@@ -132,6 +212,13 @@ unset($arr_query);
|
||||
-->*/?>
|
||||
<body class="mdui-theme-primary-brown mdui-theme-accent-indigo mdui-appbar-with-toolbar mdui-drawer-body-left"
|
||||
<?=$LimitHotkeyUsage?' topmargin=0 leftmargin=0 scroll=no style="overflow:hidden" oncontextmenu="return false" onpaste="return false" oncopy="return false;" oncut="return false;" onkeydown="return KeyDown()"':"" ?>>
|
||||
|
||||
<!-- 未启用JS时提示 -->
|
||||
<noscript><br /><br /><br /><br /><br /><br />
|
||||
<p style="text-align: center; color: red;">你的浏览器不支持JavaScript!</p>
|
||||
<meta http-equiv="refresh" content="0; url=prompt/noscript.html"/>
|
||||
<br /><br /><br /><br /><br /><br /></noscript>
|
||||
|
||||
<!--加载Cookie中保存的theme-->
|
||||
<script>
|
||||
app.loadTheme();
|
||||
@@ -255,7 +342,7 @@ unset($arr_query);
|
||||
<script src="./js/click2copy.js"></script>
|
||||
|
||||
<?php
|
||||
// 计算统计信息 End
|
||||
// ************************* 计算统计信息 End *************************
|
||||
require_once "function/statistics/end.php";
|
||||
?>
|
||||
</body>
|
||||
|
10
js/index.html
Normal file
10
js/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
78
note____.txt
78
note____.txt
@@ -7,4 +7,80 @@
|
||||
https://foundation.youdao.com/ip/ipinfo
|
||||
|
||||
如果有标DJ的是英式音标,标KK的是美式音标。bai
|
||||
比如你查一个词coat,DJ:du[kəut],KK:[kot]。
|
||||
比如你查一个词coat,DJ:du[kəut],KK:[kot]。
|
||||
|
||||
|
||||
若页面需默认用 极速 速核,增加标签:<meta name="renderer" content="webkit">
|
||||
若页面需默认用ie兼容内核,增加标签:<meta name="renderer" content="ie-comp">
|
||||
若页面需默认用ie标准内核,增加标签:<meta name="renderer" content="ie-stand">
|
||||
|
||||
|
||||
|
||||
HTML5 Boilerplate 使用相对协议请求 Google CDN 中的 jQuery ,使用方式为:
|
||||
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
|
||||
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.4.2.js"%3E%3C/script%3E'))</script>
|
||||
上面的例子中除了引用 Google CDN 中的文件外,还添加了一个本地 jQuery 链接,以便连接 Google CDN 失败后,使用本地副本。
|
||||
|
||||
|
||||
|
||||
分享到QQ的缩略图显示设置:未确认是否有效?
|
||||
<meta itemprop="name" content="0047ol"/>
|
||||
<meta name="shareimage" itemprop="image" content="logo.png" />
|
||||
<meta name="keywords" content="0047ol" />
|
||||
<meta name="description" itemprop="description" content="0047ol" />
|
||||
|
||||
H5手Q分享通用接口代码片段(https://blog.csdn.net/qq_35432904/article/details/81704321)
|
||||
<meta itemprop="name" content="网页标题">
|
||||
<meta itemprop="description" content="网页描述">
|
||||
<meta itemprop="image" content="缩略图">
|
||||
|
||||
|
||||
|
||||
error_reporting(0);//禁用错误报告
|
||||
error_reporting(E_ALL ^ E_NOTICE);//显示除去 E_NOTICE 之外的所有错误信息
|
||||
error_reporting(E_ALL^E_WARNING^E_NOTICE);//显示除去E_WARNING E_NOTICE 之外的所有错误信息
|
||||
error_reporting(E_ERROR | E_WARNING | E_PARSE);//显示运行时错误,与error_reporting(E_ALL ^ E_NOTICE);效果相同。
|
||||
error_reporting(E_ALL);//显示所有错误
|
||||
|
||||
js:
|
||||
// var flags = [
|
||||
// {flag:'1',info:'清香1'},
|
||||
// {flag:'2',info:'清香2'},
|
||||
// {flag:'3',info:'清香3'},
|
||||
// {flag:'4',info:'清香4'},
|
||||
// {flag:'5',info:'清香5'}];
|
||||
// var arr = '4';
|
||||
// flags.map(e=>{ if(arr == e.flag){ console.log(e.info); alert(e.info);} })
|
||||
|
||||
|
||||
|
||||
HTMl中Meta标签 参考:https://www.cnblogs.com/cxzhome/p/8448463.html
|
||||
|
||||
|
||||
详解HTML5中rel属性的prefetch预加载功能使用:https://www.cnblogs.com/suyuwen1/p/5506397.html
|
||||
|
||||
|
||||
header('Content-Type: text/html; charset=utf-8'); //网页编码
|
||||
|
||||
header('Content-Type: text/plain'); //纯文本格式
|
||||
|
||||
header('Content-Type: image/jpeg'); //JPG、JPEG
|
||||
|
||||
header('Content-Type: application/zip'); // ZIP文件
|
||||
|
||||
header('Content-Type: application/pdf'); // PDF文件
|
||||
|
||||
header('Content-Type: audio/mpeg'); // 音频文件
|
||||
|
||||
header('Content-type: text/css'); //css文件
|
||||
|
||||
header('Content-type: text/javascript'); //js文件
|
||||
|
||||
header('Content-type: application/json'); //json
|
||||
|
||||
header('Content-type: application/pdf'); //pdf
|
||||
|
||||
header('Content-type: text/xml'); //xml
|
||||
|
||||
header('Content-Type: application/x-shockw**e-flash'); //Flash动画
|
@@ -14,5 +14,12 @@
|
||||
*/
|
||||
?>
|
||||
<p>本站不支持IE 10 以下版本的浏览器。</p>
|
||||
<p>
|
||||
使用框架:jQuery、MDUI
|
||||
</p>
|
||||
|
||||
<p>
|
||||
更新记录:
|
||||
</p>
|
||||
<?php
|
||||
require_once __DIR__."/component/under-construction.php";
|
10
page/component/index.html
Normal file
10
page/component/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@@ -30,10 +30,9 @@
|
||||
}
|
||||
</style>
|
||||
<div id="construct" style="margin-top:50px;">
|
||||
<h1>您访问的页面不存在!</h1>
|
||||
<h1>404 您访问的页面不存在!</h1>
|
||||
<p style="text-align: center;">
|
||||
尊敬的访客,您好,您访问的<span><?=$page ?></span>功能不存在,请检查网址是否输入正确。<br />
|
||||
感谢您对<span><?=$title ?></span>的支持
|
||||
尊敬的访客,您好,您访问的页面不存在,请检查网址是否输入正确。<br />
|
||||
</p>
|
||||
<div class="notice-foot">
|
||||
<p><?=$title ?></p>
|
||||
|
10
page/index.html
Normal file
10
page/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
653
page/login.php
653
page/login.php
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* 页面: 登录
|
||||
* 版本号: 1.0.0
|
||||
* 修改时间: 2020.08.15
|
||||
* 修改时间: 2020.08.22
|
||||
* 备注: 不可上线,需要完善
|
||||
*
|
||||
* 调用前需要的变量:
|
||||
@@ -15,99 +15,566 @@
|
||||
?>
|
||||
|
||||
<?php
|
||||
if((!isset($action) || !$action || trim($action) == "")/* $action不存在 */ || ($action!="login" && $action!="register")/* $action为其他值 */){
|
||||
$action = "login";
|
||||
}
|
||||
// 生成token
|
||||
session_start();
|
||||
$TokenNames = array("login_token", "register_token", "findpwd_token");
|
||||
foreach($TokenNames as $TokenName) {
|
||||
${$TokenName} = isset($_SESSION[$TokenName]) ? $_SESSION[$TokenName] : "";
|
||||
if (!${$TokenName}) {
|
||||
// 生成 token 令牌,等待稍后的验证
|
||||
// - 在正式使用中用 openssl_random_pseudo_bytes() 代替 uniqid()
|
||||
// generate token and persist for later verification
|
||||
// - in practice use openssl_random_pseudo_bytes() or similar instead of uniqid()
|
||||
${$TokenName} = md5(uniqid());
|
||||
$_SESSION[$TokenName]= ${$TokenName};
|
||||
}
|
||||
}
|
||||
session_write_close();
|
||||
?>
|
||||
<div class="mdui-container">
|
||||
<main>
|
||||
<div class="mdui-row">
|
||||
<?php if ($action != "register") {
|
||||
?>
|
||||
<div class="login-container">
|
||||
<div class="panel mdui-col-sm-6 mdui-col-md-6 mdui-col-offset-sm-3 mdui-col-offset-md-3">
|
||||
<div class="panel-header">
|
||||
登录账号
|
||||
</div>
|
||||
<div class="panel-body-box">
|
||||
<form action="" method="post">
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">账号</label>
|
||||
<input class="mdui-textfield-input" type="text" name="account" value="" autocomplete="off">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">密码</label>
|
||||
<input class="mdui-textfield-input" type="password" name="password" value="">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<button class="mdui-btn mdui-btn-block mdui-color-theme-accent mdui-ripple">登录</button>
|
||||
</div>
|
||||
<!--<input type="hidden" name="__token__" value="3bd2b7c4fea946b5e9408bc3bca25357">-->
|
||||
</form>
|
||||
<p class="mdui-clearfix mdui-m-t-1">
|
||||
<a class="mdui-float-left" href="">忘记密码?</a>
|
||||
<a class="mdui-float-right" href="./?page=<?=$page ?>&action=register">注册账号</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<div class="register-container">
|
||||
<div class="panel mdui-col-sm-6 mdui-col-md-6 mdui-col-offset-sm-3 mdui-col-offset-md-3">
|
||||
<div class="panel-header">
|
||||
注册账号
|
||||
</div>
|
||||
<div class="panel-body-box">
|
||||
<form action="/auth/register.html" method="post">
|
||||
<div class="mdui-textfield mdui-textfield-floating-label mdui-textfield-has-bottom">
|
||||
<label class="mdui-textfield-label">用户名</label>
|
||||
<input class="mdui-textfield-input" type="text" name="username" maxlength="15" value="">
|
||||
<div class="mdui-textfield-counter">
|
||||
<span class="mdui-textfield-counter-inputed">0</span> / 15
|
||||
</div>
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">邮箱</label>
|
||||
<input class="mdui-textfield-input" type="email" name="email" value="">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">密码</label>
|
||||
<input class="mdui-textfield-input" type="password" name="password" value="">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">确认密码</label>
|
||||
<input class="mdui-textfield-input" type="password" name="password_confirm">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label mdui-textfield-has-bottom">
|
||||
<label class="mdui-textfield-label">验证码</label>
|
||||
<input class="mdui-textfield-input" type="text" name="captcha" maxlength="5" autocomplete="off">
|
||||
<img src="/captcha.html" class="captcha" onclick="this.src = '/captcha.html' + '?t=' + new Date().getTime()" alt="验证码">
|
||||
<div class="mdui-textfield-counter">
|
||||
<span class="mdui-textfield-counter-inputed">0</span> / 5
|
||||
</div>
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<button class="mdui-btn mdui-btn-block mdui-color-theme-accent mdui-ripple">注册</button>
|
||||
</div>
|
||||
<!--<input type="hidden" name="__token__" value="487336ea0f2102a7d533b6d061689d92">-->
|
||||
</form>
|
||||
<p class="mdui-clearfix mdui-m-t-1">
|
||||
已有账号?<a href="./?page=<?=$page ?>&action=login">登录</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
// 判断是哪个panel
|
||||
if((!isset($action) || !$action || trim($action) == "")){/* $action不存在 */
|
||||
$action = "login";
|
||||
} else {
|
||||
// 不在这里判断,用JS判断。JS实现:如果$action为其他值,跳转到login
|
||||
switch ($action) {
|
||||
case 'login':
|
||||
case 'register':
|
||||
case 'findpwd':
|
||||
break;
|
||||
|
||||
default:/* $action为其他值 */
|
||||
// $action = "login";
|
||||
echo '<script>window.location = "?page=login";</script>';
|
||||
echo '</body</html>';
|
||||
exit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 定义验证码URL
|
||||
$verifycode_path = "./function/captcha.php?t=";
|
||||
|
||||
// PHP部分结束,开始HTML部分
|
||||
?>
|
||||
|
||||
<!-- 动画 -->
|
||||
<style>
|
||||
/* panel淡入动画 开始 */
|
||||
@keyframes fade-in {
|
||||
0% {opacity: 0;}/*初始状态 透明度为0*/
|
||||
40% {opacity: 0;}/*过渡状态 透明度为0*/
|
||||
100% {opacity: 1;}/*结束状态 透明度为1*/
|
||||
}
|
||||
@-webkit-keyframes fade-in {/*针对webkit内核*/
|
||||
0% {opacity: 0;}
|
||||
40% {opacity: 0;}
|
||||
100% {opacity: 1;}
|
||||
}
|
||||
#tab {
|
||||
animation: fade-in;/*动画名称*/
|
||||
animation-duration: 0.5s;/*动画持续时间*/
|
||||
-webkit-animation:fade-in 0.5s;/*针对webkit内核*/
|
||||
}
|
||||
/* panel淡入动画 结束 */
|
||||
</style>
|
||||
|
||||
<!-- 样式 -->
|
||||
<style>
|
||||
/* panel样式 开始 */
|
||||
.panel-container {
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 2rem;
|
||||
|
||||
float: none;
|
||||
|
||||
text-align: center;
|
||||
}
|
||||
.panel {
|
||||
box-shadow: 0 0 50px 0 rgba(0, 0, 0, 0.13);
|
||||
border-radius: 0.5rem;
|
||||
|
||||
display: inline-block;
|
||||
width: 80%;
|
||||
min-width: 250px;
|
||||
text-align: left;
|
||||
}
|
||||
.panel-box {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
.panel-box-header {
|
||||
padding: 1rem;
|
||||
}
|
||||
.panel-box-body {
|
||||
padding: 0.5rem;
|
||||
border-top: 1px solid #f1f1f1;
|
||||
}
|
||||
/* panel样式 结束 */
|
||||
|
||||
/* 验证码 样式 开始 */
|
||||
.mdui-textfield .captcha {
|
||||
position: absolute;
|
||||
top: 34px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 140px;
|
||||
cursor: pointer;
|
||||
}
|
||||
/* 验证码 样式 结束 */
|
||||
|
||||
/* 获取邮箱验证码 样式 开始 */
|
||||
.mdui-textfield .get-vercode-btn {
|
||||
position: absolute;
|
||||
top: 34px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 140px;
|
||||
height: 35px;
|
||||
cursor: pointer;
|
||||
}
|
||||
/* 获取邮箱验证码 样式 结束 */
|
||||
</style>
|
||||
|
||||
<div id="loginpanel-tab" class="mdui-tab mdui-tab-centered mdui-color-theme-300" mdui-tab>
|
||||
<a id="tablogin" href="#login-tab" onclick="switchPanel('login');" class="mdui-ripple <?=$action=="login"?'mdui-tab-active':''?>"><i class="mdui-icon material-icons">fingerprint</i>登录</a>
|
||||
<a id="tabregister" href="#register-tab" onclick="switchPanel('register');" class="mdui-ripple <?=$action=="register"?'mdui-tab-active':''?>"><i class="mdui-icon material-icons">group_add</i>注册</a>
|
||||
<a id="tabfindpwd" href="#findpwd-tab" onclick="switchPanel('findpwd');" class="mdui-ripple <?=$action=="findpwd"?'mdui-tab-active':''?>"><i class="mdui-icon material-icons">cached</i>找回密码</a>
|
||||
|
||||
|
||||
<button onclick="debugmode();">测试用 填验证码</button>
|
||||
</div>
|
||||
|
||||
<span id="user-name">加载中...</span>
|
||||
<button id="logout_btn" class="mdui-btn mdui-ripple mdui-hidden mdui-color-theme-accent">退出登录</button>
|
||||
<div id="tab">
|
||||
<!-- 登录 -->
|
||||
<div id="login-tab" class="panel-container mdui-col-sm-6 mdui-col-offset-sm-3 mdui-col-md-6 mdui-col-offset-md-3">
|
||||
<div class="panel">
|
||||
<div class="panel-box">
|
||||
<div class="panel-box-header">
|
||||
登录
|
||||
</div>
|
||||
<div class="panel-box-body">
|
||||
<form id="form_login" ><!-- action="" method="post" -->
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">用户名</label>
|
||||
<input id="login_username" class="mdui-textfield-input" type="text" name="username" value="" autocomplete="off">
|
||||
<!-- oninput="document.getElementById('register_username').value=this.value;" -->
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">密码</label>
|
||||
<input id="login_password" class="mdui-textfield-input" type="password" name="password" value="" autocomplete="off">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label mdui-textfield-has-bottom">
|
||||
<label class="mdui-textfield-label">验证码</label>
|
||||
<input id="login_captcha" class="mdui-textfield-input" type="text" name="captcha" maxlength="5" autocomplete="off">
|
||||
<img id="login_vercodeimg" src="<?=$verifycode_path.time()?>" class="captcha" onclick="refresh_verify_code('login')" alt="验证码">
|
||||
<div class="mdui-textfield-counter"><span class="mdui-textfield-counter-inputed">0</span> / 5</div>
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<button class="mdui-btn mdui-btn-block mdui-color-theme-accent mdui-ripple">登录</button>
|
||||
</div>
|
||||
<input type="hidden" name="token" value="<?php echo $login_token; ?>">
|
||||
</form>
|
||||
<p class="mdui-clearfix mdui-m-t-1">
|
||||
<a class="mdui-float-left" href="javascript: clickElement('tabregister')">注册账号</a>
|
||||
<a class="mdui-float-right" href="javascript: clickElement('tabfindpwd')">忘记密码?</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 注册 -->
|
||||
<div id="register-tab" class="panel-container mdui-col-sm-6 mdui-col-offset-sm-3 mdui-col-md-6 mdui-col-offset-md-3">
|
||||
<div class="panel">
|
||||
<div class="panel-box">
|
||||
<div class="panel-box-header">
|
||||
注册
|
||||
</div>
|
||||
<div class="panel-box-body">
|
||||
<form id="form_register"><!-- action="" method="post" -->
|
||||
<div class="mdui-textfield mdui-textfield-floating-label mdui-textfield-has-bottom">
|
||||
<label class="mdui-textfield-label">用户名</label>
|
||||
<input id="register_username" class="mdui-textfield-input" type="text" name="username" maxlength="15" value="" autocomplete="off">
|
||||
<div class="mdui-textfield-counter"><span class="mdui-textfield-counter-inputed">0</span> / 15</div>
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label mdui-textfield-has-bottom">
|
||||
<label class="mdui-textfield-label">昵称</label>
|
||||
<input id="register_nickname" class="mdui-textfield-input" type="text" name="nickname" maxlength="10" value="" autocomplete="off">
|
||||
<div class="mdui-textfield-counter"><span class="mdui-textfield-counter-inputed">0</span> / 10</div>
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">邮箱(暂时还不用输入)</label>
|
||||
<input class="mdui-textfield-input" type="email" name="email" value="" autocomplete="off">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">密码</label>
|
||||
<input id="register_password" class="mdui-textfield-input" type="password" name="password" value="" autocomplete="off">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">确认密码</label>
|
||||
<input id="register_password_confirm" class="mdui-textfield-input" type="password" name="password_confirm" autocomplete="off">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label mdui-textfield-has-bottom">
|
||||
<label class="mdui-textfield-label">验证码</label>
|
||||
<input id="register_captcha" class="mdui-textfield-input" type="text" name="captcha" maxlength="5" autocomplete="off">
|
||||
<img id="register_vercodeimg" src="<?=$verifycode_path.time()?>" class="captcha" onclick="refresh_verify_code('register')" alt="验证码">
|
||||
<div class="mdui-textfield-counter"><span class="mdui-textfield-counter-inputed">0</span> / 5</div>
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<button class="mdui-btn mdui-btn-block mdui-color-theme-accent mdui-ripple">注册</button>
|
||||
</div>
|
||||
<input type="hidden" name="token" value="<?php echo $register_token; ?>">
|
||||
</form>
|
||||
<p class="mdui-clearfix mdui-m-t-1">
|
||||
已有账号?<a href="javascript: clickElement('tablogin')">去登录</a>
|
||||
<a class="mdui-float-right" href="javascript: clickElement('tabfindpwd')">忘记密码?</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 找回密码 -->
|
||||
<div id="findpwd-tab" class="panel-container mdui-col-sm-6 mdui-col-offset-sm-3 mdui-col-md-6 mdui-col-offset-md-3">
|
||||
<div class="panel">
|
||||
<div class="panel-box">
|
||||
<div class="panel-box-header">
|
||||
找回密码
|
||||
</div>
|
||||
<div class="panel-box-body">
|
||||
<form id="form_findpwd" ><!-- action="" method="post" -->
|
||||
<!--<form action="/auth/register.html" method="post">-->
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">请输入您的用户名</label>
|
||||
<input class="mdui-textfield-input" type="text" id="findpwd_username" name="username" maxlength="15" value="" autocomplete="off">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">请输入您注册时填写的邮箱</label>
|
||||
<input class="mdui-textfield-input" type="email" name="email" value="" autocomplete="off">
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<label class="mdui-textfield-label">邮箱验证码</label>
|
||||
<input class="mdui-textfield-input" type="text" name="email-vercode" value="" autocomplete="off">
|
||||
<button class="mdui-btn mdui-btn-raised get-vercode-btn">获取邮箱验证码</button>
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label mdui-textfield-has-bottom">
|
||||
<label class="mdui-textfield-label">验证码</label>
|
||||
<input id="findpwd_captcha" class="mdui-textfield-input" type="text" name="captcha" maxlength="5" autocomplete="off">
|
||||
<img id="findpwd_vercodeimg" src="<?=$verifycode_path.time()?>" class="captcha" onclick="refresh_verify_code('findpwd')" alt="验证码">
|
||||
<div class="mdui-textfield-counter"><span class="mdui-textfield-counter-inputed">0</span> / 5</div>
|
||||
</div>
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<button class="mdui-btn mdui-btn-block mdui-color-theme-accent mdui-ripple">点击验证</button>
|
||||
</div>
|
||||
<input type="hidden" name="token" value="<?php echo $findpwd_token; ?>">
|
||||
</form>
|
||||
<p class="mdui-clearfix mdui-m-t-1">
|
||||
<a class="mdui-float-left" href="javascript: clickElement('tablogin')">去登录</a>
|
||||
<a class="mdui-float-right" href="javascript: clickElement('tabregister')">注册账号</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 切换panel
|
||||
function switchPanel(action) {
|
||||
$('body,html').animate({scrollTop:0},300);
|
||||
|
||||
// 不刷新替换网页URL
|
||||
if ('pushState' in history) {
|
||||
var txt ="?page=login&action=" + action;
|
||||
var stateObject = {id: txt};
|
||||
var title = "标题 "+txt;
|
||||
var newUrl = txt;
|
||||
history.pushState(stateObject,title,newUrl);
|
||||
}
|
||||
|
||||
// 刷新验证码
|
||||
refresh_verify_code(action);
|
||||
|
||||
// 同步注册、登录、找回密码 面板的用户名
|
||||
const login_username = document.getElementById('login_username');
|
||||
const register_username = document.getElementById('register_username');
|
||||
const findpwd_username = document.getElementById('findpwd_username');
|
||||
switch(action){
|
||||
case "login":
|
||||
if(register_username.value.trim() != "")
|
||||
login_username.value=register_username.value;
|
||||
setTimeout(function(){ login_username.focus(); }, 0);
|
||||
break;
|
||||
case "register":
|
||||
if(login_username.value.trim() != "" && login_username.value.length <= 15)
|
||||
register_username.value=login_username.value;
|
||||
else
|
||||
register_username.value="";
|
||||
setTimeout(function(){ register_username.focus(); }, 0);
|
||||
break;
|
||||
case "findpwd":
|
||||
if(login_username.value.trim() != "")
|
||||
findpwd_username.value=login_username.value;
|
||||
else
|
||||
findpwd_username.value=register_username.value;
|
||||
setTimeout(function(){ findpwd_username.focus(); }, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 点击 或 切换panel 时获取新验证码
|
||||
const login_vercodeimg = document.getElementById('login_vercodeimg');
|
||||
const register_vercodeimg = document.getElementById('register_vercodeimg');
|
||||
const findpwd_vercodeimg = document.getElementById('findpwd_vercodeimg');
|
||||
const login_captcha = document.getElementById('login_captcha');
|
||||
const register_captcha = document.getElementById('register_captcha');
|
||||
const findpwd_captcha = document.getElementById('findpwd_captcha');
|
||||
function refresh_verify_code(action) {
|
||||
var vercodeimg_url = "<?=$verifycode_path?>" + Math.round(new Date().getTime() / 1000);
|
||||
switch(action){
|
||||
case "login":
|
||||
login_vercodeimg.src = vercodeimg_url;
|
||||
login_captcha.value="";
|
||||
break;
|
||||
case "register":
|
||||
register_vercodeimg.src = vercodeimg_url;
|
||||
register_captcha.value="";
|
||||
break;
|
||||
case "findpwd":
|
||||
findpwd_vercodeimg.src = vercodeimg_url;
|
||||
findpwd_captcha.value="";
|
||||
break;
|
||||
}
|
||||
setTimeout(debugmode(), 1500);// 测试用,正式发布请删除
|
||||
}
|
||||
|
||||
|
||||
// 模拟点击元素
|
||||
function clickElement(ElementId) {
|
||||
var e = document.createEvent("MouseEvents");
|
||||
e.initEvent("click", true, true);
|
||||
document.getElementById(ElementId).dispatchEvent(e); //只要id 就好
|
||||
}
|
||||
|
||||
|
||||
// 获取用户登录信息
|
||||
function toggle(){
|
||||
$.getJSON("function/users/get-status.php",function (res) {
|
||||
//获取当前用户是否登录
|
||||
if(res['flag']){//用户已经登录,显示昵称和注销选项
|
||||
// $('li.toggle').toggleClass('hidden');
|
||||
$('#user-name').html("欢迎您," + res['nickname'] + "!")
|
||||
if($('#logout_btn').hasClass('mdui-hidden'))
|
||||
$('#logout_btn').removeClass('mdui-hidden');
|
||||
}else{
|
||||
$('#user-name').html("还未登陆")
|
||||
if(!$('#logout_btn').hasClass('mdui-hidden'))
|
||||
$('#logout_btn').addClass('mdui-hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
// 页面加载时就需要获取用户登录信息
|
||||
toggle();
|
||||
|
||||
|
||||
// 先加载好flag对应的info
|
||||
var flags = "网页还在加载中哦,客官请别急";// "网络连接失败,请刷新页面后再试";
|
||||
var flagsIsLoaded = false;
|
||||
$.getJSON('function/users/flag-json.php',function (res) { flags = res; flagsIsLoaded = true; }); // 需要等待json加载完后才可以用
|
||||
function getflag(flag){
|
||||
if(flagsIsLoaded)
|
||||
return flags[flag];
|
||||
else
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
||||
$('#form_login').submit(function (e) {/*登录*/
|
||||
e.preventDefault();/*阻止表单默认事件,页面全局刷新*/
|
||||
var data=$('#form_login').serialize();/*将表单里的数据包装起来*/
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'function/users/login.php',
|
||||
data: data, //可选参数
|
||||
dataType: "json",
|
||||
success: function (res) { //可选参数
|
||||
if(res){
|
||||
// flag版本:1.0.2
|
||||
switch(res){
|
||||
case 10000: // 登录成功
|
||||
toggle();/*修改首页选项菜单*/
|
||||
break;
|
||||
case 10010: // 验证码输入错误
|
||||
alert(getflag(res));
|
||||
refresh_verify_code('register');
|
||||
break;
|
||||
case 10011: // 验证码已经失效
|
||||
alert(getflag(res));
|
||||
refresh_verify_code('register');
|
||||
break;
|
||||
case 10012: // 验证码未输入
|
||||
alert(getflag(res));
|
||||
break;
|
||||
case 10020: // 用户名或密码错误
|
||||
alert(getflag(res));
|
||||
refresh_verify_code('login');
|
||||
break;
|
||||
case 10021: // 用户名未输入
|
||||
alert(getflag(res));
|
||||
break;
|
||||
case 10022: // 密码未输入
|
||||
alert(getflag(res));
|
||||
break;
|
||||
case 10030: // 已登录帐号,但未确定是否为当前帐号
|
||||
alert(getflag(res));
|
||||
break;
|
||||
case 10031: // 已登录当前帐号
|
||||
alert(getflag(res));
|
||||
break;
|
||||
case 10032: // 已登录其他帐号
|
||||
alert(getflag(res));
|
||||
break;
|
||||
case 10040: // 系统未知错误
|
||||
alert(getflag(res));
|
||||
break;
|
||||
case 10041: // 服务器原因登录失败
|
||||
alert(getflag(res));
|
||||
break;
|
||||
case 10050: // 无效token
|
||||
alert(getflag(res));
|
||||
break;
|
||||
}
|
||||
}
|
||||
refresh_verify_code('login');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#form_register').submit(function (e) {
|
||||
e.preventDefault();
|
||||
var data=$('#form_register').serialize();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'function/users/regist.php',
|
||||
data: data, //可选参数
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
if(res){
|
||||
// flag版本:1.0.1
|
||||
alert(getflag(res));
|
||||
switch(res){
|
||||
case 20000: // 注册成功
|
||||
toggle();
|
||||
break;
|
||||
case 20010: // 验证码输入错误
|
||||
refresh_verify_code('register');
|
||||
break;
|
||||
case 20011: // 验证码已经失效
|
||||
refresh_verify_code('register');
|
||||
break;
|
||||
// case 20012: // 验证码未输入
|
||||
// break;
|
||||
// case 20020: // 用户名已存在
|
||||
// break;
|
||||
// case 20021: // 用户名未输入
|
||||
// break;
|
||||
// case 20022: // 密码未输入
|
||||
// break;
|
||||
// case 20023: // 确认密码未输入
|
||||
// break;
|
||||
// case 20024: // 两次密码不相同
|
||||
// break;
|
||||
// case 20025: // 昵称未输入
|
||||
// break;
|
||||
// case 20026: // 用户名太短、太长或含有特殊字符
|
||||
// break;
|
||||
// case 20032: // 已登录其他帐号
|
||||
// break;
|
||||
// case 20040: // 系统未知错误
|
||||
// break;
|
||||
// case 20041: // 服务器原因注册失败
|
||||
// break;
|
||||
// case 20050: // 无效token
|
||||
// break;
|
||||
}
|
||||
}
|
||||
refresh_verify_code('login');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// 退出登录 按钮点击事件
|
||||
$('#logout_btn').click(function () {
|
||||
if(confirm('确定要退出登陆吗?')) {
|
||||
$.getJSON('function/users/logout.php',function (res) {
|
||||
if(res){
|
||||
location.reload();
|
||||
// toggle();
|
||||
}else{
|
||||
// alert("系统错误,退出失败!");
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 填写测试用账号,自动填写验证码
|
||||
function debugmode(){
|
||||
// 登陆部分测试
|
||||
document.getElementById('login_username').value = "111111";
|
||||
document.getElementById('login_password').value = "111111";
|
||||
|
||||
// 注册部分测试
|
||||
document.getElementById('register_username').value = "666666";
|
||||
document.getElementById('register_nickname').value = "六个六";
|
||||
document.getElementById('register_password').value = "666666";
|
||||
document.getElementById('register_password').value = "666666";
|
||||
document.getElementById('register_password_confirm').value = "666666";
|
||||
|
||||
// 填写验证码部分
|
||||
$.getJSON('function/get-captcha-code-test-only.php',function (res) {
|
||||
login_captcha.value = register_captcha.value = findpwd_captcha.value = res;
|
||||
login_captcha.focus(); register_captcha.focus(); findpwd_captcha.focus();
|
||||
window.getSelection().empty();
|
||||
});
|
||||
}
|
||||
// 页面一打开就自动填写验证码
|
||||
$(debugmode());
|
||||
</script>
|
||||
|
||||
<!--<button id="btnshowdialog">弹出对话框测试</button>-->
|
||||
<!-- 提示对话框 -->
|
||||
<div id="dialog" class="mdui-dialog">
|
||||
<div class="mdui-dialog-title">提示</div>
|
||||
<div class="mdui-dialog-content"><span id="alertText"></span></div>
|
||||
<div class="mdui-dialog-actions">
|
||||
<button class="mdui-btn mdui-ripple" mdui-dialog-cancel>确认</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
// 窗体加载完成后事件
|
||||
|
||||
// 对话框
|
||||
var dialog = new mdui.Dialog('#dialog');
|
||||
// document.getElementById('btnshowdialog').addEventListener('click', function () {
|
||||
// showmsg("msg");
|
||||
// });
|
||||
function showmsg(msg){
|
||||
document.getElementById('alertText').innerHTML = msg;
|
||||
dialog.handleUpdate();
|
||||
dialog.open();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
// 建设中
|
||||
require_once __DIR__. "/component/under-construction.php";
|
||||
?>
|
||||
<!-- 样式 -->
|
||||
<link rel="stylesheet" href="css/page_login.css">
|
||||
require_once __DIR__. "/component/under-construction.php";
|
@@ -18,7 +18,7 @@
|
||||
// echo $book;
|
||||
?>
|
||||
<div class="mdui-appbar">
|
||||
<div class="mdui-tab mdui-tab-full-width mdui-color-theme" mdui-tab>
|
||||
<div class="mdui-tab mdui-tab-full-width mdui-color-theme-400" mdui-tab>
|
||||
<?php $_book = "oxford"; $_bookname = "牛津词典"; ?>
|
||||
<a href="#"
|
||||
<?=$book!=$_book?'onclick="window.location.href=\'./?page=' . $page . '&book=' . $_book . '\'"':""?>
|
||||
|
107
prompt/404.php
Normal file
107
prompt/404.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
// php的版本没什么限制
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header("status: 404 Not Found");
|
||||
|
||||
// php版本大于5.4可以使用
|
||||
// http_response_code(404);
|
||||
|
||||
$config = require "../config.php";
|
||||
|
||||
$jump_to = $config['page']['homepage']; // 跳转的首页地址
|
||||
$title = $config['page']['title'];
|
||||
?>
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=0.8" /><!-- 手机端适当缩小 -->
|
||||
<title>出错啦 - <?=$title?></title>
|
||||
<style>
|
||||
body{
|
||||
margin: 0;
|
||||
}
|
||||
#q{
|
||||
font-size: 3rem;
|
||||
line-height: 3rem;
|
||||
text-align: center;
|
||||
}
|
||||
#e{
|
||||
border: 2px solid #333333;
|
||||
margin: 80px;
|
||||
padding: 6px;
|
||||
background: #f8f8f8;
|
||||
text-align: center;
|
||||
font-size: 1.3rem;
|
||||
/*min-width: 200px;*/
|
||||
}
|
||||
#footer{
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<br/>
|
||||
<p id="q">出错啦</p>
|
||||
<p id="e">
|
||||
<br/>
|
||||
错误信息:<span id="i">网页未找到(404)</span>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<a href="javascript:history.go(-1)">👈返回</a> |
|
||||
<a href="<?=$jump_to?>">回首页</a><span id="adCountDownDIv" style="display: none;">(<font id="id8" size="7">5</font>秒后跳转)</span>
|
||||
<br/>
|
||||
</p>
|
||||
<hr />
|
||||
<p id="footer"><?=$title?></p>
|
||||
|
||||
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script>
|
||||
var time = 4;
|
||||
var timer;
|
||||
timer = setInterval('tiaozhuan()', 1000);
|
||||
if (typeof jQuery != 'undefined') {
|
||||
// jQuery 已加载
|
||||
$("#adCountDownDIv").fadeIn(800);
|
||||
} else {
|
||||
// jQuery 未加载
|
||||
document.getElementById("adCountDownDIv").style.display = 'inline-block';
|
||||
}
|
||||
|
||||
function tiaozhuan() {
|
||||
var t = document.getElementById("id8");
|
||||
if(t==null)
|
||||
return; // 出错
|
||||
if (time > 0) {
|
||||
t.innerHTML = time;
|
||||
time--;
|
||||
} else if(time == 0) {
|
||||
clearInterval(timer);
|
||||
location.href = "<?=$jump_to?>";
|
||||
}
|
||||
}
|
||||
|
||||
<?php // php 这样注释不会显示出去
|
||||
// function 获取网址参数(参数) {
|
||||
// // return new URL(window.location.href).searchParams.get(参数)
|
||||
// return new URL(window.location.href + "?<?php echo $_SERVER["QUERY_STRING"]?【!!】>").searchParams.get(参数)
|
||||
// }
|
||||
|
||||
// var Errcode=获取网址参数('i');
|
||||
// if(Errcode=='403')
|
||||
// document.getElementById("i").innerHTML = '禁止访问(403)';
|
||||
// else if(Errcode=='404')
|
||||
// document.getElementById("i").innerHTML = '网页未找到(404)';
|
||||
// else if(Errcode=='500')
|
||||
// document.getElementById("i").innerHTML = '内部错误(500)';
|
||||
// else if(Errcode=='503')
|
||||
// document.getElementById("i").innerHTML = '服务不可用(503)';
|
||||
// else if(Errcode=='未知')
|
||||
// document.getElementById("i").innerHTML = '未知';
|
||||
// else
|
||||
// document.getElementById("i").innerHTML = '暂无错误信息';
|
||||
// //$('#声明文字').style.display = 'block'
|
||||
?>
|
||||
</script>
|
||||
</body></html>
|
10
prompt/index.html
Normal file
10
prompt/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
54
prompt/noscript.html
Normal file
54
prompt/noscript.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" />
|
||||
<title>您的浏览器不支持JavaScript</title>
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/mdui@1.0.0/dist/css/mdui.min.css"
|
||||
integrity="sha384-2PJ2u4NYg6jCNNpv3i1hK9AoAqODy6CdiC+gYiL2DVx+ku5wzJMFNdE3RoWfBIRP"
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
try {
|
||||
window.location = "../index.php"; // 适用于极速内核
|
||||
}catch(error){
|
||||
try {
|
||||
window.location.href = "../index.php";
|
||||
}catch(error){
|
||||
window.open('../index.php'); // 适用于IE内核,但是极速内核可能会拦截
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- 未启用JS时提示 -->
|
||||
<br /><br /><br /><br /><br /><br />
|
||||
<noscript>
|
||||
<!--<i class="mdui-icon material-icons">error_outline</i>-->
|
||||
|
||||
<p style="text-align: center; color: red;">
|
||||
<i class="mdui-icon material-icons" style="font-size: 150px;"></i>
|
||||
</p>
|
||||
<p style="text-align: center; color: red;">你的浏览器不支持JavaScript!<br />Your browser does not support JavaScript!</p>
|
||||
<br />
|
||||
<div style="text-align: center;">
|
||||
<div style="display: block; margin:0 auto; padding: 0 1rem; border:1px solid #000; width: 50%; min-width: 300px;">
|
||||
<p style="text-align: left;">
|
||||
【可能的原因】<br />
|
||||
1. 您关闭了浏览器的JavaScript权限。<br />
|
||||
解决方法:请尝试打开浏览器高级设置中的JavaScript权限。<br />
|
||||
<br />
|
||||
2. 您的浏览器版本太旧,无法打开本站。<br />
|
||||
解决方法:请安装Chrome或者Firefox内核新版浏览器,不要使用IE内核浏览器。<br />
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</noscript>
|
||||
<br /><br /><br /><br /><br /><br />
|
||||
</body>
|
||||
</html>
|
@@ -146,7 +146,7 @@
|
||||
【郑重声明】版权所有,违者必究!
|
||||
在未经原作者授权的情况下,不得去除或修改此处版权信息,或者使用CSS样式使得版权信息字体变小、变浅、改变不易分辨的字体等。
|
||||
-->
|
||||
<p style="margin-bottom: 5px;"><a href="<?=$homepage ?>"><?=$title ?></a> | Powerd by <a href="https://only4.work/" target="_blank" rel="nofollow">张小弟之家</a> © 2019 - <?=date("Y")?> · All Rights Reserved.</p>
|
||||
<p style="margin-bottom: 5px;"><a href="<?=$homepage ?>"><?=$title ?></a> | Powerd by <a href="https://only4.work/" target="_blank" rel="nofollow">张小弟之家</a> © 2019 - <?=date("Y")?> · 保留所有权利 · All Rights Reserved.</p>
|
||||
<p style="margin-top: 5px; margin-bottom: 5px;"><?= $record_code // 备案代码 ?></p>
|
||||
<?= $statistical_code // 统计代码 ?>
|
||||
</div>
|
||||
|
10
public/index.html
Normal file
10
public/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@@ -37,8 +37,9 @@ $homeurl="./?page=";
|
||||
|
||||
<?php $PageName="login"; ?>
|
||||
<?=$page==$PageName?'<li ':'<a href="'.$homeurl.$PageName.'" ' ?>class="mdui-list-item mdui-ripple<?php echo $page==$PageName?$cls:""; ?>">
|
||||
<i class="mdui-list-item-icon mdui-icon material-icons">input</i>
|
||||
<div class="mdui-list-item-content">登录</div>
|
||||
<!--<i class="mdui-list-item-icon mdui-icon material-icons">input</i>-->
|
||||
<i class="mdui-list-item-icon mdui-icon material-icons">fingerprint</i>
|
||||
<div class="mdui-list-item-content">登录 / 注册</div>
|
||||
</<?=$page==$PageName?'li':'a' ?>>
|
||||
|
||||
<?php $PageName="upload-wordbook"; ?>
|
||||
@@ -85,6 +86,13 @@ $homeurl="./?page=";
|
||||
<div class="mdui-list-item-content">个人中心</div>
|
||||
</<?=$page==$PageName?'li':'a' ?>>
|
||||
|
||||
<?php $PageName="logout"; ?>
|
||||
<?=$page==$PageName?'<li ':'<a href="'.$homeurl.$PageName.'" ' ?>class="mdui-list-item mdui-ripple<?php echo $page==$PageName?$cls:""; ?>">
|
||||
<!--<i class="mdui-list-item-icon mdui-icon material-icons">input</i>-->
|
||||
<i class="mdui-list-item-icon mdui-icon material-icons">exit_to_app</i>
|
||||
<div class="mdui-list-item-content">退出登录</div>
|
||||
</<?=$page==$PageName?'li':'a' ?>>
|
||||
|
||||
|
||||
<li class="mdui-subheader">设置 更多</li>
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<!--顶部菜单栏-->
|
||||
<div class="mdui-appbar mdui-appbar-fixed mdui-shadow-6">
|
||||
<div class="mdui-appbar mdui-appbar-fixed mdui-shadow-6 mdui-appbar-scroll-hide">
|
||||
<div class="mdui-toolbar mdui-color-theme">
|
||||
<a href="javascript:;" class="mdui-btn mdui-btn-icon">
|
||||
<i class="mdui-icon material-icons" mdui-drawer="{target: '#main-drawer', swipe: true}" mdui-tooltip="{content: '菜单'}">menu</i>
|
||||
|
@@ -1,3 +1,5 @@
|
||||
用户数据表(MySQL数据表创建语句).txt
|
||||
|
||||
NOT NULL 规定该字段不允许为空
|
||||
UNSIGNED 无符号
|
||||
|
||||
@@ -14,7 +16,8 @@ CREATE TABLE `testdatabase`.`login_fail_log` (
|
||||
CREATE TABLE `testdatabase`.`users` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户 id',
|
||||
`username` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户名',
|
||||
`unionid` VARCHAR(100) NOT NULL COMMENT '全局唯一用户名',
|
||||
`nickname` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '用户昵称',
|
||||
`unionid` VARCHAR(100) NOT NULL COMMENT '全局唯一用户ID',
|
||||
`password` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '密码',
|
||||
`safety_password` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '安全密码',
|
||||
|
||||
|
Binary file not shown.
10
test/index.html
Normal file
10
test/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
166
test/install - from zblog.php.bak
Normal file
166
test/install - from zblog.php.bak
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
exit();
|
||||
#///////////////////////////////////////////////////////////////////////////////
|
||||
#// 在线背单词 在线安装程序
|
||||
#///////////////////////////////////////////////////////////////////////////////
|
||||
#// 如果您看到了这条消息,说明您的虚拟主机或者服务器不支持PHP,
|
||||
#// 我们十分遗憾的告诉您,您可能需要更换其他服务器或者安装PHP以继续。
|
||||
#///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
@set_time_limit(300);
|
||||
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
header('Content-type: text/html; charset=utf-8');
|
||||
|
||||
ob_start();
|
||||
|
||||
$xml=null;
|
||||
|
||||
function GetHttpContent($url) {
|
||||
$r = null;
|
||||
if (function_exists("curl_init") && function_exists('curl_exec')) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
if(ini_get("safe_mode")==false && ini_get("open_basedir")==false){
|
||||
curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
|
||||
}
|
||||
if(extension_loaded('zlib')){
|
||||
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 300);
|
||||
$opt[CURLOPT_USERAGENT]=$_SERVER['HTTP_USER_AGENT'] . ' AppCentre/2099-01-01 ';
|
||||
curl_setopt_array($ch,$opt);
|
||||
$r = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
} elseif (ini_get("allow_url_fopen")) {
|
||||
if(function_exists('ini_set'))ini_set('default_socket_timeout',300);
|
||||
$opt['header']='User-Agent: AppCentre/2099-01-01 ' . $_SERVER['HTTP_USER_AGENT'];
|
||||
$r = file_get_contents((extension_loaded('zlib')?'compress.zlib://':'') . $url, false, stream_context_create(array('http' => $opt)));
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
// 检查安装目录权限
|
||||
function install0(){
|
||||
|
||||
$d=dirname(__FILE__);
|
||||
|
||||
if(substr((string)decoct(fileperms($d)),-3)<>'755'&&substr((string)decoct(fileperms($d)),-3)<>'777'){
|
||||
echo "<p>警告:安装目录权限" . $d . "不是0755或是0777,可能无法运行在线安装程序.</p>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 下载数据包
|
||||
function install1(){
|
||||
|
||||
echo "<p>正在努力地下载数据包...</p>";
|
||||
ob_flush();
|
||||
|
||||
$GLOBALS['xml']=GetHttpContent('https://update.zblogcn.com/zblogphp/Release.xml');
|
||||
|
||||
//file_put_contents('release.xml',$GLOBALS['xml']);
|
||||
|
||||
}
|
||||
|
||||
// 解压、安装
|
||||
function install2(){
|
||||
|
||||
echo "<p>正在解压和安装文件...</p>";
|
||||
ob_flush();
|
||||
if ($GLOBALS['xml']) {
|
||||
$xml = simplexml_load_string($GLOBALS['xml'],'SimpleXMLElement');
|
||||
$old = umask(0);
|
||||
foreach ($xml->file as $f) {
|
||||
$filename=str_replace('\\','/',$f->attributes());
|
||||
$dirname= dirname($filename);
|
||||
mkdir($dirname,0755,true);
|
||||
if(PHP_OS=='WINNT'||PHP_OS=='WIN32'||PHP_OS=='Windows'){
|
||||
//$fn=iconv("UTF-8","GBK//IGNORE",$filename);
|
||||
$fn=$filename;
|
||||
}else{
|
||||
$fn=$filename;
|
||||
}
|
||||
file_put_contents($fn,base64_decode($f));
|
||||
}
|
||||
umask($old);
|
||||
} else {
|
||||
exit('release.xml不存在!');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 删除当前安装php,跳转到安装页面
|
||||
function install3(){
|
||||
|
||||
#unlink('release.xml');
|
||||
@unlink('install.php');
|
||||
echo '<script type="text/javascript">window.location="./zb_install/"</script>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
$title = "在线背单词";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<!-- DNS预解析 -->
|
||||
<!--<link rel="dns-prefetch" href="//zblogcn.com">-->
|
||||
<!--<link rel="dns-prefetch" href="//www.zblogcn.com">-->
|
||||
<!--<link rel="dns-prefetch" href="//app.zblogcn.com">-->
|
||||
<!--<link rel="dns-prefetch" href="//update.zblogcn.com">-->
|
||||
<title><?php echo $title; ?> 在线安装程序</title>
|
||||
<style type="text/css">
|
||||
*{font-size:14px;font-family:'Microsoft YaHei', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', 'Heiti SC', STHeiti, SimSun, sans-serif , Verdana, Arial;}
|
||||
body{margin:0;padding:0;color: #000000;background:#fafafa;}
|
||||
h1,h2,h3,h4,h5,h6{font-size:18px;padding:0;color:#3a6ea5;}
|
||||
h1{font-size:28px;}
|
||||
input{padding:15px 82px;cursor:pointer;}
|
||||
input:hover{box-shadow:0 0 0.5em rgba(0,0,0,0.2);}
|
||||
div{position:absolute;left: 50%;top: 50%;margin: -250px 0px 0px -300px;padding:0;overflow:hidden;height:400px;width:600px;background-color:white;text-align:center;box-shadow:0 0 0.5em rgba(0,0,0,0.2);padding-top:20px;padding-bottom:20px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1><?php echo $title; ?> 在线安装</h1>
|
||||
<?php
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == 'POST'){
|
||||
?>
|
||||
<p><img id="logo" src="https://update.zblogcn.com/zblogphp/loading.gif" alt="<?php echo $title; ?>在线安装" title="<?php echo $title; ?>在线安装"/></p>
|
||||
<?php
|
||||
flush();
|
||||
ob_flush();
|
||||
|
||||
install1();
|
||||
install2();
|
||||
install3();
|
||||
die();
|
||||
|
||||
}else{
|
||||
|
||||
?>
|
||||
<p><?php echo (($v=GetHttpContent('https://update.zblogcn.com/zblogphp/'))=='')?'不能联网获取<?php echo $title; ?>!':'最新版本:'.$v;?></p><br/>
|
||||
<p><img id="logo" src="https://update.zblogcn.com/zblogphp/loading.png" alt="<?php echo $title; ?>在线安装" title="<?php echo $title; ?>在线安装"/></p>
|
||||
<p style="display:none;"><img id="logo2" src="https://update.zblogcn.com/zblogphp/loading.gif" alt="" title=""/></p><br/>
|
||||
<?php
|
||||
install0();
|
||||
}
|
||||
|
||||
?>
|
||||
<form method="post" action="#">
|
||||
<p><input type="submit" value="开始安装" onclick="this.style.display='none';document.getElementById('logo').src='https://update.zblogcn.com/zblogphp/loading.gif'" /></p>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
61
test/union-login.bak/csrf document.txt
Normal file
61
test/union-login.bak/csrf document.txt
Normal file
@@ -0,0 +1,61 @@
|
||||
[https://www.zhihu.com/question/60102253]
|
||||
|
||||
PHP加了Token验证表单防止CSRF后还有必要做其它的防范吗?比如判断REFERER,再加个验证码之类的?有没有这个必要,目前再写一个模板做练习,已经加上了Token验证,准备再加上判断REFERER时突然觉得这样会不会有点多此一举?或则有什么其它更好的方法吗?
|
||||
|
||||
|
||||
目前的代码是这样的,先判断来源,再判断Token
|
||||
|
||||
//判断请求-登陆
|
||||
if($_GET['login']=='action'){
|
||||
//判断REFERER
|
||||
$referer = $_SERVER["HTTP_REFERER"]; //获取前一页面的 URL 地址
|
||||
$url = $_SERVER["HTTP_HOST"]; //获取本页面的主机 URL 地址
|
||||
//echo "来源页面:$referer </br> 本地页面:$url </br>"; //输出结果(测试用)
|
||||
if(preg_match("|$url|", $referer)){
|
||||
//来源通过,判断Token令牌
|
||||
session_start();
|
||||
if($_POST['token'] == $_SESSION['token']){
|
||||
unset($_SESSION['token']);
|
||||
echo "这是一个正常的提交请求";
|
||||
}else{
|
||||
echo "这是一个非法的提交请求";
|
||||
}
|
||||
}else{
|
||||
echo '非法来源的请求';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[https://blog.csdn.net/qq_31752115/article/details/103775475]
|
||||
php如何防止csrf攻击
|
||||
|
||||
CSRF概念:CSRF跨站点请求伪造(Cross—Site Request Forgery),跟XSS攻击一样,存在巨大的危害性,你可以这样来理解:
|
||||
|
||||
攻击者盗用了你的身份,以你的名义发送恶意请求,对服务器来说这个请求是完全合法的,但是却完成了攻击者所期望的一个操作,比如以你的名义发送邮件、发消息,盗取你的账号,添加系统管理员,甚至于购买商品、虚拟货币转账等。(推荐学习:PHP编程从入门到精通)
|
||||
|
||||
如:其中Web A为存在CSRF漏洞的网站,Web B为攻击者构建的恶意网站,User C为Web A网站的合法用户。
|
||||
|
||||
防御CSRF攻击:
|
||||
|
||||
目前防御 CSRF 攻击主要有三种策略:验证 HTTP Referer 字段;在请求地址中添加 token 并验证;在 HTTP 头中自定义属性并验证。
|
||||
|
||||
(1)验证 HTTP Referer 字段
|
||||
|
||||
根据 HTTP 协议,在 HTTP 头中有一个字段叫 Referer,它记录了该 HTTP 请求的来源地址。在通常情况下,访问一个安全受限页面的请求来自于同一个网站,比如需要访问 http://bank.example/withdraw?account=bob&amount=1000000&for=Mallory,用户必须先登陆 bank.example,然后通过点击页面上的按钮来触发转账事件。
|
||||
|
||||
这时,该转帐请求的 Referer 值就会是转账按钮所在的页面的 URL,通常是以 bank.example 域名开头的地址。而如果黑客要对银行网站实施 CSRF 攻击,他只能在他自己的网站构造请求,当用户通过黑客的网站发送请求到银行时,该请求的 Referer 是指向黑客自己的网站。
|
||||
|
||||
因此,要防御 CSRF 攻击,银行网站只需要对于每一个转账请求验证其 Referer 值,如果是以 bank.example 开头的域名,则说明该请求是来自银行网站自己的请求,是合法的。如果 Referer 是其他网站的话,则有可能是黑客的 CSRF 攻击,拒绝该请求。
|
||||
|
||||
(2)在请求地址中添加 token 并验证
|
||||
|
||||
CSRF 攻击之所以能够成功,是因为黑客可以完全伪造用户的请求,该请求中所有的用户验证信息都是存在于 cookie 中,因此黑客可以在不知道这些验证信息的情况下直接利用用户自己的 cookie 来通过安全验证。
|
||||
|
||||
要抵御 CSRF,关键在于在请求中放入黑客所不能伪造的信息,并且该信息不存在于 cookie 之中。
|
||||
|
||||
可以在 HTTP 请求中以参数的形式加入一个随机产生的 token,并在服务器端建立一个拦截器来验证这个 token,如果请求中没有 token 或者 token 内容不正确,则认为可能是 CSRF 攻击而拒绝该请求。
|
||||
|
||||
(3)在 HTTP 头中自定义属性并验证
|
||||
|
||||
这种方法也是使用 token 并进行验证,和上一种方法不同的是,这里并不是把 token 以参数的形式置于 HTTP 请求之中,而是把它放到 HTTP 头中自定义的属性里。通过 XMLHttpRequest 这个类,可以一次性给所有该类请求加上 csrftoken 这个 HTTP 头属性,并把 token 值放入其中。这样解决了上种方法在请求中加入 token 的不便,同时,通过 XMLHttpRequest 请求的地址不会被记录到浏览器的地址栏,也不用担心 token 会透过 Referer 泄露到其他网站中去。
|
@@ -12,8 +12,9 @@
|
||||
|
||||
<li class="toggle"><a data-toggle="modal" href="#loginer">登录</a></li>
|
||||
<li class="toggle"><a data-toggle="modal" href="#register">注册</a></li>
|
||||
<li class="toggle hidden"><a id="nicheng" href="##"></a></li>
|
||||
<li class="toggle hidden"><a id="logout" href="##">注销</a></li>
|
||||
|
||||
<li class="toggle hidden"><a id="nicheng" href="./login.html"></a></li>
|
||||
<li class="toggle hidden"><a id="logout" href="./login.html">注销</a></li>
|
||||
|
||||
<!-- 登录 -->
|
||||
<div id="loginer" class="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
|
Before Width: | Height: | Size: 633 B After Width: | Height: | Size: 633 B |
3
test/union-login.bak/sql.txt
Normal file
3
test/union-login.bak/sql.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
创建用户表数据库(注意testdatabase)
|
||||
CREATE TABLE `testdatabase`.`user` ( `id` INT NOT NULL AUTO_INCREMENT , `username` VARCHAR(20) NOT NULL , `pwd` VARCHAR(20) NOT NULL , `nc` VARCHAR(20) NOT NULL COMMENT '昵称' , PRIMARY KEY (`id`)) ENGINE = InnoDB;
|
Reference in New Issue
Block a user