/***************************************************************************
* 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. *
* *
***************************************************************************/
include('common.php');
$vars = parsed_vars();
switch ($vars['action']) {
case 'newposts': newpostst(); break;
case 't': in_topic(); break;
case 'members': members(); break;
default: search(); break;
}
include('page_tail.php');
function newpostst() {
global $exbb,$vars,$lang,$inuser;
$allforums = get_file($exbb['home_path'].'data/allforums.php');
$newest = array();
foreach ($allforums as $id=>$forum) {
if ( isset($forum['last_time']) && $forum['last_time'] > $exbb['last_visit'] ) {
if ($forum['private'] && !$inuser['private'][$id]) continue;
$newest[] = $id;
}
}
if (count($newest)) {
$to_show = array();
foreach ($newest as $inforum) {
$filetoopen = $exbb['home_path'].'forum'.$inforum.'/list.php';
$topics = array();
$topics = get_file($filetoopen);
$keys = array_keys($topics);
foreach ($keys as $id=>$topicid) {
if ($topics[$topicid]['postdate'] >= $exbb['last_visit'] && $topics[$topicid]['p_id'] != $exbb['mem_id']) {
$date = $topics[$topicid]['postdate'];
$to_show[$date] = $topics[$topicid]; //all info about topic
$to_show[$date]['f_id'] = $inforum;
$to_show[$date]['t_id'] = $topicid;
} else { break 1;}
}
}
unset($topics,$newest);
if (!count($to_show)) error($lang['Main_msg'],$lang['No_newposts'],'',0);
krsort($to_show,SORT_NUMERIC);
$data = '';
$l_v = $exbb['last_visit'];
$t_visits = (isset($_COOKIE['t_visits'])) ? unserialize($_COOKIE['t_visits']) : array();
$pinned = get_file($exbb['home_path'].'forum'.$inforum.'/_pinned.php');
foreach ($to_show as $date=>$topic){
if ($f_readed = (isset($_COOKIE['f'.$inforum])) ? $_COOKIE['f'.$inforum] : 0) {
$exbb['last_visit'] = $f_readed > $exbb['last_visit'] ? $f_readed : $exbb['last_visit'];
}
if ( isset($pinned[$topic['t_id']]) ) $topic['state'] = 'pinned';
$top_id = $topic['f_id'].$topic['t_id'];
$topicicon = topic_icon($topic,$t_visits[$top_id]);
$m_id = isset($topic['a_id']) ? $topic['a_id'] : 0;
$p_id = isset($topic['p_id']) ? $topic['p_id'] : 0;
$t_name = sprintf('%s',$topic['f_id'],$topic['t_id'],$date,wordwrap($topic['name'], 32, ' ', 1));
$t_desc = wordwrap($topic['desc'], 32, ' ', 1);
$f_name = sprintf('%s',$topic['f_id'],$allforums[$topic['f_id']]['name']);
$t_post = $topic['posts'];
$t_strt = $topic['author'] ? $topic['author'] : $lang['Unreg'];
$poster = $topic['poster'] ? $topic['poster'] : $lang['Unreg'];
$p_date = longdate($date+$exbb['usertime']*3600);
include('./templates/'.$exbb['default_style'].'newposts_data.tpl');
}
$found = count($to_show);
$icon_path = './templates/'.$exbb['default_style'].'im';
$title_page = $exbb['boardname'].' :: '.$lang['Search'];
include('./templates/'.$exbb['default_style'].'all_header.tpl');
include('./templates/'.$exbb['default_style'].'logos.tpl');
include('./templates/'.$exbb['default_style'].'newposts.tpl');
include('./templates/'.$exbb['default_style'].'footer.tpl');
}
else {
error($lang['Main_msg'],$lang['No_newposts'],'',0);
}
}
function in_topic() {
global $exbb,$vars,$lang;
$title_page = $exbb['boardname'].' :: '.$lang['Search'];
include('./templates/'.$exbb['default_style'].'all_header.tpl');
include('./templates/'.$exbb['default_style'].'logos.tpl');
include('./templates/'.$exbb['default_style'].'srch_intop.tpl');
include('./templates/'.$exbb['default_style'].'footer.tpl');
}
function members() {
global $exbb,$vars,$lang;
include($exbb['home_path'] . 'language/' . $exbb['default_lang'] . '/lang_reg.php');
$filetoopen = $exbb['home_path'].'data/users.php';
$users = get_file($filetoopen);
$total = count($users);
$pages = ($total) ? ceil($total/30) : 1;
$pagestart = ( isset($vars['p']) ) ? intval($vars['p']) : 1;
$sort = ( $vars['s'] == 'n' ) ? 'n' : 'd';
$order = ( $vars['order'] == 'DESC') ? 'DESC' : 'ASC';
$sort_arr = array('d'=>$lang['Sort_join'], 'n'=>$lang['Sort_name']);
$sort_mode = '';
unset($sort_arr);
if ($sort == 'd') {
ksort($users,SORT_NUMERIC);
} else {
uasort($users, 'sort_by_name');
}
$ids = array_keys($users);
unset($users);
$sort_order = '';
$p_order = '&s='.$sort.'&order='.$order;
if ($pagestart < 1 or $pagestart > $pages) $pagestart = 1;
if ($total > 30) {
$startarray = ($pagestart - 1) * 30;
$endarray = 30;
$page = '';
for($i=1;$i<=$pages;$i++){
if ($pagestart != $i) {$page .= ''.$i.' ';}
else {$page .= '['.$i.'] ';}
}
$pages = ''.$lang['Pages'].' ('.$pages.'): '.$page;
}
else {
$startarray = 0;
$pages = $lang['Pages'].' ('.$pages.')';
$endarray = $total;
}
$ids = array_slice($ids,$startarray,$endarray);
$profile = $lang['User_info'];
foreach ($ids as $id) {
$member = getmember($id);
if (!$member) { continue; }
$name = $member['name'];
$posts = $member['posts'];
$interests = $member['interests']?$member['interests']:"???";
if (!empty($member['title']) && $member['status'] != 'banned' ) { $title = $member['title']; }
else { switch ($member['status']) {
case 'ad' : $title = $lang['Admin']; break;
case 'me' : $title = $lang['User']; break;
case 'banned' : $title = $lang['User_banned']; break;
}
}
$location = $member['location'];
$joined = date("d.m.Y", $member['joined']);
if ($member['www'] != 'http://') {
$member['www'] = str_replace('http://','',$member['www']);
$www = (strlen($member['www']) > 4) ? ''.$lang['Look'].'' : ' ';
}
$email = ($member['showemail']) ? ''.$lang['Write'].'' : ''.$lang['Write'].'';
$icq = ($member['icq']) ? '' : ' ';
$class = ( !($id % 2) ) ? 'row1' : 'row2';
include('./templates/'.$exbb['default_style'].'memb_data.tpl');
}
$title_page = $exbb['boardname'].' :: '.$lang['Search'];
include('./templates/'.$exbb['default_style'].'all_header.tpl');
include('./templates/'.$exbb['default_style'].'logos.tpl');
include('./templates/'.$exbb['default_style'].'memblist.tpl');
include('./templates/'.$exbb['default_style'].'footer.tpl');
}
function sort_by_name($a, $b) {
return strcmp($a['n'], $b['n']);
}
function sort_by_posts($a, $b) {
if ($a['posts'] == $b['posts']) return 0;
return ($a['posts'] < $b['posts']) ? -1 : 1;
}
function search() {
global $exbb,$vars,$lang;
$allforums = get_file($exbb['home_path'].'data/allforums.php');
if ( !isset($vars['action']) ) {
$forums = '