summaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to 'admin')
-rw-r--r--admin/access.php85
-rw-r--r--admin/album.php114
-rw-r--r--admin/artist.php121
-rw-r--r--admin/catalog.php282
-rw-r--r--admin/duplicates.php59
-rw-r--r--admin/flags.php91
-rw-r--r--admin/index.php96
-rw-r--r--admin/mail.php139
-rw-r--r--admin/orphan.php71
-rw-r--r--admin/preferences.php92
-rw-r--r--admin/song.php182
-rw-r--r--admin/users.php181
12 files changed, 1513 insertions, 0 deletions
diff --git a/admin/access.php b/admin/access.php
new file mode 100644
index 00000000..31793907
--- /dev/null
+++ b/admin/access.php
@@ -0,0 +1,85 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 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.
+
+*/
+
+require('../modules/init.php');
+
+
+/* Scrub in the Needed vars */
+$action = scrub_in($_REQUEST['action']);
+$access_id = scrub_in($_REQUEST['access_id']);
+$access = new Access($access_id);
+
+if (!$user->has_access(100)) {
+ header("Location: http://" . conf('web_path') . "/index.php?access=denied");
+ exit();
+}
+
+
+show_template('header');
+
+show_menu_items('Admin');
+show_admin_menu('Access Lists');
+show_clear();
+if ( $action == 'show_confirm_delete' ) {
+ show_confirm_action(_("Do you really want to delete this Access Record?"), "admin/access.php", "access_id=" . $_REQUEST['access_id'] . "&action=delete_host");
+}
+/*!
+ @action delete_host
+ @discussion deletes an access list entry
+*/
+elseif ( $action == 'delete_host' ) {
+ $access->delete($_REQUEST['access_id']);
+ show_confirmation(_("Entry Deleted"),_("Your Access List Entry has been removed"),"admin/access.php");
+
+} // delete_host
+/*!
+ @action add_host
+ @discussion add a new access list entry
+*/
+elseif ($action == 'add_host') {
+
+ $access->create($_REQUEST['name'], $_REQUEST['start'],$_REQUEST['end'],$_REQUEST['level']);
+ show_confirmation(_("Entry Added"),_("Your new Access List Entry has been created"),"admin/access.php");
+
+} // add_host
+/*!
+ @action show_add_host
+ @discussion show the add host box
+*/
+elseif ( $action == 'show_add_host' ) {
+ include(conf('prefix') . "/templates/show_add_access.inc");
+}
+else {
+ $list = array();
+ $list = $access->get_access_list();
+ include(conf('prefix') ."/templates/show_access_list.inc");
+}
+echo "<br /><br />";
+
+show_admin_menu('Access Lists');
+show_menu_items('Admin');
+
+?>
+
+
+</body>
+</html>
diff --git a/admin/album.php b/admin/album.php
new file mode 100644
index 00000000..7b8751f0
--- /dev/null
+++ b/admin/album.php
@@ -0,0 +1,114 @@
+<?php
+
+/*
+
+ Copyright (c) 2004 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 Album Mojo
+ Update the album information for the site.
+
+*/
+
+require('../modules/init.php');
+
+
+if (!$user->has_access(100)) {
+ header("Location:" . conf('web_path') . "/index.php?access=denied");
+ exit();
+}
+
+
+if ( $action == 'Change Name' ) {
+
+ update_album_name($album, $new_name);
+
+ if ( $update_tag ) {
+ // get songs associated with this
+ $songs = get_songs_from_album($album);
+
+ // run update_local_mp3
+ $total_updated = update_local_mp3($new_name, 'album', $songs);
+ $update_text = "Updated the database and $total_updated local files.";
+ }
+
+ // set the action to view so everybody can see the changes
+ $action = 'View';
+}
+
+show_template('header');
+
+show_menu_items('Admin');
+show_admin_menu('Catalog');
+
+?>
+
+<p>Use this form to change the name(s) of albums in the database. In order to update your
+local MP3's your Apache user must have write-permission to your MP3's.</p>
+
+<form name="album" method="post" action="album.php">
+<table>
+ <tr>
+ <td>Select Album:</td>
+ <td> <?php show_album_pulldown($album) ?> </td>
+ <td> <input type=submit name=action value=View> </td>
+ </tr>
+</table>
+</form>
+
+<hr>
+
+<?php
+
+// if album exists then show some info
+if ( $album and $action == 'View' ) {
+ $album_name = get_album_name($album);
+
+?>
+
+<p style="color: red;"><?= $update_text ?></p>
+
+<form name="album_change" method=post action="album.php">
+ <table>
+ <tr>
+ <td>Album Name:</td>
+ <td><input type=text name="new_name" value="<?= $album_name ?>" size="50"></td>
+ <td> &nbsp; </td>
+ <td><input type=submit name=action value="Change Name"></td>
+ <tr>
+ <td> &nbsp; </td> <td><input type="checkbox" name="update_tag">
+ Update MP3 tag <b>Note: this will only modify your local MP3's</b>
+ </td>
+ </tr>
+ </table>
+ <input type=hidden name=album value="<?= $album ?>">
+</form>
+
+<?php
+
+ $song_ids = get_song_ids_from_album($album);
+ show_songs($song_ids, 0);
+}
+
+show_footer();
+?>
+
+</body>
+</html>
diff --git a/admin/artist.php b/admin/artist.php
new file mode 100644
index 00000000..ebec5db6
--- /dev/null
+++ b/admin/artist.php
@@ -0,0 +1,121 @@
+<?php
+
+/*
+
+ Copyright (c) 2001 - 2005 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 Artist page
+ Update the artist information for the site.
+
+*/
+
+require('../modules/init.php');
+
+
+if (!$user->has_access(100)) {
+ header("Location:". conf('web_path') . "/index.php?access=denied");
+ exit();
+}
+
+$dbh = dbh();
+
+if ( $action == 'Change Name' ) {
+ if ( $settings[demo_mode] == 'false' && $username != $settings[demo_user] ) {
+ $old_artist_name = get_artist_name($artist);
+ update_artist_name($artist, $new_name);
+
+ if ( $update_tag ) {
+ // get songs associated with this
+ $song_ids = get_song_ids_from_artist($artist);
+
+ // run update_local_mp3
+ $total_updated = update_local_mp3($new_name, 'artist', $song_ids);
+ $update_text = "Updated $old_artist_name to $new_name and $total_updated local files.";
+ }
+ else {
+ $update_text = "Updated $old_artist_name to $new_name.";
+ }
+
+ // set the action to view so everybody can see the changes
+ $action = 'View';
+ }
+}
+
+show_template('header');
+
+show_menu_items("..");
+show_admin_menu('Catalog');
+
+?>
+
+<p>Use this form to change the name(s) of artists in the database. In order to update your
+local MP3's your Apache user must have write-permission to your MP3's.</p>
+
+<form name="artist" method="post" action="artist.php">
+<table>
+ <tr>
+ <td>Select Artist:</td>
+ <td> <?php show_artist_pulldown($artist) ?> </td>
+ <td> <input type=submit name=action value=View> </td>
+ </tr>
+</table>
+</form>
+
+<hr>
+
+<?php
+
+// if artist exists then show some info
+if ( $artist and $action == 'View' ) {
+ $sql = "SELECT name FROM artist WHERE id='$artist'";
+ $db_result = mysql_query($sql, $dbh);
+
+ $r = mysql_fetch_row($db_result);
+ $artist_name = $r[0];
+
+?>
+
+<p style="color: red;"><?= $update_text ?></p>
+
+<form name="artist_change" method=post action="artist.php">
+ <table>
+ <tr>
+ <td>Artist Name:</td> <td><input type=text name="new_name" value="<?= $artist_name ?>" size="50"></td>
+ <td> &nbsp; </td> <td><input type=submit name=action value="Change Name"></td>
+ </tr>
+ <tr>
+ <td> &nbsp; </td> <td><input type="checkbox" name="update_tag">
+ Update MP3 tag <b>Note: this will only modify your local MP3's</b>
+ </td>
+ </tr>
+ </table>
+ <input type="hidden" name="artist" value="<?= $artist ?>">
+</form>
+
+<?php
+
+ show_albums_for_artist($artist);
+}
+
+?>
+
+</body>
+</html>
diff --git a/admin/catalog.php b/admin/catalog.php
new file mode 100644
index 00000000..d3c4bc6d
--- /dev/null
+++ b/admin/catalog.php
@@ -0,0 +1,282 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 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 (!$user->has_access(100)) {
+ access_denied();
+}
+
+
+/* Set any vars we are going to need */
+$catalog = new Catalog($_REQUEST['catalog_id']);
+
+show_template('header');
+
+/* Generate the menus */
+show_menu_items('Admin');
+show_admin_menu('Catalog');
+show_clear();
+
+
+/* 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)"):
+ 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; }
+ $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)"):
+ 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 '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)"):
+ 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,$_REQUEST['update_type']);
+ } // 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['confrim'] == '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");
+ print("<hr>\n");
+ 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 'Update Flags':
+ if (conf('demo_mode')) { break; }
+ echo "<pre>";
+ print_r($_REQUEST);
+ echo "</pre>";
+ 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;
+ // (Added by Cucumber 20050216)
+ case 'dump_album_art':
+ $catalogs = $catalog->get_catalogs();
+
+ foreach ($catalogs as $data) {
+ $data->dump_album_art();
+ }
+ break;
+
+ default:
+ include(conf('prefix') . '/templates/catalog.inc');
+
+} // end switch
+echo "<br /><br />";
+show_admin_menu('Catalog');
+show_menu_items('Admin');
+
+?>
+
+</body>
+</html>
diff --git a/admin/duplicates.php b/admin/duplicates.php
new file mode 100644
index 00000000..739472c8
--- /dev/null
+++ b/admin/duplicates.php
@@ -0,0 +1,59 @@
+<?php
+
+/*
+
+ Copyright (c) 2001 - 2005 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.
+
+*/
+
+
+// Allows users to search for duplicate songs in their catalogs
+
+require_once ("../modules/init.php");
+require_once( conf('prefix').'/lib/duplicates.php');
+
+
+if (!$user->has_access(100)) {
+ header ("Location: " . conf('web_path') . "/index.php?access=denied");
+ exit();
+}
+
+$action = scrub_in($_REQUEST['action']);
+$search_type = scrub_in($_REQUEST['search_type']);
+
+show_template('header');
+
+show_menu_items('Admin');
+show_admin_menu('Users');
+
+
+switch ($action)
+{
+ case 'search':
+ $flags = get_duplicate_songs($search_type);
+ show_duplicate_songs($flags,$search_type);
+ break;
+ default:
+ show_duplicate_searchbox($search_type);
+}
+
+show_footer();
+?>
+
+</body>
+</html>
diff --git a/admin/flags.php b/admin/flags.php
new file mode 100644
index 00000000..f7965d03
--- /dev/null
+++ b/admin/flags.php
@@ -0,0 +1,91 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 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 Flags Mojo
+*/
+
+require_once ("../modules/init.php");
+require_once( conf('prefix').'/lib/flag.php');
+
+if (!$user->has_access(100)) {
+ header ("Location: " . conf('web_path') . "/index.php?access=denied");
+ exit();
+}
+
+
+$action = scrub_in($_REQUEST['action']);
+show_template('header');
+
+show_menu_items('Admin');
+show_admin_menu('Users');
+
+switch ($action)
+{
+ case 'show':
+ $flags = get_flagged_songs();
+ show_flagged_songs($flags);
+ break;
+ case 'Set Flags':
+ case 'Update Flags':
+ $flags = scrub_in($_REQUEST['song']);
+ update_flags($flags);
+ $newflags = get_flagged_songs();
+ show_flagged_songs($newflags);
+ break;
+ case 'Edit Selected':
+ $flags = scrub_in($_REQUEST['song']);
+ $count = add_to_edit_queue($flags);
+ if($count) show_edit_flagged();
+ break;
+ case 'Next':
+ $song = scrub_in($_REQUEST['song']);
+ update_song_info($song);
+ show_edit_flagged();
+ // Pull song ids from an edit queue in $_SESSION,
+ // And edit them one at a time
+ break;
+ case 'Skip':
+ $count = add_to_edit_queue(scrub_in($_REQUEST['song']));
+ if($count) show_edit_flagged();
+ case 'Flag Songs':
+ break;
+ case 'Remove Flags':
+ break;
+ case 'Clear Edit List':
+ unset($_SESSION['edit_queue']);
+
+ case 'Done':
+ $song = scrub_in($_REQUEST['song']);
+ update_song_info($song);
+ default:
+ $flags = get_flagged_songs();
+ show_flagged_songs($flags);
+
+}
+
+show_footer();
+?>
+
+</body>
+</html>
diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 00000000..a830897a
--- /dev/null
+++ b/admin/index.php
@@ -0,0 +1,96 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 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 Index
+ Do most of the dirty work of displaying the mp3 catalog
+
+*/
+
+require ("../modules/init.php");
+
+$action = scrub_in($_REQUEST['action']);
+
+if (!$user->has_access(100)) {
+ header ("Location: " . conf('web_path') . "/index.php?access=denied");
+ exit();
+}
+
+
+// let's set the preferences here so that they take affect on the fly
+if ( $action == 'Update Preferences' ) {
+ update_site_preferences($preferences_id, 'true', $new_m_host, $new_w_host,
+ $new_site_title, $new_login_message, $new_session_lifetime, $new_font,
+ $new_background_color, $new_primary_color, $new_secondary_color,
+ $new_primary_font_color, $new_secondary_font_color,
+ $new_error_color, $new_popular_threshold);
+ // reload the preferences now
+ set_preferences();
+}
+
+show_template('header');
+show_menu_items('Admin');
+
+if ( $action == 'show_site_preferences' ) {
+ show_admin_menu('Site Preferences');
+}
+elseif ( ($action == 'show_users') || ($action == 'show_new_user')) {
+ show_admin_menu('Users');
+}
+elseif ( $action == 'show_update_catalog' ) {
+ show_admin_menu('Catalog');
+}
+else {
+ show_admin_menu('...');
+}
+
+if ( $action == 'Update Preferences' ) {
+ $action = 'show_preferences';
+}
+elseif ( $action == 'show_update_catalog' ) {
+ show_update_catalog();
+}
+elseif ( $action == 'show_file_manager' ) {
+ show_file_manager();
+}
+elseif ( $action == 'show_site_preferences' ) {
+ $user = new User(0);
+ require (conf('prefix') . "/templates/show_preferences.inc");
+}
+elseif ( $action == 'show_preferences' ) {
+ $user = new User($_REQUEST['user_id']);
+ require (conf('prefix') . "/templates/show_preferences.inc");
+}
+elseif ( $action == 'show_orphaned_files' ) {
+ show_orphaned_files();
+}
+else {
+ require (conf('prefix') . "/templates/show_admin_index.inc");
+} // if they didn't pick anything
+
+echo "<br /><br />";
+show_admin_menu('');
+show_menu_items('Admin');
+?>
+
+</body>
+</html>
diff --git a/admin/mail.php b/admin/mail.php
new file mode 100644
index 00000000..d5aef413
--- /dev/null
+++ b/admin/mail.php
@@ -0,0 +1,139 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 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 Mail Admin Page
+ Means to mail your users or give updates about the server
+
+*/
+
+require('../modules/init.php');
+
+if (!$user->has_access(100)) {
+ access_denied();
+}
+
+
+$action = scrub_in($_POST['action']);
+$to = scrub_in($_REQUEST['to']);
+$subject = stripslashes(scrub_in($_POST['subject']));
+$message = stripslashes(scrub_in($_POST['message']));
+
+if ( $action == 'send_mail' && !conf('demo_mode')) {
+ $user = new User(0,$_SESSION['userdata']['id']);
+ // do the mail mojo here
+ if ( $to == 'all' ) {
+ $sql = "SELECT * FROM user WHERE email IS NOT NULL";
+ }
+ elseif ( $to == 'users' ) {
+ $sql = "SELECT * FROM user WHERE access='users' AND email IS NOT NULL";
+ }
+ elseif ( $to == 'admins' ) {
+ $sql = "SELECT * FROM user WHERE access='admin' AND email IS NOT NULL";
+ }
+
+ $db_result = mysql_query($sql, dbh());
+
+ $recipient = '';
+
+ while ( $u = mysql_fetch_object($db_result) ) {
+ $recipient .= "$u->fullname <$u->email>, ";
+ }
+
+ // Remove the last , from the recipient
+ $recipient = rtrim($recipient,",");
+
+ $from = $user->fullname."<".$user->email.">";
+
+ // woohoo!!
+ mail ($from, $subject, $message,
+ "From: $from\r\n".
+ "Bcc: $recipient\r\n");
+
+ // tell them that it was sent
+ $complete_text = "Your message was successfully sent.";
+}
+
+if ( empty($to) ) {
+ $to = 'all';
+}
+
+if ( empty($subject) ) {
+ $site_title = conf('site_title');
+ $subject = "[$site_title] ";
+}
+
+show_template('header');
+
+show_menu_items('Admin');
+show_admin_menu('Mail Users');
+show_clear();
+?>
+
+<form name="mail" method="post" action="<?php echo conf('web_path'); ?>/admin/mail.php" enctype="multipart/form-data">
+
+<p><font color="<?php echo $error_color; ?>"><?php echo $complete_text; ?></font></p>
+
+<table>
+ <tr>
+ <td><?php echo _("Mail to"); ?>:</td>
+ <td>
+ <select name="to">
+ <option value="all" <?php if ($to == 'all') { echo "SELECTED"; } ?>>All</option>
+ <option value="users" <?php if ($to == 'user') { echo "SELECTED"; } ?>>Users</option>
+ <option value="admins" <?php if ($to == 'admin') { echo "SELECTED"; } ?>>Admins</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td><?php echo _("Subject"); ?>:</td>
+ <td>
+ <input name="subject" value="<?php echo $_POST['subject']; ?>" size="50"></input>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top"><?php echo _("Message"); ?>:</td>
+ <td>
+ <textarea class="input" name="message" rows="20" cols="70"><?php echo $message; ?></textarea>
+ </td>
+ </tr>
+
+ <tr>
+ <td>&nbsp;</td>
+ <td>
+ <input type="hidden" name="action" value="send_mail" />
+ <input type="submit" value="<?php echo _("Send Mail"); ?>" />
+ </td>
+ </tr>
+</table>
+
+</form>
+<br /><br />
+<?php
+ show_admin_menu('Mail Users');
+ show_menu_items('Admin');
+?>
+
+</body>
+</html>
diff --git a/admin/orphan.php b/admin/orphan.php
new file mode 100644
index 00000000..dfeee13b
--- /dev/null
+++ b/admin/orphan.php
@@ -0,0 +1,71 @@
+<?php
+
+/*
+
+ Copyright (c) 2001 - 2005 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 Orphaned Admin Page
+ View and edit orphan files
+
+*/
+
+require('../modules/init.php');
+
+
+if (!$user->has_access(100)) {
+ header("Location: " . conf('web_path') . "/index.php?access=denied");
+ exit();
+}
+
+
+if ( $type and $action == 'show_songs' ) {
+ print("<p style=\"font-size: 12px; font-weight: bold;\"> Orphaned Songs with missing $type information </p>");
+
+ $song_ids = get_orphan_songs($type);
+ show_songs($song_ids);
+}
+
+show_template('header');
+
+show_menu_items('Admin');
+show_admin_menu('Catalog');
+
+if ( $action == 'show_orphan_songs' ) {
+ print("<p style=\"font-size: 12px; font-weight: bold;\"> Orphaned songs with no artist </p>");
+
+ $song_ids = get_orphan_songs();
+ show_songs($song_ids);
+}
+elseif ( $action == 'show_orphan_albums' ) {
+ print("<p style=\"font-size: 12px; font-weight: bold;\"> Orphaned albums with no name </p>");
+
+ $song_ids = get_orphan_albums();
+ show_songs($song_ids);
+}
+
+?>
+
+
+<hr>
+
+</body>
+</html>
diff --git a/admin/preferences.php b/admin/preferences.php
new file mode 100644
index 00000000..2fa729eb
--- /dev/null
+++ b/admin/preferences.php
@@ -0,0 +1,92 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 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 Preferences page
+ Preferences page for whole site, and where
+ the admins do editing of other users preferences
+
+*/
+
+require('../modules/init.php');
+
+
+if (!$user->has_access(100)) {
+ access_denied();
+}
+
+$user_id = intval(scrub_in($_REQUEST['user_id']));
+
+
+switch(scrub_in($_REQUEST['action'])) {
+
+ case 'user':
+ $temp_user = new User(0,$user_id);
+ $user_id = $temp_user->id;
+ $fullname = "ADMIN - " . $temp_user->fullname;
+ $preferences = $temp_user->get_preferences();
+ break;
+ case 'update_preferences':
+ if (conf('demo_mode')) { break; }
+ update_preferences($user_id);
+ if ($user_id != '0') {
+ $temp_user = new User(0,$user_id);
+ $fullname = "ADMIN - " . $temp_user->fullname;
+ $preferences = $temp_user->get_preferences();
+ }
+ else {
+ $preferences = get_site_preferences();
+ }
+ break;
+ case 'fix_preferences':
+ $temp_user = new User(0,$user_id);
+ $temp_user->fix_preferences();
+ $preferences = $temp_user->get_preferences();
+ break;
+ default:
+ $user_id = 0;
+ $preferences = get_site_preferences();
+ $fullname = "Site";
+ break;
+
+} // End Switch Action
+
+
+// HEADER
+show_template('header');
+show_menu_items('Admin');
+show_admin_menu('Admin Preferences');
+show_clear();
+// HEADER
+
+// Set Target
+$target = "/admin/preferences.php";
+
+// Show the default preferences page
+require (conf('prefix') . "/templates/show_preferences.inc");
+
+
+// FOOTER
+show_admin_menu('Admin Preferences');
+show_menu_items('Admin');
+
+?>
diff --git a/admin/song.php b/admin/song.php
new file mode 100644
index 00000000..cf38a14f
--- /dev/null
+++ b/admin/song.php
@@ -0,0 +1,182 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 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 Song Admin Files
+ Edit song information. Can be just DB or file based (update MP3 ID3 tags).
+
+*/
+
+require('../modules/init.php');
+require_once(conf('prefix').'/lib/flag.php');
+
+if (!$user->has_access('100')) {
+ access_denied();
+}
+
+
+$action = scrub_in($_REQUEST['action']);
+$song = scrub_in($_REQUEST['song']);
+
+
+show_template('header');
+
+show_menu_items('Admin');
+show_admin_menu('Catalog');
+
+$song_obj = new Song($_REQUEST['song_id']);
+
+switch($action)
+{
+ case "Update":
+ case "update";
+ update_song_info($song);
+ edit_song_info($song);
+ break;
+ case "Edit":
+ case "edit":
+ edit_song_info($song);
+ break;
+ case "disable":
+
+ // If we pass just one, make it still work
+ if (!is_array($_REQUEST['song_ids'])) { $song_obj->update_enabled('disabled',$_REQUEST['song_ids']); }
+ else {
+ foreach ($_REQUEST['song_ids'] as $song_id) {
+ $song_obj->update_enabled('disabled',$song_id);
+ } // end foreach
+ } // end else
+ show_confirmation(_("Songs Disabled"),_("The requested song(s) have been disabled"),return_referer());
+ break;
+ case "enabled":
+ // If we pass just one, make it still work
+ if (!is_array($_REQUEST['song_ids'])) { $song_obj->update_enabled('enabled',$_REQUEST['song_ids']); }
+ else {
+ foreach ($_REQUEST['song_ids'] as $song_id) {
+ $song_obj->update_enabled('enabled',$song_id);
+ } // end foreach
+ } // end else
+ show_confirmation(_("Songs Enabled"),_("The requested song(s) have been enabled"),return_referer());
+ break;
+
+ default:
+ echo "Don't know what to do yet.";
+}
+
+
+/*
+ @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($info->genre, 1);
+echo <<<EDIT_SONG_4
+ <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>&nbsp;</td>
+ <td><input type="checkbox" name="update_id3" value="yes">&nbsp;Update id3 tags</input></td>
+ <td>&nbsp;</td>
+ </tr>
+EDIT_SONG_5;
+}
+echo <<<EDIT_SONG_6
+ <tr class="odd">
+ <td> &nbsp; </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;
+}
+
+?>
+<hr>
+
+</body>
+</html>
diff --git a/admin/users.php b/admin/users.php
new file mode 100644
index 00000000..350d1289
--- /dev/null
+++ b/admin/users.php
@@ -0,0 +1,181 @@
+<?php
+
+/*
+
+ Copyright (c) 2001 - 2005 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 Users Admin Page
+ Handles User management functions
+
+*/
+
+require_once ("../modules/init.php");
+
+if (!$user->has_access(100)) {
+ access_denied();
+}
+
+
+$action = scrub_in($_REQUEST['action']);
+
+
+show_template('header');
+
+show_menu_items('Admin');
+show_admin_menu('Users');
+show_clear();
+
+$user_id = scrub_in($_REQUEST['user']);
+$temp_user = new User($user_id);
+
+switch ($action) {
+ case 'edit':
+ if (conf('demo_mode')) { break; }
+ show_user_form($temp_user->id,
+ $temp_user->username,
+ $temp_user->fullname,
+ $temp_user->email,
+ $temp_user->access,
+ 'edit_user',
+ '');
+ break;
+
+ case 'update_user':
+ if (conf('demo_mode')) { break; }
+
+ /* Clean up the variables */
+ $username = scrub_in($_REQUEST['new_username']);
+ $fullname = scrub_in($_REQUEST['new_fullname']);
+ $email = scrub_in($_REQUEST['new_email']);
+ $access = scrub_in($_REQUEST['user_access']);
+ $pass1 = scrub_in($_REQUEST['new_password_1']);
+ $pass2 = scrub_in($_REQUEST['new_password_2']);
+
+ /* Setup the temp user */
+ $thisuser = new User($username);
+
+ /* Verify Input */
+ if (empty($username)) {
+ $GLOBALS['error']->add_error('username',_("Error Username Required"));
+ }
+ if ($pass1 !== $pass2 AND !empty($pass1)) {
+ $GLOBALS['error']->add_error('password',_("Error Passwords don't match"));
+ }
+
+ /* If we've got an error then break! */
+ if ($GLOBALS['error']->error_state) {
+ show_user_form($temp_user->id,
+ $thisuser->username,
+ $thisuser->fullname,
+ $thisuser->email,
+ $thisuser->access,
+ 'edit_user',
+ '');
+ break;
+ } // if we've had an oops!
+
+ if ($access != $thisuser->access) {
+ $thisuser->update_access($access);
+ }
+ if ($email != $thisuser->email) {
+ $thisuser->update_email($email);
+ }
+ if ($username != $thisuser->username) {
+ $thisuser->update_username($username);
+ }
+ if ($fullname != $user->fullname) {
+ $thisuser->update_fullname($fullname);
+ }
+ if ($pass1 == $pass2 && strlen($pass1)) {
+ $thisuser->update_password($pass1);
+ }
+ show_confirmation("User Updated", $thisuser->username . "'s information has been updated","admin/users.php");
+ break;
+ case 'add_user':
+ if (conf('demo_mode')) { break; }
+ $username = scrub_in($_REQUEST['new_username']);
+ $fullname = scrub_in($_REQUEST['new_fullname']);
+ $email = scrub_in($_REQUEST['new_email']);
+ $access = scrub_in($_REQUEST['user_access']);
+ $pass1 = scrub_in($_REQUEST['new_password_1']);
+ $pass2 = scrub_in($_REQUEST['new_password_2']);
+ if (($pass1 !== $pass2)) {
+ $GLOBALS['error']->add_error('password',_("Error Passwords don't match"));
+ }
+ if (empty($username)) {
+ $GLOBALS['error']->add_error('username',_("Error Username Required"));
+ }
+ if (!$user->create($username, $fullname, $email, $pass1, $access)) {
+ $GLOBALS['error']->add_error('general',"Error: Insert Failed");
+ }
+ /* If we end up with an error */
+ if ($GLOBALS['error']->error_state) {
+ show_user_form('','$username','$fullname','$email','$access','new_user','');
+ break;
+ }
+ show_confirmation("New User Added",$username . " has been created with an access level of " . $access,"admin/users.php");
+ break;
+ case 'delete':
+ if (conf('demo_mode')) { break; }
+ show_confirm_action(_("Are you sure you want to permanently delete") . " $temp_user->fullname ($temp_user->username) ?",
+ "admin/users.php",
+ "action=confirm_delete&user=$temp_user->username");
+ break;
+
+ case 'confirm_delete':
+ if (conf('demo_mode')) { break; }
+ if ($_REQUEST['confirm'] == _("No")) { show_manage_users(); break; }
+ if ($temp_user->delete()) {
+ show_confirmation(_("User Deleted"), "$temp_user->username has been Deleted","admin/users.php");
+ }
+ else {
+ show_confirmation(_("Delete Error"), _("Unable to delete last Admin User"),"admin/users.php");
+ }
+ break;
+ case 'show_add_user':
+ if (conf('demo_mode')) { break; }
+ show_user_form('','','','','','new_user','');
+ break;
+
+ case 'update':
+ case 'disabled':
+ if (conf('demo_mode')) { break; }
+ $level = scrub_in($_REQUEST['level']);
+ $thisuser = new User($_REQUEST['user']);
+ if ($_SESSION['userdata']['access'] == 'admin') {
+ $thisuser->update_access($level);
+ }
+ show_manage_users();
+ break;
+
+ default:
+ show_manage_users();
+
+}
+
+echo "<br /><br />";
+show_admin_menu('Users');
+show_menu_items('Admin');
+
+?>
+
+</body>
+</html>