Просмотр файла moduls/cool_news.php

Размер файла: 1.28Kb
<?php
/**********************************************/
/* Автор скрипта: Александр Есин              */
/* E-Mail: [email protected] ([email protected]) */
/* ICQ: 6464729                               */
/* Site: http://ticlove.ru                    */
/**********************************************/
?>
<?php define ('SECURED', true); ?>
<?php require (dirname(__FILE__).'/../_inc/sql.php'); ?>
<?php require (dirname(__FILE__).'/../_inc/config.php'); ?>
<?php require (dirname(__FILE__).'/../_inc/function.php'); ?>
<?php
	 if (!empty($_SESSION['auth_id']) && (intval($_POST['user_id']) == $_SESSION['auth_id']))
	 {
	      $user_id = intval($_POST['user_id']);
	      $news_id = intval($_POST['news_id']);
	      if (!empty($news_id))
	      {
	           if (mysql_num_rows(mysql_query("SELECT * FROM `q_news_class` WHERE `id_news` = '".$news_id."' AND `id_user` = '".$user_id."' LIMIT 1;")) == 0)
		   {
		        if (mysql_query("INSERT INTO `q_news_class` (`id_news`, `id_user`) VALUES ('".$news_id."', '".$user_id."');"))
			{
			     $cool_all = mysql_result(mysql_query("SELECT COUNT(*) FROM `q_news_class` WHERE `id_news` = '".$news_id."';"), 0);
			     echo ($cool_all > 1 ? 'Вы и '.($cool_all - 1) : 'Вы');
			}
	      }
	      }
	 }
?>