Advertisement
SSYT

like.php

May 10th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.15 KB | None | 0 0
  1. <?php
  2.     header('Access-Control-Allow-Origin: http://myscripts.forumz.ro');
  3.     $mysql = mysql_connect("localhost", "u719064522_bitcd", "5vEelfGVsC") or die(mysql_error());
  4.     if(!$mysql)
  5.         print("Conexiunea cu serverul a esuat !");
  6.     $database = mysql_select_db("u719064522_stupd") or die(mysql_error());
  7.     if(!$database)
  8.         print("Conexiunea cu baza de date a esuat !");
  9.    
  10.     if (strpos($_SERVER['HTTP_REFERER'], 'myscripts.forumz.ro')) {
  11.         if(isset($_GET['query']) || isset($_POST['post_id']))
  12.         {
  13.             $like = array(
  14.                 "date" => date("j M"),
  15.                 "post" => $_POST['post_id'],
  16.                 "count" => $_POST['like_count'],
  17.                 "author" => $_POST['post_author'],
  18.                 "pep_like" => $_POST['user']
  19.             );
  20.  
  21.             $coutn = $_POST['post_id'];
  22.             $sql_yt = "SELECT * FROM `likes` WHERE `PostID`=".$coutn."";
  23.             $result_3 = mysql_query($sql_yt);
  24.             $count_entry_db = mysql_num_rows($result_3);
  25.  
  26.             $sql_st = "SELECT * FROM `likes` WHERE `PostID`=".$coutn."";
  27.             $result_152 = mysql_query($sql_st);
  28.             $count_entry_db2 = mysql_num_rows($result_152);
  29.  
  30.             if($count_entry_db == 1)
  31.             {
  32.                 if ($_POST['post_author'] === $_POST['user']) {
  33.                     echo "Not like your post !";
  34.                 } else {
  35.                     $sql_11 = "SELECT `Count`, `People` FROM `likes` WHERE `PostID`=".$coutn."";
  36.                     $result_4 = mysql_query($sql_11);
  37.                     $rows = mysql_fetch_assoc($result_4);
  38.                     $curCount = $rows['Count'] + 1;
  39.                     if($rows['People'] == "") {
  40.                         $curPeople = "<a href=\"/u". $_POST['user_id_people'] ."\">".$_POST['user']."</a>"; } else {
  41.                         $curPeople = "<a class=\"class_user\" href=\"/u". $_POST['user_id_people'] ."\"><img src=\"". $_POST['avatars'] ."\">  ".$_POST['user']."</a>, ".$rows['People']."";
  42.                     }
  43.  
  44.                     $query_3 = "UPDATE `likes` SET `Count`=".$curCount.", `People`='". $curPeople ."' WHERE `PostID`=".$coutn."";
  45.                     mysql_query($query_3);
  46.  
  47.                     if($count_entry_db2 == 1) {
  48.                         $sds_1 = "SELECT `Count`, `Recive`, `Likes` FROM `user_likes` WHERE `User`=".$_POST['post_author']." LIMIT 1";
  49.                         $resu_1 = mysql_query($sds_1);
  50.                         $row = mysql_fetch_assoc($resu_1);
  51.                         $curCount = $row['Count'] + 1;
  52.                         $curReciv = $row['Recive'] + 1;
  53.                         $curLikes = $row['Likes'] + 1;
  54.                         $data_2 = "UPDATE `user_likes` SET `Count`='".$curCount."',`Recive`='".$curReciv."',`Likes`='".$curLikes."' WHERE `User`=".$_POST['post_author']."";
  55.                         mysql_query($data_2);
  56.                     }
  57.                     echo "Updated your like !";
  58.                 }
  59.             }
  60.  
  61.             if($count_entry_db == 0)
  62.             {
  63.                 if ($_POST['post_author'] === $_POST['user']) {
  64.                     return false;
  65.                 } else {
  66.                     $query_2 = "INSERT INTO `likes`(`PostID`, `Count`, `People`, `Author`, `Date`) VALUES ('".$like["post"]."','".$like["count"]."', '<a class=\"class_user\" href=\"/u". $_POST['user_id_people'] ."\"><img src=\"". $_POST['avatars'] ."\"> ".$_POST['user']."</a>', '<a href=\"/u". $_POST['user_id'] ."\">".$_POST['post_author']."</a>', '".$like["date"]."')";
  67.                 }
  68.                 mysql_query($query_2);
  69.                 echo "[". $count_entry_db ."] Inserted !";
  70.                 if($count_entry_db2 == 0) {
  71.                     $data_1 = "INSERT INTO `user_likes`(`User`, `Count`, `Recive`, `Likes`) VALUES ('".$_POST['post_author']."','1','1','0')";
  72.                     mysql_query($data_1);
  73.                 }
  74.             }
  75.         }
  76.     }
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement