top-image

OLDER ARTICLES

问题描述

  • 上传文件时提示“文件超出大小”,修改后台设置无效。

解决步骤

  1. 检查zblog后台设置
    • 全局设置:修改“允许上传文件的大小(单位MB)”。
  2. 修改php.ini
    • 虚拟主机:联系主机提供商修改。
    • 服务器:找到php.ini文件,修改upload_max_filesize参数,保存并重启服务器。

操作步骤

  1. 安装注册插件
    • 安装官方提供的注册插件。
  2. 修改插件文件
    • 打开/zb_users/plugin/RegPage/include.php文件。
  3. 替换模板名称
    • 在第213行,将$article->Template改为自定义模板的名称,例如'login'
当前位置:<a href="{$host}">网站首页</a>
{if $type=='category'}
{php}
$html='';
function navcate($id){
    global $html;
    $cate = new Category;
    $cate->LoadInfoByID($id);
    $html = ' > <a href="'.$cate->Url.'" title="查看'.$cate->Name.'中的全部文章">'.$cate->Name.'</a>'.$html;
    if(($cate->ParentID)>0){
        navcate($cate->ParentID);
    }
}
navcate($category->ID);
global $html;
echo $html;
{/php}
{else}
 > {$title}
{/if}

效果示例: 当前位置:网站首页 > 一级分类 > 二级分类 > 三级分类

  • 前提条件:确保电脑环境为Windows,并且安装了PHP环境。
  • 推荐的PHP环境搭建软件
    • phpStudy
    • UPUPW:推荐下载Nginx PHP7.0系列
    • 宝塔面板
  • 安装步骤
    • 按照所选软件的官方文档或视频教程完成PHP环境的搭建。
    • 下载zblogPHP版本的安装文件。
    • 将安装文件上传至本地服务器的根目录。
    • 在浏览器中输入http://localhost/install.php,按照提示完成安装。
  • 默认设置

    • 在WordPress后台的“设置” -> “阅读” -> “博客页面至多显示”中设置每页显示的文章数量,但这是全局设置,所有分类都会使用这个值。
  • 自定义设置

    • 使用pre_get_posts钩子来动态设置不同分类的每页文章数量。
  • 代码示例

    // 不同分类调用不同的分页显示数量
    function tx_wp_filter_pre_get_posts($query) {
      if ($query->is_main_query()) { // 判断是否为主查询
        $num = '';
        if (is_category()) { // 判断是否为分类
          $cat_ID = get_queried_object_id(); // 获取分类ID
          if (get_option('cat-pagenum-' . $cat_ID)) { // 判断分类自定义字段是否有值
            $num = get_option('cat-pagenum-' . $cat_ID);
            $query->set('posts_per_page', $num); // 给主循环数据里面的每页文章数量赋值
          }
        }
      }
      return $query;
    }
    add_action('pre_get_posts', 'tx_wp_filter_pre_get_posts'); // 挂上钩子
  • 简化版代码

    // 不同分类调用不同的分页显示数量
    function tx_wp_filter_pre_get_posts($query) {
      if ($query->is_main_query()) { // 判断是否为主查询
        $num = '';
        if (is_category(array(1))) { // 数字1为指定分类ID
          $num = 2; // 数字2为每页文章数量值,可以任意修改但必须是整数
          $query->set('posts_per_page', $num); // 给主循环数据里面的每页文章数量赋值
        }
      }
      return $query;
    }
    add_action('pre_get_posts', 'tx_wp_filter_pre_get_posts'); // 挂上钩子

     

  • Apache (.htaccess):

    RewriteEngine On
    ErrorDocument 404 /404.html
    RewriteBase /
    
    # 信息列表
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^listinfo-(.+?)-(.+?)\.html$ /e/action/ListInfo/index\.php\?classid=$1&page=$2
    
    # 信息内容页
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^showinfo-(.+?)-(.+?)-(.+?)\.html$ /e/action/ShowInfo\.php\?classid=$1&id=$2&page=$3
    
    # 标题分类列表页
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^infotype-(.+?)-(.+?)\.html$ /e/action/InfoType/index\.php\?ttid=$1&page=$2
    
    # TAGS信息列表页
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^tags-(.+?)-(.+?)\.html$ /e/tags/index\.php\?tagname=$1&page=$2
    
    # 评论列表页
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)\.html$ /e/pl/index\.php\?doaction=$1&classid=$2&id=$3&page=$4&myorder=$5&tempid=$6
  • IIS6 (httpd.ini):

    [ISAPI_Rewrite]
    # 3600 = 1 hour
    CacheClockRate 3600
    RepeatLimit 32
    
    # 信息列表
    RewriteRule ^(.*)listinfo-(.+?)-(.+?)\.html$ $1/e/action/ListInfo/index\.php\?classid=$2&page=$3
    
    # 信息内容页
    RewriteRule ^(.*)showinfo-(.+?)-(.+?)-(.+?)\.html$ $1/e/action/ShowInfo\.php\?classid=$2&id=$3&page=$4
    
    # 标题分类列表页
    RewriteRule ^(.*)infotype-(.+?)-(.+?)\.html$ $1/e/action/InfoType/index\.php\?ttid=$2&page=$3
    
    # TAGS信息列表页
    RewriteRule ^(.*)tags-(.+?)-(.+?)\.html$ $1/e/tags/index\.php\?tagname=$2&page=$3
    
    # 评论列表页
    RewriteRule ^(.*)comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)\.html$ $1/e/pl/index\.php\?doaction=$2&classid=$3&id=$4&page=$5&myorder=$6&tempid=$7
    
    # 搜索伪静态
  • IIS7 (web.config):

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <!-- 帝国7.2默认规则 IIS7的rule name不能重复相同 -->
        <rewrite>
          <rules>
            <rule name="listinfo">
              <match url="^(.*/)*listinfo-(.+?)-(.+?).html\?*(.*)$" />
              <action type="Rewrite" url="{R:1}/e/action/ListInfo/index.php?classid={R:2}&page={R:3}" />
            </rule>
            <rule name="showinfo">
              <match url="^(.*/)*showinfo-(.+?)-(.+?)-(.+?).html\?*(.*)$" />
              <action type="Rewrite" url="{R:1}/e/action/ShowInfo.php?classid={R:2}&id={R:3}&page={R:4}" />
            </rule>
            <rule name="infotype">
              <match url="^(.*/)*infotype-(.+?)-(.+?).html\?*(.*)$" />
              <action type="Rewrite" url="{R:1}/e/action/InfoType/index.php?ttid={R:2}&page={R:3}" />
            </rule>
            <rule name="tags">
              <match url="^(.*/)*tags-(.+?)-(.+?).html\?*(.*)$" />
              <action type="Rewrite" url="{R:1}/e/tags/index.php?tagname={R:2}&page={R:3}" />
            </rule>
            <rule name="comment">
              <match url="^(.*/)*comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?).html\?*(.*)$" />
              <action type="Rewrite" url="{R:1}/e/pl/index.php?doaction={R:2}&classid={R:3}&id={R:4}&page={R:5}&myorder={R:6}&tempid={R:7}" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
  • Nginx:

    rewrite ^([^\.]*)/listinfo-(.+?)-(.+?)\.html$ $1/e/action/ListInfo/index.php?classid=$2&page=$3 last;
    rewrite ^([^\.]*)/showinfo-(.+?)-(.+?)-(.+?)\.html$ $1/e/action/ShowInfo.php?classid=$2&id=$3&page=$4 last;
    rewrite ^([^\.]*)/infotype-(.+?)-(.+?)\.html$ $1/e/action/InfoType/index.php?ttid=$2&page=$3 last;
    rewrite ^([^\.]*)/tags-(.+?)-(.+?)\.html$ $1/e/tags/index.php?tagname=$2&page=$3 last;
    rewrite ^([^\.]*)/comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)\.html$ $1/e/pl/index.php?doaction=$2&classid=$3&id=$4&page=$5&myorder=$6&tempid=$7 last;
    
    if (!-e $request_filename) {
      return 404;
    }

 

  1. 12小时内

     
     
    <?=$empire->gettotal("select count(*) as total from [!db.pre!]ecms_表 where newstime > UNIX_TIMESTAMP() - 12*3600")?>
  2. 6小时内

     
     
    <?=$empire->gettotal("select count(*) as total from [!db.pre!]ecms_表 where newstime > UNIX_TIMESTAMP() - 6*3600")?>

 

原因

  1. 数据库还原后用户名不匹配:还原数据库后,原有的用户名可能与输入的用户名不一致。
  2. 用户名输入错误:用户在登录时输入的用户名错误。

解决方案

  1. 检查数据库用户名
    • 使用 phpMyAdmin 等工具进入数据库,查看 dede_admin 表中的用户名。
    • 确认用户名是否正确,如有误,进行修改。
  1. 修改 customfields.func.php 文件

    • 找到:
       
       
      $fvalue = trim($ntag->GetInnerText());
    • 修改为:
       
       
      $fvalue = ($ntag == "") ? trim($ntag) : trim($ntag->GetInnerText());
  2. 修改 img.lib.php 文件

    • 找到:
       
       
      $innerTmp = $arcTag->GetInnerText();
    • 修改为:
       
       
      $innerTmp = ($arcTag == "") ? trim($arcTag) : trim($arcTag->GetInnerText());

 

.dede_pages {
    text-align: right;
}

.dede_pages ul {
    float: right;
    padding: 12px 0px 12px 16px;
}

.dede_pages ul li {
    float: left;
    font-family: Tahoma;
    line-height: 17px;
    margin-right: 6px;
    border: 1px solid #E9E9E9;
}

.dede_pages ul li a {
    float: left;
    padding: 2px 4px 2px;
    color: #555;
    display: block;
}

.dede_pages ul li a:hover {
    color: #690;
    text-decoration: none;
    padding: 2px 4px 2px;
}

.dede_pages ul li.thisclass,
.dede_pages ul li.thisclass a,
.pagebox ul li.thisclass a:hover {
    background-color: #F8F8F8;
    padding: 2px 4px 2px;
    font-weight: bold;
}

.dede_pages .pageinfo {
    line-height: 21px;
    padding: 12px 10px 12px 16px;
    color: #999;
}

.dede_pages .pageinfo strong {
    color: #555;
    font-weight: normal;
    margin: 0px 2px;
}

 

Page 564 of 1049:« First« 561 562 563 564 565 566 567 »Last »
bottom-img