Location: PHPKode > projects > Potato News > newcopy/includes/news.php
<link rel="stylesheet" type="text/css"
href="news.css" />
<?PHP
include("data/settings.php");
$func = $_REQUEST['func'];
$arc = $_REQUEST['arc'];
$month = $_REQUEST['month'];
$year = $_REQUEST['year'];
$pid = $_REQUEST['pid'];

if ($pid != "") {

if (file_exists("data/articles/$pid.txt")) {
include ("data/articles/$pid.db.php");

echo "<div class='title'>$title</div>";
echo "<div class='content'>";
include("data/articles/$pid.txt");
echo "</div><br>";
echo "<div class=\"foot\">Posted by $postauthor on $postdate</div>";

}


} else {


if ($func == "filter") {
echo "<div class='title'/>Filter by date</div>";
echo "<div class='content'/><a href='?arc='/><< Back</a></div><br>";
echo "<div class='content'/>
<form action='?func=check' method='post'>
<b>Month:</b> &nbsp;
<select name='month' size='0' height='1'>
	<option value='January'>January</option>
	<option value='February'>February</option>
	<option value='March'>March</option>
		<option value='April'>April</option>
		
			<option value='May'>May</option>
	<option value='June'>June</option>
	<option value='July'>July</option>
		<option value='August'>August</option>
		
			<option value='September'>September</option>
	<option value='October'>October</option>
	<option value='November'>November</option>
		<option value='December'>December</option>

</select> &nbsp;

<b>Year (YYYY):</b> &nbsp;
<input type=\"text\" name=\"year\" size=\"4\" maxlength='4' value=\"\"><br>
<br>
<INPUT TYPE=SUBMIT VALUE=\"Search\">
</form>
</div>";

echo "<br>";


} elseif ($func == "check" and preg_match('/^[a-z0-9]+$/i', $year) and preg_match('/^[a-z0-9]+$/i', $month)) {

echo "<div class='content'/>
<b>Month:</b> $month<br>
<b>Year:</b> $year<br><br>

<a href='?func=filter'/>Back to search</a><br>
<a href='?arc'/>Back to main</a><br><br></div>";

$dirid="data/articles";
$dh=opendir($dirid);
while ($dave=readdir($dh))
{
if (file_exists("data/articles/$dave.txt")) {
if (file_exists("data/articles/$dave.db.php")) {
include ("data/articles/$dave.db.php");
if ($postmonth == "$month" and $postyear == "$year") {
echo "<div class='title'>$title</div>";
echo "<div class='content'>";
if ($newsimage != "") {
echo "<img src='$newsimage' align='left'/>";
}
include ("data/articles/$dave.txt");
echo "</div><br>";
echo "<div class=\"foot\">Posted by $postauthor on $postdate";

if ($permalink == "yes") {
echo "|| <a href='?pid=$a1'/>Permalink</a></div>";
} else {
echo "</div>";
}
echo "<br>";
echo "<br>";
}
}
}
}
closedir ($dh);


} else {

$file = fopen("data/articles/newsid.txt","r");
$exra = fgets($file);
fclose($file);

$sixer = 8*$arc;

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

$n1 = 0+$sixer;
$n2 = 1+$sixer;
$n3 = 2+$sixer;
$n4 = 3+$sixer;
$n5 = 4+$sixer;
$n6 = 5+$sixer;
$n7 = 6+$sixer;
$n8 = 7+$sixer;

$a1 = $exra-$n1;
$a2 = $exra-$n2;
$a3 = $exra-$n3;
$a4 = $exra-$n4;
$a5 = $exra-$n5;
$a6 = $exra-$n6;
$a7 = $exra-$n7;
$a8 = $exra-$n8;

if (file_exists("data/articles/$a1.txt")) {
if (file_exists("data/articles/$a1.db.php")) {
include ("data/articles/$a1.db.php");
echo "<div class='title'>$title</div>";
echo "<div class='content'>";
if ($newsimage != "") {
echo "<img src='$newsimage' align='left'/>";
}
include ("data/articles/$a1.txt");
echo "</div><br>";
echo "<div class=\"foot\">Posted by $postauthor on $postdate";

if ($permalink == "yes") {
echo "|| <a href='?pid=$a1'/>Permalink</a></div>";
} else {
echo "</div>";
}

echo "<br>";
echo "<br>";
}
}

if (file_exists("data/articles/$a2.txt")) {
if (file_exists("data/articles/$a2.db.php")) {
include ("data/articles/$a2.db.php");
echo "<div class='title'>$title</div>";
echo "<div class='content'>";
if ($newsimage != "") {
echo "<img src='$newsimage' align='left'/>";
}
include ("data/articles/$a2.txt");
echo "</div><br>";
echo "<div class=\"foot\">Posted by $postauthor on $postdate";

if ($permalink == "yes") {
echo "|| <a href='?pid=$a2'/>Permalink</a></div>";
} else {
echo "</div>";
}

echo "<br>";
echo "<br>";
}
}

if (file_exists("data/articles/$a3.txt")) {
if (file_exists("data/articles/$a3.db.php")) {
include ("data/articles/$a3.db.php");
echo "<div class='title'>$title</div>";
echo "<div class='content'>";
if ($newsimage != "") {
echo "<img src='$newsimage' align='left'/>";
}
include ("data/articles/$a3.txt");
echo "</div><br>";
echo "<div class=\"foot\">Posted by $postauthor on $postdate";

if ($permalink == "yes") {
echo "|| <a href='?pid=$a3'/>Permalink</a></div>";
} else {
echo "</div>";
}

echo "<br>";
echo "<br>";
}
}

if (file_exists("data/articles/$a4.txt")) {
if (file_exists("data/articles/$a4.db.php")) {
include ("data/articles/$a4.db.php");
echo "<div class='title'>$title</div>";
echo "<div class='content'>";
if ($newsimage != "") {
echo "<img src='$newsimage' align='left'/>";
}
include ("data/articles/$a4.txt");
echo "</div><br>";
echo "<div class=\"foot\">Posted by $postauthor on $postdate";

if ($permalink == "yes") {
echo "|| <a href='?pid=$a4'/>Permalink</a></div>";
} else {
echo "</div>";
}

echo "<br>";
echo "<br>";
}
}

if (file_exists("data/articles/$a5.txt")) {
if (file_exists("data/articles/$a5.db.php")) {
include ("data/articles/$a5.db.php");
echo "<div class='title'>$title</div>";
echo "<div class='content'>";
if ($newsimage != "") {
echo "<img src='$newsimage' align='left'/>";
}
include ("data/articles/$a5.txt");
echo "</div><br>";
echo "<div class=\"foot\">Posted by $postauthor on $postdate";

if ($permalink == "yes") {
echo "|| <a href='?pid=$a5'/>Permalink</a></div>";
} else {
echo "</div>";
}

echo "<br>";
echo "<br>";
}
}

if (file_exists("data/articles/$a6.txt")) {
if (file_exists("data/articles/$a6.db.php")) {
include ("data/articles/$a6.db.php");
echo "<div class='title'>$title</div>";
echo "<div class='content'>";
if ($newsimage != "") {
echo "<img src='$newsimage' align='left'/>";
}
include ("data/articles/$a6.txt");
echo "</div><br>";
echo "<div class=\"foot\">Posted by $postauthor on $postdate";

if ($permalink == "yes") {
echo "|| <a href='?pid=$a6'/>Permalink</a></div>";
} else {
echo "</div>";
}

echo "<br>";
echo "<br>";
}
}

if (file_exists("data/articles/$a7.txt")) {
if (file_exists("data/articles/$a7.db.php")) {
include ("data/articles/$a7.db.php");
echo "<div class='title'>$title</div>";
echo "<div class='content'>";
if ($newsimage != "") {
echo "<img src='$newsimage' align='left'/>";
}
include ("data/articles/$a7.txt");
echo "</div><br>";
echo "<div class=\"foot\">Posted by $postauthor on $postdate";

if ($permalink == "yes") {
echo "|| <a href='?pid=$a7'/>Permalink</a></div>";
} else {
echo "</div>";
}

echo "<br>";
echo "<br>";
}
}

if (file_exists("data/articles/$a8.txt")) {
if (file_exists("data/articles/$a8.db.php")) {
include ("data/articles/$a8.db.php");
echo "<div class='title'>$title</div>";
echo "<div class='content'>";
if ($newsimage != "") {
echo "<img src='$newsimage' align='left'/>";
}
include ("data/articles/$a8.txt");
echo "</div><br>";
echo "<div class=\"foot\">Posted by $postauthor on $postdate";

if ($permalink == "yes") {
echo "|| <a href='?pid=$a8'/>Permalink</a></div>";
} else {
echo "</div>";
}

echo "<br>";
echo "<br>";
}
}



if ($exra < "8") {
echo "";
} else {
echo "<div class='content' align=\"center\"><a href=\"?arc=$prev\"/>Previous</a>";
echo "";
if ($arc == "" or $arc == "0") {
echo "</div>";
} else {
echo " || <a href=\"?arc=$next\"/>Next</a></div>";
}
}

echo "<div class='content' align='center'><a href='?func=filter'/>Filter posts by date</a></div>";

}


}
echo "<br><div class='content' align='center' />Powered by <a href='http://potato-scripts.com'/>Potato News</a></div>";

?>

Return current item: Potato News