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