summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-12-28 22:56:55 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-12-28 22:56:55 +0000
commitd6e28b752f3f04e418a4c27f37fa67b76596d5ec (patch)
tree7425e8a886db303672c97ccebc3d145bf5fa8b5d /lib
parent223143ed3a95ad59ff2945f6746da73992012354 (diff)
downloadampache-d6e28b752f3f04e418a4c27f37fa67b76596d5ec.tar.gz
ampache-d6e28b752f3f04e418a4c27f37fa67b76596d5ec.tar.bz2
ampache-d6e28b752f3f04e418a4c27f37fa67b76596d5ec.zip
* Added new Snoopy, fixes some minor bugs
* Rewrote Album Art collection, fixing tons of logic flaws, single album art find is currently broken might even be a little faster now when using folder and id3 methods at the same time * Fixed some issues with FastCGI installs * Removed another upload file that wasn't used anymore * Tweaked Recently Played to show 'played XXX ago'
Diffstat (limited to 'lib')
-rw-r--r--lib/album.lib.php33
-rw-r--r--lib/class/album.class.php345
-rw-r--r--lib/class/catalog.class.php60
-rw-r--r--lib/init.php1
-rw-r--r--lib/upload.php264
5 files changed, 229 insertions, 474 deletions
diff --git a/lib/album.lib.php b/lib/album.lib.php
index fc030163..891c1b24 100644
--- a/lib/album.lib.php
+++ b/lib/album.lib.php
@@ -24,6 +24,39 @@ function get_albums($sql, $action=0) {
} // get_albums
+/**
+ * get_image_from_source
+ * This gets an image for the album art from a source as
+ * defined in the passed array. Because we don't know where
+ * its comming from we are a passed an array that can look like
+ * ['url'] = URL *** OPTIONAL ***
+ * ['file'] = FILENAME *** OPTIONAL ***
+ * ['raw'] = Actual Image data, already captured
+ */
+function get_image_from_source($data) {
+
+ // Already have the data, this often comes from id3tags
+ if (isset($data['raw'])) {
+ return $data['raw'];
+ }
+
+ // Check to see if it's a URL
+ if (isset($data['url'])) {
+ $snoopy = new Snoopy();
+ $snoopy->fetch($results['url']);
+ return $snoopy->results;
+ }
+
+ // Check to see if it's a FILE
+ if (isset($data['file'])) {
+ $handle = fopen($data['file'],'rb');
+ $image_data = fread($handle,filesize($data['file']));
+ fclose($handle);
+ return $image_data;
+ }
+
+ return false;
+} // get_image_from_source
?>
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 0279bb62..be13d7c8 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -36,6 +36,9 @@ class Album {
var $art;
var $art_mime;
+ // cached information
+ var $_songs=array();
+
/*!
@function Album
@discussion Album class, for modifing a song.
@@ -178,24 +181,29 @@ class Album {
/**
* get_art
- * This function should be called for gathering and returning Album Art
- * By default it ignores the DB and looks at the current gathering preferences
- * as defined by the config file and attempts to find the album art. If the
- * param FAST is passed then it will only check the database, if no art is
- * found it return false. This only return the first art found and should
- * not be used for the advanced album art finding functions, but for the
- * catalog
+ * This function only pulls art from the database, nothing else
+ * It should not be called when trying to find new art
*/
- function get_art($fast = 0) {
+ function get_art() {
- // If we are doing fast then only return
- // what's in the database
- if ($fast) {
- return $this->get_db_art();
- }
+ return $this->get_db_art();
+
+ } // get_art
+
+ /**
+ * find_art
+ * This function searches for album art using all configured methods
+ * for the current album. There is an optional 'limit' passed that will
+ * gather up to the specified number of possible album covers.
+ * There is also an optional array of options the possible options are
+ * ['keyword'] = STRING
+ * ['artist'] = STRING
+ * ['album_name'] = STRING
+ */
+ function find_art($options=array(),$limit=null) {
/* Create Base Vars */
- $album_art_order = array();
+ $results = array();
/* Attempt to retrive the album art order */
$config_value = conf('album_art_order');
@@ -203,80 +211,106 @@ class Album {
/* If it's not set */
if (empty($config_value)) {
- $album_art_order = array('id3','folder','amazon');
+ // They don't want art!
+ return false;
}
elseif (!is_array($config_value)) {
- array_push($album_art_order,$config_value);
- }
- else {
- $album_art_order = array_merge($album_art_order, conf('album_art_order'));
+ $config_value = array($config_value);
}
- foreach ($album_art_order AS $method) {
+ foreach ($config_value AS $method) {
$method_name = "get_" . $method . "_art";
if (in_array($method_name,$class_methods)) {
- if ($this->{$method_name}()) {
- return $this->get_db_art();
- } // if method finds the art
+ // Some of these take options!
+ switch ($method_name) {
+ case 'get_amazon_art':
+ $data = $this->{$method_name}($options['keyword']);
+ break;
+ case 'get_id3_art':
+ $data = $this->{$method_name}($limit);
+ break;
+ default:
+ $data = $this->{$method_name}();
+ break;
+ }
+
+ // Add the results we got to the current set
+ $total_results += count($data);
+ $results = array_merge($results,$data);
+
+ if ($total_results > $limit) {
+ return $results;
+ }
+
} // if the method exists
} // end foreach
- return false;
+ return $results;
- } // get_art
+ } // find_art
/*!
@function get_id3_art
@discussion looks for art from the id3 tags
*/
- function get_id3_art() {
+ function get_id3_art($limit='') {
- $songs = $this->get_songs();
+ // grab the songs and define our results
+ if (!count($this->_songs)) {
+ $this->_songs = $this->get_songs();
+ }
+ $data = array();
// Foreach songs in this album
- foreach ($songs as $song) {
+ foreach ($this->_songs as $song) {
+
// If we find a good one, stop looking
$getID3 = new getID3();
$id3 = $getID3->analyze($song->file);
if ($id3['format_name'] == "WMA") {
$image = $id3['asf']['extended_content_description_object']['content_descriptors']['13'];
+ $data[] = array('raw'=>$image['data'],'mime'=>$image['mime']);
}
- else {
- $image = $id3['id3v2']['APIC']['0'];
+ elseif (isset($id3['id3v2']['APIC'])) {
+ // Foreach incase they have more then one
+ foreach ($id3['id3v2']['APIC'] as $image) {
+ $data[] = array('raw'=>$image['data'],'mime'=>$image['mime']);
+ }
}
- if ($image) {
- $art = $image['data'];
- $mime = $image['mime'];
- // Stick it in the db for next time
- $this->insert_art($art,$mime);
-
- return true;
- } // end if image
+ if (!empty($limit) && $limit < count($data)) {
+ return $data;
+ }
+
} // end foreach
- return false;
+ return $data;
} // get_id3_art
- /*!
- @function get_folder_art()
- @discussion returns the album art from the folder of the mp3s
- */
- function get_folder_art() {
+ /**
+ * get_folder_art()
+ * returns the album art from the folder of the audio files
+ * If a limit is passed or the preferred filename is found the current results set
+ * is returned
+ */
+ function get_folder_art($limit='') {
- $songs = $this->get_songs();
+ if (!count($this->_songs)) {
+ $this->_songs = $this->get_songs();
+ }
+ $data = array();
/* See if we are looking for a specific filename */
$preferred_filename = conf('album_art_preferred_filename');
/* Thanks to dromio for origional code */
/* Added search for any .jpg, png or .gif - Vollmer */
- foreach($songs as $song) {
+ foreach($this->_songs as $song) {
$dir = dirname($song->file);
/* Open up the directory */
@@ -295,46 +329,33 @@ class Album {
if ($extension == "jpg" || $extension == "gif" || $extension == "png" || $extension == "jp2") {
if ($file == $preferred_filename) {
- $found = 1;
- $album_art_filename = array('file' => $file, 'ext' => $extension);
- break;
- }
- elseif (!$preferred_filename) {
- $found = 1;
- $album_art_filename = array('file' => $file, 'ext' => $extension);
- break;
+ // If we found the preferred filename we're done, wipe out previous results
+ $data = array(array('file' => $file, 'mime' => 'image/' . $extension));
+ return $data;
}
else {
- $found = 1;
- $album_art_filename = array('file' => $file, 'ext' => $extension);
+ $data[] = array('file' => $file, 'mime' => 'image/' . $extension);
}
} // end if it's an image
} // end while reading dir
@closedir($handle);
+
+ if (!empty($limit) && $limit < count($data)) {
+ return $data;
+ }
- if ($found) {
- $handle = fopen($dir."/".$album_art_filename['file'], "rb");
- $mime = "image/" . $album_art_filename['ext'];
- $art = '';
- while(!feof($handle)) {
- $art .= fread($handle, 1024);
- }
- fclose($handle);
- $this->insert_art($art,$mime);
- return true;
- } // if found
} // end foreach songs
- return false;
+ return $data;
} // get_folder_art()
- /*!
- @function get_db_art()
- @discussion returns the album art from the db
- */
+ /**
+ * get_db_art()
+ * returns the album art from the db along with the mime type
+ */
function get_db_art() {
$sql = "SELECT art,art_mime FROM album WHERE id='$this->id' AND art_mime IS NOT NULL";
@@ -345,100 +366,13 @@ class Album {
return $results;
} // get_db_art
-
-
- /*!
- @function get_amazon_art
- @discussion searches amazon for the
- album art
- */
- function get_amazon_art() {
-
- $results = $this->find_art();
-
- if (count($results) < 1) { return false; }
-
- $snoopy = new Snoopy();
- $snoopy->fetch($results['0']['url']);
- $data = $snoopy->results;
-
- $this->insert_art($data,$results['0']['mime']);
-
- return true;
-
- } // get_amazon_art
-
- /*!
- @function get_random_songs
- @discussion gets a random number, and
- a random assortment of songs from this
- album
- */
- function get_random_songs() {
-
- $results = array();
-
- $sql = "SELECT id FROM song WHERE album='$this->id' ORDER BY RAND()";
- $db_results = mysql_query($sql, dbh());
-
- while ($r = mysql_fetch_array($db_results)) {
- $results[] = $r[0];
- }
-
- return $results;
-
- } // get_random_songs
-
- /*!
- @function clear_art
- @discussion clears the album art from the DB
- */
- function clear_art() {
-
- $sql = "UPDATE album SET art=NULL, art_mime=NULL WHERE id='$this->id'";
- $db_results = mysql_query($sql, dbh());
-
- } // clear_art
-
- /*!
- @function insert_art
- @discussion this takes a string representation of an image
- and inserts it into the database. You must pass the
- mime type as well
- */
- function insert_art($image, $mime) {
-
- /* Have to disable this for Demo because people suck and try to
- * insert PORN :(
- */
- if (conf('demo_mode')) { return false; }
-
- // Check for PHP:GD and if we have it make sure this image is of some size
- if (function_exists('ImageCreateFromString')) {
- $im = @ImageCreateFromString($image);
- if (@imagesx($im) == 1 || @imagesy($im) == 1 && $im) {
- return false;
- }
- } // if we have PHP:GD
-
- // Push the image into the database
- $sql = "UPDATE album SET art = '" . sql_escape($image) . "'," .
- " art_mime = '" . sql_escape($mime) . "'" .
- " WHERE id = '$this->id'";
- $db_results = mysql_query($sql, dbh());
- return true;
-
- } // insert_art
-
- /*!
- @function find_art
- @discussion searches amazon or a url
- for the album art
- @patch Added Keyword Support (csammis)
- @patch Added Variable Root Amazon Search (nhorloc)
- */
- function find_art($coverurl = '', $keywords = '') {
+ /**
+ * get_amazon_art
+ * This takes keywords and performs a search of the Amazon website
+ * for album art. It returns an array of found objects with mime/url keys
+ */
+ function get_amazon_art($keywords = '') {
$images = array();
$final_results = array();
@@ -447,9 +381,6 @@ class Album {
// Prevent the script from timing out
set_time_limit(0);
- // No coverurl specified search amazon
- if (empty($coverurl)) {
-
if (empty($keywords)) {
$keywords = $this->name;
/* If this isn't a various album combine with artist name */
@@ -498,13 +429,7 @@ class Album {
/* Log this if we're doin debug */
debug_event('amazon-xml',"Searched using $keywords with " . conf('amazon_developer_key') . " as key " . count($final_results) . " results found",'5');
} // end foreach
- } // if no cover
-
- // If we've specified a coverurl, create a fake Amazon array with it
- else {
- $final_results = array_merge($final_results, array(array('LargeImage' => $coverurl)));
- }
-
+
/* Foreach through what we've found */
foreach ($final_results as $result) {
@@ -533,11 +458,75 @@ class Album {
$images[] = $data;
} // if we've got something
-
- /* Default to false */
+
return $images;
- } // find_art
+ } // get_amazon_art()
+
+
+ /*!
+ @function get_random_songs
+ @discussion gets a random number, and
+ a random assortment of songs from this
+ album
+ */
+ function get_random_songs() {
+
+ $results = array();
+
+ $sql = "SELECT id FROM song WHERE album='$this->id' ORDER BY RAND()";
+ $db_results = mysql_query($sql, dbh());
+
+ while ($r = mysql_fetch_array($db_results)) {
+ $results[] = $r[0];
+ }
+
+ return $results;
+
+ } // get_random_songs
+
+ /*!
+ @function clear_art
+ @discussion clears the album art from the DB
+ */
+ function clear_art() {
+
+ $sql = "UPDATE album SET art=NULL, art_mime=NULL WHERE id='$this->id'";
+ $db_results = mysql_query($sql, dbh());
+
+ } // clear_art
+
+ /*!
+ @function insert_art
+ @discussion this takes a string representation of an image
+ and inserts it into the database. You must pass the
+ mime type as well
+ */
+ function insert_art($image, $mime) {
+
+ /* Have to disable this for Demo because people suck and try to
+ * insert PORN :(
+ */
+ if (conf('demo_mode')) { return false; }
+
+ // Check for PHP:GD and if we have it make sure this image is of some size
+ if (function_exists('ImageCreateFromString')) {
+ $im = @ImageCreateFromString($image);
+ if (@imagesx($im) == 1 || @imagesy($im) == 1 && $im) {
+ return false;
+ }
+ } // if we have PHP:GD
+
+ // Push the image into the database
+ $sql = "UPDATE album SET art = '" . sql_escape($image) . "'," .
+ " art_mime = '" . sql_escape($mime) . "'" .
+ " WHERE id = '$this->id'";
+ $db_results = mysql_query($sql, dbh());
+
+ return true;
+
+ } // insert_art
+
} //end of album class
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index 347d6ef3..75702add 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -461,29 +461,25 @@ class Catalog {
// Run through them an get the art!
foreach ($albums as $album) {
flush();
- if ($debug) { echo "&nbsp;&nbsp;&nbsp;&nbsp;" . $album->name . " -- "; }
-
- if ($methods['id3']) {
- $found = $album->get_id3_art();
- if ($found && $debug) { echo _("Found in ID3") . "<br />\n"; }
- }
- if ($methods['amazon'] && !$found) {
- $found = $album->get_amazon_art();
- if ($found && $debug) { echo _("Found on Amazon") . "<br />\n"; }
- }
- if ($methods['folder'] && !$found) {
- $found = $album->get_folder_art();
- if ($found && $debug) { echo _("Found in Folder") . "<br />\n"; }
+ if (conf('debug')) {
+ debug_event('gather_art','Gathering art for ' . $album->name,'5');
}
- if (count($methods) == '0' && !$found) {
- $found = $album->get_art();
- if ($found && $debug) { echo _("Found") . "<br />\n"; }
- }
-
- if (!$found && $debug) { echo "<font class=\"error\">" . _("Not Found") . "</font><br />\n"; }
+ // Define the options we want to use for the find art function
+ $options = array(
+ 'album_name' => $album->name,
+ 'artist' => $album->artist,
+ 'keyword' => $album->artist . ' ' . $album->name
+ );
+
+ // Return results
+ $results = $album->find_art($options,1);
+
+ // Pull the string representation from the source
+ $image = get_image_from_source($results['0']);
+ $album->insert_art($image,$results['0']['mime']);
+
if ($found) { $art_found++; }
-
/* Stupid little cutesie thing */
$search_count++;
@@ -1635,21 +1631,23 @@ class Catalog {
$album_id = $song->album;
if ($info['change']) {
echo "<dl style=\"list-style-type:none;\">\n\t<li>";
- echo "<b>$song->file " . _("Updated") . "</b>\n";
+ echo "<b>$song->file " . _('Updated') . "</b>\n";
echo $info['text'];
- /* If we aren't doing a fast update re-gather album art */
- if ($gather_type != 'fast_update' AND !isset($searched_albums[$album_id])) {
- $album = new Album($song->album);
- $searched_albums[$album_id] = 1;
- $found = $album->get_art();
- unset($album);
- if ($found) { $is_found = _(" FOUND"); }
+ $album = new Album($song->album);
+
+ if (!$album->has_art) {
+ $found = $album->find_art($options,1);
+ if (count($found)) {
+ $image = get_image_from_source($found['0']);
+ $album->insert_art($image,$found['mime']);
+ $is_found = _(' FOUND');
+ }
echo "<br /><b>" . _('Searching for new Album Art') . ". . .$is_found</b><br />\n";
unset($found,$is_found);
- }
- elseif (isset($searched_albums[$album_id])) {
+ }
+ else {
echo "<br /><b>" . _('Album Art Already Found') . ". . .</b><br />\n";
- }
+ }
echo "\t</li>\n</dl>\n<hr align=\"left\" width=\"50%\" />\n";
flush();
$total_updated++;
diff --git a/lib/init.php b/lib/init.php
index a3c9e98d..b7fbdac1 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -154,7 +154,6 @@ require_once(conf('prefix') . '/lib/batch.lib.php');
require_once(conf('prefix') . '/lib/themes.php');
require_once(conf('prefix') . '/lib/stream.lib.php');
require_once(conf('prefix') . '/lib/playlist.lib.php');
-require_once(conf('prefix') . '/lib/upload.php');
require_once(conf('prefix') . '/lib/democratic.lib.php');
require_once(conf('prefix') . '/modules/lib.php');
require_once(conf('prefix') . '/modules/catalog.php');
diff --git a/lib/upload.php b/lib/upload.php
deleted file mode 100644
index 9390d519..00000000
--- a/lib/upload.php
+++ /dev/null
@@ -1,264 +0,0 @@
-<?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.
-
-*/
-
-/*!
- @function check_upload_extension
- @discussion checks the extension against the allow list
-*/
-function check_upload_extension($name='file') {
-
-
- $filename = $_FILES[$name]['name'];
-
- $path_parts = pathinfo($filename);
-
- $extension = $path_parts['extension'];
-
- $allowed_extensions = "/" . conf('catalog_file_pattern') . "/";
- if (preg_match($allowed_extensions,$extension)) {
- return true;
- }
-
- debug_event('upload',"Error: Invalid Extension $extension",'2');
-
- return false;
-
-} // check_upload_extension
-
-/*!
- @function check_upload_size
- @discussion checks the filesize of the upload
-*/
-function check_upload_size($name='file') {
- static $total_size;
-
- $size = $_FILES[$name]['size'];
-
- $total_size = $total_size + $size;
-
- if ($size > conf('max_upload_size')) {
- debug_event('upload',"Error: Upload to large, $size",'2');
- return false;
- }
-
- if ($total_size > conf('max_upload_size')) {
- debug_event('upload',"Error: Total Upload to large, $total_size",'2');
- return false;
- }
-
- return true;
-
-} // check_upload_size
-
-/*!
- @function check_upload_directory
- @discussion this functions checks to make sure that you can actually write to the upload directory
-*/
-function check_upload_directory($directory) {
-
- /* We need to make sure we can write to said dir */
- if (@is_writable($directory)) {
- return true;
- }
-
- return false;
-
-} // check_upload_directory
-
-/*!
- @function find_upload_catalog
- @dicussion all upload directories must be contained within another catalog, this checks
- to make sure that is true. returns id of catalog found or false
-*/
-function find_upload_catalog($directory) {
-
- $sql = "SELECT id, path FROM catalog";
- $db_results = mysql_query($sql, dbh());
-
- while( $results = mysql_fetch_assoc($db_results)) {
-
- $catalog_path = str_replace("\\","/",$results['path']);
-
- $directory = str_replace("\\","/",$directory);
- if (strncmp($directory,$catalog_path,strlen($catalog_path)) == '0') {
- return $results['id'];
- }
-
- } // end while loop through catalog records
-
- return false;
-
-} // find_upload_catalog
-
-/*!
- @function upload_file
- @discussion this uploads a file to ampache
-*/
-function upload_file($file,$target_directory) {
-
- /* Build target file names */
- $full_filename = $target_directory . "/" . $_FILES[$file]['name'];
-
- /* Check to make sure the file doesn't exist already */
- if (file_exists($full_filename)) {
- $GLOBALS['error']->add_error($file,"Error: $full_filename already exists");
- return false;
- }
-
- /* Attempt to move the file */
- if (!$upload_code = @move_uploaded_file($_FILES[$file]['tmp_name'],$full_filename)) {
- $GLOBALS['error']->add_error($file,"Error: Unable to move $full_filename");
- return false;
- }
-
- return $full_filename;
-
-} // upload_file
-
-/*!
- @function insert_quarantine_record
- @discussion this inserts the record that a file has been added
-*/
-function insert_quarantine_record($username,$action,$filename) {
-
- /* First make sure this file isn't listed already */
- $sql = "SELECT id FROM " . tbl_name('upload') . " WHERE file='" . sql_escape($filename) . "'";
- $db_results = mysql_query($sql, dbh());
-
- /* If no rows, insert using ugly sql statement */
- if (!mysql_num_rows($db_results)) {
- $sql = "INSERT INTO " . tbl_name('upload') . " (`user`,`file`,`action`,`addition_time`)" .
- " VALUES ('$username','" . sql_escape($filename) . "','$action','" . time() . "')";
- $db_results = mysql_query($sql, dbh());
- }
-
- else {
- $sql = "UPDATE " . tbl_name('upload') . " SET action='$action' WHERE file='" . sql_escape($filename) . "'";
- $db_results = mysql_query($sql, dbh());
- }
-
-} // insert_quarantine_record
-
-/*!
- @function update_quarantine_record
- @discusison this updates an existing quarantine record
-*/
-function update_quarantine_record($id, $new_action) {
-
- $sql = "UPDATE " . tbl_name('upload') . " SET action='$new_action' WHERE id='" . sql_escape($id) . "'";
- $db_results = mysql_query($sql, dbh());
-
- return true;
-
-} // update_quarantine_record
-
-/*!
- @function get_uploads
- @discussion gets uploads and returns an array of em
-*/
-function get_uploads() {
-
- $sql = "SELECT * FROM " . tbl_name('upload');
- $db_results = mysql_query($sql, dbh());
-
- $results = array();
-
- while ($r = mysql_fetch_assoc($db_results)) {
-
- /* Create the vainfo object and get info */
- $vainfo = new vainfo($r['file']);
- $vainfo->get_info();
- $data = $vainfo->tags;
-
- $key = get_tag_type($vainfo->tags);
-
- /* Fill Empty info from filename/path */
- $data = clean_tag_info($vainfo->tags,$key,$r['file']);
-
- $data['id'] = $r['id'];
- $data['user'] = $r['user'];
- $data['action'] = $r['action'];
- $data['addition_time'] = $r['addition_time'];
-
- $results[] = $data;
-
- } // end while
-
- return $results;
-
-} // get_uploads
-
-/*!
- @function show_upload
- @discussion This shows the upload templates
-*/
-function show_upload() {
-
- require_once( "templates/show_upload.inc" );
- echo( "\n<br /><br />\n" );
- require_once( "templates/show_uploads.inc" );
-
-} // show_upload
-
-/*!
- @function report_file_error
- @discussion use with $_FILES and move_uploaded_file
- if move_uploaded_file returns false (error), pass
- $file['error'] here for interpretation
-*/
-function report_file_error( $error_code ) {
-
- $codes = array(
- 0 => _( "The file uploaded successfully" ),
- 1 => _( "The uploaded file exceeds the upload_max_filesize directive in php.ini" ),
- 2 => _( "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form" ),
- 3 => _( "The uploaded file was only partially uploaded" ),
- 4 => _( "No file was uploaded" ),
- 6 => _( "Missing a temporary folder" )
- );
-
- return $codes[$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
-
-?>