und und gibt den // dazwischenliegenden HTML Code aus. // // Version History: // Mai 2001 Zeiler Erste Version // 23.11.2001 Wiest Template-Mechanismus integriert // 30.09.2005 Sung Layout angepasst // 15.11.2005 Sung Anpassung an die neue Serverumgebung // 09.04.2008 Sung Links aus der Druckversion entfernt, mehr Hintergrundfarben hinzugef�gt // 26.10.2012 Masselli "Diese Seite drucken" aus der Druckversion entfernt, Kodierung auf ISO-8859-1 gesetzt // (c) 2001 Universit�t T�bingen, WSI, Lehrstuhl Rechnerarchitektur //$TEMPLATE = "http://www.ra.cs.uni-tuebingen.de/templates/template_print.html"; $TEMPLATE = "../templates/template_print.html"; $http_referer = $_SERVER['HTTP_REFERER']; // WORKAROUND FOR FILE $http_referer = preg_replace("/(.*cs\.uni-tuebingen\.de)(.*)/sim","..$2", $http_referer); if($http_referer == "") { die("Cannot load print the supplied page '".$_SERVER['HTTP_REFERER']."'!"); } // Read in template and source document $templateContents = file_get_contents($TEMPLATE); $fileContents = file_get_contents($http_referer); // echo join('',file("../lehre/ws13/robotik1.html")); //echo $templateContents; //echo $fileContents; // Extract absolute path from HTTP REFERER URL preg_match("/(http:\/\/)?(.*?\/)(.*\/.*?|\z)/i", $http_referer, $matches); $relPath = "/" . $matches[3]; $zeigeTeilnehmer = "//"; if(preg_match($zeigeTeilnehmer, $fileContents)) { $httpPrint = preg_replace("/\.\./","",$http_referer); $table = file_get_contents("http://www.cogsys.cs.uni-tuebingen.de/php/wwwseminar/zeigeTeilnehmer.php?url=" . $httpPrint . "&isActive=yes"); $fileContents = preg_replace($zeigeTeilnehmer, $table ,$fileContents); } // Extract tag from source document if(preg_match ("/<title>(.*?)<\/title>/sim", $fileContents, $matches) > 0 ) { $title = $matches[1]; } else { $title = "Kein Titel"; } // Extract <!--HEAD--> tag from source document if(preg_match ("/<!--HEAD-->(.*?)<!--\/HEAD-->/sim", $fileContents, $matches) > 0 ) { $head = $matches[1]; } else { $head = ""; } // Extract <!--BODY--> tag from source document if(preg_match ("/<!--BODY-->(.*?)<!--\/BODY-->/sim", $fileContents, $matches) > 0 ) { $body = $matches[1]; } else { $body = ""; } //Delete "Diese Seite drucken" $body = preg_replace("/>Diese Seite drucken</", "><", $body); // Fix relative URLs for links and images in body part // $body = preg_replace("/<a\s+href\s*=\s*\"(?!http|\/)(.*?)\"/sim", "<a href=\"$relPath$1\"", $body); $body = preg_replace("/<a\s+href\s*=\s*\"(?!http|\/)(.*?)\"\s*>(.*?)<\/a>/sim", "$2", $body); $body = preg_replace("/<img\s+src\s*=\s*\"(?!http|\/)(.*?)\"/sim", "<img src=\"$relPath$1\"", $body); // Remove the static gifs (does not work for those created by the include derective) $body = preg_replace("/<img src='images\/anmelden.gif' border='0'>/", "", $body); // Add background color to the tables /* $body = preg_replace("/<td\s?(height=\"[0-9]*\")?(valign=\"[a-z]*\")?>/i", "<td style=\"background-color: #ffffff;\">", $body); */ if (strpos($title,"Übung")!==FALSE) { $templateContents = preg_replace("/#B4A069/","#D7B469",$templateContents); } elseif (strpos($title,"Sem")!==FALSE) { $templateContents = preg_replace("/#B4A069/","#916946",$templateContents); } elseif (strpos($title,"Prosem")!==FALSE) { $templateContents = preg_replace("/#B4A069/","#D29600",$templateContents); } elseif (strpos($title,"Prakt")!==FALSE) { $templateContents = preg_replace("/#B4A069/","#B4A096",$templateContents); } // Insert title, head, body and referer parts of source document into template $templateContents = preg_replace("/<!--TITLE-->/sim", $title, $templateContents); $templateContents = preg_replace("/<!--HEAD CONTENT-->/sim", $head, $templateContents); $templateContents = preg_replace("/<!--BODY CONTENT-->/sim", $body, $templateContents); $templateContents = preg_replace("/<!--HTTP REFERER-->/sim", $_SERVER['HTTP_REFERER'], $templateContents); // Output result echo $templateContents; ?>