Файл: core/editpost.php
Строк: 28
<?php
/*
* @author mides <Mike Osendowski>
* @link http://midwm.org
* @copyright 2011-2014
*/
if (is_auth())
{
switch ($module)
{
case 'guestbook':
$table = 'guestbook';
break;
case 'forum':
$table = 'forum_posts';
break;
}
$post = DB::run()->queryFetch("select * from `".$table."` where `id` = ?;", array($id));
if (($post['userid'] == $u['id'] && $post['time'] > TIME - 60 * $config['editmin']) or access($module.($module == 'forum' ? $post['categid'] : '_editpost')))
{
if (!isset($_SESSION[$module]['editpost_refurl'][$id]) && $refurl)
{
$_SESSION[$module]['editpost_refurl'][$id] = $refurl.'#'.$post['id'];
}
$message = isset($_POST['message']) ? check($_POST['message']) : FALSE;
if ($message)
{
if (mb_strlen($message, 'utf-8') <= $config['msglength'])
{
if ($_SESSION['wait'] < TIME)
{
DB::run()->query("update `".$table."` set `message` = ?, `edit_by` = ?, `edit_time` = ?, `edit_count` = (`edit_count`+1) where `id` = ?;", array($message, $u['id'], TIME, $post['id']));
$_SESSION['wait'] = TIME + $config['wait_time'];
$redirect = isset($_SESSION[$module]['editpost_refurl'][$id]) ? $_SESSION[$module]['editpost_refurl'][$id] : '/'.$module;
unset($_SESSION[$module]['editpost_refurl'][$id]);
redirect($redirect);
}
else
{
$_SESSION['note'] = $lang['Anti_Spam_Please_wait_before_trying_again'];
}
}
else
{
$_SESSION['note'] = $lang['Your_message_exceeds_the_maximum_number_of_characters_allowed'].' ('.$config['msglength'].')';
}
}
$config['newtitle'] = $lang['Edit_post'];
$tpl['file'] = 'editpost';
require_once 'core/header.php';
}
else
{
redirect('/'.$module);
}
}
else
{
redirect('/'.$module);
}