summaryrefslogtreecommitdiff
path: root/modules/server_add/controllers/server_add.php
diff options
context:
space:
mode:
authorAndy Staudacher <andy.st@gmail.com>2009-08-29 14:17:48 -0700
committerAndy Staudacher <andy.st@gmail.com>2009-08-29 14:17:48 -0700
commita5dfc81a8f7bef0305b62254252de6df23684199 (patch)
tree4851cb68abede6920208871449dedd2e939c1a16 /modules/server_add/controllers/server_add.php
parentd5660d2d3ea6e8172272f1eb27e8071a1a42d87b (diff)
parenta9fcec755a835e284465bafcc9aba9ec9c2f0f62 (diff)
Merge commit 'upstream/master'
Conflicts: modules/akismet/views/admin_akismet.html.php modules/comment/helpers/comment_rss.php modules/gallery/helpers/gallery_rss.php modules/gallery/libraries/I18n.php modules/gallery/views/permissions_browse.html.php modules/gallery/views/simple_uploader.html.php modules/info/views/info_block.html.php modules/organize/controllers/organize.php modules/organize/views/organize.html.php modules/organize/views/organize_album.html.php themes/default/views/album.html.php themes/default/views/movie.html.php themes/default/views/photo.html.php
Diffstat (limited to 'modules/server_add/controllers/server_add.php')
-rw-r--r--modules/server_add/controllers/server_add.php33
1 files changed, 20 insertions, 13 deletions
diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php
index f68392ce..26b3bd08 100644
--- a/modules/server_add/controllers/server_add.php
+++ b/modules/server_add/controllers/server_add.php
@@ -150,7 +150,8 @@ class Server_Add_Controller extends Admin_Controller {
$queue[] = array($child, $entry->id);
} else {
$ext = strtolower(pathinfo($child, PATHINFO_EXTENSION));
- if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) {
+ if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4")) &&
+ filesize($child) > 0) {
$child_entry = ORM::factory("server_add_file");
$child_entry->task_id = $task->id;
$child_entry->file = $child;
@@ -219,19 +220,25 @@ class Server_Add_Controller extends Admin_Controller {
$album = album::create($parent, $name, $title, null, $owner_id);
$entry->item_id = $album->id;
} else {
- $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
- if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) {
- $photo = photo::create($parent, $entry->file, $name, $title, null, $owner_id);
- $entry->item_id = $photo->id;
- } else if (in_array($extension, array("flv", "mp4"))) {
- $movie = movie::create($parent, $entry->file, $name, $title, null, $owner_id);
- $entry->item_id = $movie->id;
- } else {
- // This should never happen, because we don't add stuff to the list that we can't
- // process. But just in, case.. set this to a non-null value so that we skip this
- // entry.
+ try {
+ $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
+ if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) {
+ $photo = photo::create($parent, $entry->file, $name, $title, null, $owner_id);
+ $entry->item_id = $photo->id;
+ } else if (in_array($extension, array("flv", "mp4"))) {
+ $movie = movie::create($parent, $entry->file, $name, $title, null, $owner_id);
+ $entry->item_id = $movie->id;
+ } else {
+ // This should never happen, because we don't add stuff to the list that we can't
+ // process. But just in, case.. set this to a non-null value so that we skip this
+ // entry.
+ $entry->item_id = 0;
+ $task->log("Skipping unknown file type: $entry->file");
+ }
+ } catch (Exception $e) {
+ // This can happen if a photo file is invalid, like a BMP masquerading as a .jpg
$entry->item_id = 0;
- $task->log("Skipping unknown file type: $entry->file");
+ $task->log("Skipping invalid file: $entry->file");
}
}