WordPress 使用 CloudFlare 后,后台无法进入、重定向次数过多、提示 Sorry, you are not allowed to access this page. 作者: Chuwen 时间: 2021-07-10 分类: PHP 评论 ## 具体原因 1. CloudFlare 那边 SSL 配置的是“灵活”  2. WordPress 后台配置的又是 https  最终就会导致浏览器一直报“重定向次数过多”,或者 WordPress 直接报 `Sorry, you are not allowed to access this page.` CloudFlare SSL 配置“灵活”,指的是 **源站**(也就是你的 WordPress)博客不支持 https,然后 CloudFlare 可以实现: 浏览器 --https--> CloudFlare --http--> 你的服务器(WordPress) **但是**,你在 WordPress 后台配置的了你的 WordPress 地址是 `https` 地址开头的,所以当 CloudFlare 访问你的 WordPress 时,你的 WordPress 告诉 CloudFlare 你只能通过 https 访问,CloudFlare 又告诉你的浏览器你只能访问 https 这样就造成了循环.... ## 解决办法 将 CloudFlare 的 SSL 配置改为“完全”或“完全(严格)”,**推荐选择完全**具体看: 
目录/时间线 Typecho 自定义模板 作者: Chuwen 时间: 2021-07-04 分类: PHP 1 条评论 ## 使用说明 如果你使用的是 Typecho 默认主题,那么你可以在你博客目录下 `/www/wwwroot/nowtime.cc/usr/themes/default` 新建一个文件名为 `time-line.php` 然后将下述**模板源码**粘贴进去保存 > 其它主题可以参照着你主题目录下的 `page.php` 源码来修改我下面写的**模板源码** 然后去博客后台 -> 管理 -> 独立页面 -> 新增,选择模板  然后“发布页面即可” ### 效果预览 https://nowtime.cc/time-line.html  ## 模板源码 ```php need('header.php'); ?> title() ?> content(); ?> need('comments.php'); ?> widget("Widget_Contents_Post_Recent", "pageSize=100000000000000")->to($post); $recentPost = array(); while ($post->next()) { $recentPost[] = array( "title" => $post->title, "link" => $post->permalink, "time" => $post->created, ); } ?> need('sidebar.php'); ?> need('footer.php'); ?> ```
Hyperf 使用 @date、@datetime 注释启动都报错 作者: Chuwen 时间: 2021-07-03 分类: PHP 评论 Hyperf 使用 @date、@datetime 注释启动都报错 ### 使用 @date 注释 代码如下: ```php * @date: 2021/7/3 12:28 */ public function index(RequestInterface $request, ResponseInterface $response): \Psr\Http\Message\ResponseInterface { return $response->raw($this->help()); } } ``` 报错: ```log #4 /www/wwwroot/NowTool/vendor/hyperf/d in /www/wwwroot/NowTool/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php on line 39 Fatal error: Uncaught Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@date" in method App\Controller\V1\Video\DouyinController::index() was never imported. Did you maybe forget to add a "use" statement for this annotation? in /www/wwwroot/NowTool/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:39 Stack trace: ``` ### 使用 @datetime 注释 又报以下错误: ```log Fatal error: Uncaught Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The class "datetime" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "datetime". If it is indeed no annotation, then you need to add @IgnoreAnnotation("datetime") to the _class_ doc comment of method App\Controller\V1\Video\DouyinController::index(). in /www/wwwroot/NowTool/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:39 Stack trace: ``` > The class "datetime" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "datetime". ### 看到以上错误大概需要怎么做了 参照文档的“注解”部分:https://hyperf.wiki/2.1/#/zh-cn/annotation 解决办法就是,添加需要忽略“注解”,配置文件位置 `/config/autoload/annotations.php`:  然后就可以正常启动了 
Laravel 添加模型方法注释,使 PHPStorm 有语法提示 作者: Chuwen 时间: 2021-06-30 分类: Laravel,PHP 评论 ## 安装 1. 在 PHPStorm 上装 `Laravel` 插件  2. 在项目中添加 `barryvdh/laravel-ide-helper` 包 ```shell composer require barryvdh/laravel-ide-helper ``` ## 使用 1.为**所有模型**添加注释 ```shell php artisan ide-helper:models ``` 2.为**指定模型**添加注释 > 以下展示的是为 `App\Models\Admin` 模型添加注释,*\App\Models\Admin* 是模型的命名空间名字 ```shell php artisan ide-helper:models \App\Models\Admin ``` 3.为 Facades 生成注释 ```shell php artisan ide-helper:generate ``` 4.生成 PHPstorm Meta file ```shell php artisan ide-helper:meta ``` ## 运行为“模型添加注释”后的截图 
整了个小玩意-佳寓用电明细查询 作者: Chuwen 时间: 2021-06-14 分类: PHP 评论 > 虽然是个小东西,但为了做的完美些,也肝了2天空闲时间 项目地址:https://github.com/PrintNow/jiayu-hydropower-query 在线预览:https://nowtime.cc/jiayu/ 