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
|
<?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.
*/
/**
* Flag Admin Document
* This document handles the administrative aspects of
* flagging.
*/
require('../lib/init.php');
if (!$GLOBALS['user']->has_access('100')) {
access_denied();
exit();
}
show_template('header');
$action = scrub_in($_REQUEST['action']);
switch ($action) {
case 'edit_song':
$catalog = new Catalog();
$song = new Song($_REQUEST['song_id']);
$new_song = new Song();
/* Setup the vars so we can use the update_song function */
$new_song->title = revert_string(scrub_in($_REQUEST['title']));
$new_song->track = revert_string(scrub_in($_REQUEST['track']));
$new_song->year = revert_string(scrub_in($_REQUEST['year']));
$new_song->comment = revert_string(scrub_in($_REQUEST['comment']));
/* If no change in string take Drop down */
if (strcasecmp(stripslashes($_REQUEST['genre_string']),$song->get_genre_name()) == 0) {
$genre = $song->get_genre_name($_REQUEST['genre']);
}
else {
$genre = scrub_in($_REQUEST['genre_string']);
}
if (strcasecmp(stripslashes($_REQUEST['album_string']),$song->get_album_name()) == 0) {
$album = $song->get_album_name($_REQUEST['album']);
}
else {
$album = scrub_in($_REQUEST['album_string']);
}
if (strcasecmp(stripslashes($_REQUEST['artist_string']),$song->get_artist_name()) == 0) {
$artist = $song->get_artist_name($_REQUEST['artist']);
}
else {
$artist = scrub_in($_REQUEST['artist_string']);
}
/* Use the check functions to get / create ids for this info */
$new_song->genre = $catalog->check_genre(revert_string($genre));
$new_song->album = $catalog->check_album(revert_string($album));
$new_song->artist = $catalog->check_artist(revert_string($artist));
/* Update this mofo, store an old copy for cleaning */
$old_song = new Song();
$old_song->artist = $song->artist;
$old_song->album = $song->album;
$old_song->genre = $song->genre;
$song->update_song($song->id,$new_song);
/* Now that it's been updated clean old junk entries */
$catalog = new Catalog();
$cleaned = $catalog->clean_single_song($old_song);
/* Add a tagging record of this so we can fix the file */
if ($_REQUEST['flag']) {
$flag = new Flag();
$flag->add($song->id,'song','retag','Edited Song, auto-tag');
}
if (isset($cleaned['artist']) || isset($cleaned['album'])) { $_SESSION['source'] = conf('web_path') . '/index.php'; }
show_confirmation(_('Song Updated'),_('The requested song has been updated'),$_SESSION['source']);
break;
case 'reject_flag':
$flag_id = scrub_in($_REQUEST['flag_id']);
$flag = new Flag($flag_id);
$flag->delete_flag();
$flag->format_name();
$url = return_referer();
$title = _('Flag Removed');
$body = _('Flag Removed from') . " " . $flag->name;
show_confirmation($title,$body,$url);
break;
case 'show_edit_song':
$_SESSION['source'] = return_referer();
$song = new Song($_REQUEST['song']);
$song->format_song();
require_once (conf('prefix') . '/templates/show_edit_song.inc.php');
break;
case 'disable':
$song_obj = new Song();
// If we pass just one, make it still work
if (!is_array($_REQUEST['song_ids'])) { $song_obj->update_enabled(0,$_REQUEST['song_ids']); }
else {
foreach ($_REQUEST['song_ids'] as $song_id) {
$song_obj->update_enabled(0,$song_id);
} // end foreach
} // end else
show_confirmation(_('Songs Disabled'),_('The requested song(s) have been disabled'),return_referer());
break;
case 'enabled':
$song_obj = new Song();
// If we pass just one, make it still work
if (!is_array($_REQUEST['song_ids'])) { $song_obj->update_enabled(1,$_REQUEST['song_ids']); }
else {
foreach ($_REQUEST['song_ids'] as $song_id) {
$song_obj->update_enabled(1,$song_id);
} // end foreach
} // end else
show_confirmation(_('Songs Enabled'),_('The requested song(s) have been enabled'),return_referer());
break;
case 'show_flagged':
$flag = new Flag();
$flagged = $flag->get_flagged();
echo "<span class=\"header1\">" . _('Flagged Records') . "</span>\n";
require (conf('prefix') . '/templates/show_flagged.inc.php');
break;
default:
break;
} // end switch
/*
@function edit_song_info
@discussion yea this is just wrong
*/
function edit_song_info($song) {
$info = new Song($song);
preg_match("/^.*\/(.*?)$/",$info->file, $short);
$filename = htmlspecialchars($short[1]);
if(preg_match('/\.ogg$/',$short[1]))
{
$ogg = TRUE;
$oggwarn = "<br/><br><em>This file is an OGG file, which Ampache only has limited support for.<br/>";
$oggwarn .= "You can make changes to the database here, but Ampache will not change the actual file's information.</em><br/><br/>";
}
echo <<<EDIT_SONG_1
<p><b>Editing $info->title</b></p>
<form name="update_song" method="post" action="song.php">
<table class="border" cellspacing="0">
<tr class="table-header">
<td colspan="3"><b>Editing $info->title</b></td>
</tr>
<tr class="odd">
<td>File:</td>
<td colspan="2">$filename $oggwarn</td>
</tr>
<tr class="odd">
<td>Title:</td>
<td colspan="2"><input type="text" name="title" size="60" value="$info->title" /></td>
</tr>
<tr class="even">
<td>Artist:</td>
<td>
EDIT_SONG_1;
show_artist_pulldown($info->artist);
echo <<<EDIT_SONG_2
</td>
<td>or <input type="text" name="new_artist" size="30" value="" /></td>
</tr>
<tr class="odd">
<td>Album:</td>
<td>
EDIT_SONG_2;
show_album_pulldown($info->album);
echo <<<EDIT_SONG_3
</td>
<td>or <input type="text" name="new_album" size="30" value="" /></td>
</tr>
<tr class="even">
<td>Track:</td>
<td colspan="2"><input type="text" size="4" maxlength="4" name="track" value="$info->track"></input></td>
</tr>
<tr class="odd">
<td>Genre:</td>
<td colspan="2">
EDIT_SONG_3;
show_genre_pulldown('genre',$info->genre);
echo <<<EDIT_SONG_4
</td>
</tr>
<tr class="even">
<td>Year</td>
<td colspan="2"><input type="text" size="4" maxlength="4" name="year" value="$info->year"></input></td>
</tr>
EDIT_SONG_4;
if(!$ogg)
{
echo <<<EDIT_SONG_5
<tr class="even">
<td> </td>
<td><input type="checkbox" name="update_id3" value="yes"></input> Update id3 tags </td>
<td> </td>
</tr>
EDIT_SONG_5;
}
echo <<<EDIT_SONG_6
<tr class="odd">
<td> </td>
<td colspan="2">
<input type="hidden" name="song" value="$song" />
<input type="hidden" name="current_artist_id" value="$info->artist" />
<input type="submit" name="action" value="Update" />
</td>
</tr>
</table>
</form>
EDIT_SONG_6;
}
show_footer();
?>
|