diff options
-rw-r--r-- | admin/flag.php | 17 | ||||
-rw-r--r-- | admin/mail.php | 136 | ||||
-rw-r--r-- | bin/quarantine_migration.php.inc | 74 | ||||
-rw-r--r-- | bin/sort_files.php.inc | 11 | ||||
-rw-r--r-- | lib/class/flag.class.php | 52 | ||||
-rw-r--r-- | lib/upload.php | 21 | ||||
-rw-r--r-- | templates/show_admin_info.inc.php | 19 | ||||
-rw-r--r-- | templates/show_confirmation.inc.php | 8 | ||||
-rw-r--r-- | templates/show_flagged.inc.php | 4 | ||||
-rw-r--r-- | templates/show_mail_users.inc.php | 59 | ||||
-rw-r--r-- | templates/show_uploads.inc | 11 |
11 files changed, 273 insertions, 139 deletions
diff --git a/admin/flag.php b/admin/flag.php index df7893c2..2c8e4c16 100644 --- a/admin/flag.php +++ b/admin/flag.php @@ -71,6 +71,15 @@ switch ($action) { } 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(); + $url = return_referer(); + $title = _('Flag Removed'); + $body = _('Flag Removed from') . " " . $flag->print_name(); + show_confirmation($title,$body,$url); + break; case 'show_edit_song': $_SESSION['source'] = return_referer(); $song = new Song($_REQUEST['song']); @@ -88,7 +97,7 @@ switch ($action) { } // end else show_confirmation(_('Songs Disabled'),_('The requested song(s) have been disabled'),return_referer()); break; - case "enabled": + 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']); } @@ -99,6 +108,12 @@ switch ($action) { } // 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 diff --git a/admin/mail.php b/admin/mail.php index a69b0ead..df717780 100644 --- a/admin/mail.php +++ b/admin/mail.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -20,16 +20,11 @@ */ -/*! - @header Mail Admin Page - Means to mail your users or give updates about the server - -*/ - require('../modules/init.php'); -if (!$user->has_access(100)) { +if (!$GLOBALS['user']->has_access(100)) { access_denied(); + exit(); } @@ -38,92 +33,61 @@ $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 = $GLOBALS['user']; - // 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' OR access='25' AND email IS NOT NULL"; - } - elseif ( $to == 'admins' ) { - $sql = "SELECT * FROM user WHERE access='admin' OR access='100' AND email IS NOT NULL"; - } +/* Always show the header */ +show_template('header'); + +switch ($action) { + case 'send_mail': + if (conf('demo_mode')) { break; } + + // 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' OR access='25' AND email IS NOT NULL"; + } + elseif ( $to == 'admins' ) { + $sql = "SELECT * FROM user WHERE access='admin' OR access='100' AND email IS NOT NULL"; + } - $db_result = mysql_query($sql, dbh()); + $db_result = mysql_query($sql, dbh()); - $recipient = ''; + $recipient = ''; - while ( $u = mysql_fetch_object($db_result) ) { - $recipient .= "$u->fullname <$u->email>, "; - } + while ( $u = mysql_fetch_object($db_result) ) { + $recipient .= "$u->fullname <$u->email>, "; + } - // Remove the last , from the recipient - $recipient = rtrim($recipient,","); + // Remove the last , from the recipient + $recipient = rtrim($recipient,","); - $from = $user->fullname."<".$user->email.">"; + $from = $user->fullname."<".$user->email.">"; - // woohoo!! - mail ($from, $subject, $message, - "From: $from\r\n". - "Bcc: $recipient\r\n"); + // 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."; -} + /* Confirmation Send */ + $url = conf('web_path') . '/admin/mail.php'; + $title = _('E-mail Sent'); + $body = _('Your E-mail was successfully sent.'); + show_confirmation($title,$body,$url); + break; + default: + if ( empty($to) ) { + $to = 'all'; + } -if ( empty($to) ) { - $to = 'all'; -} + if ( empty($subject) ) { + $subject = "[" . conf('site_title') . "] "; + } + require (conf('prefix') . '/templates/show_mail_users.inc.php'); + break; +} // end switch -if ( empty($subject) ) { - $site_title = conf('site_title'); - $subject = "[$site_title] "; -} +show_footer(); -show_template('header'); -?> -<form name="mail" method="post" action="<?php echo conf('web_path'); ?>/admin/mail.php" enctype="multipart/form-data"> - -<p><font color="<?php echo conf('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=\"selected\""; } ?>>All</option> - <option value="users" <?php if ($to == 'user') { echo "selected=\"selected\""; } ?>>Users</option> - <option value="admins" <?php if ($to == 'admin') { echo "selected=\"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> </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_footer(); ?> +?> diff --git a/bin/quarantine_migration.php.inc b/bin/quarantine_migration.php.inc index e23dddab..803317ef 100644 --- a/bin/quarantine_migration.php.inc +++ b/bin/quarantine_migration.php.inc @@ -1,6 +1,9 @@ <?php /* + Copyright 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 @@ -15,10 +18,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - created by RosenSama 2005 - - call: php quarantine_migration.php + created by RosenSama 2005 + call: php quarantine_migration.php */ $no_session='1'; @@ -46,7 +48,7 @@ while ($results = mysql_fetch_assoc($db_results)) { $upload_dir = conf('upload_dir'); if (!@is_writeable($upload_dir)) { - cli_out("\n" . _("Error: Unable to write to") . $upload_dir); + echo "\n" . _('Error: Unable to write to') . " $upload_dir ". "\n"; exit; } @@ -60,48 +62,57 @@ if (!$catalog_id) { $catalog = new Catalog($catalog_id); /* Itterate through the files we need to move */ -$adds = &$files['add']; -foreach ($adds as $data) { +foreach ($files['add'] as $data) { /* Make sure that the target filename doesn't exist */ + $target_file = $upload_dir . "/" . basename($data['file']); + + if (file_exists($target_file)) { + echo 'Error: File Exists'; + debug_event('file_exists','Error: $target_file already exist','1'); + continue; + } + + $results = copy($data['file'],$target_file); + if (!$results) { echo "Error: Unable to copy " . $data['file'] . " skipping...\n"; continue; } - $command = "mv " . $data['file'] . " " . $upload_dir; - $command = escapeshellcmd($command); - - exec($command,$return,$error); + /* Check the filesize to make sure it copied */ + $new_sum = filesize($target_file); + $old_sum = filesize($data['file']); + + if ($new_sum != $old_sum || !$new_sum) { + echo "Error: Size Inconsistency, not deleting " . $data['file'] . "\n"; + continue; + } + + $results = unlink($data['file']); + if (!$results) { echo "Error: Unable to delete " . $data['file'] . "\n";} - if (!$error) { - cli_out("\n" . _("Moved") . " " . $data['file']); + else { + echo _('Adding') . " " . $target_file . " " . _('to database') . "\n"; - $new_filename = $upload_dir . "/" . basename($data['file']); - - cli_out(_("Adding") . " " . $new_filename . " " . _("to database")); + $catalog->add_file($target_file); - $catalog->add_file($new_filename); - + /* Remove it from the catalog */ $sql = "DELETE FROM upload WHERE id='" . $data['id'] . "'"; $db_results = mysql_query($sql, dbh()); } - else { - cli_out(_("Move Failed") . " " . $data['file']); - } - - + } // end foreach /* Itterate through the files we need to delete */ -$deletes = &$files['delete']; -foreach ($deletes as $data) { - - unlink($data['file']); - cli_out(_("Deleted") . " " . $data['file']); +foreach ($files['delete'] as $data) { - $sql = "DELETE FROM upload WHERE id='" . $data['id'] . "'"; - $db_results = mysql_query($sql, dbh()); + $results = unlink($data['file']); + if (!$results) { echo "Error: Unable to Delete File\n"; } + else { + echo _('Deleted') . " " . $data['file'] . "\n"; + $sql = "DELETE FROM upload WHERE id='" . $data['id'] . "'"; + $db_results = mysql_query($sql, dbh()); + } } // end foreach - exit(); /*! @@ -132,7 +143,8 @@ sufficient rights to perform the above two functions. $input= fgetc( STDIN ); } while ( trim( $input ) == '' ); - if(strcmp($input,"y") != 0 ) { + if(strcasecmp($input,"y") != 0 ) { + echo "\nExiting...\n"; exit; } } // usage() diff --git a/bin/sort_files.php.inc b/bin/sort_files.php.inc index d0ccc31a..7f446873 100644 --- a/bin/sort_files.php.inc +++ b/bin/sort_files.php.inc @@ -249,7 +249,7 @@ function sort_move_file($song,$fullname) { echo "\tMaking $path Directory\n"; } else { - if (conf('debug')) { log_event('commandline','mkdir',"Creating $path directory"); } + debug_event('mkdir',"Creating $path directory",'5'); $results = mkdir($path); if (!$results) { echo "Error: Unable to create $path move failed\n"; @@ -270,14 +270,13 @@ function sort_move_file($song,$fullname) { /* Check for file existance */ if (file_exists($fullname)) { - if (conf('debug')) { log_event('commandline','file exists','Error: $fullname already exists'); } + debug_event('file exists','Error: $fullname already exists','1'); echo "Error: $fullname already exists\n"; return false; } $results = copy($song->file,$fullname); - if (conf('debug')) { log_event('commandline','copy','Copied ' . $song->file . ' to ' . $fullname); } - + debug_event('copy','Copied ' . $song->file . ' to ' . $fullname,'5'); /* Look for the folder art and copy that as well */ if (!conf('album_art_preferred_filename')) { @@ -289,12 +288,12 @@ function sort_move_file($song,$fullname) { $old_art = $old_dir . "/" . conf('album_art_preferred_filename'); } - if (conf('debug')) { log_event('commandline','copy_art','Copied ' . $old_art . ' to ' . $folder_art); } + debug_event('copy_art','Copied ' . $old_art . ' to ' . $folder_art,'5'); @copy($old_art,$folder_art); if (!$results) { echo "Error: Unable to copy file to $fullname\n"; return false; } - /* Check the md5sums */ + /* Check the filesize */ $new_sum = filesize($fullname); $old_sum = filesize($song->file); diff --git a/lib/class/flag.class.php b/lib/class/flag.class.php index 8bbdc2c9..dc6f44a3 100644 --- a/lib/class/flag.class.php +++ b/lib/class/flag.class.php @@ -113,6 +113,30 @@ class Flag { } // get_total /** + * get_flagged + * This returns an array of ids of flagged songs if no limit is passed + * it gets everything + */ + function get_flagged($count=0) { + + if ($count) { $limit_clause = "LIMIT " . intval($count); } + + $sql = "SELECT id FROM flagged ORDER BY id $limit_clause"; + $db_results = mysql_query($sql, dbh()); + + /* Default it to an array */ + $results = array(); + + /* While the query */ + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = $r['id']; + } + + return $results; + + } // get_flagged + + /** * add * This adds a flag entry for an item, it takes an id, a type, the flag type * and a comment and then inserts the mofo @@ -138,6 +162,34 @@ class Flag { } // add /** + * delete_flag + * This deletes the flagged entry and rescans the file to revert to the origional + * state, in a perfect world, I could just roll the changes back... not until 3.4 + */ + function delete_flag() { + + $sql = "DELETE FROM flagged WHERE id='$this->id'"; + $db_results = mysql_query($sql, dbh()); + + return true; + + } // reject + + /** + * approve + * This approves the current flag object ($this->id) by setting approved to + * 1 + */ + function approve() { + + $sql = "UPDATE flagged SET approved='1' WHERE id='$this->id'"; + $db_results = mysql_query($sql, dbh()); + + return true; + + } // approve + + /** * print_name * This function formats and prints out a userfriendly name of the flagged * object diff --git a/lib/upload.php b/lib/upload.php index 43cfc7bd..deac8ffd 100644 --- a/lib/upload.php +++ b/lib/upload.php @@ -240,4 +240,25 @@ function report_file_error( $error_code ) { } // report_file_error + +/** + * show_upload_status_style + * Pure fluf, it shows Grey for 'unknown' Green for Add and Red for delete + */ +function show_upload_status_style($action) { + + switch ($action) { + case 'add': + return 'width:10px;background:green;'; + break; + case 'delete': + return 'width:10px;background:red;'; + break; + default: + return 'width:10px;'; + break; + } // end switch + +} // show_upload_status_style + ?> diff --git a/templates/show_admin_info.inc.php b/templates/show_admin_info.inc.php index bf5820e4..2d69c058 100644 --- a/templates/show_admin_info.inc.php +++ b/templates/show_admin_info.inc.php @@ -22,24 +22,25 @@ $web_path = conf('web_path'); /* Setup the needed objects */ -$flagged = Flag::get_recent('10'); -$total_flagged = Flag::get_total(); +$flag = new Flag(); +$flagged = $flag->get_recent('10'); +$total_flagged = $flag->get_total(); ?> <span class="header1"><?php echo _('Information'); ?></span><br /> <div class="text-box"> -<span class="header2"><?php echo _('Last Ten Flagged Songs'); ?></span><br /> -<?php require (conf('prefix') . '/templates/show_flagged.inc.php'); ?> -<div class="text-action"> -<a href="<?php echo $web_path; ?>/admin/flag.php?action=show_flagged"><?php echo _('Show All'); ?>...</a> -</div> +<span class="header2"><?php echo _('Last Ten Flagged Records'); ?></span><br /> + <?php require (conf('prefix') . '/templates/show_flagged.inc.php'); ?> + <div class="text-action"> + <a href="<?php echo $web_path; ?>/admin/flag.php?action=show_flagged"><?php echo _('Show All'); ?>...</a> + </div> </div><br /> <span class="header2"><?php echo _('Disabled Songs'); ?></span><br /> <div class="text-box"> -<!-- Show Last 10 Disabled Songs --> + <!-- Show Last 10 Disabled Songs --> </div><br /> <span class="header2"><?php echo _('User Activity'); ?></span><br /> <div class="text-box"> -<!-- Show Last 10 Active Users (Bandwidth Usage guess) --> + <!-- Show Last 10 Active Users (Bandwidth Usage guess) --> </div> diff --git a/templates/show_confirmation.inc.php b/templates/show_confirmation.inc.php index 07994401..bf64f576 100644 --- a/templates/show_confirmation.inc.php +++ b/templates/show_confirmation.inc.php @@ -22,9 +22,11 @@ <div class="confirmation-box"> <span class="header1"><?php echo scrub_out($title); ?></span><br /> <?php echo scrub_out($text); ?> -<br /><br /> -[ <a href="<?php echo $path; ?>"><?php echo _('Continue'); ?></a> ] +<br /> +<div class="text-action"> + <a href="<?php echo $path; ?>"><?php echo _('Continue'); ?></a> <?php if ($cancel) { ?> - [ <a href="<?php echo conf('web_path') . "/" . return_referer(); ?>"><?php echo _('Cancel'); ?></a> ]<br /> + <a href="<?php echo conf('web_path') . "/" . return_referer(); ?>"><?php echo _('Cancel'); ?></a> <?php } ?> </div> +</div> diff --git a/templates/show_flagged.inc.php b/templates/show_flagged.inc.php index 068f38af..b078a2da 100644 --- a/templates/show_flagged.inc.php +++ b/templates/show_flagged.inc.php @@ -47,5 +47,9 @@ $web_path = conf('web_path'); <?php } ?> </td> </tr> +<?php } if (!count($flagged)) { ?> +<tr class="<?php echo flip_class(); ?>"> + <td colspan="4" class="error"><?php echo _('No Records Found'); ?></td> +</tr> <?php } ?> </table> diff --git a/templates/show_mail_users.inc.php b/templates/show_mail_users.inc.php new file mode 100644 index 00000000..19960474 --- /dev/null +++ b/templates/show_mail_users.inc.php @@ -0,0 +1,59 @@ +<?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. + +*/ +?> +<form name="mail" method="post" action="<?php echo conf('web_path'); ?>/admin/mail.php" enctype="multipart/form-data"> +<span class="header1"><?php echo _('Send E-mail to Users'); ?></span> +<table class="text-box"> + <tr> + <td><?php echo _('Mail to'); ?>:</td> + <td> + <select name="to"> + <option value="all" <?php if ($to == 'all') { echo "selected=\"selected\""; } ?>>All</option> + <option value="users" <?php if ($to == 'user') { echo "selected=\"selected\""; } ?>>Users</option> + <option value="admins" <?php if ($to == 'admin') { echo "selected=\"selected\""; } ?>>Admins</option> + </select> + </td> + </tr> + + <tr> + <td><?php echo _('Subject'); ?>:</td> + <td> + <input name="subject" value="<?php echo scrub_out($_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 scrub_out($message); ?></textarea> + </td> + </tr> + + <tr> + <td> </td> + <td> + <input type="hidden" name="action" value="send_mail" /> + <input class="button" type="submit" value="<?php echo _('Send Mail'); ?>" /> + </td> + </tr> +</table> +</form> diff --git a/templates/show_uploads.inc b/templates/show_uploads.inc index d0f444d4..6553c932 100644 --- a/templates/show_uploads.inc +++ b/templates/show_uploads.inc @@ -45,14 +45,19 @@ if (count($uploads)) { <?php foreach ($uploads as $upload) { ?> <tr class="<?php echo flip_class(); ?>"> <?php if($GLOBALS['user']->has_access(100)) { ?> - <td> - <a href="<?php echo conf('web_path'); ?>/upload.php?action=add&id=<?php echo $upload['id']; ?>"><?php echo _('Add'); ?></a> | + <td align="center"> + <div class="text-action"> + <?php if ($upload['action'] != 'add') { ?> + <a href="<?php echo conf('web_path'); ?>/upload.php?action=add&id=<?php echo $upload['id']; ?>"><?php echo _('Add'); ?></a> + <?php } elseif ($upload['action'] != 'delete') { ?> <a href="<?php echo conf('web_path'); ?>/upload.php?action=delete&id=<?php echo $upload['id']; ?>"><?php echo _('Delete'); ?></a> + <?php } ?> + </div> </td> <?php } else { ?> <td>N/A</td> <?php } ?> - <td><?php echo ucfirst($upload['action']); ?></td> + <td style="<?php echo show_upload_status_style($upload['action']); ?>"> </td> <td><?php echo $upload['title']; ?></td> <td><?php echo $upload['artist']; ?></td> <td><?php echo $upload['album']; ?></td> |