Merge branch 'master' into newui
[bookreader.git] / BookReaderIA / www / BookReaderJSLocate.php
index d828090..f60d221 100644 (file)
@@ -22,6 +22,7 @@ require_once '/petabox/setup.inc';
 
 $id = $_REQUEST['id'];
 $book = $_REQUEST['book']; // support multiple books within an item
+$subPrefix = $_REQUEST['subPrefix']; // same as above but with same naming as BookReaderImages
 
 if ("" == $id) {
     echo "No identifier specified!";
@@ -32,21 +33,13 @@ $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];
-    }
-}
+$server = $results[0][0];
+$serverBaseURL = BookReader::serverBaseURL($server);
 
-$url = "http://{$serverBaseURL}/BookReader/BookReaderJSIA.php?id=" . urlencode($id) . "&itemPath={$results[0][1]}&server={$serverBaseURL}";
-if ($book) {
+$url = "http://{$serverBaseURL}/BookReader/BookReaderJSIA.php?id=" . urlencode($id) . "&itemPath={$results[0][1]}&server={$server}";
+if ($subPrefix) {
+    $url .= "&subPrefix=" . urlencode($subPrefix);
+} else if ($book) {
     $url .= "&subPrefix=" . urlencode($book);
 }