<?php

include "../admin/adminses.php";
include "../engine/functions.php";
require_once("../mycode/funcnews.php");
$sitetitle="Управление новостями";
$what = (isset($_GET['what'])) ? intval($_GET['what']) : 0;
$myFile="../engine/newsdb.php";
$newsperpage=30;

@$contentcenter.= "<h3>Обзор новостей</h3>";

if(file_exists("$myFile")){
	$news=file("$myFile");
	if ($what>0) {
	@chmod("../engine/newsdb.phpt", 0777);
	$open=fopen("$myFile","w");
	   for($i=0;$i<count($news);$i++)
	   {
	      if(($i+1)!=$what){fwrite($open,$news[$i]);}
	   }
	fclose($open); 
	@chmod("../engine/newsdb.php", 0604);
	$contentcenter.="<B>Новость удалена!</B><br><center><a href='javascript:history.back(1)'><B>Вернуться назад</B></a></center>";
	} else {
	$countallnews = count($news);
	$contentcenter.="Всего новостей: $countallnews<hr>\n";
	if(!isset($_REQUEST["newspage"])) {$_REQUEST["newspage"]=1;
	} else {$_REQUEST["newspage"] = (int)$_REQUEST["newspage"];}
	$j = ($countallnews-1)-(($_REQUEST["newspage"]-1)*$newsperpage);
	$i = $j-$newsperpage;
		for($j;(($i<$j)&&($j>=0));$j--)  {
		$new=unserialize($news[$j]);
		if ($new=="") {continue;}
		@$newsmarkers=array(
		@$head = $new['head'],
		@$startnews = $new['mess'],
		@$adminemail = $new['admmail'],
		@$adminname = $new['aname'],
		@$date = $new['pubdate'],
		@$time = $new['pubtime']
		);
		$p = $j+1;
		$contentcenter.="&nbsp;&#8226;&nbsp;<font color=red>$date</font> <b><font color=#446D8C>$head</font></b> - <a href=\"../admin/news.php?what=" . $p . "\">Удалить</a><br>";
		}
	}
} else {$contentcenter.="Новостей нет!";}


include "../admin/admintemplate.php";

?>
