<?php // <- Do not Remove this line
// ----------------------------------------------
// ----------------------------------------------
// ----------Sentertainment.net Presents---------
// -----------Unofficial IPB WAP Script----------
// ----------------------------------------------
// ----------------------------------------------
// Release v1.6
//
// ============SIMPLIFIED TERMS OF USE===========
// ----Under Basic GNU General Public License----
// Extra:
// This script is in no affiliation with Invision
// or any of it's members and this script may not
// be sold in any form.
// As request by the author of this code, we ask
// (not rquire) that in the event of modding this
// code, that you send your modded copy to the
// author for open-source development.
// If any of these terms are not to your needs,
// then permission from the author is before any
// terms of use may be broken.
// THIS HEADER MAY NOT BE CHANGED OR REMOVED
// WITHOUT PERMISSION FROM THE ORIGINAL CREATORS
//
//
// INSTRUCTIONS:
// Just Fill out all required info to meet your Forums
// and place this file anywhere you please on your
// server. Unrestricted fil access to this script
// may be required for Attachments to work.
//
//
// ===================CREDITS====================
// --------Giving Credit Where it is Due!--------
//
// TeraByte:
// Brought unnoticed Nav Error to my attention!
//
// All the rest goes to me! ;)
// ----------------------------------------------
// -------------Database Login Info--------------
// ----------------------------------------------
$dbuser = ""; // Forum SQL Database Access Username
$dbpass = ""; // Forum SQL Database Access Password
$dbname = ""; // Forum SQL Database Name
$dbserver = ""; // Database Server (Usualy "localhost")
// ----------------------------------------------
// ----------------Forum Settings----------------
// ----------------------------------------------
error_reporting(0);
$furl = "forum.com/"; // Forum URL (Without "http://www.")
$uploadsdir = "uploads/"; // Forum Uploads Directory
$boardtype = 1; // *Feature Not Yet Complete* Board type; 1 = IPB, 2 = phpBB
$board_title = ""; // Script Display Title
$boardname = ""; // Board Display Name
$forumpostsperpage = 5; // Number of topics to show per page (Forum View)
$topicpostsperpage = 3; // Number of posts to show per page (Topic View)
$pagecreation = 0; // Show Page Creation Time; 1=True, 0=False
$msgcharlimit = 75; // Character Limit for forum views
$topiccharlimit = 300; // Character Limit for topic views
$tableprefix = "ibf_"; // Table name prefix ex: ibf_posts
$enattach = 0; // Enable Attachments; 1 = Yes, 0 = No
$resimgview = 1; // Disable Images if current Member seetings have them disabled; 1 = Yes, 0 = No
$enemoticons = 0; // Enable Emoticons & Images; 1 = Yes, 0 = No
$autowap = 1; // Detect WAP access automatically; Display WAP Access Only
$showses = 1; // Show Session count (Current Visistors); 1 = Yes, 0 = No
$sesmin = 30; // Counts visitors within * min; Only works when $showses is enabled
$loginsesmin = 10; // Login sessions last * min when idle
$manageses = 0; // Allow Script to Manage (Delete) Old Sessions
$sesdeltime = 60; // Deletes Sessions within * min; Only works when $manageses is enabled
$viewdetails = 1; // Show Last Post Details in Forum Views; 1 = Yes, 0 = No
$allowlogin = 1; // Allow Memebers to Login (Show Login Info & Pages); 1 = Yes, 0 = No
$permview = 1; // Display Forums According to User Permissions; 1 = Yes, 0 = No
$navmode = 0; // Forum Navigation; 1 = Radio Buttons, 0 = Hyperlinks
$forumviewnavmode = 0; // Forum View Navigation (Radio Buttons May result in Error if over 15 forums)
$followperms = 1; // Respect IPB Read/Write/Reply/Edit Permissions; 1 = Yes, 0 = No
$showpinned = 1; // Show pinned topics in forum view; 1 = Yes, 0 = No
// Below this line is forum specific data already set for
// Invision Power Boards.
// ------------------Table Info------------------
If ($boardtype == 1) {
// Deafult IPB Configuration
$poststable = "posts";
$categoriestable = "categories";
$forumstable = "forums";
$topicstable = "topics";
$sessionstable = "sessions";
$memberstable = "members";
$tid_column = "tid";
$pid_column = "pid";
$topic_id_column = "topic_id";
$member_id_column = "member_id";
$member_name_column = "member_name";
$forum_id_column = "forum_id";
$ip_address_column = "ip_address";
$running_time_column = "running_time";
$post_id_column = "post_id";
$category_column = "category";
$name_column = "name";
$position_column = "position";
$last_post_column = "last_post";
$title_column = "title";
$post_column = "post";
$post_date_column = "post_date";
$posts_column = "posts";
$views_column = "views";
$author_name_column = "author_name";
$pinned_column = "pinned";
} else {
// No Support for phpBB yet! :(
}
// ----------------------------------------------
// ----------------------------------------------
// ---------Do Not Change Below this line--------
// ----------------------------------------------
// ----------------------------------------------
If ($autowap == 1) {
if(strpos(strtoupper($HTTP_ACCEPT),'VND.WAP.WML') > 0) {
$brow = 'WML';
} else {
$browser=substr(trim($HTTP_USER_AGENT),0,4);
if($browser=='Noki' || // Nokia phones and emulators
$browser=='Eric' || // Ericsson WAP phones and emulators
$browser=='WapI' || // Ericsson WapIDE 2.0
$browser=='MC21' || // Ericsson MC218
$browser=='AUR ' || // Ericsson R320
$browser=='R380' || // Ericsson R380
$browser=='UP.B' || // UP.Browser
$browser=='WinW' || // WinWAP browser
$browser=='UPG1' || // UP.SDK 4.0
$browser=='upsi' || // another kind of UP.Browser ??
$browser=='QWAP' || // unknown QWAPPER browser
$browser=='Jigs' || // unknown JigSaw browser
$browser=='Java' || // unknown Java based browser
$browser=='Alca' || // unknown Alcatel-BE3 browser (UP based?)
$browser=='MITS' || // unknown Mitsubishi browser
$browser=='MOT-' || // unknown browser (UP based?)
$browser=='My S' || // unknown Ericsson devkit browser ?
$browser=='WAPJ' || // Virtual WAPJAG www.wapjag.de
$browser=='fetc' || // fetchpage.cgi Perl script from www.wapcab.de
$browser=='ALAV' || // yet another unknown UP based browser ?
$browser=='Wapa') // another unknown browser (Web based 'Wapalyzer'?)
{
$brow = 'WML';
} else {
$brow = 'HTML';
}
}
if($brow == 'HTML') {
header("Content-type: text/html");
echo("<p><b>WAP Access Only!</b><br/><br/>Click <a href=\"http://www." . $furl . "\">here</a> to visit the HTML enabled forums.");
exit;
}
}
// Send Header
If (!substr($pid, 0 , 1)=="f") {
header("Content-type: text/vnd.wap.wml");
}
// Connect to Database
$dbcn = @mysql_connect($dbserver, $dbuser, $dbpass);
if (!$dbcn) {
exit();
}
if (! @mysql_select_db($dbname) ) {
exit();
}
// Split Variables (Some devices can't handle multiple variables well)
If (!$tid_page==Null) {
$array_tid_page = split("_", $tid_page);
$tid = $array_tid_page[0];
$page = $array_tid_page[1];
}
If (!$fid_page==Null) {
$array_fid_page = split("_", $fid_page);
$fid = $array_fid_page[0];
$page = $array_fid_page[1];
}
If (!$page_action==Null) {
$array_page_action = split("_", $page_action);
$page = $array_page_action[0];
$action = $array_page_action[1];
}
If (!$tid_pid_page==Null) {
$array_tid_pid_page = split("_", $tid_pid_page);
$ptid = $array_tid_pid_page[0];
$ppid = $array_tid_pid_page[1];
$ppage = $array_tid_pid_page[2];
}
// Translit
function ruslat ($string)
{
$string = ereg_replace("ж","zh",$string);
$string = ereg_replace("ё","yo",$string);
$string = ereg_replace("й","i",$string);
$string = ereg_replace("ю","yu",$string);
$string = ereg_replace("ь","'",$string);
$string = ereg_replace("ч","4",$string);
$string = ereg_replace("щ","sh",$string);
$string = ereg_replace("ц","c",$string);
$string = ereg_replace("у","u",$string);
$string = ereg_replace("к","k",$string);
$string = ereg_replace("е","e",$string);
$string = ereg_replace("н","n",$string);
$string = ereg_replace("г","g",$string);
$string = ereg_replace("ш","sh",$string);
$string = ereg_replace("з","z",$string);
$string = ereg_replace("х","h",$string);
$string = ereg_replace("ъ","''",$string);
$string = ereg_replace("ф","f",$string);
$string = ereg_replace("ы","y",$string);
$string = ereg_replace("в","v",$string);
$string = ereg_replace("а","a",$string);
$string = ereg_replace("п","p",$string);
$string = ereg_replace("р","r",$string);
$string = ereg_replace("о","o",$string);
$string = ereg_replace("л","l",$string);
$string = ereg_replace("д","d",$string);
$string = ereg_replace("э","yе",$string);
$string = ereg_replace("я","jа",$string);
$string = ereg_replace("с","s",$string);
$string = ereg_replace("м","m",$string);
$string = ereg_replace("и","i",$string);
$string = ereg_replace("т","t",$string);
$string = ereg_replace("б","b",$string);
$string = ereg_replace("Ё","yo",$string);
$string = ereg_replace("Й","I",$string);
$string = ereg_replace("Ю","YU",$string);
$string = ereg_replace("Ч","4",$string);
$string = ereg_replace("Ь","'",$string);
$string = ereg_replace("Щ","SH'",$string);
$string = ereg_replace("Ц","C",$string);
$string = ereg_replace("У","U",$string);
$string = ereg_replace("К","K",$string);
$string = ereg_replace("Е","E",$string);
$string = ereg_replace("Н","N",$string);
$string = ereg_replace("Г","G",$string);
$string = ereg_replace("Ш","SH",$string);
$string = ereg_replace("З","Z",$string);
$string = ereg_replace("Х","H",$string);
$string = ereg_replace("Ъ","''",$string);
$string = ereg_replace("Ф","F",$string);
$string = ereg_replace("Ы","Y",$string);
$string = ereg_replace("В","V",$string);
$string = ereg_replace("А","A",$string);
$string = ereg_replace("П","P",$string);
$string = ereg_replace("Р","R",$string);
$string = ereg_replace("О","O",$string);
$string = ereg_replace("Л","L",$string);
$string = ereg_replace("Д","D",$string);
$string = ereg_replace("Ж","Zh",$string);
$string = ereg_replace("Э","Ye",$string);
$string = ereg_replace("Я","Ja",$string);
$string = ereg_replace("С","S",$string);
$string = ereg_replace("М","M",$string);
$string = ereg_replace("И","I",$string);
$string = ereg_replace("Т","T",$string);
$string = ereg_replace("Б","B",$string);
return $string;
}
// Convert HTML to WML Code
function html2wml($boardcode){
global $enemoticons;
$boardcode = str_replace("<i>", "", $boardcode);
$boardcode = str_replace("</i>", "", $boardcode);
$boardcode = str_replace("<!--QuoteEEnd-->", "</i>", $boardcode);
$boardcode = str_replace("<!--QuoteEBegin-->", "<i>", $boardcode);
If ($enemoticons == 1) {
$keepstr = "<br><img><i><br>";
} else {
$keepstr = "<br><i><br>";
}
$boardcode = str_replace("</br>", "<br/>", str_replace("<br>", "<br/>", str_replace(":/mlink:", "\">MOBILE LINK</a>", str_replace(":mlink:", "<a href=\"", strip_tags($boardcode, $keepstr)))));
$boardcode = str_replace("<br/><br/>", "<br/>", $boardcode);
$boardcode = str_replace("<br/><br/>", "<br/>", $boardcode);
$boardcode = html_entity_decode2($boardcode);
$boardcode = wmlspecialchars($boardcode);
$boardcode = str_replace(wmlspecialchars("<br/>"), "<br/>", $boardcode);
$boardcode = str_replace(wmlspecialchars("<i>"), "<i>", $boardcode);
$boardcode = str_replace(wmlspecialchars("</i>"), "</i>", $boardcode);
If ($enemoticons == 1) {
$boardcode = str_replace(wmlspecialchars("<img src='http://"), "<img src=\"http://", $boardcode);
$boardcode = str_replace(wmlspecialchars("' border='0' style='vertical-align:middle' alt='"), "\" alt=\"", $boardcode);
$boardcode = str_replace(wmlspecialchars("' border='0' alt='"), "\" alt=\"", $boardcode);
$boardcode = str_replace(wmlspecialchars("' />"), "\" />", $boardcode);
}
return $boardcode;
}
// Convert Special Characters to WML
function wmlspecialchars($wml) {
$wml = str_replace("$", "$", $wml);
$wml = str_replace("'", "'", $wml);
$wml = str_replace("!", "!", $wml);
$wml = str_replace("$", "$$", $wml);
$wml = str_replace("&", "&", $wml);
$wml = str_replace("<", "<", $wml);
$wml = str_replace(">", ">", $wml);
$wml = str_replace("'", "'", $wml);
$wml = str_replace("\"", """, $wml);
$wml = str_replace(" ", " ", $wml);
$wml = str_replace(" ", " ", $wml);
return $wml;
}
// Add-on to html_enity_decode for some characters
function html_entity_decode2($html) {
$html = str_replace("$", "$", $html);
$html = str_replace("'", "'", $html);
$html = str_replace("!", "!", $html);
$html = str_replace("[", "[", $html);
$html = str_replace("]", "]", $html);
$html = html_entity_decode($html, ENT_QUOTES);
return $html;
}
// Create Page Navigation
function topicpagenav($result, $page, $tid){
global $PHP_SELF;
global $topicpostsperpage;
$returnstr = "";
$num = (int)((mysql_num_rows($result) - 1)/ $topicpostsperpage);
If (($page - 3)>0) {
$returnstr = $returnstr . "<a href=\"" . $PHP_SELF . "?tid_page=" . $tid . "0#viewtopic\">1</a>...";
}
If (($page - 3) > -1) {
$returnstr = $returnstr . "<a href=\"" . $PHP_SELF . "?tid_page=" . $tid . "_" . ($page - 3) . "#viewtopic\">" . (intval($page) - 2) . "</a> ";
}
If (($page - 2) > -1) {
$returnstr = $returnstr . "<a href=\"" . $PHP_SELF . "?tid_page=" . $tid . "_" . ($page - 2) . "#viewtopic\">" . (intval($page) - 1) . "</a> ";
}
If (($page - 1) > -1) {
$returnstr = $returnstr . "<a href=\"" . $PHP_SELF . "?tid_page=" . $tid . "_" . ($page - 1) . "#viewtopic\">" . (intval($page)) . "</a> ";
}
$returnstr = $returnstr . ($page + 1)." ";
If (($page) < $num) {
$returnstr = $returnstr . "<a href=\"" . $PHP_SELF . "?tid_page=" . $tid . "_" . ($page + 1) . "#viewtopic\">" . (intval($page) + 2) . "</a> ";
}
If (($page + 1) < $num) {
$returnstr = $returnstr . "<a href=\"" . $PHP_SELF . "?tid_page=" . $tid . "_" . ($page + 2) . "#viewtopic\">" . (intval($page) + 3) . "</a> ";
}
If (($page + 2) < $num) {
$returnstr = $returnstr . "<a href=\"" . $PHP_SELF . "?tid_page=" . $tid . "_" . ($page + 3) . "#viewtopic\">" . (intval($page) + 4) . "</a> ";
}
If (($page + 3) < $num) {
$returnstr = $returnstr . "...<a href=\"" . $PHP_SELF . "?tid_page=" . $tid . $num . "#viewtopic\">" . ($num + 1) . "</a>";
}
return $returnstr;
}
// Limit text on Forum Views & Convert Lines
function docharlimit($msgtext){
global $msgcharlimit;
$msgtext = str_replace("<br/>", " ", $msgtext);
$msgtext = str_replace(" ", " ", $msgtext);
$msgtext = strip_tags($msgtext);
$varx = 0;
$newmsgtext = "";
if ($msgcharlimit < strlen($msgtext)) {
$msgwordarray = split(" ", $msgtext);
$continuemsgtrim = true;
while ($varx < count($msgwordarray) && $continuemsgtrim == true) {
If ($msgcharlimit > strlen($newmsgtext . " " . $msgwordarray[$varx + 1])) {
$newmsgtext = $newmsgtext . $msgwordarray[$varx + 1] . " ";
} else {
$continuemsgtrim = false;
}
$varx = $varx + 1;
}
$newmsgtext = substr($newmsgtext, 0, strlen($newmsgtext) - 1) . "...";
} else {
$newmsgtext = $msgtext;
}
return $newmsgtext;
}
function dosimplecharlimit($msgtext, $tid, $pid, $page){
global $topiccharlimit;
global $PHP_SELF;
$varx = 0;
$newmsgtext = "";
if ($topiccharlimit < strlen($msgtext)) {
$msgtext = strip_tags($msgtext, "<br/>");
$msgwordarray = split(" ", $msgtext);
$continuemsgtrim = true;
while ($varx < count($msgwordarray) && $continuemsgtrim == true) {
If ($topiccharlimit > strlen($newmsgtext . " " . $msgwordarray[$varx + 1])) {
$newmsgtext = $newmsgtext . $msgwordarray[$varx + 1] . " ";
} else {
$continuemsgtrim = false;
}
$varx = $varx + 1;
}
$newmsgtext = substr($newmsgtext, 0, strlen($newmsgtext) - 1) . "...<br/><a href=\"" . $PHP_SELF . "?tid_pid_page=" . $tid . "_" . $pid . "_" . $page . "#viewtopic\">Посмотреть все</a>";
} else {
$newmsgtext = $msgtext;
}
return $newmsgtext;
}
function getperm($fid, $perm) {
global $memgroup;
global $tableprefix;
global $forumstable;
global $followperms;
$group = mysql_fetch_array(mysql_query("SELECT g_perm_id FROM " . $tableprefix . "groups WHERE g_id='" . $memgroup . "'"));
$permid = $group['g_perm_id'];
$perminfo = mysql_fetch_array(mysql_query("SELECT " . $perm . "_perms FROM " . $tableprefix . $forumstable . " WHERE id='" . $fid . "'"));
$forumperms = $perminfo[$perm . "_perms"];
If ($forumperms == "*") {
$retval = true;
} elseif ($followperms == 0) {
$retval = true;
} else {
$forumperms = split(",", $forumperms);
$x = 0;
$retval = false;
while ($x < count($forumperms)) {
If ($permid == $forumperms[$x]) {
$retval = true;
}
$x = $x + 1;
}
}
return $retval;
}
// Manage IPB Sessions
If ($manageses==1) {
mysql_query("DELETE " . $tableprefix . $sessionstable . " WHERE running_time < '" . (time() - $sesdeltime) . "'");
}
// Get User Login & Set Persmissions
If (!substr($pid, 0 , 1)=="f") {
$allowpost = 1;
$memid = 0;
$guestinfo = mysql_fetch_array(mysql_query("SELECT mgroup, name FROM " . $tableprefix . $memberstable . " WHERE id=0 LIMIT 1"));
$memgroup = $guestinfo['mgroup'];
$guestname = $guestinfo['name'];
If (mysql_num_rows(mysql_query("SELECT * FROM " . $tableprefix . $sessionstable . " WHERE id='" . $REMOTE_ADDR . "'")) > 0) {
mysql_query("UPDATE " . $tableprefix . $sessionstable . " SET id='" . $REMOTE_ADDR . "', $ip_address_column='" . $REMOTE_ADDR . "', running_time='" . time() . "' WHERE id='" . $REMOTE_ADDR . "' LIMIT 1");
} else {
mysql_query("INSERT INTO " . $tableprefix . $sessionstable . " SET id='" . $REMOTE_ADDR . "', $ip_address_column='" . $REMOTE_ADDR . "', running_time='" . time() . "'");
}
If ($allowlogin==1) {
$sesinfo = mysql_fetch_array(mysql_query("SELECT * FROM " . $tableprefix . $sessionstable . " WHERE id = '" . $REMOTE_ADDR . "' AND $running_time_column > '" . (time() - (60 * $loginsesmin)) . "'"));
If (!$sesinfo[$member_name_column]=="") {
If ($REMOTE_ADDR==$sesinfo[$ip_address_column]) {
$username = $sesinfo[$member_name_column];
If ($sesinfo['restrict_post'] > 0) {
$allowpost = 0;
}
If ($sesinfo['view_img'] == 0 && $resimgview == 1) {
$enemoticons = 0;
}
$loggedin = 1;
$memgroup = $sesinfo['member_group'];
} else {
$username = $guestname;
$loggedin = 0;
}
} else {
$username= $guestname;
$loggedin = 0;
}
If ($loggedin==0){
$loginstr = "Привет<br/><b>$username</b> (<a href=\"$PHP_SELF?action=login#view\">Login</a>)<br/><br/>";
} else {
$loginstr = "Привет<br/><b>$username</b> (<a href=\"$PHP_SELF?action=logout#view\">Logout</a>)<br/><br/>";
}
} else {
$loginstr = "";
}
}
// Finish coded header & Main Page
If (!substr($pid, 0 , 1)=="f") {
If ($navmode == 1) {
$mainnavstr = <<<EOF
Навигация:
<select name="action" value="0">
<option><onevent type="onpick"><go href="$PHP_SELF#view" method="post"><postfield name="action" value="last5"/><postfield name="p" value="0"/></go></onevent>Активные темы ($forumpostsperpage)</option>
<option><onevent type="onpick"><go href="$PHP_SELF#view" method="post"><postfield name="action" value="categories"/></go></onevent>Категории</option>
<option><onevent type="onpick"><go href="$PHP_SELF#view" method="post"><postfield name="action" value="forums"/></go></onevent>Форумы</option>
</select><br/><br/>
EOF;
} else {
$mainnavstr = <<<EOF
Навигация:<br/>
<a href="$PHP_SELF?action=last5#view">Активные темы ($forumpostsperpage)</a><br/>
<a href="$PHP_SELF?action=categories#view">Категории</a><br/>
<a href="$PHP_SELF?action=forums#view">Форумы</a><br/>
<br/><br/>
EOF;
}
$disstr = <<<EOF
<?xml version="1.0" encoding="windows-1251"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="index" title="{$boardtitle}">
<p align="center"><b>MyPinsk.com | Форум</b><br/><br/>
$loginstr
$mainnavstr
EOF;
// Show Session Counts
If ($showses==1) {
$users = mysql_num_rows(mysql_query("SELECT * FROM " . $tableprefix . $sessionstable . " WHERE $running_time_column >" . (time() - (60 * $sesmin)) . ""));
$members = mysql_num_rows(mysql_query("SELECT * FROM " . $tableprefix . $sessionstable . " WHERE $ip_address_column <> id AND $member_id_column > 0 AND $running_time_column >" . (time() - (60 * $sesmin)) . ""));
$guests = mysql_num_rows(mysql_query("SELECT * FROM " . $tableprefix . $sessionstable . " WHERE $member_id_column = 0 AND $ip_address_column <> id AND $running_time_column >" . (time() - (60 * $sesmin)) . ""));
$wap = mysql_num_rows(mysql_query("SELECT * FROM " . $tableprefix . $sessionstable . " WHERE id = $ip_address_column AND $running_time_column >" . (time() - (60 * $sesmin)) . ""));
$wapmembers = mysql_num_rows(mysql_query("SELECT * FROM " . $tableprefix . $sessionstable . " WHERE id = $ip_address_column AND $member_id_column > 0 AND $running_time_column > " . (time() - (60 * $sesmin)) . ""));
$wapguests = $wap - $wapmembers;
$disstr1 = <<<EOF
<b>$users</b> пользователей он-лайн:<br/>
$members Пользователей, $guests гостей, $wap WAP ($wapmembers, $wapguests)
<br/>
EOF;
} else {
$disstr1 = "";
}
$disstr2 = <<<EOF
<br/><small>
Coding by<br/>Sentertainment.net
</small>
</p>
</card>
<card id="view" title="{$boardtitle}">
EOF;
echo(ruslat($disstr . $disstr1 . $disstr2));
}
if ($action=="") {
} else {
If ($action=="forums") {
$disstr = "";
$t1 = microtime();
echo(ruslat("<p align=\"center\"><b>Форумы</b><br/><br/>"));
If ($forumviewnavmode == 1) {
echo("<select name=\"id\" value=\"0\">");
}
$result = mysql_query("SELECT `$name_column`, `id` FROM `" . $tableprefix . $categoriestable . "` WHERE `id`>0 ORDER BY `$position_column`");
while ($row = mysql_fetch_array($result)) {
If ($forumviewnavmode == 0) {
echo(ruslat("<br/><b>" . $row[$name_column] . "</b><br/>"));
}
$result2 = mysql_query("SELECT `$name_column`, `id` FROM `" . $tableprefix . $forumstable . "` WHERE `$category_column`=" . $row['id'] . " ORDER BY `position`");
while ($row2 = mysql_fetch_array($result2)) {
If (getperm($row2['id'], "read")) {
If ($forumviewnavmode == 0) {
echo(ruslat("<a href=\"" . $PHP_SELF . "?fid=" . $row2['id'] . "#viewforum\">" . wmlspecialchars(html_entity_decode2($row2[$name_column])) . "</a><br/>"));
} else {
echo(ruslat("<option><onevent type=\"onpick\"><go href=\"" . $PHP_SELF . "#viewforum\" method=\"post\"><postfield name=\"fid\" value=\"" . $row2['id'] . "\"/></go></onevent>" . wmlspecialchars(html_entity_decode2($row2[$name_column])) . "</option>"));
}
}
}
}
If ($forumviewnavmode == 1) {
echo("</select>");
}
echo(ruslat("<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>"));
$t2 = microtime();
if ($pagecreation==1) {
echo(ruslat("<p align=\"center\"><br/>Создано за<br/>" . substr(($t2 - $t1), 0, 8) . " сек.</p>"));
}
}
If ($action=="last5") {
$t1 = microtime();
echo(ruslat("<p align=\"center\"><b>Активные темы (" . $forumpostsperpage . ")</b><br/></p>"));
$result = mysql_query("SELECT * FROM `" . $tableprefix . $topicstable . "` ORDER BY `$last_post_column` DESC LIMIT " . ($page* $forumpostsperpage) . "," . $forumpostsperpage);
while ($row = mysql_fetch_array($result)) {
$result2 = mysql_query("SELECT * FROM `" . $tableprefix . $poststable . "` WHERE `$topic_id_column`=" . $row[$tid_column] . " ORDER BY `$post_date_column` DESC LIMIT 0,1");
$row2 = mysql_fetch_array($result2);
$topic = wmlspecialchars(html_entity_decode2($row[$title_column]));
If (getperm($row2['forum_id'], "read")) {
$boardcode = docharlimit(html2wml($row2[$post_column]));
} else {
$boardcode = "У вас нет прав доступа к этому разделу!";
}
if ($viewdetails == 1) {
echo(ruslat("<p><b>Тема: </b><a href=\"" . $PHP_SELF . "?tid_page=" . $row2[$topic_id_column] . "_0#viewtopic\">" . $topic . "</a> (" . $row[$posts_column] . ", " . $row[$views_column] . ")<br/><b>Последнее сообщение:</b><br/><i>Автор:</i> " . $row2[$author_name_column] . "<br/><i>Сообщ.:</i> " . $boardcode . "<br/><br/></p>"));
} else {
echo(ruslat("<p><a href=\"" . $PHP_SELF . "?tid_page=" . $row2[$topic_id_column] . "_0#viewtopic\">" . $topic . "</a> (" . $row[$posts_column] . ", " . $row[$views_column] . ")<br/></p>"));
}
}
echo("<p align=\"center\">");
$p2 = $page + 1;
$p3 = $page - 1;
if (!$page==0) {
echo(ruslat("<a href=\"" . $PHP_SELF . "?page_action=" . $p3 . "_last5#view\">Пред.</a> "));
}
$result = mysql_query("SELECT * FROM `" . $tableprefix . $topicstable . "` ORDER BY '$last_post_column' DESC LIMIT " . ($p2 * $forumpostsperpage) . "," . $forumpostsperpage);
if ($result&&$row = mysql_fetch_array($result)) {
echo(ruslat("<a href=\"" . $PHP_SELF . "?page_action=" . $p2 . "_last5#view\">След.</a>"));
}
echo(ruslat("<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>"));
$t2 = microtime();
if ($pagecreation==1) {
echo(ruslat("<p align=\"center\"><br/>Создано за<br/>" . substr(($t2 - $t1), 0, 8) . " сек.</p>"));
}
}
If ($action=="categories") {
$t1 = microtime();
echo(ruslat("<p align=\"center\"><b>Категории</b><br/><br/>"));
If ($navmode == 1) {
echo("<select name=\"id\" value=\"0\">");
}
$result = mysql_query("SELECT `$name_column`, `id` FROM `" . $tableprefix . $categoriestable . "` WHERE `id`>0 ORDER BY `$position_column`");
while ($row = mysql_fetch_array($result)) {
If ($navmode == 1) {
echo(ruslat("<option><onevent type=\"onpick\"><go href=\"" . $PHP_SELF . "#viewcategory\" method=\"post\"><postfield name=\"id\" value=\"" . $row['id'] . "\"/></go></onevent>" . wmlspecialchars(html_entity_decode2($row[$name_column])) . "</option>"));
} else {
echo(ruslat("<a href=\"" . $PHP_SELF . "?id=" . $row['id'] . "#viewcategory\">" . wmlspecialchars(html_entity_decode2($row[$name_column])) . "</a><br/>"));
}
}
If ($navmode == 1) {
echo("</select>");
}
echo(ruslat("<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>"));
$t2 = microtime();
if ($pagecreation==1) {
echo(ruslat("<p align=\"center\"><br/>Создано за<br/>" . substr(($t2 - $t1), 0, 8) . " сек.</p>"));
}
}
If ($action=="login") {
$disstr = <<<EOF
<p align="center"><b>Вход</b><br/><br/>
<do type="accept" label="Login">
<go href="$PHP_SELF?action=login2#view" method="post">
<postfield name="LoginUsername" value="\$LoginUsername"/>
<postfield name="LoginPassword" value="\$LoginPassword"/>
</go>
</do>
Имя:<br/>
<input type="text" name="LoginUsername"/><br/><br/>
Пароль:<br/>
<input type="password" name="LoginPassword"/>
</p>
EOF;
echo(ruslat($disstr));
}
If ($action=="login2") {
echo(ruslat("<p align=\"center\"><b>Вход</b><br/><br/>"));
$result = mysql_query("SELECT * FROM " . $tableprefix . $memberstable . " where $name_column = '" . $LoginUsername . "'");
If (!$result) {
echo(ruslat("Ошибка<br/><br/><a href=\"$PHP_SELF?action=login#view\">Назад</a>"));
}
If (mysql_num_rows(mysql_query("SELECT * FROM " . $tableprefix . $sessionstable . " WHERE member_name = '" . $LoginUsername . "' AND $member_id_column > 0")) > 0) {
$logintype = 1;
} else {
$logintype = 0;
}
If ($row = mysql_fetch_array($result)) {
If ($row['password'] == md5($LoginPassword)) {
mysql_query("REPLACE INTO " . $tableprefix . $sessionstable . " SET id='" . $REMOTE_ADDR . "', $ip_address_column='" . $REMOTE_ADDR . "', $running_time_column='" . time() . "', $member_name_column='" . $row['name'] . "', $member_id_column='" . $row['id'] . "', browser = '" . $HTTP_USER_AGENT . "', member_group = '" . $row['mgroup'] . "', login_type = $logintype");
echo(ruslat("Вы зашли как $LoginUsername,<br/>Сессия завершится через $loginsesmin минут.<br/><br/><a href=\"" . $PHP_SELF . "\">Home</a>"));
} else {
echo(ruslat("Неверное имя или пароль<br/><br/><a href=\"$PHP_SELF?action=login#view\">Назад</a>"));
}
} else {
echo(ruslat("Неверное имя или пароль<br/><br/><a href=\"$PHP_SELF?action=login#view\">Назад</a>"));
}
echo("</p>");
}
If ($action=="logout") {
echo("<p align=\"center\"><b>Logout</b><br/><br/>");
mysql_query("REPLACE INTO " . $tableprefix . $sessionstable . " SET id='" . $REMOTE_ADDR . "', $ip_address_column='" . $REMOTE_ADDR . "', $running_time_column='" . time() . "'");
echo(ruslat("Вы вышли<br/><br/><a href=\"" . $PHP_SELF . "\">Главная</a>"));
echo("</p>");
}
}
If (!substr($pid, 0 , 1)=="f") {
$disstr = <<<EOF
</card>
<card id="viewcategory" title="{$boardtitle}">
<p align="center">
EOF;
echo(ruslat($disstr));
}
if (!$id==Null) {
$t1_1 = microtime();
$result = mysql_query("SELECT `$name_column` FROM `" . $tableprefix . $categoriestable . "` WHERE `id`=" . $id);
$row = mysql_fetch_array($result);
echo(ruslat("<b>" . wmlspecialchars(html_entity_decode2($row[$name_column])) . "</b><br/><br/>"));
If ($forumviewnavmode == 1) {
echo("<select name=\"fid\" value=\"0\">");
}
$result = mysql_query("SELECT `$name_column`, `id` FROM `" . $tableprefix . $forumstable . "` WHERE `$category_column`=" . $id . " ORDER BY `$position_column`");
while ($row = mysql_fetch_array($result)) {
If (getperm($row['id'], "read")) {
If ($forumviewnavmode == 1) {
echo(ruslat("<option><onevent type=\"onpick\"><go href=\"" . $PHP_SELF . "#viewforum\" method=\"post\"><postfield name=\"fid\" value=\"" . $row['id'] . "\"/></go></onevent>" . wmlspecialchars(html_entity_decode2($row[$name_column])) . "</option>"));
} else {
echo(ruslat("<a href=\"" . $PHP_SELF . "?fid=" . $row['id'] . "#viewforum\">" . wmlspecialchars(html_entity_decode2($row[$name_column])) . "</a><br/>"));
}
}
}
If ($forumviewnavmode == 1) {
echo("</select>");
}
echo(ruslat("<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>"));
$t2_1 = microtime();
if ($pagecreation==1) {
echo(ruslat("<p align=\"center\"><br/>Создано за<br/>" . substr(($t2_1 - $t1_1), 0, 8) . " сек."));
}
}
If (!substr($pid, 0 , 1)=="f") {
if (isset($id))
{
$disstr = <<<EOF
</card>
<card id="viewforum" title="{$boardtitle}">
EOF;
echo(ruslat($disstr));
}
else
{
$disstr = <<<EOF
</p>
</card>
<card id="viewforum" title="{$boardtitle}">
EOF;
echo(ruslat($disstr));
}
}
if (!$fid==Null) {
$t1_2 = microtime();
$result = mysql_query("SELECT `$name_column` FROM `" . $tableprefix . $forumstable . "` WHERE `id`=" . $fid);
$row = mysql_fetch_array($result);
echo(ruslat("<p align=\"center\"><b>" . wmlspecialchars(html_entity_decode2($row['name'])) . "</b><br/><br/>"));
If (getperm($fid, "read")) {
$result = mysql_query("SELECT * FROM `" . $tableprefix . $topicstable . "` WHERE `$forum_id_column`=" . $fid . " AND `$pinned_column`=1 ORDER BY `$last_post_column` DESC");
If ($showpinned==1) {
while ($row = mysql_fetch_array($result)) {
$topic = wmlspecialchars(html_entity_decode2($row[$title_column]));
echo(ruslat("<i>Pinned: </i><a href=\"" . $PHP_SELF . "?tid_page=" . $row['tid'] . "_0#viewtopic\">" . $topic . "</a><br/>"));
}
}
echo("<br/></p>");
$result = mysql_query("SELECT * FROM `" . $tableprefix . $topicstable . "` WHERE `$forum_id_column`=" . $fid . " ORDER BY `$last_post_column` DESC LIMIT " . ($page* $forumpostsperpage) . "," . $forumpostsperpage);
If (getperm($fid, "read")) {
while ($row = mysql_fetch_array($result)) {
$result2 = mysql_query("SELECT * FROM `" . $tableprefix . $poststable . "` WHERE `$topic_id_column`=" . $row['tid'] . " ORDER BY '$post_date_column' DESC LIMIT 0,1");
$row2 = mysql_fetch_array($result2);
$topic = wmlspecialchars(html_entity_decode2($row[$title_column]));
$boardcode = docharlimit(html2wml($row2[$post_column]));
if ($viewdetails == 1) {
echo(ruslat("<p><b>Тема: </b><a href=\"" . $PHP_SELF . "?tid_page=" . $row2[$topic_id_column] . "_0#viewtopic\">" . $topic . "</a> (" . $row[$posts_column] . ", " . $row[$views_column] . ")<br/><b>Последнее сообщение:</b><br/><i>Автор:</i> " . $row2[$author_name_column] . "<br/><i>Сообщ.:</i> " . $boardcode . "<br/><br/></p>"));
} else {
echo(ruslat("<p><a href=\"" . $PHP_SELF . "?tid_page=" . $row2[$topic_id_column] . "_0#viewtopic\">" . $topic . "</a> (" . $row[$posts_column] . ", " . $row[$views_column] . ")<br/></p>"));
}
}
}
echo("<p align=\"center\">");
$p2 = $page + 1;
$p3 = $page - 1;
if (!$page==0) {
echo(ruslat("<a href=\"" . $PHP_SELF . "?fid_page=" . $fid . "_" . $p3 . "#viewforum\">Prev</a> "));
}
$result = mysql_query("SELECT * FROM `" . $tableprefix . $topicstable . "` ORDER BY '$last_post_column' DESC LIMIT " . ($p2 * $forumpostsperpage) . "," . $forumpostsperpage);
if ($result&&$row = mysql_fetch_array($result)) {
echo(ruslat("<a href=\"" . $PHP_SELF . "?fid_page=" . $fid . "_" . $p2 . "#viewforum\">Next</a>"));
}
echo(ruslat("<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>"));
$t2 = microtime();
if ($pagecreation==1) {
echo(ruslat("<p align=\"center\"><br/>Создано за<br/>" . substr(($t2 - $t1), 0, 8) . " сек.</p>"));
}
} else {
echo(ruslat("<p>У Вас нет прав доступа к этому форуму.<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>"));
}
}
If (!substr($pid, 0 , 1)=="f") {
$disstr = <<<EOF
</card>
<card id="viewtopic" title="{$boardtitle}">
EOF;
echo(ruslat($disstr));
}
if (!$tid==Null) {
$t1_3 = microtime();
$result = mysql_query("SELECT `$title_column`, `forum_id` FROM `" . $tableprefix . $topicstable . "` WHERE `tid`=" . $tid);
if (!$result) {
exit();
}
$row = mysql_fetch_array($result);
$topic_fid = $row["forum_id"];
echo(ruslat("<p align=\"center\"><b>Topic: " . wmlspecialchars(html_entity_decode2($row[$title_column])) . "</b><br/><br/></p>"));
$result = mysql_query("SELECT * FROM `" . $tableprefix . $poststable . "` WHERE `$topic_id_column`=" . $tid . " ORDER BY '$post_date_column' LIMIT " . ($page* $topicpostsperpage) . "," . $topicpostsperpage);
$result2 = mysql_query("SELECT 'id' FROM `" . $tableprefix . $poststable . "` WHERE `$topic_id_column`=" . $tid . " ORDER BY '$post_date_column'");
if (!$result) {
exit();
}
If (getperm($topic_fid, "read")) {
while ($row = mysql_fetch_array($result)) {
$boardcode = dosimplecharlimit(html2wml($row[$post_column]),$tid ,$row['pid'], $page);
if (!$row['attach_file']==null && $enattach == 1) {
$postfile = "<b>Присоединено:</b> <a href=\"" . $PHP_SELF . "?pid=f" . $row['pid'] . "\">" . $row['attach_file'] . "</a><br/>";
} else {
$postfile = "";
}
echo(ruslat("<p><b>Пользователь:</b> " . $row[$author_name_column] . "<br/><b>Сообщ.:</b> " . $boardcode . "<br/>" . $postfile . "<br/></p>"));
}
} else {
echo(ruslat("<p>У Вас нет прав доступа к этому разделу."));
}
echo("<p align=\"center\">");
$p2 = $page + 1;
$p3 = $page - 1;
if (!$page==0) {
echo(ruslat("<a href=\"" . $PHP_SELF . "?tid_page=" . $tid . "_" . $p3 . "#viewtopic\">Пред.</a> "));
}
$result = mysql_query("SELECT * FROM `" . $tableprefix . $poststable . "` WHERE `$topic_id_column`=" . $tid . " ORDER BY '$post_date_column' LIMIT " . ($p2 * $topicpostsperpage) . "," . $topicpostsperpage);
if ($result&&$row = mysql_fetch_array($result)) {
echo(ruslat(" <a href=\"" . $PHP_SELF . "?tid_page=" . $tid . "_" . $p2 . "#viewtopic\">След.</a>"));
}
echo("<br/>" . topicpagenav($result2, $page, $tid));
echo(ruslat("<br/><a href=\"" . $PHP_SELF . "\">Главная</a>"));
echo("</p>");
$t2_3 = microtime();
if ($pagecreation==1) {
echo(ruslat("<p align=\"center\"><br/>Создано за<br/>" . substr(($t2_3 - $t1_3), 0, 8) . " сек.</p>"));
}
} elseif (!$ptid==null) {
$t1_3 = microtime();
$result = mysql_query("SELECT * FROM `" . $tableprefix . $poststable . "` WHERE `pid`=" . $ppid);
echo(ruslat("<p align=\"center\"><b>Посмотреть все</b><br/></p>"));
$row = mysql_fetch_array($result);
$boardcode = html2wml($row[$post_column]);
if (!$row['attach_file']==null && $enattach == 1) {
$postfile = ruslat("<b>Присоединено:</b> <a href=\"" . $PHP_SELF . "?pid=f" . $row['pid'] . "\">" . $row['attach_file'] . "</a><br/>");
} else {
$postfile = "";
}
echo(ruslat("<p>" . $boardcode . "<br/>" . $postfile . "<br/></p>"));
echo("<p align=\"center\">");
echo(ruslat("<br/>" . "<a href=\"" . $PHP_SELF . "?tid_page=" . $ptid . "_" . $ppage . "#viewtopic\">Назад</a>"));
echo(ruslat("<br/><a href=\"" . $PHP_SELF . "\">Главная</a>"));
echo("</p>");
$t2_3 = microtime();
if ($pagecreation==1) {
echo(ruslat("<p align=\"center\"><br/>Создано за<br/>" . substr(($t2_3 - $t1_3), 0, 8) . " сек.</p>"));
}
}
If (!substr($pid, 0 , 1)=="f") {
$disstr = <<<EOF
</card></wml>
EOF;
echo(ruslat($disstr));
}
// Send file if Attachment URL selected
if (substr($pid, 0 , 1)=="f" && $enattach == 1) {
$pid = substr($pid, 1);
$result = mysql_query("SELECT * FROM `" . $tableprefix . $poststable . "` WHERE `$pid_column`=" . $pid);
$row = mysql_fetch_array($result);
$filename = $row['attach_file'];
$hardfilename = "http://www." . $furl . $uploadsdir . $row['attach_id'];
$ext = strtolower(substr($filename, (strlen($filename) - 3), 3));
$ext2 = strtolower(substr($filename, (strlen($filename) - 4), 4));
$type = "text/vnd.wap.wml";
// Find MIME Type by extension
if ($ext=="jar") {
$type = "application/java-archive";
} elseif ($ext=="thm") {
$type = "application/vnd.eri.thm";
} elseif ($ext=="jad") {
$type = "text/vnd.sun.j2me.app-descriptor";
} elseif ($ext=="wbmp") {
$type = "image/vnd.wap.wbmp";
} elseif ($ext2=="midi"||$ext=="mid"||$ext=="kar") {
$type = "audio/midi";
} elseif ($ext=="gif") {
$type = "image/gif";
} elseif ($ext=="jpg"||$ext2=="jpeg"||$ext=="jpe") {
$type = "image/jpeg";
} elseif ($ext=="mmf") {
$type = "application/vnd.smaf";
} elseif ($ext=="mp3") {
$type = "audio/x-mpeg";
} elseif ($ext=="wav") {
$type = "audio/x-wav";
} elseif ($ext=="amr") {
$type = "audio/amr";
} elseif ($ext=="kws") {
$type = "kws-audio/x-kws";
} elseif ($ext=="sis") {
$type = "application/x-epocinstall";
} elseif ($ext=="zip") {
$type = "application/zip";
} elseif ($ext=="rar") {
$type = "application/x-rar-compressed";
}
if (!function_exists('file_get_contents')) {
$filecontents = implode('', file($hardfilename));
} else {
$filecontents = file_get_contents($hardfilename);
}
header( "Content-Type: " . $type . "\nContent-Disposition: inline; filename=\"". $filename ."\"\nContent-Length: ".(string)(array_sum(count_chars ($filecontents)) ) );
$fh = fopen( $hardfilename, 'rb' );
fpassthru( $fh );
fclose( $fh );
}
?>