/***************************************************************************
* ExBB v.1.1 *
* Copyright (c) 2002-20õõ by Alexander Subhankulov aka Warlock *
* *
* http://www.exbb.net *
* email: admin@exbb.net *
* *
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/*
Íå èçìåíÿéòå ýòó êîíñòàíòó, åñëè íå çíàåòå çà÷åì îíà!
Best perfomance (more files) - 20480 (20 kB)
Optimal - 45-50 kB
Maximum - 80 kB
*/
define('MAX_THREAD_SIZE',20480); # 20 kB
include('common.php');
$vars = parsed_vars();
if ($vars['action'] == 'addnew' && $vars['previewfirst'] == 'no') { addnewthread(); }
elseif ($vars['action'] == 'addnew' && $vars['previewfirst'] == 'yes') { newthread(); }
elseif ($vars['action'] == 'addreply' && $vars['previewfirst'] == 'no') { addreply(); }
elseif ($vars['action'] == 'addreply' && $vars['previewfirst'] == 'yes') { reply(); }
elseif ($vars['action'] == 'new') { newthread(); }
elseif ($vars['action'] == 'reply') { reply(); }
elseif ($vars['action'] == 'replyquote') { replyquote(); }
elseif ($vars['action'] == 'poll') { poll_vote(); }
else { error($lang['Main_msg'],$lang['Correct_post']);}
include('page_tail.php');
function newthread() {
global $exbb,$lang,$vars,$inuser;
$inforum = $vars['forum'];
$forum = get_file($exbb['home_path'].'data/allforums.php');
if (!isset($forum[$inforum])) error($lang['Main_msg'],$lang['Dont_chg_url']);
$inmembmod = moderator($inforum,$forum);
if ( defined('IS_ADMIN') ) $inuser['private'][$inforum] = true;
if ( ($forum[$inforum]['private']) && (!$inuser['private'][$inforum]) ) error($lang['Posts_sent'],$lang['Post_no']);
$allof = false;
switch ($forum[$inforum]['status']) {
case 'reged': if (!$exbb['reged']) {$allof = true;} break;
default: $allof = false;
}
if ($allof) error($lang['Enter_error'],$lang['Reg_users_can']);
$set_poll = isset($vars['poll']) ? true : false;
$forumname = stripslashes($forum[$inforum]['name']);
$idmbcodestate = $forum[$inforum]['codes'];
$privateforum = $forum[$inforum]['private'];
$startnewthreads = $forum[$inforum]['status'];
if ($exbb['emoticons']) {
$emoticonslink = ''.$lang['Smiles_on'].'';
$emoticonsbutton = ''.$lang['Do_smiles'].'
';
}
if ($idmbcodestate) {
$codemap = '
';
$smilesmap = '
';
$java = '';
}
$upload = (isset($forum[$inforum]['upload']) && !empty($forum[$inforum]['upload']) && $exbb['file_upload']) ? $forum[$inforum]['upload'] : 0;
$hidden = '';
if ($upload && $inuser['upload']) {
$enctype = ' enctype="multipart/form-data"';
$hidden = '';
$filetoup = $lang['File_upload'].$upload.'
';
}
if ($set_poll) $hidden .= "\n".'';
# Add member to who's online
if (!$privateforum) whosonline($lang['Topic_create_in'].' '.$forumname.'');
if ($vars['previewfirst'] == 'yes') {
post_size();
$preview = str_replace( '$' , '$' , $vars['inpost'] );
$preview = ikoncode($preview);
if ($exbb['emoticons']) { $preview = setsmiles($preview); }
if ($exbb['wordcensor']) $preview = bads_filter($preview);
include('./templates/'.$exbb['default_style'].'preview.tpl');
unset($preview);
$vars['inpost'] = stripslashes($_POST['inpost']);
$vars['pollansw'] = stripslashes($_POST['pollansw']);
}
$startthreads = ($startnewthreads == 'no') ? ''.$lang['Admins_only'].'' : $lang['All_users_can'];
if (!$exbb['reged']) {$reg = ' '.$lang['You_reged'].'';}
else {
if ($exbb['emailfunctions']) $requestnotify = ($vars['notify'] == 'yes') ? ''.$lang['Do_email'].'
' : ''.$lang['Do_email'].'
';
$sig_show = ''.$lang['Do_sig'].'
';
$sticked = '';
if ($inmembmod) $sticked = ($vars['pin'] == 1) ? ''.$lang['Pin'].'?
' : ''.$lang['Pin'].'?
';
$reg = null;
}
$title_page = $exbb['boardname'].' :: '.$lang['Topic_create'];
include('./templates/'.$exbb['default_style'].'all_header.tpl');
include('./templates/'.$exbb['default_style'].'post_addnew.tpl');
include('./templates/'.$exbb['default_style'].'footer.tpl');
}
function addreply() {
global $exbb,$lang,$vars,$inuser;
$inforum = $vars['forum'];
$currenttime = time();
post_size();
if (($exbb['flood_limit']) && !defined('IS_ADMIN') ) {
$lastpost = $_SESSION['lastposttime'] + $exbb['flood_limit'];
if ($lastpost > $currenttime) error($lang['Reply_sent'],$lang['Flood_limit'].$exbb['flood_limit'].$lang['Flood_sec']);
}
$filetoopen = $exbb['home_path'].'data/allforums.php';
$allforums = get_file($filetoopen);
$all = fopen($filetoopen,'r+');
lock_file($all);
if (($allforums[$inforum]['private']) && (!$inuser['private'][$inforum])) {fclose($all); error($lang['Posts_sent'],$lang['Post_no']);};
if (!$exbb['reged'] and $allforums[$inforum]['status'] != 'all') {fclose($all); error($lang['Posts_sent'],$lang['Reg_users_can']);}
if ($exbb['sts'] == 'banned') {fclose($all); error($lang['Posts_sent'],$lang['You_deleted']);}
if ($vars['inpost'] == '') {fclose($all); error($lang['Posts_sent'],$lang['Mess_needed']);}
else { # start else
$inmembmod = moderator($inforum,$allforums);
$forumname = $allforums[$inforum]['name'];
$intopic = $vars['topic'];
$filetoopen = $exbb['home_path'].'forum'.$inforum.'/list.php';
$list = get_file($filetoopen);
$lst = fopen($filetoopen,'r+');
lock_file($lst);
$top_name = $list[$intopic]['name'];
if ( $list[$intopic]['state'] == 'closed' or $list[$intopic]['state'] == 'moved') {fclose($all); fclose($lst); error($lang['Reply_sent'],$lang['Topic_blocked']);}
$file_id = (isset($list[$intopic]['fls'])) ? $list[$intopic]['fls'] : '';
$filetoopen = $exbb['home_path'].'forum'.$inforum.'/'.$intopic.'-thd'.$file_id.'.php';
if ( !file_exists($filetoopen) ) {
fclose($all); fclose($lst);
sendmail($exbb['boardname'],$exbb['adminemail'],$lang['Topic_broken']."\n".$filetoopen,$lang['EXBB_ERROR'],$exbb['adminemail']);
error($lang['EXBB_ERROR'],$lang['Topic_broken']);
}
$allmessages = get_file($filetoopen);
$thd = fopen($filetoopen,'r+');
lock_file($thd);
ksort($allmessages,SORT_NUMERIC);
end($allmessages);
$last_key = key($allmessages);
$thd_count = count($allmessages);
#Check double clicking :)
if ( $allmessages[$last_key]['post'] == $vars['inpost'] ) {fclose($all); fclose($lst); fclose($thd); error($lang['Reply_sent'],$lang['Reply_sent_alrd'],'',false);}
if ($inmembmod) $vars['inpost'] = soft_clr_value($_POST['inpost']);
$vars['inpost'] = preg_replace( "#(\?|&|;|&)PHPSESSID=([0-9a-zA-Z]){32}#i", "", $vars['inpost'] );
$new_att = false;
if ($allforums[$inforum]['upload'] && $inuser['upload']) {
$exbb['uploadsize'] = $allforums[$inforum]['upload'];
$attach = attach_upload();
if (!empty($attach['attach_id']) && !empty($attach['attach_file'])) {
$allmessages[$currenttime]['attach_id'] = $attach['attach_id'];
$allmessages[$currenttime]['attach_file'] = $attach['attach_file'];
$new_att = true;
}
}
if ($allmessages[$last_key]['p_id'] == $exbb['mem_id'] && $exbb['reged'] && $currenttime - $last_key < 7200 && !$new_att) {
$allmessages[$last_key]['post'] .= '
[s]'.$lang['Adding_from'].'[/s]
'.$vars['inpost'];
$post_added = false;
$timelimit = $last_key;
} else {
include('./data/boardstats.php');
$post_added = true;
$exbb['totalposts']++;
save_statfile();
##########################################################################
clearstatcache();
if ( filesize($filetoopen) >= MAX_THREAD_SIZE ) {
$file_id = ( empty($file_id) ) ? 0 : intval($file_id);
$extmode = ( isset($list[$intopic]['ext']) ) ? unserialize($list[$intopic]['ext']) : array();
$extmode[$file_id] = $thd_count;
$file_id++;
$extmode[$file_id] = 1;
$list[$intopic]['ext'] = serialize($extmode);
$list[$intopic]['fls'] = $file_id;
fclose($thd);
$allmessages = array();
$filetoopen = $exbb['home_path'].'forum'.$inforum.'/'.$intopic.'-thd'.$file_id.'.php';
$thd = fopen($filetoopen,'a+');
lock_file($thd);
$thd_count = array_sum($extmode);
unset($extmode,$file_id,$thdid,$count);
}
elseif ( !empty($file_id) ) {
$extmode = array();
$extmode = ( isset($list[$intopic]['ext']) ) ? unserialize($list[$intopic]['ext']) : array();
$extmode[$file_id] = $thd_count + 1;
$list[$intopic]['ext'] = serialize($extmode);
$thd_count = array_sum($extmode);
$page = ceil($extmode[0]/intval($exbb['posts_per_page']))+$list[$intopic]['fls'];
unset($extmode,$file_id,$thdid,$count);
} else { $thd_count++; $page = ceil($thd_count/intval($exbb['posts_per_page']));}
##########################################################################
$allmessages[$currenttime]['p_id'] = $exbb['mem_id'];
$allmessages[$currenttime]['post'] = $vars['inpost'];
$allmessages[$currenttime]['ip'] = $vars['IP_ADDRESS'];
$allmessages[$currenttime]['smiles'] = ($vars['inshowemoticons'] == 'yes') ? true : false;
$allmessages[$currenttime]['sig'] = ($vars['inshowsignature'] == 'yes') ? true : false;
$timelimit = $currenttime;
}
#��������� ��������� �����
save_opened_file($thd,$allmessages);
@chmod($filetoopen,$exbb['ch_files']);
$allmessages = array();
if ($post_added) $allforums[$inforum]['posts']++;
$allforums[$inforum]['last_poster'] = $exbb['member'];
$allforums[$inforum]['last_poster_id'] = $exbb['mem_id'];
$allforums[$inforum]['last_post'] = $list[$intopic]['name'];
$allforums[$inforum]['last_post_id'] = $intopic;
$allforums[$inforum]['last_key'] = $timelimit;
$allforums[$inforum]['last_time'] = $currenttime;
save_opened_file($all,$allforums);
unset($attach);
$list[$intopic]['posts'] = $thd_count - 1;
$list[$intopic]['poster'] = $exbb['member'];
$list[$intopic]['p_id'] = $exbb['mem_id'];
$list[$intopic]['postdate'] = $currenttime;
uasort ($list, 'sort_by_postdate');
save_opened_file($lst,$list);
if ($exbb['reged']) {
if ($post_added) {
$inuser['posts']++;
$inuser['sig_on'] = ($vars['inshowsignature'] == 'yes') ? true : false;
if (isset($inuser['posted'][$inforum])) {$inuser['posted'][$inforum]++;} else {$inuser['posted'][$inforum] = 1;}
}
if (!$allforums[$inforum]['private']) {
$inuser['lastpost']['date'] = $currenttime;
$inuser['lastpost']['link'] = 'topic.php?forum='.$inforum.'&topic='.$intopic;
$inuser['lastpost']['name'] = $list[$intopic]['name'];
}
$filetomake = $exbb['home_path'].'members/'.$exbb['mem_id'].'.php';
save_file($filetomake,$inuser);
}
$_SESSION['lastposttime'] = $currenttime;
# email functions
if ($exbb['emailfunctions']) { # start mail
$filetoopen = $exbb['home_path'].'forum'.$inforum.'/'.$intopic.'-m.php';
$emailers = (file_exists($filetoopen)) ? get_file($filetoopen) : array();
if ($vars['notify'] == 'yes' and $exbb['reged']) {
if ( !isset($emailers[$exbb['mem_id']]) ) {
$emailers[$exbb['mem_id']] = 1;
save_file($filetoopen,$emailers);
@chmod($filetoopen,$exbb['ch_files']);
}
}
if ($exbb['mail_posts']) {
if ($exbb['wordcensor']) $vars['inpost'] = bads_filter($_POST['inpost']);
if (is_array($emailers)) {
unset($emailers[$exbb['mem_id']]);
$time = date("d-m-Y H:i:s",$currenttime);
$vars['inpost'] = str_replace("\n\n","\n",$vars['inpost']);
$vars['inpost'] = stripslashes($vars['inpost']);
$vars['inpost'] = preg_replace(array("'\[b\]'i","'\[/b\]'i","'\[i\]'i","'\[/i\]'i"),array("","","","",""), $vars['inpost'] );
include('./templates/'.$exbb['default_style'].'email_reply.tpl');
$forumname = strip_tags($forumname);
sendmail($exbb['boardname'],$exbb['adminemail'],$email,'['.$forumname.'] '.$top_name.' - '.$lang['Notify_by_email'],$emailers);
unset($emailers);
}
}
} # end email send.
$relocurl = 'topic.php?forum='.$inforum.'&topic='.$intopic.'&v=l#'.strval($timelimit);
$title_page = $exbb['boardname'] .' :: '.$lang['Sent_in'].' '.$forumname;
$ok_title = $lang['Added'];
$url1 = '
',"\n",$vars['inpost']);
$vars['inpost'] = str_replace('
',"\n",$vars['inpost']);
$addfield = $lang['New_topic_thks']."\n";
include('./templates/'.$exbb['default_style'].'email_reply.tpl');
sendmail($exbb['boardname'],$exbb['adminemail'],$email,"[$forumname] $lang[Notify_by_email]",$inuser['mail']);
}
#Send email for forum subscribers
$filetoopen = $exbb['home_path'].'forum'.$inforum.'/_f_track.php';
$emailers = ( file_exists($filetoopen) ) ? get_file($filetoopen) : array();
unset($emailers[$exbb['mem_id']]);
if (count($emailers)) {
include('./templates/'.$exbb['default_style'].'email_newtopic.tpl');
sendmail($exbb['boardname'],$exbb['adminemail'],$email,$lang['New_topic_inforum'].$forumname,$emailers);
}
}
$_SESSION['lastposttime'] = $currenttime;
$relocurl = 'topic.php?forum='.$inforum.'&topic='.$intopic;
$title_page = $exbb['boardname'].' :: '.$lang['Topic_created'];
$ok_title = $lang['Added'];
$url1 = '