Path : /var/www/html/main/
File Upload :
Current File : /var/www/html/main/fetch-pages-like.php

<?php
error_reporting(E_ALL);
ini_set("display_errors", 0);

include('config.php');

$_GET["page"] = filter_var($_POST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH);
if(!is_numeric($_GET["page"])){
  header('HTTP/1.1 500 Invalid page number!');
  exit;
}

if($_POST['lang']=="TH"){
  include_once('lang/th.php');
}else{
  include_once('lang/eng.php');
}
?>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
<?php
$sql = "select * from ap_pages where id='$_POST[id]'";
$query = mysqli_query($conn,$sql);
$rows = mysqli_fetch_array($query);
mysqli_query($conn,"update ap_pages set likes='".($rows['likes']+1)."' where id='$_POST[id]'");

$query = mysqli_query($conn,$sql);
$rows = mysqli_fetch_array($query);

/*$xlen = strlen($rows['likes']);
if($xlen==1){
  $xl =  "<img src=\"icons/star.svg\" width=\"20px\">";
}elseif($xlen==2){
  $xl = "<img src=\"icons/star.svg\" width=\"20px\"><img src=\"icons/star.svg\" width=\"20px\">";
}elseif($xlen==3){
  $xl = "<img src=\"icons/star.svg\" width=\"20px\"><img src=\"icons/star.svg\" width=\"20px\"><img src=\"icons/star.svg\" width=\"20px\">";
}elseif($xlen==4){
  $xl = "<img src=\"icons/star.svg\" width=\"20px\"><img src=\"icons/star.svg\" width=\"20px\"> <img src=\"icons/star.svg\" width=\"20px\"><img src=\"icons/star.svg\" width=\"20px\">";
}elseif($xlen==5 || $xlen>5){
  $xl = "<img src=\"icons/star.svg\" width=\"20px\"><img src=\"icons/star.svg\" width=\"20px\"><img src=\"icons/star.svg\" width=\"20px\"><img src=\"icons/star.svg\" width=\"20px\"><img src=\"icons/star.svg\" width=\"20px\">";
}else{
  $xl = "";
}*/

$xlen = $rows['likes'];
if($xlen<=10){
  $xl =  "<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>";
}elseif($xlen>10 && $xlen<=20){
  $xl = "<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
  <i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>";
}elseif($xlen>20 && $xlen<=30){
  $xl = "<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
  <i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
  <i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>";
}elseif($xlen>30 && $xlen<=40){
  $xl = "<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
  <i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
  <i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
  <i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>";
}elseif($xlen>40){
  $xl = "<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
  <i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
  <i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
  <i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
  <i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>";
}else{
  $xl = "";
}

echo $ap_publish." ".dateThai($rows['date_time'])." <a onclick=\"pagesLike_$_POST[id]();\" title=\"Like\"><i class=\"far fa-thumbs-up\" style=\"font-size:18px;color:blue\"></i></a> $rows[likes] $xl";

if($rows['counters']>0){ 
?>
<i class="fa fa-signal" style="font-size:18px;color:red"></i> <span class="badge bg-success text-white"><?php echo number_format($rows['counters']) ?></span>
<?php 
}
?>
<a class="btn-floating btn-fb" href="javascript:void(0);" onClick="window.open('https://www.facebook.com/sharer.php?u=<?php echo urlencode("$ap_site$ap_folder?page_id=$rows[id]&lang=$rows[lang]"); ?>','facebook','scrollbars=yes,resizable=yes,width=1000,height=600')"><i class="fas fa-share text-danger"> Share </i></a>
<?php
/*include('logs.php');*/

mysqli_close($conn);
?>