//Nov 2014 - Changed to deal with lack of fopen wrappers on www-old
// See SLIDEjax2.works.php for the old version.
//SLIDEjax.php
/* + Slurps the contents of the referring URL,
* + Extracts everything between
* and
* + Treats each
,
,
as the beginning of
* of a
(leaves
and beyond alone)
* + Adds class="show incremental" to all of the tags below if
* they have no class.
* + Wraps S5 slide show classes and javascript around everything
*/
$ref = $_SERVER['HTTP_REFERER'];
$toppieces = split("/",$ref);
$mysite = $toppieces[3]."/".$toppieces[4]."/";
//$pieces = split('physix/302/',$ref);
$pieces = split($mysite,$ref);
if ($pieces[1] == ''){
die ("called from bad URL!");
}
$morepieces = split('/',$pieces[1]);
$thedir = $morepieces[0] ."/";
// Works on local machine
//$fcontents = join('',file('http://localhost/'.$mysite.$pieces[1]));
// Works at GC
//$fcontents = join('',file('http://www-old.goshen.edu/'.$mysite.$pieces[1]));
$fcontents = join('',file('../../'.$mysite.$pieces[1]));
preg_match('/2.h" \?>(.*)<\? inc/si',$fcontents,
$matches);
$slidishstuff = $matches[1];
//print $fcontents;
//print $slidishstuff;
//exit();
//Massage relative image links to absolute links
$pattern = "/src=\'([^\/h])/i";
$replacement = "src=\'/". $mysite . $thedir ."$1";
$slidishstuff = preg_replace($pattern, $replacement, $slidishstuff);
$pattern = "/src=\"([^\/h])/i";
$replacement = "src=\"/". $mysite . $thedir ."$1";
$slidishstuff = preg_replace($pattern, $replacement, $slidishstuff);
//Massage relative urls to absolute urls
$pattern = "/href=\'([^\/h])/i";
$replacement = "href=\'/". $mysite . $thedir ."$1";
$slidishstuff = preg_replace($pattern, $replacement, $slidishstuff);
// The 'h' below avoids re-writing absolute URLs that begin 'http...'
//... yeah, it's a kludge.
$pattern = "/href=\"([^\/h])/i";
$replacement = "href=\"/". $mysite . $thedir ."$1";
$slidishstuff = preg_replace($pattern, $replacement, $slidishstuff);
//Set default