Modifications arround getExtension

This commit is contained in:
Quentin Ligier 2016-03-17 19:21:59 +01:00
parent 4324d2a5cb
commit 44c54c48f6
6 changed files with 9 additions and 3 deletions

BIN
dist/main.js vendored

Binary file not shown.

BIN
dist/view.js vendored

Binary file not shown.

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, true); $extension = getExtension($photo->url, false);
// Set title for photo // Set title for photo
$zipFileName = $zipTitle . '/' . $photo->title . $extension; $zipFileName = $zipTitle . '/' . $photo->title . $extension;

View File

@ -845,7 +845,7 @@ final class Photo {
} }
// Get extension // Get extension
$extension = getExtension($photo->url, true); $extension = getExtension($photo->url, false);
if (empty($extension)===true) { if (empty($extension)===true) {
Log::error(Database::get(), __METHOD__, __LINE__, 'Invalid photo extension'); Log::error(Database::get(), __METHOD__, __LINE__, 'Invalid photo extension');
return false; return false;

View File

@ -6,11 +6,14 @@
*/ */
function getExtension($filename, $isURI = false) { function getExtension($filename, $isURI = false) {
// If $filename is an URI, get only the path component # If $filename is an URI, get only the path component
if ($isURI===true) $filename = parse_url($filename, PHP_URL_PATH); if ($isURI===true) $filename = parse_url($filename, PHP_URL_PATH);
$extension = pathinfo($filename, PATHINFO_EXTENSION); $extension = pathinfo($filename, PATHINFO_EXTENSION);
# Special cases
if (strpos($extension, ':')!==false) list($extension, ) = explode(':', $extension, 2);
if (empty($extension)===false) $extension = '.' . $extension; if (empty($extension)===false) $extension = '.' . $extension;
return $extension; return $extension;

View File

@ -275,11 +275,14 @@ upload.start = {
basicModal.close() basicModal.close()
/*
// Only check for file validity on PHP side
let extension = data.link.split('.').pop() let extension = data.link.split('.').pop()
if (extension!=='jpeg' && extension!=='jpg' && extension!=='png' && extension!=='gif' && extension!=='webp') { if (extension!=='jpeg' && extension!=='jpg' && extension!=='png' && extension!=='gif' && extension!=='webp') {
loadingBar.show('error', 'File format of link not supported.') loadingBar.show('error', 'File format of link not supported.')
return false return false
} }
*/
files[0] = { files[0] = {
name : data.link, name : data.link,