I'm trying to create mutlipule pages with from a single php script. It reads a file which list all the files that need to be displayed. Truncates according to the amount of files i want to be displayed. And adds links accordingly (i.e. More articles 1, More Articles 2). Take a look at the code to better understand what I am trying to do. I can explain more in detail if the code isn't enough.
/*
+----------------------------------------------------------------------+
| phpCET Version beta 1.9.8 |
+----------------------------------------------------------------------+
| Copyright (c) 2000-2002 [email]hooligan@dow-clan.net[/email] |
| 2002-2003 [email]hooligan@dow-clan.net[/email] (Joshua M. |
+----------------------------------------------------------------------+
| This program 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. |
| |
| This program 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 this program; if not, write to the Free Software |
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| MA 02111-1307, USA. |
+----------------------------------------------------------------------+
| Authors: [email]hooligan@dow-clan.ne[/email] |
+----------------------------------------------------------------------+
*****************/
error_reporting(E_ALL);
//Extract config
$linespan = 0;
$knife = "<~>";
$pie = file_get_contents("phpcet/config.inc.ctxt");
$slice = explode($knife, $pie);
include($slice[1]."cet_lang.php");
$handle_parts = $slice[2];
$handle = opendir($handle_parts);
/*/this was made to use multiple pages
if(isset($_GET["page"]))
{
$page = 0;
}
else
{
$_GET["page"] = 0;
}
$pages = explode(",", $slice[8]);
if($slice[8] < 0)
{
$pcount = 0;
}
else
{
$pcount = count($pages);
}
*/
$pcount=0;
$_GET["page"] = 0;
if (isset($handle))
{
//echo "<html>\n";
//echo "<head>\n";
//echo "<title>$slice[3]</title>\n";
//echo "<meta name=\"chache\" content=\"no-chache\">\n";
//echo "<meta name=\"robots\" content=\"index, follow\">\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"phpcet/phpCET.css\">\n";
//Do not remove or modify this "Generated by" message.
echo "<!-- Generated using phpCET visit us
at [url]http://www.dow-clan.net/[/url] -->\n";
//echo "</head>\n";
//echo "<body>\n";
echo "<table class=\"maintable\">";
echo "<tr>";
echo "<td class=\"maintd\">";
if($pcount > 0)
{
echo "<hr class=\"hr\">";
echo "<div align=\"center\">";
for ($i = 0; $i <= $pcount; $i++)
{
echo "<a href=\"?page=$i\" class=\"pagelinks\">page "; echo $i; echo "</a> ";
}
echo "</div>";
echo "<hr class=\"hr\">";
}
echo "<table class=\"table\">\n";
/* This was used to create mutlipule pages
if($slice[8] == "all")
{
$pcount = 346 * 100000 + 3;
$pcountorg = $pcount;
}
elseif($slice[8] >= 15)
{
$pcount = 18;
$pcountorg = $pcount;
}
elseif($slice[8] <= 5)
{
$pcount = 8;
$pcountorg = $pcount;
}
else
{
$pcount = $slice[8] + 3;
$pcountorg = $pcount;
}
*/
while (false !==($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$construct = file_get_contents($slice[2].$file);
$parse = explode("<~>", $construct);
if($slice[8] == "yes")
{
$date = date ("F d Y", filemtime($slice[2].$file))."<br><br>";
}
else
{
$date = "";
}
if(isset($_GET["id"]))
{
$mind = 0;
}
else
{
$mind = 1;
}
if($mind == 1)
{
echo "<tr>\n";
echo "<td class=\"td\">";
echo "<div class=\"title\">"; echo $parse[1]; echo "<br><font size=1>$date</font></div></div>";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"td\">";
echo "<div class=\"heading\">$parse[2]</div>";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td calss=\"td\">";
echo "<a href=\"?id=$parse[4]&ref="; echo $_SERVER["PHP_SELF"];
echo "\" class=\"morelink\">";
echo $cet_lang["more"];
echo "</a>\n";
echo "<hr class=\"hr\">";
echo "</td>\n";
}
if(isset($_GET["id"]))
{
if($_GET["id"] == $parse[4])
{
$content = $parse[3];
$newinfo = $parse[2];
echo "<tr>\n";
echo "<td class=\"td\">";
echo "<div class=\"title2\">"; echo $parse[1]; echo "<br><font size=1>$date</font></div></div>";
echo "</td>\n";
echo "<tr>\n";
echo "<td class=\"td\">";
echo "<div class=\"maintext\">$content</div>";
echo "<hr class=\"hr\">";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"td\">";
echo "<div><a href=\""; echo $_GET["ref"]; echo "?&search=articles\" class=\"returnlink\">";
echo $cet_lang["returnlinka"]; echo "</a></div>";
echo "</td>\n";
//May add more information for statistics...eg REMOTE_ADDR || REMOTE_HOST etc
//phpCET Hit counter v1.0 final - dow-clan.net
$hitfile = fopen($slice[1]."hits/hit.$parse[4].ctxt", "r+");
$hitstring = (file_get_contents($slice[1]."hits/hit.$parse[4].ctxt"));
$i = 0;
while(++$i)
{
$count = $hitstring + ++$i - 1; //Amazing
// how I figured this out..by myself
fwrite($hitfile, $count);
break;
}
fclose($hitfile);
}
}
}
}
echo "</tr>\n";
echo "</table>\n";
if($pcount > 0)
{
echo "<hr class=\"hr\">";
echo "<div align=\"center\">";
for ($i = 0; $i <= $pcount; $i++)
{
echo "<a href=\"?page=$i\" class=\"pagelinks\">page $i</a> ";
//this code above generated page 1, page 2, page 3 in
//accordance with the amount of articles however
//only a few articles where displayed and not the ones
//i needed (ie the first article from page 1 would show on
//all article listings page 2, page 3 etc...would all have
//article 1
}
echo "</div>";
echo "<hr class=\"hr\">";
}
echo "</td>";
echo "</tr>\n";
echo "</table>\n";
}
Continued....