Merge branch 'feed' into 2.1
This commit is contained in:
commit
91618c24e1
@ -345,9 +345,11 @@ build = {
|
||||
break;
|
||||
|
||||
case "Tags": // Tags
|
||||
infobox += "</table>";
|
||||
infobox += "<div class='separator'><h1>" + infos[index][0] + "</h1></div>";
|
||||
infobox += "<div id='tags'>" + infos[index][1] + "</div>";
|
||||
if (forView!==true&&!lychee.publicMode) {
|
||||
infobox += "</table>";
|
||||
infobox += "<div class='separator'><h1>" + infos[index][0] + "</h1></div>";
|
||||
infobox += "<div id='tags'>" + infos[index][1] + "</div>";
|
||||
}
|
||||
break;
|
||||
|
||||
default: // Item
|
||||
|
@ -224,7 +224,7 @@ contextMenu = {
|
||||
|
||||
lychee.api("getAlbums", function(data) {
|
||||
|
||||
if (!data.albums) {
|
||||
if (data.num===0) {
|
||||
items = [["New Album", 0, "album.add()"]];
|
||||
} else {
|
||||
$.each(data.content, function(index) {
|
||||
|
@ -20,6 +20,7 @@ multiselect = {
|
||||
|
||||
if (mobileBrowser()) return false;
|
||||
if (lychee.publicMode) return false;
|
||||
if (visible.search()) return false;
|
||||
if ($('.album:hover, .photo:hover').length!=0) return false;
|
||||
if (visible.multiselect()) $('#multiselect').remove();
|
||||
|
||||
|
@ -200,7 +200,7 @@ photo = {
|
||||
|
||||
});
|
||||
|
||||
params = "setAlbum&photoIDs=" + photoIDs + "&albumID=" + albumID;
|
||||
params = "setPhotoAlbum&photoIDs=" + photoIDs + "&albumID=" + albumID;
|
||||
lychee.api(params, function(data) {
|
||||
|
||||
if (data!==true) lychee.error(null, params, data);
|
||||
@ -355,7 +355,7 @@ photo = {
|
||||
album.json.content[id].tags = tags;
|
||||
});
|
||||
|
||||
params = "setTags&photoIDs=" + photoIDs + "&tags=" + tags;
|
||||
params = "setPhotoTags&photoIDs=" + photoIDs + "&tags=" + tags;
|
||||
lychee.api(params, function(data) {
|
||||
|
||||
if (data!==true) lychee.error(null, params, data);
|
||||
|
@ -170,6 +170,7 @@ upload = {
|
||||
}],
|
||||
["Cancel", function() {}]
|
||||
];
|
||||
|
||||
modal.show("Import from Link", "Please enter the direct link to a photo to import it: <input class='text' type='text' placeholder='http://' value='http://'>", buttons);
|
||||
|
||||
},
|
||||
@ -194,10 +195,15 @@ upload = {
|
||||
upload.close();
|
||||
upload.notify("Import complete");
|
||||
|
||||
if (album.getID()===false) lychee.goto("0");
|
||||
if (data==="Notice: Import only contains albums!") {
|
||||
if (visible.albums()) lychee.load();
|
||||
else lychee.goto("");
|
||||
}
|
||||
else if (album.getID()===false) lychee.goto("0");
|
||||
else album.load(albumID);
|
||||
|
||||
if (data==="Warning: Folder empty!") lychee.error("Folder empty. No photos imported!", params, data);
|
||||
if (data==="Notice: Import only contains albums!") return true;
|
||||
else if (data==="Warning: Folder empty!") lychee.error("Folder empty. No photos imported!", params, data);
|
||||
else if (data!==true) lychee.error(null, params, data);
|
||||
|
||||
});
|
||||
@ -205,7 +211,8 @@ upload = {
|
||||
}],
|
||||
["Cancel", function() {}]
|
||||
];
|
||||
modal.show("Import from Server", "This action will import all photos which are located in <b>'uploads/import/'</b> of your Lychee installation.", buttons);
|
||||
|
||||
modal.show("Import from Server", "This action will import all photos and albums which are located in <b>'uploads/import/'</b> of your Lychee installation.", buttons);
|
||||
|
||||
},
|
||||
|
||||
|
@ -8,47 +8,52 @@
|
||||
visible = {
|
||||
|
||||
albums: function() {
|
||||
if ($("#tools_albums").css("display")==="block") return true;
|
||||
if ($('#tools_albums').css('display')==='block') return true;
|
||||
else return false;
|
||||
},
|
||||
|
||||
album: function() {
|
||||
if ($("#tools_album").css("display")==="block") return true;
|
||||
if ($('#tools_album').css('display')==='block') return true;
|
||||
else return false;
|
||||
},
|
||||
|
||||
photo: function() {
|
||||
if ($("#imageview.fadeIn").length>0) return true;
|
||||
if ($('#imageview.fadeIn').length>0) return true;
|
||||
else return false;
|
||||
},
|
||||
|
||||
search: function() {
|
||||
if (search.code!==null&&search.code!=='') return true;
|
||||
else return false;
|
||||
},
|
||||
|
||||
infobox: function() {
|
||||
if ($("#infobox.active").length>0) return true;
|
||||
if ($('#infobox.active').length>0) return true;
|
||||
else return false;
|
||||
},
|
||||
|
||||
controls: function() {
|
||||
if (lychee.loadingBar.css("opacity")<1) return false;
|
||||
if (lychee.loadingBar.css('opacity')<1) return false;
|
||||
else return true;
|
||||
},
|
||||
|
||||
message: function() {
|
||||
if ($(".message").length>0) return true;
|
||||
if ($('.message').length>0) return true;
|
||||
else return false;
|
||||
},
|
||||
|
||||
signin: function() {
|
||||
if ($(".message .sign_in").length>0) return true;
|
||||
if ($('.message .sign_in').length>0) return true;
|
||||
else return false;
|
||||
},
|
||||
|
||||
contextMenu: function() {
|
||||
if ($(".contextmenu").length>0) return true;
|
||||
if ($('.contextmenu').length>0) return true;
|
||||
else return false;
|
||||
},
|
||||
|
||||
multiselect: function() {
|
||||
if ($("#multiselect").length>0) return true;
|
||||
if ($('#multiselect').length>0) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
### Import from server
|
||||
|
||||
To import photos from your server (photos you have uploaded via FTP to your server), sign in and click the add-icon on the top right. Then choose 'Import from Server'.
|
||||
|
||||
### Upload and share single photos
|
||||
|
||||
You can upload photos directly with every FTP client into Lychee. This feature helps you to share single images quickly with others.
|
||||
|
||||
1. Upload an image to `uploads/import/`
|
||||
2. Navigate your browser to the place where Lychee is located (e.g. `http://example.com/view.php?p=filename.png`). `filename.png` must be replaced with the filename of your uploaded file.
|
||||
3. Share the link.
|
||||
|
||||
Lychee will import the file as a public image, delete the original (unused) file and display it in the browser. [Sample FTP configuration »](http://l.electerious.com/view.php?p=13657692738813)
|
155
php/access/admin.php
Normal file
155
php/access/admin.php
Normal file
@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @name Admin Access
|
||||
* @author Tobias Reich
|
||||
* @copyright 2014 by Tobias Reich
|
||||
*/
|
||||
|
||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||
if (!defined('LYCHEE_ACCESS_ADMIN')) exit('Error: You are not allowed to access this area!');
|
||||
|
||||
switch ($_POST['function']) {
|
||||
|
||||
// Album Functions
|
||||
|
||||
case 'getAlbums': echo json_encode(getAlbums(false));
|
||||
break;
|
||||
|
||||
case 'getAlbum': if (isset($_POST['albumID']))
|
||||
echo json_encode(getAlbum($_POST['albumID']));
|
||||
break;
|
||||
|
||||
case 'addAlbum': if (isset($_POST['title']))
|
||||
echo addAlbum($_POST['title']);
|
||||
break;
|
||||
|
||||
case 'setAlbumTitle': if (isset($_POST['albumIDs'])&&isset($_POST['title']))
|
||||
echo setAlbumTitle($_POST['albumIDs'], $_POST['title']);
|
||||
break;
|
||||
|
||||
case 'setAlbumDescription': if (isset($_POST['albumID'])&&isset($_POST['description']))
|
||||
echo setAlbumDescription($_POST['albumID'], $_POST['description']);
|
||||
break;
|
||||
|
||||
case 'setAlbumPublic': if (isset($_POST['albumID']))
|
||||
if (!isset($_POST['password'])) $_POST['password'] = '';
|
||||
echo setAlbumPublic($_POST['albumID'], $_POST['password']);
|
||||
break;
|
||||
|
||||
case 'setAlbumPassword': if (isset($_POST['albumID'])&&isset($_POST['password']))
|
||||
echo setAlbumPassword($_POST['albumID'], $_POST['password']);
|
||||
break;
|
||||
|
||||
case 'deleteAlbum': if (isset($_POST['albumIDs']))
|
||||
echo deleteAlbum($_POST['albumIDs']);
|
||||
break;
|
||||
|
||||
// Photo Functions
|
||||
|
||||
case 'getPhoto': if (isset($_POST['photoID'])&&isset($_POST['albumID']))
|
||||
echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
|
||||
break;
|
||||
|
||||
case 'deletePhoto': if (isset($_POST['photoIDs']))
|
||||
echo deletePhoto($_POST['photoIDs']);
|
||||
break;
|
||||
|
||||
case 'setPhotoAlbum': if (isset($_POST['photoIDs'])&&isset($_POST['albumID']))
|
||||
echo setPhotoAlbum($_POST['photoIDs'], $_POST['albumID']);
|
||||
break;
|
||||
|
||||
case 'setPhotoTitle': if (isset($_POST['photoIDs'])&&isset($_POST['title']))
|
||||
echo setPhotoTitle($_POST['photoIDs'], $_POST['title']);
|
||||
break;
|
||||
|
||||
case 'setPhotoStar': if (isset($_POST['photoIDs']))
|
||||
echo setPhotoStar($_POST['photoIDs']);
|
||||
break;
|
||||
|
||||
case 'setPhotoPublic': if (isset($_POST['photoID'])&&isset($_POST['url']))
|
||||
echo setPhotoPublic($_POST['photoID'], $_POST['url']);
|
||||
break;
|
||||
|
||||
case 'setPhotoDescription': if (isset($_POST['photoID'])&&isset($_POST['description']))
|
||||
echo setPhotoDescription($_POST['photoID'], $_POST['description']);
|
||||
break;
|
||||
|
||||
case 'setPhotoTags': if (isset($_POST['photoIDs'])&&isset($_POST['tags']))
|
||||
echo setPhotoTags($_POST['photoIDs'], $_POST['tags']);
|
||||
break;
|
||||
|
||||
// Add Functions
|
||||
|
||||
case 'upload': if (isset($_FILES)&&isset($_POST['albumID']))
|
||||
echo upload($_FILES, $_POST['albumID']);
|
||||
break;
|
||||
|
||||
case 'importUrl': if (isset($_POST['url'])&&isset($_POST['albumID']))
|
||||
echo importUrl($_POST['url'], $_POST['albumID']);
|
||||
break;
|
||||
|
||||
case 'importServer': if (isset($_POST['albumID']))
|
||||
echo importServer($_POST['albumID']);
|
||||
break;
|
||||
|
||||
// Search Function
|
||||
|
||||
case 'search': if (isset($_POST['term']))
|
||||
echo json_encode(search($_POST['term']));
|
||||
break;
|
||||
|
||||
// Session Function
|
||||
|
||||
case 'init': echo json_encode(init('admin'));
|
||||
break;
|
||||
|
||||
case 'login': if (isset($_POST['user'])&&isset($_POST['password']))
|
||||
echo login($_POST['user'], $_POST['password']);
|
||||
break;
|
||||
|
||||
case 'logout': logout();
|
||||
break;
|
||||
|
||||
// Settings
|
||||
|
||||
case 'setLogin': if (isset($_POST['username'])&&isset($_POST['password']))
|
||||
if (!isset($_POST['oldPassword'])) $_POST['oldPassword'] = '';
|
||||
echo setLogin($_POST['oldPassword'], $_POST['username'], $_POST['password']);
|
||||
break;
|
||||
|
||||
case 'setSorting': if (isset($_POST['type'])&&isset($_POST['order']))
|
||||
echo setSorting($_POST['type'], $_POST['order']);
|
||||
break;
|
||||
|
||||
// Miscellaneous
|
||||
|
||||
case 'update': echo update();
|
||||
|
||||
default: switch ($_GET['function']) {
|
||||
|
||||
case 'getFeed': if (isset($_GET['albumID']))
|
||||
echo getFeed($_GET['albumID']);
|
||||
break;
|
||||
|
||||
case 'getAlbumArchive': if (isset($_GET['albumID']))
|
||||
getAlbumArchive($_GET['albumID']);
|
||||
break;
|
||||
|
||||
case 'getPhotoArchive': if (isset($_GET['photoID']))
|
||||
getPhotoArchive($_GET['photoID']);
|
||||
break;
|
||||
|
||||
case 'update': echo update();
|
||||
break;
|
||||
|
||||
default: exit('Error: Function not found! Please check the spelling of the called function.');
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
?>
|
126
php/access/guest.php
Normal file
126
php/access/guest.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @name Guest Access (Public Mode)
|
||||
* @author Tobias Reich
|
||||
* @copyright 2014 by Tobias Reich
|
||||
*/
|
||||
|
||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||
if (!defined('LYCHEE_ACCESS_GUEST')) exit('Error: You are not allowed to access this area!');
|
||||
|
||||
switch ($_POST['function']) {
|
||||
|
||||
// Album Functions
|
||||
|
||||
case 'getAlbums': echo json_encode(getAlbums(true));
|
||||
break;
|
||||
|
||||
case 'getAlbum': if (isset($_POST['albumID'])&&isset($_POST['password'])) {
|
||||
if (isAlbumPublic($_POST['albumID'])) {
|
||||
// Album Public
|
||||
if (checkAlbumPassword($_POST['albumID'], $_POST['password']))
|
||||
echo json_encode(getAlbum($_POST['albumID']));
|
||||
else
|
||||
echo 'Warning: Wrong password!';
|
||||
} else {
|
||||
// Album Private
|
||||
echo 'Warning: Album private!';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'checkAlbumAccess':if (isset($_POST['albumID'])&&isset($_POST['password'])) {
|
||||
if (isAlbumPublic($_POST['albumID'])) {
|
||||
// Album Public
|
||||
if (checkAlbumPassword($_POST['albumID'], $_POST['password']))
|
||||
echo true;
|
||||
else
|
||||
echo false;
|
||||
} else {
|
||||
// Album Private
|
||||
echo false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Photo Functions
|
||||
|
||||
case 'getPhoto': if (isset($_POST['photoID'])&&isset($_POST['albumID'])&&isset($_POST['password'])) {
|
||||
if (isPhotoPublic($_POST['photoID'], $_POST['password']))
|
||||
echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
|
||||
else
|
||||
echo 'Warning: Wrong password!';
|
||||
}
|
||||
break;
|
||||
|
||||
// Session Functions
|
||||
|
||||
case 'init': echo json_encode(init('public'));
|
||||
break;
|
||||
|
||||
case 'login': if (isset($_POST['user'])&&isset($_POST['password']))
|
||||
echo login($_POST['user'], $_POST['password']);
|
||||
break;
|
||||
|
||||
// Miscellaneous
|
||||
|
||||
default: switch ($_GET['function']) {
|
||||
|
||||
case 'getFeed': if (isset($_GET['albumID'])&&isset($_GET['password'])) {
|
||||
|
||||
// Album Feed
|
||||
if (isAlbumPublic($_GET['albumID'])) {
|
||||
// Album Public
|
||||
if (checkAlbumPassword($_GET['albumID'], $_GET['password']))
|
||||
echo getFeed($_GET['albumID']);
|
||||
else
|
||||
exit('Warning: Wrong password!');
|
||||
} else {
|
||||
// Album Private
|
||||
exit('Warning: Album private!');
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'getAlbumArchive': if (isset($_GET['albumID'])&&isset($_GET['password'])) {
|
||||
|
||||
// Album Download
|
||||
if (isAlbumPublic($_GET['albumID'])) {
|
||||
// Album Public
|
||||
if (checkAlbumPassword($_GET['albumID'], $_GET['password']))
|
||||
getAlbumArchive($_GET['albumID']);
|
||||
else
|
||||
exit('Warning: Wrong password!');
|
||||
} else {
|
||||
// Album Private
|
||||
exit('Warning: Album private or not downloadable!');
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'getPhotoArchive': if (isset($_GET['photoID'])&&isset($_GET['password'])) {
|
||||
|
||||
// Photo Download
|
||||
if (isPhotoPublic($_GET['photoID'], $_GET['password']))
|
||||
// Photo Public
|
||||
getPhotoArchive($_GET['photoID']);
|
||||
else
|
||||
// Photo Private
|
||||
exit('Warning: Photo private or not downloadable!');
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default: exit('Error: Function not found! Please check the spelling of the called function.');
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
?>
|
23
php/access/installation.php
Normal file
23
php/access/installation.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @name Installation Access
|
||||
* @author Tobias Reich
|
||||
* @copyright 2014 by Tobias Reich
|
||||
*/
|
||||
|
||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||
if (!defined('LYCHEE_ACCESS_INSTALLATION')) exit('Error: You are not allowed to access this area!');
|
||||
|
||||
switch ($_POST['function']) {
|
||||
|
||||
case 'dbCreateConfig': if (isset($_POST['dbHost'])&&isset($_POST['dbUser'])&&isset($_POST['dbPassword'])&&isset($_POST['dbName']))
|
||||
echo dbCreateConfig($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName']);
|
||||
break;
|
||||
|
||||
default: echo 'Warning: No configuration!';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
?>
|
293
php/api.php
293
php/api.php
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* @name API
|
||||
* @author Tobias Reich
|
||||
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
||||
* @copyright 2014 by Tobias Reich
|
||||
*/
|
||||
|
||||
@ini_set('max_execution_time', '200');
|
||||
@ -16,305 +16,68 @@ if (!empty($_POST['function'])||!empty($_GET['function'])) {
|
||||
|
||||
session_start();
|
||||
define('LYCHEE', true);
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Load modules
|
||||
require('modules/album.php');
|
||||
require('modules/db.php');
|
||||
require('modules/misc.php');
|
||||
require('modules/photo.php');
|
||||
require('modules/session.php');
|
||||
require('modules/settings.php');
|
||||
require('modules/upload.php');
|
||||
require('modules/album.php');
|
||||
require('modules/photo.php');
|
||||
require('modules/tags.php');
|
||||
require('modules/misc.php');
|
||||
|
||||
|
||||
if (file_exists('../data/config.php')) require('../data/config.php');
|
||||
else {
|
||||
|
||||
/**
|
||||
* Installation Mode
|
||||
* Installation Access
|
||||
* Limited access to configure Lychee. Only available when the config.php file is missing.
|
||||
*/
|
||||
|
||||
switch ($_POST['function']) {
|
||||
|
||||
case 'dbCreateConfig': if (isset($_POST['dbHost'])&&isset($_POST['dbUser'])&&isset($_POST['dbPassword'])&&isset($_POST['dbName']))
|
||||
echo dbCreateConfig($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName']);
|
||||
break;
|
||||
|
||||
default: echo 'Warning: No configuration!';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
define('LYCHEE_ACCESS_INSTALLATION', true);
|
||||
require('access/installation.php');
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
// Connect to DB
|
||||
// Connect and get settings
|
||||
$database = dbConnect();
|
||||
|
||||
// Get Settings
|
||||
$settings = getSettings();
|
||||
|
||||
// Escape
|
||||
foreach(array_keys($_POST) as $key) $_POST[$key] = mysqli_real_escape_string($database, urldecode($_POST[$key]));
|
||||
foreach(array_keys($_GET) as $key) $_GET[$key] = mysqli_real_escape_string($database, urldecode($_GET[$key]));
|
||||
foreach(array_keys($_POST) as $key) $_POST[$key] = mysqli_real_escape_string($database, urldecode($_POST[$key]));
|
||||
foreach(array_keys($_GET) as $key) $_GET[$key] = mysqli_real_escape_string($database, urldecode($_GET[$key]));
|
||||
|
||||
// Validate parameters
|
||||
if (isset($_POST['albumIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['albumIDs'])!==1) exit('Error: Wrong parameter type for albumIDs!');
|
||||
if (isset($_POST['photoIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['photoIDs'])!==1) exit('Error: Wrong parameter type for photoIDs!');
|
||||
if (isset($_POST['albumID'])&&preg_match('/^[0-9sf]{1,}$/', $_POST['albumID'])!==1) exit('Error: Wrong parameter type for albumID!');
|
||||
if (isset($_POST['photoID'])&&preg_match('/^[0-9]{14}$/', $_POST['photoID'])!==1) exit('Error: Wrong parameter type for photoID!');
|
||||
if (isset($_POST['albumIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['albumIDs'])!==1) exit('Error: Wrong parameter type for albumIDs!');
|
||||
if (isset($_POST['photoIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['photoIDs'])!==1) exit('Error: Wrong parameter type for photoIDs!');
|
||||
if (isset($_POST['albumID'])&&preg_match('/^[0-9sf]{1,}$/', $_POST['albumID'])!==1) exit('Error: Wrong parameter type for albumID!');
|
||||
if (isset($_POST['photoID'])&&preg_match('/^[0-9]{14}$/', $_POST['photoID'])!==1) exit('Error: Wrong parameter type for photoID!');
|
||||
|
||||
// Fallback for switch statement
|
||||
if (!isset($_POST['function'])) $_POST['function'] = '';
|
||||
if (!isset($_GET['function'])) $_GET['function'] = '';
|
||||
|
||||
if (isset($_SESSION['login'])&&$_SESSION['login']==true) {
|
||||
|
||||
/**
|
||||
* Admin Mode
|
||||
* Admin Access
|
||||
* Full access to Lychee. Only with correct password/session.
|
||||
*/
|
||||
|
||||
switch ($_POST['function']) {
|
||||
|
||||
// Album Functions
|
||||
|
||||
case 'getAlbums': echo json_encode(getAlbums(false));
|
||||
break;
|
||||
|
||||
case 'getAlbum': if (isset($_POST['albumID']))
|
||||
echo json_encode(getAlbum($_POST['albumID']));
|
||||
break;
|
||||
|
||||
case 'addAlbum': if (isset($_POST['title']))
|
||||
echo addAlbum($_POST['title']);
|
||||
break;
|
||||
|
||||
case 'setAlbumTitle': if (isset($_POST['albumIDs'])&&isset($_POST['title']))
|
||||
echo setAlbumTitle($_POST['albumIDs'], $_POST['title']);
|
||||
break;
|
||||
|
||||
case 'setAlbumDescription': if (isset($_POST['albumID'])&&isset($_POST['description']))
|
||||
echo setAlbumDescription($_POST['albumID'], $_POST['description']);
|
||||
break;
|
||||
|
||||
case 'setAlbumPublic': if (isset($_POST['albumID']))
|
||||
if (!isset($_POST['password'])) $_POST['password'] = '';
|
||||
echo setAlbumPublic($_POST['albumID'], $_POST['password']);
|
||||
break;
|
||||
|
||||
case 'setAlbumPassword':if (isset($_POST['albumID'])&&isset($_POST['password']))
|
||||
echo setAlbumPassword($_POST['albumID'], $_POST['password']);
|
||||
break;
|
||||
|
||||
case 'deleteAlbum': if (isset($_POST['albumIDs']))
|
||||
echo deleteAlbum($_POST['albumIDs']);
|
||||
break;
|
||||
|
||||
// Photo Functions
|
||||
|
||||
case 'getPhoto': if (isset($_POST['photoID'])&&isset($_POST['albumID']))
|
||||
echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
|
||||
break;
|
||||
|
||||
case 'deletePhoto': if (isset($_POST['photoIDs']))
|
||||
echo deletePhoto($_POST['photoIDs']);
|
||||
break;
|
||||
|
||||
case 'setAlbum': if (isset($_POST['photoIDs'])&&isset($_POST['albumID']))
|
||||
echo setAlbum($_POST['photoIDs'], $_POST['albumID']);
|
||||
break;
|
||||
|
||||
case 'setPhotoTitle': if (isset($_POST['photoIDs'])&&isset($_POST['title']))
|
||||
echo setPhotoTitle($_POST['photoIDs'], $_POST['title']);
|
||||
break;
|
||||
|
||||
case 'setPhotoStar': if (isset($_POST['photoIDs']))
|
||||
echo setPhotoStar($_POST['photoIDs']);
|
||||
break;
|
||||
|
||||
case 'setPhotoPublic': if (isset($_POST['photoID'])&&isset($_POST['url']))
|
||||
echo setPhotoPublic($_POST['photoID'], $_POST['url']);
|
||||
break;
|
||||
|
||||
case 'setPhotoDescription': if (isset($_POST['photoID'])&&isset($_POST['description']))
|
||||
echo setPhotoDescription($_POST['photoID'], $_POST['description']);
|
||||
break;
|
||||
|
||||
// Add Functions
|
||||
|
||||
case 'upload': if (isset($_FILES)&&isset($_POST['albumID']))
|
||||
echo upload($_FILES, $_POST['albumID']);
|
||||
break;
|
||||
|
||||
case 'importUrl': if (isset($_POST['url'])&&isset($_POST['albumID']))
|
||||
echo importUrl($_POST['url'], $_POST['albumID']);
|
||||
break;
|
||||
|
||||
case 'importServer': if (isset($_POST['albumID']))
|
||||
echo importServer($_POST['albumID']);
|
||||
break;
|
||||
|
||||
// Search Function
|
||||
|
||||
case 'search': if (isset($_POST['term']))
|
||||
echo json_encode(search($_POST['term']));
|
||||
break;
|
||||
|
||||
// Tag Functions
|
||||
|
||||
case 'getTags': if (isset($_POST['photoID']))
|
||||
echo json_encode(getTags($_POST['photoID']));
|
||||
break;
|
||||
|
||||
case 'setTags': if (isset($_POST['photoIDs'])&&isset($_POST['tags']))
|
||||
echo setTags($_POST['photoIDs'], $_POST['tags']);
|
||||
break;
|
||||
|
||||
// Session Function
|
||||
|
||||
case 'init': echo json_encode(init('admin'));
|
||||
break;
|
||||
|
||||
case 'login': if (isset($_POST['user'])&&isset($_POST['password']))
|
||||
echo login($_POST['user'], $_POST['password']);
|
||||
break;
|
||||
|
||||
case 'logout': logout();
|
||||
break;
|
||||
|
||||
// Settings
|
||||
|
||||
case 'setLogin': if (isset($_POST['username'])&&isset($_POST['password']))
|
||||
if (!isset($_POST['oldPassword'])) $_POST['oldPassword'] = '';
|
||||
echo setLogin($_POST['oldPassword'], $_POST['username'], $_POST['password']);
|
||||
break;
|
||||
|
||||
case 'setSorting': if (isset($_POST['type'])&&isset($_POST['order']))
|
||||
echo setSorting($_POST['type'], $_POST['order']);
|
||||
break;
|
||||
|
||||
// Miscellaneous
|
||||
|
||||
case 'update': echo update();
|
||||
|
||||
default: if (isset($_GET['function'])&&$_GET['function']=='getAlbumArchive'&&isset($_GET['albumID']))
|
||||
|
||||
// Album Download
|
||||
getAlbumArchive($_GET['albumID']);
|
||||
|
||||
else if (isset($_GET['function'])&&$_GET['function']=='getPhotoArchive'&&isset($_GET['photoID']))
|
||||
|
||||
// Photo Download
|
||||
getPhotoArchive($_GET['photoID']);
|
||||
|
||||
else if (isset($_GET['function'])&&$_GET['function']=='update')
|
||||
|
||||
// Update Lychee
|
||||
echo update();
|
||||
|
||||
else
|
||||
|
||||
// Function unknown
|
||||
exit('Error: Function not found! Please check the spelling of the called function.');
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
define('LYCHEE_ACCESS_ADMIN', true);
|
||||
require('access/admin.php');
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Public Mode
|
||||
* Guest Access
|
||||
* Access to view all public folders and photos in Lychee.
|
||||
*/
|
||||
|
||||
switch ($_POST['function']) {
|
||||
|
||||
// Album Functions
|
||||
|
||||
case 'getAlbums': echo json_encode(getAlbums(true));
|
||||
break;
|
||||
|
||||
case 'getAlbum': if (isset($_POST['albumID'])&&isset($_POST['password'])) {
|
||||
if (isAlbumPublic($_POST['albumID'])) {
|
||||
// Album Public
|
||||
if (checkAlbumPassword($_POST['albumID'], $_POST['password']))
|
||||
echo json_encode(getAlbum($_POST['albumID']));
|
||||
else
|
||||
echo 'Warning: Wrong password!';
|
||||
} else {
|
||||
// Album Private
|
||||
echo 'Warning: Album private!';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'checkAlbumAccess':if (isset($_POST['albumID'])&&isset($_POST['password'])) {
|
||||
if (isAlbumPublic($_POST['albumID'])) {
|
||||
// Album Public
|
||||
if (checkAlbumPassword($_POST['albumID'], $_POST['password']))
|
||||
echo true;
|
||||
else
|
||||
echo false;
|
||||
} else {
|
||||
// Album Private
|
||||
echo false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Photo Functions
|
||||
|
||||
case 'getPhoto': if (isset($_POST['photoID'])&&isset($_POST['albumID'])&&isset($_POST['password'])) {
|
||||
if (isPhotoPublic($_POST['photoID'], $_POST['password']))
|
||||
echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
|
||||
else
|
||||
echo 'Warning: Wrong password!';
|
||||
}
|
||||
break;
|
||||
|
||||
// Session Functions
|
||||
|
||||
case 'init': echo json_encode(init('public'));
|
||||
break;
|
||||
|
||||
case 'login': if (isset($_POST['user'])&&isset($_POST['password']))
|
||||
echo login($_POST['user'], $_POST['password']);
|
||||
break;
|
||||
|
||||
// Miscellaneous
|
||||
|
||||
default: if (isset($_GET['function'])&&$_GET['function']=='getAlbumArchive'&&isset($_GET['albumID'])&&isset($_GET['password'])) {
|
||||
|
||||
// Album Download
|
||||
if (isAlbumPublic($_GET['albumID'])) {
|
||||
// Album Public
|
||||
if (checkAlbumPassword($_GET['albumID'], $_GET['password']))
|
||||
getAlbumArchive($_GET['albumID']);
|
||||
else
|
||||
exit('Warning: Wrong password!');
|
||||
} else {
|
||||
// Album Private
|
||||
exit('Warning: Album private or not downloadable!');
|
||||
}
|
||||
|
||||
} else if (isset($_GET['function'])&&$_GET['function']=='getPhotoArchive'&&isset($_GET['photoID'])&&isset($_GET['password'])) {
|
||||
|
||||
// Photo Download
|
||||
if (isPhotoPublic($_GET['photoID'], $_GET['password']))
|
||||
// Photo Public
|
||||
getPhotoArchive($_GET['photoID']);
|
||||
else
|
||||
// Photo Private
|
||||
exit('Warning: Photo private or not downloadable!');
|
||||
|
||||
} else {
|
||||
|
||||
// Function unknown
|
||||
exit('Error: Function not found! Please check the spelling of the called function.');
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
define('LYCHEE_ACCESS_GUEST', true);
|
||||
require('access/guest.php');
|
||||
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,9 @@ function addAlbum($title) {
|
||||
global $database;
|
||||
|
||||
if (strlen($title)<1||strlen($title)>50) return false;
|
||||
$sysdate = date("d.m.Y");
|
||||
$result = $database->query("INSERT INTO lychee_albums (title, sysdate) VALUES ('$title', '$sysdate');");
|
||||
|
||||
$sysdate = date("d.m.Y");
|
||||
$result = $database->query("INSERT INTO lychee_albums (title, sysdate) VALUES ('$title', '$sysdate');");
|
||||
|
||||
if (!$result) return false;
|
||||
return $database->insert_id;
|
||||
@ -32,8 +33,10 @@ function getAlbums($public) {
|
||||
// Albums
|
||||
if ($public) $query = "SELECT * FROM lychee_albums WHERE public = 1";
|
||||
else $query = "SELECT * FROM lychee_albums";
|
||||
$result = $database->query($query) OR exit("Error: $result <br>".$database->error);
|
||||
$i = 0;
|
||||
|
||||
$result = $database->query($query) OR exit("Error: $result <br>".$database->error);
|
||||
$i = 0;
|
||||
|
||||
while($row = $result->fetch_object()) {
|
||||
|
||||
// Info
|
||||
@ -41,11 +44,14 @@ function getAlbums($public) {
|
||||
$return["content"][$row->id]['title'] = $row->title;
|
||||
$return["content"][$row->id]['public'] = $row->public;
|
||||
$return["content"][$row->id]['sysdate'] = date('F Y', strtotime($row->sysdate));
|
||||
|
||||
// Password
|
||||
if ($row->password=="") $return["content"][$row->id]['password'] = false;
|
||||
else $return["content"][$row->id]['password'] = true;
|
||||
|
||||
// Thumbs
|
||||
if (($public&&$row->password=="")||(!$public)) {
|
||||
|
||||
$albumID = $row->id;
|
||||
$result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = '$albumID' ORDER BY star DESC, " . substr($settings['sorting'], 9) . " LIMIT 0, 3");
|
||||
$k = 0;
|
||||
@ -56,6 +62,7 @@ function getAlbums($public) {
|
||||
if (!isset($return["content"][$row->id]["thumb0"])) $return["content"][$row->id]["thumb0"] = "";
|
||||
if (!isset($return["content"][$row->id]["thumb1"])) $return["content"][$row->id]["thumb1"] = "";
|
||||
if (!isset($return["content"][$row->id]["thumb2"])) $return["content"][$row->id]["thumb2"] = "";
|
||||
|
||||
}
|
||||
|
||||
// Album count
|
||||
@ -65,9 +72,6 @@ function getAlbums($public) {
|
||||
|
||||
$return["num"] = $i;
|
||||
|
||||
if ($i==0) $return["albums"] = false;
|
||||
else $return["albums"] = true;
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
@ -77,8 +81,8 @@ function getSmartInfo() {
|
||||
global $database, $settings;
|
||||
|
||||
// Unsorted
|
||||
$result = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = 0 " . $settings['sorting']);
|
||||
$i = 0;
|
||||
$result = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = 0 " . $settings['sorting']);
|
||||
$i = 0;
|
||||
while($row = $result->fetch_object()) {
|
||||
if ($i<3) $return["unsortedThumb$i"] = $row->thumbUrl;
|
||||
$i++;
|
||||
@ -86,8 +90,8 @@ function getSmartInfo() {
|
||||
$return['unsortedNum'] = $i;
|
||||
|
||||
// Public
|
||||
$result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE public = 1 " . $settings['sorting']);
|
||||
$i = 0;
|
||||
$result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE public = 1 " . $settings['sorting']);
|
||||
$i = 0;
|
||||
while($row2 = $result2->fetch_object()) {
|
||||
if ($i<3) $return["publicThumb$i"] = $row2->thumbUrl;
|
||||
$i++;
|
||||
@ -95,8 +99,8 @@ function getSmartInfo() {
|
||||
$return['publicNum'] = $i;
|
||||
|
||||
// Starred
|
||||
$result3 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE star = 1 " . $settings['sorting']);
|
||||
$i = 0;
|
||||
$result3 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE star = 1 " . $settings['sorting']);
|
||||
$i = 0;
|
||||
while($row3 = $result3->fetch_object()) {
|
||||
if ($i<3) $return["starredThumb$i"] = $row3->thumbUrl;
|
||||
$i++;
|
||||
@ -128,34 +132,33 @@ function getAlbum($albumID) {
|
||||
|
||||
default: $result = $database->query("SELECT * FROM lychee_albums WHERE id = '$albumID';");
|
||||
$row = $result->fetch_object();
|
||||
$return['title'] = $row->title;
|
||||
$return['description'] = $row->description;
|
||||
$return['sysdate'] = date('d M. Y', strtotime($row->sysdate));
|
||||
$return['public'] = $row->public;
|
||||
if ($row->password=="") $return['password'] = false;
|
||||
else $return['password'] = true;
|
||||
$return['title'] = $row->title;
|
||||
$return['description'] = $row->description;
|
||||
$return['sysdate'] = date('d M. Y', strtotime($row->sysdate));
|
||||
$return['public'] = $row->public;
|
||||
$return['password'] = ($row->password=="" ? false : true);
|
||||
$query = "SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE album = '$albumID' " . $settings['sorting'];
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Get photos
|
||||
$result = $database->query($query);
|
||||
$previousPhotoID = "";
|
||||
$i = 0;
|
||||
$result = $database->query($query);
|
||||
$previousPhotoID = "";
|
||||
$i = 0;
|
||||
while($row = $result->fetch_array()) {
|
||||
|
||||
$return['content'][$row['id']]['id'] = $row['id'];
|
||||
$return['content'][$row['id']]['title'] = $row['title'];
|
||||
$return['content'][$row['id']]['sysdate'] = date('d F Y', strtotime($row['sysdate']));
|
||||
$return['content'][$row['id']]['public'] = $row['public'];
|
||||
$return['content'][$row['id']]['star'] = $row['star'];
|
||||
$return['content'][$row['id']]['tags'] = $row['tags'];
|
||||
$return['content'][$row['id']]['album'] = $row['album'];
|
||||
$return['content'][$row['id']]['thumbUrl'] = $row['thumbUrl'];
|
||||
$return['content'][$row['id']]['id'] = $row['id'];
|
||||
$return['content'][$row['id']]['title'] = $row['title'];
|
||||
$return['content'][$row['id']]['sysdate'] = date('d F Y', strtotime($row['sysdate']));
|
||||
$return['content'][$row['id']]['public'] = $row['public'];
|
||||
$return['content'][$row['id']]['star'] = $row['star'];
|
||||
$return['content'][$row['id']]['tags'] = $row['tags'];
|
||||
$return['content'][$row['id']]['album'] = $row['album'];
|
||||
$return['content'][$row['id']]['thumbUrl'] = $row['thumbUrl'];
|
||||
|
||||
$return['content'][$row['id']]['previousPhoto'] = $previousPhotoID;
|
||||
$return['content'][$row['id']]['nextPhoto'] = "";
|
||||
$return['content'][$row['id']]['previousPhoto'] = $previousPhotoID;
|
||||
$return['content'][$row['id']]['nextPhoto'] = "";
|
||||
if ($previousPhotoID!="") $return['content'][$previousPhotoID]['nextPhoto'] = $row['id'];
|
||||
|
||||
$previousPhotoID = $row['id'];
|
||||
@ -171,20 +174,20 @@ function getAlbum($albumID) {
|
||||
} else {
|
||||
|
||||
// Enable next and previous for the first and last photo
|
||||
$lastElement = end($return['content']);
|
||||
$lastElementId = $lastElement['id'];
|
||||
$firstElement = reset($return['content']);
|
||||
$firstElementId = $firstElement['id'];
|
||||
$lastElement = end($return['content']);
|
||||
$lastElementId = $lastElement['id'];
|
||||
$firstElement = reset($return['content']);
|
||||
$firstElementId = $firstElement['id'];
|
||||
|
||||
if ($lastElementId!==$firstElementId) {
|
||||
$return['content'][$lastElementId]['nextPhoto'] = $firstElementId;
|
||||
$return['content'][$firstElementId]['previousPhoto'] = $lastElementId;
|
||||
$return['content'][$lastElementId]['nextPhoto'] = $firstElementId;
|
||||
$return['content'][$firstElementId]['previousPhoto'] = $lastElementId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$return['id'] = $albumID;
|
||||
$return['num'] = $i;
|
||||
$return['id'] = $albumID;
|
||||
$return['num'] = $i;
|
||||
|
||||
return $return;
|
||||
|
||||
@ -219,8 +222,8 @@ function deleteAlbum($albumIDs) {
|
||||
|
||||
global $database;
|
||||
|
||||
$error = false;
|
||||
$result = $database->query("SELECT id FROM lychee_photos WHERE album IN ($albumIDs);");
|
||||
$error = false;
|
||||
$result = $database->query("SELECT id FROM lychee_photos WHERE album IN ($albumIDs);");
|
||||
|
||||
// Delete photos
|
||||
while ($row = $result->fetch_object())
|
||||
@ -252,10 +255,10 @@ function getAlbumArchive($albumID) {
|
||||
$zipTitle = "Unsorted";
|
||||
}
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$result = $database->query($query);
|
||||
$files = array();
|
||||
$i=0;
|
||||
$zip = new ZipArchive();
|
||||
$result = $database->query($query);
|
||||
$files = array();
|
||||
$i = 0;
|
||||
|
||||
while($row = $result->fetch_object()) {
|
||||
$files[$i] = "../uploads/big/".$row->url;
|
||||
@ -293,15 +296,13 @@ function setAlbumPublic($albumID, $password) {
|
||||
|
||||
global $database;
|
||||
|
||||
$result = $database->query("SELECT public FROM lychee_albums WHERE id = '$albumID';");
|
||||
$row = $result->fetch_object();
|
||||
if ($row->public == 0){
|
||||
$public = 1;
|
||||
} else {
|
||||
$public = 0;
|
||||
}
|
||||
$result = $database->query("SELECT public FROM lychee_albums WHERE id = '$albumID';");
|
||||
$row = $result->fetch_object();
|
||||
$public = ($row->public===0 ? 1 : 0);
|
||||
|
||||
$result = $database->query("UPDATE lychee_albums SET public = '$public', password = NULL WHERE id = '$albumID';");
|
||||
if (!$result) return false;
|
||||
|
||||
if ($public==1) {
|
||||
$result = $database->query("UPDATE lychee_photos SET public = 0 WHERE album = '$albumID';");
|
||||
if (!$result) return false;
|
||||
@ -327,8 +328,8 @@ function checkAlbumPassword($albumID, $password) {
|
||||
|
||||
global $database;
|
||||
|
||||
$result = $database->query("SELECT password FROM lychee_albums WHERE id = '$albumID';");
|
||||
$row = $result->fetch_object();
|
||||
$result = $database->query("SELECT password FROM lychee_albums WHERE id = '$albumID';");
|
||||
$row = $result->fetch_object();
|
||||
|
||||
if ($row->password=="") return true;
|
||||
else if ($row->password==$password) return true;
|
||||
@ -340,8 +341,8 @@ function isAlbumPublic($albumID) {
|
||||
|
||||
global $database;
|
||||
|
||||
$result = $database->query("SELECT public FROM lychee_albums WHERE id = '$albumID';");
|
||||
$row = $result->fetch_object();
|
||||
$result = $database->query("SELECT public FROM lychee_albums WHERE id = '$albumID';");
|
||||
$row = $result->fetch_object();
|
||||
|
||||
if ($row->public==1) return true;
|
||||
return false;
|
||||
|
@ -32,8 +32,8 @@ function dbConnect() {
|
||||
|
||||
function dbCreateConfig($dbHost = 'localhost', $dbUser, $dbPassword, $dbName = 'lychee') {
|
||||
|
||||
$dbPassword = urldecode($dbPassword);
|
||||
$database = new mysqli($dbHost, $dbUser, $dbPassword);
|
||||
$dbPassword = urldecode($dbPassword);
|
||||
$database = new mysqli($dbHost, $dbUser, $dbPassword);
|
||||
|
||||
if ($database->connect_errno) return 'Warning: Connection failed!';
|
||||
else {
|
||||
@ -60,12 +60,9 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||
?>";
|
||||
|
||||
if (file_put_contents('../data/config.php', $config)===false) return 'Warning: Could not create file!';
|
||||
else {
|
||||
|
||||
$_SESSION['login'] = true;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
$_SESSION['login'] = true;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
@ -12,29 +12,31 @@ if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||
function openGraphHeader($photoID) {
|
||||
|
||||
global $database;
|
||||
|
||||
if (!is_numeric($photoID)) return false;
|
||||
$result = $database->query("SELECT * FROM lychee_photos WHERE id = '$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
|
||||
$parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
||||
$picture = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../uploads/big/".$row->url;
|
||||
|
||||
|
||||
$photoID = mysqli_real_escape_string($database, $photoID);
|
||||
if (!is_numeric($photoID)) return false;
|
||||
|
||||
$result = $database->query("SELECT * FROM lychee_photos WHERE id = '$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
|
||||
$parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
||||
$picture = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../uploads/big/".$row->url;
|
||||
|
||||
$return = '<!-- General Meta Data -->';
|
||||
$return .= '<meta name="title" content="'.$row->title.'" />';
|
||||
$return .= '<meta name="description" content="'.$row->description.' - via Lychee" />';
|
||||
$return .= '<link rel="image_src" type="image/jpeg" href="'.$picture.'" />';
|
||||
|
||||
|
||||
$return .= '<!-- Twitter Meta Data -->';
|
||||
$return .= '<meta name="twitter:card" content="photo">';
|
||||
$return .= '<meta name="twitter:title" content="'.$row->title.'">';
|
||||
$return .= '<meta name="twitter:image:src" content="'.$picture.'">';
|
||||
|
||||
|
||||
$return .= '<!-- Facebook Meta Data -->';
|
||||
$return .= '<meta property="og:title" content="'.$row->title.'">';
|
||||
$return .= '<meta property="og:image" content="'.$picture.'">';
|
||||
|
||||
return $return;
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
@ -42,31 +44,35 @@ function search($term) {
|
||||
|
||||
global $database, $settings;
|
||||
|
||||
$return["albums"] = "";
|
||||
$return['albums'] = '';
|
||||
|
||||
$result = $database->query("SELECT * FROM lychee_photos WHERE title like '%$term%' OR description like '%$term%' OR tags like '%$term%';");
|
||||
// Photos
|
||||
$result = $database->query("SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE title like '%$term%' OR description like '%$term%' OR tags like '%$term%';");
|
||||
while($row = $result->fetch_array()) {
|
||||
$return['photos'][$row['id']] = $row;
|
||||
$return['photos'][$row['id']]['sysdate'] = date('d F Y', strtotime($row['sysdate']));
|
||||
$return['photos'][$row['id']] = $row;
|
||||
$return['photos'][$row['id']]['sysdate'] = date('d F Y', strtotime($row['sysdate']));
|
||||
}
|
||||
|
||||
// Albums
|
||||
$result = $database->query("SELECT * FROM lychee_albums WHERE title like '%$term%' OR description like '%$term%';");
|
||||
$i=0;
|
||||
$i = 0;
|
||||
while($row = $result->fetch_object()) {
|
||||
|
||||
$return["albums"][$row->id]['id'] = $row->id;
|
||||
$return["albums"][$row->id]['title'] = $row->title;
|
||||
$return["albums"][$row->id]['public'] = $row->public;
|
||||
$return["albums"][$row->id]['sysdate'] = date('F Y', strtotime($row->sysdate));
|
||||
if ($row->password=="") $return["albums"][$row->id]['password'] = false;
|
||||
else $return["albums"][$row->id]['password'] = true;
|
||||
// Info
|
||||
$return['albums'][$row->id]['id'] = $row->id;
|
||||
$return['albums'][$row->id]['title'] = $row->title;
|
||||
$return['albums'][$row->id]['public'] = $row->public;
|
||||
$return['albums'][$row->id]['sysdate'] = date('F Y', strtotime($row->sysdate));
|
||||
$return['albums'][$row->id]['password'] = ($row->password=='' ? false : true);
|
||||
|
||||
$result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = '" . $row->id . "' " . $settings['sorting'] . " LIMIT 0, 3;");
|
||||
$k = 0;
|
||||
// Thumbs
|
||||
$result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = '" . $row->id . "' " . $settings['sorting'] . " LIMIT 0, 3;");
|
||||
$k = 0;
|
||||
while($row2 = $result2->fetch_object()){
|
||||
$return['albums'][$row->id]["thumb$k"] = $row2->thumbUrl;
|
||||
$k++;
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
}
|
||||
@ -79,13 +85,13 @@ function update() {
|
||||
|
||||
global $database;
|
||||
|
||||
if(!$database->query("SELECT `public` FROM `lychee_albums` LIMIT 1;")) $database->query("ALTER TABLE `lychee_albums` ADD `public` TINYINT( 1 ) NOT NULL DEFAULT '0'");
|
||||
if(!$database->query("SELECT `password` FROM `lychee_albums` LIMIT 1;")) $database->query("ALTER TABLE `lychee_albums` ADD `password` VARCHAR( 100 ) NULL DEFAULT ''");
|
||||
if(!$database->query("SELECT `description` FROM `lychee_albums` LIMIT 1;")) $database->query("ALTER TABLE `lychee_albums` ADD `description` VARCHAR( 1000 ) NULL DEFAULT ''");
|
||||
if($database->query("SELECT `password` FROM `lychee_albums` LIMIT 1;")) $database->query("ALTER TABLE `lychee_albums` CHANGE `password` `password` VARCHAR( 100 ) NULL DEFAULT ''");
|
||||
if(!$database->query("SELECT `public` FROM `lychee_albums` LIMIT 1;")) $database->query("ALTER TABLE `lychee_albums` ADD `public` TINYINT( 1 ) NOT NULL DEFAULT '0'");
|
||||
if(!$database->query("SELECT `password` FROM `lychee_albums` LIMIT 1;")) $database->query("ALTER TABLE `lychee_albums` ADD `password` VARCHAR( 100 ) NULL DEFAULT ''");
|
||||
if(!$database->query("SELECT `description` FROM `lychee_albums` LIMIT 1;")) $database->query("ALTER TABLE `lychee_albums` ADD `description` VARCHAR( 1000 ) NULL DEFAULT ''");
|
||||
if($database->query("SELECT `password` FROM `lychee_albums` LIMIT 1;")) $database->query("ALTER TABLE `lychee_albums` CHANGE `password` `password` VARCHAR( 100 ) NULL DEFAULT ''");
|
||||
|
||||
if($database->query("SELECT `description` FROM `lychee_photos` LIMIT 1;")) $database->query("ALTER TABLE `lychee_photos` CHANGE `description` `description` VARCHAR( 1000 ) NULL DEFAULT ''");
|
||||
if(!$database->query("SELECT `tags` FROM `lychee_photos` LIMIT 1;")) $database->query("ALTER TABLE `lychee_photos` ADD `tags` VARCHAR( 1000 ) NULL DEFAULT ''");
|
||||
if($database->query("SELECT `description` FROM `lychee_photos` LIMIT 1;")) $database->query("ALTER TABLE `lychee_photos` CHANGE `description` `description` VARCHAR( 1000 ) NULL DEFAULT ''");
|
||||
if(!$database->query("SELECT `tags` FROM `lychee_photos` LIMIT 1;")) $database->query("ALTER TABLE `lychee_photos` ADD `tags` VARCHAR( 1000 ) NULL DEFAULT ''");
|
||||
$database->query("UPDATE `lychee_photos` SET url = replace(url, 'uploads/big/', ''), thumbUrl = replace(thumbUrl, 'uploads/thumb/', '')");
|
||||
|
||||
$result = $database->query("SELECT `value` FROM `lychee_settings` WHERE `key` = 'importFilename' LIMIT 1;");
|
||||
|
@ -13,20 +13,7 @@ function getPhoto($photoID, $albumID) {
|
||||
|
||||
global $database;
|
||||
|
||||
if (!is_numeric($photoID)) {
|
||||
$result = $database->query("SELECT COUNT(*) AS quantity FROM lychee_photos WHERE import_name = '../uploads/import/$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
if ($row->quantity == 0) {
|
||||
importPhoto($photoID, 's');
|
||||
}
|
||||
if (is_file("../uploads/import/$photoID")) {
|
||||
importPhoto($photoID, 's');
|
||||
}
|
||||
$query = "SELECT * FROM lychee_photos WHERE import_name = '../uploads/import/$photoID' ORDER BY ID DESC;";
|
||||
} else {
|
||||
$query = "SELECT * FROM lychee_photos WHERE id = '$photoID';";
|
||||
}
|
||||
|
||||
$query = "SELECT * FROM lychee_photos WHERE id = '$photoID';";
|
||||
$result = $database->query($query);
|
||||
$return = $result->fetch_array();
|
||||
|
||||
@ -40,9 +27,9 @@ function getPhoto($photoID, $albumID) {
|
||||
|
||||
}
|
||||
|
||||
$return['original_album'] = $return['album'];
|
||||
$return['album'] = $albumID;
|
||||
$return['sysdate'] = date('d M. Y', strtotime($return['sysdate']));
|
||||
$return['original_album'] = $return['album'];
|
||||
$return['album'] = $albumID;
|
||||
$return['sysdate'] = date('d M. Y', strtotime($return['sysdate']));
|
||||
if (strlen($return['takedate'])>0) $return['takedate'] = date('d M. Y', strtotime($return['takedate']));
|
||||
|
||||
}
|
||||
@ -57,13 +44,9 @@ function setPhotoPublic($photoID, $url) {
|
||||
|
||||
global $database;
|
||||
|
||||
$result = $database->query("SELECT public FROM lychee_photos WHERE id = '$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
if ($row->public == 0){
|
||||
$public = 1;
|
||||
} else {
|
||||
$public = 0;
|
||||
}
|
||||
$result = $database->query("SELECT public FROM lychee_photos WHERE id = '$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
$public = ($row->public==0 ? 1 : 0);
|
||||
$result = $database->query("UPDATE lychee_photos SET public = '$public' WHERE id = '$photoID';");
|
||||
|
||||
if (!$result) return false;
|
||||
@ -75,14 +58,12 @@ function setPhotoStar($photoIDs) {
|
||||
|
||||
global $database;
|
||||
|
||||
$error = false;
|
||||
$result = $database->query("SELECT id, star FROM lychee_photos WHERE id IN ($photoIDs);");
|
||||
$error = false;
|
||||
$result = $database->query("SELECT id, star FROM lychee_photos WHERE id IN ($photoIDs);");
|
||||
|
||||
while ($row = $result->fetch_object()) {
|
||||
|
||||
if ($row->star==0) $star = 1;
|
||||
else $star = 0;
|
||||
|
||||
$star = ($row->star==0 ? 1 : 0);
|
||||
$star = $database->query("UPDATE lychee_photos SET star = '$star' WHERE id = '$row->id';");
|
||||
if (!$star) $error = true;
|
||||
|
||||
@ -93,7 +74,7 @@ function setPhotoStar($photoIDs) {
|
||||
|
||||
}
|
||||
|
||||
function setAlbum($photoIDs, $albumID) {
|
||||
function setPhotoAlbum($photoIDs, $albumID) {
|
||||
|
||||
global $database;
|
||||
|
||||
@ -122,6 +103,7 @@ function setPhotoDescription($photoID, $description) {
|
||||
|
||||
$description = htmlentities($description);
|
||||
if (strlen($description)>1000) return false;
|
||||
|
||||
$result = $database->query("UPDATE lychee_photos SET description = '$description' WHERE id = '$photoID';");
|
||||
|
||||
if (!$result) return false;
|
||||
@ -129,6 +111,23 @@ function setPhotoDescription($photoID, $description) {
|
||||
|
||||
}
|
||||
|
||||
function setPhotoTags($photoIDs, $tags) {
|
||||
|
||||
global $database;
|
||||
|
||||
// Parse tags
|
||||
$tags = preg_replace('/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/', ',', $tags);
|
||||
$tags = preg_replace('/,$|^,/', ',', $tags);
|
||||
|
||||
if (strlen($tags)>1000) return false;
|
||||
|
||||
$result = $database->query("UPDATE lychee_photos SET tags = '$tags' WHERE id IN ($photoIDs);");
|
||||
|
||||
if (!$result) return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function deletePhoto($photoIDs) {
|
||||
|
||||
global $database;
|
||||
@ -142,9 +141,9 @@ function deletePhoto($photoIDs) {
|
||||
$thumbUrl2x = $thumbUrl2x[0] . '@2x.' . $thumbUrl2x[1];
|
||||
|
||||
// Delete files
|
||||
if (!unlink('../uploads/big/' . $row->url)) return false;
|
||||
if (!unlink('../uploads/thumb/' . $row->thumbUrl)) return false;
|
||||
if (!unlink('../uploads/thumb/' . $thumbUrl2x)) return false;
|
||||
if (!unlink('../uploads/big/' . $row->url)) return false;
|
||||
if (!unlink('../uploads/thumb/' . $row->thumbUrl)) return false;
|
||||
if (!unlink('../uploads/thumb/' . $thumbUrl2x)) return false;
|
||||
|
||||
// Delete db entry
|
||||
$delete = $database->query("DELETE FROM lychee_photos WHERE id = $row->id;");
|
||||
@ -161,20 +160,18 @@ function isPhotoPublic($photoID, $password) {
|
||||
|
||||
global $database;
|
||||
|
||||
if (is_numeric($photoID)) {
|
||||
$query = "SELECT * FROM lychee_photos WHERE id = '$photoID';";
|
||||
} else {
|
||||
$query = "SELECT * FROM lychee_photos WHERE import_name = '../uploads/import/$photoID';";
|
||||
}
|
||||
$result = $database->query($query);
|
||||
$row = $result->fetch_object();
|
||||
$query = "SELECT * FROM lychee_photos WHERE id = '$photoID';";
|
||||
|
||||
$result = $database->query($query);
|
||||
$row = $result->fetch_object();
|
||||
|
||||
if (!is_numeric($photoID)&&!$row) return true;
|
||||
if ($row->public==1) return true;
|
||||
else {
|
||||
$cAP = checkAlbumPassword($row->album, $password);
|
||||
$iAP = isAlbumPublic($row->album);
|
||||
if ($iAP&&$cAP) return true;
|
||||
else return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -183,8 +180,8 @@ function getPhotoArchive($photoID) {
|
||||
|
||||
global $database;
|
||||
|
||||
$result = $database->query("SELECT * FROM lychee_photos WHERE id = '$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
$result = $database->query("SELECT * FROM lychee_photos WHERE id = '$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
|
||||
$extension = array_reverse(explode('.', $row->url));
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @name Album Module
|
||||
* @author Tobias Reich
|
||||
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
||||
*/
|
||||
|
||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||
|
||||
function getTags($photoID) {
|
||||
|
||||
global $database;
|
||||
|
||||
$result = $database->query("SELECT tags FROM lychee_photos WHERE id = '$photoID';");
|
||||
$return = $result->fetch_array();
|
||||
|
||||
if (!$result) return false;
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
function setTags($photoIDs, $tags) {
|
||||
|
||||
global $database;
|
||||
|
||||
// Parse tags
|
||||
$tags = preg_replace('/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/', ',', $tags);
|
||||
$tags = preg_replace('/,$|^,/', ',', $tags);
|
||||
|
||||
if (strlen($tags)>1000) return false;
|
||||
|
||||
$result = $database->query("UPDATE lychee_photos SET tags = '$tags' WHERE id IN ($photoIDs);");
|
||||
|
||||
if (!$result) return false;
|
||||
return true;
|
||||
|
||||
}
|
@ -16,19 +16,19 @@ function upload($files, $albumID) {
|
||||
switch($albumID) {
|
||||
// s for public (share)
|
||||
case 's':
|
||||
$public = 1;
|
||||
$star = 0;
|
||||
$albumID = 0;
|
||||
$public = 1;
|
||||
$star = 0;
|
||||
$albumID = 0;
|
||||
break;
|
||||
// f for starred (fav)
|
||||
case 'f':
|
||||
$star = 1;
|
||||
$public = 0;
|
||||
$albumID = 0;
|
||||
$star = 1;
|
||||
$public = 0;
|
||||
$albumID = 0;
|
||||
break;
|
||||
default:
|
||||
$star = 0;
|
||||
$public = 0;
|
||||
$star = 0;
|
||||
$public = 0;
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
@ -41,15 +41,15 @@ function upload($files, $albumID) {
|
||||
$id = str_replace('.', '', microtime(true));
|
||||
while(strlen($id)<14) $id .= 0;
|
||||
|
||||
$tmp_name = $file['tmp_name'];
|
||||
$extension = array_reverse(explode('.', $file['name']));
|
||||
$extension = $extension[0];
|
||||
$photo_name = md5($id) . ".$extension";
|
||||
$tmp_name = $file['tmp_name'];
|
||||
$extension = array_reverse(explode('.', $file['name']));
|
||||
$extension = $extension[0];
|
||||
$photo_name = md5($id) . ".$extension";
|
||||
|
||||
// Import if not uploaded via web
|
||||
if (!is_uploaded_file($tmp_name)) {
|
||||
if (copy($tmp_name, '../uploads/big/' . $photo_name)) {
|
||||
unlink($tmp_name);
|
||||
@unlink($tmp_name);
|
||||
$import_name = $tmp_name;
|
||||
}
|
||||
} else {
|
||||
@ -63,7 +63,7 @@ function upload($files, $albumID) {
|
||||
// Use title of file if IPTC title missing
|
||||
if ($info['title']===''&&
|
||||
$settings['importFilename']==='1')
|
||||
$info['title'] = mysqli_real_escape_string($database, substr(str_replace(".$extension", '', $file['name']), 0, 30));
|
||||
$info['title'] = mysqli_real_escape_string($database, substr(basename($file['name'], ".$extension"), 0, 30));
|
||||
|
||||
// Set orientation based on EXIF data
|
||||
if ($file['type']==='image/jpeg'&&isset($info['orientation'])&&isset($info['width'])&&isset($info['height'])) {
|
||||
@ -167,16 +167,16 @@ function getInfo($filename) {
|
||||
|
||||
global $database;
|
||||
|
||||
$url = '../uploads/big/' . $filename;
|
||||
$iptcArray = array();
|
||||
$info = getimagesize($url, $iptcArray);
|
||||
$url = '../uploads/big/' . $filename;
|
||||
$iptcArray = array();
|
||||
$info = getimagesize($url, $iptcArray);
|
||||
|
||||
// General information
|
||||
$return['type'] = $info['mime'];
|
||||
$return['width'] = $info[0];
|
||||
$return['height'] = $info[1];
|
||||
$return['date'] = date('d.m.Y', filectime($url));
|
||||
$return['time'] = date('H:i:s', filectime($url));
|
||||
$return['type'] = $info['mime'];
|
||||
$return['width'] = $info[0];
|
||||
$return['height'] = $info[1];
|
||||
$return['date'] = date('d.m.Y', filectime($url));
|
||||
$return['time'] = date('H:i:s', filectime($url));
|
||||
|
||||
// Size
|
||||
$size = filesize($url)/1024;
|
||||
@ -184,8 +184,8 @@ function getInfo($filename) {
|
||||
else $return['size'] = round($size, 1) . ' KB';
|
||||
|
||||
// IPTC Metadata Fallback
|
||||
$return['title'] = '';
|
||||
$return['description'] = '';
|
||||
$return['title'] = '';
|
||||
$return['description'] = '';
|
||||
|
||||
// IPTC Metadata
|
||||
if(isset($iptcArray['APP13'])) {
|
||||
@ -193,10 +193,10 @@ function getInfo($filename) {
|
||||
$iptcInfo = iptcparse($iptcArray['APP13']);
|
||||
if (is_array($iptcInfo)) {
|
||||
|
||||
$temp = $iptcInfo['2#105'][0];
|
||||
$temp = @$iptcInfo['2#105'][0];
|
||||
if (isset($temp)&&strlen($temp)>0) $return['title'] = $temp;
|
||||
|
||||
$temp = $iptcInfo['2#120'][0];
|
||||
$temp = @$iptcInfo['2#120'][0];
|
||||
if (isset($temp)&&strlen($temp)>0) $return['description'] = $temp;
|
||||
|
||||
}
|
||||
@ -204,46 +204,48 @@ function getInfo($filename) {
|
||||
}
|
||||
|
||||
// EXIF Metadata Fallback
|
||||
$return['orientation'] = '';
|
||||
$return['iso'] = '';
|
||||
$return['aperture'] = '';
|
||||
$return['make'] = '';
|
||||
$return['model'] = '';
|
||||
$return['shutter'] = '';
|
||||
$return['focal'] = '';
|
||||
$return['takeDate'] = '';
|
||||
$return['takeTime'] = '';
|
||||
$return['orientation'] = '';
|
||||
$return['iso'] = '';
|
||||
$return['aperture'] = '';
|
||||
$return['make'] = '';
|
||||
$return['model'] = '';
|
||||
$return['shutter'] = '';
|
||||
$return['focal'] = '';
|
||||
$return['takeDate'] = '';
|
||||
$return['takeTime'] = '';
|
||||
|
||||
// Read EXIF
|
||||
if ($info['mime']=='image/jpeg') $exif = exif_read_data($url, 'EXIF', 0);
|
||||
else $exif = false;
|
||||
|
||||
// EXIF Metadata
|
||||
if ($info['mime']=='image/jpeg'&&function_exists('exif_read_data')&&@exif_read_data($url, 'EXIF', 0)) {
|
||||
if ($exif!==false) {
|
||||
|
||||
$exif = exif_read_data($url, 'EXIF', 0);
|
||||
|
||||
$temp = $exif['Orientation'];
|
||||
$temp = @$exif['Orientation'];
|
||||
if (isset($temp)) $return['orientation'] = $temp;
|
||||
|
||||
$temp = $exif['ISOSpeedRatings'];
|
||||
$temp = @$exif['ISOSpeedRatings'];
|
||||
if (isset($temp)) $return['iso'] = $temp;
|
||||
|
||||
$temp = $exif['COMPUTED']['ApertureFNumber'];
|
||||
$temp = @$exif['COMPUTED']['ApertureFNumber'];
|
||||
if (isset($temp)) $return['aperture'] = $temp;
|
||||
|
||||
$temp = $exif['Make'];
|
||||
$temp = @$exif['Make'];
|
||||
if (isset($temp)) $return['make'] = $exif['Make'];
|
||||
|
||||
$temp = $exif['Model'];
|
||||
$temp = @$exif['Model'];
|
||||
if (isset($temp)) $return['model'] = $temp;
|
||||
|
||||
$temp = $exif['ExposureTime'];
|
||||
$temp = @$exif['ExposureTime'];
|
||||
if (isset($temp)) $return['shutter'] = $exif['ExposureTime'] . ' Sec.';
|
||||
|
||||
$temp = $exif['FocalLength'];
|
||||
$temp = @$exif['FocalLength'];
|
||||
if (isset($temp)) $return['focal'] = ($temp/1) . ' mm';
|
||||
|
||||
$temp = $exif['DateTimeOriginal'];
|
||||
$temp = @$exif['DateTimeOriginal'];
|
||||
if (isset($temp)) {
|
||||
$exifDate = explode(' ', $temp);
|
||||
$date = explode(':', $exifDate[0]);
|
||||
$exifDate = explode(' ', $temp);
|
||||
$date = explode(':', $exifDate[0]);
|
||||
$return['takeDate'] = $date[2].'.'.$date[1].'.'.$date[0];
|
||||
$return['takeTime'] = $exifDate[1];
|
||||
}
|
||||
@ -261,24 +263,24 @@ function createThumb($filename, $width = 200, $height = 200) {
|
||||
|
||||
global $settings;
|
||||
|
||||
$url = "../uploads/big/$filename";
|
||||
$info = getimagesize($url);
|
||||
$url = "../uploads/big/$filename";
|
||||
$info = getimagesize($url);
|
||||
|
||||
$photoName = explode(".", $filename);
|
||||
$newUrl = "../uploads/thumb/$photoName[0].jpeg";
|
||||
$newUrl2x = "../uploads/thumb/$photoName[0]@2x.jpeg";
|
||||
$photoName = explode(".", $filename);
|
||||
$newUrl = "../uploads/thumb/$photoName[0].jpeg";
|
||||
$newUrl2x = "../uploads/thumb/$photoName[0]@2x.jpeg";
|
||||
|
||||
// Set position and size
|
||||
$thumb = imagecreatetruecolor($width, $height);
|
||||
$thumb2x = imagecreatetruecolor($width*2, $height*2);
|
||||
if ($info[0]<$info[1]) {
|
||||
$newSize = $info[0];
|
||||
$startWidth = 0;
|
||||
$startHeight = $info[1]/2 - $info[0]/2;
|
||||
$newSize = $info[0];
|
||||
$startWidth = 0;
|
||||
$startHeight = $info[1]/2 - $info[0]/2;
|
||||
} else {
|
||||
$newSize = $info[1];
|
||||
$startWidth = $info[0]/2 - $info[1]/2;
|
||||
$startHeight = 0;
|
||||
$newSize = $info[1];
|
||||
$startWidth = $info[0]/2 - $info[1]/2;
|
||||
$startHeight = 0;
|
||||
}
|
||||
|
||||
// Fallback for older version
|
||||
@ -286,10 +288,10 @@ function createThumb($filename, $width = 200, $height = 200) {
|
||||
|
||||
// Create new image
|
||||
switch($info['mime']) {
|
||||
case 'image/jpeg': $sourceImg = imagecreatefromjpeg($url); break;
|
||||
case 'image/png': $sourceImg = imagecreatefrompng($url); break;
|
||||
case 'image/gif': $sourceImg = imagecreatefromgif($url); break;
|
||||
case 'image/webp': $sourceImg = imagecreatefromwebp($url); break;
|
||||
case 'image/jpeg': $sourceImg = imagecreatefromjpeg($url); break;
|
||||
case 'image/png': $sourceImg = imagecreatefrompng($url); break;
|
||||
case 'image/gif': $sourceImg = imagecreatefromgif($url); break;
|
||||
case 'image/webp': $sourceImg = imagecreatefromwebp($url); break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
@ -303,21 +305,19 @@ function createThumb($filename, $width = 200, $height = 200) {
|
||||
|
||||
}
|
||||
|
||||
function importPhoto($name, $albumID = 0) {
|
||||
function importPhoto($path, $albumID = 0) {
|
||||
|
||||
$tmp_name = "../uploads/import/$name";
|
||||
$info = getimagesize($tmp_name);
|
||||
$size = filesize($tmp_name);
|
||||
$nameFile = array(array());
|
||||
$nameFile[0]['name'] = $name;
|
||||
$nameFile[0]['type'] = $info['mime'];
|
||||
$nameFile[0]['tmp_name'] = $tmp_name;
|
||||
$nameFile[0]['error'] = 0;
|
||||
$nameFile[0]['size'] = $size;
|
||||
$info = getimagesize($path);
|
||||
$size = filesize($path);
|
||||
|
||||
$nameFile = array(array());
|
||||
$nameFile[0]['name'] = $path;
|
||||
$nameFile[0]['type'] = $info['mime'];
|
||||
$nameFile[0]['tmp_name'] = $path;
|
||||
$nameFile[0]['error'] = 0;
|
||||
$nameFile[0]['size'] = $size;
|
||||
|
||||
if (upload($nameFile, $albumID)) return true;
|
||||
|
||||
return false;
|
||||
return upload($nameFile, $albumID);
|
||||
|
||||
}
|
||||
|
||||
@ -338,6 +338,7 @@ function importUrl($url, $albumID = 0) {
|
||||
$pathinfo = pathinfo($key);
|
||||
$filename = $pathinfo['filename'].".".$pathinfo['extension'];
|
||||
$tmp_name = "../uploads/import/$filename";
|
||||
|
||||
copy($key, $tmp_name);
|
||||
|
||||
}
|
||||
@ -357,7 +358,9 @@ function importUrl($url, $albumID = 0) {
|
||||
$pathinfo = pathinfo($url);
|
||||
$filename = $pathinfo['filename'].".".$pathinfo['extension'];
|
||||
$tmp_name = "../uploads/import/$filename";
|
||||
|
||||
copy($url, $tmp_name);
|
||||
|
||||
return importPhoto($filename, $albumID);
|
||||
|
||||
}
|
||||
@ -368,23 +371,36 @@ function importUrl($url, $albumID = 0) {
|
||||
|
||||
}
|
||||
|
||||
function importServer($albumID = 0) {
|
||||
function importServer($albumID = 0, $path = '../uploads/import/') {
|
||||
|
||||
global $database;
|
||||
|
||||
$i = 0;
|
||||
$files = glob('../uploads/import/*');
|
||||
$files = glob($path . '*');
|
||||
$contains['photos'] = false;
|
||||
$contains['albums'] = false;
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
if (@getimagesize($file)) {
|
||||
if (!importPhoto(basename($file), $albumID)) return false;
|
||||
$i++;
|
||||
|
||||
// Photo
|
||||
if (!importPhoto($file, $albumID)) return false;
|
||||
$contains['photos'] = true;
|
||||
|
||||
} else if (is_dir($file)) {
|
||||
|
||||
$name = mysqli_real_escape_string($database, basename($file));
|
||||
$newAlbumID = addAlbum('[Import] ' . $name);
|
||||
|
||||
if ($newAlbumID!==false) importServer($newAlbumID, $file . '/');
|
||||
$contains['albums'] = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($i===0) return "Warning: Folder empty!";
|
||||
if ($contains['photos']===false&&$contains['albums']===false) return "Warning: Folder empty!";
|
||||
if ($contains['photos']===false&&$contains['albums']===true) return "Notice: Import only contains albums!";
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ Sign in and click the gear on the top left corner to change your settings. If yo
|
||||
|
||||
### FTP Upload
|
||||
|
||||
You can import photos from your server or upload photos directly with every FTP client into Lychee. [FTP Upload »](docs/md/FTP Upload.md)
|
||||
To import photos and albums located in `uploads/import/` (photos you have uploaded via FTP or else), sign in and click the add-icon on the top right. Then choose 'Import from Server'.
|
||||
|
||||
### Keyboard Shortcuts
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user