Файл: muzxit.ru/stars/addcat.php
Строк: 77
<?php
/**
* @package JohnCMS
* @link http://johncms.com
* @copyright Copyright (C) 2008-2011 JohnCMS Community
* @license LICENSE.txt (see attached file)
* @version VERSION.txt (see attached file)
* @author http://johncms.com/about
*/
define('_IN_JOHNCMS', 1);
$headmod = 'stars';
require('../incfiles/core.php');
$lng_stars = core::load_lng('stars');
if (isset($_SESSION['ref']))
unset($_SESSION['ref']);
// Задаем заголовки страницы
$textl = $lng_stars['addcat'];
require('../incfiles/head.php');
$id = $id ? $id : 0;
//$pref = $id ? " " : null;
$cat = mysql_fetch_assoc(mysql_query("select * from `stars` where `id` = '$id';"));
if ($rights < 7) {
echo '<div class="rmenu"><p>' . $lng['error_404'] . '</p></div>';
require('../incfiles/end.php');
exit;
}
if(!$cat && $id)
{
echo '<div class="rmenu"><p>' . $lng['error_wrong_data'] . '</p></div>';
require('../incfiles/end.php');
exit;
}
if(isset($_POST['submit']))
{
/*
-----------------------------------------------------------------
Добавление нового поста
-----------------------------------------------------------------
*/
// Принимаем и обрабатываем данные
$name = isset($_POST['name']) ? mb_substr(trim($_POST['name']), 0, 256) : '';
$namelat = isset($_POST['namelat']) ? mb_substr(trim($_POST['namelat']), 0, 256) : '';
$about = isset($_POST['about']) ? trim($_POST['about']) : '';
// Проверяем на ошибки
$error = array();
if (empty($_POST['name']))
$error[] = $lng_stars['error_empty_name'];
if (!$error) {
// Вставляем сообщение в базу
mysql_query("INSERT INTO `stars` SET
`name` = '$name',
`cid` = '$id',
`type` = '0'
");
// Фиксируем время последнего поста (антиспам)
header('location: index.php' . ($id ? '?id=' . $id : null) );
} else {
echo functions::display_error($error, '<a href="index.php' . ($id ? '?id=' . $id : null) . '">' . $lng['back'] . '</a>');
}
}
echo '<div class="gmenu"><form name="form" action="addcat.php' . ($id ? '?id=' . $id : null) . '" method="post">';
echo $lng_stars['nname'] . ' (max 25):<br/><input type="text" name="name" maxlength="25"/><br/>';
//echo $lng_stars['namelat'] . ' <small>(max 25)</small>:<br/><input type="text" name="name" maxlength="25"/><br/>';
//if (!$is_mobile)
// echo bbcode::auto_bb('form', 'about');
//echo '<textarea rows="' . $set_user['field_h'] . '" name="about"></textarea><br/>';
//echo '<input type="checkbox" name="addfile" value="1" /> ' . $lng_stars['add_foto'] . '<br/>';
echo '<input type="submit" name="submit" value="' . $lng['sent'] . '"/></form></div>';
echo '<div class="topmenu"><a href="index.php' . ($id ? '?id=' . $id : null) . '">' . $lng['back'] . '</a></div>';
require('../incfiles/end.php');
?>