Location: PHPKode > projects > Sound PHP Engine > s-p-e-0.3.0/s-p-e-0.3.0/data/newest.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
//
//  newest.php
//
//  Abstract: Newest publications management.
//  
//  Revision History:
// 
//	1  2005-09-18  vbt
//	2  2010-06-24  vbt
//	3  2011-01-22  vbt
// 4  2011-12-23  vbt
//
// =====================================================
// Pager; LIMIT, OFFSET.

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['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'");
		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)." 
			where state is null", $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["mnewest"]);
		
		if(isset($page) == false || ctype_digit($page) == false)
		{
			$page = 1;
		}
		
		$offset = ($page - 1) * $cfg["mnewest"];
		
		if($cfg["mnewest"] < $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='newest.php?id=$id&page=$i'>$pagearray[$i]</a>"." | ";
				  } 
			          else 
				  {
			            $pageline = $pageline."<a href='newest.php?id=$id&page=$i'>$pagearray[$i]</a>"." | ";
				  }
				}
			}
		}
	}
	
	
	echo "<html>
		<head>
		<title>".(_("Newest publications management"))."</title> 
		<link rel='stylesheet' type='text/css' href='../skin/".($cfg["skin"])."/style.css'>
		</head>
		<body class='admin'>
		<p><br>
		<font class='s-normal'>
		".(_("Back to the"))." <a href='admin.php'>".(_("s-p-e Administrator's Page"))."</a>.
		</font>
		</p>
		
		<table>
		<tr valign='top'>
		<td>
		<table class='admin-table' border='1'>
			<tr>
				<td>
				<font class='s-normal' id='w-bold'>".(_("List of the sections"))."</font>
				</td>
			</tr>
			<tr><td>
				<table bgcolor='#D5D5D5' height='496' width='250'><tr valign='top'>
				<td><p></p>";
		
		connect($cfg["host"], $cfg["user"], $cfg["password"], $cfg["database"], $connector);
		$result = mysql_query("select num, partname 
			from ".($cfg["prefix"])."partition", $connector) 
			or die("error #102-2");
		while($row = mysql_fetch_array($result, MYSQL_NUM))
		{
			echo "<p>
			<font class='s-normal' id='w-normal'>&nbsp;&nbsp;
			<a href='newest.php?id=".($row[0])."'>
			<U>".($row[1])."</U>
			</a>
			</font>
			</p>";
		}
		mysql_free_result($result);
		mysql_close($connector);
		
		echo "</td>
		</tr>
		</table>
		
		</td>
		</tr>
		</table>
		
		</td>
		<td>
		<table class='admin-table' border='1' width='100%'>
			<tr>
			<td>
			<font class='s-normal' id='w-bold'>".(_("Newest publications of the section"))."";
		if(isset($partname))
		{ 
			echo "&nbsp;&nbsp;--&nbsp;&nbsp;$partname&nbsp;&nbsp;--";
		}
		echo "</font>
		</td>
		</tr>
		
		<tr valign='top'>
		<td bgcolor='#D5D5D5' height='500'>
		<table cellpadding='5'>
		<tr>
		<td>"; 
		if(isset($pointer))
		{
			connect($cfg["host"], $cfg["user"], $cfg["password"], $cfg["database"], $connector);
			$result = mysql_query("select num, intro, login, theme, date, timer 
				from ".($cfg["prefix"].$pointer)." 
				where state is null 
				order by date desc, 
				timer desc limit $offset, ".($cfg["mnewest"])."", $connector) 
				or die("error #102-3");
			if(is_resource($result))
			{
				if(isset($id) && mysql_num_rows($result) == 0)
				{
					echo "<font class='s-normal' id='w-bold'>".(_("The section is empty."))."</font>";
				} 
				else 
				{
  				  while($row = mysql_fetch_array($result))
  				  {
				    echo "<form action='pnewest.php' method='post'>";
				    echo "<input type='hidden' name='num' value='".(base64_encode($row["num"]))."'>";
				    echo "<input type='hidden' name='id' value='".(base64_encode($id))."'>";
				    echo "<p>
				    <font class='s-normal' id='w-normal'>
				    ".(_("Author")).":&nbsp;&nbsp;".$row["login"]."
				    </font>
				    </p>

				    <p>
				    <font class='s-normal' id='w-normal'>
				    ".(_("Published")).":&nbsp;&nbsp;&nbsp;".$row["date"].";&nbsp;".$row["timer"]."
				    </font>
				    </p>

				    <p>
				    <font class='s-normal' id='w-normal'>
				    ".(_("Theme")).":&nbsp;&nbsp;&nbsp;<b>".$row["theme"]."</b>
				    </font>
				    </p>
						
				    <p>
				    <font class='s-normal' id='w-normal'>".$row["intro"]."&nbsp;</font>
				    </p>
				    <INPUT class='simple-button' type='submit' 
				    value='".(_("Delete from the list of newest publications"))."&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, "newest.php?id=$id&page=", $pagequantity);
			}
		} 
		else 
		{
			echo "<font class='s-normal' id='w-bold'>".(_("Please, select a section."))."</font>";
		}
		echo "</td>
		</tr>
		</table>

		</td>
		</tr>
		</table>
		</div>
		</body>
		</html>";
} 
else 
{
	echo _("Access denied.");
}
?>
Return current item: Sound PHP Engine