马春杰杰 Exit Reader Mode

[mcj]typecho使用过程说明

自定义typecho后台路径

Typecho 安装好后,默认的后台路径是 domain.com/admin/,为了提高安全性,我们允许以 domain.com/xxxx/ 的方式访问,其中 xxxx 是你自定义的路径。自定义的方法如下:

你只需要在系统根目录下的 config.inc.php 文件里,找到/** 后台路径(相对路径) */

define('__TYPECHO_ADMIN_DIR__', '/admin/');把这个 /admin/ 路径改成自己想要的路径就行了

typecho模板文件结构说明

文件名 作用 必须
style.css 主题样式文件 否
screenshot.png 主题缩略图 否
index.php 首页以及说明文件 是
404.php 404页面文件 否
archive.php 通用(分类、搜索、标签、作者)页面文件 否
category.php 分类页面文件 否
search.php 搜索页面文件 否
tag.php 标签页面文件 否
author.php 作者页面文件 否
comments.php 评论页面文件 否
footer.php 底部页面文件 否
functions.php 主题函数文件 否
header.php 头部页面文件 否
page.php 独立页面文件 否
post.php 日志页面文件 否
sidebar.php 侧边栏页面文件 否PS:如果archive.php不存在,index.php也会作为通用页面,实现archive.php的工作。

tinymce插件

20190308 发现启用这个插件之后,手机访问速度回非常非常慢。目前还不知道原因

访客头像

首先,将下面的代码丢到funtions.php文件当中。

//获取Gravatar头像 QQ邮箱取用qq头像function getGravatar($email, $s = 96, $d = 'mp', $r = 'g', $img = false, $atts = array()){
preg_match_all('/((\d)*)@qq.com/', $email, $vai);if (empty($vai['1']['0'])) {
    $url = 'https://www.gravatar.com/avatar/';
    $url .= md5(strtolower(trim($email)));
    $url .= "?s=$s&d=$d&r=$r";    if ($img) {
        $url = '<img src="' . $url . '"';        foreach ($atts as $key => $val)
            $url .= ' ' . $key . '="' . $val . '"';
        $url .= ' />';
    }
}else{
    $url = 'https://q2.qlogo.cn/headimg_dl?dst_uin='.$vai['1']['0'].'&spec=100';
}return  $url;
}

其次,再将下面的代码复制到需要放头像的页面,通常是comments.php页面和sidebar.php页面。

<?php $email=$comments->mail; $imgUrl = getGravatar($email);echo '<img src="'.$imgUrl.'" width="45px" height="45px" style="border-radius: 50%;" >'; ?>

大功告成!该代码可以实现的功能:当客户评论时用的不是QQ邮箱,则显示gavatar头像,否则则显示QQ头像。完美!

微信小程序

这个必须要开启ssl才行,唉,先放着吧。
https://newsn.net/say/wetypecho-install.html

绑定二级目录

在根目录建立文件.htaccess,然后输入:

RewriteEngine On
 RewriteCond %{HTTP_HOST} ^(www.)?lzxmt.mcj686.top$
 RewriteCond %{REQUEST_URI} !^/lzxmt/
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /lzxmt/$1
 RewriteCond %{HTTP_HOST} ^(www.)?lzxmt.mcj686.top$
 RewriteRule ^(/)?$ lzxmt/index.php [L]

RewriteEngine On
 RewriteCond %{HTTP_HOST} ^(www.)?www.mcj686.top$
 RewriteCond %{REQUEST_URI} !^/lzxmt/
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /lzxmt/$1
 RewriteCond %{HTTP_HOST} ^(www.)?www.mcj686.top$
 RewriteRule ^(/)?$ lzxmt/index.php [L]

RewriteEngine On
 RewriteCond %{HTTP_HOST} ^(www.)?mcj686.top$
 RewriteCond %{REQUEST_URI} !^/lzxmt/
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /lzxmt/$1
 RewriteCond %{HTTP_HOST} ^(www.)?mcj686.top$
 RewriteRule ^(/)?$ lzxmt/index.php [L] 
 
 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^(www.)?blog.mcj686.top$
 RewriteCond %{REQUEST_URI} !^/blog/
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blog/$1
 RewriteCond %{HTTP_HOST} ^(www.)?blog.mcj686.top$
 RewriteRule ^(/)?$ blog/index.php [L]

然后打开要绑定的目录,也建立.htaccess文件,然后填入:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

</IfModule>

即可。
不过目前还有问题,那就是开启之后ssl失效。
已解决,通过重新开启ssl可以了。

本文最后更新于2019年5月23日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!