PHP PROJECT

README.md

Comments php class 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.

Files


NameTypeSizeLast Modified
config.php phpfile icon 617 08 December 2015 10:24:30
badwordslist.txt textfile icon 2213 08 December 2015 10:24:30
comment.php phpfile icon 3693 08 December 2015 10:24:30
like-dislike.php phpfile icon 1751 08 December 2015 10:24:30
comment-template.php phpfile icon 1705 08 December 2015 10:24:30
comment.sql sqlfile icon 468 01 February 2017 04:13:02
bootstrapcomment.php phpfile icon 7061 08 December 2015 10:24:30

Source

  1. <?php
  2. /**
  3.  * PHP Comment Class
  4.  * @author vishv23@yahoo.com - http://v23.in
  5.  * @version 1.0.0
  6.  * @date November 17, 2015
  7. */
  8. include "config.php";
  9. include "bootstrapcomment.php";
  10. //----------edit if require-------------------------------
  11. $fieldRequire=array("name"=>"","comment"=>"","uri"=>"","tm"=>"","pid"=>"");
  12. //-------------------------------------------------------
  13. $co = new comment2("localhost",$dbuser$dbpass,$dbname);
  14. if(isset($_REQUEST["name"]) && isset($_REQUEST["id"]))
  15. {
  16. foreach($fieldRequire as $k=>$v){
  17.         if(isset($_REQUEST[$k]))
  18.         $fieldRequire[$k]=$_REQUEST[$k];
  19.     }
  20. if(isset($_REQUEST['id']))    
  21. $fieldRequire['pid']=$_REQUEST['id'];
  22. if(isset($_REQUEST['uri']))    
  23. $fieldRequire['url']=$_REQUEST['uri'];
  24.  $co->save($fieldRequire['comment'],$fieldRequire['name'],$fieldRequire['url'],$fieldRequire['tm'],$_SERVER['REMOTE_ADDR'],$fieldRequire['pid']);    
  25. exit;
  26. }
  27. if(isset($_REQUEST["group_no"]) && $_REQUEST["type"] == "showcomment")
  28. {
  29. $items_per_group=10;
  30.     $group_number filter_var($_REQUEST["group_no"], FILTER_SANITIZE_NUMBER_INTFILTER_FLAG_STRIP_HIGH);
  31.     if(!is_numeric($group_number)){
  32.         exit();
  33.     }
  34.     $position = ($group_number $items_per_group);
  35.     $co->url=$_REQUEST["uri"];
  36.     
  37.     
  38. echo '<ul>';
  39. $res $co->fetchCategoryTree(0,$_REQUEST["uri"]," LIMIT $position$items_per_group");
  40. foreach ($res as $r) {
  41. echo  $r;
  42. }
  43. echo '</ul>';
  44. exit;
  45. }    
  46. if(isset($_REQUEST["type"]) && $_REQUEST["type"] == "like"){
  47. $co->like($_REQUEST["id"]);
  48.  if($r=$co->findDisLike($_REQUEST["id"]))
  49.  echo $r->like;
  50. }
  51. if(isset($_REQUEST["type"]) && $_REQUEST["type"] == "dislike"){
  52. $co->dislike($_REQUEST["id"]);
  53.  if($r=$co->findDisLike($_REQUEST["id"]))
  54.  echo $r->dislike;
  55. }
  56. exit;
  57. ?>

Demo

You can find a demo available here: bootstrap comment

Requirment

  • mySql
  • PHP >= 5.4
  • Apache Server

Contribute

  • Vishv Sahdev

Example

>>

Download