Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Access-Control-Allow-Origin: http://myscripts.forumz.ro');
- $mysql = mysql_connect("localhost", "u719064522_bitcd", "5vEelfGVsC") or die(mysql_error());
- if(!$mysql)
- print("Conexiunea cu serverul a esuat !");
- $database = mysql_select_db("u719064522_stupd") or die(mysql_error());
- if(!$database)
- print("Conexiunea cu baza de date a esuat !");
- if (strpos($_SERVER['HTTP_REFERER'], 'myscripts.forumz.ro')) {
- if(isset($_GET['query']) || isset($_POST['post_id']))
- {
- $like = array(
- "date" => date("j M"),
- "post" => $_POST['post_id'],
- "count" => $_POST['like_count'],
- "author" => $_POST['post_author'],
- "pep_like" => $_POST['user']
- );
- $coutn = $_POST['post_id'];
- $sql_yt = "SELECT * FROM `likes` WHERE `PostID`=".$coutn."";
- $result_3 = mysql_query($sql_yt);
- $count_entry_db = mysql_num_rows($result_3);
- $sql_st = "SELECT * FROM `likes` WHERE `PostID`=".$coutn."";
- $result_152 = mysql_query($sql_st);
- $count_entry_db2 = mysql_num_rows($result_152);
- if($count_entry_db == 1)
- {
- if ($_POST['post_author'] === $_POST['user']) {
- echo "Not like your post !"
- } else {
- $sql_11 = "SELECT `Count`, `People` FROM `likes` WHERE `PostID`=".$coutn."";
- $result_4 = mysql_query($sql_11);
- $rows = mysql_fetch_assoc($result_4);
- $curCount = $rows['Count'] + 1;
- if($rows['People'] == "") {
- $curPeople = "<a href=\"/u". $_POST['user_id_people'] ."\">".$_POST['user']."</a>"; } else {
- $curPeople = "".$rows['People'].", <a href=\"/u". $_POST['user_id_people'] ."\">".$_POST['user']."</a>";
- }
- $query_3 = "UPDATE `likes` SET `Count`=".$curCount.", `People`='". $curPeople ."' WHERE `PostID`=".$coutn."";
- mysql_query($query_3);
- if($count_entry_db2 == 1) {
- $sds_1 = "SELECT `Count`, `Recive`, `Likes` FROM `user_likes` WHERE `User`=".$_POST['post_author']." LIMIT 1";
- $resu_1 = mysql_query($sds_1);
- $row = mysql_fetch_assoc($resu_1);
- $curCount = $row['Count'] + 1;
- $curReciv = $row['Recive'] + 1;
- $curLikes = $row['Likes'] + 1;
- $data_2 = "UPDATE `user_likes` SET `Count`='".$curCount."',`Recive`='".$curReciv."',`Likes`='".$curLikes."' WHERE `User`=".$_POST['post_author']."";
- mysql_query($data_2);
- }
- echo "Updated your like !";
- }
- }
- if($count_entry_db == 0)
- {
- $query_2 = "INSERT INTO `likes`(`PostID`, `Count`, `People`, `Author`, `Date`) VALUES ('".$like["post"]."','".$like["count"]."', '', '<a href=\"/u". $_POST['user_id'] ."\">".$_POST['post_author']."</a>', '".$like["date"]."')";
- mysql_query($query_2);
- echo "[". $count_entry_db ."] Inserted !";
- if($count_entry_db2 == 0) {
- $data_1 = "INSERT INTO `user_likes`(`User`, `Count`, `Recive`, `Likes`) VALUES ('".$_POST['post_author']."','1','1','0')";
- mysql_query($data_1);
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement