/old/ssp_director/images.php
PHP | 155 lines | 130 code | 25 blank | 0 comment | 33 complexity | 3633cd8c4322fa819b019fc6437e432c MD5 | raw file
- <?php
- $path_to_cache = 'xml_cache/images';
- if (isset($_GET['gid'])):
- $path_to_cache .= '_gid_' . $_GET['gid'];
- endif;
- if (isset($_GET['subdomain']) || isset($_GET['www'])):
- $path_to_cache .= '_no_www';
- endif;
- $path_to_cache .= '.xml';
- if (file_exists($path_to_cache)):
- $tail = substr(md5(uniqid(microtime())), 0, 6);
- header("Location: $path_to_cache?$tail");
- else:
- header('Content-type: text/xml;');
- if (!defined('PATH_SEPARATOR') ) {
- define('PATH_SEPARATOR', ( substr(PHP_OS, 0, 3) == 'WIN' ) ? ';' : ':');
- }
- $sep = PATH_SEPARATOR;
-
- ini_set('include_path', ini_get('include_path') . $sep . dirname(__FILE__) . '/inc/data' . $sep . dirname(__FILE__) . '/config');
-
- require('conf.php');
- require('connect.php');
- require('ent2ncr.php');
- require('find_self.php');
-
- if (empty($_GET['gid'])):
- $q = "SELECT * FROM $atbl WHERE active = 1 ORDER BY displayOrder";
- else:
- $gid = $_GET['gid'];
- $q = "SELECT $atbl.* FROM $atbl, $dltbl WHERE $dltbl.aid = $atbl.id and $dltbl.did = $gid ORDER BY $dltbl.display";
- endif;
-
- $albums = $db->get_results($q);
-
- $self = get_self();
- $self = str_replace('images.php', '', $self);
- $self = str_replace('www.', '', $self);
-
- if (!isset($_GET['subdomain']) && !isset($_GET['www'])):
- $self = 'http://www.' . $self;
- else:
- $self = 'http://' . $self;
- endif;
-
- $o = '<?xml version="1.0" encoding="utf-8"?>'."\n";
- $o .= '<!-- XML Generated by SlideShowPro Director v' . $version . " http://www.slideshowpro.net -->\n";
- $o .= '<gallery>';
-
- if (count($albums) > 0):
- foreach ($albums as $a):
- $aid = $a->id;
- $name = $a->name;
- if (!empty($name)):
- $name = ent2ncr(htmlentities(html_entity_decode(stripslashes($name)), ENT_QUOTES, 'UTF-8'));
- endif;
- $path = $a->path;
- $audio_file = $a->audioFile;
- $album_thumb = $a->aTn;
- $description = $a->description;
- if (!empty($description)):
- $description = ent2ncr(htmlentities(nl2br(html_entity_decode(stripslashes($description))), ENT_QUOTES, 'UTF-8'));
- $description = eregi_replace("\n|\r", '', $description);
- endif;
-
- if (!empty($a->audioFile)):
- $audio_file = $self . 'album-audio/' . $audio_file;
- $audio_str = ' audio="' . $audio_file . '"';
- else:
- $audio_str = '';
- endif;
- if (!empty($audio_str) && !empty($a->audioCap)):
- $audio_caption = ent2ncr(htmlentities(html_entity_decode(stripslashes($a->audioCap)), ENT_QUOTES, 'UTF-8'));
- $audio_str .= ' audioCaption="'.$audio_caption.'"';
- endif;
-
- $lg_path = $self . 'albums/' . $path . '/lg/';
-
- if ($a->tn == 1):
- $tn_path = $self . 'albums/' . $path . '/tn/';
- else:
- $tn_path = '';
- endif;
-
- if ($a->show_headers == 0):
- $description = '';
- $name = '';
- endif;
-
- $o .= "\n\t";
- $o .= '<album id="' . $aid . '" title="' . $name . '" description="' . $description . '" lgPath="' . $lg_path . '" tnPath="' . $tn_path . '" tn="' . $album_thumb . '"' . $audio_str . '>';
-
- $q = "SELECT * FROM $itbl WHERE aid = $aid AND active = 1 ORDER BY seq";
- $images = $db->get_results($q);
-
- if (count($images) > 0):
- foreach ($images as $i):
- $src = $i->src;
- $title = $i->title;
- $link = $i->link;
- $caption = $i->caption;
-
- if (!empty($title)):
- $title = ent2ncr(htmlentities(html_entity_decode(stripslashes($title)), ENT_QUOTES, 'UTF-8'));
- endif;
-
- if (!empty($link)):
- $link = ent2ncr(htmlentities(html_entity_decode(stripslashes($link)), ENT_QUOTES, 'UTF-8'));
- endif;
-
- if (!empty($link) && strpos($link, 'javascript:') === false) {
- $link = str_replace('http://', '', $link);
- $link = 'http://' . $link;
- }
-
- $pause = $i->pause;
- if ($pause != 0):
- $pause_str = ' pause="' . $pause . '"';
- else:
- $pause_str = '';
- endif;
-
- $target = $i->target;
- if ($target == 1):
- $target_str = ' target="_self"';
- else:
- $target_str = '';
- endif;
-
- if (!empty($caption)):
- $caption = ent2ncr(htmlentities(nl2br(html_entity_decode(stripslashes($caption))), ENT_QUOTES, 'UTF-8'));
- $caption = eregi_replace("\n|\r", '', $caption);
- endif;
-
- $o .= "\n\t\t".'<img src="' . $src . '" title="' . $title . '" caption="' . $caption . '" link="' . $link . '"' . $target_str . $pause_str . ' />';
- endforeach;
- endif;
-
- $o .= "\n\t";
- $o .= '</album>' . "\n";
- endforeach;
- else:
- $o .= "\n\t<!-- Warning: You have not added and/or made active any albums in Director. You must have at least one active album for SlideShowPro to function correctly. -->\n";
- endif;
-
- $o .= '</gallery>';
- if (@is_writeable(dirname(__FILE__) . '/xml_cache/') || @chmod(dirname(__FILE__) . '/xml_cache/', 0777)):
- $handle = @fopen($path_to_cache, 'w+');
- @fwrite($handle, $o) == false;
- @fclose($handle);
- endif;
- echo($o);
- endif;
- ?>