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
|
<?php
/*
Copyright (c) 2001 - 2006 Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*!
@header Admin Catalog
This document handles actions for catalog creation and passes them off to the catalog class
*/
require('../modules/init.php');
if (!$GLOBALS['user']->has_access(100)) {
access_denied();
}
/* Set any vars we are going to need */
$catalog = new Catalog($_REQUEST['catalog_id']);
show_template('header');
/* Big switch statement to handle various actions */
switch ($_REQUEST['action']) {
case 'fixed':
delete_flagged($flag);
$type = 'show_flagged_songs';
include(conf('prefix') . '/templates/flag.inc');
break;
case _("Add to Catalog(s)"):
case 'add_to_catalog':
if (conf('demo_mode')) { break; }
if ($_REQUEST['catalogs'] ) {
foreach ($_REQUEST['catalogs'] as $catalog_id) {
$catalog = new Catalog($catalog_id);
$catalog->add_to_catalog($_REQUEST['update_type']);
}
}
include(conf('prefix') . '/templates/catalog.inc');
break;
case _("Add to all Catalogs"):
if (conf('demo_mode')) { break; }
/* If they are using the file MPD type, and it's currently enabled lets do a DBRefresh for em */
if (conf('mpd_method') == 'file' AND conf('allow_mpd_playback')) {
// Connect to the MPD
if (!class_exists('mpd')) { require_once(conf('prefix') . "/modules/mpd/mpd.class.php"); }
if (!is_object($myMpd)) { $myMpd = new mpd(conf('mpd_host'),conf('mpd_port')); }
if (!$myMpd->connected) {
echo "<font class=\"error\">" . _("Error Connecting") . ": " . $myMpd->errStr . "</font>\n";
log_event($_SESSION['userdata']['username'],' connection_failed ',"Error: Unable able to connect to MPD, " . $myMpd->errStr);
} // MPD connect failed
$myMpd->DBRefresh();
} // if MPD enabled
$catalogs = $catalog->get_catalogs();
foreach ($catalogs as $data) {
$data->add_to_catalog($_REQUEST['update_type']);
}
include(conf('prefix') . '/templates/catalog.inc');
break;
case _("Update Catalog(s)"):
case 'update_catalog':
/* If they are in demo mode stop here */
if (conf('demo_mode')) { break; }
if (isset($_REQUEST['catalogs'])) {
foreach ($_REQUEST['catalogs'] as $catalog_id) {
$catalog = new Catalog($catalog_id);
$catalog->verify_catalog($catalog_id->id,$_REQUEST['update_type']);
}
}
include(conf('prefix') . '/templates/catalog.inc');
break;
case _("Update All Catalogs"):
if (conf('demo_mode')) { break; }
$catalogs = $catalog->get_catalogs();
foreach ($catalogs as $data) {
$data->verify_catalog($data->id,$_REQUEST['update_type']);
}
include(conf('prefix') . '/templates/catalog.inc');
break;
case 'full_service':
/* Make sure they aren't in demo mode */
if (conf('demo_mode')) { break; }
/* This runs the clean/verify/add in that order */
foreach ($_REQUEST['catalogs'] as $catalog_id) {
$catalog = new Catalog($catalog_id);
$catalog->clean_catalog();
$catalog->count = 0;
$catalog->update_catalog();
$catalog->count = 0;
$catalog->add_to_catalog();
}
break;
case 'delete_catalog':
if (conf('demo_mode')) { break; }
if ($_REQUEST['confirm'] === 'Yes') {
$catalog = new Catalog($_REQUEST['catalog_id']);
$catalog->delete_catalog();
}
include(conf('prefix') . '/templates/catalog.inc');
break;
case 'remove_disabled':
if (conf('demo_mode')) { break; }
$song = $_REQUEST['song'];
if (count($song)) {
$catalog->remove_songs($song);
echo "<p align=\"center\">Songs Removed... </p>";
}
else {
echo "<p align=\"center\">No Songs Removed... </p>";
}
include(conf('prefix') . '/templates/catalog.inc');
break;
case _('Clean Catalog(s)'):
case 'clean_catalog':
/* If they are in demo mode stop them here */
if (conf('demo_mode')) { break; }
// Make sure they checked something
if (isset($_REQUEST['catalogs'])) {
foreach($_REQUEST['catalogs'] as $catalog_id) {
$catalog = new Catalog($catalog_id);
$catalog->clean_catalog(0,1);
} // end foreach catalogs
}
include(conf('prefix') . '/templates/catalog.inc');
break;
case 'update_catalog_settings':
if (conf('demo_mode')) { break; }
$id = strip_tags($_REQUEST['catalog_id']);
$name = strip_tags($_REQUEST['name']);
$id3cmd = strip_tags($_REQUEST['id3_set_command']);
$rename = strip_tags($_REQUEST['rename_pattern']);
$sort = strip_tags($_REQUEST['sort_pattern']);
/* Setup SQL */
$sql = "UPDATE catalog SET " .
" name = '$name'," .
" id3_set_command = '$id3cmd'," .
" rename_pattern = '$rename'," .
" sort_pattern = '$sort'" .
" WHERE id = '$id'";
$result = mysql_query($sql, dbh());
include(conf('prefix') . '/templates/catalog.inc');
break;
case _("Clean All Catalogs"):
if (conf('demo_mode')) { break; }
$catalogs = $catalog->get_catalogs();
$dead_files = array();
foreach ($catalogs as $catalog) {
$catalog->clean_catalog(0,$_REQUEST['update_type']);
}
include(conf('prefix') . '/templates/catalog.inc');
break;
case 'add_catalog':
if (conf('demo_mode')) { break; }
if ($_REQUEST['path'] AND $_REQUEST['name']) {
/* Throw all of the album art types into an array */
$art = array('id3'=>$_REQUEST['art_id3v2'],'amazon'=>$_REQUEST['art_amazon'],'folder'=>$_REQUEST['art_folder']);
/* Create the Catalog */
$catalog->new_catalog($_REQUEST['path'],
$_REQUEST['name'],
$_REQUEST['id3set_command'],
$_REQUEST['rename_pattern'],
$_REQUEST['sort_pattern'],
$_REQUEST['type'],
$_REQUEST['gather_art'],
$_REQUEST['parse_m3u'],
$art);
include(conf('prefix') . '/templates/catalog.inc');
}
else {
$error = "Please complete the form.";
include(conf('prefix') . '/templates/add_catalog.inc');
}
break;
case 'really_clear_stats':
if (conf('demo_mode')) { break; }
if ($_REQUEST['confirm'] == 'Yes') {
clear_catalog_stats();
}
include(conf('prefix') . '/templates/catalog.inc');
break;
case 'show_add_catalog':
include(conf('prefix') . '/templates/add_catalog.inc');
break;
case 'clear_now_playing':
if (conf('demo_mode')) { break; }
clear_now_playing();
show_confirmation(_("Now Playing Cleared"),_("All now playing data has been cleared"),"/admin/catalog.php");
break;
case 'Clear Catalog':
if (conf('demo_mode')) { break; }
show_confirm_action(_("Do you really want to clear your catalog?"),
"admin/catalog.php", "action=really_clear_catalog");
print("<hr />\n");
break;
case 'clear_stats':
if (conf('demo_mode')) { break; }
show_confirm_action(_("Do you really want to clear the statistics for this catalog?"),
"admin/catalog.php", "action=really_clear_stats");
break;
case 'show_disabled':
if (conf('demo_mode')) { break; }
$songs = $catalog->get_disabled();
if (count($songs)) {
require (conf('prefix') . '/templates/show_disabled_songs.inc');
}
else {
echo "<p class=\"error\" align=\"center\">No Disabled songs found</p>";
}
break;
case 'show_delete_catalog':
if (conf('demo_mode')) { break; }
show_confirm_action(_("Do you really want to delete this catalog?"),
"admin/catalog.php",
"catalog_id=" . $_REQUEST['catalog_id'] . "&action=delete_catalog");
break;
case 'show_flagged_songs':
if (conf('demo_mode')) { break; }
$type = $_REQUEST['action'];
include (conf('prefix') . '/templates/flag.inc');
break;
case 'show_customize_catalog':
include(conf('prefix') . '/templates/customize_catalog.inc');
break;
case 'gather_album_art':
echo "<b>" . _("Starting Album Art Search") . ". . .</b><br /><br />\n";
flush();
$catalogs = $catalog->get_catalogs();
foreach ($catalogs as $data) {
$data->get_album_art();
}
echo "<b>" . _("Album Art Search Finished") . ". . .</b><br />\n";
break;
default:
include(conf('prefix') . '/templates/catalog.inc');
break;
} // end switch
/* Show the Footer */
show_footer();
?>
|