Typecho显示不同的日期方式标签

在制作Typecho主题的时候,默认官方提供的日期格式是类似July 8, 2020,这样子的,我们可能需要其他的格式,比如2020-08-08。所以我们只需要找到对应模板中的日期格式就可以。这里简单记录一下,如果以后有需要的话可以使用到。

一般而言需要修改的代码存在于archive.php index.php post.php这三个文件内

('F j, Y')  #此为英文显示代码 
('Y-m-d')   #此为数字显示代码

找到你需要修改的代码替换掉即可,想要其他的显示方式,可以看看后面提供的一些显示代码
注意:每个文件内也许不止一处需要修改,可复制出来用TXT快速查找
其它显示代码:假设日期是2001-03-10

("F j, Y, g:i a");                   // March 10, 2001, 5:16 pm
("m.d.y");                           // 03.10.01
("j, n, Y");                         // 10, 3, 2001
("Ymd");                             // 20010310
('h-i-s, j-m-y, it is w Day z ');    // 05-16-17, 10-03-01, 1631 1618 6 Fripm01
('\i\t \i\s \t\h\e jS \d\a\y.');     // It is the 10th day.
("D M j G:i:s T Y");                 // Sat Mar 10 15:16:08 MST 2001
('H:m:s \m \i\s\ \m\o\n\t\h');       // 17:03:17 m is month
("H:i:s");                           // 17:16:17
("Y-m-d H:i:s");                     // 2001-03-10 17:16:18 (MySQL DATETIME 格式)

参考文件:https://sunpma.com/79.html

帝国CMS创建网站地图Sitemap.xml文件

在后台找到自定义页面,添加自定义页面,可直接复制下面的代码放入页面内容内即可。文件名选择存放路径:../../sitemap.xml

<?='<?xml version="1.0" encoding="UTF-8"?>'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>[!--news.url--]</loc>
<lastmod> <?php echo date("Y-m-d"); ?></lastmod>
<changefreq>daily</changefreq>
<priority>1.000</priority>
</url>
[e:loop={"select * from [!db.pre!]enewsclass order by myorder",0,24,0}]
<?
if($bqr['classurl']=='')
{
$sccurl=$public_r['newsurl'].$bqr['classpath']."/";
}
else
{
$sccurl=$bqr['classurl']."/";
}
?>
<url>
<loc><?=$sccurl?></loc>
<changefreq>daily</changefreq>
<priority>0.8000</priority>
</url>
[/e:loop]
[e:loop={"select * from [!db.pre!]enewszt order by ztid",0,24,0}]
<?
if($bqr['zturl']=='')
{
$sccurl=$public_r['newsurl'].$bqr['ztpath']."/";
}
else
{
$sccurl=$bqr['zturl']."/";
}
?>
<url>
<loc><?=$sccurl?></loc>
<lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod>
<changefreq>monthly</changefreq>
<priority>0.6000</priority>
</url>
[/e:loop]
[e:loop={"select * from [!db.pre!]ecms_news order by newstime desc",0,24,0}]
<url>
<loc><?=$bqsr[titleurl]?></loc>
<lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod>
<changefreq>monthly</changefreq>
<priority>0.5000</priority>
</url>
[/e:loop]
</urlset>

上面设置之后就创建了地图生成页面,如果运行正常,那么在保存的时候就会自动在根目录创建sitemap.xml文件,如果没有自动创建文件请检查根目录是否有写入权限。

另外,可以设置自动刷新任务,添加新的定时刷新计划任务,来保持sitemap.xml的自动更新。

Html Table自适应宽度,指定列固定宽度,其他列均分宽度

做表单界面时,我想到最好的方法应该是,标题栏所在的列宽度固定,内容栏所在的列宽度自适应且要均分,这样整体表格看起来才美观有序。

要做到这一点,目前只摸索出一种办法:
1,给tabletable-layout: fixed;
2,在每个table的第一行,加<colgroup><col>,有多少列,对应加多少个<col>
3,给指定列固定宽度的<col>加成<td class="title">,然后给title定义宽度,其他列的<col>加成<col width="auto">

案例代码:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>案例文档</title>
  <style>
    table{
      width: 100%;
      border-collapse: collapse;
      border: 1px solid #000;
      word-break:break-word;
      word-wrap:break-word;
      table-layout: fixed;
    }
    table tr td{
      border: 1px solid #000;
    }
    .title {
      background-color: #eee; 
      width: 120px;
      text-align: center;
    }
  </style>
</head>
<body>
  <table>
    <colgroup>
      <col class="title">
      <col width="auto">
      <col class="title">
      <col width="auto">
    </colgroup>
    <tr>
      <td class="title">标题:</td>
      <td colspan="3"></td>
    </tr>
    <tr>
      <td class="title">标题:</td>
      <td>内容</td>
      <td class="title">标题:</td>
      <td></td>
    </tr>
    <tr>
      <td class="title">标题:</td>
      <td colspan="3"></td>
    </tr>
    <tr>
      <td class="title">标题:</td>
      <td>内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容</td>
      <td class="title">标题:</td>
      <td></td>
    </tr>
  </table>
</body>
</html>

注意:这里有一个问题,有可能你程序没法在table的第一行<tr>前面加<colgroup><col>,比如asp.net的webform里面就不知道怎么加,此时的变通方法是,把<colgroup><col>换成一个空的<tr><td>,在<td>上同样加对应的class和width属性,然后通过样式把这个空行的边框和高度去掉,不显示。

原理:通过控制第一行各个列的宽度,来实现对整个表格的列进行控制。

本文摘自:http://www.dongchuanmin.com/archives/677.html

Linux系统使用iftop查看带宽占用情况

Linux系统下如果服务器带宽跑满了,查看跟哪个ip通信占用带宽比较多,可以通过iftop命令进行查询,使用方法如下:

1 安装方法【软件官网地址:http://www.ex-parrot.com/~pdw/iftop/
CentOS系统运行:yum install iftop
Debian系统运行:apt-get install iftop

在安装过程中需要我们输入 y 继续的步骤,在安装过程中会提醒我们的。安装完毕之后,就可以使用iftop命令激活监控。

2 安装好后在服务器执行iftop -i eth1就可以查看服务器公网网卡带宽使用情况(如果只执行iftop默认检测第一块网卡使用情况,这样查的会是内网网卡eth0。
执行:iftop -i eth0 -p
注:-P 参数会将请求服务的端口显示出来,也就是说是通过服务器哪个端口建立的连接,看内网流量执行 iftop -i eth0 -P 命令。

帝国CMS屏蔽在/d/file/附件文件夹下创建栏目目录的方法

如果网站的栏目较多,图片上传保存的文件夹是不太适合存在栏目目录下的,我喜欢存在/d/file/Y-m/,放在统一的文件夹下,而且按年月目录存放,设置如下:
ecms01.png

但是有一个问题就是,每次在后台执行 “数据更新 → 恢复栏目目录” 时,程序就会自动在/d/file/附件文件夹下创建网站的所有栏目目录,尤其是当网站栏目很多时,就会造成大量的空目录。

当然你可以不管他,但我有洁癖,看不得那些毫无意义的空目录,屏蔽生成的方法如下:

一、找到文件/e/class/functions.php
二、搜索:function CreateClassPath($classpath)
三、讲执行操作的代码屏蔽掉,如下图:
ecms02.png

本文转自:http://www.dongchuanmin.com/archives/563.html

帝国CMS 用关键字做出Tags链接效果

思路:
1,帝国CMS的关键字一般是用英文逗号分隔,比如:小红,小明,小华
2,需要把英文逗号去掉,并且给每个关键字用html标签包起来,比如:<li>小红</li><li>小明</li><li>小华</li>

代码:

<?php 
$cr=$empire->fetch1("select classpagekey from {$dbtbpre}enewsclass where classid='$GLOBALS[navclassid]'");
$source=$cr[classpagekey];
$hello = explode(',',$source); 
for($index=0;$index<count($hello);$index++) 
{ 
echo "<li><a href='/e/tags/?tagname=$hello[$index]&tempid=8'>"; echo $hello[$index];echo "</a></li>"; 
} 
?>

说明:
1、先把关键字内容取出来
2、用php的explode函数,把字符串打散为数组
3、然后用for循环,把数组中的每个词语用指定的HTML标签包起来

本文转自:http://www.dongchuanmin.com/archives/623.html