+ Replaced name function from array_push_associative to array_push_assoc

+ Rewrited posting.php

git-svn-id: https://svn.pioder.pl/uf-svn/uF@32 72ec579a-5ced-4fa4-82f3-afba5d98df2f
This commit is contained in:
pioder
2009-06-01 18:46:17 +00:00
parent 7669786f46
commit 93e5cae6f0
20 changed files with 238 additions and 308 deletions

View File

@@ -30,32 +30,16 @@ SessDelInvalid();
SessRegister();
SessDeleteOld();
$msg='';
if ($_SESSION['uid']<1)
{
message_forum($lng['youarenotlogd'],'login.php?mode=login');
}
/**foreach ($_POST as $name => $value)
{
if ($forum_config['use_censorlist'])
{
$_POST[$name] = Secure::UseCensorlist($value);
}
}
*/
$start = TimeGeneration();
//add skin variables
$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'],
);
$skin = array_push_associative($skin, GenerateHeader('',''));
$skin = array();
$skin = array_push_assoc($skin, GenerateHeader('',''));
$stop = TimeGeneration();
$skin['queries'] = ShowQueries($start, $stop);
if(RANK=='2')
@@ -66,267 +50,261 @@ else
{
$skin['pa_link']='';
}
switch(trim($_GET['mode']))
if (isset($_POST['textedit']))
{
/**
*
functions for reply: normal, editing, quoting...
*
**/
case 'qpost': //quote post
$errors = false;
//check post form
if (($_POST['textedit'] =='' ) or (strlen(trim($_POST['textedit']))<10))
{
$msg ='';
if (isset($_POST['textedit']))
{
if (($_POST['textedit'] !='' ) and (strlen(trim($_POST['textedit']))>10))
{
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']));
}
$_POST['textedit'] = Secure::TagsReplace($_POST['textedit']);
$id = Post::NewPost(intval($_GET['t']),$_POST['textedit'], $_SESSION['uid']);
$count = ceil(($id / 15 ));
if ($count >1)
{
$page= '&amp;page='.$count;
}
else
{
$page='';
}
$stop = TimeGeneration();
message_forum($lng['post_is_saved'],'topic.php?t='.$_GET['t'].$page.'#'.$id);
}
else
{
$message = $lng['perror_1'];
$msg = './skins/'.$default_skin.'/post_error_body.tpl';
}
}
else
{
$_POST['textedit']='[quote]'.stripslashes(Topic::PostInformation($_GET['id'],'text')).'[/quote]';
}
Secure::topic_exists(intval($_GET['t']));
Secure::TopicLocked(intval($_GET['t']));
$skin['mainpage'] = $lng['quote'];
$skin['lmainpage'] = '</a>&gt; <a href="posting.php?mode=qpost&amp;id='.$_GET['id'].'&amp;t='.$_GET['t'].'"
class="navigator">'.$lng['quote'];
$skin['f_id'] = $_GET['id'];
$skin['action'] = 'posting.php?mode=qpost&amp;id='.$_GET['id'].'&amp;t='.$_GET['t'];
if ($msg=='')
{
$msg='./skins/'.$default_skin.'/blank.tpl';
}
include('./skins/'.$default_skin.'/overall_header.tpl');
include('./skins/'.$default_skin.'/posting_body.tpl');
include('./skins/'.$default_skin.'/overall_footer.tpl');
break;
}
case 'edit': //edit post
{
if ((User::RankAdminMod($_SESSION['uid'])) or ($_SESSION['uid']==Topic::PostInformation($_GET['id'],'u_id')))
{
$msg ='';
if (isset($_POST['textedit']))
{
if (($_POST['textedit'] !='' ) and (strlen(trim($_POST['textedit']))>10))
{
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']));
}
$_POST['textedit'] = Secure::TagsReplace($_POST['textedit']);
Post::EditPost(intval($_GET['id']),$_POST['textedit']);
$count = ceil((Topic::PostInformation(intval($_GET['id']),'tp_id') / 15 ));
if ($count >1)
{
$page= '&amp;page='.$count;
}
else
{
$page='';
}
$stop = TimeGeneration();
message_forum($lng['post_is_saved'],'topic.php?t='.Topic::PostInformation(intval($_GET['id']),'t_id').$page.'#p'.$_GET['id']);
}
else
{
$message = $lng['perror_1'];
$msg = './skins/'.$default_skin.'/post_error_body.tpl';
}
}
else
{
$_POST['textedit']=stripslashes(Topic::PostInformation($_GET['id'],'text'));
}
}
$skin['mainpage'] = $lng['editpost'];
$skin['lmainpage'] = '</a>&gt; <a href="posting.php?mode=edit&amp;id='.intval($_GET['id']).'"
class="navigator">'.$lng['editpost'];
$skin['f_id'] = intval($_GET['id']);
$skin['action'] = 'posting.php?mode=edit&amp;id='.intval($_GET['id']);
if ($msg=='')
{
$msg='./skins/'.$default_skin.'/blank.tpl';
}
include('./skins/'.$default_skin.'/overall_header.tpl');
include('./skins/'.$default_skin.'/posting_body.tpl');
include('./skins/'.$default_skin.'/overall_footer.tpl');
break;
$errors = true;
$message = $lng['perror_1'];
}
case 'rpost': //reply post
if ($_GET['mode'] == 'ntopic')
{
$msg ='';
if (isset($_POST['textedit']))
{
if (($_POST['textedit'] !='' ) and (strlen(trim($_POST['textedit']))>10))
{
if (isset($_COOKIE['antiflood']))
{
if ($_COOKIE['antiflood_time']>time())
{
message_forum($lng['antiflood_enabled'],$_SERVER['REQUEST_URI']);
}
}
else
{
setcookie('antiflood_time',(time() + $forum_config['time_antiflood']));
}
$_POST['textedit'] = Secure::TagsReplace($_POST['textedit']);
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= '&amp;page='.$count;
$page= '&amp;page='.$count;
}
else
{
$page='';
}
$stop = TimeGeneration();
message_forum($lng['post_is_saved'],'topic.php?t='.$_GET['id'].$page.'#p'.$id);
$redirect_url = 'topic.php?t='.$_GET['id'].$page.'#p'.$id;
break;
}
else
case 'qpost':
{
$message = $lng['perror_1'];
$msg = './skins/'.$default_skin.'/post_error_body.tpl';
}
}
else
{
$_POST['textedit']='';
}
Secure::topic_exists(intval($_GET['id']));
Secure::TopicLocked(intval($_GET['id']));
$skin['mainpage'] = $lng['answer'].': '.Topic::TopicInformation(intval($_GET['id']),'name');
$skin['lmainpage'] = '</a>&gt; <a href="posting.php?mode=rpost&amp;id='.intval($_GET['id']).'"
class="navigator">'.$lng['answer'].': </a><a href="topic.php?t='.$_GET['id'].'"
class="navigator">'.Topic::TopicInformation(intval($_GET['id']),'name');
$skin['f_id'] = $_GET['id'];
$skin['action'] = 'posting.php?mode=rpost&amp;id='.$_GET['id'];
if ($msg=='')
{
$msg='./skins/'.$default_skin.'/blank.tpl';
}
include('./skins/'.$default_skin.'/overall_header.tpl');
include('./skins/'.$default_skin.'/posting_body.tpl');
include('./skins/'.$default_skin.'/overall_footer.tpl');
break;
}
/**
*
Select new TOPIC
*
**/
case 'ntopic': //new topic
{
$msg ='';
if ((isset($_POST['textedit'])) and (isset($_POST['ntopic'])))
{
if (($_POST['textedit'] !='' ) and ($_POST['ntopic']!='') and (strlen(trim($_POST['textedit']))>10) and (strlen(trim($_POST['ntopic']))>5))
{
$_POST['textedit'] = Secure::TagsReplace($_POST['textedit']);
if (isset($_COOKIE['antiflood_time']))
$id = Post::NewPost(intval($_GET['id']),$_POST['textedit'], $_SESSION['uid']);
$count =ceil(($id / 15 ));
if ($count >1)
{
if ($_COOKIE['antiflood_time']>time())
{
message_forum($lng['antiflood_enabled'],$_SERVER['REQUEST_URI']);
}
$page= '&amp;page='.$count;
}
else
{
setcookie('antiflood_time',(time() + $forum_config['time_antiflood']));
$page='';
}
$_POST['ntopic'] = strip_tags(addslashes($_POST['ntopic']));
if (isset($_POST['topic_sticky']))
$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)
{
$_POST['topic_sticky']='1';
$page= '&amp;page='.$count;
}
else
{
$_POST['topic_sticky']='0';
$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']);
$stop = TimeGeneration();
message_forum($lng['post_is_saved'],'topic.php?t='.$last);
}
else
{
$message = $lng['perror_1'];
$msg = './skins/'.$default_skin.'/post_error_body.tpl';
$redirect_url = 'topic.php?t='.$last;
break;
}
}
else
{
$_POST['ntopic'] = '';
$_POST['textedit']='';
//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;
}
$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']=='')
case 'edit':
{
message_forum($lng['no_forum'], 'index.php');
$_POST['textedit'] = (empty($_POST['textedit'])) ? stripslashes(Topic::PostInformation($_GET['id'],'text')) : $_POST['textedit'];
break;
}
if($forum['lock']=='1')
case 'rpost':
{
message_forum($lng['no_posting_forum_locked'],'index.php');
$_POST['textedit'] = (empty($_POST['textedit'])) ? '' : $_POST['textedit'];
break;
}
$skin['mainpage'] = $lng['writetopic'];
$skin['action'] = $_SERVER['REQUEST_URI'];
$skin['lmainpage'] = '</a>&gt; <a href="forum.php?f='.$_GET['f'].'" class="navigator">'.$forum['name'].'</a> &gt;<a href="posting.php?mode=ntopic&amp;f='.$_GET['f'].'" class="navigator">'.$lng['writetopic'];
$skin['f_id']=$_GET['f'];
if ($msg=='')
case 'ntopic':
{
$msg='./skins/'.$default_skin.'/blank.tpl';
$_POST['textedit'] = (empty($_POST['textedit'])) ? '' : $_POST['textedit'];
$_POST['ntopic'] = (empty($_POST['ntopic'])) ? '' : $_POST['ntopic'];
break;
}
include('./skins/'.$default_skin.'/overall_header.tpl');
include('./skins/'.$default_skin.'/posting_body.tpl');
include('./skins/'.$default_skin.'/overall_footer.tpl');
}
}
//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>&gt; <a href="forum.php?f='.$_GET['f'].'" class="navigator">'.$forum['name'].'</a> &gt;<a href="posting.php?mode=ntopic&amp;f='.$_GET['f'].'" class="navigator">'.$lng['writetopic']
));
break;
}
case 'edit':
{
$skin = array_push_assoc($skin, array(
'mainpage' => $lng['editpost'],
'lmainpage' => '</a>&gt; <a href="posting.php?mode=edit&amp;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>&gt; <a href="posting.php?mode=rpost&amp;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>&gt; <a href="posting.php?mode=qpost&amp;id='.$_GET['id'].'&amp;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');
?>