Merge branch 'develop' of https://github.com/electerious/Lychee into develop

This commit is contained in:
Tobias Reich 2016-03-17 09:20:26 +01:00
commit 31e41eb2b1
5 changed files with 17 additions and 11 deletions

View File

@ -278,7 +278,7 @@ final class Album {
if (!@is_readable($photo->url)) continue; if (!@is_readable($photo->url)) continue;
// Get extension of image // Get extension of image
$extension = getExtension($photo->url); $extension = getExtension($photo->url, true);
// Set title for photo // Set title for photo
$zipFileName = $zipTitle . '/' . $photo->title . $extension; $zipFileName = $zipTitle . '/' . $photo->title . $extension;

View File

@ -50,7 +50,7 @@ final class Import {
// This prevents us from downloading invalid photos. // This prevents us from downloading invalid photos.
// Verify extension // Verify extension
$extension = getExtension($url); $extension = getExtension($url, true);
if (!in_array(strtolower($extension), Photo::$validExtensions, true)) { if (!in_array(strtolower($extension), Photo::$validExtensions, true)) {
$error = true; $error = true;
Log::error(Database::get(), __METHOD__, __LINE__, 'Photo format not supported (' . $url . ')'); Log::error(Database::get(), __METHOD__, __LINE__, 'Photo format not supported (' . $url . ')');

View File

@ -4,6 +4,7 @@ namespace Lychee\Modules;
use ZipArchive; use ZipArchive;
use Imagick; use Imagick;
use ImagickPixel;
final class Photo { final class Photo {
@ -123,7 +124,7 @@ final class Photo {
} }
// Verify extension // Verify extension
$extension = getExtension($file['name']); $extension = getExtension($file['name'], false);
if (!in_array(strtolower($extension), self::$validExtensions, true)) { if (!in_array(strtolower($extension), self::$validExtensions, true)) {
Log::error(Database::get(), __METHOD__, __LINE__, 'Photo format not supported'); Log::error(Database::get(), __METHOD__, __LINE__, 'Photo format not supported');
if ($returnOnError===true) return false; if ($returnOnError===true) return false;
@ -844,8 +845,8 @@ final class Photo {
} }
// Get extension // Get extension
$extension = getExtension($photo->url); $extension = getExtension($photo->url, true);
if ($extension===false) { if (empty($extension)) {
Log::error(Database::get(), __METHOD__, __LINE__, 'Invalid photo extension'); Log::error(Database::get(), __METHOD__, __LINE__, 'Invalid photo extension');
return false; return false;
} }

View File

@ -1,13 +1,18 @@
<?php <?php
function getExtension($filename) { # Returns the extension of the filename (path or URI) or an empty string
function getExtension($filename, $isURI = false) {
$extension = strpos($filename, '.') !== false # If $filename is an URI, get only the path component
? strrchr($filename, '.') if ($isURI)
: ''; $filename = parse_url($filename, PHP_URL_PATH);
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if (!empty($extension))
$extension = '.' . $extension;
return $extension; return $extension;
} }
?> ?>

View File

@ -91,7 +91,7 @@ if (!$settings['dropboxKey']) echo('Warning: Dropbox import not working. No prop
// Check php.ini Settings // Check php.ini Settings
if (ini_get('max_execution_time')<200&&ini_set('upload_max_filesize', '20M')===false) echo('Warning: You may experience problems when uploading a large amount of photos. Take a look in the FAQ for details.' . PHP_EOL); if (ini_get('max_execution_time')<200&&ini_set('upload_max_filesize', '20M')===false) echo('Warning: You may experience problems when uploading a large amount of photos. Take a look in the FAQ for details.' . PHP_EOL);
if (!ini_get('allow_url_fopen')) echo('Warning: You may experience problems with the Dropbox- and URL-Import. Edit your php.ini and set allow_url_fopen to 1.' . PHP_EOL); if (empty(ini_get('allow_url_fopen'))) echo('Warning: You may experience problems with the Dropbox- and URL-Import. Edit your php.ini and set allow_url_fopen to 1.' . PHP_EOL);
// Check mysql version // Check mysql version
if ($database->server_version<50500) echo('Warning: Lychee uses the GBK charset to avoid sql injections on your MySQL version. Please update to MySQL 5.5 or higher to enable UTF-8 support.' . PHP_EOL); if ($database->server_version<50500) echo('Warning: Lychee uses the GBK charset to avoid sql injections on your MySQL version. Please update to MySQL 5.5 or higher to enable UTF-8 support.' . PHP_EOL);