Loading... <div class="tip share">请注意,本文编写于 1711 天前,最后修改于 847 天前,其中某些信息可能已经过时。</div> ## 前言 这篇文章算是个记录吧,同时也方便我以后更新了重新抄作业。应该是会长久更新下去的,应该是是不会咕咕咕的。~~大概不会吧~~ 通篇都是抄的,别问,问就是抄。 ## 登录页面美化 <div class="panel panel-default collapse-panel box-shadow-wrap-lg"><div class="panel-heading panel-collapse" data-toggle="collapse" data-target="#collapse-08f188cfc7e47b8d8ef297e32e296a1732" aria-expanded="true"><div class="accordion-toggle"><span style="">登录,注册页面美化插件</span> <i class="pull-right fontello icon-fw fontello-angle-right"></i> </div> </div> <div class="panel-body collapse-panel-body"> <div id="collapse-08f188cfc7e47b8d8ef297e32e296a1732" class="collapse collapse-content"><p></p> <button class=" btn m-b-xs btn-info " onclick="window.open('https://qqdie.com/archives/typecho-LoginDesigner-plugin.html','_blank')">原贴链接</button> Login Designer 因为wp博客有个注册登录美化插件叫 `Login Designer`,所以我的这个插件也直接叫这个名字了。 实现原理 插件通过向登录/注册页面注入 `css`来实现美化效果,目前1.3.0版本内置了九款写好的样式,背景图片用户可以自行设计,同时用户还可以选择空白模板然后自己写 `css`来实现自定义美化。 插件接口 使用的是后台全局 `header`接口,然后判断用户没有登录才插入 `css`文件,这样就实现了只在登录/注册页面插入内容,而不影响后台其他东西。 下载插件 开源地址:https://github.com/jrotty/LoginDesigner <p></p></div></div></div> ## 通过伪静态隐藏掉index.php <div class="panel panel-default collapse-panel box-shadow-wrap-lg"><div class="panel-heading panel-collapse" data-toggle="collapse" data-target="#collapse-30e5eea9e3890b3249f9bdec023d6eaf2" aria-expanded="true"><div class="accordion-toggle"><span style="">index.php 是真的丑</span> <i class="pull-right fontello icon-fw fontello-angle-right"></i> </div> </div> <div class="panel-body collapse-panel-body"> <div id="collapse-30e5eea9e3890b3249f9bdec023d6eaf2" class="collapse collapse-content"><p></p> 1. 在网站根目录新建一个文件,命名为`.htaccess` 2. 根据自己的web服务器类型抄作下面作业并`放入.htaccess文件中` 3. 在网站后台==>>设置==>>永久链接==>>启用地址重写 <div class="tab-container post_tab box-shadow-wrap-lg"> <ul class="nav no-padder b-b scroll-hide" role="tablist"> <li class='nav-item active' role="presentation"><a class='nav-link active' style="" data-toggle="tab" aria-controls='tabs-a09a27328f385ad3691c802dff79bbdb880' role="tab" data-target='#tabs-a09a27328f385ad3691c802dff79bbdb880'>Apache</a></li><li class='nav-item ' role="presentation"><a class='nav-link ' style="" data-toggle="tab" aria-controls='tabs-4fd289e9eb272328453e9124514b7d41731' role="tab" data-target='#tabs-4fd289e9eb272328453e9124514b7d41731'>Nginx</a></li><li class='nav-item ' role="presentation"><a class='nav-link ' style="" data-toggle="tab" aria-controls='tabs-5080baaacad817d74ba1cf4185c118ec122' role="tab" data-target='#tabs-5080baaacad817d74ba1cf4185c118ec122'>kangle</a></li> </ul> <div class="tab-content no-border"> <div role="tabpanel" id='tabs-a09a27328f385ad3691c802dff79bbdb880' class="tab-pane fade active in"> ```apache <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1] </IfModule> ``` <div class="tip inlineBlock warning"> 此文件既可以放在apache的conf文件中,亦可以放在.htaccess中,都可以生效 </div> </div><div role="tabpanel" id='tabs-4fd289e9eb272328453e9124514b7d41731' class="tab-pane fade "> ```Nginx if (!-e $request_filename) { rewrite ^(.*)$ /index.php$1 last; } ``` </div><div role="tabpanel" id='tabs-5080baaacad817d74ba1cf4185c118ec122' class="tab-pane fade "> ```Kangle <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond $1 !^(index\.php) RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> ``` </div> </div> </div> <p></p></div></div></div> ## 打字特效插件 <div class="panel panel-default collapse-panel box-shadow-wrap-lg"><div class="panel-heading panel-collapse" data-toggle="collapse" data-target="#collapse-4756295fdde8dcd0c2854302f30a565c84" aria-expanded="true"><div class="accordion-toggle"><span style="">打字特效插件</span> <i class="pull-right fontello icon-fw fontello-angle-right"></i> </div> </div> <div class="panel-body collapse-panel-body"> <div id="collapse-4756295fdde8dcd0c2854302f30a565c84" class="collapse collapse-content"><p></p> 插件名为 `ActivatePowerMode`,评论及后台的文章编辑界面都可以用 对了,你可以在评论区试试效果,我只开了~~不知道怎么说的效果~~,震动效果我没开 PS. 现在这东西被我给卸了.......,有个事件一直在疯狂循环,用我 mac 一打开我网页风扇就起飞,先给删了,有空去改改代码... <button class=" btn m-b-xs btn-info " onclick="window.open('https://github.com/AlanDecode/Typecho-Plugin-ActivatePowerMode','_blank')">gayhub链接</button> <p></p></div></div></div> ## 一款可以显示评论者UA以及操作系统的插件 <div class="panel panel-default collapse-panel box-shadow-wrap-lg"><div class="panel-heading panel-collapse" data-toggle="collapse" data-target="#collapse-705e0cdd2f8cf69903266fe53e0b6dbd16" aria-expanded="true"><div class="accordion-toggle"><span style="">UserAgent</span> <i class="pull-right fontello icon-fw fontello-angle-right"></i> </div> </div> <div class="panel-body collapse-panel-body"> <div id="collapse-705e0cdd2f8cf69903266fe53e0b6dbd16" class="collapse collapse-content"><p></p> <button class=" btn m-b-xs btn-info " onclick="window.open('https://doge.uk/coding/useragent-modify.html','_blank')">原文链接</button> ### 使用方法 1. 先将插件置于`plugins`目录下,插件目录名应为`UserAgent` 2. 修改`Handsome`主题,`component`目录下的`comments.php`代码文件,如果你什么都没有修改的话,那代码的位置大概第`101-104`行左右 修改前的代码下: ```php <?php endif; ?> </span> <div class="comment-metadata"> ``` 添加代码 `<?php UserAgent_Plugin::get_useragent($comments->agent,$comments->ip); ?> ` 修改后代码如下: ```php <?php endif; ?><?php UserAgent_Plugin::get_useragent($comments->agent,$comments->ip); ?> </span> <div class="comment-metadata"> ``` ### 获取真实IP Typecho开启CDN后,可能无法获取访客真实IP,只能取得CDN节点IP,为此可以在Typecho博客网站的根目录的config.inc.php插入下面的代码: ```php //** 防止CDN造成无法获取客户真实IP地址 */ if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']); $_SERVER['REMOTE_ADDR'] = $list[0]; } ``` <p></p></div></div></div> ## 修改数据库编码。支持 emoji 表情。 //TODO ## 切换到其他窗口时标题栏显示一些骚东西 <div class="panel panel-default collapse-panel box-shadow-wrap-lg"><div class="panel-heading panel-collapse" data-toggle="collapse" data-target="#collapse-c83a278335f1e0ffb34431c0ed0f9b6233" aria-expanded="true"><div class="accordion-toggle"><span style="">自定义一个JS</span> <i class="pull-right fontello icon-fw fontello-angle-right"></i> </div> </div> <div class="panel-body collapse-panel-body"> <div id="collapse-c83a278335f1e0ffb34431c0ed0f9b6233" class="collapse collapse-content"><p></p>这是排版过的 js,方便看一点。 ```javascript jQuery(document).ready(function() { function d() { document.title = document[b] ? "网页崩溃了!": a } var b, c, a = document.title; "undefined" != typeof document.hidden ? (b = "hidden", c = "visibilitychange") : "undefined" != typeof document.mozHidden ? (b = "mozHidden", c = "mozvisibilitychange") : "undefined" != typeof document.webkitHidden && (b = "webkitHidden", c = "webkitvisibilitychange"), ("undefined" != typeof document.addEventListener || "undefined" != typeof document[b]) && document.addEventListener(c, d, !1) }); ``` 未排版的 js ```js jQuery(document).ready(function(){function d(){document.title=document[b]?"网页崩溃了!":a}var b,c,a=document.title;"undefined"!=typeof document.hidden?(b="hidden",c="visibilitychange"):"undefined"!=typeof document.mozHidden?(b="mozHidden",c="mozvisibilitychange"):"undefined"!=typeof document.webkitHidden&&(b="webkitHidden",c="webkitvisibilitychange"),("undefined"!=typeof document.addEventListener||"undefined"!=typeof document[b])&&document.addEventListener(c,d,!1)}); ``` <p></p></div></div></div> ## 首页文章图片获取焦点放大 <div class="panel panel-default collapse-panel box-shadow-wrap-lg"><div class="panel-heading panel-collapse" data-toggle="collapse" data-target="#collapse-2b94bc93f6b498a9a23d0fb3438877153" aria-expanded="true"><div class="accordion-toggle"><span style="">自定义一个 css</span> <i class="pull-right fontello icon-fw fontello-angle-right"></i> </div> </div> <div class="panel-body collapse-panel-body"> <div id="collapse-2b94bc93f6b498a9a23d0fb3438877153" class="collapse collapse-content"><p></p> ```css .item-thumb{ cursor: pointer; transition: all 0.6s; } .item-thumb:hover{ transform: scale(1.05); } .item-thumb-small{ cursor: pointer; transition: all 0.6s; } .item-thumb-small:hover{ transform: scale(1.05); } ``` <p></p></div></div></div> ## 修改 header.php 优化 SEO <div class="panel panel-default collapse-panel box-shadow-wrap-lg"><div class="panel-heading panel-collapse" data-toggle="collapse" data-target="#collapse-11fef47df6ec7e0d2be4b18847ea075865" aria-expanded="true"><div class="accordion-toggle"><span style="">描述 seo 优化</span> <i class="pull-right fontello icon-fw fontello-angle-right"></i> </div> </div> <div class="panel-body collapse-panel-body"> <div id="collapse-11fef47df6ec7e0d2be4b18847ea075865" class="collapse collapse-content"><p></p> 打开 `/usr/themes/handsome/component/header.php` 这个文件,在代码的第三十一行你应该能看到如下内容 ```php <title><?php Content::echoTitle($this, $this->options->title, $this->_currentPage); ?></title> ``` 在其下方添加几条字段作为 SEO 优化。 ```php <!--优化谷歌搜索结果--> <meta itemprop="name" content="XiaoCai ' Blog"> <meta itemprop="author" content="小菜"> <meta itemprop="image" content="https://blog.ixiaocai.net/usr/uploads/img/favicon.ico"> <!--个人修改,优化文章描述,seo 优化--> <?php if($this->fields->d_seo): ?> <meta name="description" content="<?php echo $this->fields->d_seo; ?>"> <?php endif; ?> <!--个人修改,优化文章描述,seo 优化--> ``` 在完成后,不仅可以优化谷歌搜索结果,且在文章指定了 `名为 d_seo 的自定义描述字段` ,则会将 `description` 指定为 d_seo。 其实 headsome 主题会自动将文章首段作为description,没必要手动指定( 但是我就是想手动指定( <p></p></div></div></div> ## ~~添加评论验证码~~ <button class=" btn m-b-xs btn-info " onclick="window.open('https://www.feiyubk.com/archives/13.html','_blank')">原贴链接</button> <div class="panel panel-default collapse-panel box-shadow-wrap-lg"><div class="panel-heading panel-collapse" data-toggle="collapse" data-target="#collapse-fadde18c4dd90bb57f2d24bb59f241be76" aria-expanded="true"><div class="accordion-toggle"><span style="">~~添加评论验证码~~</span> <i class="pull-right fontello icon-fw fontello-angle-right"></i> </div> </div> <div class="panel-body collapse-panel-body"> <div id="collapse-fadde18c4dd90bb57f2d24bb59f241be76" class="collapse collapse-content"><p></p> 在根目录下的 `function.php` 添加如下代码 ```php function themeInit($comment){$comment = spam_protection_pre($comment, $post, $result);}function spam_protection_math(){ $num1=rand(1,49); $num2=rand(1,49); echo "<label for=\"math\">请输入<code>$num1</code>+<code>$num2</code>的计算结果:</label>\n"; echo "<input type=\"text\" name=\"sum\" class=\"text\" value=\"\" size=\"25\" tabindex=\"4\" style=\"width:218px\" placeholder=\"计算结果:\">\n"; echo "<input type=\"hidden\" name=\"num1\" value=\"$num1\">\n"; echo "<input type=\"hidden\" name=\"num2\" value=\"$num2\">";}function spam_protection_pre($comment, $post, $result){ $sum=$_POST['sum']; switch($sum){ case $_POST['num1']+$_POST['num2']: break; case null: throw new Typecho_Widget_Exception(_t('对不起: 请输入验证码。<a href="javascript:history.back(-1)">返回上一页</a>','评论失败')); break; default: throw new Typecho_Widget_Exception(_t('对不起: 验证码错误,请<a href="javascript:history.back(-1)">返回</a>重试。','评论失败')); } return $comment;} ``` 打开主题 `./component/comments.php` 文件,在第 185 行位置插入如下代码: ```php <?php spam_protection_math();?> ``` 最后效果如下: ```html <div class="comment-form-url form-group col-sm-12 col-md-4"> <label for="url"><?php _me("地址") ?></label> <input id="url" class="form-control" name="url" type="url" value="<?php $this->remember('url'); ?>" maxlength="200" placeholder="<?php _me("网站或博客") ?>"></div> <?php spam_protection_math();?> </div> <?php endif; ?> <!--提交按钮--> ``` <p></p></div></div></div> ## 修改评论区填写邮箱时候的提示 这段要🔨教程,照着`./component/comments.php` XJB 改就好了 --- ## 修改一些提示信息 比如此内容仅限登录可见什么什么的 `./libs/content/Postcontent.php` `./libs/Content.php` ,`./component/comments.php` 这几处的提示信息 最后修改:2022 年 06 月 12 日 © 允许规范转载 赞 1 给点.jpg