<?php
// =====================================================
//
// s-p-e - Content management system.
// Copyright (C) 2004, 2005, 2010, 2011 Vladimir B. Tsarkov
//
// This file is part of s-p-e.
//
// s-p-e 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.
//
// s-p-e 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 s-p-e; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
//
// ------
//
// You can contact me via e-mail: lipetsk-gnu-lug at bk period ru
//
// moutput.php
//
// Abstract: Message board output.
//
// Revision History:
//
// 1 2005-06-20 vbt
// 2 2005-07-31 vbt
// 3 2005-09-18 vbt
// 4 2010-05-16 vbt
// 5 2011-01-22 vbt
//
// =====================================================
connect($cfg["host"], $cfg["user"], $cfg["password"], $cfg["database"], $connector);
$result = mysql_query("select count(num) from ".($cfg["prefix"])."message", $connector) or die("error #102");
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
$total = $row[0];
}
mysql_free_result($result);
$pagequantity = ceil($total/$cfg["mboardlim"]);
if(isset($mpage) == false || ctype_digit($mpage) == false)
{
$mpage = 1;
}
$offset = ($mpage - 1) * $cfg["mboardlim"];
if($cfg["mboardlim"] < $total)
{
for($i = 1; $i <= $pagequantity; $i++)
{
$pagearray[$i] = $i;
}
for($i = 1; isset($pagearray[$i]); $i++)
{
if(sizeof($pagearray) == 1)
{
$pageline = false;
}
else
{
if($i == 1)
{
$pageline = "| "."<a href='index.php?ins=board&mpage=$i'>$pagearray[$i]</a>"." | ";
}
else
{
$pageline = $pageline."<a href='index.php?ins=board&mpage=$i'>$pagearray[$i]</a>"." | ";
}
}
}
}
$result = mysql_query("select theme, text
from ".($cfg["prefix"])."message
order by date desc, timer desc
limit $offset, ".($cfg["mboardlim"])."", $connector)
or die("error #102");
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
echo "<font class='s-normal' id='w-bold'>".$row[0]."</font>
<br>
<ul>
<font class='s-normal' id='w-normal'>".$row[1]."</font>
</ul>
<br>";
}
mysql_free_result($result);
mysql_close($connector);
if(isset($pageline))
{
echo search_pager($pageline, $mpage, "index.php?ins=board&mpage=", $pagequantity);
}
?>