[freenet-cvs] r12677 - trunk/website/includes

mathias at freenetproject.org mathias at freenetproject.org
Sat Apr 14 10:43:39 UTC 2007


Author: mathias
Date: 2007-04-14 10:43:39 +0000 (Sat, 14 Apr 2007)
New Revision: 12677

Added:
   trunk/website/includes/FCPlib.inc.php
   trunk/website/includes/common.inc.php~
   trunk/website/includes/fairshare.inc.php
   trunk/website/includes/fcp.inc.php
   trunk/website/includes/fcptools.inc.php
   trunk/website/includes/fec.inc.php
   trunk/website/includes/fphowto.inc.php
   trunk/website/includes/freeapps.inc.php
   trunk/website/includes/openjobs.inc.php
   trunk/website/includes/roadmap.inc.php
   trunk/website/includes/whatsnew.inc.php
Log:
Added references to some old stuff


Added: trunk/website/includes/FCPlib.inc.php
===================================================================
--- trunk/website/includes/FCPlib.inc.php	                        (rev 0)
+++ trunk/website/includes/FCPlib.inc.php	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,7 @@
+<?php
+
+$pages = array(
+
+'en' => 'pages/en/FCPlib.php')
+
+?>
\ No newline at end of file

Added: trunk/website/includes/common.inc.php~
===================================================================
--- trunk/website/includes/common.inc.php~	                        (rev 0)
+++ trunk/website/includes/common.inc.php~	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,139 @@
+<?php
+
+function setLanguage() {
+	global $lang;
+	
+	$lang = $_GET['lang'];
+	
+	if(!isset($lang)) 
+	{
+		$languages = split(",", $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
+		foreach ($languages as $language) {
+			$lang_array = split(";q=", trim( $language ) );
+       		$lang = trim( $lang_array[0] );
+       		if( !isset( $lang_array[1] ) )
+           		$q = 1;
+       		else
+           		$q = trim($lang_array[1]);
+       		$lang_q["$lang"] = (float)$q;
+		}
+		
+		arsort($lang_q);
+		$i = 0;
+		$lang_index = Array();
+   		foreach($lang_q as $lang => $q) {
+      		$lang_index[$i] = $lang; //add to a new array the index key/language
+      		$i++;
+   		}
+  
+	}
+	else
+	{
+   		$lang_q[$lang] = '1' ;
+   	}
+   
+   //return $lang_index; // uncomment for returning array with keys={0..n-1}, values={most..least preferred}
+    return $lang_q;
+		
+}
+
+function selectPage($lang_q, $page) {
+	
+	if (isset($page))
+	{
+		#echo "common - page exists ".dirname(__FILE__).'/'.$page.'.inc.php';
+		if (file_exists(dirname(__FILE__).'/'.$page.'.inc.php')) {
+			#echo "file exists";
+			include dirname(__FILE__).'/'.$page.'.inc.php';							// include file with  $pages-array
+			foreach ( $lang_q as $aLang => $relevance ) 							// loop through each language
+			{	
+				foreach ( $pages as $userlang => $path )        					// loop through each language-file
+				{
+					if ($aLang == $userlang) {										// if we have a match, set file-include to $path
+						$file = $path;
+						if (file_exists($_SERVER['DOCUMENT_ROOT'].$file)) 									// if file exists, break loop
+						{
+ 							break 2;
+ 						}
+					}
+				}
+				
+			}	
+			if (!isset($file))
+			{
+				$file = $pages['en']; //if no match, default to english
+			}		
+		}
+	}
+	return $file;
+
+}	
+
+function otherLanguages() {
+		
+	include dirname(__FILE__).'/languages.inc.php';	// Include language descriptions
+		
+	global $page;
+	
+	
+	if (isset($page))
+	{
+		if (file_exists(dirname(__FILE__).'/'.$page.'.inc.php')) 
+		{
+			include dirname(__FILE__).'/'.$page.'.inc.php';	
+					
+			$out .= '<div id="additionalLang">:: &nbsp;';
+			
+			foreach ( $pages as $userlang => $path ) 
+			{
+				foreach ( $languages as $abbr_lang_name => $full_lang_name ) 
+				{
+					if ($userlang == $abbr_lang_name) 
+					{
+					    $out .= '<a href="'.$abbr_lang_name.'/'.($page ? $page : "index").'.html">'.$full_lang_name.'</a>&nbsp; :: &nbsp;';
+					}
+				}
+			}
+			
+			$out .= '</div>';
+		}	
+	}		
+	return $out;
+	
+}
+	
+if (isset($_REQUEST["lang"])) 
+{
+	$lang_q = array( $_REQUEST["lang"] => '1' );
+	$lang = $_REQUEST["lang"];
+}
+else
+{
+	$lang_q = setLanguage();
+}
+
+if (isset($_REQUEST["page"])) {
+	$page = htmlentities($_REQUEST["page"]);	
+	$file = selectPage($lang_q, $page);		
+	if(!file_exists($file) )
+	{
+		header('HTTP/1.0 404 Not Found');
+		if(empty($_SERVER["HTTP_REFERER"]) || empty($_SERVER["REQUEST_URI"])){
+			header("Location: /");
+		}else{
+			echo "<html><head><title>404</title><head>";
+			echo "<body>404 error - broken link</body>";
+			$to="webmaster";
+			$subject="404 error";
+			$content="\nA 404 error has occurred on the website : may you fix it ?\nFrom :  ".$_SERVER["HTTP_REFERER"]."\nTo : ".$_SERVER["REQUEST_URI"]."\nAt : ".date("D M j Y g:i:s a T"."\nUser-agent : ".$_SERVER["HTTP_USER_AGENT"]);
+			@mail($to,$subject,$content,"svn-build");
+		}
+		die;
+	}
+} else {
+	$page = "index";
+	$lang_q = setLanguage();
+	$file = selectPage($lang_q, $page);
+}	
+	
+?>
\ No newline at end of file


Property changes on: trunk/website/includes/common.inc.php~
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/website/includes/fairshare.inc.php
===================================================================
--- trunk/website/includes/fairshare.inc.php	                        (rev 0)
+++ trunk/website/includes/fairshare.inc.php	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,7 @@
+<?php
+
+$pages = array(
+
+'en' => 'pages/en/fairshare.php')
+
+?>
\ No newline at end of file

Added: trunk/website/includes/fcp.inc.php
===================================================================
--- trunk/website/includes/fcp.inc.php	                        (rev 0)
+++ trunk/website/includes/fcp.inc.php	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,7 @@
+<?php
+
+$pages = array(
+
+'en' => 'pages/en/fcp.php')
+
+?>
\ No newline at end of file

Added: trunk/website/includes/fcptools.inc.php
===================================================================
--- trunk/website/includes/fcptools.inc.php	                        (rev 0)
+++ trunk/website/includes/fcptools.inc.php	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,7 @@
+<?php
+
+$pages = array(
+
+'en' => 'pages/en/fcptools.php')
+
+?>
\ No newline at end of file

Added: trunk/website/includes/fec.inc.php
===================================================================
--- trunk/website/includes/fec.inc.php	                        (rev 0)
+++ trunk/website/includes/fec.inc.php	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,7 @@
+<?php
+
+$pages = array(
+
+'en' => 'pages/en/fec.php')
+
+?>
\ No newline at end of file

Added: trunk/website/includes/fphowto.inc.php
===================================================================
--- trunk/website/includes/fphowto.inc.php	                        (rev 0)
+++ trunk/website/includes/fphowto.inc.php	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,7 @@
+<?php
+
+$pages = array(
+
+'en' => 'pages/en/fphowto.php')
+
+?>
\ No newline at end of file

Added: trunk/website/includes/freeapps.inc.php
===================================================================
--- trunk/website/includes/freeapps.inc.php	                        (rev 0)
+++ trunk/website/includes/freeapps.inc.php	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,7 @@
+<?php
+
+$pages = array(
+
+'en' => 'pages/en/freeapps.php')
+
+?>
\ No newline at end of file

Added: trunk/website/includes/openjobs.inc.php
===================================================================
--- trunk/website/includes/openjobs.inc.php	                        (rev 0)
+++ trunk/website/includes/openjobs.inc.php	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,7 @@
+<?php
+
+$pages = array(
+
+'en' => 'pages/en/openjobs.php')
+
+?>
\ No newline at end of file

Added: trunk/website/includes/roadmap.inc.php
===================================================================
--- trunk/website/includes/roadmap.inc.php	                        (rev 0)
+++ trunk/website/includes/roadmap.inc.php	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,7 @@
+<?php
+
+$pages = array(
+
+'en' => 'pages/en/roadmap.php')
+
+?>
\ No newline at end of file

Added: trunk/website/includes/whatsnew.inc.php
===================================================================
--- trunk/website/includes/whatsnew.inc.php	                        (rev 0)
+++ trunk/website/includes/whatsnew.inc.php	2007-04-14 10:43:39 UTC (rev 12677)
@@ -0,0 +1,7 @@
+<?php
+
+$pages = array(
+
+'en' => 'pages/en/whatsnew.php')
+
+?>
\ No newline at end of file




More information about the cvs mailing list