r1072 - webspace/include

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Apr 29 02:05:52 EDT 2007


Author: floam
Date: 2007-04-29 02:05:51 -0400 (Sun, 29 Apr 2007)
New Revision: 1072

Added:
   webspace/include/models.php
Modified:
   webspace/include/thebrain.php
Log:
Maybe this will work!


Added: webspace/include/models.php
===================================================================
--- webspace/include/models.php	                        (rev 0)
+++ webspace/include/models.php	2007-04-29 06:05:51 UTC (rev 1072)
@@ -0,0 +1,21 @@
+<table>
+   <h2>Quake3 Models</h2>
+   <p>Here are some files for you to look at! Zakk will add more!</p>
+<?php
+$output = '<tr>
+<td class=\"leftmost block\"><a href=\"/$dir$file[name]\">$file[name]</a></td>
+<td>$file[date]</td>
+<td>$file[size]</td>
+<td class=\"rightmost\">$file[picturefriend]</td>
+</tr>';
+
+echo "<tr>
+   <th class=\"leftmost block\">Name</th>
+   <th>Date</th>
+   <th>Size</th>
+   <th class=\"rightmost\">Picture</th>
+   </tr>";
+
+directoryindex("files/models2/", $output);
+?>
+</table>
\ No newline at end of file

Modified: webspace/include/thebrain.php
===================================================================
--- webspace/include/thebrain.php	2007-04-25 22:24:55 UTC (rev 1071)
+++ webspace/include/thebrain.php	2007-04-29 06:05:51 UTC (rev 1072)
@@ -15,7 +15,8 @@
 else
 	$ua = false;
 
-if (strpos($_SERVER['HTTP_HOST'], "icculus.org") !== FALSE) {
+if (strpos($_SERVER['HTTP_HOST'], "icculus.org") !== FALSE)
+{
 	header("HTTP/1.1 301 Moved Permanently");
 	header("Location: http://ioquake3.org" . str_replace("quake3/", '', $_SERVER["REQUEST_URI"]));
 }
@@ -44,11 +45,14 @@
 
 header("Content-type: $content_type; charset=UTF-8");
 
-function include_safe($file) {
-	if (file_exists("include/$file")) {
+function include_safe($file)
+{
+	if (file_exists("include/$file"))
+	{
 		include($file);
 	}
-	else {
+	else
+	{
 		$code = 404;
 		require("errors.php");
 	}
@@ -93,4 +97,49 @@
 	$page = "home";
 else
 	$page = $_GET['page'];
+	
+function humansize($bytes)
+{
+	$types =  Array("Bytes", "Kilobytes", "Megabytes", "Gigabytes", "Terabytes");
+	$current = 0;
+	while ($bytes > 1024)
+	{
+		$current++;
+		$bytes /= 1024;
+	}
+	return round($bytes,0)." ".$types[$current];
+}
+
+function directoryindex($dir, $format)
+{
+	if ($handle = opendir($dir))
+	{
+   	while (false !== ($file = readdir($handle)))
+   	{ 
+   		if ($file != "." && $file != ".." && !is_dir("$dir$file") && !strstr($file, ".jpg"))
+   		{
+   			$file_size = humansize(filesize("$dir$file"));
+   			$file_unix_date = filemtime("$dir$file");
+   			$file_date = date("F j, Y",$file_unix_date);
+   			$jpgfile = basename($file, ".zip") . ".jpg";
+   			if (file_exists($dir . $jpgfile))
+   			   $fileimg = "<a href=\"$jpgfile\">Image</a>";
+   			else
+			      $fileimg ="N/A";
+   			$index[$file_unix_date] = array(
+   			 "name" => $file,
+   			 "size" => $file_size,
+   			 "date" => $file_date,
+   			 "picturefriend" => $fileimg,
+   			);
+   		}
+   	}
+   	closedir($handle);
+	}
+	krsort($index);
+	foreach($index as $file)
+	{
+		echo eval('return "' . $format . '";');
+	}
+}
 ?>




More information about the quake3-commits mailing list