View file moduls/photo_vote.php

File size: 1.58Kb
<?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']))
	 {
	      if (!empty($_POST['user_uid']) && !empty($_POST['vote']))
	      {
	           $user_id = intval($_POST['user_id']);
	           $user_uid = intval($_POST['user_uid']);
	           $vote = intval($_POST['vote']);
	           $foto_id = intval($_POST['foto_id']);
	           
		   if ($vote < 1 or $vote > 5) $vote = 5;
		   $q = mysql_query("SELECT * FROM `q_photo_vote` WHERE `id_user` = '".$user_id."' AND `id_foto` = '".$foto_id."' LIMIT 1;");
		   if (mysql_num_rows($q) == 0)
		   {
		        if (mysql_query("INSERT INTO `q_photo_vote` (`id_user`, `id_foto`, `uid_user`, `asses`, `time`) VALUES ('".$user_id."', '".$foto_id."', '".$user_uid."', '".$vote."', '".time()."');"))
		        {
		        ?>
			<table border="0" cellspacing="0" cellpadding="0">
			<tr>
			<td>Ваша оценка</td>
			<td><div class="vote v<?php echo $vote; ?>"></div></td>
			</tr>
			</table>
			<?php
		        }
		   }
	      }
	 }
?>