View file wml/sections.php

File size: 3.48Kb
<?php
	/**
	 *	Wap Portal Server
	 *
	 *	Copyright (C) 2002 - 2004 Emir Sakic
	 *
	 *	Wap Portal Server
	 *	Developer: Emir Sakic - [email protected]
	 *  Homepage: http://www.sakic.net
	 *	Date: 15/03/2004
	 * 	Version #: 1.2
	**/

$query = "SELECT * FROM wps_sections WHERE id = '$id'";
$result = mysql_query($query);
$row = mysql_fetch_object ($result);

echo "<card id=\"Card1\" title=\"$row->title\">\n";
if (isset($itemid) && $itemid != "") {

	if (empty($offset)) {
		$offset = 0;
	}

	$query = "SELECT * FROM wps_items WHERE id = '$itemid'";
	$result = mysql_query($query);
	$row = mysql_fetch_object ($result);

	$arrDateTime = explode(" ", $row->date);
	$arrDate = explode("-", $arrDateTime[0]);
	$arrTime = explode(":", $arrDateTime[1]);
	$date = strftime ($dateformatmiddle, mktime ($arrTime[0],$arrTime[1],$arrTime[2],$arrDate[1],$arrDate[2],$arrDate[0]) + $time_offset);
	print "<p><b>$row->title</b><br />\n";
	print "<small>$date</small><br />\n";

	// Strip all HTML tags
	$content = strip_tags($row->content);
	// Split long content in arrays (lenght 500 chars)
	$content = split_in_array($content, 500);
	// Replace new lines with branches
	//$content[$offset] = ereg_replace("(\r\n|\n|\r)", "<br />\n", $content[$offset]);
	$content[$offset] = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />\n", $content[$offset]);
	// Parse UBB code
	$content[$offset] = parseUBB($content[$offset]);

	// Display
	echo $content[$offset];

	$prev = $offset-1;
	$next = $offset+1;

	if (strlen($content[$next]) > 0) {
		echo "-";
	}
	if (strlen($content[$prev]) > 0 || strlen($content[$next]) > 0) {
		echo "<br />";
	}

	if (strlen($content[$prev]) > 0) {
		echo "
			<anchor>"._PREV_STR."
				<go href=\"index.php\">
					<postfield name=\"option\" value=\"section\" />
			  		<postfield name=\"itemid\" value=\"$row->id\" />
			  		<postfield name=\"offset\" value=\"$prev\" />
				</go>
			</anchor>&nbsp;";
	}

	if (strlen($content[$next]) > 0) {
		echo "
			<anchor>"._NEXT_STR."
				<go href=\"index.php\">
					<postfield name=\"option\" value=\"section\" />
			  		<postfield name=\"itemid\" value=\"$row->id\" />
			  		<postfield name=\"offset\" value=\"$next\" />
				</go>
			</anchor>";
	}

	echo "</p>\n";
	echo "<p align=\"center\">\n";
	echo "<anchor>"._BACK."\n";
	echo "<go href=\"index.php\">\n";
	echo "<postfield name=\"option\" value=\"section\" />\n";
	echo "<postfield name=\"id\" value=\"$row->sectionid\" />\n";
	echo "</go>\n";
	echo "</anchor>\n";
	echo "</p>\n";
} else {
	echo "<p>\n";
	echo "<b>$row->intro</b><br />";
	$query = "SELECT * FROM wps_items WHERE sectionid = '$row->id' ORDER BY ordering, date DESC";
	$result = mysql_query($query);
	for ($i = 1; $row = mysql_fetch_object ($result); $i++) {
		$arrDateTime = explode(" ", $row->date);
		$arrDate = explode("-", $arrDateTime[0]);
		$arrTime = explode(":", $arrDateTime[1]);
		$date_sh = strftime ($dateformatshort, mktime ($arrTime[0],$arrTime[1],$arrTime[2],$arrDate[1],$arrDate[2],$arrDate[0]) + $time_offset);
		if ($row->published) {
			echo "
			<anchor>$row->title
				<go href=\"index.php\">
					<postfield name=\"option\" value=\"section\" />
			  		<postfield name=\"itemid\" value=\"$row->id\" />
				</go>
			</anchor> - $date_sh<br />";
		}
	}
	echo "</p>\n";
	echo "<p align=\"center\">\n";
	echo "<anchor>"._HOME."\n";
	echo "<go href=\"index.php\">\n";
	echo "</go>\n";
	echo "</anchor>\n";
	echo "</p>\n";
}

echo "</card>\n";