Picasa HTML Album Loader
Submitted Description: This script was meant to meet a need of my
own, to include a picasa html export into a cmsmadesimple content
page.
It reads the actualy html text file, taking only the content between
the tags, and also re-writes the anchor tags, so that the
album can be navigated.
Limitations:
- Not tested with frames, so the frames templates with picasa are not
appropriate for this.
- Uses file input, so the album has to be in the same file system as
your CMS installation.
- Ignores picasa stylesheet. You could attach it in the CMSMS pages
though.
- Does not resize images, so your template needs to be wide enough
for the largest image exported from picasa.
Code: Select all
$folder = urldecode($params['folder']);
$index = $params['index'];
if($_GET['file']){
$filename = $_GET['file'];
}else{
$filename=$folder.$index;
}
if(file_exists($filename)){
$url = $folder;
$output="";
$file = fopen($filename, "r");
$count = 0;
while(!feof($file)) {
//read file line by line into variable
$tmp = fgets($file, 4096);
if(stripos($tmp,'</__body')!==false){
$num = strlen($tmp)-(stripos($tmp,'</__body')+stripos($tmp,'>',stripos($tmp,'</__body')));
$neg = $num - ($num*2);
$output = substr($tmp,$neg);
}elseif(stripos($tmp,'<__body>')!==false){
$done=true;
}else{
if(($output !='')&&(!$done)) {
$tmp = str_replace('src="','src="'.$url,$tmp);
$page = $_GET['page'];
$tmp = str_replace('<a href="','<a href="/index.php?page='.$page.'&file='.$url,$tmp);
$output = $output . $tmp;
}
}
$count++;
}
fclose ($file);
echo $output;
}else{
echo $filename.' not found.';
}
http://stephenhughes.ca/index.php?page=xmas-twins