" . T_('No Disabled songs found') . "
";
+ }
+ break;
+ case 'show_delete_catalog':
+ /* Stop the demo hippies */
+ if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
+
+ $catalog = Catalog::create_from_id($_REQUEST['catalog_id']);
+ $nexturl = AmpConfig::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($_REQUEST['catalog_id']);
+ show_confirmation(T_('Delete Catalog'), T_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)",$nexturl,1);
+ break;
+ case 'show_customize_catalog':
+ $catalog = Catalog::create_from_id($_REQUEST['catalog_id']);
+ $catalog->format();
+ require_once AmpConfig::get('prefix') . '/templates/show_edit_catalog.inc.php';
+ break;
+ case 'gather_album_art':
+ toggle_visible('ajax-loading');
+ ob_end_flush();
+
+ $catalogs = $_REQUEST['catalogs'] ? $_REQUEST['catalogs'] : Catalog::get_catalogs();
+
+ // Iterate throught the catalogs and gather as needed
+ foreach ($catalogs as $catalog_id) {
+ $catalog = Catalog::create_from_id($catalog_id);
+ require AmpConfig::get('prefix') . '/templates/show_gather_art.inc.php';
+ flush();
+ $catalog->gather_art();
+ }
+ $url = AmpConfig::get('web_path') . '/admin/catalog.php';
+ $title = T_('Album Art Search Finished');
+ $body = '';
+ show_confirmation($title,$body,$url);
+ break;
+ case 'show_catalogs':
+ default:
+ require_once AmpConfig::get('prefix') . '/templates/show_manage_catalogs.inc.php';
+ break;
+} // end switch
+
+/* Show the Footer */
+UI::show_footer();
diff --git a/sources/admin/duplicates.php b/sources/admin/duplicates.php
new file mode 100644
index 0000000..ab03ed6
--- /dev/null
+++ b/sources/admin/duplicates.php
@@ -0,0 +1,45 @@
+set_type('catalog');
+ $browse->set_static_content(true);
+ $browse->save_objects($catalog_ids);
+ $browse->show_objects($catalog_ids);
+ $browse->store();
+ break;
+}
+
+UI::show_footer();
diff --git a/sources/admin/mail.php b/sources/admin/mail.php
new file mode 100644
index 0000000..46df45c
--- /dev/null
+++ b/sources/admin/mail.php
@@ -0,0 +1,75 @@
+subject = $_REQUEST['subject'];
+ $mailer->message = $_REQUEST['message'];
+
+ if ($_REQUEST['from'] == 'system') {
+ $mailer->set_default_sender();
+ } else {
+ $mailer->sender = $GLOBALS['user']->email;
+ $mailer->sender_name = $GLOBALS['user']->fullname;
+ }
+
+ if ($mailer->send_to_group($_REQUEST['to'])) {
+ $title = T_('E-mail Sent');
+ $body = T_('Your E-mail was successfully sent.');
+ } else {
+ $title = T_('E-mail Not Sent');
+ $body = T_('Your E-mail was not sent.');
+ }
+ $url = AmpConfig::get('web_path') . '/admin/mail.php';
+ show_confirmation($title,$body,$url);
+
+ break;
+ default:
+ require_once AmpConfig::get('prefix') . '/templates/show_mail_users.inc.php';
+ break;
+} // end switch
+
+UI::show_footer();
diff --git a/sources/admin/modules.php b/sources/admin/modules.php
new file mode 100644
index 0000000..f5657f8
--- /dev/null
+++ b/sources/admin/modules.php
@@ -0,0 +1,203 @@
+has_access(100)) {
+ UI::access_denied();
+ exit();
+}
+
+
+/* Always show the header */
+UI::show_header();
+
+switch ($_REQUEST['action']) {
+ case 'install_localplay':
+ $localplay = new Localplay($_REQUEST['type']);
+ if (!$localplay->player_loaded()) {
+ Error::add('general', T_('Install Failed, Controller Error'));
+ Error::display('general');
+ break;
+ }
+ // Install it!
+ $localplay->install();
+
+ // Go ahead and enable Localplay (Admin->System) as we assume they want to do that
+ // if they are enabling this
+ Preference::update('allow_localplay_playback','-1','1');
+ Preference::update('localplay_level',$GLOBALS['user']->id,'100');
+ Preference::update('localplay_controller',$GLOBALS['user']->id,$localplay->type);
+
+ header("Location:" . AmpConfig::get('web_path') . '/admin/modules.php?action=show_localplay');
+ break;
+ case 'install_catalog_type':
+ $type = scrub_in($_REQUEST['type']);
+ $catalog = Catalog::create_catalog_type($type);
+ if ($catalog == null) {
+ Error::add('general', T_('Install Failed, Catalog Error'));
+ Error::display('general');
+ break;
+ }
+
+ $catalog->install();
+
+ /* Show Confirmation */
+ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_catalog_types';
+ $title = T_('Plugin Installed');
+ $body = '';
+ show_confirmation($title ,$body, $url);
+ break;
+ case 'confirm_uninstall_localplay':
+ $type = scrub_in($_REQUEST['type']);
+ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_localplay&type=' . $type;
+ $title = T_('Are you sure you want to remove this plugin?');
+ $body = '';
+ show_confirmation($title,$body,$url,1);
+ break;
+ case 'confirm_uninstall_catalog_type':
+ $type = scrub_in($_REQUEST['type']);
+ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_catalog_type&type=' . $type;
+ $title = T_('Are you sure you want to remove this plugin?');
+ $body = '';
+ show_confirmation($title,$body,$url,1);
+ break;
+ case 'uninstall_localplay':
+ $type = scrub_in($_REQUEST['type']);
+
+ $localplay = new Localplay($type);
+ $localplay->uninstall();
+
+ /* Show Confirmation */
+ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_localplay';
+ $title = T_('Plugin Deactivated');
+ $body = '';
+ show_confirmation($title,$body,$url);
+ break;
+ case 'uninstall_catalog_type':
+ $type = scrub_in($_REQUEST['type']);
+
+ $catalog = Catalog::create_catalog_type($type);
+ if ($catalog == null) {
+ Error::add('general', T_('Uninstall Failed, Catalog Error'));
+ Error::display('general');
+ break;
+ }
+ $catalog->uninstall();
+
+ /* Show Confirmation */
+ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_catalog_types';
+ $title = T_('Plugin Deactivated');
+ $body = '';
+ show_confirmation($title, $body, $url);
+ break;
+ case 'install_plugin':
+ /* Verify that this plugin exists */
+ $plugins = Plugin::get_plugins();
+ if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
+ debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
+ break;
+ }
+ $plugin = new Plugin($_REQUEST['plugin']);
+ if (!$plugin->install()) {
+ debug_event('plugins','Error: Plugin Install Failed, ' . $_REQUEST['plugin'],'1');
+ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins';
+ $title = T_('Unable to Install Plugin');
+ $body = '';
+ show_confirmation($title,$body,$url);
+ break;
+ }
+
+ // Don't trust the plugin to this stuff
+ User::rebuild_all_preferences();
+
+ /* Show Confirmation */
+ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins';
+ $title = T_('Plugin Activated');
+ $body = '';
+ show_confirmation($title,$body,$url);
+ break;
+ case 'confirm_uninstall_plugin':
+ $plugin = scrub_in($_REQUEST['plugin']);
+ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_plugin&plugin=' . $plugin;
+ $title = T_('Are you sure you want to remove this plugin?');
+ $body = '';
+ show_confirmation($title,$body,$url,1);
+ break;
+ case 'uninstall_plugin':
+ /* Verify that this plugin exists */
+ $plugins = Plugin::get_plugins();
+ if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
+ debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
+ break;
+ }
+ $plugin = new Plugin($_REQUEST['plugin']);
+ $plugin->uninstall();
+
+ // Don't trust the plugin to do it
+ User::rebuild_all_preferences();
+
+ /* Show Confirmation */
+ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins';
+ $title = T_('Plugin Deactivated');
+ $body = '';
+ show_confirmation($title,$body,$url);
+ break;
+ case 'upgrade_plugin':
+ /* Verify that this plugin exists */
+ $plugins = Plugin::get_plugins();
+ if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
+ debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
+ break;
+ }
+ $plugin = new Plugin($_REQUEST['plugin']);
+ $plugin->upgrade();
+ User::rebuild_all_preferences();
+ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins';
+ $title = T_('Plugin Upgraded');
+ $body = '';
+ show_confirmation($title, $body, $url);
+ break;
+ case 'show_plugins':
+ $plugins = Plugin::get_plugins();
+ UI::show_box_top(T_('Plugins'), 'box box_localplay_plugins');
+ require_once AmpConfig::get('prefix') . '/templates/show_plugins.inc.php';
+ UI::show_box_bottom();
+ break;
+ case 'show_localplay':
+ $controllers = Localplay::get_controllers();
+ UI::show_box_top(T_('Localplay Controllers'), 'box box_localplay_controllers');
+ require_once AmpConfig::get('prefix') . '/templates/show_localplay_controllers.inc.php';
+ UI::show_box_bottom();
+ break;
+ case 'show_catalog_types':
+ $catalogs = Catalog::get_catalog_types();
+ UI::show_box_top(T_('Catalog Types'), 'box box_catalog_types');
+ require_once AmpConfig::get('prefix') . '/templates/show_catalog_types.inc.php';
+ UI::show_box_bottom();
+ break;
+ default:
+ // Rien a faire
+ break;
+} // end switch
+
+UI::show_footer();
diff --git a/sources/admin/shout.php b/sources/admin/shout.php
new file mode 100644
index 0000000..04a1061
--- /dev/null
+++ b/sources/admin/shout.php
@@ -0,0 +1,61 @@
+object_type,$shout->object_id);
+ $object->format();
+ $client = new User($shout->user);
+ $client->format();
+ require_once AmpConfig::get('prefix') . '/templates/show_edit_shout.inc.php';
+ break;
+ case 'delete':
+ Shoutbox::delete($_REQUEST['shout_id']);
+ show_confirmation(T_('Shoutbox Post Deleted'),'',AmpConfig::get('web_path').'/admin/shout.php');
+ break;
+ default:
+ $browse = new Browse();
+ $browse->set_type('shoutbox');
+ $browse->set_simple_browse(true);
+ $shoutbox_ids = $browse->get_objects();
+ $browse->show_objects($shoutbox_ids);
+ $browse->store();
+ break;
+} // end switch on action
+
+UI::show_footer();
diff --git a/sources/admin/system.php b/sources/admin/system.php
new file mode 100644
index 0000000..d55f108
--- /dev/null
+++ b/sources/admin/system.php
@@ -0,0 +1,61 @@
+downloadHeaders('ampache.cfg.php','text/plain',false,filesize(AmpConfig::get('prefix') . '/config/ampache.cfg.php.dist'));
+ echo $final;
+ exit;
+ case 'reset_db_charset':
+ Dba::reset_db_charset();
+ show_confirmation(T_('Database Charset Updated'), T_('Your Database and associated tables have been updated to match your currently configured charset'), AmpConfig::get('web_path').'/admin/system.php?action=show_debug');
+ break;
+ case 'show_debug':
+ $configuration = AmpConfig::get_all();
+ if ($_REQUEST['autoupdate'] == 'force') {
+ $version = AutoUpdate::get_latest_version(true);
+ }
+ require_once AmpConfig::get('prefix') . '/templates/show_debug.inc.php';
+ break;
+ default:
+ // Rien a faire
+ break;
+} // end switch
+
+UI::show_footer();
diff --git a/sources/admin/users.php b/sources/admin/users.php
new file mode 100644
index 0000000..7068d4b
--- /dev/null
+++ b/sources/admin/users.php
@@ -0,0 +1,251 @@
+access) {
+ $client->update_access($access);
+ }
+ if ($email != $client->email) {
+ $client->update_email($email);
+ }
+ if ($website != $client->website) {
+ $client->update_website($website);
+ }
+ if ($username != $client->username) {
+ $client->update_username($username);
+ }
+ if ($fullname != $client->fullname) {
+ $client->update_fullname($fullname);
+ }
+ if ($pass1 == $pass2 && strlen($pass1)) {
+ $client->update_password($pass1);
+ }
+ $client->upload_avatar();
+
+ show_confirmation(T_('User Updated'), $client->fullname . "(" . $client->username . ")" . T_('updated'), AmpConfig::get('web_path'). '/admin/users.php');
+ break;
+ case 'add_user':
+ if (AmpConfig::get('demo_mode')) { break; }
+
+ if (!Core::form_verify('add_user','post')) {
+ UI::access_denied();
+ exit;
+ }
+
+ $username = scrub_in($_POST['username']);
+ $fullname = scrub_in($_POST['fullname']);
+ $email = scrub_in($_POST['email']);
+ $website = scrub_in($_POST['website']);
+ $access = scrub_in($_POST['access']);
+ $pass1 = $_POST['password_1'];
+ $pass2 = $_POST['password_2'];
+
+ if ($pass1 !== $pass2 || !strlen($pass1)) {
+ Error::add('password', T_("Error Passwords don't match"));
+ }
+
+ if (empty($username)) {
+ Error::add('username', T_('Error Username Required'));
+ }
+
+ /* make sure the username doesn't already exist */
+ if (!User::check_username($username)) {
+ Error::add('username', T_('Error Username already exists'));
+ }
+
+ if (!Error::occurred()) {
+ /* Attempt to create the user */
+ $user_id = User::create($username, $fullname, $email, $website, $pass1, $access);
+ if (!$user_id) {
+ Error::add('general', T_("Error: Insert Failed"));
+ }
+
+ $user = new User($user_id);
+ $user->upload_avatar();
+ } // if no errors
+ else {
+ $_REQUEST['action'] = 'show_add_user';
+ break;
+ }
+ if ($access == 5) { $access = T_('Guest');} elseif ($access == 25) { $access = T_('User');} elseif ($access == 100) { $access = T_('Admin');}
+
+ /* HINT: %1 Username, %2 Access num */
+ show_confirmation(T_('New User Added'),sprintf(T_('%1$s has been created with an access level of %2$s'), $username, $access), AmpConfig::get('web_path').'/admin/users.php');
+ break;
+ case 'enable':
+ $client = new User($_REQUEST['user_id']);
+ $client->enable();
+ show_confirmation(T_('User Enabled'),$client->fullname . ' (' . $client->username . ')', AmpConfig::get('web_path'). '/admin/users.php');
+ break;
+ case 'disable':
+ $client = new User($_REQUEST['user_id']);
+ if ($client->disable()) {
+ show_confirmation(T_('User Disabled'),$client->fullname . ' (' . $client->username . ')', AmpConfig::get('web_path'). '/admin/users.php');
+ } else {
+ show_confirmation(T_('Error'), T_('Unable to Disabled last Administrator'), AmpConfig::get('web_path').'/admin/users.php');
+ }
+ break;
+ case 'show_edit':
+ if (AmpConfig::get('demo_mode')) { break; }
+ $client = new User($_REQUEST['user_id']);
+ require_once AmpConfig::get('prefix') . '/templates/show_edit_user.inc.php';
+ break;
+ case 'confirm_delete':
+ if (AmpConfig::get('demo_mode')) { break; }
+ if (!Core::form_verify('delete_user')) {
+ UI::access_denied();
+ exit;
+ }
+ $client = new User($_REQUEST['user_id']);
+ if ($client->delete()) {
+ show_confirmation(T_('User Deleted'), sprintf(T_('%s has been Deleted'), $client->username), AmpConfig::get('web_path'). "/admin/users.php");
+ } else {
+ show_confirmation(T_('Delete Error'), T_("Unable to delete last Admin User"), AmpConfig::get('web_path')."/admin/users.php");
+ }
+ break;
+ case 'delete':
+ if (AmpConfig::get('demo_mode')) { break; }
+ $client = new User($_REQUEST['user_id']);
+ show_confirmation(T_('Deletion Request'),
+ sprintf(T_('Are you sure you want to permanently delete %s?'), $client->fullname),
+ AmpConfig::get('web_path')."/admin/users.php?action=confirm_delete&user_id=" . $_REQUEST['user_id'],1,'delete_user');
+ break;
+ case 'show_delete_avatar':
+ $user_id = $_REQUEST['user_id'];
+
+ $next_url = AmpConfig::get('web_path') . '/admin/users.php?action=delete_avatar&user_id=' . scrub_out($user_id);
+ show_confirmation(T_('User Avatar Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_avatar');
+ break;
+ case 'delete_avatar':
+ if (AmpConfig::get('demo_mode')) { break; }
+
+ if (!Core::form_verify('delete_avatar','post')) {
+ UI::access_denied();
+ exit;
+ }
+
+ $client = new User($_REQUEST['user_id']);
+ $client->delete_avatar();
+
+ $next_url = AmpConfig::get('web_path') . '/admin/users.php';
+ show_confirmation(T_('User Avater Deleted'), T_('User Avatar has been deleted'), $next_url);
+ break;
+ case 'show_generate_apikey':
+ $user_id = $_REQUEST['user_id'];
+
+ $next_url = AmpConfig::get('web_path') . '/admin/users.php?action=generate_apikey&user_id=' . scrub_out($user_id);
+ show_confirmation(T_('Generate new API Key'), T_('Confirm API Key Generation'), $next_url, 1, 'generate_apikey');
+ break;
+ case 'generate_apikey':
+ if (AmpConfig::get('demo_mode')) { break; }
+
+ if (!Core::form_verify('generate_apikey','post')) {
+ UI::access_denied();
+ exit;
+ }
+
+ $client = new User($_REQUEST['user_id']);
+ $client->generate_apikey();
+
+ $next_url = AmpConfig::get('web_path') . '/admin/users.php';
+ show_confirmation(T_('API Key Generated'), T_('New user API Key has been generated.'), $next_url);
+ break;
+ /* Show IP History for the Specified User */
+ case 'show_ip_history':
+ /* get the user and their history */
+ $working_user = new User($_REQUEST['user_id']);
+
+ if (!isset($_REQUEST['all'])) {
+ $history = $working_user->get_ip_history(0,1);
+ } else {
+ $history = $working_user->get_ip_history();
+ }
+ require AmpConfig::get('prefix') . '/templates/show_ip_history.inc.php';
+ break;
+ case 'show_add_user':
+ if (AmpConfig::get('demo_mode')) { break; }
+ require_once AmpConfig::get('prefix') . '/templates/show_add_user.inc.php';
+ break;
+ case 'show_preferences':
+ $client = new User($_REQUEST['user_id']);
+ $preferences = Preference::get_all($client->id);
+ require_once AmpConfig::get('prefix') . '/templates/show_user_preferences.inc.php';
+ break;
+ default:
+ $browse = new Browse();
+ $browse->reset_filters();
+ $browse->set_type('user');
+ $browse->set_simple_browse(1);
+ $browse->set_sort('name','ASC');
+ $user_ids = $browse->get_objects();
+ $browse->show_objects($user_ids);
+ $browse->store();
+ break;
+} // end switch on action
+
+/* Show the footer */
+UI::show_footer();
diff --git a/sources/albums.php b/sources/albums.php
new file mode 100644
index 0000000..6949003
--- /dev/null
+++ b/sources/albums.php
@@ -0,0 +1,239 @@
+has_access('75')) { UI::access_denied(); }
+ $art = new Art($_GET['album_id'],'album');
+ $art->reset();
+ show_confirmation(T_('Album Art Cleared'), T_('Album Art information has been removed from the database'),"/albums.php?action=show&album=" . $art->uid);
+ break;
+ // Upload album art
+ case 'upload_art':
+
+ // we didn't find anything
+ if (empty($_FILES['file']['tmp_name'])) {
+ show_confirmation(T_('Album Art Not Located'), T_('Album Art could not be located at this time. This may be due to write access error, or the file is not received correctly.'),"/albums.php?action=show&album=" . $_REQUEST['album_id']);
+ break;
+ }
+
+ $album = new Album($_REQUEST['album_id']);
+ // Pull the image information
+ $data = array('file'=>$_FILES['file']['tmp_name']);
+ $image_data = Art::get_from_source($data, 'album');
+
+ // If we got something back insert it
+ if ($image_data) {
+ $art = new Art($album->id,'album');
+ $art->insert($image_data,$_FILES['file']['type']);
+ show_confirmation(T_('Album Art Inserted'),'',"/albums.php?action=show&album=" . $album->id);
+ }
+ // Else it failed
+ else {
+ show_confirmation(T_('Album Art Not Located'), T_('Album Art could not be located at this time. This may be due to write access error, or the file is not received correctly.'),"/albums.php?action=show&album=" . $album->id);
+ }
+
+ break;
+ case 'find_art':
+ // If not a user then kick em out
+ if (!Access::check('interface','25')) { UI::access_denied(); exit; }
+
+ // Prevent the script from timing out
+ set_time_limit(0);
+
+ // get the Album information
+ $album = new Album($_GET['album_id']);
+ $album->format();
+ $art = new Art($album->id,'album');
+ $images = array();
+ $cover_url = array();
+
+ // If we've got an upload ignore the rest and just insert it
+ if (!empty($_FILES['file']['tmp_name'])) {
+ $path_info = pathinfo($_FILES['file']['name']);
+ $upload['file'] = $_FILES['file']['tmp_name'];
+ $upload['mime'] = 'image/' . $path_info['extension'];
+ $image_data = Art::get_from_source($upload, 'album');
+
+ if ($image_data) {
+ $art->insert($image_data,$upload['0']['mime']);
+ show_confirmation(T_('Album Art Inserted'),'',"/albums.php?action=show&album=" . $_REQUEST['album_id']);
+ break;
+
+ } // if image data
+
+ } // if it's an upload
+
+ // Build the options for our search
+ if (isset($_REQUEST['artist_name'])) {
+ $artist = scrub_in($_REQUEST['artist_name']);
+ } elseif ($album->artist_count == '1') {
+ $artist = $album->f_artist_name;
+ } else {
+ $artist = "";
+ }
+ if (isset($_REQUEST['album_name'])) {
+ $album_name = scrub_in($_REQUEST['album_name']);
+ } else {
+ $album_name = $album->full_name;
+ }
+
+ $options['artist'] = $artist;
+ $options['album_name'] = $album_name;
+ $options['keyword'] = trim($artist . " " . $album_name);
+
+ // Attempt to find the art.
+ $images = $art->gather($options);
+
+ if (!empty($_REQUEST['cover'])) {
+ $path_info = pathinfo($_REQUEST['cover']);
+ $cover_url[0]['url'] = scrub_in($_REQUEST['cover']);
+ $cover_url[0]['mime'] = 'image/' . $path_info['extension'];
+ }
+ $images = array_merge($cover_url,$images);
+
+ // If we've found anything then go for it!
+ if (count($images)) {
+ // We don't want to store raw's in here so we need to strip them out into a separate array
+ foreach ($images as $index=>$image) {
+ if ($image['raw']) {
+ unset($images[$index]['raw']);
+ }
+ } // end foreach
+ // Store the results for further use
+ $_SESSION['form']['images'] = $images;
+ require_once AmpConfig::get('prefix') . '/templates/show_album_art.inc.php';
+ }
+ // Else nothing
+ else {
+ show_confirmation(T_('Album Art Not Located'), T_('Album Art could not be located at this time. This may be due to write access error, or the file is not received correctly.'),"/albums.php?action=show&album=" . $album->id);
+ }
+
+ $albumname = $album->name;
+ $artistname = $artist;
+
+ // Remember the last typed entry, if there was one
+ if (!empty($_REQUEST['album_name'])) { $albumname = scrub_in($_REQUEST['album_name']); }
+ if (!empty($_REQUEST['artist_name'])) { $artistname = scrub_in($_REQUEST['artist_name']); }
+
+ require_once AmpConfig::get('prefix') . '/templates/show_get_albumart.inc.php';
+
+ break;
+ case 'select_art':
+
+ /* Check to see if we have the image url still */
+ $image_id = $_REQUEST['image'];
+ $album_id = $_REQUEST['album_id'];
+
+ // Prevent the script from timing out
+ set_time_limit(0);
+
+ $album = new Album($album_id);
+ $album_groups = $album->get_group_disks_ids();
+
+ $image = Art::get_from_source($_SESSION['form']['images'][$image_id], 'album');
+ $mime = $_SESSION['form']['images'][$image_id]['mime'];
+
+ foreach ($album_groups as $a_id) {
+ $art = new Art($a_id, 'album');
+ $art->insert($image, $mime);
+ }
+
+ header("Location:" . AmpConfig::get('web_path') . "/albums.php?action=show&album=" . $album_id);
+ break;
+ case 'update_from_tags':
+ // Make sure they are a 'power' user at least
+ if (!Access::check('interface','75')) {
+ UI::access_denied();
+ exit;
+ }
+
+ $type = 'album';
+ $object_id = intval($_REQUEST['album_id']);
+ $target_url = AmpConfig::get('web_path') . '/albums.php?action=show&album=' . $object_id;
+ require_once AmpConfig::get('prefix') . '/templates/show_update_items.inc.php';
+ break;
+ case 'set_track_numbers':
+ debug_event('albums', 'Set track numbers called.', '5');
+
+ if (!Access::check('interface','75')) {
+ UI::access_denied();
+ exit;
+ }
+
+ // Retrieving final song order from url
+ foreach ($_GET as $key => $data) {
+ $_GET[$key] = unhtmlentities(scrub_in($data));
+ debug_event('albums', $key.'='.$_GET[$key], '5');
+ }
+
+ if (isset($_GET['order'])) {
+ $songs = explode(";", $_GET['order']);
+ $track = 1;
+ foreach ($songs as $song_id) {
+ if ($song_id != '') {
+ Song::update_track($track, $song_id);
+ ++$track;
+ }
+ }
+ }
+ break;
+ case 'show_missing':
+ set_time_limit(600);
+ $mbid = $_REQUEST['mbid'];
+ $walbum = new Wanted(Wanted::get_wanted($mbid));
+
+ if (!$walbum->id) {
+ $walbum->mbid = $mbid;
+ if (isset($_REQUEST['artist'])) {
+ $artist = new Artist($_REQUEST['artist']);
+ $walbum->artist = $artist->id;
+ $walbum->artist_mbid = $artist->mbid;
+ } elseif (isset($_REQUEST['artist_mbid'])) {
+ $walbum->artist_mbid = $_REQUEST['artist_mbid'];
+ }
+ }
+ $walbum->load_all();
+ $walbum->format();
+ require AmpConfig::get('prefix') . '/templates/show_missing_album.inc.php';
+ break;
+ // Browse by Album
+ case 'show':
+ default:
+ $album = new Album($_REQUEST['album']);
+ $album->format();
+
+ if (!count($album->album_suite)) {
+ require AmpConfig::get('prefix') . '/templates/show_album.inc.php';
+ } else {
+ require AmpConfig::get('prefix') . '/templates/show_album_group_disks.inc.php';
+ }
+
+ break;
+} // switch on view
+
+UI::show_footer();
diff --git a/sources/artists.php b/sources/artists.php
new file mode 100644
index 0000000..c6d86c8
--- /dev/null
+++ b/sources/artists.php
@@ -0,0 +1,83 @@
+format();
+ $object_ids = $artist->get_albums($_REQUEST['catalog']);
+ $object_type = 'album';
+ require_once AmpConfig::get('prefix') . '/templates/show_artist.inc.php';
+ break;
+ case 'show_all_songs':
+ $artist = new Artist($_REQUEST['artist']);
+ $artist->format();
+ $object_type = 'song';
+ $object_ids = $artist->get_songs();
+ require_once AmpConfig::get('prefix') . '/templates/show_artist.inc.php';
+ break;
+ case 'update_from_tags':
+ $type = 'artist';
+ $object_id = intval($_REQUEST['artist']);
+ $target_url = AmpConfig::get('web_path') . "/artists.php?action=show&artist=" . $object_id;
+ require_once AmpConfig::get('prefix') . '/templates/show_update_items.inc.php';
+ break;
+ case 'match':
+ case 'Match':
+ $match = scrub_in($_REQUEST['match']);
+ if ($match == "Browse" || $match == "Show_all") { $chr = ""; } else { $chr = $match; }
+ /* Enclose this in the purty box! */
+ require AmpConfig::get('prefix') . '/templates/show_box_top.inc.php';
+ show_alphabet_list('artists','artists.php',$match);
+ show_alphabet_form($chr, T_('Show Artists starting with'),"artists.php?action=match");
+ require AmpConfig::get('prefix') . '/templates/show_box_bottom.inc.php';
+
+ if ($match === "Browse") {
+ show_artists();
+ } elseif ($match === "Show_all") {
+ $offset_limit = 999999;
+ show_artists();
+ } else {
+ if ($chr == '') {
+ show_artists('A');
+ } else {
+ show_artists($chr);
+ }
+ }
+ break;
+ case 'show_missing':
+ set_time_limit(600);
+ $mbid = $_REQUEST['mbid'];
+ $wartist = Wanted::get_missing_artist($mbid);
+
+ require AmpConfig::get('prefix') . '/templates/show_missing_artist.inc.php';
+ break;
+} // end switch
+
+UI::show_footer();
diff --git a/sources/batch.php b/sources/batch.php
new file mode 100644
index 0000000..d4a9d95
--- /dev/null
+++ b/sources/batch.php
@@ -0,0 +1,108 @@
+playlist->get_items();
+ $name = $GLOBALS['user']->username . ' - Playlist';
+ break;
+ case 'playlist':
+ $playlist = new Playlist($_REQUEST['id']);
+ $media_ids = $playlist->get_songs();
+ $name = $playlist->name;
+ break;
+ case 'smartplaylist':
+ $search = new Search('song', $_REQUEST['id']);
+ $sql = $search->to_sql();
+ $sql = $sql['base'] . ' ' . $sql['table_sql'] . ' WHERE ' .
+ $sql['where_sql'];
+ $db_results = Dba::read($sql);
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $media_ids[] = $row['id'];
+ }
+ $name = $search->name;
+ break;
+ case 'album':
+ foreach ($_REQUEST['id'] as $a) {
+ $album = new Album($a);
+ if (empty($name)) {
+ $name = $album->name;
+ }
+ $asongs = $album->get_songs();
+ foreach ($asongs as $song_id) {
+ $media_ids[] = $song_id;
+ }
+ }
+ break;
+ case 'artist':
+ $artist = new Artist($_REQUEST['id']);
+ $media_ids = $artist->get_songs();
+ $name = $artist->name;
+ break;
+ case 'browse':
+ $id = scrub_in($_REQUEST['browse_id']);
+ $browse = new Browse($id);
+ $browse_media_ids = $browse->get_saved();
+ foreach ($browse_media_ids as $media_id) {
+ switch ($_REQUEST['type']) {
+ case 'album':
+ $album = new Album($media_id);
+ $media_ids = array_merge($media_ids, $album->get_songs());
+ break;
+ case 'song':
+ $media_ids[] = $media_id;
+ break;
+ case 'video':
+ $media_ids[] = array('Video', $media_id);
+ break;
+ } // switch on type
+ } // foreach media_id
+ $name = 'Batch-' . date("dmY",time());
+ default:
+ // Rien a faire
+ break;
+} // action switch
+
+// Take whatever we've got and send the zip
+$song_files = get_song_files($media_ids);
+if (is_array($song_files['0'])) {
+ set_memory_limit($song_files['1']+32);
+ send_zip($name,$song_files['0']);
+}
+exit;
diff --git a/sources/bin/.htaccess b/sources/bin/.htaccess
new file mode 100644
index 0000000..896fbc5
--- /dev/null
+++ b/sources/bin/.htaccess
@@ -0,0 +1,2 @@
+Order deny,allow
+Deny from all
\ No newline at end of file
diff --git a/sources/bin/catalog_update.inc b/sources/bin/catalog_update.inc
new file mode 100644
index 0000000..5807f3f
--- /dev/null
+++ b/sources/bin/catalog_update.inc
@@ -0,0 +1,177 @@
+ 1) {
+ for ($x = 1; $x < count($_SERVER['argv']); $x++) {
+
+ if ($_SERVER['argv'][$x] == "-c") {
+ $operations_string .= "\n\t" . T_('- Catalog Clean');
+ $catclean = 1;
+ }
+ elseif ($_SERVER['argv'][$x] == "-v") {
+ $operations_string .= "\n\t" . T_('- Catalog Verify');
+ $catverify = 1;
+ }
+ elseif ($_SERVER['argv'][$x] == "-a") {
+ $operations_string .= "\n\t" . T_('- Catalog Add');
+ $catadd = 1;
+ }
+ elseif ($_SERVER['argv'][$x] == "-g") {
+ $operations_string .= "\n\t" . T_('- Catalog Art Gather');
+ $artadd = 1;
+ }
+ elseif ($_SERVER['argv'][$x] == "-i") {
+ $operations_string .= "\n\t" . T_('- Playlist Import');
+ $plimp = 1;
+ }
+ else {
+ if ($where) $where .= " OR ";
+ $where .= "name LIKE '%" . Dba::escape(preg_replace("/[^a-z0-9\. -]/i", "", $_SERVER['argv'][$x])) . "%'";
+ }
+ }
+}
+
+if (count($_SERVER['argv']) != 1 AND $artadd != 1 && $catclean != 1 && $catverify != 1 && $catadd != 1) {
+ usage();
+ exit;
+}
+
+if ($artadd == 0 && $catclean == 0 && $catverify == 0 && $catadd == 0) { //didn't pass any clean/verify/add arguments
+ $catclean = 1; //set them all to on
+ $catverify = 1;
+ $catadd = 1;
+ $artadd = 1;
+}
+
+echo T_("Starting Catalog Operations...") . $operations_string . "\n";
+
+if ($where) $where = "($where) AND catalog_type='local'";
+else $where = "catalog_type='local'";
+$sql = "SELECT id FROM catalog";
+if ($where) $sql .= " WHERE $where";
+$db_results = Dba::read($sql);
+
+ob_start("ob_html_strip",'1024',true);
+
+while ($row = Dba::fetch_row($db_results)) {
+
+ $catalog = Catalog::create_from_id($row['0']);
+ printf(T_('Reading: %s'), $catalog->name);
+ ob_flush();
+ echo "\n";
+ if ($catclean == 1) {
+ // Clean out dead files
+ echo T_("- Starting Clean - ");
+ echo "\n";
+ $catalog->clean_catalog();
+ echo "------------------\n\n";
+ }
+
+ if ($catverify == 1) {
+ // Verify Existing
+ echo T_("- Starting Verify - ");
+ echo "\n";
+ $catalog->verify_catalog($row['0']);
+ echo "-------------------\n\n";
+ }
+
+ if ($catadd == 1) {
+ // Look for new files
+ echo T_("- Starting Add - ");
+ echo "\n";
+ $options = array();
+ if ($artadd == 1) {
+ $options['gather_art'] = true;
+ }
+ if ($plimp == 1) {
+ $options['parse_playlist'] = true;
+ }
+ $catalog->add_to_catalog($options);
+ echo "----------------\n\n";
+ } elseif ($artadd == 1) {
+ // Look for album art
+ echo T_('Starting Album Art Search');
+ echo "\n";
+ $catalog->gather_art();
+ echo "----------------\n\n";
+ }
+}
+
+Dba::optimize_tables();
+
+ob_end_flush();
+echo "\n";
+
+function ob_html_strip($string) {
+
+ //$string = preg_replace("/update_txt\('.+'\);update_txt\('(.+)','.+'\);/","$1",$string);
+ //$string = preg_replace("/update_.+/","",$string);
+ $string = str_replace('" . "\n";
+
+ // Content
+ $xsl .= "
" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "

" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "" . "\n";
+ $xsl .= "Stream Title: | " . "\n";
+ $xsl .= "" . $channel->name . " | " . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "" . "\n";
+ $xsl .= "Stream Description: | " . "\n";
+ $xsl .= "" . $channel->description . " | " . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "" . "\n";
+ $xsl .= "Content Type: | " . "\n";
+ $xsl .= "" . Song::type_to_mime($channel->stream_type) . " | " . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "" . "\n";
+ $xsl .= "Mount Start: | " . "\n";
+ $xsl .= "" . date("c", $channel->start_date) . " | " . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "" . "\n";
+ $xsl .= "Bitrate: | " . "\n";
+ $xsl .= "" . $channel->bitrate . " | " . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "" . "\n";
+ $xsl .= "Current Listeners: | " . "\n";
+ $xsl .= "" . $channel->listeners . " | " . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "" . "\n";
+ $xsl .= "Peak Listeners: | " . "\n";
+ $xsl .= "" . $channel->peak_listeners . " | " . "\n";
+ $xsl .= "
" . "\n";
+ $genre = $channel->get_genre();
+ $xsl .= "" . "\n";
+ $xsl .= "Stream Genre: | " . "\n";
+ $xsl .= "" . $genre . " | " . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "" . "\n";
+ $xsl .= "Stream URL: | " . "\n";
+ $xsl .= "url . "\" target=\"_blank\">" . $channel->url . " | " . "\n";
+ $xsl .= "
" . "\n";
+ $currentsong = "";
+ if ($channel->media) {
+ $currentsong = $channel->media->f_artist . " - " . $channel->media->f_title;
+ }
+ $xsl .= "" . "\n";
+ $xsl .= "Current Song: | " . "\n";
+ $xsl .= "" . $currentsong . " | " . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "

" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "
" . "\n";
+
+ // Footer
+ $xsl .= "
" . "\n";
+ $xsl .= "Support Icecast development at
www.icecast.org" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "
" . "\n";
+ $xsl .= "" . "\n";
+ $xsl .= "" . "\n";
+
+ fwrite($sock, $xsl);
+
+ fclose($sock);
+ unset($client_socks[array_search($sock, $client_socks)]);
+ break;
+
+ case '/style.css':
+ case '/favicon.ico':
+ case '/images/corner_bottomleft.jpg':
+ case '/images/corner_bottomright.jpg':
+ case '/images/corner_topleft.jpg':
+ case '/images/corner_topright.jpg':
+ case '/images/icecast.png':
+ case '/images/key.png':
+ case '/images/tunein.png':
+ // Get read file data
+ $fpath = AmpConfig::get('prefix') . '/channel' . $cmd['1'];
+ $pinfo = pathinfo($fpath);
+
+ $content_type = 'text/html';
+ switch ($pinfo['extension']) {
+ case 'css':
+ $content_type = "text/css";
+ break;
+ case 'jpg':
+ $content_type = "image/jpeg";
+ break;
+ case 'png':
+ $content_type = "image/png";
+ break;
+ case 'ico':
+ $content_type = "image/vnd.microsoft.icon";
+ break;
+ }
+ fwrite($sock, "HTTP/1.0 200 OK\r\n");
+ fwrite($sock, "Content-Type: " . $content_type . "\r\n");
+ $fdata = file_get_contents($fpath);
+ fwrite($sock, "Content-Length: " . strlen($fdata) . "\r\n");
+ fwrite($sock, "\r\n");
+ fwrite($sock, $fdata);
+ fclose($sock);
+ unset($client_socks[array_search($sock, $client_socks)]);
+ break;
+ case '/stream.' . $channel->stream_type . '.m3u':
+ fwrite($sock, "HTTP/1.0 200 OK\r\n");
+ fwrite($sock, "Cache-control: public\r\n");
+ fwrite($sock, "Content-Disposition: filename=stream." . $channel->stream_type . ".m3u\r\n");
+ fwrite($sock, "Content-Type: audio/x-mpegurl\r\n");
+ fwrite($sock, "\r\n");
+
+ fwrite($sock, $channel->get_stream_url() . "\n");
+
+ fclose($sock);
+ unset($client_socks[array_search($sock, $client_socks)]);
+ break;
+ default:
+ debug_event('channel', 'Unknown request. Closing connection.', '3');
+ fclose($sock);
+ unset($client_socks[array_search($sock, $client_socks)]);
+ break;
+ }
+ }
+ }
+ // Handle data parse
+ }
+ }
+
+ if ($channel->bitrate) {
+ $time_offset = microtime(true) - $last_stream;
+ //$mtime = ($last_stream > 0 && $time_offset < 1000000) ? $time_offset : 1;
+ $mtime = 1;
+ if ($last_stream > 0 && $time_offset < 1) {
+ usleep(1000000 - ($time_offset * 1000000));
+ } elseif ($last_stream > 0) {
+ //$mtime = $time_offset;
+ }
+ $nb_chunks = ceil(($mtime * $channel->bitrate * 1000) / 4096);
+ } else {
+ $nb_chunks = 1;
+ }
+
+ // Get multiple chunks according to bitrate to return enough data per second (because sleep with socket select)
+ for ($c = 0; $c < $nb_chunks; $c++) {
+ $chunk = $channel->get_chunk();
+ $chunklen = strlen($chunk);
+ if ($chunklen > 0) {
+ foreach($stream_clients as $key => $client)
+ {
+ $sock = $client['socket'];
+ if(!is_resource($sock)) {
+ client_disconnect($channel, $client_socks, $stream_clients, $sock);
+ continue;
+ }
+
+ $clchunk = $chunk;
+ // Check if we need to insert metadata information
+ if ($client['metadata']) {
+ $chkmdlen = ($client['length'] + $chunklen) - $client['metadata_lastsent'];
+ if ($chkmdlen >= $metadata_interval) {
+ $subpos = ($client['metadata_lastsent'] + $metadata_interval) - $client['length'];
+ fwrite($sock, substr($clchunk, 0, $subpos));
+ $client['length'] += $subpos;
+ if ($channel->media->id != $client['metadata_lastsong']) {
+ $metadata = "StreamTitle='" . str_replace('-', ' ', $channel->media->f_artist) . "-" . $channel->media->f_title . "';";
+ $metadata .= chr(0x00);
+ $metadatalen = ceil(strlen($metadata) / 16);
+ $metadata = str_pad($metadata, $metadatalen * 16, chr(0x00), STR_PAD_RIGHT);
+ //debug_event('channel', 'Sending metadata to client...', '5');
+ fwrite($sock, chr($metadatalen) . $metadata);
+ $client['metadata_lastsong'] = $channel->media->id;
+ } else {
+ fwrite($sock, chr(0x00));
+ }
+ $client['metadata_lastsent'] = $client['length'];
+ $clchunk = substr($chunk, $subpos);
+ }
+ }
+ if (strlen($clchunk) > 0) {
+ fwrite($sock, $clchunk);
+ $client['length'] += strlen($clchunk);
+ }
+
+ $stream_clients[$key] = $client;
+ //debug_event('channel', 'Client stream current length: ' . $client['length'], '5');
+ }
+ } else {
+ $channel->update_listeners(0);
+ die('No more data, stream ended.');
+ }
+
+ $last_stream = microtime(true);
+ }
+}
+
+ob_end_flush();
+echo "\n";
+
+function client_disconnect($channel, &$client_socks, &$stream_clients, $sock)
+{
+ $key = array_search($sock, $client_socks);
+ unset($client_socks[$key]);
+ unset($stream_clients[$key]);
+ @fclose($sock);
+ $channel->update_listeners(count($client_socks));
+ debug_event('channel', 'A client disconnected. Now there are total '. count($client_socks) . ' clients.', '5');
+ echo "Client disconnected.\n";
+ ob_flush();
+}
+
+function usage()
+{
+ echo T_("- Channel Listening -");
+ echo "\n";
+ echo T_("Usage: channel_run.inc [-c {CHANNEL ID}|-p {PORT}|-v]");
+ echo "\n\t";
+ echo "\n-c {CHANNEL ID}\t";
+ echo T_('Channel id to start');
+ echo "\n-p {PORT}\t";
+ echo T_('Listening port, default get an available port automatically');
+ echo "\n-v\t";
+ echo T_('Verbose');
+ echo "\n";
+ echo "----------------------------------------------------------";
+ echo "\n";
+}
+
+?>
diff --git a/sources/bin/delete_disabled.inc b/sources/bin/delete_disabled.inc
new file mode 100644
index 0000000..38601c2
--- /dev/null
+++ b/sources/bin/delete_disabled.inc
@@ -0,0 +1,56 @@
+
diff --git a/sources/bin/dump_album_art.inc b/sources/bin/dump_album_art.inc
new file mode 100644
index 0000000..8238975
--- /dev/null
+++ b/sources/bin/dump_album_art.inc
@@ -0,0 +1,46 @@
+ 1) {
+ $meta = ($_SERVER['argv']['1'] == 'windows') ? 'windows' : 'linux';
+}
+
+$catalogs = Catalog::get_catalogs();
+
+foreach ($catalogs as $catalog_id) {
+ $catalog = Catalog::create_from_id($catalog_id);
+ $catalog->dump_album_art(array('metadata' => $meta));
+}
+
+
+?>
diff --git a/sources/bin/fix_filenames.inc b/sources/bin/fix_filenames.inc
new file mode 100644
index 0000000..5aef3b3
--- /dev/null
+++ b/sources/bin/fix_filenames.inc
@@ -0,0 +1,239 @@
+ 0) { $source_encoding = trim($input); }
+printf (T_('Using %s as source character set'), $source_encoding);
+echo "\n";
+
+$sql = "SELECT id FROM `catalog` WHERE `catalog_type`='local'";
+$db_results = Dba::read($sql);
+
+while ($row = Dba::fetch_assoc($db_results)) {
+
+ $catalog = Catalog::create_from_id($row['0']);
+ printf(T_('Checking %s (%s)'), $catalog->name, $catalog->path);
+ echo "\n";
+ charset_directory_correct($catalog->path);
+
+} // end of the catalogs
+
+echo T_('Finished checking filenames for valid chacters');
+echo "\n";
+
+/**************************************************
+ ****************** FUNCTIONS *********************
+ **************************************************/
+/**
+ * charset_directory_correct
+ * This function calls its self recursivly
+ * and corrects all of the non-matching filenames
+ * it looks at the i_am_crazy var and if not set prompts for change
+ */
+function charset_directory_correct($path) {
+
+ // Correctly detect the slash we need to use here
+ if (strstr($path,"/")) {
+ $slash_type = '/';
+ }
+ else {
+ $slash_type = '\\';
+ }
+
+ /* Open up the directory */
+ $handle = opendir($path);
+
+ if (!is_resource($handle)) {
+ printf (T_('ERROR: Unable to open %s'), $path);
+ echo "\n";
+ return false;
+ }
+
+ if (!chdir($path)) {
+ printf (T_('ERROR: Unable to chdir to %s'), $path);
+ echo "\n";
+ return false;
+ }
+
+ while ( false !== ($file = readdir($handle) ) ) {
+
+ if ($file == '.' || $file == '..') { continue; }
+
+ $full_file = $path.$slash_type.$file;
+
+ if (is_dir($full_file)) {
+ charset_directory_correct($full_file);
+ continue;
+ }
+
+ $verify_filename = iconv(AmpConfig::get('site_charset'),AmpConfig::get('site_charset') . '//IGNORE',$full_file);
+
+ if (strcmp($full_file,$verify_filename) != '0') {
+ $translated_filename = iconv($source_encoding,AmpConfig::get('site_charset') . '//TRANSLIT',$full_file);
+
+ // Make sure the extension stayed the same
+ if (substr($translated_filename,strlen($translated_filename)-3,3) != substr($full_file,strlen($full_file)-3,3)) {
+ echo T_("Translation failure, stripping non-valid characters");
+ echo "\n";
+ $translated_filename = iconv($source_encoding,AmpConfig::get('site_charset') . '//IGNORE',$full_file);
+ }
+
+ printf (T_('Attempting to Transcode to %s'), AmpConfig::get('site_charset'));
+ echo "\n";
+ echo "--------------------------------------------------------------------------------------------\n";
+ printf (T_('OLD: %s has invalid chars'), $full_file);
+ echo "\n";
+ printf (T_('NEW: %s'), $translated_filename);
+ echo "\n";
+ echo "--------------------------------------------------------------------------------------------\n";
+ if (!$GLOBALS['i_am_crazy']) {
+ echo T_("Rename File (Y/N):");
+ $input = trim(fgets(STDIN));
+ if (strcasecmp($input,'Y') == 0) { charset_rename_file($full_file,$translated_filename); }
+ else { echo "\n\t"; echo T_('Not Renaming...'); echo "\n\n"; }
+ }
+ else {
+ charset_rename_file($full_file,$translated_filename);
+ }
+ }
+
+ } // while reading file
+
+} // charset_directory_correct
+
+/**
+ * charset_rename_file
+ * This just takes a source / dest and does the renaming
+ */
+function charset_rename_file($full_file,$translated_filename) {
+
+ // First break out the base directory name and make sure it exists
+ // in case our crap char is in the directory
+ $directory = dirname($translated_filename);
+ $data = preg_split("/[\/\\\]/",$directory);
+ $path = '';
+
+ foreach ($data as $dir) {
+
+ $dir = charset_clean_name($dir);
+ $path .= "/" . $dir;
+
+ if (!is_dir($path)) {
+ echo "\tMaking $path directory\n";
+ $results = mkdir($path);
+ if (!$results) {
+ printf (T_('Error: Unable to create %s move failed, stopping'), $path);
+ echo "\n";
+ return false;
+ }
+ } // if the dir doesn't exist
+
+ } // end foreach
+
+ // Now to copy the file
+ $results = copy($full_file,$translated_filename);
+
+ if (!$results) {
+ echo T_('Error: Copy Failed, not deleteing old file');
+ echo "\n";
+ return false;
+ }
+
+ $old_sum = filesize($full_file);
+ $new_sum = filesize($translated_filename);
+
+ if ($old_sum != $new_sum OR !$new_sum) {
+ printf (T_('Error: Size Inconsistency, not deleting %s'), $full_file);
+ echo "\n";
+ return false;
+ }
+
+ $results = unlink($full_file);
+
+ if (!$results) { printf (T_('Error: Unable to delete %s'), $full_file); echo "\n"; return false; }
+
+ echo T_("File Moved...");
+ echo "\n\n";
+
+ return true;
+
+} // charset_rename_file
+
+/**
+ * charset_clean_name
+ * We have to have some special rules here
+ * This is run on every individual element of the search
+ * Before it is put togeather, this removes / and \ and also
+ * once I figure it out, it'll clean other stuff
+ */
+function charset_clean_name($string) {
+
+ /* First remove any / or \ chars */
+ $string = preg_replace('/[\/\\\]/','-',$string);
+
+ $string = str_replace(':',' ',$string);
+
+ $string = preg_replace('/[\!\:\*]/','_',$string);
+
+ return $string;
+
+} // charset_clean_name
+
+?>
diff --git a/sources/bin/install/.htaccess b/sources/bin/install/.htaccess
new file mode 100644
index 0000000..3a42882
--- /dev/null
+++ b/sources/bin/install/.htaccess
@@ -0,0 +1 @@
+Deny from all
diff --git a/sources/bin/install/add_user.inc b/sources/bin/install/add_user.inc
new file mode 100644
index 0000000..570afe3
--- /dev/null
+++ b/sources/bin/install/add_user.inc
@@ -0,0 +1,60 @@
+ [ -l