-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.php
798 lines (718 loc) · 24.9 KB
/
index.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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
<?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 directs 'traffic' to the proper Jinzora component.
*
* @since 01.11.05
* @author Ross Carlson <[email protected]>
* @author Ben Dodson <[email protected]>
*/
// Let's set the error reporting level
//@error_reporting(E_ERROR);
// Right away lets set the time we started
// Now we'll need to figure out the path stuff for our includes
// This is critical for CMS modes
$include_path = ""; $link_root = ""; $cms_type = "standalone"; $cms_mode = "false";
$backend = ""; $jz_lang_file = ""; $skin = ""; $my_frontend = "";
if (isset($_GET['op'])){
// This has got to be postnuke...
$include_path = "modules/". $_GET['name']. "/";
$link_root = "modules.php?";
$cms_type = "postnuke";
$cms_mode = "true";
} else if (isset($_GET['name']) and !isset($_GET['op'])){
// This has got to be phpnuke
$include_path = "modules/". $_GET['name']. "/";
// Now we need to see if it's CPGNuke
if (stristr($_SERVER['PHP_SELF'],"index.php")){
$link_root = "index.php?";
$cms_type = "cpgnuke";
$cms_mode = "true";
} else {
$link_root = "modules.php?";
$cms_type = "phpnuke";
$cms_mode = "true";
}
} else if (isset($_GET['option'])){
// This has got to be mambo
$include_path = "components/". $_GET['option']. "/";
$link_root = "index.php?";
$cms_type = "mambo";
$cms_mode = "true";
} else if(file_exists(dirname(__FILE__)."/../lib-common.php")) {
require_once(dirname(__FILE__)."/../lib-common.php");
$include_path = "";
$link_root = "index.php?";
$cms_type = "geeklog";
$cms_mode = "true";
} else if (file_exists(dirname(__FILE__)."/../../mainfile.php")) {
include(dirname(__FILE__)."/../../mainfile.php");
$include_path = "";
$link_root = "index.php?";
$cms_type = "xoops";
$cms_mode = "true";
} else if (file_exists(dirname(__FILE__)."/../../class2.php")) {
include(dirname(__FILE__)."/../../class2.php");
$include_path = "";
$link_root = "index.php?";
$cms_type = "e107";
$cms_mode = "true";
}
if ($cms_type != "xoops") {
session_name('jinzora-session');
session_start();
}
$_SESSION['jz_load_time'] = microtime();
$web_path = $include_path;
$install_complete = "no";
// cyclic dependencies...
@include($include_path. 'settings.php');
@include_once($include_path. 'system.php');
@include($include_path. 'settings.php');
include_once($include_path. "lib/general.lib.php");
include_once($include_path. 'services/class.php');
writeLogData("messages","Index: --------------- Beginning Jinzora session ---------------");
// Load our external services:
writeLogData("messages","Index: Loading default services");
$jzSERVICES = new jzServices();
$jzSERVICES->loadStandardServices();
if ($cms_mode == "true") {
writeLogData("messages","Index: Setting up CMS variables");
$ar = $jzSERVICES->cmsGETVars();
foreach ($ar as $id => $val) {
$link_root .= $id . "=" . $val . "&";
}
}
if (isset($_GET['install'])){
// Now let's include the right file
if ($_GET['install'] == "step7") {
if (isset($_POST['submit_step6_more']))
$_GET['install'] = 'step6';
}
if (strpos($_GET['install'], '..') !== false) {
die();
}
include_once($include_path. 'install/'. $_GET['install']. ".php");
exit();
}
$force_install = false;
if ($install_complete == "no") {
$force_install = true;
} else {
$cv = explode(".",$config_version);
$v = explode(".",$version);
if (!($cv[0] == $v[0] && $cv[1] == $v[1])) {
$force_install = true;
}
}
if ($force_install){
// To make upgrades easy let's see if they have a settings file already
// If they do we'll include the new one first so the new variable are already
$root_dir = ""; $media_dirs = "";
// populated for them
if (is_file('settings.php')){
@include_once($include_path. 'settings.php');
// Let's let them know we are upgrading
$upgrade = "Yes";
}
// Ok, it hasn't been installed so let's send them to the installer
include_once($include_path. 'install/step1.php');
exit();
}
// Security...
if ($cms_mode == "false" && $cms_type != "standalone") {
die('Security breach detected.');
}
// let's fix all of our variables.
// see "url.php" for details.
writeLogData("messages","Index: Cleaning POST and GET variables");
$_GET = unurlize($_GET);
$_POST = unpostize($_POST);
writeLogData("messages","Index: Checking theme settings");
// Now set up our backend; this is required for all Jinzora components.
writeLogData("messages","Index: Including backend functions");
include_once($include_path. 'backend/backend.php');
include_once($include_path. 'frontend/display.php');
// reset our this_page in case we need to add some temporary variables (frontend, etc.)
$this_page = setThisPage();
writeLogData("messages","Index: Checking for searching");
if (isset($_GET['doSearch'])) {
$_GET['action'] = "search";
if (isset($_GET['song_title'])) {
$_GET['search_query'] = $_GET['song_title'];
}
if (!isset($_GET['search_type'])) {
$_GET['search_type'] = "ALL";
}
}
// copy the POST variables for a basic search to GET variables so we don't do it twice.
// just do a powersearch with post variables.
if (isset($_POST['doSearch'])) {
$_GET['action'] = "search";
$_GET['search_query'] = $_POST['search_query'];
$_GET['search_type'] = $_POST['search_type'];
}
if (isset($jz_path)) {
unset($jz_path);
}
// support setting the path via POST:
if (isset($_POST['jz_path'])) {
$jz_path = $_POST['jz_path'];
} else if (isset($_GET['jz_path'])) {
$jz_path = $_GET['jz_path'];
} else if (!isset($jz_path)) {
$jz_path = "";
}
// maybe they set hierarchy as a string for some reason:
if (is_string($hierarchy))
$hierarchy = explode("/",$hierarchy);
// * * COMMAND LINE JINZORA * * //
include($include_path.'frontend/cli.php');
// set up our user.
writeLogData("messages","Index: Setting up the user object");
$jzUSER = new jzUser(); // class handles _SESSION stuff.
writeLogData("messages","Index: Loading user services");
if (isset($_GET['user']) && isset($_GET['pass'])) {
$store_cookie = true;
$prehashed = (isset($_REQUEST['pw_hashed']) && $_REQUEST['pw_hashed']=='true');
// Are they ok?
if ($jzUSER->login($_GET['user'],$_GET['pass'],$store_cookie, $prehashed) === false) {
//echo "login failed";
//exit();
}
} else {
$prehashed = true;
}
$jzSERVICES->loadUserServices();
if (!isset($_POST['action']) || $_POST['action'] != "login") {
handleUserInit();
writeLogData("messages","Index: Including the icons");
include_once($include_path. "frontend/icons.lib.php");
writeLogData("messages","Index: Creating a new frontend object");
} else {
handleSetFrontend(false);
}
@include_once($include_path. "lang/${jz_language}-simple.php");
@include_once($include_path. "lang/${jz_language}-extended.php");
writeLogData("messages","Index: Testing the frontend file for security and including");
@include_once($include_path.'frontend/frontends/'.$my_frontend.'/settings.php');
// Now let's see what the user was doing?
if (isset($_GET['action'])){
if ($_GET['action'] == "logout"){
writeLogData("messages","Index: Logging the user out");
$jzUSER->logout();
}
}
if ($jzUSER->getName() == ""){
$jzUSER->logout();
}
// handle changing of settings:
// These affect the session, NOT the user settings.
// This is handled in general.lib.php: setThisPage().
if (isset($_POST['action'])){
if ($_POST['action'] == "popup") {
$_GET['action'] = "popup";
$_GET['ptype'] = $_POST['ptype'];
}
}
if (checkPermission($jzUSER,"view") === false && (!isset($_POST['action']) || $_POST['action'] != "login" )) {
// Now are we in CMS mode or what?
if ($cms_type == "standalone" || $cms_type == "false" || $cms_type == ""){
writeLogData("messages","Index: Sending the user to the login page");
$fe->loginPage();
exit();
}
}
// Detect our current playlist:
if (isset($_GET['jz_playlist'])) {
$_SESSION['jz_playlist'] = $_GET['jz_playlist'];
}
if (isset($_POST['jz_playlist'])) {
$_SESSION['jz_playlist'] = $_POST['jz_playlist'];
}
// Should we use AJAX?
define('NO_AJAX_LINKS','true');
if (defined('NO_AJAX')) {
define ('NO_AJAX_LINKS','true');
define ('NO_AJAX_JUKEBOX','true');
}
$_SESSION['jz_path'] = $jz_path;
// having doSearch set and an action set is a security violation,
// since it allows executing arbitrary, unscrambled actions.
// First some security checking:
if (isset($_POST['update_settings'])) {
if (!(($_GET['action'] == "popup") && (($_GET['ptype'] == "usermanager") || ($_GET['ptype'] == "preferences")))) {
die();
}
}
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case "login":
writeLogData("messages","Index: Displaying the login page");
$fe->loginPage();
exit();
break;
case "register":
writeLogData("messages","Index: Displaying registration page");
$fe->registrationPage();
exit();
break;
case "search":
writeLogData("messages","Index: Displaying the search page results");
if (isset($_POST['powersearch'])) {
// don't worry about params in a powersearch; handle
// it on the results page.
$fe->searchResults(false,false,true);
} else if ($_GET['search_query'] == "") {
$fe->powerSearch();
// We cannot do SQL queries before we draw the header (for CMS)
// So we have the searchPage handle the query itself.
// Keywords are handled in the handleSearch() function
// See backend/backend.php.
} else {
$fe->searchResults($_GET['search_query'], $_GET['search_type']);
}
return;
break;
case "powersearch":
writeLogData("messages","Index: Displaying the power search page");
$fe->powerSearch();
exit();
break;
case "playlist":
// Now let's set the clip mode
setGlobal('CLIP_MODE',$_GET['clips']);
writeLogData("messages","Index: Generating playlists");
if ($jzUSER->getSetting('stream') === false && $jzUSER->getSetting('lofi') === false && $jzUSER->getSetting('jukebox_queue') === false) {
exit();
}
if (isset($_GET['type']) && $_GET['type'] == "playlist") {
// TODO: could pass the ID as a paramater and not automatically update the session variable.
$pid = false;
if (isset($_GET['jz_pl_id'])) {
$pid = $_GET['jz_pl_id'];
}
if (isset($_GET['plowner'])) {
$u= new jzUser(false,$_GET['plowner']);
$pl=$u->loadPlaylist($pid);
} else {
$pl = $jzUSER->loadPlaylist($pid);
}
if ($_GET['mode'] == "random") {
$pl = $pl->getSmartPlaylist();
}
$pl->play();
}
else if (isset($_GET['type']) && $_GET['type'] == "track") {
// send file directly if method == direct.
// otherwise send a playlist.
// TODO: if method = direct, do things like update playcount.
// and also validate user (pass username / md5(password) in URL)
$el = &new jzMediaTrack($_GET['jz_path']);
$pl = &new jzPlaylist();
$pl->add($el);
if (isset($_GET['clip'])) {
setGlobal("CLIP_MODE",true);
}
$pl->play();
} else {
// Ok, was this a radio playlist or standard
if (isset($_GET['mode']) && $_GET['mode'] == "radio"){
// Let's set the limit
$lim = (isset($_GET['limit'])) ? $_GET['limit'] : false;
// Now let's get the tracks from the primary artist
$el = &new jzMediaNode($_GET['jz_path']);
$pl = new jzPlaylist();
$pl->add($el);
$pl = $pl->getSmartPlaylist($lim,"radio");
$pl->play();
} else {
$el = &new jzMediaNode($_GET['jz_path']);
$rand = (isset($_GET['mode']) && $_GET['mode'] == "random") ? true : false;
$lim = (isset($_GET['limit'])) ? $_GET['limit'] : false;
$tlist = $el->getSubNodes("tracks",-1,$rand,$lim);
if ($rand === false) {
sortElements($tlist,"number");
}
$pl = &new jzPlaylist($tlist);
$pl->play();
}
}
exit();
break;
case "setplayback":
// Stupid code. Should just use the id as the variable.
// but if it ain't broke...
$_SESSION['jb_playwhere'] = $_REQUEST['player'];
// Now let's figure out it's ID
for ($i=0; $i < count($jbArr); $i++){
if ($jbArr[$i]['description'] == $_SESSION['jb_playwhere']){
$_SESSION['jb_id'] = $i;
}
}
exit();
break;
case "jukebox":
// Do we need to use the standard jukebox or not?
// Now did they have a subcommand?
if ($jzUSER->getSetting('jukebox_admin') === false && $jzUSER->getSetting('jukebox_queue') === false) {
echo 'insufficient permissions.';
exit();
}
if (isset($_GET['subaction']) or isset($_POST['subaction'])){
// Now let's pass our command
if (isset($_REQUEST['command'])){
$command = $_REQUEST['command'];
}
// Let's include the Jukebox classes
writeLogData("messages","Index: Passing command: ". $command. " to the jukebox");
include_once($include_path. "jukebox/class.php");
$jb = new jzJukebox();
$jb->passCommand($command);
}
//flushdisplay();
usleep(750000);
if (isset($_GET['frame'])){
include_once($include_path. "frontend/frontends/jukezora/topframe.php");
exit();
} else {
include_once($include_path. "jukebox.php");
exit();
}
break;
case "generateRandom":
writeLogData("messages","Index: Generating a random playlist");
if ($jzUSER->getSetting('stream') === false && $jzUSER->getSetting('lofi') === false) {
exit();
}
$pl = &new jzPlaylist();
// Let's time it.
$timer = microtime_float();
$pl->generate($_GET['random_play_type'],$_GET['random_play_number'],$_GET['random_play_genre']);
$timer = round(microtime_float() - $timer,2);
if ($_GET['random_play_genre'] != "") {
writeLogData('playback', "generated random playlist of ". $_GET['random_play_number'] . " tracks from genre '" . $_GET['random_play_genre'] . "' in $timer seconds.");
} else {
writeLogData('playback', "generated random playlist of ". $_GET['random_play_number'] ." tracks in $timer seconds.");
}
$pl->play();
exit();
break;
case "download":
writeLogData("messages","Index: Beginning a file download for: ". $_GET['jz_path']);
//while (@ob_end_flush());
if ($_GET['type'] == "track" && $single_download_mode == "raw") {
$el = &new jzMediaTrack($_GET['jz_path']);
if (!checkStreamLimit($el)){
// TODO: AJAX this so we don't come to a page, but get a Javascript alert.
echo word('Sorry, you have reached your download limit.');
exit();
}
// Are they downloading something resampled?
if (stristr($_GET['jz_path'],"data/resample")){
$name = $el->getPath();
$name = $name[sizeof($name)-1];
sendMedia($_GET['jz_path'], $name, $resample, true);
} else {
$el->increaseDownloadCount();
$name = $el->getPath();
$name = $name[sizeof($name)-1];
sendMedia($el->getFileName("host"),$name, $resample, true);
}
exit();
} else if ($_GET['type'] == "playlist") {
$pl = $jzUSER->loadPlaylist($_GET['jz_pl_id']);
$pl->download();
} else {
$pl = new jzPlaylist();
if ($_GET['type'] == "track") {
$el = &new jzMediaTrack($_GET['jz_path']);
} else {
$el = &new jzMediaNode($_GET['jz_path']);
}
if ($el->getLevel() == 0) { die(); }
$pl->add($el);
$pl->rename($el->getName());
$pl->download();
}
exit();
break;
/** Not yet...
case "import":
if (isset($_GET['query']))
$node->mediaImport("jzLibrary","URL");
else {
echo "<form>URL: <input type=\"text\" name=\"query\">";
echo '<input type="hidden" name="'.jz_encode("jz_path").'" value="'.jz_encode($_GET['jz_path']).'">';
echo '<input type="hidden" name="'.jz_encode("action").'" value="'.jz_encode("import").'">';
echo '<br><input type="submit" value="Import Media"></form>';
}
exit();
break;
case "export":
$node->mediaExport("jzLibrary");
exit();
break;
**/
case "addToPlaylist":
if (!isset($_REQUEST['jz_path']) || !isset($_REQUEST['type'])) exit();
if ($_REQUEST['type'] == 'track') {
$el = new jzMediaTrack($_REQUEST['jz_path']);
} else {
$el = new jzMediaNode($_REQUEST['jz_path']);
}
$pl = $jzUSER->loadPlaylist();
$pl->add($el);
$jzUSER->storePlaylist($pl);
if (!defined('NO_AJAX_JUKEBOX')) {
$blocks = new jzBlocks();
$blocks->playlistDisplay();
}
break;
} /* case */
}
/* * * * * * * * * */
// // // // // // / /
/*******************/
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case "login":
if (isset($_POST['self_register'])) {
writeLogData("messages","Index: Showing the self registration page");
// We are 'anonymous' for sure. Handle his variables now.
handleUserInit();
include_once($include_path. "frontend/class.php");
$fe = new jzFrontend();
$fe->registrationPage();
exit();
}
$remember = (isset($_POST['remember'])) ? true : false;
if ($_POST['field2'] == "cms-user") {
die("Security breach detected.");
}
if (($jzUSER->login($_POST['field1'],$_POST['field2'], $remember, $prehashed)) === false) {
writeLogData("messages","Index: Displaying the login page");
include_once($include_path. "frontend/class.php");
$fe = new jzFrontendClass();
$fe->loginPage(true);
exit();
}
if ($jzUSER->getSetting('view') === false) {
include_once($include_path. "frontend/class.php");
$fe = new jzFrontendClass();
$fe->loginPage();
exit();
}
$jzSERVICES->loadUserServices();
handleUserInit();
writeLogData("messages","Index: Including the icons");
include_once($include_path. "frontend/icons.lib.php");
break;
case "mediaAction":
writeLogData("messages","Index: Preforming a media action");
if (isset($_POST['randomize']) && $_POST['randomize'] == "true") {
unset($_POST['sendList']);
$_POST['sendListRandom'] = "true";
}
$exit = true;
if (isset($_POST['jz_path']) && (isset($_POST['sendPath']) || isset($_POST['sendPathRandom'])
|| ((isset($_POST['sendList']) || isset($_POST['sendListRandom'])) && sizeof($_POST['jz_list']) == 0))) {
$guy = &new jzMediaNode($_POST['jz_path']);
// should we do any filtering?
if (isset($_POST['doquery']) && $_POST['query'] != "") {
if ($_POST['how'] == "search") {
$root = &new jzMediaNode();
$pl = &new jzPlaylist($root->search(stripSlashes($_POST['query']),"tracks",-1));
}
else {
$pl = &new jzPlaylist($guy->search(stripSlashes($_POST['query']),"tracks",-1));
}
} else {
$pl = &new jzPlaylist(array($guy));
}
if (isset($_POST['sendPathRandom']) || isset($_POST['sendListRandom'])) {
$pl->flatten();
$pl->shuffle();
if (isset($_POST['limit'])) {
$pl->truncate($_POST['limit']);
}
}
else if (isset($_POST['limit'])) {
$pl->flatten();
$pl->truncate($_POST['limit']);
}
$pl->play();
}
else if (isset($_POST['info'])) {
echo "get info for the given list.";
}
else if (isset($_POST['playplaylist'])) {
$pl = $jzUSER->loadPlaylist();
if ($_POST['playplaylist'] == 'random') {
$pl->shuffle();
}
$pl->play();
} else if (isset($_POST['addList']) && sizeof($_POST['jz_list']) > 0) {
$exit = false;
$pl = $jzUSER->loadPlaylist();
if (!is_object($pl)) {
$pl = new jzPlaylist();
}
$pl->addFromForm();
$jzUSER->storePlaylist($pl);
if (!defined('NO_AJAX_JUKEBOX')) {
$blocks = new jzBlocks();
$blocks->playlistDisplay();
exit();
}
}
else if ((isset($_POST['jz_path']) && isset($_POST['addPath']))
|| (isset($_POST['addList']) && sizeof($_POST['jz_list']) == 0)) {
$exit = false;
$guy = &new jzMediaNode($_POST['jz_path']);
if (isset($_POST['doquery']) && $_POST['query'] != "") {
if ($_POST['how'] == "search") {
$root = &new jzMediaNode();
$list = $root->search(stripSlashes($_POST['query']),"tracks",-1);
}
else {
$list = $guy->search(stripSlashes($_POST['query']),"tracks",-1);
}
$pl = $jzUSER->loadPlaylist();
$pl->add($list);
$jzUSER->storePlaylist($pl);
if (!defined('NO_AJAX_JUKEBOX')) {
$blocks = new jzBlocks();
$blocks->playlistDisplay();
exit();
}
} else {
$pl = $jzUSER->loadPlaylist();
$pl->add($guy);
$jzUSER->storePlaylist($pl);
if (!defined('NO_AJAX_JUKEBOX')) {
$blocks = new jzBlocks();
$blocks->playlistDisplay();
exit();
}
}
}
else {
$pl = new jzPlaylist();
$pl->addFromForm();
$pl->flatten();
if (isset($_POST['limit'])) {
$pl->truncate($_POST['limit']);
}
if (isset($_POST['sendListRandom'])) {
$pl->shuffle();
}
$pl->play();
}
if ($exit) {
exit();
}
break;
case "playlistAction":
writeLogData("messages","Index: Preforming a playlist action");
if ($jzUSER->getSetting('stream') === false && $jzUSER->getSetting('lofi') === false && $jzUSER->getSetting('download') === false) {
exit();
}
$exit = true;
$pl = $jzUSER->loadPlaylist();
if (isset($_POST['downloadlist'])) {
if ($jzUSER->getSetting('download') === false) {
exit();
}
$pl->download();
} else if (isset($_POST['createlist'])) {
if (strlen($_POST['playlistname']) > 0) {
$pl = new jzPlaylist();
$jzUSER->storePlaylist($pl,$_POST['playlistname']);
$_SESSION['jz_playlist'] = $pl->getID();
}
$exit = false;
} else if (isset($_POST['noaction'])) {
$exit = false;
} else {
if (isset($_POST['mode'])) {
$pl = $pl->getSmartPlaylist();
}
if ($jzUSER->getSetting('stream') === false && $jzUSER->getSetting('lofi') === false) {
exit();
}
if (isset($_POST['playplaylist']) && $_POST['playplaylist'] == "random") {
$pl->shuffle();
}
$pl->play();
}
if ($exit) exit();
break;
case "generateRandom":
writeLogData("messages","Index: Generating a random playlist");
if ($jzUSER->getSetting('stream') === false && $jzUSER->getSetting('lofi') === false) {
exit();
}
$pl = &new jzPlaylist();
// Let's time it.
$timer = microtime_float();
$pl->generate($_POST['random_play_type'],$_POST['random_play_number'],$_POST['random_play_genre']);
$timer = round(microtime_float() - $timer,2);
if ($_POST['random_play_genre'] != "") {
writeLogData('playback', "generated random playlist of ". $_POST['random_play_number'] . " tracks from genre '" . $_POST['random_play_genre'] . "' in $timer seconds.");
} else {
writeLogData('playback', "generated random playlist of ". $_POST['random_play_number'] ." tracks in $timer seconds.");
}
$pl->play();
exit();
break;
}
}
// Last thing: we want to draw a standard page, since we did not previously exit.
// TODO: check for specialty pages (search,playlistmanager,etc)
// Let's count how many of everything we have
if (!isset($_SESSION['jz_num_genres'])){
$root = &new jzMediaNode();
$_SESSION['jz_num_genres'] = $root->getSubNodeCount("nodes",distanceTo("genre"));
$_SESSION['jz_num_artists'] = $root->getSubNodeCount("nodes",distanceTo("artist"));
$_SESSION['jz_num_albums'] = $root->getSubNodeCount("nodes",distanceTo("album"));
$_SESSION['jz_num_tracks'] = $root->getSubNodeCount("nodes",distanceTo("track"));
}
// The header file defines our drawPage function.
$maindiv = (isset($_GET['maindiv']) || isset($_POST['maindiv'])) ? true : false;
// Let's check for security
$blocks = new jzBlocks();
if ($blocks->checkForSecure()){
$smarty = smartySetup();
$smarty->assign('path', getcwd());
// Now let's include the template
$smarty->display(SMARTY_ROOT. 'templates/slick/security-warning.tpl');
exit();
}
if (isset($_SESSION['current_interface'])) {
$_SESSION['ref_interface'] = $_SESSION['current_interface'];
} else {
$_SESSION['ref_interface'] = "";
}
$_SESSION['current_interface'] = $fe->name;
$_SESSION['jz_purge_file_cache'] = "false";
$fe->standardPage($node,$maindiv);
?>