View file fk/fk/add_foto.php

File size: 3.02Kb
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';

include_once '../sys/inc/thead.php';

only_reg();

$set['title']='Добавление фото';
title();
aut();
err();



$id = intval($_GET['id']);
$fk=mysql_fetch_assoc(mysql_query("SELECT * FROM `fk` WHERE `id` = '".$id."' "));
if(!isset($id) or $fk['name'] == null){
header("Location: index.php?".SID); }


 

$pr_foto = mysql_result(mysql_query("SELECT COUNT(*) FROM `fk_foto` WHERE `id_fk` = '".$id."' and `id_user` = '".$user['id']."' "),0);
$max_uch = mysql_result(mysql_query("SELECT COUNT(*) FROM `fk_foto` WHERE `id_fk` = '".$id."' "),0);

if($pr_foto != 0) { $err = 'Вы уже добавили фото!'; }

elseif ($max_uch >= $fk['kol_vo']) {  $err = 'В фотоконкурсе учавствует максимальное количество участников!';   }

elseif ($fk['active'] == 0) {  $err = 'Фотоконкурс закрыт!';   }

else {




/////////////////////////////////////////
if(isset($_POST['add'])){

	 $imag = my_esc($_FILES['imag']['name']);
	$type = $_FILES['imag']['type'];

	 
	 if(empty($imag) ){
	     $err= 'Выберите фото!';
	 } 
 elseif ($type!=='image/jpeg' && $type!=='image/jpg' && $type!=='image/gif' && $type!=='image/png')
 {$err='Это же не фото!';
}
	 
	 else {
	 $ras1 = explode(".",$imag);
	 $ras1 = end($ras1);
	 $name_1 = time()."1.$ras1";
	 
	 
	 
	     if(copy($_FILES['imag']['tmp_name'], H.'fk/images/'.$name_1))
		 {
		 
		
		 
mysql_query("INSERT INTO `fk_foto` (`id_fk`, `id_user`, `golosov`, `active`, `time`, `images`) 
values('".$id."', '".$user['id']."', '0', '1', '".$time."', '".$name_1."' )");

mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) 
values('0', '".$user['id']."', 'Вы получили [b]$fk[uchastie][/b] баллов, за то, что добавили фото в фотоконкурс [url=/fk/konkurs.php?id=$id][b]$fk[name][/b][/url]', '$time')");


mysql_query("UPDATE `user` SET `balls` = `balls`+'".$fk['uchastie']."'  where `id` =  '".$user['id']."'  ");

 

 header("Location: konkurs.php?id=".$id."".SID); 

		 }
	 }
}



echo "<div class='main_menu'>
<form action='?id=".$id."' enctype='multipart/form-data' method='post'>
Фото на фотоконкурс: <br/> 
<input type='file' name='imag'/><br/> 

<input type='submit' name='add' value='Добавить'/><br/> 
</form>
</div>";

}

err();







echo '<div class="foot"><img src="/style/icons/str2.gif"> <a href="konkurs.php?id='.$id.'">Назад</a></div>';
echo '<div class="foot"><img src="img/fk.png"> <a href="index.php">Фотоконкурсы</a></div>';








include_once '../sys/inc/tfoot.php';
?>