httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: conditional HTML
Date Sun, 11 Feb 1996 23:10:36 GMT
> Processing instructions are a little less ugly, but less well defined by 
> SGML.  Basically they are tags which begin with a ?, and it's left up to 
> the browser or spec to specify what to do with them.  I.e.
> <?IF cond="condition"> 
> <?ELSIF>
> <?ENDIF>

I have written a server-side html-embedded scripting language called
PHP/FI that is used by quite a few sites on the Net now.  I by no means
think it should become any sort of standard, but I do think it serves
as a good example of what can be done with such a language.  

I went back and forth on the question of what to use as the initiator
tag as well.  I ended up going with the SGML PI tag, even though most
browsers have no clue what to do with them if they do manage to slip
through unparsed.  Here is some example code which displays a list of
files in a table.  The actual file information is read right out of
a directory with opendir() and readdir() calls in a while loop.  
A regular expression match is done on the filenames to figure out if
they are valid (.gz or .zip) and an appropriate icon is used to
represent the file.  Then at the bottom an RFC-1867 File Upload form
is presented and users who know the upload password may go ahead
and upload files directly to the upload directory.  More information
on PHP/FI can be found at if you are interested.
The site is currently being completely re-written and moved to, so you may want to check there as well.  The
actual file upload page is only on

	$file_dir = "files";
	$entry = readdir();
		$dir[$i] = $entry;
			$type[$i] = 1;
			$type[$i] = 2;
		$entry = readdir();
	$num = $i>
	<center><table border=2>
	<?if($num==0); echo "<caption>No Files!</caption><p>";
	elseif($num==1); echo "<caption>1 File</caption><p>";
	else; echo "<caption>$num Files</caption><p>"; endif>
	while($num && $i < $num);
		if($type[$i] == 1)>
			<tr><td align=center>
			<img src="/php/gifs/filegz.gif" hspace=2></td>
		<?elseif($type[$i] == 2)>
			<tr><td align=center>
			<img src="/php/gifs/filezip.gif"></td>
		<td align=center>
		<?echo "<a href=\"/php/files/$dir[$i]\">$dir[$i]</a></td>";
		echo "<th>";
		echo fileSize("$file_dir/$dir[$i]");
		echo "</th><th>";
		echo Date("M d/y H:i:s",fileMtime("$file_dir/$dir[$i]"));
		echo "</th>";
		$fp = @fopen("$file_dir/$dir[$i].info","r");
		echo "<td align=left>";
		if($fp != -1);
			$line = fgets($fp,100);
				echo $line;
				$line = fgets($fp,100);
			echo "none";
		echo "</td></tr>";
	echo "</table></center>">
	<form action="/php/receive.phtml" 
		enctype="multipart/form-data" method=POST>
	Upload password: <input type="password" name="pw"><br>
	<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
	Filename: <input type="file" name="filename"><br>
	<textarea name="description" rows=3 cols=30></textarea><br>
	<input type="submit" value=" Send File ">

View raw message