<?php // <- Do not Remove this line
// ----------------------------------------------
// ----------------------------------------------
// ----------Sentertainment.net Presents---------
// -----------Unofficial IPB WAP Script----------
// ----------------------------------------------
// ----------------------------------------------
// Release v1.5
//
// ============SIMPLIFIED TERMS OF USE===========
// This script is in no affiliation with Invision
// or any of it's members and this script may not
// be sold or modified any form.
// Also, as a request by the author of this script,
// the coding of this script may not be changed,
// altered, or modified in any form.
// If any of these terms are not to your needs,
// then permission from the author is before any
// terms of use may be broken.
// 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 Creit Where it is Due!--------
//
// Coming Soon to a script near you!
// This means all credit is mine for now!
//
// ----------------------------------------------
// -------------Database Login Info--------------
// ----------------------------------------------
$dbuser = "bart"; // Forum SQL Database Access Username
$dbpass = "bart"; // Forum SQL Database Access Password
$dbname = "bart"; // Forum SQL Database Name
$dbserver = "localhost"; // Database Server (Usualy "localhost")
// ----------------------------------------------
// ----------------Forum Settings----------------
// ----------------------------------------------
$furl = "softoplanet.com.ru/wap/"; // 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 = "Softoplanet"; // 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 = 1; // 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
// 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 (!$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];
}
// 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=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 = "Привет <b>$username</b> (<a href=\"$PHP_SELF?action=login#view\">Login</a>)<br/><br/>";
} else {
$loginstr = "Привет <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/>
Coding by<br/>Sentertainment.net
</p>
</card>
<card id="view" title="{$boardtitle}">
EOF;
echo($disstr . $disstr1 . $disstr2);
}
if ($action=="") {
} else {
If ($action=="forums") {
$disstr = "";
$t1 = microtime();
echo("<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("<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("<a href=\"" . $PHP_SELF . "?fid=" . $row2['id'] . "#viewforum\">" . wmlspecialchars(html_entity_decode2($row2[$name_column])) . "</a><br/>");
} else {
echo("<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("<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>");
$t2 = microtime();
if ($pagecreation==1) {
echo("<p align=\"center\"><br/>Создано за<br/>" . substr(($t2 - $t1), 0, 8) . " сек.</p>");
}
}
If ($action=="last5") {
$t1 = microtime();
echo("<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]));
$boardcode = docharlimit(html2wml($row2[$post_column]));
if ($viewdetails == 1) {
echo("<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("<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("<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("<a href=\"" . $PHP_SELF . "?page_action=" . $p2 . "_last5#view\">След.</a>");
}
echo("<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>");
$t2 = microtime();
if ($pagecreation==1) {
echo("<p align=\"center\"><br/>Создано за<br/>" . substr(($t2 - $t1), 0, 8) . " сек.</p>");
}
}
If ($action=="categories") {
$t1 = microtime();
echo("<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("<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("<a href=\"" . $PHP_SELF . "?id=" . $row['id'] . "#viewcategory\">" . wmlspecialchars(html_entity_decode2($row[$name_column])) . "</a><br/>");
}
}
If ($navmode == 1) {
echo("</select>");
}
echo("<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>");
$t2 = microtime();
if ($pagecreation==1) {
echo("<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($disstr);
}
If ($action=="login2") {
echo("<p align=\"center\"><b>Вход</b><br/><br/>");
$result = mysql_query("SELECT * FROM " . $tableprefix . $memberstable . " where $name_column = '" . $LoginUsername . "'");
If (!$result) {
echo("Ошибка<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("Вы зашли как $LoginUsername,<br/>Сессия завершится через $loginsesmin минут.<br/><br/><a href=\"" . $PHP_SELF . "\">Home</a>");
} else {
echo("Неверное имя или пароль<br/><br/><a href=\"$PHP_SELF?action=login#view\">Назад</a>");
}
} else {
echo("Неверное имя или пароль<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("Вы вышли<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($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("<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("<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("<a href=\"" . $PHP_SELF . "?fid=" . $row['id'] . "#viewforum\">" . wmlspecialchars(html_entity_decode2($row[$name_column])) . "</a><br/>");
}
}
}
If ($forumviewnavmode == 1) {
echo("</select>");
}
echo("<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>");
$t2_1 = microtime();
if ($pagecreation==1) {
echo("<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($disstr);
}
else
{
$disstr = <<<EOF
</p>
</card>
<card id="viewforum" title="{$boardtitle}">
EOF;
echo($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("<p align=\"center\"><b>" . wmlspecialchars(html_entity_decode2($row['name'])) . "</b><br/><br/></p>");
echo("<p>");
$result = mysql_query("SELECT * FROM `" . $tableprefix . $topicstable . "` WHERE `$forum_id_column`=" . $fid . " AND `$pinned_column`=1 ORDER BY `$last_post_column` DESC");
while ($row = mysql_fetch_array($result)) {
$topic = wmlspecialchars(html_entity_decode2($row[$title_column]));
echo("<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("<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("<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("<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("<a href=\"" . $PHP_SELF . "?page_action=" . $p2 . "_last5#view\">След.</a>");
}
echo("<br/><a href=\"" . $PHP_SELF . "\">Главная</a></p>");
$t2 = microtime();
if ($pagecreation==1) {
echo("<p align=\"center\"><br/>Создано за<br/>" . substr(($t2 - $t1), 0, 8) . " сек.</p>");
}
}
If (!substr($pid, 0 , 1)=="f") {
$disstr = <<<EOF
</card>
<card id="viewtopic" title="{$boardtitle}">
EOF;
echo($disstr);
}
if (!$tid==Null) {
$t1_3 = microtime();
$result = mysql_query("SELECT `$title_column` FROM `" . $tableprefix . $topicstable . "` WHERE `tid`=" . $tid);
if (!$result) {
exit();
}
$row = mysql_fetch_array($result);
echo("<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();
}
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("<p><b>Пользователь:</b> " . $row[$author_name_column] . "<br/><b>Сообщ.:</b> " . $boardcode . "<br/>" . $postfile . "<br/></p>");
}
echo("<p align=\"center\">");
$p2 = $page + 1;
$p3 = $page - 1;
if (!$page==0) {
echo("<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(" <a href=\"" . $PHP_SELF . "?tid_page=" . $tid . "_" . $p2 . "#viewtopic\">След.</a>");
}
echo("<br/>" . topicpagenav($result2, $page, $tid));
echo("<br/><a href=\"" . $PHP_SELF . "\">Главная</a>");
echo("</p>");
$t2_3 = microtime();
if ($pagecreation==1) {
echo("<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("<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 = "<b>Присоединено:</b> <a href=\"" . $PHP_SELF . "?pid=f" . $row['pid'] . "\">" . $row['attach_file'] . "</a><br/>";
} else {
$postfile = "";
}
echo("<p>" . $boardcode . "<br/>" . $postfile . "<br/></p>");
echo("<p align=\"center\">");
echo("<br/>" . "<a href=\"" . $PHP_SELF . "?tid_page=" . $ptid . "_" . $ppage . "#viewtopic\">Назад</a>");
echo("<br/><a href=\"" . $PHP_SELF . "\">Главная</a>");
echo("</p>");
$t2_3 = microtime();
if ($pagecreation==1) {
echo("<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($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 );
}
?>