作者 邓超

1

<?php
use Model\listsSql;
echo strlen("你好啊阿萨德你白求恩是奥斯卡女把万科城那就睡吧八十年代你");
include_once __DIR__."/../vendor/autoload.php";
//use Model\listsSql;
//include_once __DIR__."/../vendor/autoload.php";
//$ids = db()->all('select `id` from `'.\Model\emailSql::$table.'` limit 1000 offset 0');
... ...
... ... @@ -3,6 +3,9 @@
namespace Controller;
use Lib\Mail\MailFun;
use Model\folderSql;
/**
* 文件夹管理
* @author:dc
... ... @@ -42,6 +45,33 @@ class Folder extends Base {
* @time 2023/2/18 17:56
*/
public function create(){
$formData = app()->request(['pid','folder']);
// 验证目录 可以输入中文英文数字
if(empty($formData['folder']) || !preg_match("/^[\u4E00-\u9FA5A-Za-z0-9_]+$/",$formData['folder'])){
app()->e('folder_create_name_error');
}
// 不为空上级
if(!empty($formData['pid'])){
$parent = db()->first(folderSql::first(['id'=>$formData['pid']]));
if(!$parent || $parent['email_id'] != $this->login_email['id']){
app()->e('folder_parent_not_fount');
}
if($parent['pid']){
app()->e('folder_tree_max_two');
}
}
// 判断文件夹是否存在
$has = db()->count(folderSql::has(
[
'email_id' => $this->login_email['id'],
'origin_folder' => $formData['folder']
]
));
}
... ...
<?php
namespace Controller;
use Lib\Mail\MailFun;
use Model\emailSql;
use Model\listsSql;
/**
* @author:dc
* @time 2023/2/13 11:28
* Class Home
* @package Controller
*/
class Test {
public function home(){
ob_start();
header("Content-Type:text/event-stream;Charset=UTF-8;\n\n");
header("cache-control:no-cache;\n\n");
foreach (range(1,10) as $i)
{
echo $i.'hello world'.PHP_EOL.PHP_EOL ;
ob_flush();
flush();
sleep(1);
}
ob_clean();
}
public function a(){
header("Content-Type:text/html;Charset=UTF-8;");
echo '1';
}
}
... ...
... ... @@ -18,4 +18,10 @@ return [
'login_error' => '登录失败',
'token_verify_error' => '令牌验证失败',
'token_verify_notfound' => '令牌验证失败.',
'param_request_error' => '参数异常',
'folder_create_name_error' => '文件夹名称只能输入中文英文数字',
'folder_parent_not_fount' => '上级文件夹不存在',
'folder_tree_max_two' => '文件夹最多2级',
];
\ No newline at end of file
... ...
... ... @@ -53,7 +53,6 @@ class App {
public function __construct()
{
header("Content-Type:application/json;Charset=utf8;");
$this->date = date('Y-m-d');
$this->dateTime = date('Y-m-d H:i:s');
... ... @@ -63,7 +62,7 @@ class App {
$this->route = new Route();
// 请求参数 TODO::不允许其他类型的请求参数
$this->request = my_filter($_POST);
$this->request = my_filter($_POST,['trim']);
}
... ... @@ -90,9 +89,9 @@ class App {
public static function run() {
$app = self::instance();
try {
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$app->e('need_post_request');
}
// if ($_SERVER['REQUEST_METHOD'] != 'POST'){
// $app->e('need_post_request');
// }
// 取到路由 控制器
$route = $app->route->get(explode('?',$_SERVER['REQUEST_URI'])[0]);
... ... @@ -222,9 +221,16 @@ class App {
// end code
header("Content-Type:application/json;Charset=UTF-8;");
// header("Content-Type:text/html;Charset=UTF-8;");
// header("Content-Type:text/event-stream;Charset=UTF-8;");
if(self::instance()->data){
echo json_encode(self::instance()->data,JSON_UNESCAPED_UNICODE);
}
echo json_encode(self::instance()->data,JSON_UNESCAPED_UNICODE);
// ob_flush();
// ob_clean();
}
... ...
... ... @@ -33,6 +33,9 @@ class Route {
*/
public function get($route):array{
$route = trim($route,'/');
if(empty($route)){
return $this->url['/']??[];
}
return $this->url[$route]??[];
}
... ...
... ... @@ -32,10 +32,20 @@ class folderSql {
* @author:dc
* @time 2023/2/18 11:48
*/
public static function has($where){
public static function has($where):string {
return "select `id` from `".self::$table."` where ".dbWhere($where);
}
/**
* 查询一条完整的数据
* @param $where
* @return string
* @author:dc
* @time 2023/2/20 16:39
*/
public static function first($where):string {
return "select * from `".self::$table."` where ".dbWhere($where);
}
... ...
... ... @@ -7,6 +7,13 @@
return [
/**
* home
* @see \Controller\Test::a()
*/
'/' => [\Controller\Test::class, 'a'],
't' => [\Controller\Test::class, 'home'],
/**
* 登录操作
* @see \Controller\Login::login()
* @param string email 邮箱
... ...