帝国cms接入第三方评论系统HashOver开源免费

时间:2023年08月08日

/

来源:网络

/

编辑:佚名

自己建站需要用到评论系统,系统自带的不错,但不美观。畅言免费版有广告并且是弹窗广告.去除广告需要收费.
那自己就找找吧! 看有没有合适的,在网络上一搜索,找到了这个分享给大家。
由 jacobwb发布在 github 上的开源项目,目前版本为2.0,共有两个分支;
网站:https://github.com/  
原版
HashOver 1.0.1
https://github.com/jacobwb/hashover  (原版1.0)
百度网盘链接: https://pan.baidu.com/s/1c1fG9nq6affLvcKFT3HGMQ 提取码: r1a2
分支版本
HashOver 2.0 (development)
https://github.com/jacobwb/hashover-next   //作者一直在持续更新
https://github.com/AndreaCatania/hashover-next  //AndreaCatania 的 分支版本
https://gitee.com/jiangfei1006/hashover  //国内开源项目平台
如果你保存的有之前多说的数据,那么你可以下载一个转换程序,将多说数据直接转换为 HashOver 数据。
转换程序国人开发,项目地址:https://github.com/JJYing/Duoshuo-to-Hashover 
作者:图月志 JJYing
下面来介绍一下 HashOver 评论系统的安装与使用。
1、先到上面的链接下载 HashOver,解压,将 hashover 目录上传到你网站目录。
2、在内容页模板中加入一下代码
<script type="text/javascript" src="/hashover/loader.php"></script>
//注意调取正确路径
3、在帝国cms公共模板变量评论模版内容加入 
<div id="hashover">
    <center id="loading">
        <img src="./hashover/images/loading-ltr.gif" alt="Loading..." width="90" height="30">
    </center>
</div>
其他说明:
<center id="loading">
        <img src="./hashover/images/loading-ltr.gif" alt="Loading..." width="90" height="30">
    </center>
//这里是加载提示,可以直接删除,或者自己制作一个gif 替换。
//但是  <div id="hashover"></div> 必须有
4、打开 hashover/backend/classes/secrets.php 进行配置
class Secrets
{
    // REQUIRED SETUP INFORMATION
 
    // E-mail for notification of new comments
    protected $notificationEmail = 'example@example.com';       //设置接收评论提醒的邮箱
 
    // Unique encryption key (case-sensitive)
    protected $encryptionKey = '8CharKey';                      //设置一个key 必须修改
 
    // Login name to gain admin rights (case-sensitive)
    protected $adminName = 'admin';                             //设置你评论管理的用户名  
 
    // Login password to gain admin rights (case-sensitive)
    protected $adminPassword = 'passwd';                        //设置你评论管理的密码
 
    // OPTIONAL SQL INFORMATION
 
    // Type of database, sqlite or mysql
    protected $databaseType = 'sqlite';                          //设置你评论系统的数据库类型(可以不改)
 
    // Database name
    protected $databaseName = 'hashover-threads';                //设置为mysql后的数据库名
 
    // SQL database host name
    protected $databaseHost = 'localhost';                       //设置为mysql后的数据地址
 
    // SQL database login user
    protected $databaseUser = 'root';                            //设置为mysql后的数据库用户名
 
    // SQL database login password
    protected $databasePassword = 'password';                    //设置为mysql后的数据库密码
  
    // SQL database character set
    protected $databaseCharset = 'utf8';                         //这个还需要在解释一下的话,你就不适合做站长
   
    // OPTIONAL SMTP MAILER SETUP
 
    // SMTP server host name                                      //以下是邮件设置,默认使用sendmail发送邮件,当你设置为smtp发送时下面的设置才会生效,当然,你可以在后台设置发送邮件的方式。
    protected $smtpHost = 'smtp.gmail.com';                       //SMTP地址                   
 
    // SMTP server port number                                    //SMTP端口
    protected $smtpPort = 465;
 
    // SMTP server encryption method        
    protected $smtpCrypto = 'ssl';                                //SMTP加密
 
    // SMTP server requires login authentication
    protected $smtpAuth = true;
 
    // SMTP server user
    protected $smtpUser = 'user';                                 //SMTP用户名
 
    // SMTP server password
    protected $smtpPassword = 'password';                         //SMTP密码
}
完成上面的设置你的 HashOver 就已经可以用了。访问 /hashover/admin来设置 ,用你刚刚设置的用户名和密码登陆,登陆后在设置中,可以将语言设置为简体中文。然后评论系统的设置也都在这里面。
评论框上面有 名称、密码、邮件、网址 四个字段,通常密码字段是不需要的。后台无法关闭和控制这些。
需要打开   hashover/backend/classes/settings.php文件来进行设置。
class SafeSettings
{
    // Primary settings
    public $language        = 'auto';            // UI language, for example 'en', 'de', etc. 'auto' to use system locale
    public $theme            = 'default';            // Comment Cascading Style Sheet (CSS)
    public $allowsImages        = true;                // Whether external image URLs wrapped in [img] tags are embedded
    public $allowsLikes        = true;                // Whether a "Like" link is displayed
    public $allowsDislikes        = false;            // Whether a "Dislike" link is displayed; allowing Reddit-style voting
    public $usesAjax        = true;                // Whether AJAX is used for posting, editing, and loading comments
    public $collapsesInterface    = false;            // Whether the comment form, thread, and end links are all initially hidden
    public $collapsesComments    = true;                // Whether to hide comments and display a link to show them
    public $collapseLimit        = 3;                // Number of comments that aren't hidden
    public $replyMode        = 'thread';            // Whether to display replies as a 'thread' or as a 'stream'
    public $streamDepth        = 3;                // In stream mode, the number of reply indentions to allow before the thread flattens
    public $popularityThreshold    = 5;                // Minimum likes a comment needs to be popular
    public $popularityLimit        = 2;                // Number of comments allowed to become popular
    public $usesMarkdown        = true;                // Whether comments will be parsed for Markdown
 
    // Date and Time settings
    public $serverTimezone        = 'America/Los_Angeles';    // Server timezone
    public $usesUserTimezone    = true;                // Whether comment dates should use the user's timezone (JavaScript-mode)
    public $usesShortDates        = true;                // Whether comment dates are shortened, for example "X days ago"
    public $timeFormat        = 'g:ia';            // Time format, use 'H:i' for 24-hour format (see: http://php.net/manual/en/function.date.php)
    public $dateFormat        = 'm/d/Y';            // Date format (see: http://php.net/manual/en/function.date.php)
 
    // Field options, use true/false to enable/disable a field,
    // use 'required' to require a field be properly filled
    public $fieldOptions = array (
        'name'     => true,                #是否显示名称字段 true为显示 false为不显示
        'password' => true,                #是否显示密码字段 true为显示 false为不显示
        'email'    => true,                #是否显示邮箱字段 true为显示 false为不显示
        'website'  => true                 #是否显示网址字段 true为显示 false为不显示
    );
 
    // Behavior settings
    public $displaysTitle        = true;                // Whether page title is shown or not
    public $formPosition        = 'top';            // Position for primary form; options: 'top' or 'bottom'
    public $showsReplyCount        = true;                // Whether to show reply count separately from total
    public $countIncludesDeleted    = true;                // Whether comment counts should include deleted comments
    public $iconMode        = 'image';            // How to display avatar icons (either 'image', 'count' or 'none')
    public $iconSize        = 45;                // Size of Gravatar icons in pixels
    public $imageFormat        = 'png';            // Format for icons and other images (use 'svg' for HDPI)
    public $usesLabels        = false;            // Whether to display labels above inputs
    public $usesCancelButtons    = true;                // Whether forms have "Cancel" buttons
    public $appendsCss        = true;                // Whether to automatically add a CSS <link> element to the page <head>
    public $appendsRss        = true;                // Whether a comment RSS feed link is displayed
 
    // Technical settings
    public $subscribesUser        = true;                // Whether to subscribe the user to e-mail notifications by default
    public $allowsUserReplies    = false;            // Whether given e-mails are sent as reply-to address to users
    public $gravatarDefault        = 'custom';            // Gravatar theme to use ('custom', 'identicon', 'monsterid', 'wavatar', or 'retro')
    public $gravatarForce        = false;            // Whether to force the themed Gravatar images instead of an avatar image
    public $minifiesJavascript    = false;            // Whether JavaScript output should be minified
    public $minifyLevel        = 4;                // How much to minify JavaScript code, options: 1, 2, 3, 4
}
如果你的评论跟网站不在同一台服务器的话,还需要设置一个授权域名,
打开 hashover/backend/classes/sensitivesettings.php  
class SensitiveSettings extends SafeSettings
{
    // Primary settings
    public $dataFormat        = 'xml';            // Format comments will be stored in; options: xml, json, sql
    public $defaultName        = 'Anonymous';            // Default name to use when one isn't given
    public $allowsLogin        = true;                // Whether users can login and logout (when false form cookies are still set)
    public $usesModeration        = false;            // Whether comments must be approved before they appear to other visitors
    public $pendsUserEdits        = false;            // Whether comments need to be approved again when edited
 
    // E-mail settings
    public $mailer            = 'sendmail';            // How to send notification e-mails, either 'sendmail' or 'smtp'
    public $mailType        = 'text';            // What format to send e-mails in, either 'text' or 'html'
    public $noreplyEmail        = 'noreply@example.com';    // E-mail used when no e-mail is given
 
    // Behavior settings
    public $usesAutoLogin        = true;                // Whether a user's first comment automatically logs them in
 
    // Technical settings
    public $loginMethod        = 'defaultLogin';        // Login method class for handling user login information
    public $setsCookies        = true;                // Whether cookies are enabled
    public $secureCookies        = false;            // Whether cookies set over secure HTTPS will only be transmitted over HTTPS
    public $storesIpAddress        = false;            // Whether to store users' IP addresses
    public $spamDatabase        = 'remote';            // Whether to use a remote or local spam database
    public $spamCheckModes        = 'php';            // Perform IP spam check in 'json' or 'php' mode, or 'both'
    public $enabledApi        = array ('all');        // An array of enabled API. 'all' = fully-enabled, empty array = fully disabled
    public $latestMax        = 10;                // Maximum number of comments to save as latest comments
    public $latestTrimWidth        = 100;                // Number of characters to trim latest comments to, 0 for no trim
    public $userDeletionsUnlink    = false;            // Whether user deleted files are actually unlinked from the filesystem
    public $allowLocalMetadata    = false;            // Whether default metadata should be collected while running on a local server
 
    // Types of images allowed to be embedded in comments
    public $imageTypes = array (
        'jpeg',
        'jpg',
        'png',
        'gif'
    );
 
    // External domains allowed to remotely load HashOver scripts
    public $allowedDomains = array (
        '127.0.0.1:8000'                 //这里给出了修改案例,按照你的域名设置即可!
        // '*.example.com',
        // '*.example.org',
        // '*.example.net'
    );
}
除了上面做了中文备注的地方需要修改以外其他的都不需要修改,后台设置即可。
注意事项:
1、修改时区 ,在后台设置中找到 “在用户的时区(JavaScript模式)中显示日期/时间” 选项,将后面的  “America/Los_Angeles” 修改为 “Asia/Shanghai”  时间就会按照 我们的 +8 时区来显示!
2、最新的评论默认是显示在下面,修改方法可以通过js来修改。
 
#如果是香港主机,加载慢,强制让他生效。
window.addEventListener('load',function() {
    $("#hashover-sort-select").val("threaded-by-date").change();
    $("#hashover-end-links").remove();
},false);
window.onload = function() {
    $("#hashover-sort-select").val("threaded-by-date").change();
    $("#hashover-end-links").remove();  
}
$(window).load(function() {
    $("#hashover-sort-select").val("threaded-by-date").change();
    $("#hashover-end-links").remove();   
})
 
$(document).ready(function() {
    $("#hashover-sort-select").val("threaded-by-date").change();
    $("#hashover-end-links").remove(); 
});
$(function() {
    $("#hashover-sort-select").val("threaded-by-date").change();
    $("#hashover-end-links").remove();
});
 
function jiangfei() {
    $("#hashover-sort-select").val("threaded-by-date").change();
    $("#hashover-end-links").remove(); 
}
setTimeout(function() {
    $("#hashover-sort-select").val("threaded-by-date").change();
    $("#hashover-end-links").remove();
},500);
setTimeout(function() {
    $("#hashover-sort-select").val("threaded-by-date").change();
    $("#hashover-end-links").remove();
},1000);
setTimeout(function() {
    $("#hashover-sort-select").val("threaded-by-date").change();
    $("#hashover-end-links").remove();
},1500);
setTimeout(function() {
    $("#hashover-sort-select").val("threaded-by-date").change();
    $("#hashover-end-links").remove();   
},2000);
#如果你是国内主机,只要下面这句就行!
$("#hashover-sort-select").val("threaded-by-date").change(); #模拟点击排序为新评论优先显示而已。
$("#hashover-end-links").remove();  #这句删除下面的链接信息!
一起研究学习吧!
猜你需要

豫ICP备2021026617号-1  豫公网安备:41172602000185   Copyright © 2021-2028 www.78moban.com/ All Rights Reserved

本站作品均来自互联网,转载目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵犯您的版权,请联系 1565229909#qq.com(把#改成@),我们将立即处理。