<?php

// mod like for Johncms with notify (reversion 1.0)
// keep this line as thanks to the writer
// support site : http://natocms.com

defined('_IN_JOHNCMS') or die('Error: restricted access');

if ($user_id) {
    $nato = ''.getenv("HTTP_REFERER").'';
    if(!empty($nato)){
    $already_like = mysql_result(mysql_query("select count(*) from forum_like where user_id = '$user_id' and id = '$id' "), 0);
    $userid = mysql_query("select refid, user_id from forum where id = '$id'");
    $user = mysql_fetch_assoc($userid);
    $idchude = $user['refid'];
    $tenchude = mysql_query("select text from forum where type = 't' and id = '$idchude'");
    $chktcd = mysql_fetch_assoc($tenchude); $text = ''.$chktcd['text'].'';
    $n = $user['user_id'];
    $nick = mysql_query("select id from users where id = '$n' ");
    $chk = mysql_fetch_assoc($nick);
    $c = $chk['id'];
    $page = $set_forum['upfp'] ? 1 : ceil(mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `type` = 'm' AND `refid` = '$idchude'" . ($rights >= 7 ? '' : " AND `close` != '1'")), 0) / $kmess);
    if($already_like == 1 && $user_id != $c) {
    mysql_query("UPDATE `users` SET `likes` = likes - 1 WHERE `id` = '$c' ");
    mysql_query("DELETE FROM `forum_like` WHERE `user_id` = '$user_id' AND `id` = '$id'");
    mysql_query("insert into `cms_mail` set `user_id` = '1', `from_id` = '$c', `text` = '".$login." just unlike your post in theme [url=".$home."/forum/index.php?id=".$idchude."&page=".$page."#".$id."]".$text."[/url]', `time` = '".time()."', `read` = '0', `sys` = '1', `delete` = '0', `count` = '0', `size` = '0', `spam` = '0', `them` = 'About theme ".$text."' ");
    }
    header("Location: $nato");
    } else { require('../incfiles/head.php');
                echo functions::display_error($lng['error_wrong_data']);
        require('../incfiles/end.php');
        exit; }
} else { 
        require('../incfiles/head.php');
                echo functions::display_error($lng['access_guest_forbidden']);
        require('../incfiles/end.php');
        exit;
}

?>