File size: 3.2Kb
<?php
require_once 'inc.php';
require_once 'head.php';
if ($admin == 1){
echo '
<div class="line2"><a href="panel.php?do=add_news">Добавить новость</a></div>';
}
if ($do == ''){
$num= $set['num_index'];
$all=mysql_result(mysql_query('SELECT COUNT(*) FROM news'),0);
$total=intval(($all-1)/$num)+1;
if($page>$total){$page=$total;}elseif($page<1){$page=1;}
$start=$page*$num-$num;
if($all){
$res=mysql_query('SELECT * FROM news ORDER BY id DESC LIMIT '.$start.', '.$num);
while($m=mysql_fetch_assoc($res)){
echo '
<div class="line">
» <a href="index.php?do=view&id='.$m['id'].'">'.$m['name'].'</a> ('.$m['date'].' в '.$m['time'].')';
if ($admin == 1){
echo '<a href="panel.php?do=del_news&id='.$m['id'].'">[DEL]</a> | <a href="panel.php?do=edit_news&id='.$m['id'].'">[EDIT]</a>';
}
echo '
</div>';
}
page($all,'index.php?',$page,$total,'новостей');
}else{
echo '<div class="line"><font color="red">Новостей нет</font></div>';
}
}
if ($do == 'view'){
if (mysql_num_rows(mysql_query("SELECT * FROM news WHERE id='".$id."' LIMIT 1"))==0){
exit('Новости таким ид НЕ существует');
}else{
$text = mysql_fetch_array(mysql_query("SELECT * FROM news WHERE id='".$id."' LIMIT 1"));
$comm = mysql_result(mysql_query("SELECT COUNT(*) FROM comments WHERE id_news='".$id."'"),0);
echo '
<div class="line2">'.$text['name'].' - '.$text['date'].' в '.$text['time'].'</div>
<div class="line">
'.vizual($text['text']).'
</div>
<div class="line">
<a href="comm.php?id='.$id.'">Комментарии ('.$comm.')
</div>
'.$back.'
';
}
}
if ($do == 'bb'){
echo'
<div class="line2">BB-Коды</span><br></div>';
echo'<div class="line">
Текст: [i]Привет[/i]<br>
Результат: <i>Привет</i><br></div>
<div class="line2">
[b]Текст[/b] - <b>Текст</b><br>
[u]Текст[/u] - <u>Текст</u><br>
[i]Текст[/i] - <i>Текст</i><br>
[red]Текст[/red] - <font color="red">Текст</font><br>
[green]Текст[/green] - <font color="green">Текст</font><br>
[black]Текст[/black] - <font color="black">Текст</font><br>
[white]Текст[/white] - <font color="white">Текст</font><br>
[yellow]Текст[/yellow] - <font color="yellow">Текст</font><br>
[orange]Текст[/orange] - <font color="orange">Текст</font><br>
[blue]Текст[/blue] - <font color="blue">Текст</font><br>
[violet]Текст[/violet] - <font color="violet">Текст</font><br>
</div>
'.$back.'
';
}
if ($do == 'enter'){
if (!isset($_POST['pass'])){
$_SESSION['cod']=mt_rand(1111,9999);
echo '
<div class="line2">Авторизация</div>
<div class="line">
<form action="?do=enter" method="POST">
Введите пароль: <br />
<input type="text" name="pass"><br />
Код: '.$_SESSION['cod'].'<br />
<input type="text" name="cod" maxlength="4"><br />
<input type="submit" value="Войти">
</form>
</div>
'.$back.'';
}else{
$pass = filtr($_POST['pass']);
$true = mysql_result(mysql_query("SELECT password FROM `set` WHERE id='1'"),0);
if ($true != $pass){
exit('Пароль введен неверно');
}else{
$_SESSION['pass']=$pass;
unset($_SESSION['cod']);
header("Location: index.php");
}
}
}
require_once 'foot.php';
?>