Forum Moderators: coopster
-max
------------------------------------------
<html>
<body>
<?
if (($file == "") OR (!file_exists($file.txt))) {
$file = 1;
}
echo "<html><body bgcolor=blue><h1 align=center>File $file</h1><hr><pre>";
include("$file.txt");
$next = $file+1;
$prev = $file-1;
echo "</pre><hr><p align=\"center\">";
if (file_exists($prev.txt)) { echo "<a href=\"index.php?file=$prev\"><font color=\"#ffffff\">PREVIOUS</font></a> ¦ ";
} else {
echo <font color=\"#c0c0c0\">Previous</font> ¦ "; }
if (file_exists($next.txt)) { echo "<a href=\"index.php?file=$next\"><font color=\"#ffffff\">NEXT</font></a>";
} else {
echo <font color=\"#c0c0c0\">NEXT</font>"; }
echo "</p></body></html>";
?>
</body>
</html>
-------------------------------------------
I named the file fubar.php. I know my ISP runs php. Are there any errors in the code itself?
thanks,
Max
<?
if (($file == "") OR (!file_exists("$file.txt"))) {
$file = 1;
}
echo "<html><body bgcolor=blue><h1 align=center>File $file</h1><hr><pre>";
include("$file.txt");
$next = $file+1;
$prev = $file-1;
echo "</pre><hr><p align=\"center\">";
if (file_exists("$prev.txt")) { echo "<a href=\"fubar.php?file=$prev\"><font color=\"#ffffff\">PREVIOUS</font></a> ¦ ";
} else {
echo "<font color=\"#c0c0c0\">Previous</font> ¦ "; }
if (file_exists("$next.txt")) { echo "<a href=\"fubar.php?file=$next\"><font color=\"#ffffff\">NEXT</font></a>";
} else {
echo "<font color=\"#c0c0c0\">NEXT</font>"; }
echo "</p></body></html>";
?>
you can add little tags like title or anything, but this should get you started let me know if u need any other modifications
-max
[edited by: jatar_k at 5:33 pm (utc) on Dec. 22, 2003]
[edit reason] no personal urls thanks [/edit]
Anyway, this is good stuff. Thanks WhosAWhata. What I would like to do is include page title and description in the textfile and explode them onto the html page in the title tag and description meta data areas. Would that be difficult?
[edited by: jatar_k at 5:34 pm (utc) on Dec. 22, 2003]
[edit reason] no personal urls thanks [/edit]
and then change the code to something like this, [1][edited by: WhosAWhata at 6:56 pm (utc) on Dec. 22, 2003]
<?
if (($file == "") OR (!file_exists("$file.txt"))) { $file = 1; }
$grab = "$file.txt"; $read = fopen("$grab", "r"); do {
$data = fread($read, 8192);
if (strlen($data) == 0) { break; }
$contents .= $data;
} while(true);
fclose ($read);
echo "<html><body bgcolor=blue><h1 align=center>";
if(ereg("<!--title(.*)endtitle-->", $contents, $out)){
echo $out;
} else { echo "File $file"; }
echo "</h1>"; error_reporting(0);
do { $data = fread($read, 8192);
if (strlen($data) == 0) { break; }
$contents .= $data;
} while(true);
fclose ($read);
if(ereg("<!--desc(.*)enddesc-->", $contents, $out)){ echo "<p align=center>"; echo $out[1]; echo"</p>"; }
echo "<hr><pre>";
include("$file.txt");
$next = $file+1;
$prev = $file-1;
echo "</pre><hr><p align=\"center\">";
if (file_exists("$prev.txt")) { echo "<a href=\"fubar.php?file=$prev\"><font color=\"#ffffff\">PREVIOUS</font></a> ¦ ";
} else {
echo "<font color=\"#c0c0c0\">Previous</font> ¦ "; }
if (file_exists("$next.txt")) { echo "<a href=\"fubar.php?file=$next\"><font color=\"#ffffff\">NEXT</font></a>";
} else {
echo "<font color=\"#c0c0c0\">NEXT</font>"; }
echo "</p></body></html>";
?>
-------------------------------------------------
<?php
$next = $file+1;
$prev = $file-1;
echo "</pre><p align=\"center\">";
if (file_exists("$prev.jpg")) { echo "<a href=\"index.php?file=$prev\">Previous</a> ¦ ";
} else {
echo "Previous ¦ "; }
if (file_exists("$next.jpg")) { echo "<a href=\"index.php?file=$next\">Next</a>";
} else {
echo "Next"; }
echo "</p></body></html>";
if (($file == "") OR (!file_exists("$file.jpg"))) {
$file = 1;
}
echo "<pre>";
include("$file.jpg");
?>
-------------------------------------------------
My objective was to put the links on top of the include function. Is there an error in the edited code that would explain why the page hangs up on 1.txt until "Next" is clicked a second time? BTW, thanks for all the help. I really appreciate it.
-max
--------------------------------------------------------
<?php
$next = $file+1;
$prev = $file-1;
echo "</pre><p align=\"center\">";
if (file_exists("$prev.txt")) { echo "<a href=\"index.php?file=$prev\">Previous</a> ¦ ";
} else {
echo "Previous ¦ "; }
if (file_exists("$next.txt")) { echo "<a href=\"index.php?file=$next\">Next</a>";
} else {
echo "Next"; }
echo "</p></body></html>";
if (($file == "") OR (!file_exists("$file.txt"))) {
$file = 1;
}
echo "<pre>";
include("$file.txt");
?>
<html>
<head></head>
<?php
$imgdir = "images/";
$imgend = ".jpg";
$next=$_SERVER['QUERY_STRING'];
if (($next >= 2) && (is_file($imgdir.$next.$imgend))) {
echo "<body class=\"type\"><p><< <a href=\"type.php?";
echo ($next-1);
echo "\">back</a> ¦¦ <a href=\"type.php?";
echo ($next+1);
echo "\" name=\"next\" id=\"next\">next</a> >></p><h1>Tales of the Typewriter</h1><img src=\"";
echo $imgdir.$next.$imgend;
echo"\" width=\"612\" alt=\"typed notes\" id=\"typeimg\" name=\"typeimg\" title=\"Notes typed by the audience at Grackle Mundy\" /></body></html>";
}
else {
echo
"<body class=\"type\">
<p><< <a href=\"../index.htm\">index</a> ¦¦ <a href=\"type.php?2\" name= \"next\" id=\"next\">next</a> >></p><h1>Tales of the Typewriter</h1>
<img src=\"images/1.jpg\" width=\"612\" alt=\"typed notes\" id=\"typeimg\" name=\"typeimg\" title=\"Notes typed by the audience at Grackle Mundy\" />
</body>
</html>";
}
?> Thanks,
Adam
if (($file == "") OR (!file_exists("$file.txt"))) {
$file = 1;
}
$next = $file+1;
$prev = $file-1;
the code should read
<?php
if (($file == "") OR (!file_exists("$file.txt"))) {
$file = 1;
}
$next = $file+1;
$prev = $file-1;
echo "</pre><p align=\"center\">";
if (file_exists("$prev.txt")) { echo "<a href=\"index.php?file=$prev\">Previous</a> ¦ ";
} else {
echo "Previous ¦ "; }
if (file_exists("$next.txt")) { echo "<a href=\"index.php?file=$next\">Next</a>";
} else {
echo "Next"; }
echo "</p></body></html>";
echo "<pre>";
include("$file.txt");
?>