View file xmyx.ru/albums/act/create.php

File size: 2.5Kb
<?php defined('ACCESS') OR die('No direct script access...');

/*
* Author - Tw1nGo
* VK - https://vk.com/tw1ngo93
*/

if (isset($user))$ank['id'] = $user['id'];

if (!isset($user) && $user['id'] != $ank['id']){ 
	header("Location: /?".SID);
	exit; 
}

if (isset($user) && $user['id'] == $ank['id'])
{

// Кнопка отмены
if (isset($_POST['cancel'])){
	header("Location: ?uid=$ank[id]".SID);
	exit;
}

if (isset($_POST['cfms']) && isset($_POST['name']) && isset($_POST['msg'])){

$name = my_esc($_POST['name']);
if (strlen2($name) < 3)$err = 'Короткое название, min: 3.';
if (strlen2($name) > 50)$err = 'Большое название, max: 50.';

$access = intval($_POST['access']);

$msg = $_POST['msg'];
		
if (strlen2($msg) > 250)$err = 'Большое описание, max: 250.';
$msg = my_esc($msg);
		
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `photos` WHERE `id_user` = '$ank[id]' AND `name` = '$name'"),0) != 0)
$err = 'У Вас уже есть такой альбом!';	
		
if (!isset($err)){
	mysql_query("INSERT INTO `photos` (`msg`, `time_create`, `id_user`, `name`, `time`, `access`) values('$msg', '$time', '$ank[id]', '$name', '$time', '$access')");
	$photos_id = mysql_insert_id();
	
	$_SESSION['message'] = 'Фотоальбом успешно создан';
	header("Location: ?uid=$ank[id]");
	exit;
}
}

thead('Создание альбома');

?>
<div class="page_block fit_box new_form photos" style="padding: 0 10px 10px;">
<form action="?act=create" method="post">
<dl class="fi_row">
<dt class="fi_label">Название: <span style="float: right;color: #C3C3C3;">max: 50</span></dt>
<dd>
<input class="textfield" name="name" value="" placeholder="Название" type="text">
</dd>
</dl>
<dl class="fi_row">
<dt class="fi_label">Описание: <span style="float: right;color: #C3C3C3;">не обязательно</span></dt>
<dd>
<textarea class="textfield" placeholder="Описание" name="msg"></textarea>
</dd>
</dl>
<dl class="fi_row">
<dt class="fi_label">Могут смотреть:</dt>
<dd>
<select id="m_status" name="access"> 
<option value="0" selected="selected">Все пользоватеи</option> 
<option value="1">Только друзья </option> 
<option value="2">Только я</option> 
</select>
</dd>
</dl>	
<div class="fi_row">
<input class="flat_button button_small" type="submit" name="cfms" value="Создать" /> 
<input class="flat_button button_small" type="submit" name="cancel" value="Отмена" />
</div>
</form>
</div>
<?

}