<?php
|
|
/**
|
|
* @package uForum
|
|
* @file posting.php
|
|
* @version $Id$
|
|
* @copyright 2009(c) PioDer <[email protected]>
|
|
* @link http://pioder.gim2przemysl.int.pl/
|
|
* @license GNU GPL v3
|
|
**/
|
|
define('IN_uF', true);
|
|
//include files
|
|
include('./config.php');
|
|
include('./includes/constants.php');
|
|
include('./includes/db.php');
|
|
include('./includes/errors.php');
|
|
//connect to database
|
|
DataBase::db_connect();
|
|
include('./includes/sessions.php');
|
|
include('./includes/classes/class_user.php');
|
|
include('./common.php');
|
|
include('./includes/misc_functions.php');
|
|
include('./includes/classes/class_forum.php');
|
|
include('./includes/classes/class_posting.php');
|
|
include('./includes/classes/class_topic.php');
|
|
include('./includes/classes/secure.php');
|
|
include('./lngs/'.DefaultLang().'/main.php');
|
|
$start = TimeGeneration();
|
|
$default_skin = ViewSkinName();
|
|
SessDelInvalid();
|
|
SessRegister();
|
|
SessDeleteOld();
|
|
$msg='';
|
|
|
|
if ($_SESSION['uid']<1)
|
|
{
|
|
message_forum($lng['youarenotlogd'],'login.php?mode=login');
|
|
}
|
|
$start = TimeGeneration();
|
|
//add skin variables
|
|
$skin = array();
|
|
|
|
$skin = array_push_assoc($skin, GenerateHeader('',''));
|
|
$stop = TimeGeneration();
|
|
$skin['queries'] = ShowQueries($start, $stop);
|
|
|
|
if (isset($_POST['textedit']))
|
|
{
|
|
$errors = false;
|
|
//check post form
|
|
if (($_POST['textedit'] =='' ) or (strlen(trim($_POST['textedit']))<10))
|
|
{
|
|
$errors = true;
|
|
$message = $lng['perror_1'];
|
|
}
|
|
|
|
if ($_GET['mode'] == 'ntopic')
|
|
{
|
|
if (($_POST['ntopic']!='') or (strlen(trim($_POST['ntopic']))>5))
|
|
{
|
|
$errors = true;
|
|
$message = $lng['perror_3'];
|
|
}
|
|
}
|
|
|
|
//antiflood lock
|
|
if (isset($_COOKIE['antiflood_time']))
|
|
{
|
|
if ($_COOKIE['antiflood_time']>time())
|
|
{
|
|
message_forum($lng['antiflood_enabled'],$_SERVER['REQUEST_URI']);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
setcookie('antiflood_time',(time() + $forum_config['time_antiflood']));
|
|
}
|
|
|
|
//prepare post...
|
|
if (!$errors)
|
|
{
|
|
$_POST['textedit'] = Secure::TagsReplace($_POST['textedit']);
|
|
if ($_GET['mode']=='ntopic')
|
|
{
|
|
$_POST['ntopic'] = Secure::UseCensorlist(strip_tags(trim($_POST['ntopic'])));
|
|
if (isset($_POST['topic_sticky']))
|
|
{
|
|
$_POST['topic_sticky']='1';
|
|
}
|
|
else
|
|
{
|
|
$_POST['topic_sticky']='0';
|
|
}
|
|
}
|
|
|
|
|
|
//do it!
|
|
switch ($_GET['mode'])
|
|
{
|
|
case 'rpost':
|
|
{
|
|
$id = Post::NewPost(intval($_GET['id']),$_POST['textedit'], $_SESSION['uid']);
|
|
$count =ceil(($id / 15 ));
|
|
if ($count >1)
|
|
{
|
|
$page= '&page='.$count;
|
|
}
|
|
else
|
|
{
|
|
$page='';
|
|
}
|
|
$redirect_url = 'topic.php?t='.$_GET['id'].$page.'#p'.$id;
|
|
break;
|
|
}
|
|
|
|
case 'qpost':
|
|
{
|
|
$id = Post::NewPost(intval($_GET['id']),$_POST['textedit'], $_SESSION['uid']);
|
|
$count =ceil(($id / 15 ));
|
|
if ($count >1)
|
|
{
|
|
$page= '&page='.$count;
|
|
}
|
|
else
|
|
{
|
|
$page='';
|
|
}
|
|
$redirect_url = 'topic.php?t='.$_GET['id'].$page.'#p'.$id;
|
|
|
|
break;
|
|
}
|
|
|
|
case 'edit':
|
|
{
|
|
Post::EditPost(intval($_GET['id']),$_POST['textedit']);
|
|
$count = ceil((Topic::PostInformation(intval($_GET['id']),'tp_id') / 15 ));
|
|
if ($count >1)
|
|
{
|
|
$page= '&page='.$count;
|
|
}
|
|
else
|
|
{
|
|
$page='';
|
|
}
|
|
$redirect_url = 'topic.php?t='.Topic::PostInformation(intval($_GET['id']),'t_id').$page.'#p'.$_GET['id'];
|
|
|
|
break;
|
|
}
|
|
|
|
case 'ntopic':
|
|
{
|
|
$last = Post::NewTopic($_POST['textedit'],$_POST['ntopic'], intval($_GET['f']), $_SESSION['uid'], $_POST['topic_sticky']);
|
|
$redirect_url = 'topic.php?t='.$last;
|
|
break;
|
|
}
|
|
}
|
|
//redirecting to topic page...
|
|
$stop = TimeGeneration();
|
|
message_forum($lng['post_is_saved'], $redirect_url);
|
|
}
|
|
else
|
|
{
|
|
$msg = './skins/'.$default_skin.'/post_error_body.tpl';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch($_GET['mode'])
|
|
{
|
|
case 'qpost':
|
|
{
|
|
$_POST['textedit'] = (empty($_POST['textedit'])) ? '[quote]'.stripslashes(Topic::PostInformation($_GET['id'],'text')).'[/quote]' : $_POST['textedit'];
|
|
break;
|
|
}
|
|
|
|
case 'edit':
|
|
{
|
|
$_POST['textedit'] = (empty($_POST['textedit'])) ? stripslashes(Topic::PostInformation($_GET['id'],'text')) : $_POST['textedit'];
|
|
break;
|
|
}
|
|
|
|
case 'rpost':
|
|
{
|
|
$_POST['textedit'] = (empty($_POST['textedit'])) ? '' : $_POST['textedit'];
|
|
break;
|
|
}
|
|
|
|
case 'ntopic':
|
|
{
|
|
$_POST['textedit'] = (empty($_POST['textedit'])) ? '' : $_POST['textedit'];
|
|
$_POST['ntopic'] = (empty($_POST['ntopic'])) ? '' : $_POST['ntopic'];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//generating output page
|
|
if ($_GET['mode'] == 'rpost' || $_GET['mode'] == 'qpost')
|
|
{
|
|
Secure::topic_exists(intval($_GET['id']));
|
|
Secure::TopicLocked(intval($_GET['id']));
|
|
}
|
|
|
|
if ($_GET['mode'] == 'ntopic')
|
|
{
|
|
$sql = "SELECT `lock`, `name`, `f_id` FROM ".FORUMS_TABLE." WHERE `f_id`='".intval($_GET['f'])."'";
|
|
$forum = DataBase::fetch(DataBase::sql_query($sql, GENERAL, 'Could not obtain forum information'));
|
|
if($forum['name']=='')
|
|
{
|
|
message_forum($lng['no_forum'], 'index.php');
|
|
}
|
|
if($forum['lock']=='1')
|
|
{
|
|
message_forum($lng['no_posting_forum_locked'],'index.php', 5);
|
|
}
|
|
}
|
|
|
|
if ($_GET['mode']=='edit')
|
|
{
|
|
if (Topic::PostInformation(trim(strip_tags($_GET['id'])), 'p_id')== '')
|
|
{
|
|
message_forum($lng['no_message'], 'index.php');
|
|
}
|
|
|
|
if ((!User::RankAdminMod($_SESSION['uid'])) or ($_SESSION['uid']!=Topic::PostInformation($_GET['id'],'u_id')))
|
|
{
|
|
message_forum($lng['perror_2'], 'index.php');
|
|
}
|
|
}
|
|
|
|
switch ($_GET['mode'])
|
|
{
|
|
case 'ntopic':
|
|
{
|
|
$skin = array_push_assoc($skin, array(
|
|
'mainpage' => $lng['writetopic'],
|
|
'lmainpage' => '</a>> <a href="forum.php?f='.$_GET['f'].'" class="navigator">'.$forum['name'].'</a> ><a href="posting.php?mode=ntopic&f='.$_GET['f'].'" class="navigator">'.$lng['writetopic']
|
|
));
|
|
break;
|
|
}
|
|
|
|
case 'edit':
|
|
{
|
|
$skin = array_push_assoc($skin, array(
|
|
'mainpage' => $lng['editpost'],
|
|
'lmainpage' => '</a>> <a href="posting.php?mode=edit&id='.intval($_GET['id']).'"
|
|
class="navigator">'.$lng['editpost']
|
|
));
|
|
break;
|
|
}
|
|
|
|
case 'rpost':
|
|
{
|
|
$skin = array_push_assoc($skin, array(
|
|
'mainpage' => $lng['answer'].': '.Topic::TopicInformation(intval($_GET['id']),'name'),
|
|
'lmainpage' => '</a>> <a href="posting.php?mode=rpost&id='.intval($_GET['id']).'"
|
|
class="navigator">'.$lng['answer'].': </a><a href="topic.php?t='.$_GET['id'].'"
|
|
class="navigator">'.Topic::TopicInformation(intval($_GET['id']),'name')
|
|
));
|
|
break;
|
|
}
|
|
|
|
case 'qpost':
|
|
{
|
|
$skin = array_push_assoc($skin, array(
|
|
'mainpage' => $lng['quote'],
|
|
'lmainpage' => '</a>> <a href="posting.php?mode=qpost&id='.$_GET['id'].'&t='.$_GET['t'].'"
|
|
class="navigator">'.$lng['quote']
|
|
));
|
|
break;
|
|
}
|
|
|
|
// if no mode... :D
|
|
default:
|
|
{
|
|
$stop = TimeGeneration();
|
|
message_forum($lng['invalidmode'],'index.php');
|
|
break;
|
|
}
|
|
}
|
|
|
|
$skin = array_push_assoc($skin, array(
|
|
'smiles'=>Post::SmilesShow(),
|
|
//labels
|
|
'lsmiles'=>$lng['smiles'],
|
|
'ltopicname'=>$lng['ltopicname'],
|
|
'lsave'=>$lng['save'],
|
|
'lreset'=>$lng['reset'],
|
|
'lmsg'=>$lng['message'],
|
|
'lsticky_topic'=>$lng['sticky_topic'],
|
|
'lwritetopic'=>$lng['writetopic'],
|
|
));
|
|
|
|
if ($msg=='')
|
|
{
|
|
$msg='./skins/'.$default_skin.'/blank.tpl';
|
|
}
|
|
|
|
//do it!
|
|
include('./skins/'.$default_skin.'/overall_header.tpl');
|
|
include('./skins/'.$default_skin.'/posting_body.tpl');
|
|
include('./skins/'.$default_skin.'/overall_footer.tpl');
|
|
?>
|