View file status/like.php

File size: 1.12Kb
<?php

require '../inc/func.php';
bk_head('Like');
require '../inc/head.php';
$id = num($_GET['id']);

if(empty($id)){
$id =1;
}
$ch_id = mysql_query("SELECT `id` FROM `status` WHERE `id` = '".$id."' ");
if(!mysql_num_rows($ch_id)){
header('location: list.php?id=1');
}
$status=mysql_fetch_array(mysql_query("select * from `status` where `id`='".$id."';"));






if (isset($_GET['like']) && isset($user))
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `status_like` WHERE `id_status` = '".$id."' AND `id_user` = '$userid' LIMIT 1"),0)!=0){} else {
mysql_query("INSERT INTO `status_like` (`id_user`, `id_status`) values('$userid', '".$id."')");}

if(isset($user) && $userid!=$status['from_id']){

mysql_query("INSERT INTO `notice` (`id_id`, `type`,`id_from`,`id_user`,`time`) values('$id', 'l', '$userid', '$status[from_id]','".time()."')");
}
header('Location: list.php?id='.$id.'');
}
if (isset($_GET['unlike']) && isset($user))
{
mysql_query("DELETE FROM `status_like` WHERE `id_user` = '$userid' AND `id_status` = '".$id."' LIMIT 1");
mysql_query("OPTIMIZE `status_like`");
header('Location: list.php?id='.$id.'');
}
bk_foot();

?>