Вход Регистрация
Файл: minibb11/bb_functions.php
Строк: 1622
<?
/*
bb_functions.php : basic functions file for miniBB.
Copyright (C) 2001-2002 miniBB.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.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

$datelog gmdate("Y-m-d H:i:s");
$cookieexptime time() + $cookie_expires;
$version '1.1';

$minimalistBB=$$cookiename;

function 
user_logged_in ($user) {

global 
$minimalistBB;
global 
$user_usr$user_pwd;
global 
$admin_usr$admin_pwd;
global 
$username$userpassword;
global 
$cookiename$cookieexptime$cookiepath$cookiedomain$cookiesecure$cookie_renew;

$returned FALSE;

$cookievalue $minimalistBB;
if(
$cookievalue) {
$cookievalue explode ("|"$cookievalue);
$username $cookievalue[0]; $userpassword $cookievalue[1]; $exptime $cookievalue[2];
if (
$user_usr!='' and $username!=$user_usr) { $returned=FALSE; return; }

$nowtime time();
$pasttime $exptime $nowtime;

if (
$user == 'admin') {
if (
$username == $admin_usr and $userpassword == md5($admin_pwd)) {
$returned TRUE;

if (
$pasttime <= $cookie_renew) {
// if expiration time of cookie is less than defined in setup, we redefine it below
$cook $admin_usr."|".md5($admin_pwd)."|".$cookieexptime;
setcookie ($cookiename);
setcookie ($cookiename$cook$cookieexptime$cookiepath$cookiedomain$cookiesecure);
}

else { 
$returned=FALSE; }
}
elseif (
$user == 'user' and $user_usr !=$admin_usr) {
$row DB_query(1,0);
if (
$row == TRUE
{
// It means that username exists in database; so let's check a password
$username $row[0]; $userpassword $row[1];
if (
$username == $user_usr and $userpassword == $user_pwd
{
//if username and password applies, we renew cookie if necessary
$returned TRUE;

if (
$pasttime <= $cookie_renew
{
// if expiration time of cookie is less than defined in setup, we redefine it below
$cook $user_usr."|".$user_pwd."|".$cookieexptime;
setcookie ($cookiename);
setcookie ($cookiename$cook$cookieexptime$cookiepath$cookiedomain$cookiesecure);
}
}
// username and password not apply
else { 
$returned FALSE;
}
}
//username is not in database; it means we have Anonymous user and need to set up it
else 

if (
$pasttime <= $cookie_renew) {
$cook $user_usr."||".$cookieexptime;
setcookie ($cookiename);
setcookie ($cookiename$cook$cookieexptime$cookiepath$cookiedomain$cookiesecure);
}
$returned FALSE
}
}
}
else {
$returned FALSE;
}
return 
$returned;
}

//----------------------------
function get_user_id_and_sort ($user_usr) {
$row DB_query(2,0);
if (
$row == TRUE) {
$returned = array ($row[0], $row[1]);
}
else 
$returned = array(0,0);
return 
$returned;
}

//---------------------------------------
function get_template_forum_orders($resultVal$count$forumID$l_mysql_error) {
// Get forumorder options
for ($i=0$i<=$count$i++) {
$a $i+1;
$forumorder.="<option value="".$a.""";
if (
$forumID == $resultVal["forum_id"][$i]) $forumorder.=" selected";
$forumorder.=">".$a."</option>";
}
return 
$forumorder;
}

//---------------------------------------
function getForumIcons() {
global 
$l_forumIcon$l_accessDenied;
$iconList='';
$handle=@opendir('./img/forum_icons');
if (
$handle) {
$ss 0;
while ((
$file readdir($handle))!==false) {
if (
$file != "." && $file != "..") {
$iconList.="<a href="JavaScript:paste_strinL('{$file}')" onMouseOver="window.status='{$l_forumIcon}: {$file}'; return true"><img src="./img/forum_icons/{$file}" width=16 height=16 border=0 alt="{$file}"></a>&nbsp;&nbsp;";
$ss++;
if (
$ss==5) {
$ss 0;
$iconList.="<br>n";
}
}
}
closedir($handle);
if (
$iconList==''$iconList=$l_accessDenied;
}
else {
$iconList=$l_accessDenied;
}

return 
$iconList;
}

//---------------------------------------
function get_forums_fast_preview ($resultVal$count$l_mysql_error) {
global 
$viewTopicsIfOnlyOneForum$l_topicsWillBeDisplayed$bb_admin;
// Get forums fast order preview in admin panel
$fast='';
for (
$i=0$i<=$count$i++) {
$fast.="<img src="./img/forum_icons/".$resultVal["forum_icon"][$i]."" width=16 height=16 border=0 alt="Forum icon">&nbsp;<b><a href=$bb_admin?action=editforum2&amp;forumID=".$resultVal["forum_id"][$i].">".stripslashes($resultVal["forum_name"][$i])."</a></b> [ORDER: ".$resultVal["forum_order"][$i]."] - <i><small>".stripslashes($resultVal["forum_desc"][$i])."</small></i><br>";
}
if (
$count and $viewTopicsIfOnlyOneForum == "1"$fast.="<br>".$l_topicsWillBeDisplayed;
return 
$fast;
}

function 
makeUp($name) {
global 
$l_meta;
global 
$l_tpl_not_found;
if (
substr($name05)=='email'$ext 'txt'; else $ext 'html';

chdir ('./templates');
if (
file_exists ('./'.$name.'.'.$ext)) { 
$fd fopen ('./'.$name.'.'.$ext'r'); 
$tpl addslashes(fread ($fdfilesize ('./'.$name.'.'.$ext))); 
fclose ($fd);
}
else {
header("Location: index.php");
}
chdir ('..');
return 
$tpl;
}

function 
load_header() {
//Because of loading page title, we need to load this template separately
global $title$bgColor$sitename$tableParam$l_meta$l_menu$l_sepr$l_reply$action$logged$errorMSG$adminPanel$user_logging;

if(
strlen($action)>or $adminPanel==1$l_menu[0] = "$l_sepr <a href="./index.php">$l_menu[0]</a> "; else $l_menu[0]='';
if(
$action=='vtopic'$l_menu[7] = "$l_sepr <a href="#newtopic">$l_menu[7]</a> "; 
elseif($action=='vthread'$l_menu[7] = "$l_sepr <a href="#newreply">$l_reply</a> "; else $l_menu[7]='';
if($action!='stats'$l_menu[3] = "$l_sepr <a href="./index.php?action=stats">$l_menu[3]</a> "; else $l_menu[3]='';
if(
$action!='search'$l_menu[1] = "$l_sepr <a href="./index.php?action=search">$l_menu[1]</a> "; else $l_menu[1]='';
if(
$action!='registernew'&&$logged !=and $adminPanel!=1$l_menu[2] = "$l_sepr <a href="./index.php?action=registernew">$l_menu[2]</a> "; else $l_menu[2]='';
if(
$action!='manual'$l_menu[4] = "$l_sepr <a href="./index.php?action=manual">$l_menu[4]</a> "; else $l_menu[4]='';
if(
$action!='prefs'&&$logged == 1$l_menu[5] = "$l_sepr <a href="./index.php?action=prefs">$l_menu[5]</a> "; else $l_menu[5]='';
if(
$action!='language'$l_menu[8] = "$l_sepr <a href="./index.php?action=language">$l_menu[8]</a> "; else $l_menu[8]='';
if(
$logged==1$l_menu[6] = "$l_sepr <a href="./index.php?mode=logout">$l_menu[6]</a> "; else $l_menu[6]='';

if (!isset(
$title)) $title=$sitename;

$tplHeader makeUp('main_header'); eval("$tplHeader = "$tplHeader";"); $tplHeader=stripslashes($tplHeader);
return 
$tplHeader;
}


function 
viewThread(){
global 
$tableParam;
global 
$sitename$viewmaxreplys;
global 
$l_header_main$l_author$l_sub_answer$l_message$l_forumnotexists$l_topicnotexists$l_back$l_moveTopic$l_deleteTopic$l_closeTopic$l_unlockTopic$l_edit$l_editedBy$l_deletePost$l_sepr$l_admin$l_member$l_emptyTopic$l_returntoforums$l_posted$l_disableBbCode$l_whatIsIt$l_sub_post_msg$l_topic_closed$l_quoting$l_warnEncoding;
global 
$user_id$logged_admin$logged_user$forum$topic$page$title$makeLim$deleteTopic$closeTopic$moveTopic$loginLogout$postText$userRanks;

$listPosts=''$deleteTopic='';

if(!
$page$query=DB_query(3,0);

$row=DB_query(8,0);
if(!
$row){
$errorMSG=$l_forumnotexists$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title $title.$l_forumnotexists;

$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

$forumName=$row[0]; $forumIcon=$row[2];

$topicData=DB_query(5,0);
if(
$topicData and $topicData[4]==$forum){
$topicName $topicData[0];
if (
$topicName==''$topicName=$l_emptyTopic;
$topicStatus $topicData[1];
$topicPoster $topicData[2];
$topicPosterName $topicData[3];
}
else {
$errorMSG=$l_topicnotexists$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title $title.$l_topicnotexists;

$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

$numRows=DB_query(6,0);

if (
$page==-1$page=pageChk($page,$numRows,$viewmaxreplys);

$pageNav=pageNav($page,$numRows,"index.php?action=vthread&amp;forum=$forum&amp;topic=$topic&amp;page=",$viewmaxreplys,FALSE);
$makeLim=makeLim($page,$numRows,$viewmaxreplys);

$anchor 1;
$i=0;
$cols DB_query(7,0);

$tpl makeUp('main_posts_cell');

do{
if(
$i%2==0$bg=$tableParam[8];
elseif(
$i%2==1$bg=$tableParam[9];

$postDate str_replace ('<br>',' ',convert_date($cols[2]));

$allowedEdit "<a href="index.php?action=editmsg&amp;topic=$topic&amp;forum=$forum&amp;post={$cols[6]}&amp;page=$page&amp;anchor=$anchor">$l_edit</a>";

if (
$logged_admin == 1) { 
$viewIP $l_sepr IP: <a href="index.php?action=viewipuser&amp;postip={$cols[4]}">".$cols[4]."</a>"
$allowed $allowedEdit." "."<a href="index.php?action=delmsg&amp;topic=$topic&amp;forum=$forum&amp;post={$cols[6]}&amp;page=$page">$l_deletePost</a>";

else { 
$cols[4]='';
if (
$user_id==$cols[0] and $user_id !=and $cols[5]!=2) {
$allowed $allowedEdit;
}
else {
$allowed='';
}
}

if (
$cols[5] == 0) {
$editedBy=''
}
else {
$editedBy $l_sepr $l_editedBy".($cols[5]==2?"<a href="index.php?action=userinfo&user=1">".$l_admin."</a>":$cols[1]); 
}

if (
$cols[0] !=0) {
$cc=$cols[0];
if (isset(
$userRanks[$cc])) $ins=$userRanks[$cc];
else 
$ins=($cc==1?$l_admin:$l_member);
$viewReg "<a href="index.php?action=userinfo&user={$cc}">$ins</a>";
}
else 
$viewReg='';

$posterName=$cols[1];
$posterText=$cols[3];

$eValued $tpl;
eval(
"$eValued = "$eValued";");
$listPosts.=stripslashes($eValued);

$i++;
$anchor++;
}
while(
$cols=DB_query(7,1));

$l_messageABC=$l_sub_answer;
if (
$topicStatus == 0) {
$emailCheckBox emailCheckBox();
$mainPostForm makeUp('main_post_form'); stripslashes(eval("$mainPostForm = "$mainPostForm";")); 
$mainPostArea makeUp('main_post_area'); 
}
else {
$mainPostArea makeUp('main_post_closed'); 
}
eval(
"$mainPostArea = "$mainPostArea";"); $mainPostArea stripslashes($mainPostArea);

if (
$logged_admin == 1) {
$deleteTopic "$l_sepr <a href="index.php?action=deltopic&amp;forum=$forum&amp;topic=$topic">$l_deleteTopic</a>";
$moveTopic "$l_sepr <a href="index.php?action=movetopic&amp;forum=$forum&amp;topic=$topic&amp;page=$page">$l_moveTopic</a>";
if (
$topicStatus == 0$closeTopic "<a href="index.php?action=locktopic&amp;forum=$forum&amp;topic=$topic">$l_closeTopic</a>";
if (
$topicStatus == 1$closeTopic "<a href="index.php?action=unlocktopic&amp;forum=$forum&amp;topic=$topic">$l_unlockTopic</a>";
}

if (
$user_id == $topicPoster and $user_id !=0) {
if (
$topicStatus == 0$closeTopic "<a href="index.php?action=locktopic&amp;forum=$forum&amp;topic=$topic">$l_closeTopic</a>";
if (
$topicStatus == 1$closeTopic "<a href="index.php?action=unlocktopic&amp;forum=$forum&amp;topic=$topic">$l_unlockTopic</a>";
}

$title $title.$topicName;

$main makeUp('main_posts');
$forumsList getForumsList($forum0);

eval(
"$main = "$main";"); echo load_header().stripslashes($main); 
}

//-------------------------->
function viewTopic(){
global 
$tableParam;
global 
$sitename$viewmaxtopic$viewmaxreplys$viewTopicsIfOnlyOneForum
global 
$l_emptyTopic$l_chooseForum$l_message$l_forumnotexists$l_noTopicsInForum$l_back$l_returntoforums$l_sortedBy$l_sortBy$l_topic$l_replies$l_views$l_author$l_posted$l_sub_post_tpc$l_new_topic$l_disableBbCode$l_whatIsIt$l_emptyTopic$l_anonymous$l_warnEncoding;
global 
$user_id$logged_admin$logged_user$loginLogout$forum$topic$page$title$user_sort$sortBy$sortedByT$sortByT$sortByNew$makeLim$postText$warning;

$list_topics='';
$pageNav '';
$forumsList '';

if (
$viewTopicsIfOnlyOneForum=='1') { $forum DB_query(16,0); $forum $forum[0]; }

if (!
$forum or !($row=DB_query(8,0))) {
$errorMSG=$l_forumnotexists$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title $title.$l_forumnotexists;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

$forumName $row[0];$forumIcon $row[2];

if (
$user_sort==''$user_sort 0/* Sort messages default by last answer (0) desc OR 1 - by last new topics */

$numRows=DB_query(9,0);

if (
$numRows == 0) {
$errorMSG=$l_noTopicsInForum$correctErr='';
$title $title.$l_noTopicsInForum;
$warn makeUp('main_warning'); eval("$warn = "$warn";"); $warn=stripslashes($warn);
}

else {

$warn='';
//if at least one topic exists in this forum

$pageNav=pageNav($page,$numRows,"index.php?action=vtopic&amp;forum=$forum&amp;sortBy=$sortBy&amp;page=",$viewmaxtopic,FALSE);
$makeLim=makeLim($page,$numRows,$viewmaxtopic);

if (
$user_sort==1) { $cols=DB_query(10,0); $sus 10; }
else { 
$cols=DB_query(11,0); $sus 11; }

$i=0;

$tpl makeUp('main_topics_cell');

do{
if(
$i%2==0$bg=$tableParam[8];
elseif(
$i%2==1$bg=$tableParam[9];
$topic=$cols[0];
$topicTitle=$cols[1];
if (
$topicTitle==''$topicTitle=$l_emptyTopic;
$numReplies=0;
$numViews=$cols[5];
$lastAuthor=$cols[3];
$numReplies=DB_query(6,0);

$pageNavCell=pageNav(0,$numReplies,"index.php?action=vthread&amp;forum=$forum&amp;topic=$topic&amp;page=",$viewmaxreplys,TRUE);

if(
$numReplies>=1$numReplies-=1;
$whenPosted convert_date($cols[4]);
if (
trim($cols[1]) == ''$cols[1]=$l_emptyTopic;

if (
$cols[3]==''$cols[3]=$l_anonymous;

if (
$cols[6]==1$tpcIcon='locked';
elseif (
$numReplies<=0$tpcIcon 'empty';
elseif (
$numReplies>=$viewmaxreplys$tpcIcon 'hot';
else 
$tpcIcon 'default';

$eValued $tpl;
eval(
"$eValued = "$eValued";");
$list_topics.=stripslashes($eValued);
$i++;

}
while(
$cols=DB_query($sus,1));
}
//if topics are in this forum
$forumsList getForumsList($forum1);

$l_messageABC=$l_message;

$emailCheckBox emailCheckBox();

$mainPostForm makeUp('main_post_form'); eval("$mainPostForm = "$mainPostForm";"); $mainPostForm stripslashes($mainPostForm);

$title $title.$forumName;

$main makeUp('main_topics');
eval(
"$main = "$main";"); echo load_header().$warn.stripslashes($main);
}

//-------------------------------------------------
function lastDiscussions(){
global 
$tableParam;
global 
$sitename$viewlastdiscussions$viewmaxtopic$viewmaxreplys$user_sort$sortBy$l_anonymous;
global 
$l_emptyTopic;
global 
$page$forum$topic;

if (
$user_sort==''$user_sort 0// Sort messages default by last answer (0) desc OR 1 - by last new topics

//Define forum icons
$fIconsRow=DB_query(16,0);
if (
$fIconsRow) {
do {
$ind=$fIconsRow[0];
$fIcon[$ind]=$fIconsRow[3];
}
while(
$fIconsRow=DB_query(16,1));
}

if (
$user_sort==1) { $cols DB_query(14,0); $sus 14; }
else { 
$cols DB_query(15,0); $sus 15; }

$list_topics '';

if (
$cols) {

$i=0;
$tpl makeUp('main_last_discussions_cell');

do{
$forum=$cols[6];
$topic=$cols[0];
$topic_title=$cols[1];
if (
$topic_title==''$topic_title=$l_emptyTopic;
$numViews=$cols[5];
$lastPoster=$cols[3];
if(
$i%2==0$bg=$tableParam[8];
elseif(
$i%2==1$bg=$tableParam[9];
$numReplies=0;
$numReplies=DB_query(6,0);

$pageNavCell=pageNav(0,$numReplies,"index.php?action=vthread&amp;forum=$forum&amp;topic=$topic&amp;page=",$viewmaxreplys,TRUE);

if(
$numReplies>=1$numReplies-=1;
$whenPosted convert_date ($cols[4]);
if (
trim($cols[1]) == ''$cols[1]=$l_emptyTopic;

if (
$cols[3] == ''$cols[3]=$l_anonymous;

//Forum icon
$ind $cols[6]; $forumIcon $fIcon[$ind]; 
if (
$forumIcon == ''$forumIcon='default.gif';

$eValued $tpl;
eval(
"$eValued = "$eValued";");
$list_topics.=stripslashes($eValued);
$i++;
}
while(
$cols=DB_query($sus,1));
}

return 
$list_topics;

}


//---------------------->
function viewForum(){
global 
$tableParam;
global 
$title$sitename;
global 
$l_forum$l_num_topics$l_num_posts;
global 
$forum$user_logging;

$cols=DB_query(16,0);
$i=0;
$tpl=makeUp('main_forums_cell');
$list_forums '';
do{
if(
$i%2==0$bg=$tableParam[8];
elseif(
$i%2==1$bg=$tableParam[9];
$forum=$cols[0];
$forum_icon=$cols[3];
$forum_desc=$cols[2];
$forum_title=$cols[1];
$numTopics=DB_query(9,0);
$numPosts=DB_query(95,0);
$numPosts=$numPosts-$numTopics;

$eValued $tpl;
eval(
"$eValued = "$eValued";");
$list_forums.=stripslashes($eValued);

$i++;
}
while(
$cols=DB_query(16,1));
$title=$sitename;

$main makeUp('main_forums');
eval(
"$main = "$main";");
echo 
load_header().stripslashes($main);
}



//---------------------->
function getIP(){
$ip1 getenv('REMOTE_ADDR');
$ip2 getenv('HTTP_X_FORWARDED_FOR');
if (
$ip2!=''$finalIP $ip2; else $finalIP $ip1;
$finalIP=substr($finalIP016);
return 
$finalIP;
}


//---------------------->
function postThread(){
global 
$tableParam;
global 
$post_text_maxlength$post_word_maxlength$viewmaxreplys$postRange$emailusers$emailadmin$sitename$main_url$admin_email;
global 
$l_emptyPost$l_back$l_forbidden$l_anonymous$l_returntoforums$l_antiSpam;
global 
$forum$topic$action$logged$user_email$anchor$postText$poster_ip$user_usr$user_id$disbbcode$TT$title$errorMSG$CheckSendMail;

//Check if topic is not locked
if (DB_query(43,0)==1) {
$errorMSG=$l_forbidden$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title $title.$l_forbidden;

$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
else {
if (!
$user_usr$user_usr=$l_anonymous;
if (
$postText==''$postText $TT;

if (
$postText=='') {
$errorMSG=$l_emptyPost$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title $title.$l_emptyPost;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

$postText=textFilter($postText,$post_text_maxlength,$post_word_maxlength,1,$disbbcode,1$user_id);
$poster_ip=getIP();

//Posting query with anti-spam protection

if(DB_query(19,0)) {

if (
$user_id==or DB_query(79,0)) { 
$query=DB_query(20,0);

if (
$emailusers==or $emailadmin==1) {
$topicTitle DB_query(5,0);
$topicTitle $topicTitle[0];
$postTextSmall strip_tags(substr(str_replace('<br>'"n"$postText), 0200)).'...';
$msg makeUp('email_reply_notify'); eval("$msg = "$msg";"); $msg=stripslashes($msg);
$sub=explode('SUBJECT>>'$msg); $sub=explode('<<'$sub[1]); $msg=trim($sub[1]); $sub=$sub[0];
}

//Email all users about this reply if allowed
if ($emailusers==1) {
$row DB_query(83,0);
do {
if (
$row[0]!=$user_id and $row[1]!='') {
sendMail ($row[1], $sub$msg$admin_email$admin_email);
}
}
while (
$row=DB_query(83,1));
}

//Email admin if allowed
if ($emailadmin==and $user_id!=1) {
sendMail ($admin_email$sub$msg$admin_email$admin_email);
}

//Insert user into email notifies if allowed
$user_email DB_query(63,$user_id); $user_email $user_email[4];
if (
$CheckSendMail and emailCheckBox()!='' and substr(emailCheckBox(),0,8)!='<!--U-->' and $user_email!=''DB_query(81,0);
}
else {
$errorMSG=$l_antiSpam$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_antiSpam;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

}
else {
$errorMSG=$l_forbidden$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_forbidden;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

$totalPosts = (integer) DB_query(6,0);
$vmax = (integer) $viewmaxreplys;
$anchor $totalPosts;
if (
$anchor>$vmax$anchor $totalPosts-((floor($totalPosts/$vmax))*$vmax);
}
}


//--------------------->
function postTopic(){
global 
$topic_max_length$post_word_maxlength$postRange$tableParam;
global 
$l_returntoforums$l_topiccannotempty$l_emptyTopic$l_anonymous$l_back$l_forbidden$l_mysql_error$l_antiSpam;
global 
$poster_ip$forum$topic$user_usr$user_id$TT$title$errorMSG$disbbcode$topicTitle$CheckSendMail;

if (!
$user_usr$user_usr=$l_anonymous;

if (
$topicTitle=='') {
$errorMSG=$l_topiccannotempty$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_topiccannotempty;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
else {
$TT $topicTitle;
$topicTitle=textFilter($topicTitle,$topic_max_length,$post_word_maxlength,0,1,0,$user_id);
}

$poster_ip=getIP();

if(
DB_query(8,0)) {
if (
$user_id==or DB_query(79,0)) {
$topic=DB_query(22,0); 
if(
$topic>0) { postThread(); }
else {
$errorMSG=$l_mysql_error$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_mysql_error;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}
else {
$errorMSG=$l_antiSpam$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_antiSpam;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

}
else {
$errorMSG=$l_forbidden$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_forbidden;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

}

//--------------------->
function deltopic() {
global 
$tableParam;
global 
$l_returntoforums$l_forbidden$l_back$l_areYouSureDeleteTopic$l_topicnotexists$l_topicsDeleted$l_postsDeleted$l_itseemserror$l_yes$l_no$l_submit;
global 
$topic$forum$dy$logged_admin$title;

if (
$logged_admin == 1) {
switch (
$dy) {
case 
1:
$topicsDel DB_query(23,0);
$postsDel DB_query(24,0)-1;
$errorMSG=$l_topicsDeleted.$topicsDel."<br>".$l_postsDeleted.$postsDel
if (
$postsDel and $topicDel == 0$errorMSG.="<br>".$l_itseemserror;
$correctErr "<a href="index.php?action=vtopic&amp;forum=$forum">$l_back</a>";
$title.=$l_topicsDeleted;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
break;

default:
if(!
$topic$topic = -1;
$topicName DB_query(25,0);
if(!
$topicName) {
$errorMSG=$l_topicnotexists$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_topicnotexists;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
else {
$title.=$l_postsDeleted;
$tpl makeUp('tools_delete_topic_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}
}
else {
$errorMSG=$l_forbidden$correctErr='';
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}

//--------------->
function locktopic($status) {
global 
$tableParam;
global 
$l_returntoforums$l_forbidden$l_back$l_topicLocked$l_topicUnLocked$l_itseemserror;
global 
$topic$forum$logged_admin$user_id$errorMSG$title;

if (
$status !=and $status !=0$status 1;

if (
DB_query(26,0)==TRUE or $logged_admin == 1) {
if (
DB_query(27,$status)>0) {
$errorMSG = ($status == 1?$l_topicLocked:$l_topicUnLocked);
}
else {
$errorMSG=$l_itseemserror;
}
$correctErr "<a href="index.php?action=vthread&amp;forum=$forum&amp;topic=$topic">$l_back</a>";
}
else {
$errorMSG=$l_forbidden$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_forbidden;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
$title.=$errorMSG;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

//--------------->
function deleteMsg($step) {
global 
$tableParam;
global 
$l_returntoforums$l_forbidden$l_back$l_itseemserror$l_postNotExist$l_areYouSureDeletePost$l_postDeleted$l_postID$l_poster$l_yes$l_no$l_submit;
global 
$topic$forum$page$post$logged_admin$user_id$errorMSG$title;

if (
$step !=and $step !=0$step 0;
//0 - 1st step, 1-delete concrete

if ($logged_admin == and !DB_query(42,0)) {

switch(
$step) {
case 
1:
if(
$row=DB_query(41,0) and DB_query(50,0)) {
$errorMSG=$l_postDeleted$correctErr "<a href="index.php?action=vthread&amp;forum=$forum&amp;topic=$topic&amp;page=$page">$l_back</a>";
}
else {
$errorMSG=$l_itseemserror$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
}
break;

default:
$msgData=DB_query(40,0);
if(
$msgData){
$Poster $msgData[0];
$title.=$l_areYouSureDeletePost;
$tpl makeUp('tools_delete_msg_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
else {
$errorMSG=$l_postNotExist$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_postNotExist;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}
}
else {
$errorMSG=$l_forbidden$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_forbidden;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
$title.=$errorMSG;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

//--------------->
function editMsg($step) {
global 
$tableParam;
global 
$topic_max_length$post_text_maxlength$post_word_maxlength;
global 
$cookiename$cookiepath$cookiedomain$cookiesecure$postRange, ${$cookiename.'Update'};
global 
$l_returntoforums$l_emptyPost$l_forbidden$l_back$l_itseemserror$l_postNotExist$l_postEdited$l_messageABC$l_editPost$l_topicTitleUpdated$l_onlyAdminCanEdit$l_topicTextUpdated$l_edit$l_topicTitle$l_disableBbCode$l_whatIsIt$l_warnEncoding$l_antiSpam;
global 
$topic$forum$page$post$postText$postTopic$anchor$logged_admin$user_id$errorMSG$title$disbbcode$loginLogout;

if (${
$cookiename.'Update'} and $user_id!=1) {
$errorMSG=$l_antiSpam$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_antiSpam;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

//$postTopic=''; 
$userAllow=0;

if (!isset(
$disbbcode)) $disbbcode 0;

if (
$post) {

if (
$step !=and $step !=0$step 0;
//0 - 1st step, 1-edit concrete

//Now check if admin or corresponding user are logged
if (($logged_admin==or $userAllow=DB_query(44,0)) and $user_id !=0) {

if (
DB_query(47,0)==and $logged_admin!=1) {
$errorMSG=$l_onlyAdminCanEdit$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_onlyAdminCanEdit;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
else {

switch (
$step) {
case (
1):
$errorMSG='';

if (
strlen($postText)==0) {
$title.=$l_emptyPost;
$errorMSG=$l_emptyPost;
$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
}
else {

//Update topic title if admin is logged, if it is first post
if ($logged_admin==and DB_query(42,0)) {
$postTopic=textFilter($postTopic,$topic_max_length,$post_word_maxlength,0,1,0,$logged_admin);
if (
DB_query(46,0)) $errorMSG.=$l_topicTitleUpdated."<br>"
//else $errorMSG.=$l_itseemserror."<br>";
}

if (
$userAllow$pSt 1; elseif ($logged_admin==1$pSt=2; else $pSt=1;

$postText=textFilter($postText,$post_text_maxlength,$post_word_maxlength,1,$disbbcode,1,$logged_admin);

$updatePost DB_query(48,$pSt);
if (
$updatePost !=0$errorMSG.=$l_topicTextUpdated."<br>"
//else $errorMSG.=$l_itseemserror."<br>";

$title.=$l_editPost;
$correctErr "<a href="index.php?action=vthread&amp;forum=$forum&amp;topic=$topic&amp;page=$page&amp;anchor=$anchor">$l_back</a>";
}

if (
$user_id!=1) {
setcookie ($cookiename.'Update');
setcookie ($cookiename.'Update'1time()+$postRange$cookiepath$cookiedomain$cookiesecure); 
}

$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
break;

default:
if (
$row=DB_query(45,0)) {

$postText=deCodeBB($row[0]);
$postTopic=$row[1];

$l_messageABC=$l_editPost;
if (
$logged_admin==and DB_query(42,0)) {
$mainPostForm=makeUp('tools_edit_topic_title');
eval(
"$mainPostForm = "$mainPostForm";"); $mainPostForm stripslashes($mainPostForm);
} else 
$mainPostForm='';

$emailCheckBox='';

$eValued makeUp('main_post_form');
eval(
"$eValued = "$eValued";");
$eValued stripslashes($eValued);

$mainPostForm.=$eValued;

$title.=$l_editPost;

$tpl makeUp('tools_edit_post');
eval(
"$tpl = "$tpl";");
$tpl stripslashes($tpl);

echo 
load_header().stripslashes($tpl);
}
else {
$errorMSG=$l_postNotExist$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_postNotExist;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}
}
}
else {
$errorMSG=$l_forbidden$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$title.=$l_forbidden;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}
else {
$title.=$l_forbidden;
$errorMSG=$l_forbidden;
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl);
}

}

//--------------->
function moveTopic($step) {
global 
$tableParam;
global 
$l_returntoforums$l_forbidden$l_back$l_itseemserror$l_topicMoved$l_goTopic$l_topicnotexists$l_moveTopic$l_yes$l_no$l_to;
global 
$topic$forum$page$logged_admin$user_id$errorMSG$title$forumWhere;

if (
$topic) {

if (
$step !=and $step !=0$step 0;
//0 - 1st step, 1-edit concrete

if ($logged_admin==and DB_query(5,0) and DB_query(8,0) and DB_query(28,0)>1) {

switch(
$step) {
case 
1:

if (isset(
$topic) and isset($forum) and isset($forumWhere)) {
if (
DB_query(51,0)) {
$title=$l_topicMoved;
$errorMSG=$l_topicMoved;
$correctErr "<a href="index.php?action=vthread&amp;topic=$topic&amp;forum=$forumWhere">$l_goTopic</a>";
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
else {
$title=$l_itseemserror;
$errorMSG=$l_itseemserror;
$correctErr "<a href="index.php?action=vthread&amp;topic=$topic&amp;forum=$forum&amp;page=$page">$l_back</a>";
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}
else {
$title=$l_forbidden;
$errorMSG=$l_forbidden;
$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

break;

default:
$forumsList='';
if (
$row=DB_query(16,0)) {
do {
if (
$row[0] != $forum$forumsList.="<option value="".$row[0]."">".$row[1]."</option>n";
}
while (
$row=DB_query(16,1));
}

$topicTitle DB_query(5,0); $topicTitle $topicTitle[0];

$tpl makeUp('tools_move_topic'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl);
}
}
else {
$title=$l_forbidden;
$errorMSG=$l_forbidden;
$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}
else {
$title=$l_topicnotexists;
$errorMSG=$l_topicnotexists;
$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}

//--------------->
function userInfo($user) {
global 
$tableParam$stats_inf_table_color$sitename$viewmaxtopic;
global 
$l_userInfo$l_userNotExists$l_userInfo$l_about$l_back$l_returntoforums$l_usrInfo$l_userLastTopics$l_userLastPosts$l_stats_numTopics$l_stats_numPosts;
global 
$title;

$USERINFO='';

$row DB_query(63,$user);
if (
$row) {
if (
$row[10]!=1$row[4]=''; else $row[4]='<a href="mailto:'.$row[4].'">'.$row[4].'</a>';
if (
$row[6]!=''$row[6]='<a href="'.$row[6].'" target="_new">'.$row[6].'</a>'; else $row[6]='';
$row[2] = str_replace('<br>'' 'convert_date($row[2]));

$usrCell makeUp('main_user_info_cell');

for (
$i=1$i<10$i++) {

if (isset(
$l_usrInfo[$i]) and $row[$i]!=''
{

$what=$l_usrInfo[$i]; $whatValue=$row[$i];
$cell $usrCell;
eval(
"$cell = "$cell";"); $cell=stripslashes($cell);
$USERINFO.=$cell;
}
}

/* Topics count */
if ($lastT=DB_query(94,0)) {
$what=$l_stats_numTopics;
$whatValue=$lastT[0];
$cell=$usrCell; eval("$cell = "$cell";"); $cell=stripslashes($cell);
$USERINFO.=$cell;
}

/* Posts count */
if ($lastT=DB_query(93,0)) {
$what=$l_stats_numPosts;
$whatValue=$lastT[0]-$whatValue;
$cell=$usrCell; eval("$cell = "$cell";"); $cell=stripslashes($cell);
$USERINFO.=$cell;
}

/* Last topics */
if ($lastT=DB_query(90,0)) {
$what=$l_userLastTopics;
$whatValue='';
do {
$whatValue.='<li><a href="index.php?action=vthread&topic='.$lastT[0].'&amp;forum='.$lastT[1].'&amp;page=-1">' .$lastT[2].'</a>';
}
while (
$lastT=DB_query(90,1));
$cell=$usrCell;
eval(
"$cell = "$cell";"); $cell=stripslashes($cell);
$USERINFO.=$cell;
}

/* Last posts */
if ($lastT=DB_query(91,0)) {
$what=$l_userLastPosts;
$whatValue='';
do {
$whatValue.='<li><a href="index.php?action=vthread&topic='.$lastT[0].'&amp;forum='.$lastT[1].'&amp;page=-1">' .$lastT[2].'</a>';
}
while (
$lastT=DB_query(91,1));
$cell=$usrCell;
eval(
"$cell = "$cell";"); $cell=stripslashes($cell);
$USERINFO.=$cell;
}

/* Activities */
$what=$l_usrInfo[10]; $whatValue=uFstats($user);
$cell=$usrCell;
eval(
"$cell = "$cell";"); $cell=stripslashes($cell);
$USERINFO.=$cell;

$userInfo $l_about.' "'.$row[1].'"';
$title.=$l_about.' '.$row[1];
$tpl makeUp('main_user_info'); 
}
else {
$title.=$l_userNotExists;
$errorMSG=$l_userNotExists;
$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$tpl makeUp('main_warning');
}

eval(
"$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

//--------------->
function get_microtime () {
$mtime microtime();
$mtime explode(" ",$mtime);
$mtime $mtime[1] + $mtime[0];
$time_is $mtime;
return 
$time_is;
}

//--------------->
function convert_date ($dateR) {
global 
$l_months$dateFormat;

$months explode (":"$l_months);
if (
sizeof($months)!=12$dateR "N/A";
else {
list (
$currentD$currentT) = explode (' '$dateR);
$cAll explode ("-"$currentD);
$dateR str_replace ("DD"$cAll[2], $dateFormat);
$dateR str_replace ("YYYY"$cAll[0], $dateR);
$whichMonth $cAll[1]-1;
$dateR str_replace ("MM"$months[$whichMonth], $dateR);
$dateR str_replace ("T"$currentT$dateR);
}
return 
$dateR;
}

//--------------->
function wrapText($wrap,$text){
$exploded=explode(' ',$text);
for(
$i=0;$i<sizeof($exploded);$i++) if(strlen($exploded[$i])>$wrap$exploded[$i]=chunk_split($exploded[$i],$wrap,' ');
return 
implode(' ',$exploded);
}

//--------------->
function urlMaker($text,$wrap){
$text str_replace("n"" n "$text);

$words=explode(' ',$text);
for(
$i=0;$i<sizeof($words);$i++){

if (
strlen($words[$i])>$wrap$word=chunk_split($words[$i],$wrap,' '); else $word=$words[$i];
//Trim below is necessary is the tag is placed at the begin of string

if(strtolower(substr($words[$i],0,7))=='http://'$word='<a href="'.$words[$i].'" target="_new">'.$word.'</a>';
elseif(
strtolower(substr($words[$i],0,8))=='https://'$word='<a href="'.$words[$i].'" target="_new">'.$word.'</a>';
elseif(
strtolower(substr($words[$i],0,6))=='ftp://'$word='<a href="'.$words[$i].'" target="_new">'.$word.'</a>';
elseif(
strtolower(substr($words[$i],0,4))=='ftp.'$word='<a href="ftp://'.$words[$i].'" target="_new">'.$word.'</a>';
elseif(
strtolower(substr($words[$i],0,4))=='www.'$word='<a href="http://'.$words[$i].'" target="_new">'.$word.'</a>';
elseif(
strtolower(substr($words[$i],0,7))=='mailto:'$word='<a href="'.$words[$i].'">'.$word.'</a>';
$words[$i]=$word;
//$words[$i] = str_replace ("n ", "n", $words[$i]);
}
$ret str_replace (" n ""n"implode(' ',$words));
return 
$ret;
}

//--------------->
function enCodeBB ($msg$admin) {

$pattern[0] = "/[url=(.+?)](.+?)[/url]/i";
$replacement[0] = '<a href="\1" target="_new">\2</a>';

$pattern[1] = "/[email=(.+?)](.+?)[/email]/i";
$replacement[1] = '<a href="mailto:\1">\2</a>';

$pattern[2] = "/[img(left|right)?](http://(.+?).(gif|jpg))[/img]/i";
$replacement[2] = '<img src="\2" border="0" align="\1" alt="">';

$pattern[3] = "/[[bB]](.+?)[/[bB]]/s";
$replacement[3] = '<b>\1</b>';

$pattern[4] = "/[[iI]](.+?)[/[iI]]/s";
$replacement[4] = '<i>\1</i>';

$pattern[5] = "/[[uU]](.+?)[/[uU]]/s";
$replacement[5] = '<u>\1</u>';

if (
$admin == 1) {
$pattern[6] = "/[font(#[A-F0-9]{6})](.+?)[/font]/is";
$replacement[6] = '<font color="\1">\2</font>';
}

$msg preg_replace($pattern$replacement$msg);
return 
$msg;
}

//--------------->
function deCodeBB ($msg) {
$pattern[0] = "/<a href="mailto:(.+?)">(.+?)</a>/i";
$replacement[0] = "[email=\1]\2[/email]";

$pattern[1] = "/<a href="(.+?)" target="_new">(.+?)</a>/i";
$replacement[1] = "[url=\1]\2[/url]";

$pattern[2] = "/<img src="(.+?)" border="0" align="(left|right)?" alt="">/i";
$replacement[2] = "[img\2]\1[/img]";

$pattern[3] = "/<[bB]>(.+?)</[bB]>/s";
$replacement[3] = "[b]\1[/b]";

$pattern[4] = "/<[iI]>(.+?)</[iI]>/s";
$replacement[4] = "[i]\1[/i]";

$pattern[5] = "/<[uU]>(.+?)</[uU]>/s";
$replacement[5] = "[u]\1[/u]";

$pattern[6] = "/<font color="(#[A-F0-9]{6})">(.+?)</font>/is";
$replacement[6] = '[font\1]\2[/font]';

$msg preg_replace($pattern$replacement$msg);
$msg str_replace ('<br>'"n"$msg);
return 
$msg;
}

//--------------->
function textFilter($text,$size,$wrap,$urls,$bbcodes,$eofs,$admin){
$text=trim(chop(htmlspecialchars($text,ENT_QUOTES)));
$text=str_replace(chr(92).chr(92).chr(92).chr(92), '&#92;&#92;'$text);
$text=str_replace(chr(92).chr(92), '&#92;'$text);
$text=str_replace('&amp;#''&#'$text);
if(
$urls and !$bbcodes) {
$text=urlMaker($text,$wrap);
}
if (!
$bbcodes) {
$text enCodeBB($text$admin);
}
else 
$text=wrapText($wrap,$text);
if(
$size) {
if(
strlen($text)>$size) {
$text=substr($text,0,$size);
//Avoid special symbols extract
$tmpArr explode ('&'$text);
$last sizeof($tmpArr)-1;
if (
$last>0) {
if (
substr_count($tmpArr[$last], ';')==0array_pop($tmpArr);
$text implode ('&'$tmpArr);
}
}
}
if(
$eofs){
while (
substr_count($text"rnrnrnrn")>4$text=str_replace("rnrnrnrn","rn",$text);
while (
substr_count($text"nnnn")>4$text=str_replace("nnnn","n",$text);
$text=str_replace("n",'<br>',$text);
}
return 
$text;
}

//--------------->
function pageChk($page,$numRows,$viewMax){
if(
$numRows>and ($page>or $page==-1)){
$max=$numRows/$viewMax;
if(
intval($max)==$max$max=intval($max)-1; else $max=intval($max);
if (
$page==-1) return $max;
elseif(
$page>$max) return $max;
else return 
$page;
}
else return 
0;
}

//--------------->
function pageNav($page,$numRows,$url,$viewMax,$navCell){
global 
$viewpagelim;
if(
$viewpagelim>=1$viewpagelim-=1;
$pageNav='';
$page=pageChk($page,$numRows,$viewMax);
$iVal=intval(($numRows-1)/$viewMax);
if(
$iVal>$viewpagelim$iVal=$viewpagelim;
if(
$numRows>0&&$iVal>0&&$numRows<>$viewMax){
$end=$iVal;
if(!
$navCell$start=0; else $start=1;
if(
$page>0&&!$navCell$pageNav=' <a href="'.$url.($page-1).'">&lt;&lt;</a>';
if(
$navCell&&$end>4){ $end=3;$pageNav.=' . '; }
elseif(
$page<9&&$end>9){ $end=9;$pageNav.=' . '; }
elseif(
$page>=9&&$end>9){
$start=intval($page/9)*9-1;$end=$start+10;
if(
$end>$iVal$end=$iVal;
$pageNav.=' <a href="'.$url.'0">1</a> ...';
}
else 
$pageNav.=' . ';
for(
$i=$start;$i<=$end;$i++){
if(
$i==$page&&!$navCell$pageNav.=' <b>'.($i+1).'</b> .';
else 
$pageNav.=' <a href="'.$url.$i.'">'.($i+1).'</a> .';
}
if(((
$navCell&&$iVal>4)||($iVal>9&&$start<$iVal-10))){
if(
$navCell&&$iVal<6); else $pageNav.='..';
for(
$n=$iVal-1;$n<=$iVal;$n++){
if(
$n>=$i$pageNav.=' <a href="'.$url.$n.'">'.($n+1).'</a> .';
}
}
if(
$page<$iVal&&!$navCell$pageNav.=' <a href="'.$url.($page+1).'">&gt;&gt;</a>';
return 
$pageNav;
}
}

//--------------->
function makeLim($page,$numRows,$viewMax){
$page=pageChk($page,$numRows,$viewMax);
if(
intval($numRows/$viewMax)!=0&&$numRows>0){
if (
$page>0) return ' LIMIT '.($page*$viewMax).','.$viewMax;
else return 
' LIMIT '.$viewMax;
}
else return 
'';
}

//--------------->
function deSlice($lsTopics,$id){
global 
$user_sort;
global 
$forum;
$user_sort+=0;$i=0;$sPage=0;
if(
$lsTopics){
global 
$viewmaxtopic;
if(
$user_sort==1){
$cols=DB_query(76,0);
do{
$i++;if($id==$cols[0]) break;}
while(
$cols=DB_query(76,1));
}
else{
$cols=DB_query(77,0);
do{
$i++;if($id==$cols[0]) break;}
while(
$cols=DB_query(77,1));
}
$sPage=intval(($i-1)/$viewmaxtopic);
}
else{
global 
$viewmaxreplys;
$cols=DB_query(78,0);
do{
$i++;if($id==$cols[0]) break;}
while(
$cols=DB_query(78,1));
$sPage=intval(($i-1)/$viewmaxreplys);
}
return 
$sPage;
}

//--------------->
function search(){
global 
$tableParam;
global 
$l_returntoforums$l_searchSite$l_search$sitename;
global 
$forum$topic$page$searchFor$searchWhere$searchHow$searchString$searchString2$searchResults$title$makeLim;
global 
$viewmaxsearch;

$searchWhere+=0;$searchHow+=0;$word=0;$min=2;
$exploded=explode(' ',$searchFor);
if(
$searchHow==0){
if(
strlen($exploded[0])>$min$word=1;
$searchString="'%$exploded[0]%'";
$searchString2=$searchString;
for(
$i=1;$i<sizeof($exploded);$i++){
if(!
$word&&strlen($exploded[$i])>$min$word=1;
if(
$searchWhere==0){
$searchString.=" AND posts.post_text LIKE '%$exploded[$i]%'";
$searchString2.=" AND topics.topic_title LIKE '%$exploded[$i]%'";
}
elseif(
$searchWhere==1$searchString.=" AND topic_title LIKE '%$exploded[$i]%'";
elseif(
$searchWhere==2$searchString.=" AND poster_name LIKE '%$exploded[$i]%'";
}
}
elseif(
$searchHow==1){
$word=1;
if(
strlen($exploded[0])>$min){
$searchString="'%$exploded[0]%'";
$searchString2=$searchString;
for(
$i=1;$i<sizeof($exploded);$i++){
if(
$word&&strlen($exploded[$i])<=$min) {$word=0; break;}
if(
$searchWhere==0){
$searchString.=" OR posts.post_text LIKE '%$exploded[$i]%'";
$searchString2.=" OR topics.topic_title LIKE '%$exploded[$i]%'";
}
elseif(
$searchWhere==1$searchString.=" OR topic_title LIKE '%$exploded[$i]%'";
elseif(
$searchWhere==2$searchString.=" OR poster_name LIKE '%$exploded[$i]%'";
}
}
else {
$word=0;}
}
else{
for (
$i=0;$i<sizeof($exploded);$i++){
if (
strlen($exploded[$i])>$min) {$word=1; break;}
}
$searchString="'%$searchFor%'";
$searchString2=$searchString;
}
unset(
$exploded);
if(
$searchWhere!=0) unset($searchString2);

if(!
$word||strlen($searchFor)>100) {
$title=$title.$l_search[10];$searchResults='<small>'.$l_search[10].'</small>';
}
else {
$i=$viewmaxsearch*$page;
if(
$searchWhere==0){
$numRows=DB_query(53,0);
$pageNav=pageNav($page,$numRows,"index.php?action=search&amp;searchFor=$searchFor&amp;searchWhere=$searchWhere&amp;searchHow=$searchHow&amp;page=",$viewmaxsearch,FALSE);
$makeLim=makeLim($page,$numRows,$viewmaxsearch);
if(
$numRows){
$cols=DB_query(4,0);
do{
$i++;
$searchResults.='<b>'.$i.'. </b><small>posted :: '.$cols[4].'</small> - <a href="index.php?action=vtopic&amp;forum='.$cols[1].'&amp;page='.deSlice(TRUE,$cols[2]).'">'.$cols[6].'</a> <b>&#8212;&#8250;</b> <a href="index.php?action=vthread&amp;forum='.$cols[1].'&amp;topic='.$cols[2].'">'.$cols[5].'</a><br>'."n".'
&nbsp;&nbsp;&nbsp; <small><a href="index.php?action=vthread&amp;forum='
.$cols[1].'&amp;topic='.$cols[2].'&amp;page='.deSlice(FALSE,$cols[0]).'">'.substr(strip_tags($cols[3]),0,81).'...</a></small><br><br>'."n";
}
while(
$cols=DB_query(4,1));
}
}
elseif(
$searchWhere==1){
$numRows=DB_query(54,0);
$pageNav=pageNav($page,$numRows,"index.php?action=search&amp;searchFor=$searchFor&amp;searchWhere=$searchWhere&amp;searchHow=$searchHow&amp;page=",$viewmaxsearch,FALSE);
$makeLim=makeLim($page,$numRows,$viewmaxsearch);
if(
$numRows){
$cols=DB_query(52,0);
do{
$i++;
$searchResults.='<b>'.$i.'. </b><small>posted :: '.$cols[3].'</small> - <a href="index.php?action=vtopic&forum='.$cols[1].'&amp;page='.deSlice(TRUE,$cols[0]).'">'.$cols[4].'</a> <b>&#8212;&#8250;</b> <a href="index.php?action=vthread&amp;forum='.$cols[1].'&amp;topic='.$cols[0].'">'.$cols[2].'</a><br><br>'."n";
}
while(
$cols=DB_query(52,1));
}
}
elseif(
$searchWhere==2){
$numRows=DB_query(58,0);
$pageNav=pageNav($page,$numRows,"index.php?action=search&amp;searchFor=$searchFor&amp;searchWhere=$searchWhere&amp;searchHow=$searchHow&amp;page=",$viewmaxsearch,FALSE);
$makeLim=makeLim($page,$numRows,$viewmaxsearch);
if(
$numRows){
$cols=DB_query(57,0);
do{
$i++;
$searchResults.='<b>'.$i.'. </b><small>posted :: '.$cols[4].'</small> - <a href="index.php?action=vtopic&amp;forum='.$cols[1].'&amp;page='.deSlice(TRUE,$cols[2]).'">'.$cols[6].'</a> <b>&#8212;&#8250;</b> <a href="index.php?action=vthread&amp;forum='.$cols[1].'&amp;topic='.$cols[2].'">'.$cols[5].'</a><br>'."n".'&nbsp;&nbsp;&nbsp; <small><a href="index.php?action=vthread&amp;forum='.$cols[1].'&amp;topic='.$cols[2].'&amp;page='.deSlice(FALSE,$cols[0]).'">'.substr(strip_tags($cols[3]),0,81).'...</a></small><br><br>'."n";
}
while(
$cols=DB_query(57,1));
}
}
$title $title.$l_searchSite;
}
$tpl makeUp('search'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl);
}

//---------------------->
function uFstats($user){
global 
$tableParam$stats_barColor$stats_barWidth$stats_barWidthLim;
global 
$forum$userID;
$userID=$user+0;$key2='';
$list_uFstats='';
$tpl=makeUp('stats_bar');
if(
$cols=DB_query(72,0)){
do{
if(
$cols[2]){
$val=$cols[2];
if(!isset(
$vMax)) $vMax=$val;
$stats_barWidth=round(100*($val/$vMax));
if(
$stats_barWidth>$stats_barWidthLim$key='<a href="index.php?action=vtopic&amp;forum='.$cols[0].'">'.$cols[1].'</a>';
else{
$key2='<a href="index.php?action=vtopic&amp;forum='.$cols[0].'">'.$cols[1].'</a>';
$key='<a href="index.php?action=vtopic&amp;forum='.$cols[0].'">...</a>';
}
$eValued $tpl;
eval(
"$eValued = "$eValued";"); $eValued stripslashes($eValued);
$list_uFstats.=$eValued;
}
else break;
}
while(
$cols=DB_query(72,1));
return 
$list_uFstats;
}
else {
return 
'';
}
}

//---------------------->
function statistics(){
global 
$tableParam$sitename$stats_barColor$stats_barWidth$stats_barWidthLim;
global 
$l_stats$l_stats_numUsers$l_stats_numTopics$l_stats_numPosts$l_stats_aUsers$l_stats_popular$l_stats_viewed$l_stats_top;
global 
$topic$key$top$makeLim;
global 
$l_stats_admin$l_stats_lastReg;
global 
$adminInf$lastRegUsr;
$top+=0;$key2='';
function 
fTopa($top){
if(
$top==0$topa=5;
elseif(
$top==1$topa=10;
elseif(
$top==2$topa=20;
else 
$topa=40;
return 
$topa;
}
$statsTop=' . ';
for(
$i=0;$i<4;$i++){
if(
$i<>$top$statsTop.='<a href="index.php?action=stats&amp;top='.$i.'">'.$l_stats_top.' '.fTopa($i).'</a> . ';
else 
$statsTop.=$l_stats_top.' '.fTopa($i).' . ';
}

$makeLim='LIMIT '.fTopa($top);

$tpl=makeUp('stats_bar');

if(
$cols=DB_query(39,0)){
do{
if(
$cols[3]){
$val=$cols[3]-1;
if(!isset(
$vMax)) $vMax=$val;
if (
$vMax!=0$stats_barWidth=round(100*($val/$vMax));
if(
$stats_barWidth>$stats_barWidthLim$key='<a href="index.php?action=vthread&amp;forum='.$cols[2].'&amp;topic='.$cols[0].'">'.$cols[1].'</a>';
else{
$key2='<a href="index.php?action=vthread&amp;forum='.$cols[2].'&amp;topic='.$cols[0].'">'.$cols[1].'</a>';
$key='<a href="index.php?action=vthread&amp;forum='.$cols[2].'&amp;topic='.$cols[0].'">...</a>';
}
$eValued=$tpl;
eval(
"$eValued="$eValued";");$eValued=stripslashes($eValued);
$list_stats_popular.=$eValued;
}
else break;
}
while(
$cols=DB_query(39,1));
unset(
$vMax);$key2='';
}

if(
$cols=DB_query(12,0)){
do{
if(
$cols[1]){
if(!isset(
$vMax)) $vMax=$cols[1];
$val=$cols[1];
$stats_barWidth=round(100*($val/$vMax));
if(
$stats_barWidth>$stats_barWidthLim$key='<a href="index.php?action=vthread&amp;forum='.$cols[3].'&amp;topic='.$cols[0].'">'.$cols[2].'</a>';
else{
$key2='<a href="index.php?action=vthread&amp;forum='.$cols[3].'&amp;topic='.$cols[0].'">'.$cols[2].'</a>';
$key='<a href="index.php?action=vthread&amp;forum='.$cols[3].'&amp;topic='.$cols[0].'">...</a>';
}
$eValued=$tpl;
eval(
"$eValued="$eValued";");$eValued=stripslashes($eValued);
$list_stats_viewed.=$eValued;
}
else break;
}
while(
$cols=DB_query(12,1));
unset(
$vMax);$key2='';
}

if(
$cols=DB_query(55,0)){
do{
if(
$cols[2]){
$val=$cols[2];
if(!isset(
$vMax)) $vMax=$val;
$stats_barWidth=round(100*($val/$vMax));
if(
$stats_barWidth>$stats_barWidthLim$key='<a href="index.php?action=userinfo&amp;user='.$cols[0].'">'.$cols[1].'</a>';
else{
$key2='<a href="index.php?action=userinfo&amp;user='.$cols[0].'">'.$cols[1].'</a>';
$key='<a href="index.php?action=userinfo&amp;user='.$cols[0].'">...</a>';
}
$eValued=$tpl;
eval(
"$eValued="$eValued";");$eValued=stripslashes($eValued);
$list_stats_aUsers.=$eValued;
}
else break;
}
while(
$cols=DB_query(55,1));
unset(
$cols);
}
$numUsers=DB_query(36,0);
$numTopics=DB_query(37,0);
$numPosts=DB_query(38,0);
$adminInf=DB_query(75,0);
$lastRegUsr=DB_query(74,0);
$main=makeUp('stats');
eval(
"$main="$main";");
echo 
load_header().stripslashes($main);
}

//---------------------->
function manual() {
global 
$tableParam;
global 
$title$main_url$l_menu;

$manual makeUp('manual');
eval(
"$manual = "$manual";");
$manual stripslashes($manual);

$title.=$l_menu[4];
$tpl makeUp('faq');
eval(
"$tpl = "$tpl";");
echo 
load_header().stripslashes($tpl);
}

//---------------------->
function viewipuser($posterip) {
global 
$tableParam;
global 
$l_forbidden$l_back$l_usersIPs$l_userIP$sitename$l_userNoIP;
global 
$logged_admin$title;
$listUsers='';

if (
$logged_admin == and $posterip !='') {

$title.=$l_usersIPs." ".$posterip.":";

$l_usersIPs $l_usersIPs." ".$posterip;

if (
$row=DB_query(59,0)) {
$listUsers.="<ul>";
do {
$star = ($row[1]!=0?"<a href="index.php?action=userinfo&user={$row[1]}">*</a>":"");
$listUsers.="<li><p>{$row[0]}{$star}";;
}
while (
$row=DB_query(59,1));
$listUsers.="</ul>";
}
else {
$listUsers=$l_userNoIP;
}
$tpl makeUp('tools_userips'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
else {
$title.=$l_forbidden;
$errorMSG=$l_forbidden;
$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}

//---------------------->
function sendMail ($email$subject$msg$from_email$errors_email) {
// Function sends mail with return-path (if incorrect email TO specifed. Reply-To: and Errors-To: need contain equal addresses!
$msg=str_replace("rn""n"$msg);

$php_version phpversion();
$from_email "From: $from_emailnReply-To: $errors_emailnErrors-To: $errors_emailnX-Mailer: PHP ver. $php_version";

mail($email$subject$msg$from_email);
}

function 
deHtmlspecialchars($strline) {
return 
str_replace('&amp;''&'str_replace('&quot;''"'str_replace('&lt;''<'str_replace('&gt;''>'$strline))));
}

//---------------------->
function getUserData() {
global 
$login$passwd$passwd2$email$icq$website$occupation$from$interest$showemail$sorttopics;
//DON'T CHANGE first index to 0
$userData[1] = trim($login);
$userData[2] = $passwd;
$userData[3] = $passwd2;
$userData[4] = trim($email);
$userData[5] = trim($icq);
$userData[6] = trim($website);
$userData[7] = htmlspecialchars(trim($occupation));
$userData[8] = htmlspecialchars(trim($from));
$userData[9] = htmlspecialchars(trim($interest));
$userData[10] = $showemail;
$userData[11] = $sorttopics;
return 
$userData;
}

function 
editPrefs ($step) {
global 
$tableParam;
global 
$l_userErrors$l_editPrefs$l_max$l_sub_name$l_necessaryFields$l_symbols$l_sub_pass$l_passOnceAgain$l_onlyIfChangePwd$l_email$l_userOcc$l_websiteUrl$l_userFrom$l_chooseCountry$l_userInterest$l_userViewEmail$l_yes$l_no$l_sortTopics$l_newTopics$l_newAnswers$l_forbidden$l_returntoforums$l_mysql_error$l_prefsUpdated$l_prefsNotUpdated$l_prefsPassUpdated$l_userErrors$l_errorUserData$sitename;
global 
$user_id$logged$admin_email$title$login$passwd$passwd2$email$icq$website$occupation$from$interest$showemail$sorttopics$email1;

if (
$logged==1) {

if (!isset(
$warning)) $warning='';
$l_fillRegisterForm ='';
$editable 'disabled';
$userTitle=$l_editPrefs;
$l_passOnceAgain.=' (<small>'.$l_onlyIfChangePwd.')</small>';
$actionName='editprefs';

$userData DB_query(63,$user_id);
if (
$userData) {

if (
$step==1) {
$login $userData[1];
$userData getUserData();

$showEmailYes = ($userData[10]==1)?'checked':'';
$showEmailNo = ($showEmailYes=='checked')?'':'checked';
$sortTopics1 = ($userData[11]==1)?'checked':'';
$sortTopics0 = ($sortTopics1=='checked')?'':'checked';

$correct checkUserData($userData'upd');
$email1 $userData[4];
if (
DB_query(71,0)==or ($email1==$admin_email and $user_id!=1)) $correct=4;

if (
$correct=='ok') {
//Update db
$upd DB_query(70,$userData);
if (
$upd) {
$title.=$l_prefsUpdated;
$warning=$l_prefsUpdated;
if (
$userData[2]!=''$warning.=', '.$l_prefsPassUpdated;
}
else {
$title.=$l_editPrefs;
$warning=$l_prefsNotUpdated;
}

}
else {
if (
$l_userErrors[$correct] == ''$l_userErrors[$correct]=$l_undefined;
$warning $l_errorUserData.": <font color=red><b>{$l_userErrors[$correct]}</b></font>";
$title.=$l_errorUserData;
}

$tpl makeUp('user_dataform'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

else {
//step=0
$login $userData[1];
$passwd '';
$passwd2='';
$email $userData[4];
$icq $userData[5];
$website $userData[6];
$occupation deHtmlspecialchars($userData[7]);
$from deHtmlspecialchars($userData[8]);
$interest deHtmlspecialchars($userData[9]);

$showEmailYes = ($userData[10]==1)?'checked':'';
$showEmailNo = ($showEmailYes=='checked')?'':'checked';
$sortTopics1 = ($userData[11]==1)?'checked':'';
$sortTopics0 = ($sortTopics1=='checked')?'':'checked';

$title.=$l_editPrefs;
$tpl makeUp('user_dataform'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

}
else {
$title.=$l_mysql_error$errorMSG=$l_mysql_error$correctErr '';
$tpl makeUp('main_warning'); 
}
}
else {
$title.=$l_forbidden$errorMSG=$l_forbidden$correctErr '';
$tpl makeUp('main_warning'); 
}

eval(
"$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;

}

//---------------------->
function getForumsList ($frm$st) {
//$st: 1 - dont show included forum, 0 - show all (select included)
global $tableParam$viewTopicsIfOnlyOneForum;
global 
$l_chooseForum;

if (
$viewTopicsIfOnlyOneForum!=1) {
$row=DB_query(16,0);
if (
$row) {
$i=0;
$listForums '';
$tpl makeUp('main_forums_list');
do {
$sel='';
if (
$st==1) {
if (
$row[0]!=$frm$listForums.='<option value='.$row[0].'>'.$row[1].'</option>'."n";
}
else {
if (
$row[0]==$frm$sel ' selected';
$listForums.='<option value='.$row[0].$sel.'>'.$row[1].'</option>'."n";
}
$i++;
}
while (
$row=DB_query(16,1));

if (
$i>1) {
eval(
"$tpl = "$tpl";"); $tpl stripslashes($tpl); return $tpl;
}
else {
return 
'';
}
}
else {
return 
'';
}

}
else {
return 
'';
}

}

//---------------------->
function checkUserData($userData$act) {
global 
$userRegName$disallowNames;

$userRegExp "^[".$userRegName."]{3,40}$";

if (!
eregi($userRegExp,$userData[1]) or in_array($userData[1],$disallowNames)) { return 1; }
elseif (
$act=='reg' and !eregi("^[A-Za-z0-9_]{5,32}$"$userData[2])) { return 2; }
elseif (
$act=='upd' and $userData[2]!='' and !eregi("^[A-Za-z0-9_]{5,32}$"$userData[2])) { return 2; }
elseif (
$userData[2] != $userData[3]) { return 3; }
elseif (!
eregi("^[0-9a-z]+([._-][0-9a-z]+)*_?@[0-9a-z]+([._-][0-9a-z]+)*[.][0-9a-z]{2}[0-9A-Z]?[0-9A-Z]?$"$userData[4])) { return 4; }
elseif (
$userData[5] != '' and !eregi("^[0-9]*$"$userData[5])) { return 5; }
elseif (
$userData[6] != '' and !eregi("^(f|ht)tp[s]?://.*$"$userData[6])) { return 6; }
else { return 
"ok"; }
}

//---------------------->
function registerUser($step) {
global 
$tableParam;
global 
$l_userErrors$l_returntoforums$l_userRegistered$l_newUserRegister$l_back$l_necessaryFields$l_fillRegisterForm$l_max$l_symbols$l_sub_name$l_sub_pass$l_passOnceAgain$l_email$l_websiteUrl$l_userOcc$l_userFrom$l_chooseCountry$l_userInterest$l_userViewEmail$l_yes$l_no$l_sortTopics$l_newTopics$l_newAnswers$l_errorUserData$l_undefined$l_thankYouReg$l_goToLogin$l_itseemserror$l_errorUserExists;
global 
$sitename$admin_email$admin_usr$emailadmin$logged$user_usr$login$passwd$passwd2$email$icq$website$occupation$from$interest$showemail$sorttopics$main_url$title$showEmailYes$showEmailNo$sortTopics1$sortTopics0;

$warning=''$editable '';
$actionName 'register';

if (
$logged != 1) {

if (
$showemail=='') { 
$showEmailYes 'checked'$showEmailNo ''
}
else {
$showEmailYes = ($showemail==1)?'checked':'';
$showEmailNo = ($showEmailYes=='checked')?'':'checked';
}

if (
$sorttopics=='') {
$sortTopics1 'checked'$sortTopics0 '';
}
else {
$sortTopics1 = ($sorttopics==1)?'checked':'';
$sortTopics0 = ($sortTopics1=='checked')?'':'checked';
}

if (
$user_usr and $step==0$login $user_usr;
$userTitle=$l_newUserRegister;

switch(
$step) {
case 
1:
$userData getUserData();

if (
DB_query(60,0) and !DB_query(62,$userData) and $userData[1]!=$admin_usr and $userData[4]!=$admin_email) {

$correct checkUserData($userData'reg');

if (
$correct=="ok") {

$row=DB_query(61,$userData);
if (
$row) {

$emailMsg makeUp('email_user_register'); eval("$emailMsg = "$emailMsg";"); 
$emailMsg stripslashes($emailMsg);
$sub=explode('SUBJECT>>'$emailMsg); $sub=explode('<<'$sub[1]); $emailMsg=trim($sub[1]); $sub=$sub[0];
sendMail($userData[4], $sub$emailMsg$admin_email$admin_email);

if (
$emailadmin==1) {
$emailMsg makeUp('email_admin_userregister'); eval("$emailMsg = "$emailMsg";"); 
$emailMsg stripslashes($emailMsg);
$sub=explode('SUBJECT>>'$emailMsg); $sub=explode('<<'$sub[1]); $emailMsg=trim($sub[1]); $sub=$sub[0];
sendMail($admin_email$sub$emailMsg$userData[4], $admin_email);
}

$title.=$l_userRegistered;
$errorMSG=$l_thankYouReg;
$correctErr=$l_goToLogin;
$tpl makeUp('main_warning'); 
}
else {
$title.=$l_itseemserror;
$errorMSG=$l_itseemserror;
$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$tpl makeUp('main_warning');
}
}
else {
if (
$l_userErrors[$correct] == ''$l_userErrors[$correct]=$l_undefined;
$warning $l_errorUserData.": <font color=red><b>{$l_userErrors[$correct]}</b></font>";
$title.=$l_errorUserData;
$tpl makeUp('user_dataform');
}
}
else {
$title.=$l_errorUserExists;
$warning $l_errorUserData.': <font color=red><b>'.$l_errorUserExists.'</b></font>';
$tpl makeUp('user_dataform');
}
eval(
"$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
break;

default:
$title.=$l_newUserRegister;
$tpl makeUp('user_dataform'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;

}
}
else {
$title.=$l_userRegistered;
$errorMSG=$l_userRegistered;
$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}

//---------------------->
function send_password ($step) {
global 
$tableParam;
global 
$l_send$l_pwdWillBeSent$l_emailNotExists$l_emailSent$l_back$l_returntoforums$l_itseemserror;
global 
$email$admin_email$title$sitename$main_url$newPasswd$confirmCode$updID;

$newPasswd=''$confirmCode='';

if (
$email=='' or $email==$admin_email$email='';

if (
$step == 0) {
$title.=$l_pwdWillBeSent;
$tpl makeUp('tools_send_password'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
elseif (
$step == 1) {
$updID=DB_query(67,0);
if (
$updID<=0) {

$title.=$l_emailNotExists;
$errorMSG=$l_emailNotExists;
$correctErr "<a href="JavaScript:history.back(-1)">$l_back</a>";
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
else {

$newPasswd substr(ereg_replace("[^0-9A-Za-z]""A"md5(uniqid(rand()))),0,8);
$confirmCode substr(md5(uniqid(rand())),0,32);

$update=DB_query(68,0);

if (
$update>0) {
$msg makeUp("email_user_password"); eval("$msg = "$msg";"); $msg stripslashes($msg);
$sub=explode('SUBJECT>>'$msg); $sub=explode('<<'$sub[1]); $msg=trim($sub[1]); $sub=$sub[0];
sendMail($email$sub$msg$admin_email$admin_email);

$title.=$l_emailSent;
$errorMSG=$l_emailSent;
$correctErr '';
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
else {
$title.=$l_itseemserror;
$errorMSG=$l_itseemserror;
$correctErr '';
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}
}
}
}

//---------------------->
function confirm_password($confirmCode) {
global 
$tableParam;
global 
$l_forbidden$l_returntoforums$l_itseemserror$l_passwdUpdate;
global 
$title;

if (
$confirmCode=='') {
$title.=$l_forbidden$errorMSG=$l_forbidden$correctErr '';
}
else {
$upd DB_query(69,0);
if (
$upd>0) {
$title.=$l_passwdUpdate$errorMSG=$l_passwdUpdate$correctErr '';
}
else {
$title.=$l_itseemserror$errorMSG=$l_itseemserror$correctErr '';
}
}
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

//---------------------->
function emailCheckBox() {
global 
$l_emailNotify$l_unsubscribe;
global 
$emailadmin$emailusers$user_id$forum$topic$action$logged;

$isInDb DB_query(80,0);

$true0 = ($emailusers==1);
$true1 = ($logged==1);
$true2 = ($action=='vtopic' or $action == 'vthread' or $action=='ptopic' or $action=='pthread');
$true3a = ($user_id==and $emailadmin!=and !$isInDb);
$true3b = ($user_id!=and !$isInDb);
$true3 = ($true3a or $true3b);

if (
$true0 and $true1 and $true2 and $true3) {
$checkEmail "<input type=checkbox name=CheckSendMail> <a href="index.php?action=manual#emailNotifications">$l_emailNotify</a>";
}
elseif(
$isInDb$checkEmail="<!--U--><a href="index.php?action=unsubscribe&topic={$topic}&usrid={$user_id}">$l_unsubscribe</a>";
else {
$checkEmail '';
}
return 
$checkEmail;
}

//----------------------->
function changeLang($step) {
global 
$tableParam;
global 
$selLang$lang$deleteLang$cookiename$cookiepath$cookiedomain$cookiesecure$cookielang_exp;
global 
$l_menu$l_chooseLang$l_deleteLang$l_whatIsIt;

if (
$step==0) {
$langList='';
$ss=0;
$handle=@opendir('./lang');
if (
$handle) {
while ((
$file readdir($handle))!=false) {
if (
$file != "." && $file != ".." && substr($file, -4)=='.php') {

chdir ('./lang');
$fd fopen('./'.$file'r'); 
$getLang fread ($fdfilesize ('./'.$file));
fclose($fd);
chdir ('..');

$getLang explode('$Lang:'$getLang); $getLang explode(':$'$getLang[1]); $getLang $getLang[0];

$langList.='<input type=radio name=selLang value="'.substr($file03).'"';
if (
substr($file03)==$lang$langList.=' checked';
$langList.='>'.$getLang.'</option><br>'."n";
$ss++;
}
}
closedir($handle);

if (
$ss>1) { $tpl makeUp('main_language'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return; }
else 
header("Location: index.php");
}
else 
header("Location: index.php");
}

else {
if (
$deleteLang=='on'setcookie($cookiename.'Language');
else {
setcookie ($cookiename.'Language');
setcookie ($cookiename.'Language'$selLangtime()+$cookielang_exp$cookiepath$cookiedomain$cookiesecure);
}
header("Location: index.php?");

}
}

//----------------------->
function unsubscribeFromTopic($topic$usrid) {
global 
$user_id$topicU$title$tableParam$l_accessDenied$l_completed$l_itseemserror$l_returntoforums;

if (
$topic and $usrid and $usrid==$user_id and DB_query(80,0)) {
$topicU=$topic;

$op=DB_query(96,0);
if (
$op>0) {
$errorMSG=$l_completed$title.=$l_completed;
}
else {
$errorMSG=$l_itseemserror$title.=$l_itseemserror;
}

}
else {
$title.=$l_accessDenied$errorMSG=$l_accessDenied;
}

$correctErr '';
$tpl makeUp('main_warning'); eval("$tpl = "$tpl";"); echo load_header().stripslashes($tpl); return;
}

?>
Онлайн: 2
Реклама