[cvs-annodex] commit (/annodex): +phpannodex/trunk/phpsrc/mod_annodex.php

ctford nobody at lists.annodex.net
Wed Dec 21 14:47:12 EST 2005


Update of /annodex (new revision 1716)

Added files:
   phpannodex/trunk/phpsrc/mod_annodex.php

Log Message:
A CGI equivilent of mod_annodex. Only outputs headers for now.

Added: phpannodex/trunk/phpsrc/mod_annodex.php
===================================================================
--- phpannodex/trunk/phpsrc/mod_annodex.php	2005-12-20 22:44:30 UTC (rev 1715)
+++ phpannodex/trunk/phpsrc/mod_annodex.php	2005-12-21 03:47:11 UTC (rev 1716)
@@ -0,0 +1,41 @@
+<?php
+
+	const BUFFER_SIZE = 1024;
+	
+	/* Attempt to stop browsers caching the output of the script. */
+	header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
+	header("Expires: Mon, 29 Aug 1983 04:00:00 GMT"); // Date in the past
+
+	/* Break up the accept field of the request so we can parse it. */
+	$accept_array = explode(",",$_SERVER[HTTP_ACCEPT]);
+
+	/* If application/x-cmml is a higher priority than 
+	 * application/x-annodex then we want to output cmml. Otherwise we want
+	 * to output annodex.
+	 */
+	foreach( $accept_array as $key => $type ) {
+		$accept_array[$key] = explode(";",$type);
+		if( $accept_array[$key][1]=="text/x-cmml" ) {
+			output_cmml();
+			exit;
+		} else if ( $accept_array[$key][1]=="application/x-annodex" ) {
+			break;
+		}
+	}
+
+	/* If we get this far in the script it's because cmml is not preferred
+	 * over annodex.
+	 */
+	output_annodex();
+	exit;
+
+/* Output the requested .anx file as cmml. */
+function output_cmml() {
+	header('Content-Type: text/x-cmml');
+}
+
+/* Output the requested .anx file as proper annodex. */
+function output_annodex() {
+	header('Content-Type: application/x-annodex');
+}
+	


-- 
ctford



More information about the cvs-annodex mailing list