Location: PHPKode > projects > Sound PHP Engine > s-p-e-0.3.0/s-p-e-0.3.0/data/arc.php
<?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 3 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, see <http://www.gnu.org/licenses/>.
//
// ------
//
//  You can contact me via e-mail: lipetsk-gnu-lug at bk period ru
//
//  arc.php
//
//  Abstract: Archive.
//  
//  Revision History:
// 
//	1  2004-03-27 - 2005-07-02  vbt
//	2  2005-07-21  vbt
//	3  2005-09-23  vbt
//	4  2010-06-24  vbt
//	5  2011-01-21  vbt
// 6  2011-12-23  vbt
//
// =====================================================
header("Content-Type: text/html; charset=UTF-8");

include("configure/specfg.php"); 
include("../include/functions.php");

cache();

session_set_save_handler("open", "close", "read", "write", "destroy", "gc");
session_start();

gc();

redirect(read(session_id()));

if(read(session_id()) == "administrator")
	{

	language($cfg["deflangadmin"]);
	
	if(isset($_GET["type"]))
	{
		$type = base64_decode($_GET["type"]);
		if($type == 110)
		{
			$length = 10;
			$stype = _("news");
		}
		if($type == 111)
		{
			$length = 11;
			$stype = _("articles");
		}
		
	}
	
	if(isset($type) && isset($length) && ctype_digit($type))
	{
	
		if(isset($_GET["id"]) && ctype_digit($_GET["id"]))
		{
			$id = $_GET["id"];
			connect($cfg["host"], $cfg["user"], $cfg["password"], $cfg["database"], $connector);
			$result = mysql_query("select partname, pnid 
				from ".($cfg["prefix"])."partition 
				where num='$id' 
				and pnid regexp '^[0-9]{".($length)."}$'");
			while($row = mysql_fetch_array($result, MYSQL_NUM))
			{
				$partname = $row[0];
				$pointer = $row[1];
			}
			mysql_free_result($result);
			mysql_close($connector);
		}
		
		if(isset($_GET["page"]) && ctype_digit($_GET["page"]))
		{
			$page = $_GET["page"];
		}
		
		if(isset($pointer))
		{
			connect($cfg["host"], $cfg["user"], $cfg["password"], $cfg["database"], $connector);
			$result = mysql_query("select count(num) 
				from ".($cfg["prefix"].$pointer)."", $connector) 
				or die("error #102-1");
			while($row = mysql_fetch_array($result, MYSQL_NUM))
			{
				$total = $row[0];
			}
			mysql_free_result($result);
			mysql_close($connector);
		
			$pagequantity = ceil($total/$cfg["manarc"]);
		
			if(isset($page) == false || ctype_digit($page) == false)
			{
				$page = 1;
			}
		
			$offset = ($page - 1) * $cfg["manarc"];
			
			if($cfg["manarc"] < $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='arc.php?type=".(base64_encode($type))."&id=$id&page=$i'>$pagearray[$i]</a>"." | ";
						} 
						else 
						{
							$pageline = $pageline."<a href='arc.php?type=".(base64_encode($type))."&id=$id&page=$i'>$pagearray[$i]</a>"." | ";
						}
					}
				}
			}
		}
		
		echo "<html>
		<head>
		<title>".(_("Archive"))."</title> 
		<link rel='stylesheet' type='text/css' href='../skin/".($cfg["skin"])."/style.css'>
		</head>";
		echo "<body class='admin'>";
		echo "<p><br><font class='s-normal' id='w-normal'>
		&nbsp;".(_("Back to the"))." <a href='admin.php'>".(_("s-p-e Administrator's Page"))."</a>.
		</font></p>";
		
		echo "<table><tr valign='top'><td>";
		echo "<table class='admin-table' border='1'>
			<tr>
			<td>
				<font class='s-normal' id='w-bold'>
				".(_("List of the"))."&nbsp;$stype&nbsp;".(_("sections"))."
				</font>
				</td>
			</tr>
			<tr><td>
				<table class='admin-table' height='496' width='250'><tr valign='top'>
				<td><br>";
		
		connect($cfg["host"], $cfg["user"], $cfg["password"], $cfg["database"], $connector);
		$result = mysql_query("select num, partname 
			from ".($cfg["prefix"])."partition 
			where pnid regexp '^[0-9]{".($length)."}$'", $connector) 
			or die("error #102-2");
		while($row = mysql_fetch_array($result, MYSQL_NUM))
		{
			echo "<font class='s-normal' id='w-normal'>&nbsp;&nbsp;
			<a href='arc.php?type=".(base64_encode($type))."&id=".($row[0])."'>
			<U>".($row[1])."</U>
			</a>
			</font>
			<br>";
		}
		mysql_free_result($result);
		mysql_close($connector);
		
		echo "</td>
		</tr>
		</table>

		</td>
		</tr>
		</table>
		
		</td>
		<td>
		
		<table class='admin-table' border='1' width='430'>
		<tr>
		<td>
			<font class='s-normal' id='w-bold'>".(_("Content of the section"))."";
		if(isset($partname))
		{ 
			echo "&nbsp;&nbsp;--&nbsp;&nbsp;$partname&nbsp;&nbsp;--";
		}
			echo "</font>
		</td>
		</tr>
		<tr valign='top'>
		<td height='500'>
		
		<table cellpadding='5'><tr><td>"; 
		
		if(isset($pointer) == false)
		{
			echo "<font class='s-normal' id='w-normal'>".(_("Please, select a section."))."</font>";
		} 
		
		if(isset($pointer) && isset($id))
		{
			connect($cfg["host"], $cfg["user"], $cfg["password"], $cfg["database"], $connector);
			$result = mysql_query("select num, intro, login, theme, date, timer 
				from ".($cfg["prefix"].$pointer)." 
				order by date desc, timer desc 
				limit $offset, ".($cfg["manarc"])."", $connector) 
				or die("error #102-3");
			if(mysql_num_rows($result) == 0)
			{
				echo "<font class='s-normal' id='w-normal'>".(_("The section is empty."))."</font>";
			} 
			else 
			{
				while($row = mysql_fetch_array($result, MYSQL_NUM))
				{
					echo "<form action='parc.php' method='post'>";
					echo "<input type='hidden' name='num' value='".(base64_encode($row[0]))."'>";
					echo "<input type='hidden' name='id' value='".(base64_encode($id))."'>";
					echo "<input type='hidden' name='partname' value='".(base64_encode($partname))."'>";
					echo "<p>
					<font class='s-normal' id='w-normal'>
					".(_("Author")).":&nbsp;&nbsp;".$row[2]."
					</font>
					</p>
					<p>
					<font class='s-normal' id='w-normal'>
					".(_("Published")).":&nbsp;&nbsp;&nbsp;".$row[4].";&nbsp;".$row[5]."
					</font>
					</p>
					<p>
					<font class='s-normal' id='w-normal'>
					".(_("Theme")).":&nbsp;&nbsp;&nbsp;<b>".$row[3]."</b>
					</font>
					</p>
					<p>
					<font class='s-normal' id='w-normal'>
					".$row[1]."&nbsp;
					</font>
					<INPUT class='simple-button' type='submit' value='".(_("Move to archive"))."&nbsp;&raquo;'>
					</form>
					<div align='center'>
					<hr width='400'>
					</div>
					<br>";
				}
				mysql_free_result($result);
			}
			mysql_close($connector);
		}
		if(isset($pageline))
		{
			echo search_pager($pageline, $page, "arc.php?type=".(base64_encode($type))."&id=$id&page=", $pagequantity);
		}
		echo "</td>
		</tr>
		</table>
		
		</td>
		</tr>
		</table>
		</div>
		</body>
		</html>";
	}
} else {
	echo "".(_("Access denied."))."";
}
?>
Return current item: Sound PHP Engine