PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/popup.php

https://github.com/jinzora/jinzora3
PHP | 464 lines | 325 code | 38 blank | 101 comment | 39 complexity | f2f31f366dd8b7de70bed66891cfa35e MD5 | raw file
  1. <?php define('JZ_SECURE_ACCESS','true');
  2. /**
  3. * - JINZORA | Web-based Media Streamer -
  4. *
  5. * Jinzora is a Web-based media streamer, primarily desgined to stream MP3s
  6. * (but can be used for any media file that can stream from HTTP).
  7. * Jinzora can be integrated into a CMS site, run as a standalone application,
  8. * or integrated into any PHP website. It is released under the GNU GPL.
  9. *
  10. * - Resources -
  11. * - Jinzora Author: Ross Carlson <ross@jasbone.com>
  12. * - Web: http://www.jinzora.org
  13. * - Documentation: http://www.jinzora.org/docs
  14. * - Support: http://www.jinzora.org/forum
  15. * - Downloads: http://www.jinzora.org/downloads
  16. * - License: GNU GPL <http://www.gnu.org/copyleft/gpl.html>
  17. *
  18. * - Contributors -
  19. * Please see http://www.jinzora.org/team.html
  20. *
  21. * - Code Purpose -
  22. * - This page contains a number of tools that are used and displayed in popup boxes
  23. *
  24. * @since 02.17.04
  25. * @author Ross Carlson <ross@jinzora.org>
  26. */
  27. $include_path = '';
  28. include_once('jzBackend.php');
  29. $_GET = unurlize($_GET);
  30. $_POST = unpostize($_POST);
  31. $path = $_GET['jz_path'];
  32. $node = new jzMediaNode($path);
  33. $popup = new jzPopup();
  34. $popup->popupSwitch($_GET['ptype'],$node);
  35. exit();
  36. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  37. //
  38. // This section processes any form posts that may hit this page
  39. //
  40. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  41. class jzPopup {
  42. /* Constructor
  43. *
  44. **/
  45. function jzPopup() {
  46. global $jzUSER;
  47. // Now let's se if they selected a Genre, Artist, or Album:
  48. if (isset($_POST['chosenPath'])) {
  49. if (isset($_POST['jz_type']) && $_POST['jz_type'] == "track") {
  50. if (checkPermission($jzUSER,'play',$_POST['chosenPath']) === false) {
  51. $this->closeWindow(false);
  52. }
  53. $e = new jzMediaTrack($_POST['chosenPath']);
  54. $pl = new jzPlaylist();
  55. $pl->add($e);
  56. $pl->play();
  57. exit();
  58. } else {
  59. $return = $this->returnGoBackPage($_POST['return']);
  60. }
  61. //$url = $return. "&" . jz_encode("path") . "=". jz_encode(urlencode($_POST['chosenPath']));
  62. $link = array();
  63. $link['jz_path'] = $_POST['chosenPath'];
  64. // Now let's fix that if we need to
  65. // Ok, now that we've got the URL let's refresh the parent and close this window
  66. echo '<body onload="opener.location.href=\''. urlize($link) . '\';window.close();">';
  67. exit();
  68. }
  69. }
  70. /* The switch that controls the popup type.
  71. *
  72. * @author Ben Dodson
  73. * @version 1/28/05
  74. * @since 1/28/05
  75. *
  76. **/
  77. function popupSwitch($type,$node) {
  78. if (false !== stristr($type,'..') || false !== stristr($type,'/') || false !== stristr($type,'\\')) {
  79. die('security breach detected in popupswitch');
  80. }
  81. if (file_exists(($file = dirname(__FILE__).'/popups/'.$type.'.php'))) {
  82. include($file);
  83. return;
  84. }
  85. die('invalid popup: ' . $type);
  86. }
  87. /**
  88. * Displays a close window input button
  89. *
  90. * @author Ross Carlson
  91. * @since 03/07/05
  92. * @version 03/07/05
  93. * @param $reload Should we reload the parent on click (default to false)
  94. *
  95. **/
  96. function closeButton($reload = false){
  97. echo '<input type="submit" value="'. word('Close'). '" name="close" onClick="window.close();';
  98. if ($reload){
  99. echo 'opener.location.reload(true);';
  100. }
  101. echo '" class="jz_submit">';
  102. }
  103. /**
  104. * This is a 'smart' function that displays the user
  105. * information about a piece of media.
  106. *
  107. * @author Ben Dodson
  108. * @since 7/6/05
  109. * @version 7/6/05
  110. **/
  111. function itemInformation($item) {
  112. if ($item->getType() == "jzMediaNode" || $item->getType() == "jzMediaTrack") {
  113. if ($item->isLeaf()) {
  114. $this->displayTrackInfo($item);
  115. } else { // node
  116. if (isNothing($item->getDescription())) {
  117. $this->displayNodeStats($item);
  118. } else {
  119. $this->displayReadMore($item);
  120. }
  121. }
  122. }
  123. }
  124. /**
  125. * Displays the top of the page for the popup window
  126. *
  127. * @author Ross Carlson
  128. * @version 01/18/05
  129. * @since 01/18/05
  130. * @param $bg_color a hex value for the background color, IF we want one
  131. * @param $headerTitle The title for the page
  132. */
  133. function displayPageTop($bg_color = "", $headerTitle = "", $js = true){
  134. global $row_colors, $web_root, $root_dir, $skin, $cms_mode, $cms_type, $cur_theme, $css;
  135. $display = new jzDisplay();
  136. //handleSetTheme();
  137. // AJAX:
  138. $display->handleAJAX();
  139. // Let's include the javascript
  140. if ($js){
  141. echo '<script type="text/javascript" src="'. $root_dir. '/lib/jinzora.js"></script>'. "\n";
  142. echo '<script type="text/javascript" src="'. $root_dir. '/lib/overlib.js"></script>';
  143. echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>';
  144. }
  145. // Let's start our page
  146. echo '<title>Jinzora</title>'. "\n";
  147. // Let's output the Jinzora style sheet
  148. //include_once($css);
  149. echo '<link rel="stylesheet" title="'. $skin. '" type="text/css" media="screen" href="'. $css. '">'. "\n";
  150. // Now let's see if they wanted a different background color
  151. if ($bg_color <> ""){
  152. echo '<span style="font-size:0px">.</span><body marginwidth=0 marginheight=0 style="margin: 0px" style="background-color:'. $bg_color. '">'. "\n";
  153. }
  154. // Now let's output the CMS style sheet, if necessary
  155. if ($cms_mode <> "false"){
  156. switch ($cms_type){
  157. case "postnuke" :
  158. case "phpnuke" :
  159. case "cpgnuke" :
  160. case "mdpro" :
  161. echo '<LINK REL="StyleSheet" HREF="'. $_SESSION['cms-style']. '" TYPE="text/css">';
  162. // Now let's get the data we need from the session var
  163. $cArr = explode("|",urldecode($_SESSION['cms-theme-data']));
  164. echo "<style type=\"text/css\">" .
  165. ".jz_row1 { background-color:". $cArr[0]. "; }".
  166. ".jz_row2 { background-color:". $cArr[1]. "; }".
  167. ".and_head1 { background-color:". $cArr[0]. "; }".
  168. ".and_head2 { background-color:". $cArr[1]. "; }".
  169. "</style>";
  170. break;
  171. case "mambo" :
  172. echo '<LINK REL="StyleSheet" HREF="'. $_SESSION['cms-style']. '" TYPE="text/css">'. "\n";
  173. $row_colors = array('sectiontableentry2','tabheading');
  174. break;
  175. }
  176. }
  177. if (stristr($skin,"/")){
  178. $img_path = $root_dir. "/". $skin;
  179. } else {
  180. $img_path = $root_dir. "/style/". $skin;
  181. }
  182. // Now let's show the page title
  183. if ($headerTitle <> ""){
  184. ?>
  185. <table width="100%" cellpadding="3" cellspacing="0" border="0"><tr><td>
  186. <table width="100%" cellpadding="3" cellspacing="0" border="0">
  187. <tr>
  188. <td width="6" height="6" style="background: url(<?php echo $img_path; ?>/inner-block-top-left.gif); background-repeat:no-repeat"></td>
  189. <td width="99%" height="6" style="background: url(<?php echo $img_path; ?>/inner-block-top-middle.gif);"></td>
  190. <td width="6" height="6" style="background: url(<?php echo $img_path; ?>/inner-block-top-right.gif); background-repeat:no-repeat"></td>
  191. </tr>
  192. <tr>
  193. <td width="6" style="background: url(<?php echo $img_path; ?>/inner-block-left.gif); background-repeat:repeat"></td>
  194. <td width="99%">
  195. <table width="100%" cellpadding="0" cellspacing="0" border="0">
  196. <tr>
  197. <td width="100%">
  198. <font size="1" color="<?php echo jz_font_color; ?>">
  199. <strong><?php echo $headerTitle; ?></strong>
  200. </font>
  201. </td>
  202. <td align="right"><a href="javascript:window.close();"><?php echo word('Close'); ?></a></td>
  203. </tr>
  204. </table>
  205. </td>
  206. <td width="6" style="background: url(<?php echo $img_path; ?>/inner-block-right.gif); background-repeat:repeat"></td>
  207. </tr>
  208. <tr>
  209. <td width="6" height="6" style="background: url(<?php echo $img_path; ?>/inner-block-bottom-left.gif); background-repeat:no-repeat"></td>
  210. <td width="99%" height="6" style="background: url(<?php echo $img_path; ?>/inner-block-bottom-middle.gif);"></td>
  211. <td width="6" height="6" style="background: url(<?php echo $img_path; ?>/inner-block-bottom-right.gif); background-repeat:no-repeat"></td>
  212. </tr>
  213. </table>
  214. </td></tr></table>
  215. <?php
  216. }
  217. flushDisplay();
  218. }
  219. /**
  220. * Opens a block to have rounded corners
  221. *
  222. * @author Ross Carlson
  223. * @version 01/18/05
  224. * @since 01/18/05
  225. */
  226. function openBlock(){
  227. global $root_dir;
  228. ?>
  229. <table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td>
  230. <?php
  231. }
  232. /**
  233. * Closes a block to have rounded corners
  234. *
  235. * @author Ross Carlson
  236. * @version 01/18/05
  237. * @since 01/18/05
  238. */
  239. function closeBlock(){
  240. echo "</td></tr></table>". "\n";
  241. flushdisplay();
  242. }
  243. /**
  244. * Closes the popup window for us
  245. *
  246. * @author Ross Carlson
  247. * @version 01/18/05
  248. * @since 01/18/05
  249. * @param $parent_reload Should we refresh the calling page (defaults to true)?
  250. */
  251. function closeWindow($parent_reload = true){
  252. if ($parent_reload){
  253. ?>
  254. <script language="javascript">
  255. opener.location.reload(true);
  256. window.close();
  257. -->
  258. </SCRIPT>
  259. <?php
  260. } else {
  261. ?>
  262. <script language="javascript">
  263. window.close();
  264. -->
  265. </SCRIPT>
  266. <?php
  267. }
  268. }
  269. function readAllDirs2($dirName, &$readCtr){
  270. global $audio_types, $video_types;
  271. // Let's up the max_execution_time
  272. ini_set('max_execution_time','6000');
  273. // Let's look at the directory we are in
  274. if (is_dir($dirName)){
  275. $d = dir($dirName);
  276. if (is_object($d)){
  277. while($entry = $d->read()) {
  278. // Let's make sure we are seeing real directories
  279. if ($entry == "." || $entry == "..") { continue;}
  280. if ($readCtr % 100 == 0){
  281. ?>
  282. <script language="javascript">
  283. p.innerHTML = '<b><?php echo $readCtr. " ". word("files analyzed"); ?></b>';
  284. -->
  285. </SCRIPT>
  286. <?php
  287. @flush(); @ob_flush();
  288. }
  289. // Now let's see if we are looking at a directory or not
  290. if (filetype($dirName. "/". $entry) <> "file"){
  291. // Ok, that was a dir, so let's move to the next directory down
  292. readAllDirs2($dirName. "/". $entry, $readCtr);
  293. } else {
  294. if (preg_match("/\.($audio_types|$video_types)$/i", $entry)){
  295. $readCtr++;
  296. $_SESSION['jz_full_counter']++;
  297. }
  298. }
  299. }
  300. // Now let's close the directory
  301. $d->close();
  302. }
  303. }
  304. }
  305. /**
  306. * Searches for meta data of the given node but shows the results step by step
  307. *
  308. * @author Ross Carlson
  309. * @version 01/18/05
  310. * @since 01/18/05
  311. * @param $node The node we are looking at
  312. */
  313. function stepMetaSearch($node){
  314. global $jzSERVICES, $row_colors, $allow_id3_modify, $include_path, $allow_filesystem_modify;
  315. echo '<div id="artist"></div>';
  316. echo '<div id="arStatus"></div>';
  317. echo '<div id="count"></div>';
  318. echo '<div id="art"></div>';
  319. ?>
  320. <SCRIPT LANGUAGE=JAVASCRIPT><!--\
  321. ar = document.getElementById("artist");
  322. ars = document.getElementById("arStatus");
  323. c = document.getElementById("count");
  324. i = document.getElementById("art");
  325. -->
  326. </SCRIPT>
  327. <?php
  328. flushdisplay();
  329. // Now let's search, first we need to get all the nodes from here down
  330. $nodes = $node->getSubNodes("nodes",-1);
  331. // Now let's add the node for what we are viewing
  332. $nodes = array_merge(array($node),$nodes);
  333. $total = count($nodes);$c=0;$start=time();
  334. foreach($nodes as $item){
  335. ?>
  336. <SCRIPT LANGUAGE=JAVASCRIPT><!--\
  337. ar.innerHTML = '<nobr><?php echo word("Item"); ?>: <?php echo $item->getName(); ?></nobr>';
  338. ars.innerHTML = '<?php echo word("Status: Searching..."); ?>';
  339. -->
  340. </SCRIPT>
  341. <?php
  342. flushdisplay();
  343. // Is this an artist?
  344. if ($item->getPType() == 'artist'){
  345. }
  346. // Is this an album?
  347. if ($item->getPType() == 'album'){
  348. // Now let's loop all the services
  349. $sArr = array("jinzora", "yahoo","rs","musicbrainz","google");
  350. foreach ($sArr as $service){
  351. ?>
  352. <SCRIPT><!--\
  353. ars.innerHTML = '<?php echo word("Searching"). ": ". $service; ?>'
  354. -->
  355. </SCRIPT>
  356. <?php
  357. flushdisplay();
  358. include_once($include_path. "services/services/metadata/". $service. ".php");
  359. $func = "SERVICE_GETALBUMMETADATA_". $service;
  360. $itemData = $func($item, false, "array");
  361. if ($itemData['image'] <> ""){
  362. echo '<table width="100%" cellpadding="3" cellspacing="0" border="0"><tr><td>';
  363. echo '<img width="75" align="left" src="'. $itemData['image']. '" border="0">';
  364. if (!isNothing($itemData['year'])){
  365. echo $itemData['year']. "<br>";
  366. }
  367. if (!isNothing($itemData['rating'])){
  368. echo $itemData['rating'];
  369. }
  370. echo $itemData['review'];
  371. echo '</td></tr><tr><td><input class="jz_submit" type="button" name="edit_download_image" value="'. word("Download"). " - ". $service. '">';
  372. echo "<br><br></td></tr></table>";
  373. }
  374. unset($itemData);
  375. flushdisplay();
  376. }
  377. }
  378. }
  379. ?>
  380. <br>
  381. <SCRIPT LANGUAGE=JAVASCRIPT><!--\
  382. ars.innerHTML = '&nbsp;';
  383. c.innerHTML = '&nbsp;';
  384. -->
  385. </SCRIPT>
  386. <?php
  387. echo "<br><center>";
  388. $this->closeButton(true);
  389. exit();
  390. }
  391. // This function figures out the page to return too
  392. // Added 4.6.04 by Ross Carlson
  393. // Returns the page to go back to
  394. function returnGoBackPage($page){
  395. global $row_colors, $cms_mode;
  396. // Now let's split this into an array so we can get all the paramaters
  397. $pageArray = explode("&",$page);
  398. // Let's split the page name from the paramaters
  399. $splitArray = explode("?",$pageArray[0]);
  400. $pageName = $splitArray[0];
  401. // Now let's fix up the first one, so we'll have just the URL
  402. $pageArray[0] = $splitArray[1];
  403. for ($i=0; $i < count($pageArray); $i++){
  404. // now let's fix it up
  405. if (stristr($pageArray[$i],"path")){
  406. $pageArray[$i] = "";
  407. }
  408. }
  409. // Now let's put it back together
  410. $page = implode("&",$pageArray);
  411. // Now let's remove any &&
  412. while (stristr($page,"&&")){
  413. $page = str_replace("&&","",$page);
  414. }
  415. $page = $pageName . "?". $page;
  416. return $page;
  417. }
  418. }
  419. ?>