View file news-ds/list_edit/index.php

File size: 3.14Kb
<?
	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';

	user_access('adm_news',null,'index.php?'.SID);

	define ('id', isset( $_GET['id'] ) ? abs(intval($_GET['id'])) : 0);	

	$act = mysql_fetch_assoc(mysql_query("SELECT * FROM `news_list` WHERE `id` = '".id."' LIMIT 1"));	
	$name = htmlspecialchars($act['name']);

	// проверяем существует категория
	
	if (!empty($act)) {


	if (isset($_POST['save']) && isset($user))
	{
	$name = htmlspecialchars( $_POST['name'] );
	
	if (strlen2($name) > 501){ $err = 'Название слишком длинная'; }
	if (strlen2($name) < 3){ $err = 'Название слишком короткое'; }
	
	if(!isset($err))
	{
	mysql_query("UPDATE `news_list` SET `name` = '$name', `user` = '$user[id]' WHERE `id` = '$act[id]' LIMIT 1");
	
	$_SESSION['message'] = 'Категория изменена ';
	header ("Location: /news/list/act.php?id=".$act['id']."" . SID);
	exit;
	
	}
	}

// заголовок страницы

	$set['title'] = 'Новости : Категории : Редактирование'; 
	
// head	

	include_once '../../sys/inc/thead.php';
	
	title();
	aut();
	err();

	echo'
	<link rel="stylesheet" href="/news/style.css" type="text/css">
	<div class="main_bg">
	<div class="lc_br wbg font0 relative oh" id="header_path">  
	<a href="/" style="font-size:0;"> <img src="/news/ico/home.png" alt=""> </a>       
	<span class="lc_brw"> 
	<img src="/news/ico/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">
	<a href="/news/">Новости</a></span>
	<span class="lc_brw"> 
	<img src="/news/ico/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">
	<a href="/news/list/">Категории</a></span>
	<span class="lc_brw"> 
	<img src="/news/ico/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">
	<a href="/news/list/act.php?id='.$act['id'].'">'.$name.'</a></span>
	<span class="lc_brw"> 
	<img src="/news/ico/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">
	Редактирование</span></span>	
	</div></div>
	<form method="post">
	<div class="wrapper"> 
	<div class="block"> 
	<div>  
	<div class="grey" style ="margin-bottom: 6px;">Название  (500 знаков): </div> 
	<div class="input-txt_wrapper"> 
	<input class="input-txt" type="text" name="name" value="'.$name.'" maxlength="500">
	</div>     
	</div>
	</div></div>
	<table class="table__wrap">
	<tbody><tr> <td> 
	<div class="wrapper mt_0 mr0">
	<button name="save"  class="  link  blue full is_final " style = "color: grey!important;">
	<img src="/news/ico/profile.png " alt="" class="m"> 
	<span class="m">Изменить категорию</span>
	</button>
	</div></td> </tr> 
	</tbody></table>
	</form>
	';
	
	}else{$_SESSION['message'] = 'Ошибка категория не найдена'; header("location: /news/list/");}
	
	include_once '../../sys/inc/tfoot.php';
?>