View file public_html/mpanel/headlines.php

File size: 8.13Kb
<?php
#-----------------------------------------------------#
#          ********* WAP-MOTORS *********             #
#             Made by   :  VANTUZ                     #
#               E-mail  :  [email protected]         #
#                 Site  :  http://pizdec.ru           #
#             WAP-Site  :  http://visavi.net          #
#                  ICQ  :  36-44-66                   #
#  Вы не имеете право вносить изменения в код скрипта #
#-----------------------------------------------------#	
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";

if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!="") {
if ($dostup==101 || $dostup==102){

echo'<img src="../images/img/partners.gif" alt=""> <b>Управление заголовками</b><br><br>';


//---------------------------------------- Список заголовков -------------------------------------------//
if(!isset($action)){	

$file = file(BASEDIR."local/headlines.dat");
$total = count($file);    

if($total<1){echo'<br><img src="../images/img/reload.gif" alt=""> <b>Заголовков еще нет!</b><br>';}

if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($total < $start + $config_headlines){ $end = $total; }
else {$end = $start + $config_headlines; }
for ($i = $start; $i < $end; $i++){


$data = explode("|",$file[$i]);

echo '<img src="../images/img/edit.gif" alt=""> <b><a href="headlines.php?action=edit&amp;editlines='.$i.'&amp;start='.$start.'&amp;'.SID.'">'.$data[2].'</a></b> ('.$data[1].') ';

echo '<a href="headlines.php?action=del&amp;editlines='.$i.'&amp;start='.$start.'&amp;'.SID.'"><font color="#FF0000">[Del]</font></a><br>';

}

echo'<hr>'; 
if ($start != 0) {echo '<a href="headlines.php?start='.($start - $config_headlines).'&amp;'.SID.'">&lt;-Назад</a> ';}else{echo'&lt;-Назад';}
echo' | '; 
if ($total > $start + $config_headlines) {echo ' <a href="headlines.php?start='.($start + $config_headlines).'&amp;'.SID.'">Далее-&gt;</a>';}else{echo'Далее-&gt;';}

if($total>0){

$ba=ceil($total/$config_headlines);
$ba2=$ba*$config_headlines-$config_headlines;

echo '<br><hr>Страницы:';
$asd=$start-($config_headlines*3);
$asd2=$start+($config_headlines*4);

if($asd<$total && $asd>0){echo ' <a href="headlines.php?start=0&amp;'.SID.'">1</a> ... ';}

for($i=$asd; $i<$asd2;)
{
if($i<$total && $i>=0){
$ii=floor(1+$i/$config_headlines);

if ($start==$i) {
echo ' <b>('.$ii.')</b>';
               }
                else {
echo ' <a href="headlines.php?start='.$i.'&amp;'.SID.'">'.$ii.'</a>';
                     }}


$i=$i+$config_headlines;}
if($asd2<$total){echo ' ... <a href="headlines.php?start='.$ba2.'&amp;'.SID.'">'.$ba.'</a>';}
}

echo'<br><br><img src="../images/img/edit.gif" alt=""> <a href="headlines.php?action=add&amp;'.SID.'">Добавить</a>';
}


//----------------------------- Подготовка к редактированию заголовка -------------------------------//
if($action=="edit") {
if($editlines!=""){

$file = file(BASEDIR."local/headlines.dat");
$data = explode("|",$file[$editlines]);


if($config_themes!="wml"){	

echo'<form action="headlines.php?editlines='.$editlines.'&amp;action=addedit&amp;start='.$start.'&amp;'.SID.'" method="POST">';
echo'Страница: <br><input type="text" name="headstr" value="'.$data[1].'"><br>';
echo'Название: <br><input type="text" name="headname" value="'.$data[2].'"><br>';
echo'<br><input type="submit" value="Изменить"></form><hr>';

}else{

echo'<br>--------------------<br>';
echo'Страница: <br><input type="text" name="headstr" value="'.$data[1].'"/><br>';
echo'Название: <br><input type="text" name="headname" value="'.$data[2].'"/><br>';

echo'<anchor>Изменить';
echo'<go href="headlines.php?editlines='.$editlines.'&amp;action=addedit&amp;start='.$start.'&amp;'.SID.'" method="post">';
echo'<postfield name="headstr" value="$(headstr)"/>';
echo'<postfield name="headname" value="$(headname)"/>';
echo'</go></anchor><br>--------------------<br>';
}

}else{echo 'Ошибка! Не выбран заголовок для редактирования!<br>';}

echo'<br><img src="../images/img/back.gif" alt=""> <a href="headlines.php?start='.$start.'&amp;'.SID.'">Вернуться</a>';
}


//---------------------------------------- Редактирование заголовка -------------------------------------------//
if($action=="addedit") {
if($editlines!=""){
if($headstr!="" && $headname!=""){

$headstr=check($headstr);	
$headname=check($headname);


$text='|'.$headstr.'|'.$headname.'|';
$text=no_br($text);

$file=file(BASEDIR."local/headlines.dat");
$fp=fopen(BASEDIR."local/headlines.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
for ($i=0;$i< sizeof($file);$i++) {if ($editlines!=$i) {fputs($fp,$file[$i]);} else {fputs($fp,"$text\r\n");}}
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);


}else{header ("Location: headlines.php?action=edit&editlines=$editlines&start=$start&isset=mp_noheaddat&".SID); exit;}
}else{header ("Location: headlines.php?start=$start&isset=mp_noheadlines&".SID); exit;}

header ("Location: headlines.php?start=$start&isset=mp_headlines&".SID);
}

//----------------------------- Подготовка к добавлению заголовка ----------------------------------------//
if($action=="add") {

if($config_themes!="wml"){	

echo'<form action="headlines.php?action=addstr&amp;'.SID.'" method="POST">';
echo'Страница: <br><input type="text" name="headstr"><br>';
echo'Название: <br><input type="text" name="headname""><br>';
echo'<br><input type="submit" value="Добавить"></form><hr>';

}else{

echo'<br>--------------------<br>';
echo'Страница: <br><input type="text" name="headstr"/><br>';
echo'Название: <br><input type="text" name="headname"/><br>';

echo'<anchor>Добавить';
echo'<go href="headlines.php?action=addstr&amp;'.SID.'" method="post">';
echo'<postfield name="headstr" value="$(headstr)"/>';
echo'<postfield name="headname" value="$(headname)"/>';
echo'</go></anchor><br>--------------------<br>';
}

echo'<br><img src="../images/img/back.gif" alt=""> <a href="headlines.php?'.SID.'">Вернуться</a>';
}


//---------------------------------------- Добавление заголовка -------------------------------------------//
if($action=="addstr") {
if($headstr!="" && $headname!=""){

$headstr=check($headstr);	
$headname=check($headname);


$text='|'.$headstr.'|'.$headname.'|';
$text=no_br($text);

$fp=fopen(BASEDIR."local/headlines.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$text\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);

}else{header ("Location: headlines.php?action=add&isset=mp_noheaddat&".SID); exit;}

header ("Location: headlines.php?start=$start&isset=mp_addheadlines&".SID);
}

//---------------------------------------- Уладение заголовка -------------------------------------------//
if($action=="del") {
if($editlines!=""){
$file=file(BASEDIR."local/headlines.dat");	
$fp=fopen(BASEDIR."local/headlines.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) { if ($i==$editlines) {unset($file[$i]);} }
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);

}else{header ("Location: headlines.php?start=$start&isset=mp_noheaddel&".SID); exit;}

header ("Location: headlines.php?start=$start&isset=mp_headdel&".SID);	
}




echo'<br><img src="../images/img/panel.gif" alt=""> <a href="index.php?'.SID.'">В админку</a><br>';
echo'<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a><br>';

} else {header ("Location: ../index.php?isset=404&".SID);}
} else {header ("Location: ../index.php?isset=404&".SID);}

include_once"../themes/$config_themes/foot.php";
?>