PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/old/ssp_director/images.php

https://github.com/fauxparse/jesters
PHP | 155 lines | 130 code | 25 blank | 0 comment | 33 complexity | 3633cd8c4322fa819b019fc6437e432c MD5 | raw file
  1. <?php
  2. $path_to_cache = 'xml_cache/images';
  3. if (isset($_GET['gid'])):
  4. $path_to_cache .= '_gid_' . $_GET['gid'];
  5. endif;
  6. if (isset($_GET['subdomain']) || isset($_GET['www'])):
  7. $path_to_cache .= '_no_www';
  8. endif;
  9. $path_to_cache .= '.xml';
  10. if (file_exists($path_to_cache)):
  11. $tail = substr(md5(uniqid(microtime())), 0, 6);
  12. header("Location: $path_to_cache?$tail");
  13. else:
  14. header('Content-type: text/xml;');
  15. if (!defined('PATH_SEPARATOR') ) {
  16. define('PATH_SEPARATOR', ( substr(PHP_OS, 0, 3) == 'WIN' ) ? ';' : ':');
  17. }
  18. $sep = PATH_SEPARATOR;
  19. ini_set('include_path', ini_get('include_path') . $sep . dirname(__FILE__) . '/inc/data' . $sep . dirname(__FILE__) . '/config');
  20. require('conf.php');
  21. require('connect.php');
  22. require('ent2ncr.php');
  23. require('find_self.php');
  24. if (empty($_GET['gid'])):
  25. $q = "SELECT * FROM $atbl WHERE active = 1 ORDER BY displayOrder";
  26. else:
  27. $gid = $_GET['gid'];
  28. $q = "SELECT $atbl.* FROM $atbl, $dltbl WHERE $dltbl.aid = $atbl.id and $dltbl.did = $gid ORDER BY $dltbl.display";
  29. endif;
  30. $albums = $db->get_results($q);
  31. $self = get_self();
  32. $self = str_replace('images.php', '', $self);
  33. $self = str_replace('www.', '', $self);
  34. if (!isset($_GET['subdomain']) && !isset($_GET['www'])):
  35. $self = 'http://www.' . $self;
  36. else:
  37. $self = 'http://' . $self;
  38. endif;
  39. $o = '<?xml version="1.0" encoding="utf-8"?>'."\n";
  40. $o .= '<!-- XML Generated by SlideShowPro Director v' . $version . " http://www.slideshowpro.net -->\n";
  41. $o .= '<gallery>';
  42. if (count($albums) > 0):
  43. foreach ($albums as $a):
  44. $aid = $a->id;
  45. $name = $a->name;
  46. if (!empty($name)):
  47. $name = ent2ncr(htmlentities(html_entity_decode(stripslashes($name)), ENT_QUOTES, 'UTF-8'));
  48. endif;
  49. $path = $a->path;
  50. $audio_file = $a->audioFile;
  51. $album_thumb = $a->aTn;
  52. $description = $a->description;
  53. if (!empty($description)):
  54. $description = ent2ncr(htmlentities(nl2br(html_entity_decode(stripslashes($description))), ENT_QUOTES, 'UTF-8'));
  55. $description = eregi_replace("\n|\r", '', $description);
  56. endif;
  57. if (!empty($a->audioFile)):
  58. $audio_file = $self . 'album-audio/' . $audio_file;
  59. $audio_str = ' audio="' . $audio_file . '"';
  60. else:
  61. $audio_str = '';
  62. endif;
  63. if (!empty($audio_str) && !empty($a->audioCap)):
  64. $audio_caption = ent2ncr(htmlentities(html_entity_decode(stripslashes($a->audioCap)), ENT_QUOTES, 'UTF-8'));
  65. $audio_str .= ' audioCaption="'.$audio_caption.'"';
  66. endif;
  67. $lg_path = $self . 'albums/' . $path . '/lg/';
  68. if ($a->tn == 1):
  69. $tn_path = $self . 'albums/' . $path . '/tn/';
  70. else:
  71. $tn_path = '';
  72. endif;
  73. if ($a->show_headers == 0):
  74. $description = '';
  75. $name = '';
  76. endif;
  77. $o .= "\n\t";
  78. $o .= '<album id="' . $aid . '" title="' . $name . '" description="' . $description . '" lgPath="' . $lg_path . '" tnPath="' . $tn_path . '" tn="' . $album_thumb . '"' . $audio_str . '>';
  79. $q = "SELECT * FROM $itbl WHERE aid = $aid AND active = 1 ORDER BY seq";
  80. $images = $db->get_results($q);
  81. if (count($images) > 0):
  82. foreach ($images as $i):
  83. $src = $i->src;
  84. $title = $i->title;
  85. $link = $i->link;
  86. $caption = $i->caption;
  87. if (!empty($title)):
  88. $title = ent2ncr(htmlentities(html_entity_decode(stripslashes($title)), ENT_QUOTES, 'UTF-8'));
  89. endif;
  90. if (!empty($link)):
  91. $link = ent2ncr(htmlentities(html_entity_decode(stripslashes($link)), ENT_QUOTES, 'UTF-8'));
  92. endif;
  93. if (!empty($link) && strpos($link, 'javascript:') === false) {
  94. $link = str_replace('http://', '', $link);
  95. $link = 'http://' . $link;
  96. }
  97. $pause = $i->pause;
  98. if ($pause != 0):
  99. $pause_str = ' pause="' . $pause . '"';
  100. else:
  101. $pause_str = '';
  102. endif;
  103. $target = $i->target;
  104. if ($target == 1):
  105. $target_str = ' target="_self"';
  106. else:
  107. $target_str = '';
  108. endif;
  109. if (!empty($caption)):
  110. $caption = ent2ncr(htmlentities(nl2br(html_entity_decode(stripslashes($caption))), ENT_QUOTES, 'UTF-8'));
  111. $caption = eregi_replace("\n|\r", '', $caption);
  112. endif;
  113. $o .= "\n\t\t".'<img src="' . $src . '" title="' . $title . '" caption="' . $caption . '" link="' . $link . '"' . $target_str . $pause_str . ' />';
  114. endforeach;
  115. endif;
  116. $o .= "\n\t";
  117. $o .= '</album>' . "\n";
  118. endforeach;
  119. else:
  120. $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";
  121. endif;
  122. $o .= '</gallery>';
  123. if (@is_writeable(dirname(__FILE__) . '/xml_cache/') || @chmod(dirname(__FILE__) . '/xml_cache/', 0777)):
  124. $handle = @fopen($path_to_cache, 'w+');
  125. @fwrite($handle, $o) == false;
  126. @fclose($handle);
  127. endif;
  128. echo($o);
  129. endif;
  130. ?>