Initial import GameCrash_Original
authorAndreas Grabmüller <webmaster@letzplay.de>
Fri, 7 Nov 2003 23:24:42 +0000 (23:24 +0000)
committerAndreas Grabmüller <webmaster@letzplay.de>
Fri, 7 Nov 2003 23:24:42 +0000 (23:24 +0000)
git-svn-id: file:///Users/dpage/pgweb/svn-repo/trunk@150 8f5c7a92-453e-0410-a47f-ad33c8a6b003

93 files changed:
portal/.htaccess [new file with mode: 0644]
portal/admin/events.php [new file with mode: 0644]
portal/admin/globals.php [new file with mode: 0644]
portal/admin/import.php [new file with mode: 0644]
portal/admin/index.php [new file with mode: 0644]
portal/admin/news.php [new file with mode: 0644]
portal/admin/pages.php [new file with mode: 0644]
portal/admin/templates.php [new file with mode: 0644]
portal/cache/index.htm [new file with mode: 0644]
portal/layout/css/postgresql.css [new file with mode: 0644]
portal/layout/css/postgresql_admin.css [new file with mode: 0644]
portal/layout/images/banner-background.jpg [new file with mode: 0644]
portal/layout/images/banner-left.jpg [new file with mode: 0644]
portal/layout/images/banner-right.jpg [new file with mode: 0644]
portal/layout/images/flags/Argentina.gif [new file with mode: 0644]
portal/layout/images/flags/Australia.gif [new file with mode: 0644]
portal/layout/images/flags/Austria.gif [new file with mode: 0644]
portal/layout/images/flags/Belgium.gif [new file with mode: 0644]
portal/layout/images/flags/Belguim.gif [new file with mode: 0644]
portal/layout/images/flags/BosniaandHerzegovina.gif [new file with mode: 0644]
portal/layout/images/flags/Brazil.gif [new file with mode: 0644]
portal/layout/images/flags/Bulgaria.gif [new file with mode: 0644]
portal/layout/images/flags/Canada.gif [new file with mode: 0644]
portal/layout/images/flags/Chile.gif [new file with mode: 0644]
portal/layout/images/flags/China.gif [new file with mode: 0644]
portal/layout/images/flags/Colombia.gif [new file with mode: 0644]
portal/layout/images/flags/CostaRica.gif [new file with mode: 0644]
portal/layout/images/flags/Czech-republic.gif [new file with mode: 0644]
portal/layout/images/flags/CzechRepublic.gif [new file with mode: 0644]
portal/layout/images/flags/Denmark.gif [new file with mode: 0644]
portal/layout/images/flags/Estonia.gif [new file with mode: 0644]
portal/layout/images/flags/Finland.gif [new file with mode: 0644]
portal/layout/images/flags/France.gif [new file with mode: 0644]
portal/layout/images/flags/Germany.gif [new file with mode: 0644]
portal/layout/images/flags/Greece.gif [new file with mode: 0644]
portal/layout/images/flags/HongKong.gif [new file with mode: 0644]
portal/layout/images/flags/Hungary.gif [new file with mode: 0644]
portal/layout/images/flags/Iceland.gif [new file with mode: 0644]
portal/layout/images/flags/India.gif [new file with mode: 0644]
portal/layout/images/flags/Indonesia.gif [new file with mode: 0644]
portal/layout/images/flags/Ireland.gif [new file with mode: 0644]
portal/layout/images/flags/Israel.gif [new file with mode: 0644]
portal/layout/images/flags/Italy.gif [new file with mode: 0644]
portal/layout/images/flags/Japan.gif [new file with mode: 0644]
portal/layout/images/flags/Korea.gif [new file with mode: 0644]
portal/layout/images/flags/Latvia.gif [new file with mode: 0644]
portal/layout/images/flags/Mexico.gif [new file with mode: 0644]
portal/layout/images/flags/Netherlands.gif [new file with mode: 0644]
portal/layout/images/flags/New Zealand.gif [new file with mode: 0644]
portal/layout/images/flags/NewZealand.gif [new file with mode: 0644]
portal/layout/images/flags/Norway.gif [new file with mode: 0644]
portal/layout/images/flags/Philippines.gif [new file with mode: 0644]
portal/layout/images/flags/Poland.gif [new file with mode: 0644]
portal/layout/images/flags/Portugal.gif [new file with mode: 0644]
portal/layout/images/flags/Romania.gif [new file with mode: 0644]
portal/layout/images/flags/Russia.gif [new file with mode: 0644]
portal/layout/images/flags/Singapore.gif [new file with mode: 0644]
portal/layout/images/flags/SlovakRepublic.gif [new file with mode: 0644]
portal/layout/images/flags/South-africa1.gif [new file with mode: 0644]
portal/layout/images/flags/South-korea.gif [new file with mode: 0644]
portal/layout/images/flags/SouthAfrica.gif [new file with mode: 0644]
portal/layout/images/flags/Spain.gif [new file with mode: 0644]
portal/layout/images/flags/Sweden.gif [new file with mode: 0644]
portal/layout/images/flags/Switzerland.gif [new file with mode: 0644]
portal/layout/images/flags/Taiwan.gif [new file with mode: 0644]
portal/layout/images/flags/Thailand.gif [new file with mode: 0644]
portal/layout/images/flags/Turkey.gif [new file with mode: 0644]
portal/layout/images/flags/UK.gif [new file with mode: 0644]
portal/layout/images/flags/USA.gif [new file with mode: 0644]
portal/layout/images/flags/Ukraine.gif [new file with mode: 0644]
portal/layout/images/lngflags/de.gif [new file with mode: 0644]
portal/layout/images/lngflags/de_disabled.gif [new file with mode: 0644]
portal/layout/images/lngflags/en.gif [new file with mode: 0644]
portal/layout/images/lngflags/en_disabled.gif [new file with mode: 0644]
portal/system/docs.php [new file with mode: 0644]
portal/system/global/functions.database.php [new file with mode: 0644]
portal/system/global/functions.language.php [new file with mode: 0644]
portal/system/global/functions.layout.php [new file with mode: 0644]
portal/system/global/functions.php [new file with mode: 0644]
portal/system/global/languages.php [new file with mode: 0644]
portal/system/global/settings.php [new file with mode: 0644]
portal/system/handleform.php [new file with mode: 0644]
portal/system/handler.php [new file with mode: 0644]
portal/system/languages/de.php [new file with mode: 0644]
portal/system/languages/en.php [new file with mode: 0644]
portal/system/layout/basic.bottom.php [new file with mode: 0644]
portal/system/layout/basic.left.php [new file with mode: 0644]
portal/system/layout/basic.right.php [new file with mode: 0644]
portal/system/layout/basic.top.php [new file with mode: 0644]
portal/system/layout/docs.left.php [new file with mode: 0644]
portal/system/layout/docs.right.php [new file with mode: 0644]
portal/system/page.php [new file with mode: 0644]
portal/tools/rebuildcache [new file with mode: 0644]

diff --git a/portal/.htaccess b/portal/.htaccess
new file mode 100644 (file)
index 0000000..b48612d
--- /dev/null
@@ -0,0 +1,18 @@
+# Fire up mod_rewrite
+RewriteEngine ON
+
+# Check if the page is already cached
+# Use this and exit
+RewriteCond %{DOCUMENT_ROOT}/cache%{REQUEST_URI} -f
+RewriteRule ^(.*)$ cache/$1 [L]
+
+# Rewrite every request except those for
+# static files to system/handler.php
+RewriteCond %{REQUEST_URI} !^/cache/.*
+RewriteCond %{REQUEST_URI} !^/admin/.*
+RewriteCond %{REQUEST_URI} !^/layout/.*
+RewriteCond %{REQUEST_URI} !^/files/.*
+RewriteCond %{REQUEST_URI} !^/system/handler.php$
+RewriteCond %{REQUEST_URI} !^/system/handleform.php$
+RewriteCond %{REQUEST_URI} !^/search.cgi$
+RewriteRule ^(.*)$ system/handler.php
\ No newline at end of file
diff --git a/portal/admin/events.php b/portal/admin/events.php
new file mode 100644 (file)
index 0000000..c279861
--- /dev/null
@@ -0,0 +1,175 @@
+<?php
+
+require "globals.php";
+
+CreateHeader("Events");
+
+// Get all possible languages
+require('../system/global/languages.php');
+
+// Check for actions
+if ($_REQUEST['action'] == "delete" && intval($_REQUEST['id']) > 0) {
+  echo "<p>You want to delete Event ID $_REQUEST[id]. Are you sure?<p>";
+  echo '<p><form action="events.php" method="POST"><input type="hidden" name="action" value="dodelete"><input type="hidden" name="id" value="'.$_REQUEST['id'].'"><input type="submit" value="Delete now"></form></p>';
+  exit;
+}
+
+if ($_POST['action'] == "dodelete" && intval($_POST['id']) > 0) {
+  pg_query($db, "DELETE FROM events WHERE id=".intval($_POST['id']));
+}
+
+if ($_REQUEST['action'] == "edit" && intval($_REQUEST['id']) > 0) {
+  $rs = pg_query($db, "SELECT * FROM events WHERE id=".$_REQUEST['id']);
+  $event = pg_fetch_array($rs);
+  echo '<form action="events.php" method="POST">';
+  echo '<center><p><table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#000000">';
+  echo '<table border="0" cellpadding="2" cellspacing="1">';
+  echo '<tr><td bgcolor="#FFFFFF">Event id</td><td bgcolor="#FFFFFF">'.$event['id'].'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Posted by</td><td bgcolor="#FFFFFF"><input type="text" size="25" name="posted_by" value="'.$event['posted_by'].'"></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Start date</td><td bgcolor="#FFFFFF"><input type="text" size="25" name="start_date" value="'.$event['start_date'].'"></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">End date</td><td bgcolor="#FFFFFF"><input type="text" size="25" name="end_date" value="'.$event['end_date'].'"></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Active</td><td bgcolor="#FFFFFF"><select name="active"><option value="Yes"'.iif($event['active']=='t',' selected').'>Yes</option><option value="No"'.iif($event['active']!='t',' selected').'>No</option></select></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Approved</td><td bgcolor="#FFFFFF"><select name="approved"><option value="Yes"'.iif($event['approved']=='t',' selected').'>Yes</option><option value="No"'.iif($event['approved']!='t',' selected').'>No</option></select></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2" align="center"><input type="submit" value="Update"> <input type="reset" value="Reset"></td></tr>';
+  echo '</td></tr></table>';
+  echo '</table></p></center>';
+  echo '<input type="hidden" name="action" value="doedit"><input type="hidden" name="id" value="'.$_REQUEST['id'].'"></form>';
+  exit;
+}
+
+if ($_POST['action'] == "doedit" && intval($_POST['id']) > 0) {
+  pg_query($db, "UPDATE events SET posted_by='$_POST[posted_by]', start_date='$_POST[start_date]', end_date='$_POST[end_date]', active='$_POST[active]', approved='$_POST[approved]' WHERE id=".intval($_POST['id']));
+}
+
+if ($_REQUEST['action'] == "translate" && intval($_REQUEST['id']) > 0 && isset($_LANGUAGES["$_REQUEST[language]"])) {
+  $rs = pg_query($db, "SELECT event,summary,details FROM events_text WHERE eventid=$_REQUEST[id] AND language='en'");
+  $originalevent = pg_fetch_array($rs);
+  $rs = pg_query($db, "SELECT event,summary,details FROM events_text WHERE eventid=$_REQUEST[id] AND language='$_REQUEST[language]'");
+  if (pg_num_rows($rs) == 0) {
+    $event = "";
+       $summary = "";
+       $details = "";
+  } else {
+    $eventarray = pg_fetch_array($rs);
+       $event = $eventarray['event'];
+       $summary = $eventarray['summary'];
+       $details = $eventarray['details'];
+  }
+  echo '<form action="events.php" method="POST">';
+  echo '<center><p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td bgcolor="#000000">';
+  echo '<table border="0" cellpadding="2" cellspacing="1" width="100%">';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2"><b>Event</b></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">English</td><td bgcolor="#FFFFFF">'.nl2br(htmlspecialchars($originalevent['event'])).'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">'.$_LANGUAGES["$_REQUEST[language]"].'</td><td bgcolor="#FFFFFF"><input type="text" name="event" value="'.htmlspecialchars($event).'" size="50" style="width:100%"></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2"><b>Summary</b></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">English</td><td bgcolor="#FFFFFF">'.nl2br(htmlspecialchars($originalevent['summary'])).'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">'.$_LANGUAGES["$_REQUEST[language]"].'</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="summary" cols="80" rows="4" style="width:100%">'.htmlspecialchars($summary).'</textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2"><b>Details</b></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">English</td><td bgcolor="#FFFFFF">'.nl2br(htmlspecialchars($originalevent['details'])).'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">'.$_LANGUAGES["$_REQUEST[language]"].'</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="details" cols="80" rows="4" style="width:100%">'.htmlspecialchars($details).'</textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2" align="center"><input type="submit" value="Update"> <input type="reset" value="Reset"></td></tr>';
+  echo '</td></tr></table>';
+  echo '</table></p></center>';
+  echo '<input type="hidden" name="action" value="dotranslate"><input type="hidden" name="id" value="'.$_REQUEST['id'].'"><input type="hidden" name="language" value="'.$_REQUEST['language'].'"></form>';
+  exit;
+}
+
+if ($_POST['action'] == "dotranslate" && intval($_POST['id']) > 0) {
+  pg_query($db, "DELETE FROM events_text WHERE eventid=$_POST[id] AND language='$_POST[language]'");
+  $eventid = intval($_POST['id']);
+  $event = trim($_POST['event']);
+  $summary = trim($_POST['summary']);
+  $details = trim($_POST['details']);
+  if ($event != "" && $summary != "") {
+    pg_query($db, "INSERT INTO events_text (eventid,language,event,summary,details) VALUES ($eventid,'$_POST[language]','$event','$summary','$details')");
+  }
+}
+
+if ($_REQUEST['action'] == "add") {
+  echo '<form action="events.php" method="POST">';
+  echo '<center><p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td bgcolor="#000000">';
+  echo '<table border="0" cellpadding="2" cellspacing="1" width="100%">';
+  echo '<tr><td bgcolor="#FFFFFF">Posted by</td><td bgcolor="#FFFFFF"><input type="text" size="25" name="posted_by" value=""></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Start date</td><td bgcolor="#FFFFFF"><input type="text" size="25" name="start_date" value=""></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">End date</td><td bgcolor="#FFFFFF"><input type="text" size="25" name="end_date" value=""></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Active</td><td bgcolor="#FFFFFF"><select name="active"><option value="Yes">Yes</option><option value="No" selected>No</option></select></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Approved</td><td bgcolor="#FFFFFF"><select name="approved"><option value="Yes">Yes</option><option value="No" selected>No</option></select></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Event</td><td bgcolor="#FFFFFF"><input type="text" name="event" value="" size="50" style="width:100%"></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Summary</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="summary" cols="80" rows="4" style="width:100%"></textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Details</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="details" cols="80" rows="10" style="width:100%"></textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2" align="center"><input type="submit" value="Add news"> <input type="reset" value="Reset"></td></tr>';
+  echo '</td></tr></table>';
+  echo '</table></p></center>';
+  echo '<input type="hidden" name="action" value="doadd"></form>';
+  exit;
+}
+
+if ($_POST['action'] == "doadd") {
+  $event = trim($_POST['event']);
+  $summary = trim($_POST['summary']);
+  $details = trim($_POST['details']);
+  $rs = pg_query($db, "SELECT nextval('events_id_seq') AS newid;");
+  $newid = pg_result($rs, 0, "newid");
+  pg_query($db, "INSERT INTO events (id, posted_by, start_date, end_date, active, approved) VALUES ($newid, '$_POST[posted_by]', '$_POST[start_date]', '$_POST[end_date]', '$_POST[active]', '$_POST[approved]')");
+  pg_query($db, "INSERT INTO events_text (eventid,event,summary,details,language) VALUES ($newid,'$event','$summary','$details','en')");
+}
+
+?>
+
+<p><a href="events.php?action=add">Add event</a></p>
+
+<p><center>
+<table border="0" cellspacing="0" cellpadding="0" width="100%">
+  <tr>
+    <td bgcolor="#000000">
+         <table border="0" cellspacing="1" cellpadding="2" width="100%">
+           <tr>
+          <th bgcolor="#FFFFFF">ID</th>
+          <th bgcolor="#FFFFFF">Posted</th>
+          <th bgcolor="#FFFFFF">Event</th>
+          <th bgcolor="#FFFFFF">Active</th>
+          <th bgcolor="#FFFFFF">Approved</th>
+          <th bgcolor="#FFFFFF">Translate</th>
+          <th bgcolor="#FFFFFF" colspan="2">Options</th>
+        </tr>
+
+<?php
+
+  $nl = "\n";
+  $rs = pg_query($db, "SELECT n.id, n.posted, t.event, n.active, n.approved FROM events n LEFT OUTER JOIN events_text t ON (t.language='en' AND n.id=t.eventid) ORDER BY n.id DESC");
+  while($row = pg_fetch_array($rs)){
+       $translated = array();
+       $translatelinks = '';
+       $translations = pg_query($db, "SELECT language FROM events_text WHERE eventid=$row[id]");
+       while($translation = pg_fetch_array($translations)) {
+         $translated["$translation[language]"] = true;
+       }
+       reset($_LANGUAGES);
+       while(list($key,$val) = each($_LANGUAGES)){
+         $translatelinks .= '<a href="events.php?action=translate&id='.$row['id'].'&language='.$key.'"><img src="/layout/images/lngflags/'.$key.iif(!$translated[$key],'_disabled').'.gif" alt="'.$val.'" border="0"></a> ';
+       }
+       echo '        <tr>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.$row['id'].'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.$row['posted'].'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.$row['event'].'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.iif($row['active']=='t','Yes','No').'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.iif($row['approved']=='t','Yes','No').'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF" align="center">'.trim($translatelinks).'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF" align="center"><a href="events.php?action=edit&id='.$row['id'].'">Edit</a></td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF" align="center"><a href="events.php?action=delete&id='.$row['id'].'">Delete</a></td>'.$nl;
+       echo '        </tr>'.$nl;
+  } // while
+
+?>
+
+         </table>
+       </td>
+  </tr>
+</table>
+</center></p>
+
+<?php
+
+CreateFooter();
+
+?>
\ No newline at end of file
diff --git a/portal/admin/globals.php b/portal/admin/globals.php
new file mode 100644 (file)
index 0000000..7739db6
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+require "../system/global/settings.php";
+
+// Connect to the portal database
+if (!$db = pg_connect($_SETTINGS['db_portal'])) {
+  echo "Can't connect to the Portal database.";
+  exit;
+}
+
+// Some layout functions
+function CreateHeader($title="Administration") {
+  echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>PostgreSQL.org Administration: '.$title.'</title>
+<link rel="stylesheet" href="/layout/css/postgresql_admin.css" type="text/css">
+</head>
+<body>
+<p><center><h2>'.$title.'</h2></center></p>
+';
+}
+
+function CreateFooter() {
+  echo '
+</body>
+</html>';
+}
+
+function iif($expression,$yes,$no="") {
+  if ($expression) {
+    return $yes;
+  } else {
+    return $no;
+  }
+}
+
+?>
diff --git a/portal/admin/import.php b/portal/admin/import.php
new file mode 100644 (file)
index 0000000..104bbbc
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+function logaction($text) {
+       echo "<li>$text...</li>";
+}
+
+require "globals.php";
+
+CreateHeader("Import the english PostgreSQL.org data");
+
+echo '<p>Importing data...</p>';
+
+echo '<p><ul>';
+
+logaction('Dropping english news');
+pg_query($db, "DELETE FROM news_text WHERE language='en'");
+
+logaction('Inserting english news');
+pg_query($db, "INSERT INTO news_text (newsid, language, headline, summary, story) SELECT id, 'en', headline, summary, story FROM news");
+
+logaction('Dropping english events');
+pg_query($db, "DELETE FROM events_text WHERE language='en'");
+
+logaction('Inserting english events');
+pg_query($db, "INSERT INTO events_text (eventid, language, event, summary, details) SELECT id, 'en', event, summary, details FROM events");
+
+logaction('Dropping english polls');
+pg_query($db, "DELETE FROM survey_questions WHERE language='en'");
+
+logaction('Inserting english polls');
+pg_query($db, "INSERT INTO survey_questions (surveyid, language, question, opt1, opt2, opt3, opt4, opt5, opt6, opt7, opt8) SELECT id, 'en', question, opt1, opt2, opt3, opt4, opt5, opt6, opt7, opt8 FROM surveys");
+
+logaction('Dropping english documentation');
+pg_query($db, "DELETE FROM documentation WHERE language='en'");
+
+logaction('Inserting english documentation');
+pg_query($db, "INSERT INTO documentation (id, language, file, version, title, content, dirty) SELECT id, 'en', file, version, title, content, dirty FROM docs");
+
+echo '</ul></p>';
+
+echo '<p>done.</p>';
+
+CreateFooter();
+
+?>
\ No newline at end of file
diff --git a/portal/admin/index.php b/portal/admin/index.php
new file mode 100644 (file)
index 0000000..30e7b1c
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+if ($_REQUEST['open'] == "topframe") {
+  echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>PostgreSQL.org Administration</title>
+<link rel="stylesheet" href="/layout/css/postgresql_admin.css" type="text/css">
+</head>
+<body class="nav">
+  <table border="0" cellspacing="0" cellpadding="5" width="100%">
+    <tr>
+         <td align="left"><a href="news.php" target="Content" style="font-weight: bold; color: #020169"><font size=-1>News</font></a> &nbsp;| &nbsp;<a href="events.php" target="Content" style="font-weight: bold; color: #020169"><font size=-1>Events</font></a> &nbsp;| &nbsp;<a href="pages.php" target="Content" style="font-weight: bold; color: #020169"><font size=-1>Static pages</font></a> &nbsp;| &nbsp;<a href="templates.php" target="Content" style="font-weight: bold; color: #020169"><font size=-1>Templates</font></a> &nbsp;| &nbsp;<a href="import.php" target="Content" style="font-weight: bold; color: #020169"><font size=-1>Import data (temp)</font></a></td>
+         <td align="right"><a href="index.php?open=phpinfo" target="Content" style="font-weight: bold; color: #020169"><font size=-1>phpinfo()</font></a> &nbsp;| &nbsp;<a href="/admin/phpPgAdmin/" target="Content" style="font-weight: bold; color: #020169"><font size=-1>phpPgAdmin</font></a> &nbsp;| &nbsp;<a href="/stats/" target="Content" style="font-weight: bold; color: #020169"><font size=-1>Stats</font></a> &nbsp;| &nbsp;<a href="/" target="_top" style="font-weight: bold; color: #020169"><font size=-1>PostgreSQL.org</font></a></td>
+       </tr>
+  </table>
+</body>
+</html>';
+} elseif ($_REQUEST['open'] == "phpinfo") {
+  phpinfo();
+} elseif ($_REQUEST['open'] == "index") {
+  echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>PostgreSQL.org Administration</title>
+<link rel="stylesheet" href="/layout/css/postgresql_admin.css" type="text/css">
+</head>
+<body>
+<p>Welcome to the new PostgreSQL Administration area.</p>
+<p>Please choose one option on the top.</p>
+</body>
+</html>';
+} else {
+  echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
+<html>
+<head>
+<title>PostgreSQL.org Administration</title>
+</head>
+<frameset rows="30,*">
+  <frame src="index.php?open=topframe" name="Navigation" noresize frameborder="0" scrolling="no">
+  <frame src="index.php?open=index" name="Content" noresize frameborder="0">
+  <noframes>
+    <p>Sorry, your browser does not accept frames. Please go here to administrate the website:</p>
+       <p><a href="news.php">News</a><br>
+       <a href="events.php">Events</a></p>
+  </noframes>
+</frameset>
+</html>';
+}
+
+?>
\ No newline at end of file
diff --git a/portal/admin/news.php b/portal/admin/news.php
new file mode 100644 (file)
index 0000000..463526b
--- /dev/null
@@ -0,0 +1,171 @@
+<?php
+
+require "globals.php";
+
+CreateHeader("News");
+
+// Get all possible languages
+require('../system/global/languages.php');
+
+// Check for actions
+if ($_REQUEST['action'] == "delete" && intval($_REQUEST['id']) > 0) {
+  echo "<p>You want to delete News ID $_REQUEST[id]. Are you sure?<p>";
+  echo '<p><form action="news.php" method="POST"><input type="hidden" name="action" value="dodelete"><input type="hidden" name="id" value="'.$_REQUEST['id'].'"><input type="submit" value="Delete now"></form></p>';
+  exit;
+}
+
+if ($_POST['action'] == "dodelete" && intval($_POST['id']) > 0) {
+  pg_query($db, "DELETE FROM news WHERE id=".intval($_POST['id']));
+}
+
+if ($_REQUEST['action'] == "edit" && intval($_REQUEST['id']) > 0) {
+  $rs = pg_query($db, "SELECT * FROM news WHERE id=".$_REQUEST['id']);
+  $news = pg_fetch_array($rs);
+  echo '<form action="news.php" method="POST">';
+  echo '<center><p><table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#000000">';
+  echo '<table border="0" cellpadding="2" cellspacing="1">';
+  echo '<tr><td bgcolor="#FFFFFF">News id</td><td bgcolor="#FFFFFF">'.$news['id'].'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Posted by</td><td bgcolor="#FFFFFF"><input type="text" size="25" name="posted_by" value="'.$news['posted_by'].'"></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Active</td><td bgcolor="#FFFFFF"><select name="active"><option value="Yes"'.iif($news['active']=='t',' selected').'>Yes</option><option value="No"'.iif($news['active']!='t',' selected').'>No</option></select></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Approved</td><td bgcolor="#FFFFFF"><select name="approved"><option value="Yes"'.iif($news['approved']=='t',' selected').'>Yes</option><option value="No"'.iif($news['approved']!='t',' selected').'>No</option></select></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2" align="center"><input type="submit" value="Update"> <input type="reset" value="Reset"></td></tr>';
+  echo '</td></tr></table>';
+  echo '</table></p></center>';
+  echo '<input type="hidden" name="action" value="doedit"><input type="hidden" name="id" value="'.$_REQUEST['id'].'"></form>';
+  exit;
+}
+
+if ($_POST['action'] == "doedit" && intval($_POST['id']) > 0) {
+  pg_query($db, "UPDATE news SET posted_by='".$_POST[posted_by]."', active='$_POST[active]', approved='$_POST[approved]' WHERE id=".intval($_POST['id']));
+}
+
+if ($_REQUEST['action'] == "translate" && intval($_REQUEST['id']) > 0 && isset($_LANGUAGES["$_REQUEST[language]"])) {
+  $rs = pg_query($db, "SELECT headline,summary,story FROM news_text WHERE newsid=$_REQUEST[id] AND language='en'");
+  $originalnews = pg_fetch_array($rs);
+  $rs = pg_query($db, "SELECT headline,summary,story FROM news_text WHERE newsid=$_REQUEST[id] AND language='$_REQUEST[language]'");
+  if (pg_num_rows($rs) == 0) {
+    $headline = "";
+       $summary = "";
+       $story = "";
+  } else {
+    $news = pg_fetch_array($rs);
+       $headline = $news['headline'];
+       $summary = $news['summary'];
+       $story = $news['story'];
+  }
+  echo '<form action="news.php" method="POST">';
+  echo '<center><p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td bgcolor="#000000">';
+  echo '<table border="0" cellpadding="2" cellspacing="1" width="100%">';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2"><b>Headline</b></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">English</td><td bgcolor="#FFFFFF">'.nl2br(htmlspecialchars($originalnews['headline'])).'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">'.$_LANGUAGES["$_REQUEST[language]"].'</td><td bgcolor="#FFFFFF"><input type="text" name="headline" value="'.htmlspecialchars($headline).'" size="50" style="width:100%"></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2"><b>Summary</b></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">English</td><td bgcolor="#FFFFFF">'.nl2br(htmlspecialchars($originalnews['summary'])).'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">'.$_LANGUAGES["$_REQUEST[language]"].'</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="summary" cols="80" rows="4" style="width:100%">'.htmlspecialchars($summary).'</textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2"><b>Story</b></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">English</td><td bgcolor="#FFFFFF">'.nl2br(htmlspecialchars($originalnews['story'])).'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">'.$_LANGUAGES["$_REQUEST[language]"].'</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="story" cols="80" rows="10" style="width:100%">'.htmlspecialchars($story).'</textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2" align="center"><input type="submit" value="Update"> <input type="reset" value="Reset"></td></tr>';
+  echo '</td></tr></table>';
+  echo '</table></p></center>';
+  echo '<input type="hidden" name="action" value="dotranslate"><input type="hidden" name="id" value="'.$_REQUEST['id'].'"><input type="hidden" name="language" value="'.$_REQUEST['language'].'"></form>';
+  exit;
+}
+
+if ($_POST['action'] == "dotranslate" && intval($_POST['id']) > 0) {
+  pg_query($db, "DELETE FROM news_text WHERE newsid=$_POST[id] AND language='$_POST[language]'");
+  $newsid = intval($_POST['id']);
+  $headline = trim($_POST['headline']);
+  $summary = trim($_POST['summary']);
+  $story = trim($_POST['story']);
+  if ($headline != "" && $summary != "") {
+    pg_query($db, "INSERT INTO news_text (newsid,language,headline,summary,story) VALUES ($newsid,'$_POST[language]','$headline','$summary','$story')");
+  }
+}
+
+if ($_REQUEST['action'] == "add") {
+  echo '<form action="news.php" method="POST">';
+  echo '<center><p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td bgcolor="#000000">';
+  echo '<table border="0" cellpadding="2" cellspacing="1" width="100%">';
+  echo '<tr><td bgcolor="#FFFFFF">Posted by</td><td bgcolor="#FFFFFF"><input type="text" size="25" name="posted_by" value=""></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Active</td><td bgcolor="#FFFFFF"><select name="active"><option value="Yes">Yes</option><option value="No" selected>No</option></select></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Approved</td><td bgcolor="#FFFFFF"><select name="approved"><option value="Yes">Yes</option><option value="No" selected>No</option></select></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Headline</td><td bgcolor="#FFFFFF"><input type="text" name="headline" value="" size="50" style="width:100%"></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Summary</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="summary" cols="80" rows="4" style="width:100%"></textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Story</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="story" cols="80" rows="10" style="width:100%"></textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2" align="center"><input type="submit" value="Add news"> <input type="reset" value="Reset"></td></tr>';
+  echo '</td></tr></table>';
+  echo '</table></p></center>';
+  echo '<input type="hidden" name="action" value="doadd"></form>';
+  exit;
+}
+
+if ($_POST['action'] == "doadd") {
+  $headline = trim($_POST['headline']);
+  $summary = trim($_POST['summary']);
+  $story = trim($_POST['story']);
+  $rs = pg_query($db, "SELECT nextval('news_id_seq') AS newid;");
+  $newid = pg_result($rs, 0, "newid");
+  pg_query($db, "INSERT INTO news (id, posted_by, active, approved) VALUES ($newid, '$_POST[posted_by]', '$_POST[active]', '$_POST[approved]')");
+  pg_query($db, "INSERT INTO news_text (newsid,headline,summary,story,language) VALUES ($newid,'$headline','$summary','$story','en')");
+}
+
+?>
+
+<p><a href="news.php?action=add">Add news</a></p>
+
+<p><center>
+<table border="0" cellspacing="0" cellpadding="0" width="100%">
+  <tr>
+    <td bgcolor="#000000">
+         <table border="0" cellspacing="1" cellpadding="2" width="100%">
+           <tr>
+          <th bgcolor="#FFFFFF">ID</th>
+          <th bgcolor="#FFFFFF">Posted</th>
+          <th bgcolor="#FFFFFF">Headline</th>
+          <th bgcolor="#FFFFFF">Active</th>
+          <th bgcolor="#FFFFFF">Approved</th>
+          <th bgcolor="#FFFFFF">Translate</th>
+          <th bgcolor="#FFFFFF" colspan="2">Options</th>
+        </tr>
+
+<?php
+
+  $nl = "\n";
+  $rs = pg_query($db, "SELECT n.id, n.posted, t.headline, n.active, n.approved FROM news n LEFT OUTER JOIN news_text t ON (t.language='en' AND n.id=t.newsid) ORDER BY n.id DESC");
+  while($row = pg_fetch_array($rs)){
+       $translated = array();
+       $translatelinks = '';
+       $translations = pg_query($db, "SELECT language FROM news_text WHERE newsid=$row[id]");
+       while($translation = pg_fetch_array($translations)) {
+         $translated["$translation[language]"] = true;
+       }
+       reset($_LANGUAGES);
+       while(list($key,$val) = each($_LANGUAGES)){
+         $translatelinks .= '<a href="news.php?action=translate&id='.$row['id'].'&language='.$key.'"><img src="/layout/images/lngflags/'.$key.iif(!$translated[$key],'_disabled').'.gif" alt="'.$val.'" border="0"></a> ';
+       }
+       echo '        <tr>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.$row['id'].'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.$row['posted'].'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.$row['headline'].'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.iif($row['active']=='t','Yes','No').'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.iif($row['approved']=='t','Yes','No').'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF" align="center">'.trim($translatelinks).'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF" align="center"><a href="news.php?action=edit&id='.$row['id'].'">Edit</a></td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF" align="center"><a href="news.php?action=delete&id='.$row['id'].'">Delete</a></td>'.$nl;
+       echo '        </tr>'.$nl;
+  } // while
+
+?>
+
+         </table>
+       </td>
+  </tr>
+</table>
+</center></p>
+
+<?php
+
+CreateFooter();
+
+?>
\ No newline at end of file
diff --git a/portal/admin/pages.php b/portal/admin/pages.php
new file mode 100644 (file)
index 0000000..b4ac57b
--- /dev/null
@@ -0,0 +1,152 @@
+<?php
+
+require "globals.php";
+
+CreateHeader("Static pages");
+
+// Get all possible languages
+require('../system/global/languages.php');
+
+// Check for actions
+if ($_REQUEST['action'] == "delete" && $_REQUEST['page'] != "") {
+  echo "<p>You want to delete the page $_REQUEST[page].htm. Are you sure?<p>";
+  echo '<p><form action="pages.php" method="POST"><input type="hidden" name="action" value="dodelete"><input type="hidden" name="page" value="'.$_REQUEST['page'].'"><input type="submit" value="Delete now"></form></p>';
+  exit;
+}
+
+if ($_POST['action'] == "dodelete" && $_POST['page'] != "") {
+  pg_query($db, "DELETE FROM staticpages WHERE name='$_POST[page]'");
+}
+
+if ($_REQUEST['action'] == "edit" && $_REQUEST['page'] != "") {
+  echo '<form action="pages.php" method="POST">';
+  echo '<center><p><table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#000000">';
+  echo '<table border="0" cellpadding="2" cellspacing="1">';
+  echo '<tr><td bgcolor="#FFFFFF">Page</td><td bgcolor="#FFFFFF"><input type="text" size="25" name="name" value="'.$_REQUEST['page'].'">.htm</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2" align="center"><input type="submit" value="Update"> <input type="reset" value="Reset"></td></tr>';
+  echo '</td></tr></table>';
+  echo '</table></p></center>';
+  echo '<input type="hidden" name="action" value="doedit"><input type="hidden" name="page" value="'.$_REQUEST['page'].'"></form>';
+  exit;
+}
+
+if ($_POST['action'] == "doedit" && $_POST['page'] != "" && $_POST['name'] != "") {
+  pg_query($db, "UPDATE staticpages SET name='$_POST[name]' WHERE name='$_POST[page]'");
+}
+
+if ($_REQUEST['action'] == "translate" && $_REQUEST['page'] != "" && isset($_LANGUAGES["$_REQUEST[language]"])) {
+  $rs = pg_query($db, "SELECT title,content FROM staticpages WHERE name='$_REQUEST[page]' AND language='en'");
+  $originalpage = pg_fetch_array($rs);
+  $rs = pg_query($db, "SELECT title,content FROM staticpages WHERE name='$_REQUEST[page]' AND language='$_REQUEST[language]'");
+  if (pg_num_rows($rs) == 0) {
+    $title = "";
+       $content = "";
+  } else {
+    $page = pg_fetch_array($rs);
+       $title = $page['title'];
+       $content = $page['content'];
+  }
+  echo '<form action="pages.php" method="POST">';
+  echo '<center><p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td bgcolor="#000000">';
+  echo '<table border="0" cellpadding="2" cellspacing="1" width="100%">';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2"><b>Page title</b></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">English</td><td bgcolor="#FFFFFF">'.nl2br(htmlspecialchars($originalpage['title'])).'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">'.$_LANGUAGES["$_REQUEST[language]"].'</td><td bgcolor="#FFFFFF"><input type="text" name="title" value="'.htmlspecialchars($title).'" size="50" style="width:100%"></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2"><b>Page content</b></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">English</td><td bgcolor="#FFFFFF">'.nl2br(htmlspecialchars($originalpage['content'])).'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">'.$_LANGUAGES["$_REQUEST[language]"].'</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="content" cols="80" rows="10" style="width:100%">'.htmlspecialchars($content).'</textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2" align="center"><input type="submit" value="Update"> <input type="reset" value="Reset"></td></tr>';
+  echo '</td></tr></table>';
+  echo '</table></p></center>';
+  echo '<input type="hidden" name="action" value="dotranslate"><input type="hidden" name="page" value="'.$_REQUEST['page'].'"><input type="hidden" name="language" value="'.$_REQUEST['language'].'"></form>';
+  exit;
+}
+
+if ($_POST['action'] == "dotranslate" && $_POST['page'] != "") {
+  pg_query($db, "DELETE FROM staticpages WHERE name='$_POST[page]' AND language='$_POST[language]'");
+  $title = trim($_POST['title']);
+  $content = trim($_POST['content']);
+  if ($title != "" && $content != "") {
+    pg_query($db, "INSERT INTO staticpages (name,language,title,content) VALUES ('$_POST[page]','$_POST[language]','$title','$content')");
+  }
+}
+
+if ($_REQUEST['action'] == "add") {
+  echo '<form action="pages.php" method="POST">';
+  echo '<center><p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td bgcolor="#000000">';
+  echo '<table border="0" cellpadding="2" cellspacing="1" width="100%">';
+  echo '<tr><td bgcolor="#FFFFFF">Page</td><td bgcolor="#FFFFFF"><input type="text" size="25" name="name" value="">.htm</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Title</td><td bgcolor="#FFFFFF"><input type="text" name="title" value="" size="50" style="width:100%"></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">Content</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="content" cols="80" rows="10" style="width:100%"></textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2" align="center"><input type="submit" value="Add page"> <input type="reset" value="Reset"></td></tr>';
+  echo '</td></tr></table>';
+  echo '</table></p></center>';
+  echo '<input type="hidden" name="action" value="doadd"></form>';
+  exit;
+}
+
+if ($_POST['action'] == "doadd") {
+  $name = trim($_POST['name']);
+  $rs = pg_query($db, "SELECT * FROM staticpages WHERE name='$name'");
+  if (pg_num_rows($rs) > 0) {
+    echo "<p>Sorry, this page does already exist.</p>";
+       exit;
+  }
+  $title = trim($_POST['title']);
+  $content = trim($_POST['content']);
+  pg_query($db, "INSERT INTO staticpages (name,language,title,content) VALUES ('$name','en','$title','$content')");
+}
+
+?>
+
+<p><a href="pages.php?action=add">Add page</a></p>
+
+<p><center>
+<table border="0" cellspacing="0" cellpadding="0" width="100%">
+  <tr>
+    <td bgcolor="#000000">
+         <table border="0" cellspacing="1" cellpadding="2" width="100%">
+           <tr>
+          <th bgcolor="#FFFFFF">Page</th>
+          <th bgcolor="#FFFFFF">Title</th>
+          <th bgcolor="#FFFFFF">Translate</th>
+          <th bgcolor="#FFFFFF" colspan="2">Options</th>
+        </tr>
+
+<?php
+
+  $nl = "\n";
+  $rs = pg_query($db, "SELECT DISTINCT ON (name) name,title FROM staticpages ORDER BY name");
+  while($row = pg_fetch_array($rs)){
+       $translated = array();
+       $translatelinks = '';
+       $translations = pg_query($db, "SELECT language FROM staticpages WHERE name='$row[name]'");
+       while($translation = pg_fetch_array($translations)) {
+         $translated["$translation[language]"] = true;
+       }
+       reset($_LANGUAGES);
+       while(list($key,$val) = each($_LANGUAGES)){
+         $translatelinks .= '<a href="pages.php?action=translate&page='.$row['name'].'&language='.$key.'"><img src="/layout/images/lngflags/'.$key.iif(!$translated[$key],'_disabled').'.gif" alt="'.$val.'" border="0"></a> ';
+       }
+       echo '        <tr>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.$row['name'].'.htm</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.$row['title'].'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF" align="center">'.trim($translatelinks).'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF" align="center"><a href="pages.php?action=edit&page='.$row['name'].'">Edit</a></td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF" align="center"><a href="pages.php?action=delete&page='.$row['name'].'">Delete</a></td>'.$nl;
+       echo '        </tr>'.$nl;
+  } // while
+
+?>
+
+         </table>
+       </td>
+  </tr>
+</table>
+</center></p>
+
+<?php
+
+CreateFooter();
+
+?>
\ No newline at end of file
diff --git a/portal/admin/templates.php b/portal/admin/templates.php
new file mode 100644 (file)
index 0000000..2dcc6e7
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+
+require "globals.php";
+
+CreateHeader("Template translation");
+
+// Get all possible languages
+require('../system/global/languages.php');
+
+// Check for actions
+if ($_REQUEST['action'] == "translate" && $_REQUEST['template'] != "" && isset($_LANGUAGES["$_REQUEST[language]"])) {
+  $rs = pg_query($db, "SELECT content FROM templates WHERE name='$_REQUEST[template]' AND language='en'");
+  $originaltemplate = pg_fetch_array($rs);
+  $rs = pg_query($db, "SELECT content FROM templates WHERE name='$_REQUEST[template]' AND language='$_REQUEST[language]'");
+  if (pg_num_rows($rs) == 0) {
+    $title = "";
+       $content = "";
+  } else {
+    $template = pg_fetch_array($rs);
+       $title = $template['title'];
+       $content = $template['content'];
+  }
+  echo '<form action="templates.php" method="POST">';
+  echo '<center><p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td bgcolor="#000000">';
+  echo '<table border="0" cellpadding="2" cellspacing="1" width="100%">';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2"><b>Template "'.$_REQUEST['template'].'"</b></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">English</td><td bgcolor="#FFFFFF">'.nl2br(htmlspecialchars($originaltemplate['content'])).'</td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF">'.$_LANGUAGES["$_REQUEST[language]"].'</td><td bgcolor="#FFFFFF"><textarea wrap="virtual" name="content" cols="80" rows="10" style="width:100%">'.htmlspecialchars($content).'</textarea></td></tr>';
+  echo '<tr><td bgcolor="#FFFFFF" colspan="2" align="center"><input type="submit" value="Update"> <input type="reset" value="Reset"></td></tr>';
+  echo '</td></tr></table>';
+  echo '</table></p></center>';
+  echo '<input type="hidden" name="action" value="dotranslate"><input type="hidden" name="template" value="'.$_REQUEST['template'].'"><input type="hidden" name="language" value="'.$_REQUEST['language'].'"></form>';
+  exit;
+}
+
+if ($_POST['action'] == "dotranslate" && $_POST['template'] != "") {
+  pg_query($db, "DELETE FROM templates WHERE name='$_POST[template]' AND language='$_POST[language]'");
+  $content = trim($_POST['content']);
+  if ($content != "") {
+    pg_query($db, "INSERT INTO templates (name,language,content) VALUES ('$_POST[template]','$_POST[language]','$content')");
+  }
+}
+
+?>
+
+<p><center>
+<table border="0" cellspacing="0" cellpadding="0" width="100%">
+  <tr>
+    <td bgcolor="#000000">
+         <table border="0" cellspacing="1" cellpadding="2" width="100%">
+           <tr>
+          <th bgcolor="#FFFFFF">Template</th>
+          <th bgcolor="#FFFFFF">Translate</th>
+        </tr>
+
+<?php
+
+  $nl = "\n";
+  $rs = pg_query($db, "SELECT DISTINCT ON (name) name FROM templates ORDER BY name");
+  while($row = pg_fetch_array($rs)){
+       $translated = array();
+       $translatelinks = '';
+       $translations = pg_query($db, "SELECT language FROM templates WHERE name='$row[name]'");
+       while($translation = pg_fetch_array($translations)) {
+         $translated["$translation[language]"] = true;
+       }
+       reset($_LANGUAGES);
+       while(list($key,$val) = each($_LANGUAGES)){
+         $translatelinks .= '<a href="templates.php?action=translate&template='.$row['name'].'&language='.$key.'"><img src="/layout/images/lngflags/'.$key.iif(!$translated[$key],'_disabled').'.gif" alt="'.$val.'" border="0"></a> ';
+       }
+       echo '        <tr>'.$nl;
+       echo '          <td bgcolor="#FFFFFF">'.$row['name'].'</td>'.$nl;
+       echo '          <td bgcolor="#FFFFFF" align="center">'.trim($translatelinks).'</td>'.$nl;
+       echo '        </tr>'.$nl;
+  } // while
+
+?>
+
+         </table>
+       </td>
+  </tr>
+</table>
+</center></p>
+
+<?php
+
+CreateFooter();
+
+?>
\ No newline at end of file
diff --git a/portal/cache/index.htm b/portal/cache/index.htm
new file mode 100644 (file)
index 0000000..fb5d0d0
--- /dev/null
@@ -0,0 +1,76 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+
+<head>
+  <title>PostgreSQL: Choose language</title>
+  <meta http-equiv="Expires" content="Mon, 06 Jan 1990 00:00:01 GMT">
+  <meta http-equiv="Pragma" content="no-cache">
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <meta name="Author" content="Dave Page">
+  <meta name="keyword" content="PostgreSQL, database, dbms, postgres, postgres95, pgsql, relational, SQL, ODBC, JDBC"> 
+  <link rel="stylesheet" href="/layout/css/postgresql.css" type="text/css">
+</head>
+
+<body>
+  <a name="TOP"></a>
+  <p>&nbsp;</p>
+  <center>
+    <table width="95%" border=0 cellspacing=0 cellpadding=2 bgcolor="#000000">
+      <tr>
+        <td>
+          <table width="100%" border=0 cellpadding=0 cellspacing=0 bgcolor="#FFFFFF">
+            <tr>
+              <td>
+                <table width="100%" cellpadding=0 cellspacing=0 border=0>
+                  <tr>
+                    <!-- Ad -->
+                    <td align=center rowspan=2 bgcolor="#FFFFFF" width=126 height=120><a href="http://ads.hub.org/redirect.php?lvl=sponsor" TARGET="_banner"><img src="http://ads.hub.org/display_image.php?lvl=sponsor" border=0 alt="Sponsorenbanner" width=120 height=120></a></td>
+                    <!-- End Ad -->
+                    <!-- Banner -->
+                    <td rowspan=1 bgcolor="#6884A4" width="100%" background="/layout/images/banner-background.jpg"><a href="/de/index.htm"><img src="/layout/images/banner-left.jpg" alt="PostgreSQL Banner" border=0 width="186" height="95"></a></td>
+                    <td rowspan=2 bgcolor="#6884A4" width="120" align="right"><a href="/de/index.htm"><img src="/layout/images/banner-right.jpg" alt="PostgreSQL Banner" border=0 width=120 height=120></a></td>
+                    <!-- End Banner -->
+                    <!-- Ad -->
+                    <td align=center rowspan=2 bgcolor="#FFFFFF" width=126 height=120><a href="http://ads.hub.org/redirect.php?lvl=free" TARGET="_banner"><img src="http://ads.hub.org/display_image.php?lvl=free" border=0 alt="Banner eines PostgreSQL-Projekts" width=120 height=120></a></td>
+                    <!-- End Ad -->
+                  </tr>   
+                  <tr>
+                    <td align=left bgcolor="#6884A4" nowrap height=25> 
+                      &nbsp;
+                      <a href="/en/index.htm" style="font-size:x-small; color: #FFFFFF;">English</a><font color="#CDDDEB">&nbsp;&middot;</font>
+                      <a href="/de/index.htm" style="font-size:x-small; color: #FFFFFF;">Deutsch</a>
+                    </td>
+                  </tr>
+                </table>
+                <table width="100%" cellpadding=0 cellspacing=0 border=0 bgcolor="#FFFFFF">
+                  <tr>
+                    <td valign=top width="25">
+                      &nbsp;
+                    </td>
+                    <td valign=top>
+                      <br>
+                      <p>Dear visitor, PostgreSQL.org is now available in two languages. Please choose your prefered language here:</p>
+                      <p><table border="0" cellspacing="0" cellpadding="0" width="100%">
+                        <tr>
+                          <td width="50%" align="center"><a href="/en/index.htm"><img src="/layout/images/flags/UK.gif" border="0"></a><br><a href="/en/index.htm">English</a></td>
+                          <td width="50%" align="center"><a href="/de/index.htm"><img src="/layout/images/flags/Germany.gif" border="0"></a><br><a href="/de/index.htm">Deutsch</a></td>
+                        </tr>
+                      </table></p>
+                      <p>If you want to help translating PostgreSQL.org into your language, please send a mail to the <a href="mailto:webmaster@postgresql.org">webmasters</a>. Please write in english.</p>
+                      <br><br>
+                    </td>
+                    <td valign=top width="25">
+                      &nbsp;
+                    </td>
+                  </tr>
+                </table>
+              </td>
+            </tr>
+          </table>
+        </td>
+      </tr>
+    </table>
+    </center>
+    <p align="center">&nbsp;</p>
+  </body>
+</html>
\ No newline at end of file
diff --git a/portal/layout/css/postgresql.css b/portal/layout/css/postgresql.css
new file mode 100644 (file)
index 0000000..19a4c22
--- /dev/null
@@ -0,0 +1,10 @@
+body {margin:0; background:#555555;}
+A {font-family:helvetica,arial,sans-serif; font-weight:normal; color:#020169; text-decoration:none;}
+A:active {color:#6884A4;}
+A:visited {color:#6884A4;}
+A:hover        {text-decoration:underline; color:#020169;}
+LI {font-family:helvetica,arial,sans-serif;}
+BIG {text-decoration:none; font-family:helvetica,arial,sans-serif; font-weight:bold; font-size:normal;}
+SMALL {text-decoration:none; font-family:helvetica,arial,sans-serif; font-weight:normal; font-size:x-small;}
+ol,ul,p,body,td,tr,th,form,span,div {font-family:helvetica,arial,sans-serif;}
+h1,h2,h3,h4,h5,h6 {font-family:helvetica,arial,sans-serif;}
\ No newline at end of file
diff --git a/portal/layout/css/postgresql_admin.css b/portal/layout/css/postgresql_admin.css
new file mode 100644 (file)
index 0000000..0d307bd
--- /dev/null
@@ -0,0 +1,13 @@
+body {margin-top:30; margin-left:10; margin-right:10; margin-bottom:10; background:#FFFFFF;}
+body.nav {margin:3; background:#CDDDEB;}
+A {font-family:helvetica,arial,sans-serif; font-weight:normal; font-size:x-small; color:#020169; text-decoration:none;}
+A:active {color:#6884A4;}
+A:visited {color:#6884A4;}
+A:hover        {text-decoration:underline; color:#020169;}
+LI {font-family:helvetica,arial,sans-serif;}
+BIG {text-decoration:none; font-family:helvetica,arial,sans-serif; font-weight:bold; font-size:small;}
+SMALL {text-decoration:none; font-family:helvetica,arial,sans-serif; font-weight:normal; font-size:xx-small;}
+ol,ul,p,body,td,tr,th,form,span,div {font-family:helvetica,arial,sans-serif; font-size:x-small;}
+tt {font-size:x-small;}
+h1,h2,h3,h4,h5,h6 {font-family:helvetica,arial,sans-serif;}
+
diff --git a/portal/layout/images/banner-background.jpg b/portal/layout/images/banner-background.jpg
new file mode 100644 (file)
index 0000000..e28778f
Binary files /dev/null and b/portal/layout/images/banner-background.jpg differ
diff --git a/portal/layout/images/banner-left.jpg b/portal/layout/images/banner-left.jpg
new file mode 100644 (file)
index 0000000..7ff5dfc
Binary files /dev/null and b/portal/layout/images/banner-left.jpg differ
diff --git a/portal/layout/images/banner-right.jpg b/portal/layout/images/banner-right.jpg
new file mode 100644 (file)
index 0000000..c3bce40
Binary files /dev/null and b/portal/layout/images/banner-right.jpg differ
diff --git a/portal/layout/images/flags/Argentina.gif b/portal/layout/images/flags/Argentina.gif
new file mode 100644 (file)
index 0000000..08ef6ae
Binary files /dev/null and b/portal/layout/images/flags/Argentina.gif differ
diff --git a/portal/layout/images/flags/Australia.gif b/portal/layout/images/flags/Australia.gif
new file mode 100644 (file)
index 0000000..5cc15b3
Binary files /dev/null and b/portal/layout/images/flags/Australia.gif differ
diff --git a/portal/layout/images/flags/Austria.gif b/portal/layout/images/flags/Austria.gif
new file mode 100644 (file)
index 0000000..d72b945
Binary files /dev/null and b/portal/layout/images/flags/Austria.gif differ
diff --git a/portal/layout/images/flags/Belgium.gif b/portal/layout/images/flags/Belgium.gif
new file mode 100644 (file)
index 0000000..3d314a3
Binary files /dev/null and b/portal/layout/images/flags/Belgium.gif differ
diff --git a/portal/layout/images/flags/Belguim.gif b/portal/layout/images/flags/Belguim.gif
new file mode 100644 (file)
index 0000000..3d314a3
Binary files /dev/null and b/portal/layout/images/flags/Belguim.gif differ
diff --git a/portal/layout/images/flags/BosniaandHerzegovina.gif b/portal/layout/images/flags/BosniaandHerzegovina.gif
new file mode 100644 (file)
index 0000000..c0d92dc
Binary files /dev/null and b/portal/layout/images/flags/BosniaandHerzegovina.gif differ
diff --git a/portal/layout/images/flags/Brazil.gif b/portal/layout/images/flags/Brazil.gif
new file mode 100644 (file)
index 0000000..ea5fa81
Binary files /dev/null and b/portal/layout/images/flags/Brazil.gif differ
diff --git a/portal/layout/images/flags/Bulgaria.gif b/portal/layout/images/flags/Bulgaria.gif
new file mode 100644 (file)
index 0000000..35c0b11
Binary files /dev/null and b/portal/layout/images/flags/Bulgaria.gif differ
diff --git a/portal/layout/images/flags/Canada.gif b/portal/layout/images/flags/Canada.gif
new file mode 100644 (file)
index 0000000..322d4b9
Binary files /dev/null and b/portal/layout/images/flags/Canada.gif differ
diff --git a/portal/layout/images/flags/Chile.gif b/portal/layout/images/flags/Chile.gif
new file mode 100644 (file)
index 0000000..12b6a90
Binary files /dev/null and b/portal/layout/images/flags/Chile.gif differ
diff --git a/portal/layout/images/flags/China.gif b/portal/layout/images/flags/China.gif
new file mode 100644 (file)
index 0000000..4baf243
Binary files /dev/null and b/portal/layout/images/flags/China.gif differ
diff --git a/portal/layout/images/flags/Colombia.gif b/portal/layout/images/flags/Colombia.gif
new file mode 100644 (file)
index 0000000..a4f604b
Binary files /dev/null and b/portal/layout/images/flags/Colombia.gif differ
diff --git a/portal/layout/images/flags/CostaRica.gif b/portal/layout/images/flags/CostaRica.gif
new file mode 100644 (file)
index 0000000..d3a3143
Binary files /dev/null and b/portal/layout/images/flags/CostaRica.gif differ
diff --git a/portal/layout/images/flags/Czech-republic.gif b/portal/layout/images/flags/Czech-republic.gif
new file mode 100644 (file)
index 0000000..10d5a3c
Binary files /dev/null and b/portal/layout/images/flags/Czech-republic.gif differ
diff --git a/portal/layout/images/flags/CzechRepublic.gif b/portal/layout/images/flags/CzechRepublic.gif
new file mode 100644 (file)
index 0000000..62515e3
Binary files /dev/null and b/portal/layout/images/flags/CzechRepublic.gif differ
diff --git a/portal/layout/images/flags/Denmark.gif b/portal/layout/images/flags/Denmark.gif
new file mode 100644 (file)
index 0000000..4dce860
Binary files /dev/null and b/portal/layout/images/flags/Denmark.gif differ
diff --git a/portal/layout/images/flags/Estonia.gif b/portal/layout/images/flags/Estonia.gif
new file mode 100644 (file)
index 0000000..b8bbf1d
Binary files /dev/null and b/portal/layout/images/flags/Estonia.gif differ
diff --git a/portal/layout/images/flags/Finland.gif b/portal/layout/images/flags/Finland.gif
new file mode 100644 (file)
index 0000000..a43a398
Binary files /dev/null and b/portal/layout/images/flags/Finland.gif differ
diff --git a/portal/layout/images/flags/France.gif b/portal/layout/images/flags/France.gif
new file mode 100644 (file)
index 0000000..13fcbf2
Binary files /dev/null and b/portal/layout/images/flags/France.gif differ
diff --git a/portal/layout/images/flags/Germany.gif b/portal/layout/images/flags/Germany.gif
new file mode 100644 (file)
index 0000000..e25a855
Binary files /dev/null and b/portal/layout/images/flags/Germany.gif differ
diff --git a/portal/layout/images/flags/Greece.gif b/portal/layout/images/flags/Greece.gif
new file mode 100644 (file)
index 0000000..1ede215
Binary files /dev/null and b/portal/layout/images/flags/Greece.gif differ
diff --git a/portal/layout/images/flags/HongKong.gif b/portal/layout/images/flags/HongKong.gif
new file mode 100644 (file)
index 0000000..ef31643
Binary files /dev/null and b/portal/layout/images/flags/HongKong.gif differ
diff --git a/portal/layout/images/flags/Hungary.gif b/portal/layout/images/flags/Hungary.gif
new file mode 100644 (file)
index 0000000..eca0e10
Binary files /dev/null and b/portal/layout/images/flags/Hungary.gif differ
diff --git a/portal/layout/images/flags/Iceland.gif b/portal/layout/images/flags/Iceland.gif
new file mode 100644 (file)
index 0000000..ee4d17f
Binary files /dev/null and b/portal/layout/images/flags/Iceland.gif differ
diff --git a/portal/layout/images/flags/India.gif b/portal/layout/images/flags/India.gif
new file mode 100644 (file)
index 0000000..aab1776
Binary files /dev/null and b/portal/layout/images/flags/India.gif differ
diff --git a/portal/layout/images/flags/Indonesia.gif b/portal/layout/images/flags/Indonesia.gif
new file mode 100644 (file)
index 0000000..463f457
Binary files /dev/null and b/portal/layout/images/flags/Indonesia.gif differ
diff --git a/portal/layout/images/flags/Ireland.gif b/portal/layout/images/flags/Ireland.gif
new file mode 100644 (file)
index 0000000..a550678
Binary files /dev/null and b/portal/layout/images/flags/Ireland.gif differ
diff --git a/portal/layout/images/flags/Israel.gif b/portal/layout/images/flags/Israel.gif
new file mode 100644 (file)
index 0000000..11453ed
Binary files /dev/null and b/portal/layout/images/flags/Israel.gif differ
diff --git a/portal/layout/images/flags/Italy.gif b/portal/layout/images/flags/Italy.gif
new file mode 100644 (file)
index 0000000..511dba8
Binary files /dev/null and b/portal/layout/images/flags/Italy.gif differ
diff --git a/portal/layout/images/flags/Japan.gif b/portal/layout/images/flags/Japan.gif
new file mode 100644 (file)
index 0000000..37ebca6
Binary files /dev/null and b/portal/layout/images/flags/Japan.gif differ
diff --git a/portal/layout/images/flags/Korea.gif b/portal/layout/images/flags/Korea.gif
new file mode 100644 (file)
index 0000000..57b52b3
Binary files /dev/null and b/portal/layout/images/flags/Korea.gif differ
diff --git a/portal/layout/images/flags/Latvia.gif b/portal/layout/images/flags/Latvia.gif
new file mode 100644 (file)
index 0000000..5a768d0
Binary files /dev/null and b/portal/layout/images/flags/Latvia.gif differ
diff --git a/portal/layout/images/flags/Mexico.gif b/portal/layout/images/flags/Mexico.gif
new file mode 100644 (file)
index 0000000..8a6687a
Binary files /dev/null and b/portal/layout/images/flags/Mexico.gif differ
diff --git a/portal/layout/images/flags/Netherlands.gif b/portal/layout/images/flags/Netherlands.gif
new file mode 100644 (file)
index 0000000..c09d3eb
Binary files /dev/null and b/portal/layout/images/flags/Netherlands.gif differ
diff --git a/portal/layout/images/flags/New Zealand.gif b/portal/layout/images/flags/New Zealand.gif
new file mode 100644 (file)
index 0000000..67b933f
Binary files /dev/null and b/portal/layout/images/flags/New Zealand.gif differ
diff --git a/portal/layout/images/flags/NewZealand.gif b/portal/layout/images/flags/NewZealand.gif
new file mode 100644 (file)
index 0000000..e329285
Binary files /dev/null and b/portal/layout/images/flags/NewZealand.gif differ
diff --git a/portal/layout/images/flags/Norway.gif b/portal/layout/images/flags/Norway.gif
new file mode 100644 (file)
index 0000000..20d23b7
Binary files /dev/null and b/portal/layout/images/flags/Norway.gif differ
diff --git a/portal/layout/images/flags/Philippines.gif b/portal/layout/images/flags/Philippines.gif
new file mode 100644 (file)
index 0000000..540d455
Binary files /dev/null and b/portal/layout/images/flags/Philippines.gif differ
diff --git a/portal/layout/images/flags/Poland.gif b/portal/layout/images/flags/Poland.gif
new file mode 100644 (file)
index 0000000..756f939
Binary files /dev/null and b/portal/layout/images/flags/Poland.gif differ
diff --git a/portal/layout/images/flags/Portugal.gif b/portal/layout/images/flags/Portugal.gif
new file mode 100644 (file)
index 0000000..91bf32a
Binary files /dev/null and b/portal/layout/images/flags/Portugal.gif differ
diff --git a/portal/layout/images/flags/Romania.gif b/portal/layout/images/flags/Romania.gif
new file mode 100644 (file)
index 0000000..2d38df2
Binary files /dev/null and b/portal/layout/images/flags/Romania.gif differ
diff --git a/portal/layout/images/flags/Russia.gif b/portal/layout/images/flags/Russia.gif
new file mode 100644 (file)
index 0000000..f72e7f7
Binary files /dev/null and b/portal/layout/images/flags/Russia.gif differ
diff --git a/portal/layout/images/flags/Singapore.gif b/portal/layout/images/flags/Singapore.gif
new file mode 100644 (file)
index 0000000..20ec560
Binary files /dev/null and b/portal/layout/images/flags/Singapore.gif differ
diff --git a/portal/layout/images/flags/SlovakRepublic.gif b/portal/layout/images/flags/SlovakRepublic.gif
new file mode 100644 (file)
index 0000000..f3486fb
Binary files /dev/null and b/portal/layout/images/flags/SlovakRepublic.gif differ
diff --git a/portal/layout/images/flags/South-africa1.gif b/portal/layout/images/flags/South-africa1.gif
new file mode 100644 (file)
index 0000000..015d07e
Binary files /dev/null and b/portal/layout/images/flags/South-africa1.gif differ
diff --git a/portal/layout/images/flags/South-korea.gif b/portal/layout/images/flags/South-korea.gif
new file mode 100644 (file)
index 0000000..57b52b3
Binary files /dev/null and b/portal/layout/images/flags/South-korea.gif differ
diff --git a/portal/layout/images/flags/SouthAfrica.gif b/portal/layout/images/flags/SouthAfrica.gif
new file mode 100644 (file)
index 0000000..015d07e
Binary files /dev/null and b/portal/layout/images/flags/SouthAfrica.gif differ
diff --git a/portal/layout/images/flags/Spain.gif b/portal/layout/images/flags/Spain.gif
new file mode 100644 (file)
index 0000000..690efa4
Binary files /dev/null and b/portal/layout/images/flags/Spain.gif differ
diff --git a/portal/layout/images/flags/Sweden.gif b/portal/layout/images/flags/Sweden.gif
new file mode 100644 (file)
index 0000000..4f2f53c
Binary files /dev/null and b/portal/layout/images/flags/Sweden.gif differ
diff --git a/portal/layout/images/flags/Switzerland.gif b/portal/layout/images/flags/Switzerland.gif
new file mode 100644 (file)
index 0000000..98cef7c
Binary files /dev/null and b/portal/layout/images/flags/Switzerland.gif differ
diff --git a/portal/layout/images/flags/Taiwan.gif b/portal/layout/images/flags/Taiwan.gif
new file mode 100644 (file)
index 0000000..e769846
Binary files /dev/null and b/portal/layout/images/flags/Taiwan.gif differ
diff --git a/portal/layout/images/flags/Thailand.gif b/portal/layout/images/flags/Thailand.gif
new file mode 100644 (file)
index 0000000..a317e75
Binary files /dev/null and b/portal/layout/images/flags/Thailand.gif differ
diff --git a/portal/layout/images/flags/Turkey.gif b/portal/layout/images/flags/Turkey.gif
new file mode 100644 (file)
index 0000000..3d28b89
Binary files /dev/null and b/portal/layout/images/flags/Turkey.gif differ
diff --git a/portal/layout/images/flags/UK.gif b/portal/layout/images/flags/UK.gif
new file mode 100644 (file)
index 0000000..0f555d0
Binary files /dev/null and b/portal/layout/images/flags/UK.gif differ
diff --git a/portal/layout/images/flags/USA.gif b/portal/layout/images/flags/USA.gif
new file mode 100644 (file)
index 0000000..bcf4929
Binary files /dev/null and b/portal/layout/images/flags/USA.gif differ
diff --git a/portal/layout/images/flags/Ukraine.gif b/portal/layout/images/flags/Ukraine.gif
new file mode 100644 (file)
index 0000000..b951bef
Binary files /dev/null and b/portal/layout/images/flags/Ukraine.gif differ
diff --git a/portal/layout/images/lngflags/de.gif b/portal/layout/images/lngflags/de.gif
new file mode 100644 (file)
index 0000000..99d829d
Binary files /dev/null and b/portal/layout/images/lngflags/de.gif differ
diff --git a/portal/layout/images/lngflags/de_disabled.gif b/portal/layout/images/lngflags/de_disabled.gif
new file mode 100644 (file)
index 0000000..0ff1480
Binary files /dev/null and b/portal/layout/images/lngflags/de_disabled.gif differ
diff --git a/portal/layout/images/lngflags/en.gif b/portal/layout/images/lngflags/en.gif
new file mode 100644 (file)
index 0000000..98a3366
Binary files /dev/null and b/portal/layout/images/lngflags/en.gif differ
diff --git a/portal/layout/images/lngflags/en_disabled.gif b/portal/layout/images/lngflags/en_disabled.gif
new file mode 100644 (file)
index 0000000..8da5190
Binary files /dev/null and b/portal/layout/images/lngflags/en_disabled.gif differ
diff --git a/portal/system/docs.php b/portal/system/docs.php
new file mode 100644 (file)
index 0000000..cef6f6c
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+
+// we know the $url must have the format /xy/documentation/{version}/{type}/{chapter}.htm
+preg_match("/^\/$language\/documentation\/([^\/]*)\/([a-z]*)\/([^\/]*)\.htm$/",$url,$docsarray);
+
+$version = $docsarray[1];
+$type = iif($docsarray[2]=='interactive', 'interactive', 'static');
+$chapter = $docsarray[3];
+
+$db = database_connect('portal');
+
+// Do we need to get the correct version?
+if ($version == 'current') {
+  $rs = pg_query($db, 'SELECT max(version) FROM docs');
+  $version = pg_result($rs, 0, 0);
+}
+
+// The old docs hat .htm, new new have .html
+$extension = iif($version < 7.1, ".htm", ".html");
+
+// TEMPORARY: FIND A PAGE TO TEST A REPLACEMENT...
+//$rs = pg_query($db, "SELECT * FROM docs WHERE content LIKE '%IMG SRC%' LIMIT 1");
+//$result = pg_fetch_array($rs);
+//echo $result['file'];
+
+$rs = pg_query($db, "SELECT title, content FROM documentation WHERE version = $version::numeric AND file = '$chapter$extension' AND language IN ('".$_LANGUAGE['handler']."','".$_SETTINGS['defaultlanguage']."') ORDER BY language ".$_LANGUAGE['order']." LIMIT 1");
+if (pg_num_rows($rs) == 0) {
+  $_LANGUAGE['pagetitle'] = $_LANGUAGE['docs_title'];
+  $pagecontent = '<br><br><p><font color=red><b>The specified file could not be found!</b></font></p><br>';
+} else {
+  $result = pg_fetch_array($rs);
+  $_LANGUAGE['pagetitle'] = $result['title'];
+  $pagecontent = $result['content'];
+  
+  // Fix the urls
+  $pagecontent = preg_replace('/href="(?<!http|ftp|mailto)([^\.]+).html/i', "href=\"\$1.htm", $pagecontent);
+  
+  // Fix the images
+  $pagecontent = str_replace('IMG SRC="', "IMG SRC=\"/images/documentation/$version/", $pagecontent);
+  
+  // Build the comments
+  if ($type == 'interactive') {
+    $comments = '';
+    $c = pg_query($db, "SELECT id, comment, date_part('epoch', posted_at) AS timestamp, posted_by FROM comments WHERE version = $version::numeric AND file = '$chapter$extension' ORDER BY posted_at");
+    while ($comment = pg_fetch_array($c)) {
+      $comments .= LoadTemplate('docs_comment', $language, array('comment' => nl2br(stripslashes($comment['comment'])), 'poster' => stripslashes($comment['posted_by']), 'date' => date("d M Y G:i:s", $comment['timestamp'])));
+    }
+    if ($comments == '') {
+      $comments = '<br><b>No comments could be found for this page!</b>';
+    }
+    // Add the comment form
+    $pagecontent .= LoadTemplate('docs_comments', $language, array('doc' => $chapter.$extension, 'version' => $version, 'comments' => $comments));
+  }
+}
+
+// get the basic layout ($top, $left, $right and $bottom)
+require("./layout/basic.top.php");
+require("./layout/docs.left.php");
+require("./layout/docs.right.php");
+require("./layout/basic.bottom.php");
+
+// get $content
+$content = "$top
+$left
+$pagecontent
+$right
+$bottom";
+
+$content = ParseOutput($content);
+
+?>
\ No newline at end of file
diff --git a/portal/system/global/functions.database.php b/portal/system/global/functions.database.php
new file mode 100644 (file)
index 0000000..06ea8a3
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+function database_connect($type) {
+  global $_SETTINGS;
+  // use $cons to remember all existing connection ressources
+  static $cons;
+  if (isset($cons[$type])) {
+    // return an existing connection ressource
+    return $cons[$type];
+  }
+  if (isset($_SETTINGS["db_$type"])) {
+    // let's try to connnect
+       if ($_SETTINGS['usepersistent']) {
+      $con = @pg_pconnect($_SETTINGS["db_$type"]);
+    } else {
+         $con = @pg_connect($_SETTINGS["db_$type"]);
+       }
+       // remember connection ressource
+       $cons[$type] = $con;
+       // return the connection ressource or FALSE
+       return $con;
+  } else {
+    // no database connection string available
+    return false;
+  }
+}
+
+?>
\ No newline at end of file
diff --git a/portal/system/global/functions.language.php b/portal/system/global/functions.language.php
new file mode 100644 (file)
index 0000000..6437ed1
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+
+function GetLanguageFromUrl($url) {
+  global $_LANGUAGES;
+  $lng = "";
+  if ($url == "") {
+    return false;
+  }
+  $urlarray = explode("/",$url);
+  if (isset($urlarray[1])) {
+    $lng = $urlarray[1];
+  }
+  if (isset($_LANGUAGES[$lng])) {
+    return $lng;
+  } else {
+    return false;
+  }
+}
+
+function GetLanguageFromCookie() {
+  global $_LANGUAGES;
+  // Well, we don't set that cookie
+  // anywhere at the moment...
+  if (isset($_COOKIE['pg_lang'])) {
+    $lng = $_COOKIE['pg_lang'];
+  } else {
+    return false;
+  }
+  if (isset($_LANGUAGES[$lng])) {
+    return $lng;
+  } else {
+    return false;
+  }
+}
+
+function GetLanguageFromBrowser() {
+  global $_LANGUAGES;
+  // Check which variable is set
+  if (isset($_ENV['HTTP_ACCEPT_LANGUAGE'])) {
+    $lng = $_ENV['HTTP_ACCEPT_LANGUAGE'];
+  } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
+    $lng = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
+  } else {
+    return false;
+  }
+  if (isset($_LANGUAGES[$lng])) {
+    // IE has a single value like 'de'
+    return $lng;
+  } else {
+    // Mozilla can have multiple languages, for example
+    // de-at,de;q=0.8,en-us;q=0.5,en;q=0.3
+    // Maybe we have something like this here?
+    $lngarray = split ('[,;]', $lng);
+    if (count($lngarray) > 1) {
+      for ($i=0; $i<count($lngarray); $i++) {
+        if (isset($_LANGUAGES["$lngarray[$i]"])) {
+          return $lngarray[$i];
+        }
+      }
+    }
+  }
+  // Nothing worked, return false
+  return false;
+}
+
+function GetAnyLanguage($url="") {
+  global $_SETTINGS;
+  $lng = false;
+  if ($url != "") {
+    $lng = GetLanguageFromUrl($url);
+  }
+  if (!$lng) {
+    $lng = GetLanguageFromCookie();
+  }
+  if (!$lng) {
+    $lng = GetLanguageFromBrowser();
+  }
+  if (!$lng) {
+    $lng = $_SETTINGS['defaultlanguage'];
+  }
+  return $lng;
+}
+
+function SetLanguageCookie($language="") {
+  setcookie("pg_lang",$language,time()+60*60*24*90,"/");
+}
+
+?>
\ No newline at end of file
diff --git a/portal/system/global/functions.layout.php b/portal/system/global/functions.layout.php
new file mode 100644 (file)
index 0000000..8bde987
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+
+function LoadStaticPage($pagename, $language) {
+  global $_LANGUAGE, $_SETTINGS;
+  if (!$db = database_connect('portal')) {
+    return array("content" => "Sorry, could not connect to the portal database", "title" => "Database Error");
+  }
+  $pageinfos = pg_query($db, "SELECT content, title FROM staticpages WHERE name='$pagename' AND language='$language' LIMIT 1");
+  if (pg_num_rows($pageinfos) > 0) {
+       return pg_fetch_array($pageinfos);
+  }
+  $pageinfos = pg_query($db, "SELECT content, title FROM staticpages WHERE name='$pagename' AND language='".$_SETTINGS['defaultlanguage']."' LIMIT 1");
+  if (pg_num_rows($pageinfos) > 0) {
+    return pg_fetch_array($pageinfos);
+  } elseif ($pagename != 'notfound') {
+       return LoadStaticPage('notfound', $language, $variables);
+  }
+  return array("content" => "Sorry, could not find this page", "title" => "Page not found");
+}
+
+function LoadTemplate($templatename, $language, $variables=array()) {
+  global $_LANGUAGE, $_SETTINGS;
+  if (!$db = database_connect('portal')) {
+    return "Could not connect to the portal database";
+  }
+  $templates = pg_query($db, "SELECT content FROM templates WHERE name='$templatename' AND language='$language' LIMIT 1");
+  if (pg_num_rows($templates) > 0) {
+    $template = pg_fetch_array($templates);
+       return DoVariables($template['content'], $variables);
+  }
+  $templates = pg_query($db, "SELECT content FROM templates WHERE name='$templatename' AND language='".$_SETTINGS['defaultlanguage']."' LIMIT 1");
+  if (pg_num_rows($templates) > 0) {
+    $template = pg_fetch_array($templates);
+       return DoVariables($template['content'], $variables);
+  }
+  return "Could not load Template '$templatename'.";
+}
+
+function DoVariables($content, $variables) {
+  if (is_array($variables) && count($variables > 0)) {
+    while(list($key,$val) = each($variables)){
+         $content = str_replace("{VAR_".$key."}",$val,$content);
+    }
+  }
+  return $content;
+}
+
+function ParseOutput($output) {
+  global $_LANGUAGE, $_SETTINGS, $pagestarttime;
+  
+  // Parse language contents
+  reset($_LANGUAGE);
+  while(list($key,$val) = each($_LANGUAGE)){
+       $output = str_replace("{LNG_".$key."}",$val,$output);
+  }
+  reset($_LANGUAGE);
+  
+  // Some stats
+  $pageendtime = microtime();
+  $starttime = explode(' ', $pagestarttime);
+  $endtime = explode(' ', $pageendtime);
+  $totaltime = $endtime[0] - $starttime[0] + $endtime[1] - $starttime[1];
+  $output = str_replace("{VAR_pagestats}",$totaltime,$output);
+
+  // The masterserver for dynamic content and form handling
+  $output = str_replace("{VAR_masterserver}",$_SETTINGS['masterserver'],$output);
+  
+  // Go, go, go ;)
+  return $output;
+}
+
+?>
\ No newline at end of file
diff --git a/portal/system/global/functions.php b/portal/system/global/functions.php
new file mode 100644 (file)
index 0000000..2dee11c
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+
+function ExternalRedirect($language="",$target="") {
+  global $_SETTINGS;
+  if ($language == "") {
+    $language = $_SETTINGS['defaultlanguage'];
+  }
+  if ($target == "") {
+    $target = "/index.htm";
+  }
+  header("Location: http://".$_SETTINGS['servername']."/$language$target",true,302);
+  exit;
+}
+
+function GetUserCountry($ip="") {
+  // We'll use the IP-To-Country database from
+  // http://ip-to-country.com/tools/
+  if ($ip == "") {
+    $ip = $_SERVER['REMOTE_ADDR'];
+  }
+  $ip = preg_split( "/[.]+/", $ip);
+  $ipnumber = (double) ($ip[0] * 16777216) + ($ip[1] * 65536) + ($ip[2] * 256) + ($ip[3]);
+  $db = database_connect("portal");
+  $rs = pg_query($db,"SELECT countrycode FROM iptocountry WHERE $ipnumber BETWEEN startip AND endip LIMIT 1");
+  if (pg_num_rows($rs) >= 1) {
+    $row = pg_fetch_array($rs);
+       $countrycode = trim(strtolower($row['countrycode']));
+       if ($countrycode == "gb") {
+         $countrycode = "uk";
+       }
+       return $countrycode;
+  } else {
+    return false;
+  }
+}
+
+function getpct($val, $tot) {
+  if ($val == 0) {
+    $res = 0;
+  } else {
+    $res = (100 / ($tot / $val));
+  }
+  return number_format($res, 3);
+}
+
+function VerifyEmail ($address) {
+  // Check the email address structure
+  if (eregi("^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~ ])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~ ]+\\.)+[a-zA-Z]{2,4}\$", $address) == 0) {
+    return 1;
+  }
+  // Get the user/domain
+  $user = strtok($address,"@");
+  $domain = strtok("") . ".";
+  // Little workaround for the windows testmachine ;)
+  if (!function_exists('getmxrr')) {
+    return 0;
+  }
+  // Check for the domain MX records
+  if (getmxrr($domain, $servers)) {
+    return 0;
+  }
+  // No MX record, so maybe it's a host
+  if (gethostbyname($domain) == $domain) {
+    return 2;
+  } else {
+    return 0;
+  }
+}
+
+function iif($expression,$true,$false="") {
+  if ($expression) {
+    return $true;
+  } else {
+    return $false;
+  }
+}
+
+?>
\ No newline at end of file
diff --git a/portal/system/global/languages.php b/portal/system/global/languages.php
new file mode 100644 (file)
index 0000000..35f4630
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+
+$_LANGUAGES = array(
+  "en" => "English",
+  "de" => "Deutsch"
+);
+
+?>
\ No newline at end of file
diff --git a/portal/system/global/settings.php b/portal/system/global/settings.php
new file mode 100644 (file)
index 0000000..b8be165
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+// clear the $_SETTINGS array
+$_SETTINGS = array();
+
+// some default settings
+$_SETTINGS['servername'] = $_SERVER["SERVER_NAME"];
+$_SETTINGS['masterserver'] = "http://wwwdevel2.postgresql.org";
+$_SETTINGS['defaultlanguage'] = "en";
+$_SETTINGS['notifymail'] = "webmaster@letzplay.de";
+//$_SETTINGS['notifymail'] = "pgsql-www@postgresql.org";
+
+// database settings
+$_SETTINGS['usepersistent'] = false;
+$_SETTINGS['db_portal'] = "dbname=186_portal host=jupiter.hub.org user=186_pgsql";
+$_SETTINGS['db_gborg'] = "dbname=186_gborg host=jupiter.hub.org user=186_gborg";
+
+// clear the $_DONTCACHE array
+$_DONTCACHE = array();
+
+// This pages should be kept dynamic
+$_DONTCACHE['/download.htm'] = true;
+$_DONTCACHE['/mirrors.htm'] = true;
+
+?>
\ No newline at end of file
diff --git a/portal/system/handleform.php b/portal/system/handleform.php
new file mode 100644 (file)
index 0000000..4319eb9
--- /dev/null
@@ -0,0 +1,189 @@
+<?php
+
+// Some needed files
+require("./global/settings.php");
+require("./global/languages.php");
+require("./global/functions.php");
+require("./global/functions.database.php");
+require("./global/functions.language.php");
+require("./global/functions.layout.php");
+
+if (!isset($_REQUEST['action'])) {
+  ExternalRedirect(GetAnyLanguage());
+}
+$action = $_REQUEST['action'];
+
+// If we have a referer like http://www.postgresql.org/en/index.htm
+// change the referrer to /en/index.htm
+if (preg_match("/^http:\/\/([^\/]*)(.*).htm$/",$_SERVER['HTTP_REFERER'])) {
+  $_SERVER['HTTP_REFERER'] = preg_replace("/^http:\/\/([^\/]*)(.*).htm$/","\$2.htm",$_SERVER['HTTP_REFERER']);
+}
+
+// Maybe someone wants to change the language?
+if ($action == "switchlanguage" && isset($_REQUEST['setlanguage']) && isset($_LANGUAGES[$_REQUEST['setlanguage']])) {
+  // Someone has called /system/handler.php?setlanguage=xx
+  // Try to find out where he does come from
+  if (isset($_SERVER['HTTP_REFERER']) && preg_match("/^\/([a-z]{2})\/(.*)\.htm$/",$_SERVER['HTTP_REFERER'])) {
+    ExternalRedirect($_REQUEST['setlanguage'], preg_replace("/^\/([a-z]{2})\/(.*)$/","/\$2", $_SERVER['HTTP_REFERER']));
+  } else {
+    ExternalRedirect($_REQUEST['setlanguage']);
+  }
+  exit;
+}
+
+// We want to vote...
+if ($action == "vote" && intval($_POST['surveyid']) > 0) {
+  if (intval($_POST['answer']) > 0 && intval($_POST['answer']) < 9) {
+    // The answer seems to be okay, check if the visitor has voted before
+    if ($db = database_connect("portal")) {
+      pg_query($db, "DELETE FROM survey_lock WHERE (voted + '00:15:00') < now()");
+      $rs = pg_query($db, "SELECT * FROM survey_lock WHERE ipaddr = '".$_SERVER['REMOTE_ADDR']."'");
+      if (pg_num_rows($rs) == 0) {
+        // Everything seems okay, let's vote now
+        pg_query($db, "UPDATE surveys SET respondants = (respondants + 1), tot".$_POST['answer']." = (tot".$_POST['answer']." + 1) WHERE id = ".$_POST['surveyid']."; INSERT INTO survey_lock (ipaddr) VALUES ('".$_SERVER["REMOTE_ADDR"]."');");
+      }
+    }
+  }
+  ExternalRedirect(GetAnyLanguage($_SERVER['HTTP_REFERER']),"/survey.".$_POST['surveyid'].".htm");
+}
+
+// Comment a documentation entry
+if ($action == 'commentdoc') {
+  $name = $_POST['name'];
+  $email = $_POST['email'];
+  $comment = $_POST['comment'];
+  $version = $_POST['version'];
+  $doc = $_POST['doc'];
+  
+  // Error checking
+  $msg = '';
+  if (strlen($name) < 3) {
+    $msg .= 'Your name must be at least 3 characters long!<br>';
+  }
+  if (strlen($comment) < 10) {
+    $msg .= 'Your comment must be at least 10 characters long!<br>';
+  }
+  if (strlen($email) < 7) {
+    $msg .= 'Your email address must be at least 7 characters long!<br>';
+  }
+  if (intval($version) == 0) {
+    $msg .= "There's no version for the comment!<br>";
+  }
+  if ($doc == '') {
+    $msg .= "There's no chapter for the comment!<br>";
+  }
+  
+  // Insert
+  if ($msg == '') {
+    $email = str_replace('@', ' AT ', $email);
+    $db = database_connect('portal');
+    pg_query($db, "INSERT INTO comments (version, file, comment, posted_by, posted_ip) VALUES ($version::numeric, '$doc', '" . htmlentities(addslashes($comment),ENT_NOQUOTES) . "', '" . htmlentities(addslashes($name . " <" . $email . ">"),ENT_NOQUOTES) . "', '" . $_SERVER['REMOTE_ADDR'] . "')");
+    ExternalRedirect(GetAnyLanguage($_SERVER['HTTP_REFERER']), preg_replace("/^\/([a-z]{2})\/(.*)$/","/\$2", $_SERVER['HTTP_REFERER']));
+  } else {
+    $msg .= '<br>Please press the back button on your browser and try again.';
+    echo $msg;
+    exit;
+  }
+}
+
+// Somebody wants to submit some news or a event
+if ($action == "submission") {
+  
+  // Get the form vars
+  $email = $_POST['email'];
+  $headline = $_POST['headline'];
+  $summary = $_POST['summary'];
+  $story = $_POST['story'];
+  $news = $_POST['news']; 
+  $event = $_POST['event']; 
+
+  //insert in database
+  if (!$db = database_connect("portal")) {
+    echo "Sorry, can't connect to the database. Please try again later.";
+       exit;
+  }
+
+  $msg = "";
+
+  // Check the data
+  if (VerifyEmail($email) != 0) {
+    $msg .= "The email address you entered does not appear to be valid.<br>";
+  }
+
+  if (strlen($headline) < 3 || strlen($headline) > 100) {
+    if ($news) {
+      $msg .= "The headline must be between 3 and 100 characters long.<br>";
+    } else {
+      $msg .= "The event title must be between 3 and 100 characters long.<br>";
+    }
+  }
+
+  if (strlen($summary) < 3 || strlen($summary) > 300) {
+    $msg .= "The summary must be between 3 and 300 characters long.<br>";
+  }
+
+  if (strlen($story) < 3) {
+    if ($news) {
+      $msg .= "The story must be at least 3 characters long.<br>";
+    } else {
+      $msg .= "The event details must be at least 3 characters long.<br>";
+    }
+  }
+  
+  if ($event) {
+    // Date checking for events
+    // Based on code by Devrim <devrim@gunduz.org>
+    $startdate = mktime(0, 0, 0, intval($_POST['start_month']), intval($_POST['start_day']), intval($_POST['start_year']));
+    $enddate = mktime(0, 0, 0, intval($_POST['end_month']), intval($_POST['end_day']), intval($_POST['end_year']));
+    $currentdate = time();
+    if ($enddate < $startdate) {
+      $msg .= "End date cannot be earlier than start date.<br>";
+    }
+    if ($enddate < $currentdate) {
+      $msg .= "End date cannot be earlier than today.<br>";
+    }
+  }
+
+  if (strlen($msg) == 0) {
+    $language = 'en';
+
+    // Get an ID
+    if ($news) {
+
+      // Get an ID
+      $rs = pg_query($db, "SELECT nextval('news_id_seq') AS newid;");
+      $newID = pg_result($rs, 0, "newid");
+      $mailtext = "A new entry has been added to the news database.\n\n";
+      $mailtext .= "Database Admin: http://www.postgresql.org/admin/edit_news.php?".$newID."\n\nSubmitted by: $email\nHeadline: $headline\nSummary:\n\n$summary\n\nStory:\n\n$story\n"; 
+      pg_query($db, "INSERT INTO news (id, posted_by) VALUES ($newID, '$email')");
+         pg_query($db, "INSERT INTO news_text (newsid,headline,summary,story,language) VALUES ($newID,'$headline','$summary','$story','$language')");
+      @mail($_SETTINGS['notifymail'],'New News Entry',$mailtext); 
+
+    } else {
+
+      // Get an ID
+      $rs = pg_query($db, "SELECT nextval('events_id_seq') AS newid;");
+      $newID = pg_result($rs, 0, "newid");
+
+      $mailtext = "A new entry has been added to the events database.\n\n";
+      $mailtext .= "Database Admin: http://www.postgresql.org/admin/edit_event.php?".$newID."\n\nSubmitted by: $email\nEvent: $headline\nSummary:\n\n$summary\n\nDetails:\n\n$story\n"; 
+      pg_query($db, "INSERT INTO events (id, posted_by, start_date, end_date) VALUES ($newID, '$email', '".date("Y-m-d", $startdate)."', '".date("Y-m-d", $enddate)."')");
+      pg_query($db, "INSERT INTO events_text (eventid,event,summary,details,language) VALUES ($newID,'$headline','$summary','$story','$language')");
+      @mail($_SETTINGS['notifymail'],'New Event',$mailtext);
+
+    }
+       ExternalRedirect($language,"/submitthankyou.htm");
+    $msg = "Thank you for your submission. It will be checked and approved if suitable as soon as possible.";
+  } else {
+    $msg .= "<br>Please press the back button on your browser and try again.";
+    echo $msg;
+    exit;
+  }
+  
+}
+
+// It seems we don't have anything to do...
+ExternalRedirect(GetAnyLanguage());
+
+?>
\ No newline at end of file
diff --git a/portal/system/handler.php b/portal/system/handler.php
new file mode 100644 (file)
index 0000000..7993cbb
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+
+// Create some stats (why is the page loading so slow?)
+$pagestarttime = microtime();
+
+// Init
+$url = "";
+$language = false;
+
+// Some needed files
+require("./global/settings.php");
+require("./global/languages.php");
+require("./global/functions.php");
+require("./global/functions.database.php");
+require("./global/functions.language.php");
+require("./global/functions.layout.php");
+
+// Get the url the user has typed into his browser
+if (isset($_SERVER['REQUEST_URI'])) {
+  $url = strtolower(trim($_SERVER['REQUEST_URI']));
+}
+
+if ($url == "" || $url == "/") {
+  // The user went to http://www.postgresql.org directly
+  // Redirect to /xy/index.htm
+  ExternalRedirect(GetAnyLanguage());
+}
+
+// We have a content in $url
+// Let's find out if there's a language in it
+$language = GetLanguageFromUrl($url);
+if (!$language) {
+  // don't have a language string in the url
+  // send the user to a possible page with language string
+  // We don't check if the page is valid to be able to show
+  // a error 404 page in the correct language else...
+  $url = preg_replace("/^\/([a-z]{2})\/(.*)$/","/\$2",$url);
+  ExternalRedirect(GetAnyLanguage(),$url);
+}
+
+// Load the global language variables
+$_LANGUAGE = array();
+if (file_exists("./languages/".$language.".php")) {
+  if ($language != $_SETTINGS['defaultlanguage']) {
+    // First we load the default language (usually en)
+    // and merge it with the language the user has choosen
+    require("./languages/".$_SETTINGS['defaultlanguage'].".php");
+    $defaultlanguagearray = $_LANGUAGE;
+    require("./languages/".$language.".php");
+    $_LANGUAGE = array_merge($defaultlanguagearray,$_LANGUAGE);
+  } else {
+    require("./languages/".$language.".php");
+  }
+} else {
+  require("./languages/".$_SETTINGS['defaultlanguage'].".php");
+}
+// Remember the last Language
+SetLanguageCookie($language);
+// For JOIN-Querys
+$_LANGUAGE['order'] = iif($_LANGUAGE['handler'] > $_SETTINGS['defaultlanguage'], "DESC", "ASC");
+
+// Our language seems to be okay...
+// Let's check the page syntax now.
+if (preg_match("/^\/([a-z]{2})\/([^\/]*)\.htm$/",$url) || preg_match("/^\/([a-z]{2})([\/]?)$/",$url)) {
+  // We have a standard page
+  // /xy/something.htm or /xy/ or /xy
+  require("./page.php");
+} elseif (preg_match("/^\/([a-z]{2})\/documentation\/([^\/]*)\/([a-z]*)\/([^\/]*)\.htm$/",$url)) {
+  // We have a documentation page
+  // /xy/documentation/7.3/static/some-chapter.htm
+  require("./docs.php");
+} else {
+  // No correct page type has been called
+  // Show the error 404 page
+  $url = "/$language/notfound.htm";
+  require("./page.php");
+}
+
+echo $content;
+
+?>
\ No newline at end of file
diff --git a/portal/system/languages/de.php b/portal/system/languages/de.php
new file mode 100644 (file)
index 0000000..6abf1b7
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+
+$_LANGUAGE = array(
+  "handler" => "de",
+  "name" => "Deutsch",
+  "pagetitle" => "PostgreSQL",
+  "banner_sponsor" => "Sponsorenbanner",
+  "banner_project" => "Banner eines PostgreSQL-Projekts",
+  "right_contact" => "Kontaktiere die Webmaster",
+  "right_contact_desc" => "Technische Supportanfragen an diese Adresse werden ignoriert! Bitte benutze die passende Mailingliste. Bitte auf englisch schreiben.",
+  "right_websites" => "Websites",
+  "right_advocacy" => "F&uuml;rsprache",
+  "right_advocacy_desc" => "F&ouml;rderung von PostgreSQL in der Welt.",
+  "right_gborg" => "GBorg-Projekte",
+  "right_gborg_desc" => "Projekte, die mit PostgreSQL zu Tun haben, können hier ein Zuhause finden. Bugtracker, CVS, FTP-Speicherplatz und mehr f&uuml;r Dein PostgreSQL-Projekt.",
+  "right_lists" => "Mailinglisten-Archive",
+  "right_lists_desc" => "Komplettes durchsuchbare Archive unserer &ouml;ffentlichen Mailinglisten",
+  "right_techdocs" => "Techdocs",
+  "right_techdocs_desc" => "Technische Dokumente, Howtos, White Papers und viel, viel mehr.",
+  "right_bugs" => "Bugreports",
+  "right_bugs_desc" => "Melde Bugs in PostgreSQL.",
+  "right_language" => "Sprache",
+  "right_language_desc" => "Diese Website in",
+  "left_about" => "&Uuml;ber uns",
+  "left_about_desc" => "Finde mehr &uuml;ber PostgreSQL heraus.",
+  "left_licence" => "Lizenz",
+  "left_licence_desc" => "PostgreSQL wird unter der flexiblen BSD-Lizenz vertrieben.",
+  "left_casestudies" => "Fallstudien",
+  "left_casestudies_desc" => "Details &uuml;ber einige bekannte Projekte, die PostgreSQL nutzen.",
+  "left_poll" => "Umfrage",
+  "left_poll_submit" => "Abstimmen",
+  "left_poll_results" => "Ergebnis zeigen",
+  "left_gborg_stats" => "Aktuelle Statistik",
+  "left_gborg_projects" => "Projekte",
+  "left_gborg_users" => "Benutzer",
+  "left_gborg_top" => "Top 5 Projekte",
+  "link_download" => "Herunterladen",
+  "link_mirrors" => "Mirrors",
+  "link_mailinglists" => "Mailinglisten",
+  "link_userslounge" => "Benutzer",
+  "link_userslounge_long" => "Benutzerecke",
+  "link_developer" => "Hacker",
+  "link_developer_long" => "Hackererecke",
+  "link_docs" => "Doku",
+  "link_docs_long" => "Dokumentation",
+  "link_search" => "Suche",
+  "link_top" => "Nach oben",
+  "link_store" => "Shop",
+  "docs_title" => "PostgreSQL.org Dokumentation",
+  "docs_search" => "Suchen!",
+  "docs_search_desc" => "Durchsuche diese Dokumentation:"
+);
+
+?>
\ No newline at end of file
diff --git a/portal/system/languages/en.php b/portal/system/languages/en.php
new file mode 100644 (file)
index 0000000..a489932
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+
+$_LANGUAGE = array(
+  "handler" => "en",
+  "name" => "English",
+  "pagetitle" => "PostgreSQL",
+  "banner_sponsor" => "Sponsor Banner Advertisment",
+  "banner_project" => "Project Banner Advertisment",
+  "right_contact" => "Contact the Webmasters",
+  "right_contact_desc" => "Tech Support requests to this address will be ignored! Please use the appropriate mailing list.",
+  "right_websites" => "Websites",
+  "right_advocacy" => "Advocacy",
+  "right_advocacy_desc" => "Promoting PostgreSQL to the world.",
+  "right_gborg" => "GBorg Projects",
+  "right_gborg_desc" => "PostgreSQL related projects can find a home here at Gborg. Bug tracking, CVS, ftp space and much more for your PostgreSQL related project.",
+  "right_lists" => "Mailing list archives",
+  "right_lists_desc" => "Complete searchable archives of the public mailing lists.",
+  "right_techdocs" => "Techdocs",
+  "right_techdocs_desc" => "Technical documents, howtos, white papers and much, much more.",
+  "right_bugs" => "Bug Reporting",
+  "right_bugs_desc" => "Report a bug in PostgreSQL.",
+  "right_language" => "Language",
+  "right_language_desc" => "This website in",
+  "left_about" => "What is...",
+  "left_about_desc" => "Find out more about what PostgreSQL is.",
+  "left_licence" => "Licence",
+  "left_licence_desc" => "PostgreSQL is distributed under the flexible BSD licence.",
+  "left_casestudies" => "Case studies",
+  "left_casestudies_desc" => "Check out the details of some well known projects that use PostgreSQL.",
+  "left_poll" => "User Survey",
+  "left_poll_submit" => "Submit",
+  "left_poll_results" => "Results",
+  "left_gborg_stats" => "Current statistics",
+  "left_gborg_projects" => "Projects",
+  "left_gborg_users" => "Users",
+  "left_gborg_top" => "Top 5 projects",
+  "link_download" => "Download",
+  "link_mirrors" => "Mirrors",
+  "link_mailinglists" => "Mailing Lists",
+  "link_userslounge" => "Users",
+  "link_userslounge_long" => "User's Lounge",
+  "link_developer" => "Developers",
+  "link_developer_long" => "Developers Corner",
+  "link_docs" => "Docs",
+  "link_docs_long" => "Documentation",
+  "link_search" => "Search",
+  "link_top" => "Top",
+  "link_store" => "Store",
+  "docs_title" => "PostgreSQL.org documentation",
+  "docs_search" => "Search!",
+  "docs_search_desc" => "Search this document set:"
+);
+
+?>
\ No newline at end of file
diff --git a/portal/system/layout/basic.bottom.php b/portal/system/layout/basic.bottom.php
new file mode 100644 (file)
index 0000000..46b07b9
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+$bottom = '                <table width="100%" border=0 cellpadding=0 cellspacing=0 bgcolor="#6884A4">
+                  <tr>
+                    <td>
+                      <table width="100%" border=0 cellpadding=0 cellspacing=0 bgcolor="#6884A4">
+                        <tr>
+                          <td align=left>
+                            <small>&nbsp;<a href="#TOP"><font style="color: #FFFFFF;font-size: x-small">{LNG_link_top}</font></a></small>
+                          </td>
+                          <td align=right>
+                            <a href="{VAR_masterserver}/{LNG_handler}/download.htm" style="color: #FFFFFF;font-size: x-small">{LNG_link_download}</a><font color="#CDDDEB">&nbsp;&middot;</font>
+                            <a href="{VAR_masterserver}/{LNG_handler}/mirrors.htm" style="color: #FFFFFF;font-size: x-small">{LNG_link_mirrors}</a><font color="#CDDDEB">&nbsp;&middot;</font>
+                            <a href="/{LNG_handler}/lists.htm" style="color: #FFFFFF;font-size: x-small">{LNG_link_mailinglists}</a><font color="#CDDDEB">&nbsp;&middot;</font>                   
+                            <a href="/{LNG_handler}/users-lounge.htm" style="color: #FFFFFF;font-size: x-small">{LNG_link_userslounge_long}</a><font color="#CDDDEB">&nbsp;&middot;</font> 
+                            <a href="http://developer.postgresql.org/" style="color: #FFFFFF;font-size: x-small">{LNG_link_developer_long}</a><font color="#CDDDEB">&nbsp;&middot;</font> 
+                            <a href="/{LNG_handler}/documentation.htm" style="color: #FFFFFF;font-size: x-small">{LNG_link_docs_long}</a><font color="#CDDDEB">&nbsp;&middot;</font> 
+                            <a href="{VAR_masterserver}/search.cgi" style="color: #FFFFFF;font-size: x-small">{LNG_link_search}</a><font color="#CDDDEB">&nbsp;&middot;</font>
+                            <a href="http://store.pgsql.com" style="color: #FFFFFF;font-size: x-small">{LNG_link_store}</a>&nbsp;
+                            &nbsp;
+                          </td>
+                        </tr>
+                      </table>
+                    </td>
+                  </tr>
+                </table>
+              </td>
+            </tr>
+          </table>
+        </td>
+      </tr>
+    </table>
+    </center>
+    <p align="center">Page generated in {VAR_pagestats} seconds.</p>
+  </body>
+</html>';
+
+?>
\ No newline at end of file
diff --git a/portal/system/layout/basic.left.php b/portal/system/layout/basic.left.php
new file mode 100644 (file)
index 0000000..f3a2f90
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+
+$left = '                <table width="100%" cellpadding=0 cellspacing=0 border=0 bgcolor="#FFFFFF">
+                  <tr>
+                    <td valign=top width=120>
+                                         <table width="120" cellspacing=3 cellpadding=3>
+                                           <!-- What is... -->
+                                               <tr>
+                                                 <td bgcolor="#CDDDEB">
+                                                   <center><b><a href="http://advocacy.postgresql.org/about/?lang={LNG_handler}" style="font-weight: bold; color: #020169"><font size=-1>{LNG_left_about}</font></a></b></center><br>
+                                                       <font size=-1>{LNG_left_about_desc}</font><br><br>
+                                               </td>
+                                       </tr>
+                                       <!-- Licence -->
+                                       <tr>
+                                         <td bgcolor="#CDDDEB">
+                                           <center><b><a href="/{LNG_handler}/licence.htm" style="font-weight: bold; color: #020169"><font size=-1>{LNG_left_licence}</font></a></b></center><br>
+                                               <font size=-1>{LNG_left_licence_desc}</font><br><br>
+                                         </td>
+                                       </tr>
+                                       <!-- Case studies -->
+                                       <tr>
+                                         <td bgcolor="#CDDDEB">
+                                           <center><b><a href="http://advocacy.postgresql.org/casestudies/?lang={LNG_handler}" style="font-weight: bold; color: #020169"><font size=-1>{LNG_left_casestudies}</font></a></b></center><br>
+                                               <font size=-1>{LNG_left_casestudies_desc}</font><br><br>
+                                         </td>
+                                       </tr>
+                                       <!-- Survey -->
+                                       <tr>
+                                         <td bgcolor="#CDDDEB" align=left>
+                                           <center><font color="#020169" size=-1><b>{LNG_left_poll}</b></font></center><br><font size=-1>';
+
+  $db = database_connect("portal");
+
+  if (!$db) {
+    $left .= 'Database server down';
+  } else {
+    $rs = pg_query($db, "SELECT q.*, s.id FROM surveys s, survey_questions q WHERE s.current=true AND q.language IN ('".$_LANGUAGE['handler']."','".$_SETTINGS['defaultlanguage']."') AND s.id=q.surveyid ORDER BY q.language ".$_LANGUAGE['order']." LIMIT 1");
+       $result = pg_fetch_array($rs);
+       // Display the question
+       $left .= $result['question']."\n<br><br>";
+       // Start voting form
+    $left .= '<form action="{VAR_masterserver}/system/handleform.php" method="post" style="margin-bottom: 0;"><input type="hidden" name="action" value="vote"><input type="hidden" name="surveyid" value="'.$result['id'].'">';
+       // Display the possible responses
+       $left .= iif($result['opt1'] != "", "<input type=radio name=answer value=1><small>".$result['opt1']."</small><br>\n");
+       $left .= iif($result['opt2'] != "", "<input type=radio name=answer value=2><small>".$result['opt2']."</small><br>\n");
+       $left .= iif($result['opt3'] != "", "<input type=radio name=answer value=3><small>".$result['opt3']."</small><br>\n");
+       $left .= iif($result['opt4'] != "", "<input type=radio name=answer value=4><small>".$result['opt4']."</small><br>\n");
+       $left .= iif($result['opt5'] != "", "<input type=radio name=answer value=5><small>".$result['opt5']."</small><br>\n");
+       $left .= iif($result['opt6'] != "", "<input type=radio name=answer value=6><small>".$result['opt6']."</small><br>\n");
+       $left .= iif($result['opt7'] != "", "<input type=radio name=answer value=7><small>".$result['opt7']."</small><br>\n");
+       $left .= iif($result['opt8'] != "", "<input type=radio name=answer value=8><small>".$result['opt8']."</small><br>\n");
+       // Close the voting form
+       $left.='<br><center><input type="submit" name="submit" value="{LNG_left_poll_submit}"></center></form><center>';
+       $left.="<a href=\"/{LNG_handler}/survey.".$result['id'].".htm\" style=\"font-size: x-small; color: #020169\">{LNG_left_poll_results}</a>";
+}
+
+$left .= '
+</font></center><br>
+</td>
+</tr>
+
+<!-- Gborg -->
+
+<tr>
+<td bgcolor="#CDDDEB" align=left>
+<center><b><a href="http://gborg.postgresql.org/" style="font-weight: bold; color: #020169"><font size=-1>GBorg</font></a></b></center><br>
+<font size=-1>
+{LNG_left_gborg_stats}:<br><br>';
+
+if (!$db = database_connect("gborg")) {
+  $left .= 'Connection to gborg database failed.';
+} else {
+
+  // Projects
+  $rs = pg_query($db, "SELECT count(*) AS count FROM project WHERE approved = TRUE;");
+  $result = pg_fetch_array($rs);
+  $left .= '&middot; {LNG_left_gborg_projects}: '.$result['count'].'<br>';
+
+  // Users
+  $rs = pg_query($db, "SELECT count(*) AS count FROM member WHERE confirmed = TRUE;");
+  $result = pg_fetch_array($rs);
+  $left .= '&middot; {LNG_left_gborg_users}: '.$result['count'].'<br>';
+  
+  $left .= '<br>{LNG_left_gborg_top}:<br><br>';
+
+  // Top Projects
+  $rs = pg_query($db, "SELECT project_name, project_title FROM project WHERE approved = true AND rank IS NOT NULL ORDER BY rank DESC LIMIT 5;");
+  while($result = pg_fetch_array($rs)){
+    $left .= '<a href="http://gborg.postgresql.org/project/'.$result['project_name'].'/projdisplay.php" style="font-size: x-small; color: #020169;">'.$result['project_name'].'</a><br><table width="100%"><tr><td width="10%">&nbsp;</td><td><font size="-2">'.$result['project_title'].'</font></td></tr></table><br>';
+  } // while
+
+}
+
+$left.='
+</font>
+</td>
+</tr>
+
+</table>
+
+<!-- end left bar -->';
+
+
+$left .= '                    </td>
+                    <td valign=top width="100%">
+                                         <br>';
+
+?>
\ No newline at end of file
diff --git a/portal/system/layout/basic.right.php b/portal/system/layout/basic.right.php
new file mode 100644 (file)
index 0000000..a4849f4
--- /dev/null
@@ -0,0 +1,157 @@
+<?php
+
+reset($_LANGUAGES);
+$lng_options = "";
+while(list($lng_handler, $lng_title) = each($_LANGUAGES)){
+  $lng_options .= "<option value=\"$lng_handler\"".iif($lng_handler==$language," selected").">$lng_title</option>\n";
+} // while
+reset($_LANGUAGES);
+
+$right = '                  <br><br>
+                    </td>
+                    <td valign=top width=120>
+                      <table width=120 border=0 cellspacing=3 cellpadding=3>
+                        <!-- Language chooser -->
+                        <tr>
+                          <td bgcolor="#CDDDEB">
+                            <center>
+                                                         <font size=-1 color=#020169><b>{LNG_right_language}</b></font>
+                                                       </center>
+                            <table border=0 cellspacing=0 cellpadding=0>
+                              <tr><td colspan=2>&nbsp;</td></tr>
+                              <tr>
+                                                           <td width="10%">&nbsp;</td>
+                                <td>
+                                                                 <form name="lngform" action="{VAR_masterserver}/system/handleform.php" method="post">
+                                                                   <p><font size=-1>{LNG_right_language_desc}<br>
+                                                                         <input type="hidden" name="action" value="switchlanguage">
+                                                         <select name="setlanguage" onchange="document.lngform.submit();">
+                                        '.$lng_options.'
+                                      </select>
+                                                                   </font></p>
+                                                                 </form>
+                                                           </td>
+                              </tr>
+                            </table>
+                          </td>
+                        </tr>
+                        <!-- Contact us -->
+                        <tr>
+                          <td bgcolor="#CDDDEB">
+                            <center><b><a href="mailto:webmaster@postgresql.org" style="font-weight: bold; color: #020169"><font size=-1>{LNG_right_contact}</font></a></b><br><br><font size=-1>{LNG_right_contact_desc}<br></font></center>
+                          </td>
+                        </tr>
+                        <!-- Websites -->
+                        <tr>
+                          <td bgcolor="#CDDDEB">
+                            <center>
+                                                         <font size=-1 color=#020169><b>{LNG_right_websites}</b></font>
+                                                       </center>
+                            <table border=0 cellspacing=0 cellpadding=0>
+                              <tr><td colspan=2>&nbsp;</td></tr>
+                              <tr>
+                                <td align=left colspan=2><a href="http://advocacy.postgresql.org/?lang={LNG_handler}" style="font-size: x-small; color: #020169;">{LNG_right_advocacy}</a></td>
+                              </tr>
+                              <tr>
+                                <td width="10%"> &nbsp </td>
+                                <td><font size=-1>{LNG_right_advocacy_desc}</font></td>
+                              </tr>
+                              <tr><td colspan=2>&nbsp;</td></tr>
+                              <tr>
+                                <td align=left colspan=2><a href="http://gborg.postgresql.org/" style="font-size: x-small; color: #020169;">{LNG_right_gborg}</a></td>
+                              </tr>
+                              <tr>
+                                <td width="10%">&nbsp;</td>
+                                <td><font size=-1>{LNG_right_gborg_desc}</font></td>
+                              </tr>
+                              <tr><td colspan=2>&nbsp;</td></tr>
+                              <tr>
+                                <td align=left colspan=2><a href="http://archives.postgresql.org/" style="font-size: x-small; color: #020169;">{LNG_right_lists}</a></td>
+                              </tr>
+                              <tr>
+                                <td width="10%">&nbsp;</td>
+                                <td><font size=-1>{LNG_right_lists_desc}</font></td>
+                              </tr>
+                              <tr><td colspan=2>&nbsp;</td></tr>
+                              <tr>
+                                <td align=left colspan=2><a href="http://techdocs.postgresql.org/" style="font-size: x-small; color: #020169;">{LNG_right_techdocs}</a></td>
+                              </tr>
+                              <tr>
+                                <td width="10%">&nbsp;</td>
+                                <td><font size=-1>{LNG_right_techdocs_desc}</font></td>
+                              </tr>
+                              <tr><td colspan=2>&nbsp;</td></tr>
+                              <tr>
+                                <td align=left colspan=2><a href="http://www.ca.postgresql.org/bugs/bugs.php" style="font-size: x-small; color: #020169;">{LNG_right_bugs}</a></td>
+                              </tr>
+                              <tr>
+                                <td width="10%">&nbsp;</td>
+                                <td><font size=-1>{LNG_right_bugs_desc}</font></td>
+                              </tr>
+                            </table>
+                            <br>
+                          </td>
+                        </tr>
+                        <!-- Start of International Websites section -->
+                        <tr>
+                          <td bgcolor="#CDDDEB">
+  <center><font size="-1" color="#020169"><b>International</b></font></center>
+  <table border="0" cellspacing="0" cellpadding="0">
+   <tr><td colspan="2">&nbsp;</td></tr>
+   <tr>
+    <td align=left colspan="2"><a href="http://pgsqlbr.querencialivre.rs.gov.br/" style="font-size: x-small; color: #020169;">Brazilian</a></td>
+   </tr>
+   <tr>
+    <td width="10%"> &nbsp </td>
+    <td><font size="-1">O centro de informa&ccedil;&otilde;es para os usu&aacute;rios brasileiros</font></td>
+   </tr>
+   <tr><td colspan="2">&nbsp;</td></tr>
+   <tr>
+    <td align=left colspan="2"><a href="http://www.pgsqldb.org/" style="font-size: x-small; color: #020169;">Chinese</a></td>
+   </tr>
+   <tr>
+    <td width="10%"> &nbsp </td>
+    <td><font size="-1">The Chinese PostgreSQL Community</font></td>
+   </tr>
+   <tr><td colspan="2">&nbsp;</td></tr>
+   <tr>
+    <td align=left colspan="2"><a href="http://www.postgres.de/" style="font-size: x-small; color: #020169;">Deutsch</a></td>
+   </tr>
+   <tr>
+    <td width="10%"> &nbsp </td>
+    <td><font size="-1">Die Deutsche PostgreSQL Seite</font></td>
+   </tr>
+   <tr><td colspan="2">&nbsp;</td></tr>
+   <tr>
+    <td align=left colspan="2"><a href="http://www.postgresql.cl/" style="font-size: x-small; color: #020169;">Espa&ntilde;ol</a></td>
+   </tr>
+   <tr>
+    <td width="10%">&nbsp;</td>
+    <td><font size="-1">La comunidad en Espa&ntilde;ol de PostgreSQL</font></td>
+   </tr>
+   <tr><td colspan="2">&nbsp;</td></tr>
+   <tr>
+    <td align="left" colspan="2"><a href="http://www.postgresql.jp/" style="fpnt-size: x-small; color: #020169;">Japanese</a></td>
+   </tr>
+   <tr>
+    <td width="10%">&nbsp;</td>
+    <td><font size="-1">The Japanese PostgreSQL Community</font></td>
+   </tr>
+   <tr><td colspan="2">&nbsp;</td></tr>
+   <tr>
+    <td align=left colspan="2"><a href="http://www.linuxshare.ru/docs/software/SQL/postgresql/index.html" style="font-size: x-small; color: #020169;">Россия</a></td>
+   </tr>
+   <tr>
+    <td width="10%"> &nbsp </td>
+    <td><font size="-1">Информация о PostgreSQL на русском языке</font></td>
+   </tr>
+  </table>
+                            <br>
+                          </td>
+                        </tr>
+                      </table>
+                    </td>
+                  </tr>
+                </table>';
+
+?>
\ No newline at end of file
diff --git a/portal/system/layout/basic.top.php b/portal/system/layout/basic.top.php
new file mode 100644 (file)
index 0000000..72b0c38
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+$top = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+
+<head>
+  <title>{LNG_pagetitle}</title>
+  <meta http-equiv="Expires" content="Mon, 06 Jan 1990 00:00:01 GMT">
+  <meta http-equiv="Pragma" content="no-cache">
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <meta name="Author" content="Dave Page">
+  <meta name="keyword" content="PostgreSQL, database, dbms, postgres, postgres95, pgsql, relational, SQL, ODBC, JDBC"> 
+  <link rel="stylesheet" href="/layout/css/postgresql.css" type="text/css">
+</head>
+
+<body>
+  <a name="TOP"></a>
+  <p>&nbsp;</p>
+  <center>
+    <table width="95%" border=0 cellspacing=0 cellpadding=2 bgcolor="#000000">
+      <tr>
+        <td>
+          <table width="100%" border=0 cellpadding=0 cellspacing=0 bgcolor="#FFFFFF">
+            <tr>
+              <td>
+                <table width="100%" cellpadding=0 cellspacing=0 border=0>
+                  <tr>
+                    <!-- Ad -->
+                    <td align=center rowspan=2 bgcolor="#FFFFFF" width=126 height=120><a href="http://ads.hub.org/redirect.php?lvl=sponsor" TARGET="_banner"><img src="http://ads.hub.org/display_image.php?lvl=sponsor" border=0 alt="{LNG_banner_sponsor}" width=120 height=120></a></td>
+                    <!-- End Ad -->
+                    <!-- Banner -->
+                    <td rowspan=1 bgcolor="#6884A4" width="100%" background="/layout/images/banner-background.jpg"><a href="/{LNG_handler}/index.htm"><img src="/layout/images/banner-left.jpg" alt="PostgreSQL Banner" border=0 width="186" height="95"></a></td>
+                    <td rowspan=2 bgcolor="#6884A4" width="120" align="right"><a href="/{LNG_handler}/index.htm"><img src="/layout/images/banner-right.jpg" alt="PostgreSQL Banner" border=0 width=120 height=120></a></td>
+                    <!-- End Banner -->
+                    <!-- Ad -->
+                    <td align=center rowspan=2 bgcolor="#FFFFFF" width=126 height=120><a href="http://ads.hub.org/redirect.php?lvl=free" TARGET="_banner"><img src="http://ads.hub.org/display_image.php?lvl=free" border=0 alt="{LNG_banner_project}" width=120 height=120></a></td>
+                    <!-- End Ad -->
+                  </tr>   
+                  <tr>
+                    <td align=left bgcolor="#6884A4" nowrap height=25> 
+                      &nbsp;
+                      <a href="{VAR_masterserver}/{LNG_handler}/download.htm" style="font-size:x-small; color: #FFFFFF;">{LNG_link_download}</a><font color="#CDDDEB">&nbsp;&middot;</font>
+                      <a href="{VAR_masterserver}/{LNG_handler}/mirrors.htm" style="font-size:x-small; color: #FFFFFF;">{LNG_link_mirrors}</a><font color="#CDDDEB">&nbsp;&middot;</font>
+                      <a href="/{LNG_handler}/lists.htm" style="font-size:x-small; color: #FFFFFF;">{LNG_link_mailinglists}</a><font color="#CDDDEB">&nbsp;&middot;</font>
+                      <a href="/{LNG_handler}/users-lounge.htm" style="font-size:x-small; color: #FFFFFF;">{LNG_link_userslounge}</a><font color="#CDDDEB">&nbsp;&middot;</font>
+                      <a href="http://developer.postgresql.org/" style="font-size:x-small; color: #FFFFFF;">{LNG_link_developer}</a><font color="#CDDDEB">&nbsp;&middot;</font>
+                      <a href="/{LNG_handler}/documentation.htm" style="font-size:x-small; color: #FFFFFF;">{LNG_link_docs}</a><font color="#CDDDEB">&nbsp;&middot;</font>
+                      <a href="{VAR_masterserver}/search.cgi" style="font-size:x-small; color: #FFFFFF;">{LNG_link_search}</a>
+                    </td>
+                  </tr>
+                </table>';
+
+?>
\ No newline at end of file
diff --git a/portal/system/layout/docs.left.php b/portal/system/layout/docs.left.php
new file mode 100644 (file)
index 0000000..ecd706d
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+$left = '<table width="100%" cellpadding=0 cellspacing=3 border=0 bgcolor="#FFFFFF">
+  <tr>
+    <td valign=top width="100%">
+                
+<!-- end header -->
+
+<!-- content -->
+
+<center>
+<FORM METHOD=GET ACTION="http://www.postgresql.org/search.cgi"><input type="hidden" name="ul" value="http://www.postgresql.org/documentation/'.$version.'/'.$type.'/"><table bgcolor="#6884A4" border=0 cellpadding=2 width="100%">
+<tr><td align=center bgcolor="#CDDDEB">
+{LNG_docs_search_desc} <INPUT TYPE="text" NAME="q" SIZE=50>
+<INPUT TYPE="submit" VALUE="{LNG_docs_search}"><BR>
+</td></tr>
+</table>
+</form>
+</center>
+
+';
+
+?>
\ No newline at end of file
diff --git a/portal/system/layout/docs.right.php b/portal/system/layout/docs.right.php
new file mode 100644 (file)
index 0000000..5771f92
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+
+$right = '      <br />
+    </td>
+  </tr>
+</table>';
+
+?>
\ No newline at end of file
diff --git a/portal/system/page.php b/portal/system/page.php
new file mode 100644 (file)
index 0000000..96c1cd4
--- /dev/null
@@ -0,0 +1,293 @@
+<?php
+
+// we know the $url must have the format /xy/{whatwewant}.htm
+preg_match("/^\/$language\/([^\/]*)\.htm$/",$url,$pagearray);
+$page = $pagearray[1];
+if ($page == "") {
+  $page = "index";
+}
+
+$page = explode(".",$page);
+
+// check it it's a static page
+$pagetype = "";
+switch($page[0]){
+       case "index":
+               $pagetype = "newsandevents";
+               break;
+       case "news":
+           $pagetype = "newsdetails";
+               break;
+       case "event":
+           $pagetype = "eventdetails";
+       break;
+               case "newsarchive":
+               $pagetype = "newsarchive";
+       break;
+               case "eventarchive":
+               $pagetype = "eventarchive";
+               break;
+       case "download":
+               $pagetype = "mirrors";
+               $mirrortype = "ftp";
+               break;
+       case "mirrors":
+               $pagetype = "mirrors";
+               $mirrortype = "www";
+               break;
+       case "survey":
+           $pagetype = "survey";
+               break;
+       default:
+               $pagetype = "static";
+} // switch
+
+// Get the content
+$pagecontent = "";
+if ($pagetype == "static") {
+  // Just a simple, stativ apge ;)
+  $pageinfo = LoadStaticPage($page[0], $language);
+  $pagecontent = $pageinfo['content'];
+  if ($pageinfo['title'] != "") {
+    // We have a title, let's tweak the language array a bit
+       $_LANGUAGE['pagetitle'] .= ": ".$pageinfo['title'];
+  }
+} elseif ($pagetype == "newsandevents") {
+  if (!$db = database_connect("portal")) {
+    $pagecontent = "The news database server is currently down.";
+  } else {
+    $news = "";
+       $rs = pg_query($db, "SELECT id, posted, posted_by FROM news WHERE active = TRUE AND approved = TRUE ORDER BY posted DESC");
+       while($newsitem = pg_fetch_array($rs)){
+         $details = pg_query($db, "SELECT headline, summary FROM news_text WHERE newsid=".$newsitem['id']." AND language IN ('".$_LANGUAGE['handler']."','".$_SETTINGS['defaultlanguage']."') ORDER BY language ".$_LANGUAGE['order']." LIMIT 1");
+         // Make sure there's a translation in english or in the language the user selected...
+         if (pg_num_rows($details) > 0) {
+           $detail = pg_fetch_array($details);
+               $news .= LoadTemplate("index_news", $language, array("id" => $newsitem['id'], "poster" => $newsitem['posted_by'], "date" => $newsitem['posted'], "summary" => $detail['summary'], "headline" => $detail['headline']));
+         }
+       } // while
+    $events = "";
+       $rs = pg_query($db, "SELECT id, posted, posted_by, start_date, end_date FROM events WHERE active = TRUE AND approved = TRUE ORDER BY posted DESC");
+       while($eventitem = pg_fetch_array($rs)){
+         $details = pg_query($db, "SELECT event, summary FROM events_text WHERE eventid=".$eventitem['id']." AND language IN ('".$_LANGUAGE['handler']."','".$_SETTINGS['defaultlanguage']."') ORDER BY language ".$_LANGUAGE['order']." LIMIT 1");
+         // Make sure there's a translation in english or in the language the user selected...
+         if (pg_num_rows($details) > 0) {
+           $detail = pg_fetch_array($details);
+           if ($eventitem['start_date'] == '') {
+             // No date given
+             $date = '';
+           } elseif ($eventitem['end_date'] != '' && $eventitem['end_date'] != $eventitem['start_date']) {
+             // We have an enddate and it's not the startdate
+             $date = LoadTemplate('index_event_twodates', $language, array('startdate' => $eventitem['start_date'], 'enddate' => $eventitem['end_date']));
+           } else {
+             // We do only have a startdate
+             $date = LoadTemplate('index_event_onedate', $language, array('date' => $eventitem['start_date']));
+           }
+               $events .= LoadTemplate("index_event", $language, array("id" => $eventitem['id'], "date" => $date, "poster" => $eventitem['posted_by'], "summary" => $detail['summary'], "headline" => $detail['event']));
+         }
+       } // while
+    $pagecontent = LoadTemplate("index", $language, array("news" => $news, "events" => $events));
+  }
+} elseif ($pagetype == "mirrors") {
+  $numcells = 5;
+  if (!$db = database_connect("portal")) {
+    $pagecontent = LoadTemplate("nomirrorfound", $language);
+  } else {
+       //$rs = @pg_query($db, "SELECT 'ftp' || mirror_index::text || '.' || country_code || '.postgresql.org' AS hostname, host_port AS port, host_path AS path, country_name AS country, country_code AS countrycode FROM mirrors WHERE mirror_type = 'ftp' AND mirror_active = TRUE AND mirror_private = FALSE ORDER BY country_name, mirror_index;");
+       //$rs = @pg_query($db, "select s.hostname,lower(h.country),s.mirrorwhat,directory,h.countrycode from mirrorsites s, mirrorhosts h  where s.mirrorwhat='$mirrortype' and s.active = 'on' and s.lastrsync > (now() - '48 hrs'::interval) and s.maintmode = 'no' and s.mirrorhostid = h.mirrorhostid order by s.mirrorwhat,h.country,s.hostname");
+       $urltype = iif($mirrortype=="www","http","ftp");
+       $rs = pg_query($db, "SELECT '$mirrortype' || CASE WHEN mirror_index = 0 THEN ''::text ELSE mirror_index::text END || '.' || country_code || '.postgresql.org' AS hostname, host_port AS port, host_path AS path, country_name AS country, country_code FROM mirrors WHERE mirror_type = '$mirrortype' AND mirror_active = TRUE AND mirror_private = FALSE AND mirror_dns = TRUE AND mirror_last_rsync > (now() - '48 hrs'::interval) ORDER BY country_name, mirror_index;");
+       if (!$rs || pg_num_rows($rs) == 0) {
+         $pagecontent = LoadTemplate("nomirrorfound", $language);
+       } else {
+         $usercountry = GetUserCountry();
+         $std_col = 5;
+         $std_content = "<p><table border=0 width=100%>";
+         $near_col = 5;
+         $near_content = "<p><table border=0 width=100%>";
+         $has_near = false;
+         while($mirror = pg_fetch_array($rs)){
+                 $img = str_replace(" ","",$mirror['country']).".gif";
+                 $url = $urltype.'://'.$mirror['hostname'].iif(intval($mirror['port']) > 0, ":$mirror[port]", '').$mirror['path'];
+               if ($usercountry && $mirror['country_code'] == $usercountry) {
+                 if ($near_col == 5) {
+                   // begin a new row
+                   $near_content .= "<tr>";
+                   $near_col = 0;
+                 }
+                 // add cell
+          $near_content .= "<td width=\"20%\" align=center nowrap><a href=\"$url\"><img src=\"/layout/images/flags/$img\" border=1 alt=\"".ucwords($mirror['country'])."\" width=\"32\" height=\"21\"><br>" . ucwords($mirror['country']) . "</a><br>&nbsp;</td>\n";
+                 if ($near_col == 4) {
+                   // end row
+                   $near_content .= "</tr>";
+                 }
+          $near_col++;
+                 $has_near = true;
+           } else {
+                 if ($std_col == 5) {
+                   // begin a new row
+                   $std_content .= "<tr>";
+                   $std_col = 0;
+                 }
+                 // add cell
+          $std_content .= "<td width=\"20%\" align=center nowrap><a href=\"$url\"><img src=\"/layout/images/flags/$img\" border=1 alt=\"".ucwords($mirror['country'])."\" width=\"32\" height=\"21\"><br>" . ucwords($mirror['country']) . "</a><br>&nbsp;</td>\n";
+                 if ($std_col == 4) {
+                   // end row
+                   $std_content .= "</tr>";
+                 }
+          $std_col++;
+               }
+         } // while
+         if ($std_col < 5) {
+           for ($i=0; $i<5-$std_col; $i++) {
+                 $std_content .= "<td>&nbsp;</td>";
+               }
+         }
+         if ($has_near && $near_col < 5) {
+           for ($i=0; $i<5-$near_col; $i++) {
+                 $near_content .= "<td>&nbsp;</td>";
+               }
+         }
+         $std_content .= "</table></p>";
+         $near_content .= "</table></p>";
+         if ($has_near) {
+           $std_content = LoadTemplate("download_near", $language, array("nearmirrors" => $near_content)).$std_content;
+         }
+         $pagecontent = LoadTemplate("download", $language, array("content" => $std_content));
+       }
+  }
+} elseif ($pagetype == "newsdetails") {
+  $newsid = intval($page[1]);
+  if ($newsid <= 0) {
+    ExternalRedirect($language, "/index.htm");
+  }
+  if (!$db = database_connect("portal")) {
+    $pagecontent = "Sorry, could not connect to the news database";
+  }
+  $rs = pg_exec($db, "SELECT n.posted, n.posted_by, t.headline, t.summary, t.story FROM news n, news_text t WHERE n.approved = TRUE AND n.id=$newsid AND n.id=t.newsid AND t.language IN ('".$_LANGUAGE['handler']."','".$_SETTINGS['defaultlanguage']."') ORDER BY t.language ".$_LANGUAGE['order']." LIMIT 1");
+  if (pg_num_rows($rs) <= 0) {
+    $pagecontent = "Sorry, this news could not be found.";
+  } else {
+    $newsdetails = pg_fetch_array($rs);
+       $story = nl2br(iif($newsdetails['story']!="", $newsdetails['story'], $newsdetails['summary']));
+       $pagecontent = LoadTemplate("news", $language, array("headline" => $newsdetails['headline'], "date" => $newsdetails['posted'], "poster" => $newsdetails['posted_by'], "story" => $story));
+  }
+} elseif ($pagetype == "eventdetails") {
+  $eventid = intval($page[1]);
+  if ($eventid <= 0) {
+    ExternalRedirect($language, "/index.htm");
+  }
+  if (!$db = database_connect("portal")) {
+    $pagecontent = "Sorry, could not connect to the event database";
+  }
+  $rs = pg_exec($db, "SELECT e.posted, e.posted_by, e.start_date, e.end_date, t.event, t.summary, t.details FROM events e, events_text t WHERE e.approved = TRUE AND e.id=$eventid AND e.id=t.eventid AND t.language IN ('".$_LANGUAGE['handler']."','".$_SETTINGS['defaultlanguage']."') ORDER BY t.language ".$_LANGUAGE['order']." LIMIT 1");
+  if (pg_num_rows($rs) <= 0) {
+    $pagecontent = "Sorry, this event could not be found.";
+  } else {
+    $eventdetails = pg_fetch_array($rs);
+       if ($eventdetails['start_date'] == '') {
+         // No date given
+         $date = '';
+       } elseif ($eventdetails['end_date'] != '' && $eventdetails['end_date'] != $eventdetails['start_date']) {
+         // We have an enddate and it's not the startdate
+         $date = LoadTemplate('index_event_twodates', $language, array('startdate' => $eventdetails['start_date'], 'enddate' => $eventdetails['end_date']));
+       } else {
+         // We do only have a startdate
+         $date = LoadTemplate('index_event_onedate', $language, array('date' => $eventdetails['start_date']));
+       }
+       $details = nl2br(iif($eventdetails['details']!="", $eventdetails['details'], $eventdetails['summary']));
+       $pagecontent = LoadTemplate("event", $language, array("event" => $eventdetails['event'], "date" => $date, "posted" => $eventdetails['posted'], "poster" => $eventdetails['posted_by'], "details" => $details));
+  }
+} elseif ($pagetype == "newsarchive") {
+  if (!$db = database_connect("portal")) {
+    $pagecontent = "The news database server is currently down.";
+  } else {
+    $news = "";
+       $rs = pg_query($db, "SELECT id, posted, posted_by FROM news WHERE active = FALSE AND approved = TRUE ORDER BY posted DESC");
+       while($newsitem = pg_fetch_array($rs)){
+         $details = pg_query($db, "SELECT headline, summary FROM news_text WHERE newsid=".$newsitem['id']." AND language IN ('".$_LANGUAGE['handler']."','".$_SETTINGS['defaultlanguage']."') ORDER BY language ".$_LANGUAGE['order']." LIMIT 1");
+         // Make sure there's a translation in english or in the language the user selected...
+         if (pg_num_rows($details) > 0) {
+           $detail = pg_fetch_array($details);
+               $news .= LoadTemplate("index_news", $language, array("id" => $newsitem['id'], "poster" => $newsitem['posted_by'], "date" => $newsitem['posted'], "summary" => $detail['summary'], "headline" => $detail['headline']));
+         }
+       } // while
+       $pagecontent = LoadTemplate("newsarchive", $language, array("newslist" => $news));
+  }
+} elseif ($pagetype == "eventarchive") {
+  if (!$db = database_connect("portal")) {
+    $pagecontent = "The news database server is currently down.";
+  } else {
+    $events = "";
+       $rs = pg_query($db, "SELECT id, posted, posted_by FROM events WHERE active = FALSE AND approved = TRUE ORDER BY posted DESC");
+       while($eventitem = pg_fetch_array($rs)){
+         $details = pg_query($db, "SELECT event, summary FROM events_text WHERE eventid=".$eventitem['id']." AND language IN ('".$_LANGUAGE['handler']."','".$_SETTINGS['defaultlanguage']."') ORDER BY language ".$_LANGUAGE['order']." LIMIT 1");
+         // Make sure there's a translation in english or in the language the user selected...
+         if (pg_num_rows($details) > 0) {
+           $detail = pg_fetch_array($details);
+        if ($detail['start_date'] == '') {
+          // No date given
+          $date = '';
+        } elseif ($detail['end_date'] != '' && $detail['end_date'] != $detail['start_date']) {
+          // We have an enddate and it's not the startdate
+          $date = LoadTemplate('index_event_twodates', $language, array('startdate' => $detail['start_date'], 'enddate' => $detail['end_date']));
+        } else {
+          // We do only have a startdate
+          $date = LoadTemplate('index_event_onedate', $language, array('date' => $detail['start_date']));
+        }
+               $events .= LoadTemplate("index_event", $language, array("id" => $eventitem['id'], "date" => $date, "poster" => $eventitem['posted_by'], "summary" => $detail['summary'], "headline" => $detail['event']));
+         }
+       } // while
+    $pagecontent = LoadTemplate("eventarchive", $language, array("eventlist" => $events));
+  }
+} elseif ($pagetype == "survey") {
+  // Someone wants to see a poll result
+  $pollid = intval($page[1]);
+  if ($pollid > 0) {
+    // Let's show the poll
+       if (!$db = database_connect("portal")) {
+         $pagecontent = "Sorry, could not connect to the poll database";
+       } else {
+         $rs = pg_query($db, "SELECT s.tot1, s.tot2, s.tot3, s.tot4, s.tot5, s.tot6, s.tot7, s.tot8, s.respondants, q.* FROM surveys s, survey_questions q WHERE s.id=$pollid AND q.language IN ('".$_LANGUAGE['handler']."','".$_SETTINGS['defaultlanguage']."') AND s.id=q.surveyid ORDER BY q.language ".$_LANGUAGE['order']." LIMIT 1");
+         if (pg_num_rows($rs) > 0) {
+           $rows = '';
+               $result = pg_fetch_array($rs);
+               for ($i=1; $i<9; $i++) {
+                 if ($result["opt$i"] != "") {
+                   $rows .= '  <tr><td bgcolor="#CDDDEB">'.$result["opt$i"].'</td><td bgcolor="#CDDDEB" align=right>'.$result["tot$i"].'</td><td bgcolor="#CDDDEB" align=right>'.getpct($result["tot$i"], $result['respondants']).'%</td></tr>';
+                 }
+               }
+               $title = $result['question'];
+               $total = $result['respondants'];
+         } else {
+           $rows = '';
+         }
+       }
+  }
+  // Let's get the other polls
+  $other = "";
+  $rs = pg_query($db, "SELECT id FROM surveys WHERE id != $pollid ORDER BY id DESC");
+  while($poll = pg_fetch_array($rs)){
+    $questions = pg_query($db, "SELECT question FROM survey_questions WHERE surveyid=".$poll['id']." AND language IN ('".$_LANGUAGE['handler']."','".$_SETTINGS['defaultlanguage']."') ORDER BY language ".$_LANGUAGE['order']." LIMIT 1");
+       $question = pg_fetch_array($questions);
+       $other .= '<li><a href="/{LNG_handler}/survey.'.$poll['id'].'.htm">'.$question['question'].'</a></li>';
+  } // while
+  $pagecontent = LoadTemplate("survey", $language, array("title" => $title, "rows" => $rows, "total" => $total, "other" => $other));
+}
+
+// get the basic layout ($top, $left, $right and $bottom)
+require("./layout/basic.top.php");
+require("./layout/basic.left.php");
+require("./layout/basic.right.php");
+require("./layout/basic.bottom.php");
+
+// get $content
+$content = "$top
+$left
+$pagecontent
+$right
+$bottom";
+
+$content = ParseOutput($content);
+
+?>
\ No newline at end of file
diff --git a/portal/tools/rebuildcache b/portal/tools/rebuildcache
new file mode 100644 (file)
index 0000000..c4b6a70
--- /dev/null
@@ -0,0 +1,218 @@
+#!/usr/local/bin/php
+
+<?php
+
+chdir('../system');
+
+$possiblesections = array();
+$possiblesections['news'] = true;
+$possiblesections['events'] = true;
+$possiblesections['surveys'] = true;
+$possiblesections['staticpages'] = true;
+$possiblesections['documentation'] = true;
+$possiblesections['filesandimages'] = true;
+
+function help() {
+  // Print the usage help
+  
+  global $argv, $possiblesections;
+  
+  echo "This script can be used to rebuild the PostgreSQL.org cache\n\n";
+  
+  echo "Usage:\n";
+  echo "\t{$argv[0]} [--cron] <language> <section>\n\n";
+  
+  echo "--cron\n";
+  echo "\tUse the --cron switch when you call this script\n";
+  echo "\tfrom cron so no output will be created and no questions\n";
+  echo "\twill be asked\n\n";
+  
+  echo "<language>\n";
+  echo "\tThis can be a language handler like \"en\", multiple\n";
+  echo "\tlanguage handlers seperated by commas like \"en,de\" \n";
+  echo "\tor simply \"all\" to build all languages\n\n";
+  
+  echo "<section>\n";
+  echo "\tThis can be one or more comma seperated sections or\n";
+  echo "\tsimply \"all\" to build all sections\n";
+  echo "\tPossible sections:\n";
+  
+  reset($possiblesections);
+  while (list($handler, $true) = each($possiblesections)) {
+    echo "\t\t$handler\n";
+  }
+  echo "\n";
+  
+  exit;
+}
+
+function log_message($message) {
+  if (!INCRON) {
+    echo $message;
+  }
+}
+
+function log_error($message) {
+  echo $message;
+}
+
+function builddirectory($dir) {
+  if (!is_dir($dir)) {
+    if (!@mkdir($dir)) {
+      builddirectory(dirname($dir));
+    }
+    @mkdir($dir);
+  }
+}
+
+function buildpage($page, $language='') {
+  if ($language != '') {
+    $page = "/$language/$page";
+  }
+  log_message("Building page $page...\n");
+  builddirectory(dirname("../cache$page"));
+  if (file_exists("../cache$page")) {
+    @unlink("../cache$page");
+  }
+  $pagecontent = implode('', file("http://wwwdevel2.postgresql.org$page"));
+  $pagecontent = str_replace('<p align="center">Page generated in ', '<p align="center">Page cached in ', $pagecontent);
+  $FILE = fopen("../cache$page", 'w');
+  fwrite($FILE, $pagecontent);
+  fclose($FILE);
+}
+
+if ($argv[1] == '--cron') {
+  define ('INCRON', true);
+  $language = $argv[2];
+  $section = $argv[3];
+} else {
+  define ('INCRON', false);
+  $language = $argv[1];
+  $section = $argv[2];
+}
+
+if (!((INCRON && $argc == 4) || (!INCRON && $argc == 3))) {
+  help();
+}
+
+if (!INCRON && $language == 'all' && $section == 'all') {
+  echo "You want to rebuild EVERYTHING. This will be very ressource\n";
+  echo "intensive for the server.\n";
+  echo "Do you want to continue? [Yn]";
+  $confirm = fread(STDIN, 1);
+  if ($confirm != "\n" && $confirm != 'y' && $confirm != 'Y') {
+    exit;
+  }
+}
+
+$_DOLANGUAGES = array();
+$_DOSECTIONS = array();
+
+require_once('../system/global/languages.php');
+if ($language == 'all') {
+  reset($_LANGUAGES);
+  while (list($handler, $title) = each($_LANGUAGES)) {
+    $_DOLANGUAGES[] = $handler;
+  }
+} else {
+  $languages = split(',', $language);
+  for ($i=0; $i < count($languages); $i++) {
+    $handler = $languages[$i];
+    if (isset($_LANGUAGES[$handler])) {
+      $_DOLANGUAGES[] = $handler;
+    } else {
+      log_message("Skipping non-existent language \"$handler\"...\n");
+    }
+  }
+}
+
+if (count($_DOLANGUAGES) == 0) {
+  log_error("\nNo valid language specified, exiting.\n\n");
+  exit;
+}
+
+if ($section == 'all') {
+  reset($possiblesections);
+  $_DOSECTIONS = $possiblesections;
+} else {
+  $sections = split(',', $section);
+  for ($i=0; $i < count($sections); $i++) {
+    $handler = $sections[$i];
+    if (isset($possiblesections[$handler])) {
+      $_DOSECTIONS[$handler] = true;
+    } else {
+      log_message("Skipping non-existent section \"$handler\"...\n");
+    }
+  }
+}
+
+if (count($_DOSECTIONS) == 0) {
+  log_error("\nNo valid section specified, exiting.\n\n");
+  exit;
+}
+
+require_once('../system/global/settings.php');
+require_once('../system/global/functions.database.php');
+$db = database_connect('portal');
+
+for ($i=0; $i < count($_DOLANGUAGES); $i++) {
+  
+  $language = $_DOLANGUAGES[$i];
+  
+  if ($_DOSECTIONS['news']) {
+    buildpage('index.htm', $language);
+    buildpage('newsarchive.htm', $language);
+    $rs = pg_query($db, "SELECT id FROM news WHERE approved = TRUE ORDER BY id");
+    while ($newsitem = pg_fetch_array($rs)) {
+      buildpage("news.$newsitem[id].htm", $language);
+    }
+  }
+  
+  if ($_DOSECTIONS['events']) {
+    buildpage('index.htm', $language);
+    buildpage('eventarchive.htm', $language);
+    $rs = pg_query($db, "SELECT id FROM events WHERE approved = TRUE ORDER BY id");
+    while ($eventitem = pg_fetch_array($rs)) {
+      buildpage("event.$eventitem[id].htm", $language);
+    }
+  }
+  
+  if ($_DOSECTIONS['surveys']) {
+    $rs = pg_query($db, "SELECT id FROM surveys ORDER BY id");
+    while ($surveyitem = pg_fetch_array($rs)) {
+      buildpage("survey.$surveyitem[id].htm", $language);
+    }
+  }
+  
+  if ($_DOSECTIONS['staticpages']) {
+    $rs = pg_query($db, "SELECT DISTINCT(name) FROM staticpages");
+    while ($page = pg_fetch_array($rs)) {
+      buildpage("$page[name].htm", $language);
+    }
+  }
+  
+  if ($_DOSECTIONS['documentation']) {
+    $versions = pg_query($db, "SELECT DISTINCT(version) FROM docs ORDER BY version");
+    while ($version = pg_fetch_array($versions)) {
+      $version = $version['version'];
+      $rs = pg_query($db, "SELECT DISTINCT(file) FROM docs WHERE version=$version ORDER BY file");
+      while ($doc = pg_fetch_array($rs)) {
+        $page = str_replace(".html", ".htm", $doc['file']);
+        buildpage("documentation/$version/static/$page", $language);
+        buildpage("documentation/$version/interactive/$page", $language);
+      }
+    }
+  }
+  
+}
+
+if ($_DOSECTIONS['filesandimages']) {
+  log_message("Copying files...\n");
+  system('cp -R ../files ../cache/files');
+  log_message("Copying images and layout files...\n");
+  system('cp -R ../layout/ ../cache/layout/');
+}
+  
+log_message("\nFinished rebuilding cache.\n\n");
+
+?>
\ No newline at end of file