Просмотр файла status/like.php

Размер файла: 1.12Kb
  1. <?php
  2.  
  3. require '../inc/func.php';
  4. bk_head('Like');
  5. require '../inc/head.php';
  6. $id = num($_GET['id']);
  7.  
  8. if(empty($id)){
  9. $id =1;
  10. }
  11. $ch_id = mysql_query("SELECT `id` FROM `status` WHERE `id` = '".$id."' ");
  12. if(!mysql_num_rows($ch_id)){
  13. header('location: list.php?id=1');
  14. }
  15. $status=mysql_fetch_array(mysql_query("select * from `status` where `id`='".$id."';"));
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. if (isset($_GET['like']) && isset($user))
  23. {
  24. if (mysql_result(mysql_query("SELECT COUNT(*) FROM `status_like` WHERE `id_status` = '".$id."' AND `id_user` = '$userid' LIMIT 1"),0)!=0){} else {
  25. mysql_query("INSERT INTO `status_like` (`id_user`, `id_status`) values('$userid', '".$id."')");}
  26.  
  27. if(isset($user) && $userid!=$status['from_id']){
  28.  
  29. mysql_query("INSERT INTO `notice` (`id_id`, `type`,`id_from`,`id_user`,`time`) values('$id', 'l', '$userid', '$status[from_id]','".time()."')");
  30. }
  31. header('Location: list.php?id='.$id.'');
  32. }
  33. if (isset($_GET['unlike']) && isset($user))
  34. {
  35. mysql_query("DELETE FROM `status_like` WHERE `id_user` = '$userid' AND `id_status` = '".$id."' LIMIT 1");
  36. mysql_query("OPTIMIZE `status_like`");
  37. header('Location: list.php?id='.$id.'');
  38. }
  39. bk_foot();
  40.  
  41. ?>