- Multi-Folder import from server
- Improved upload - Tidied up .php files - Removed import of single files via view.php?p=filename
This commit is contained in:
parent
753c14d85f
commit
88a5810e0c
@ -224,7 +224,7 @@ contextMenu = {
|
|||||||
|
|
||||||
lychee.api("getAlbums", function(data) {
|
lychee.api("getAlbums", function(data) {
|
||||||
|
|
||||||
if (!data.albums) {
|
if (data.num===0) {
|
||||||
items = [["New Album", 0, "album.add()"]];
|
items = [["New Album", 0, "album.add()"]];
|
||||||
} else {
|
} else {
|
||||||
$.each(data.content, function(index) {
|
$.each(data.content, function(index) {
|
||||||
|
@ -170,6 +170,7 @@ upload = {
|
|||||||
}],
|
}],
|
||||||
["Cancel", function() {}]
|
["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);
|
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.close();
|
||||||
upload.notify("Import complete");
|
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);
|
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);
|
else if (data!==true) lychee.error(null, params, data);
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -205,7 +211,8 @@ upload = {
|
|||||||
}],
|
}],
|
||||||
["Cancel", function() {}]
|
["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);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ function addAlbum($title) {
|
|||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
if (strlen($title)<1||strlen($title)>50) return false;
|
if (strlen($title)<1||strlen($title)>50) return false;
|
||||||
|
|
||||||
$sysdate = date("d.m.Y");
|
$sysdate = date("d.m.Y");
|
||||||
$result = $database->query("INSERT INTO lychee_albums (title, sysdate) VALUES ('$title', '$sysdate');");
|
$result = $database->query("INSERT INTO lychee_albums (title, sysdate) VALUES ('$title', '$sysdate');");
|
||||||
|
|
||||||
@ -32,8 +33,10 @@ function getAlbums($public) {
|
|||||||
// Albums
|
// Albums
|
||||||
if ($public) $query = "SELECT * FROM lychee_albums WHERE public = 1";
|
if ($public) $query = "SELECT * FROM lychee_albums WHERE public = 1";
|
||||||
else $query = "SELECT * FROM lychee_albums";
|
else $query = "SELECT * FROM lychee_albums";
|
||||||
|
|
||||||
$result = $database->query($query) OR exit("Error: $result <br>".$database->error);
|
$result = $database->query($query) OR exit("Error: $result <br>".$database->error);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while($row = $result->fetch_object()) {
|
while($row = $result->fetch_object()) {
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
@ -41,11 +44,14 @@ function getAlbums($public) {
|
|||||||
$return["content"][$row->id]['title'] = $row->title;
|
$return["content"][$row->id]['title'] = $row->title;
|
||||||
$return["content"][$row->id]['public'] = $row->public;
|
$return["content"][$row->id]['public'] = $row->public;
|
||||||
$return["content"][$row->id]['sysdate'] = date('F Y', strtotime($row->sysdate));
|
$return["content"][$row->id]['sysdate'] = date('F Y', strtotime($row->sysdate));
|
||||||
|
|
||||||
|
// Password
|
||||||
if ($row->password=="") $return["content"][$row->id]['password'] = false;
|
if ($row->password=="") $return["content"][$row->id]['password'] = false;
|
||||||
else $return["content"][$row->id]['password'] = true;
|
else $return["content"][$row->id]['password'] = true;
|
||||||
|
|
||||||
// Thumbs
|
// Thumbs
|
||||||
if (($public&&$row->password=="")||(!$public)) {
|
if (($public&&$row->password=="")||(!$public)) {
|
||||||
|
|
||||||
$albumID = $row->id;
|
$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");
|
$result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = '$albumID' ORDER BY star DESC, " . substr($settings['sorting'], 9) . " LIMIT 0, 3");
|
||||||
$k = 0;
|
$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]["thumb0"])) $return["content"][$row->id]["thumb0"] = "";
|
||||||
if (!isset($return["content"][$row->id]["thumb1"])) $return["content"][$row->id]["thumb1"] = "";
|
if (!isset($return["content"][$row->id]["thumb1"])) $return["content"][$row->id]["thumb1"] = "";
|
||||||
if (!isset($return["content"][$row->id]["thumb2"])) $return["content"][$row->id]["thumb2"] = "";
|
if (!isset($return["content"][$row->id]["thumb2"])) $return["content"][$row->id]["thumb2"] = "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Album count
|
// Album count
|
||||||
@ -65,9 +72,6 @@ function getAlbums($public) {
|
|||||||
|
|
||||||
$return["num"] = $i;
|
$return["num"] = $i;
|
||||||
|
|
||||||
if ($i==0) $return["albums"] = false;
|
|
||||||
else $return["albums"] = true;
|
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -132,8 +136,7 @@ function getAlbum($albumID) {
|
|||||||
$return['description'] = $row->description;
|
$return['description'] = $row->description;
|
||||||
$return['sysdate'] = date('d M. Y', strtotime($row->sysdate));
|
$return['sysdate'] = date('d M. Y', strtotime($row->sysdate));
|
||||||
$return['public'] = $row->public;
|
$return['public'] = $row->public;
|
||||||
if ($row->password=="") $return['password'] = false;
|
$return['password'] = ($row->password=="" ? false : true);
|
||||||
else $return['password'] = true;
|
|
||||||
$query = "SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE album = '$albumID' " . $settings['sorting'];
|
$query = "SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE album = '$albumID' " . $settings['sorting'];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -255,7 +258,7 @@ function getAlbumArchive($albumID) {
|
|||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
$result = $database->query($query);
|
$result = $database->query($query);
|
||||||
$files = array();
|
$files = array();
|
||||||
$i=0;
|
$i = 0;
|
||||||
|
|
||||||
while($row = $result->fetch_object()) {
|
while($row = $result->fetch_object()) {
|
||||||
$files[$i] = "../uploads/big/".$row->url;
|
$files[$i] = "../uploads/big/".$row->url;
|
||||||
@ -295,13 +298,11 @@ function setAlbumPublic($albumID, $password) {
|
|||||||
|
|
||||||
$result = $database->query("SELECT public FROM lychee_albums WHERE id = '$albumID';");
|
$result = $database->query("SELECT public FROM lychee_albums WHERE id = '$albumID';");
|
||||||
$row = $result->fetch_object();
|
$row = $result->fetch_object();
|
||||||
if ($row->public == 0){
|
$public = ($row->public===0 ? 1 : 0);
|
||||||
$public = 1;
|
|
||||||
} else {
|
|
||||||
$public = 0;
|
|
||||||
}
|
|
||||||
$result = $database->query("UPDATE lychee_albums SET public = '$public', password = NULL WHERE id = '$albumID';");
|
$result = $database->query("UPDATE lychee_albums SET public = '$public', password = NULL WHERE id = '$albumID';");
|
||||||
if (!$result) return false;
|
if (!$result) return false;
|
||||||
|
|
||||||
if ($public==1) {
|
if ($public==1) {
|
||||||
$result = $database->query("UPDATE lychee_photos SET public = 0 WHERE album = '$albumID';");
|
$result = $database->query("UPDATE lychee_photos SET public = 0 WHERE album = '$albumID';");
|
||||||
if (!$result) return false;
|
if (!$result) return false;
|
||||||
|
@ -60,15 +60,12 @@ 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!';
|
if (file_put_contents('../data/config.php', $config)===false) return 'Warning: Could not create file!';
|
||||||
else {
|
|
||||||
|
|
||||||
$_SESSION['login'] = true;
|
$_SESSION['login'] = true;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbCreate($dbName, $database) {
|
function dbCreate($dbName, $database) {
|
||||||
|
@ -13,7 +13,9 @@ function openGraphHeader($photoID) {
|
|||||||
|
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
|
$photoID = mysqli_real_escape_string($database, $photoID);
|
||||||
if (!is_numeric($photoID)) return false;
|
if (!is_numeric($photoID)) return false;
|
||||||
|
|
||||||
$result = $database->query("SELECT * FROM lychee_photos WHERE id = '$photoID';");
|
$result = $database->query("SELECT * FROM lychee_photos WHERE id = '$photoID';");
|
||||||
$row = $result->fetch_object();
|
$row = $result->fetch_object();
|
||||||
|
|
||||||
@ -42,31 +44,35 @@ function search($term) {
|
|||||||
|
|
||||||
global $database, $settings;
|
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()) {
|
while($row = $result->fetch_array()) {
|
||||||
$return['photos'][$row['id']] = $row;
|
$return['photos'][$row['id']] = $row;
|
||||||
$return['photos'][$row['id']]['sysdate'] = date('d F Y', strtotime($row['sysdate']));
|
$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%';");
|
$result = $database->query("SELECT * FROM lychee_albums WHERE title like '%$term%' OR description like '%$term%';");
|
||||||
$i=0;
|
$i = 0;
|
||||||
while($row = $result->fetch_object()) {
|
while($row = $result->fetch_object()) {
|
||||||
|
|
||||||
$return["albums"][$row->id]['id'] = $row->id;
|
// Info
|
||||||
$return["albums"][$row->id]['title'] = $row->title;
|
$return['albums'][$row->id]['id'] = $row->id;
|
||||||
$return["albums"][$row->id]['public'] = $row->public;
|
$return['albums'][$row->id]['title'] = $row->title;
|
||||||
$return["albums"][$row->id]['sysdate'] = date('F Y', strtotime($row->sysdate));
|
$return['albums'][$row->id]['public'] = $row->public;
|
||||||
if ($row->password=="") $return["albums"][$row->id]['password'] = false;
|
$return['albums'][$row->id]['sysdate'] = date('F Y', strtotime($row->sysdate));
|
||||||
else $return["albums"][$row->id]['password'] = true;
|
$return['albums'][$row->id]['password'] = ($row->password=='' ? false : true);
|
||||||
|
|
||||||
|
// Thumbs
|
||||||
$result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = '" . $row->id . "' " . $settings['sorting'] . " LIMIT 0, 3;");
|
$result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = '" . $row->id . "' " . $settings['sorting'] . " LIMIT 0, 3;");
|
||||||
$k = 0;
|
$k = 0;
|
||||||
while($row2 = $result2->fetch_object()){
|
while($row2 = $result2->fetch_object()){
|
||||||
$return['albums'][$row->id]["thumb$k"] = $row2->thumbUrl;
|
$return['albums'][$row->id]["thumb$k"] = $row2->thumbUrl;
|
||||||
$k++;
|
$k++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -95,17 +101,4 @@ function update() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pageURL() {
|
|
||||||
|
|
||||||
$pageURL = 'http';
|
|
||||||
if (isset($_SERVER["HTTPS"])&&$_SERVER["HTTPS"]==="on") $pageURL .= "s";
|
|
||||||
$pageURL .= "://";
|
|
||||||
|
|
||||||
if ($_SERVER["SERVER_PORT"]!="80") $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER['SCRIPT_NAME'];
|
|
||||||
else $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER['SCRIPT_NAME'];
|
|
||||||
|
|
||||||
return $pageURL;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -13,20 +13,7 @@ function getPhoto($photoID, $albumID) {
|
|||||||
|
|
||||||
global $database;
|
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);
|
$result = $database->query($query);
|
||||||
$return = $result->fetch_array();
|
$return = $result->fetch_array();
|
||||||
|
|
||||||
@ -59,11 +46,7 @@ function setPhotoPublic($photoID, $url) {
|
|||||||
|
|
||||||
$result = $database->query("SELECT public FROM lychee_photos WHERE id = '$photoID';");
|
$result = $database->query("SELECT public FROM lychee_photos WHERE id = '$photoID';");
|
||||||
$row = $result->fetch_object();
|
$row = $result->fetch_object();
|
||||||
if ($row->public == 0){
|
$public = ($row->public==0 ? 1 : 0);
|
||||||
$public = 1;
|
|
||||||
} else {
|
|
||||||
$public = 0;
|
|
||||||
}
|
|
||||||
$result = $database->query("UPDATE lychee_photos SET public = '$public' WHERE id = '$photoID';");
|
$result = $database->query("UPDATE lychee_photos SET public = '$public' WHERE id = '$photoID';");
|
||||||
|
|
||||||
if (!$result) return false;
|
if (!$result) return false;
|
||||||
@ -80,9 +63,7 @@ function setPhotoStar($photoIDs) {
|
|||||||
|
|
||||||
while ($row = $result->fetch_object()) {
|
while ($row = $result->fetch_object()) {
|
||||||
|
|
||||||
if ($row->star==0) $star = 1;
|
$star = ($row->star==0 ? 1 : 0);
|
||||||
else $star = 0;
|
|
||||||
|
|
||||||
$star = $database->query("UPDATE lychee_photos SET star = '$star' WHERE id = '$row->id';");
|
$star = $database->query("UPDATE lychee_photos SET star = '$star' WHERE id = '$row->id';");
|
||||||
if (!$star) $error = true;
|
if (!$star) $error = true;
|
||||||
|
|
||||||
@ -122,6 +103,7 @@ function setPhotoDescription($photoID, $description) {
|
|||||||
|
|
||||||
$description = htmlentities($description);
|
$description = htmlentities($description);
|
||||||
if (strlen($description)>1000) return false;
|
if (strlen($description)>1000) return false;
|
||||||
|
|
||||||
$result = $database->query("UPDATE lychee_photos SET description = '$description' WHERE id = '$photoID';");
|
$result = $database->query("UPDATE lychee_photos SET description = '$description' WHERE id = '$photoID';");
|
||||||
|
|
||||||
if (!$result) return false;
|
if (!$result) return false;
|
||||||
@ -178,20 +160,18 @@ function isPhotoPublic($photoID, $password) {
|
|||||||
|
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
if (is_numeric($photoID)) {
|
|
||||||
$query = "SELECT * FROM lychee_photos WHERE id = '$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);
|
$result = $database->query($query);
|
||||||
$row = $result->fetch_object();
|
$row = $result->fetch_object();
|
||||||
|
|
||||||
if (!is_numeric($photoID)&&!$row) return true;
|
if (!is_numeric($photoID)&&!$row) return true;
|
||||||
if ($row->public==1) return true;
|
if ($row->public==1) return true;
|
||||||
else {
|
else {
|
||||||
$cAP = checkAlbumPassword($row->album, $password);
|
$cAP = checkAlbumPassword($row->album, $password);
|
||||||
$iAP = isAlbumPublic($row->album);
|
$iAP = isAlbumPublic($row->album);
|
||||||
if ($iAP&&$cAP) return true;
|
if ($iAP&&$cAP) return true;
|
||||||
else return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ function upload($files, $albumID) {
|
|||||||
// Import if not uploaded via web
|
// Import if not uploaded via web
|
||||||
if (!is_uploaded_file($tmp_name)) {
|
if (!is_uploaded_file($tmp_name)) {
|
||||||
if (copy($tmp_name, '../uploads/big/' . $photo_name)) {
|
if (copy($tmp_name, '../uploads/big/' . $photo_name)) {
|
||||||
unlink($tmp_name);
|
@unlink($tmp_name);
|
||||||
$import_name = $tmp_name;
|
$import_name = $tmp_name;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -63,7 +63,7 @@ function upload($files, $albumID) {
|
|||||||
// Use title of file if IPTC title missing
|
// Use title of file if IPTC title missing
|
||||||
if ($info['title']===''&&
|
if ($info['title']===''&&
|
||||||
$settings['importFilename']==='1')
|
$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
|
// Set orientation based on EXIF data
|
||||||
if ($file['type']==='image/jpeg'&&isset($info['orientation'])&&isset($info['width'])&&isset($info['height'])) {
|
if ($file['type']==='image/jpeg'&&isset($info['orientation'])&&isset($info['width'])&&isset($info['height'])) {
|
||||||
@ -193,10 +193,10 @@ function getInfo($filename) {
|
|||||||
$iptcInfo = iptcparse($iptcArray['APP13']);
|
$iptcInfo = iptcparse($iptcArray['APP13']);
|
||||||
if (is_array($iptcInfo)) {
|
if (is_array($iptcInfo)) {
|
||||||
|
|
||||||
$temp = $iptcInfo['2#105'][0];
|
$temp = @$iptcInfo['2#105'][0];
|
||||||
if (isset($temp)&&strlen($temp)>0) $return['title'] = $temp;
|
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;
|
if (isset($temp)&&strlen($temp)>0) $return['description'] = $temp;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -214,33 +214,35 @@ function getInfo($filename) {
|
|||||||
$return['takeDate'] = '';
|
$return['takeDate'] = '';
|
||||||
$return['takeTime'] = '';
|
$return['takeTime'] = '';
|
||||||
|
|
||||||
|
// Read EXIF
|
||||||
|
if ($info['mime']=='image/jpeg') $exif = exif_read_data($url, 'EXIF', 0);
|
||||||
|
else $exif = false;
|
||||||
|
|
||||||
// EXIF Metadata
|
// 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;
|
if (isset($temp)) $return['orientation'] = $temp;
|
||||||
|
|
||||||
$temp = $exif['ISOSpeedRatings'];
|
$temp = @$exif['ISOSpeedRatings'];
|
||||||
if (isset($temp)) $return['iso'] = $temp;
|
if (isset($temp)) $return['iso'] = $temp;
|
||||||
|
|
||||||
$temp = $exif['COMPUTED']['ApertureFNumber'];
|
$temp = @$exif['COMPUTED']['ApertureFNumber'];
|
||||||
if (isset($temp)) $return['aperture'] = $temp;
|
if (isset($temp)) $return['aperture'] = $temp;
|
||||||
|
|
||||||
$temp = $exif['Make'];
|
$temp = @$exif['Make'];
|
||||||
if (isset($temp)) $return['make'] = $exif['Make'];
|
if (isset($temp)) $return['make'] = $exif['Make'];
|
||||||
|
|
||||||
$temp = $exif['Model'];
|
$temp = @$exif['Model'];
|
||||||
if (isset($temp)) $return['model'] = $temp;
|
if (isset($temp)) $return['model'] = $temp;
|
||||||
|
|
||||||
$temp = $exif['ExposureTime'];
|
$temp = @$exif['ExposureTime'];
|
||||||
if (isset($temp)) $return['shutter'] = $exif['ExposureTime'] . ' Sec.';
|
if (isset($temp)) $return['shutter'] = $exif['ExposureTime'] . ' Sec.';
|
||||||
|
|
||||||
$temp = $exif['FocalLength'];
|
$temp = @$exif['FocalLength'];
|
||||||
if (isset($temp)) $return['focal'] = ($temp/1) . ' mm';
|
if (isset($temp)) $return['focal'] = ($temp/1) . ' mm';
|
||||||
|
|
||||||
$temp = $exif['DateTimeOriginal'];
|
$temp = @$exif['DateTimeOriginal'];
|
||||||
if (isset($temp)) {
|
if (isset($temp)) {
|
||||||
$exifDate = explode(' ', $temp);
|
$exifDate = explode(' ', $temp);
|
||||||
$date = explode(':', $exifDate[0]);
|
$date = explode(':', $exifDate[0]);
|
||||||
@ -303,21 +305,19 @@ function createThumb($filename, $width = 200, $height = 200) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function importPhoto($name, $albumID = 0) {
|
function importPhoto($path, $albumID = 0) {
|
||||||
|
|
||||||
|
$info = getimagesize($path);
|
||||||
|
$size = filesize($path);
|
||||||
|
|
||||||
$tmp_name = "../uploads/import/$name";
|
|
||||||
$info = getimagesize($tmp_name);
|
|
||||||
$size = filesize($tmp_name);
|
|
||||||
$nameFile = array(array());
|
$nameFile = array(array());
|
||||||
$nameFile[0]['name'] = $name;
|
$nameFile[0]['name'] = $path;
|
||||||
$nameFile[0]['type'] = $info['mime'];
|
$nameFile[0]['type'] = $info['mime'];
|
||||||
$nameFile[0]['tmp_name'] = $tmp_name;
|
$nameFile[0]['tmp_name'] = $path;
|
||||||
$nameFile[0]['error'] = 0;
|
$nameFile[0]['error'] = 0;
|
||||||
$nameFile[0]['size'] = $size;
|
$nameFile[0]['size'] = $size;
|
||||||
|
|
||||||
if (upload($nameFile, $albumID)) return true;
|
return upload($nameFile, $albumID);
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,6 +338,7 @@ function importUrl($url, $albumID = 0) {
|
|||||||
$pathinfo = pathinfo($key);
|
$pathinfo = pathinfo($key);
|
||||||
$filename = $pathinfo['filename'].".".$pathinfo['extension'];
|
$filename = $pathinfo['filename'].".".$pathinfo['extension'];
|
||||||
$tmp_name = "../uploads/import/$filename";
|
$tmp_name = "../uploads/import/$filename";
|
||||||
|
|
||||||
copy($key, $tmp_name);
|
copy($key, $tmp_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -357,7 +358,9 @@ function importUrl($url, $albumID = 0) {
|
|||||||
$pathinfo = pathinfo($url);
|
$pathinfo = pathinfo($url);
|
||||||
$filename = $pathinfo['filename'].".".$pathinfo['extension'];
|
$filename = $pathinfo['filename'].".".$pathinfo['extension'];
|
||||||
$tmp_name = "../uploads/import/$filename";
|
$tmp_name = "../uploads/import/$filename";
|
||||||
|
|
||||||
copy($url, $tmp_name);
|
copy($url, $tmp_name);
|
||||||
|
|
||||||
return importPhoto($filename, $albumID);
|
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;
|
global $database;
|
||||||
|
|
||||||
$i = 0;
|
$files = glob($path . '*');
|
||||||
$files = glob('../uploads/import/*');
|
$contains['photos'] = false;
|
||||||
|
$contains['albums'] = false;
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
|
||||||
if (@getimagesize($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;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user