Вход Регистрация
Файл: public_html/news.php
Строк: 35
<?php
include ('./dev/db.php');
include (
'./dev/functions.php');
include (
'./dev/user.php');
$title 'Новости';
include (
'./dev/head.php');
if(!
$user) {
header('location: /index.php');
exit;
}
if(
$_GET['news'] == add) {
if(
$user['id'] != 1) {
header('location: /news.php');
exit;
}
  if(
$_POST['text']) {
  
$text _string($_POST['text']);
 
mysql_query('INSERT INTO `news` (`text`,
 `time`) VALUEs ("'
.$text.'",
  "'
.time().'")');
   
header('location: /news.php');
   
$_SESSION['result'] = 'Новость создана!';
   exit();
  }
echo 
"<div class='block center'>
  <form action='' method='post'>
  <textarea name='text' style='width: 97%'></textarea><br/>
<input type='submit' value='Создать'>
  </form></div>"
;
include (
'./dev/foot.php');
exit;
}
$max 10;
$k_post mysql_result(mysql_query("SELECT COUNT(*) FROM `news`"),0);
$k_page k_page($k_post,$max);
$page page($k_page);
$start $max*$page-$max;
$news mysql_query("SELECT * FROM `news` ORDER BY `time` DESC LIMIT $start$max");
while(
$n mysql_fetch_assoc($news))
{
echo 
'<div class="block">'.smiles($n['text']).' <span style="float: right;">'.vremja(time() - $n['time']).'</span></div>';
}
if(
$k_post<1) {
echo 
'<div class="block center">Новостей нет!</div>';
}
if(
$k_page>1) echo str('?',$k_page,$page);
if(
$user['id'] == 1) {
echo 
'<a href="?news=add" class="link"><img src="/img/arr.png"> Создать новость</a>';
}
require_once 
'./dev/foot.php';
?>
Онлайн: 1
Реклама