Internet Archive petabox-related changes
authorMichael Ang <mang@archive.org>
Thu, 28 Jan 2010 01:31:32 +0000 (01:31 +0000)
committerMichael Ang <mang@archive.org>
Thu, 28 Jan 2010 01:31:32 +0000 (01:31 +0000)
BookReaderIA/datanode/BookReaderJSIA.php
BookReaderIA/inc/BookReader.inc
BookReaderIA/inc/FlipSearchMap.inc
BookReaderIA/www/BookReaderJSLocate.php
BookReaderIA/www/browserunsupported.php

index 7a29e83..f65fb7b 100755 (executable)
@@ -49,7 +49,7 @@ if ("" == $server) {
     BRFatal("No server specified!");
 }
 
-if (!preg_match("|^/[0-3]/items/{$id}$|", $itemPath)) {
+if (!preg_match("|^/\d+/items/{$id}$|", $itemPath)) {
     BRFatal("Bad id!");
 }
 
index d61de5e..b98671f 100644 (file)
@@ -163,22 +163,29 @@ class BookReader
   <?
     exit;
   }
+
   
-  public static function jsMetadataURL($server, $identifier, $mainDir, $subPrefix = '')
+  public static function adjustToHome($server)
   {
-    $serverBaseURL = $server;
-    
-    // Check if we're on a dev vhost and point to JSIA in the user's public_html on the datanode
+    // Check if we're on a dev vhost and point to JSIA in the user's public_html
+    // on the datanode
     if (preg_match("/^www-(\w+)/", $_SERVER["SERVER_NAME"], $match)) {
       // $$$ the remapping isn't totally automatic yet and requires user to
       //     ln -s ~/petabox/www/datanode/BookReader ~/public_html/BookReader
       //     so we enable it only for known hosts
-      $devhosts = array('mang', 'testflip');
+      $devhosts = array('mang', 'testflip', 'rkumar');
       if (in_array($match[1], $devhosts)) {
-        $serverBaseURL = $serverBaseURL . ":81/~" . $match[1];
+        return $server . ":81/~" . $match[1]; //xxxx
       }
     }
-    
+    return $server;
+  }
+  
+  
+  public static function jsMetadataURL($server, $identifier, $mainDir, $subPrefix = '')
+  {
+    $serverBaseURL = BookReader::adjustToHome($server);
+
     $params = array( 'id' => $identifier, 'itemPath' => $mainDir, 'server' => $server );
     if ($subPrefix) {
         $params['subPrefix'] = $subPrefix;
index e9345ca..182572b 100644 (file)
@@ -138,9 +138,9 @@ class FlipSearchMap {
     $url = urldecode($searchUrl);
     //Another way is for the javascript code to pass in server, itemdir, and identifier directly
     //For now we'll parse the $url passed us.
-    #if (!preg_match('|http://\w+.archive.org(/[0-9]/items/\w+)/(\w+)_djvu.xml$|', $url, $match))
+    #if (!preg_match('|http://\w+.archive.org(/[0-9]+/items/\w+)/(\w+)_djvu.xml$|', $url, $match))
     #if (!preg_match('|(\w+)/(\w+)_djvu.xml$|', $url, $match))      
-    if (!preg_match('|(/[0-9]/items/[\w-]+)/([\w-]+)_djvu.xml$|', $url, $match))
+    if (!preg_match('|(/[0-9]+/items/[\w-]+)/([\w-]+)_djvu.xml$|', $url, $match))
       fatal("Can't get server and identifier from url $url");
     $bookDir = $match[1];
     $identifier = $match[2];
index 0b18e2e..70ede69 100644 (file)
@@ -31,18 +31,7 @@ $locator      = new Locator();
 
 $results = $locator->locateUDP($id, 1, false);
 
-$serverBaseURL = $results[0][0];
-
-// Check if we're on a dev vhost and point to JSIA in the user's public_html on the datanode
-if (preg_match("/^www-(\w+)/", $_SERVER["SERVER_NAME"], $match)) {
-    // $$$ the remapping isn't totally automatic yet and requires user to
-    //     ln -s ~/petabox/www/datanode/BookReader ~/public_html/BookReader
-    //     so we enable it only for known hosts
-    $devhosts = array('mang', 'testflip', 'rkumar');
-    if (in_array($match[1], $devhosts)) {
-        $serverBaseURL = $serverBaseURL . ":81/~" . $match[1];
-    }
-}
+$serverBaseURL = BookReader::adjustToHome($results[0][0]);
 
 $url = "http://{$serverBaseURL}/BookReader/BookReaderJSIA.php?id={$id}&itemPath={$results[0][1]}&server={$serverBaseURL}";
 
index 1e8680e..c098789 100644 (file)
@@ -1,4 +1,4 @@
-<?
+<? require_once '/petabox/setup.inc';
 /*
 Copyright(c)2008 Internet Archive. Software license AGPL version 3.
 
@@ -19,68 +19,14 @@ This file is part of BookReader.
 */
 
 
-$id = $_REQUEST['id'];
+$id = urlencode($_REQUEST['id']); // Sanitize since we put this value in the page
 
-// Sanitize since we put this value in the page
-$id = urlencode($id);
-
-$flippyURL = "http://" . $_SERVER['SERVER_NAME'] . "/texts/flipbook/flippy.php?id=" . $id;
+$flippyURL = "/texts/flipbook/flippy.php?id=$id";
 
+Nav::bar('Unsupported browser', 'home', null, null, 1, null,
+         '<meta http-equiv="refresh" content="10;url=http://www.archive.org'.$flippyURL.'">',
+         '', true);
 ?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-<head>
-    <title>Unsupported browser</title>
-    <meta http-equiv="refresh" content="10;url=<? echo($flippyURL); ?>">
-    <link rel="stylesheet" href="http://www.archive.org/stylesheets/archive.css?v=1.99" type="text/css">
-</head>
-<body>
-
-<table style="background-color:white " cellspacing="0" width="100%" border="0" cellpadding="0">
-  <tbody>
-    <tr> 
-      <td style="width:100px; height:72px; vertical-align:top; background-color:#000000;">
-
-        <a href="http://www.archive.org/"><img style="border:0;" alt="(logo)" src="http://www.archive.org/images/logo.jpg" width="84" height="70"/></a>
-      </td>
-      <td valign="bottom" style="background-image:url(http://www.archive.org/images/blendbar.jpg);">
-        <table width="100%" border="0" cellpadding="5">
-          <tr> 
-            <td class="level1Header">
-              <div class="tab"><a href="http://www.archive.org/web/web.php">Web</a></div><div class="tab"><a href="http://www.archive.org/details/movies">Moving Images</a></div><div class="tab"><a href="http://www.archive.org/details/texts">Texts</a></div><div class="tab"><a href="http://www.archive.org/details/audio">Audio</a></div><div class="tab"><a href="http://www.archive.org/details/software">Software</a></div><div class="tab"><a href="http://www.archive.org/details/education">Education</a></div><div class="tab"><a href="http://www.archive.org/account/login.changepw.php">Patron Info</a></div><div class="tab"><a href="http://www.archive.org/about/about.php">About IA</a></div>            </td>
-
-          </tr>
-                    
-        </table>
-      </td>
-      <td style="width:80px; height:72px; vertical-align:top; text-align: right">
-        <a href="http://www.archive.org/about/about.php"><img alt="(navigation image)" src="http://www.archive.org/images/main-header.jpg" style="margin:0; border:0; vertical-align:top;" /></a>      </td>
-    </tr>
-  </tbody>
-</table>
-
-<!--BEGIN HEADER 2-->
-<table width="100%" class="level2Header">
-  <tbody>
-    <tr>
-      <td align="left" valign="top" class="level2HeaderLeft">
-        <a class="level2Header" href="http://www.archive.org/">Home</a>
-      </td>
-      <td style="width:100%;" class="level2Header">
-        <a href="http://www.archive.org/donate/index.php">Donate</a> | 
-
-<a href="http://www.archive.org/iathreads/forums.php">Forums</a> | 
-<a href="http://www.archive.org/about/faqs.php">FAQs</a> | 
-<a href="http://www.archive.org/contribute.php">Contributions</a> | 
-<a href="http://www.archive.org/about/terms.php">Terms, Privacy, &amp; Copyright</a> | 
-<a href="http://www.archive.org/about/contact.php">Contact</a> | 
-<a href="http://www.archive.org/about/jobs.php">Jobs</a> | 
-
-<a href="http://www.archive.org/about/bios.php">Bios</a>
-      </td>
-    </tr>
-  </tbody>
-</table>
 
 
 <div class="box">
@@ -89,9 +35,9 @@ Sorry, but our new viewer does not work in this browser yet.
 </p>
 
 <p>
-Either go to our <a href="<? echo($flippyURL); ?>">old viewer</a>,
+Either go to our <a href="<?=$flippyURL?>">old viewer</a>,  
 or download <a href="http://www.mozilla.com/en-US/firefox/">Firefox</a> or
-<a href="http://www.microsoft.com/windows/internet-explorer/download-ie.aspx">IE7 (or higher)</a>.
+  <a href="http://www.microsoft.com/windows/internet-explorer/download-ie.aspx">IE7 (or higher)</a>.
 </p>
 
 <p>
@@ -100,10 +46,4 @@ You will be automatically redirected to the older viewer in 10 seconds.
 
 </div>
 
-<p id="iafoot">
-  <a href="http://www.archive.org/about/terms.php">Terms of Use (10 Mar 2001)</a>
-
-</p>
-
-</body>
-</html>
+<?=footer();?>