From: Michael S. <sta...@us...> - 2005-10-04 22:59:40
|
Update of /cvsroot/archive-access/archive-access/projects/wera/src/webapps/wera/handlers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23369/wera/src/webapps/wera/handlers Added Files: html_javascript.php html_javascript.php.js passthrough.php Log Message: First time add of wera. Moved here from nwa.nb.no. --- NEW FILE: html_javascript.php.js --- <SCRIPT language="Javascript"> <!-- // $Id: html_javascript.php.js,v 1.1 2005/10/04 22:59:27 stack-sf Exp $ // Script inserted by WERA to ensure that links point to // WERA rather than out to the Internet // This script was contributed by the Internet Archive // Some minor WERA adaptations has been made function xResolveUrl(url) { var image = new Image(); image.src = url; return image.src; } function xLateUrl(aCollection, sProp, mode) { var i = 0; for(i = 0; i < aCollection.length; i++) { if (typeof(aCollection[i][sProp]) == "string") { if (aCollection[i][sProp].indexOf("mailto:") == -1 && aCollection[i][sProp].indexOf("javascript:") == -1) { aCollection[i]["target"] = "_top"; if(aCollection[i][sProp].indexOf("http") == 0) { aCollection[i][sProp] = sWayBackCGI + "&mode=" + mode + "&url=" + aCollection[i][sProp]; } else { aCollection[i][sProp] = sWayBackCGI + "&mode=" + mode + "&url=" + xResolveUrl(aCollection[i][sProp]); } } } } } xLateUrl(document.getElementsByTagName("IMG"),"src","inline"); xLateUrl(document.getElementsByTagName("A"),"href","standalone"); xLateUrl(document.getElementsByTagName("AREA"),"href","standalone"); xLateUrl(document.getElementsByTagName("OBJECT"),"codebase","inline"); xLateUrl(document.getElementsByTagName("OBJECT"),"data","inline"); xLateUrl(document.getElementsByTagName("APPLET"),"codebase","inline"); xLateUrl(document.getElementsByTagName("APPLET"),"archive","inline"); xLateUrl(document.getElementsByTagName("EMBED"),"src","inline"); xLateUrl(document.getElementsByTagName("BODY"),"background","inline"); var forms = document.getElementsByTagName("FORM","inline"); if (forms) { var j = 0; for (j = 0; j < forms.length; j++) { f = forms[j]; if (typeof(f.action) == "string") { if(typeof(f.method) == "string") { if(typeof(f.method) != "post") { f.action = sWayBackCGI + "&url=" + f.action; } } } } } var interceptRunAlready = false; function intercept_js_href_iawm(destination) { if(!interceptRunAlready &&top.location.href != destination) { interceptRunAlready = true; top.location.href = sWayBackCGI+xResolveUrl(destination); } } // ie triggers href_iawmWatcher = document.createElement("a"); top.location.href_iawm = top.location.href; if(href_iawmWatcher.setExpression) { href_iawmWatcher.setExpression("dummy","intercept_js_href_iawm(top.location.href_iawm)"); } // mozilla triggers function intercept_js_moz(prop,oldval,newval) { intercept_js_href_iawm(newval); return newval; } if(top.location.watch) { top.location.watch("href_iawm",intercept_js_moz); } var notice = "<div style='" + "position:relative;z-index:99999;"+ "border:1px solid;color:black;background-color:lightYellow;font-size:10px;font-family:sans-serif;padding:5px'>" + "WERA... External links, forms, and search boxes may not function within this collection. " + "[ <a style='color:blue;font-size:10px;text-decoration:underline' href=\"javascript:void(top.disclaimElem.style.display='none')\">hide</a> ]" + "</div>"; function getFrameArea(frame) { if(frame.innerWidth) return frame.innerWidth * frame.innerHeight; if(frame.document.documentElement && frame.document.documentElement.clientHeight) return frame.document.documentElement.clientWidth * frame.document.documentElement.clientHeight; if(frame.document.body) return frame.document.body.clientWidth * frame.document.body.clientHeight; return 0; } function disclaim() { if(top!=self) { largestArea = 0; largestFrame = null; for(i=0;i<top.frames.length;i++) { frame = top.frames[i]; area = getFrameArea(frame); if(area > largestArea) { largestFrame = frame; largestArea = area; } } if(self!=largestFrame) { return; } } disclaimElem = document.createElement('div'); disclaimElem.innerHTML = notice; top.disclaimElem = disclaimElem; document.body.insertBefore(disclaimElem,document.body.firstChild); } disclaim(); --> </SCRIPT> --- NEW FILE: html_javascript.php --- <?php /* * This file is part of The NWA Toolset. * * Copyright (C) 2001-2002 Royal Library in Stockholm, * Royal Library in Copenhagen, * Helsinki University Library of Finland, * National Library of Norway, * National and University Library of Iceland. * * The NWA Toolset is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The NWA Toolset is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with The NWA Toolset; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** * Documenthandler that inserts a javascript into the html file * The purpose of the javascript is to make the link rewriting happen * in the browser. * The javascript is based on one of Internet Archives Wayback Machine * installations. A few modifications have been made to adapt it to the * NwaToolset url scheme. * * Please Note ! * The Javascript must be stored alongside this script, * with the same name as this script and with a '.js' extension * * @version $Id: html_javascript.php,v 1.1 2005/10/04 22:59:27 stack-sf Exp $ * * Input parameters: * aid - The url of the document in the archive (really: $conf_document_retriever preceded by the documents unique identifier in the archive) * time - The documents timestamp * mime - The documents mime-type * url - The documents original url */ //if register_globals is off if (!isset($aid)) $aid = $_REQUEST['aid']; if (!isset($mime)) $mime = $_REQUEST['mime']; if (!isset($time)) $time = $_REQUEST['time']; if (!isset($url)) $url = $_REQUEST['url']; if ($fd = fopen ($aid, "r")) { if (isset($mime)) { Header("content-type: $mime"); } while(!feof($fd)) { $document .= fread($fd, 1024); } fclose($fd); $hrefstring = "<HEAD>\n<BASE HREF=\"$url\">\n"; // Insert the base url if (preg_match_all("/<head>/i", $document, $dummy) > 0) { $document = preg_replace("/<head>/i", $hrefstring, $document, 1); } else { // if no head present $document = preg_replace("/<html>/i", "<HTML>\n" . $hrefstring . "</HEAD>", $document, 1); } $js_to_insert = "<SCRIPT language=\"Javascript\">\n"; $js_to_insert .= "var sWayBackCGI = \"##P#R#E#F#I#X##TIME#$time\"\n"; $js_to_insert .= "</SCRIPT>\n"; $js_to_insert .= file_get_contents($_SERVER['SCRIPT_FILENAME'] . ".js"); $js_to_insert .= "</html>"; $document = preg_replace("/<\/html>/i", $js_to_insert, $document); print($document); } ?> --- NEW FILE: passthrough.php --- <?php /* * This file is part of The NWA Toolset. * * Copyright (C) 2001-2002 Royal Library in Stockholm, * Royal Library in Copenhagen, * Helsinki University Library of Finland, * National Library of Norway, * National and University Library of Iceland. * * The NWA Toolset is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The NWA Toolset is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with The NWA Toolset; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** * Documenthandler that lets the document pass trough unchanged. * * $Id: passthrough.php,v 1.1 2005/10/04 22:59:27 stack-sf Exp $ * * Input parameters: * aid - The document's identifier in the archive * time - The document's timestamp * mime - The document's mime-type * url - The document's original url */ $aid = $_REQUEST['aid']; $time = $_REQUEST['time']; $mime = $_REQUEST['mime']; $url = $_REQUEST['url']; if ($fd = @fopen ($aid, "r")) { if (isset($mime)) { Header("content-type: $mime", false); } fpassthru($fd); } ?> |