PHP Classes

Bootstrap PHP Comment System with MySQL: Comments system with replies and like buttons

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (5)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 1,710 This week: 1All time: 2,299 This week: 560Up
Version License PHP version Categories
bootstrap-comment 1.0Freely Distributable5.0PHP 5, Databases, Content management
Description 

Author

This package implements a comments system with replies and like buttons.

It can display forms and buttons using the Bootstrap framework to let the user enter comments, replies to comments and click to like or dislike a comment.

The comments are saved to a MySQL database table accessed using the MySQLi extension.

The comment text is filtered to remove bad words read from a bad words list file.

Innovation Award
PHP Programming Innovation award nominee
December 2015
Number 4


Prize: One year server license IP to country, region, city, latitude, longitude, ZIP code, time zone, area code database
Comment systems are very useful to provide means for user interaction in sites that publish content of the interest of communities.

This package implements a complete comments system that includes comments, replies, like and dislike buttons and bad word filtering.

Manuel Lemos
Picture of Vishv Sahdev
  Performance   Level  
Name: Vishv Sahdev <contact>
Classes: 13 packages by
Country: India India
Age: 52
All time rank: 51530 in India India
Week rank: 106 Up8 in India India Up
Innovation award
Innovation award
Nominee: 7x

Recommendations

Comment On Post
I Want user can comment on post

upvote/downvote or like dislike system in php and mysql
I need to make upvote downvote or like and dislike system

What is the best PHP blog comment system class?
Need a script or advice for a blog commenting system

Example

<?
/**
 * PHP Comment Class
 * @author vishv23@yahoo.com - http://v23.in
 * @version 1.0.0
 * @date November 17, 2015
*/

include "config.php";
include
"bootstrapcomment.php";

//----------edit if require-------------------------------
$fieldRequire=array("name"=>"","comment"=>"");
//-----------------------------------------

$co = new bootstrapcomment("localhost",$dbuser, $dbpass,$dbname);

//------------------Save Comment---------------
if(isset($_POST['uri']) && $_POST['uri'] == $_SERVER['REQUEST_URI']){
$co->save($_POST['comment'],$_POST['name'],$_SERVER['REQUEST_URI'],time(),$_SERVER['REMOTE_ADDR'],$_POST['id']);
}

//-----------------------------------



$totalRow=$co->totalRows($_SERVER['REQUEST_URI']);

if(
$totalRow > $perPageDisplay )
$tgroup=round($totalRow / $perPageDisplay );
else
$tgroup=1;

$output['script'] = '<script>
  $(".replyin").hide();


   
      $(".rreply").click(function(){
        var id = $(this).attr("aria-value");
       
            if($(".replyin").is(":visible")){
                $(".replyin").hide();
                $("#id").val(0);
                 $("#freply").show();
            } else {
            $("#id").val(id);
                $(".replyin").show();
                  $("#freply").hide();
                  $("#name").focus();
            }
          
            return false;
        });
       
$(document).ready(function() {
$(".glyphicon-thumbs-up").one("click",function(){
var id = $(this).attr("aria-value");
$.post("/comment/like-dislike.php",{"type":"like","id":id}, function(data){

 
  


                    $("#UP"+id).text(" " +data);
                })
});

$(".glyphicon-thumbs-down").one("click",function(){
var id = $(this).attr("aria-value");
 $.ajax({
    url : "/comment/like-dislike.php",
    type: "POST",
    data : {"type": "dislike","id":id},
    success: function(data)
    {
       $("#DOWN"+id).text(" " +data);
    }
});
$(this).text(d + "v");
});
});
</script>
'
;

$output['maincontent'] ='
<p>ALL COMMENTS '
.$totalRow.'</p>
<div class="form-group rreply" id="freply">
      <input type="text" class="form-control ">
  </div>
 
<div class="form-group replyin">
 <form method="post" action="'
.$_SERVER['REQUEST_URI'].'" id="foo">
<input type="hidden" name="tm" value="'
.time().'"/>
<input type="hidden" name="uri" value="'
.$_SERVER['REQUEST_URI'].'"/>
<input type="hidden" name="id" id="id" value="0"/>
 <div class="form-group">
      <input type="text" class="form-control" id="name" name="name" placeholder="Name...">
  </div>
 
   <div class="form-group">
      <textarea class="form-control" id="comment" name="comment" row="5" placeholder="Add a public comment..."></textarea>
  </div>
  <div class="form-group">
      <button type="submit" class="btn btn-info" id="submit">Comment</button>
  </div>
</form>
  </div>

'
;

$output['maincontent'] .='<ul>';

$res=$co->fetchCategoryTree(0,$_SERVER['REQUEST_URI'],3," LIMIT 20");
  foreach (
$res as $r) {
   
$output['maincontent'] .= $r;
  }

$output['maincontent'] .= '</ul>';





$output['title']="Demo COMMENT";

$output['style']='
<style>
.showmore{padding: 10px;width: 80%; border: 1px solid #777;}
.showmore:hover{background-color: #ddd;}
.bg-info{padding: 10px;border: 1px solid #6CA6CD;font-weight: 700;}
#fo{
background-color: #e5f1ff;
border: 1px solid #b2d7ff;
padding-top: 10px;
margin-bottom: 10px;
}
.panel-body{padding: 10px; color: #777;}
span{
margin-right: 12px;
cursor: pointer;
}

span:hover{
opacity: .2;
}

glyphicon{

}
</style>'
;


if(
is_file( "comment-template.php"))
echo
$co->render_temp( "comment-template.php",array("output"=>$output));


unset(
$output);
?>


  boottstrapcommentExternal page  

Open in a separate window

  Files folder image Files  
File Role Description
Plain text file badwordslist.txt Data Badwords Filter file
Plain text file bootstrapcomment.php Class Class
Plain text file comment-template.php Aux. Template
Plain text file comment.php Example Example File
Plain text file comment.sql Data SQL Example
Plain text file config.php Conf. Config
Plain text file like-dislike.php Example Jquery Widget

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,710
This week:1
All time:2,299
This week:560Up