Trim whitespace and spaces to tabs
This commit is contained in:
parent
9b8f626836
commit
05543793b0
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Admin Access
|
* @name Admin Access
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Tobias Reich
|
* @copyright 2014 by Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Guest Access (Public Mode)
|
* @name Guest Access (Public Mode)
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Tobias Reich
|
* @copyright 2014 by Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Installation Access
|
* @name Installation Access
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Tobias Reich
|
* @copyright 2014 by Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name API
|
* @name API
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Tobias Reich
|
* @copyright 2014 by Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ini_set('max_execution_time', '200');
|
@ini_set('max_execution_time', '200');
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Album Module
|
* @name Album Module
|
||||||
* @author Philipp Maurer
|
* @author Philipp Maurer
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
@ -13,13 +13,13 @@ 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');");
|
||||||
|
|
||||||
if (!$result) return false;
|
if (!$result) return false;
|
||||||
return $database->insert_id;
|
return $database->insert_id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,52 +27,52 @@ function getAlbums($public) {
|
|||||||
|
|
||||||
global $database, $settings;
|
global $database, $settings;
|
||||||
|
|
||||||
// Smart Albums
|
// Smart Albums
|
||||||
if (!$public) $return = getSmartInfo();
|
if (!$public) $return = getSmartInfo();
|
||||||
|
|
||||||
// Albums
|
// Albums
|
||||||
if ($public) $query = "SELECT id, title, public, sysdate, password FROM lychee_albums WHERE public = 1";
|
if ($public) $query = "SELECT id, title, public, sysdate, password FROM lychee_albums WHERE public = 1";
|
||||||
else $query = "SELECT id, title, public, sysdate, password FROM lychee_albums";
|
else $query = "SELECT id, title, public, sysdate, password 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
|
||||||
$return["content"][$row->id]['id'] = $row->id;
|
$return["content"][$row->id]['id'] = $row->id;
|
||||||
$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
|
// 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;
|
||||||
while($row2 = $result2->fetch_object()){
|
while($row2 = $result2->fetch_object()){
|
||||||
$return["content"][$row->id]["thumb$k"] = $row2->thumbUrl;
|
$return["content"][$row->id]["thumb$k"] = $row2->thumbUrl;
|
||||||
$k++;
|
$k++;
|
||||||
}
|
}
|
||||||
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
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$return["num"] = $i;
|
$return["num"] = $i;
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,33 +81,33 @@ function getSmartInfo() {
|
|||||||
global $database, $settings;
|
global $database, $settings;
|
||||||
|
|
||||||
// Unsorted
|
// Unsorted
|
||||||
$result = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = 0 " . $settings['sorting']);
|
$result = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = 0 " . $settings['sorting']);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while($row = $result->fetch_object()) {
|
while($row = $result->fetch_object()) {
|
||||||
if ($i<3) $return["unsortedThumb$i"] = $row->thumbUrl;
|
if ($i<3) $return["unsortedThumb$i"] = $row->thumbUrl;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$return['unsortedNum'] = $i;
|
$return['unsortedNum'] = $i;
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
$result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE public = 1 " . $settings['sorting']);
|
$result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE public = 1 " . $settings['sorting']);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while($row2 = $result2->fetch_object()) {
|
while($row2 = $result2->fetch_object()) {
|
||||||
if ($i<3) $return["publicThumb$i"] = $row2->thumbUrl;
|
if ($i<3) $return["publicThumb$i"] = $row2->thumbUrl;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$return['publicNum'] = $i;
|
$return['publicNum'] = $i;
|
||||||
|
|
||||||
// Starred
|
// Starred
|
||||||
$result3 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE star = 1 " . $settings['sorting']);
|
$result3 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE star = 1 " . $settings['sorting']);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while($row3 = $result3->fetch_object()) {
|
while($row3 = $result3->fetch_object()) {
|
||||||
if ($i<3) $return["starredThumb$i"] = $row3->thumbUrl;
|
if ($i<3) $return["starredThumb$i"] = $row3->thumbUrl;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$return['starredNum'] = $i;
|
$return['starredNum'] = $i;
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,27 +118,27 @@ function getAlbum($albumID) {
|
|||||||
// Get album information
|
// Get album information
|
||||||
switch($albumID) {
|
switch($albumID) {
|
||||||
|
|
||||||
case "f": $return['public'] = false;
|
case "f": $return['public'] = false;
|
||||||
$query = "SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE star = 1 " . $settings['sorting'];
|
$query = "SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE star = 1 " . $settings['sorting'];
|
||||||
break;
|
|
||||||
|
|
||||||
case "s": $return['public'] = false;
|
|
||||||
$query = "SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE public = 1 " . $settings['sorting'];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "0": $return['public'] = false;
|
|
||||||
$query = "SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE album = 0 " . $settings['sorting'];
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: $result = $database->query("SELECT * FROM lychee_albums WHERE id = '$albumID';");
|
case "s": $return['public'] = false;
|
||||||
$row = $result->fetch_object();
|
$query = "SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE public = 1 " . $settings['sorting'];
|
||||||
$return['title'] = $row->title;
|
break;
|
||||||
$return['description'] = $row->description;
|
|
||||||
$return['sysdate'] = date('d M. Y', strtotime($row->sysdate));
|
case "0": $return['public'] = false;
|
||||||
$return['public'] = $row->public;
|
$query = "SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE album = 0 " . $settings['sorting'];
|
||||||
$return['password'] = ($row->password=="" ? false : true);
|
break;
|
||||||
$query = "SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE album = '$albumID' " . $settings['sorting'];
|
|
||||||
break;
|
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;
|
||||||
|
$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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,21 +148,21 @@ function getAlbum($albumID) {
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
while($row = $result->fetch_array()) {
|
while($row = $result->fetch_array()) {
|
||||||
|
|
||||||
$return['content'][$row['id']]['id'] = $row['id'];
|
$return['content'][$row['id']]['id'] = $row['id'];
|
||||||
$return['content'][$row['id']]['title'] = $row['title'];
|
$return['content'][$row['id']]['title'] = $row['title'];
|
||||||
$return['content'][$row['id']]['sysdate'] = date('d F Y', strtotime($row['sysdate']));
|
$return['content'][$row['id']]['sysdate'] = date('d F Y', strtotime($row['sysdate']));
|
||||||
$return['content'][$row['id']]['public'] = $row['public'];
|
$return['content'][$row['id']]['public'] = $row['public'];
|
||||||
$return['content'][$row['id']]['star'] = $row['star'];
|
$return['content'][$row['id']]['star'] = $row['star'];
|
||||||
$return['content'][$row['id']]['tags'] = $row['tags'];
|
$return['content'][$row['id']]['tags'] = $row['tags'];
|
||||||
$return['content'][$row['id']]['album'] = $row['album'];
|
$return['content'][$row['id']]['album'] = $row['album'];
|
||||||
$return['content'][$row['id']]['thumbUrl'] = $row['thumbUrl'];
|
$return['content'][$row['id']]['thumbUrl'] = $row['thumbUrl'];
|
||||||
|
|
||||||
$return['content'][$row['id']]['previousPhoto'] = $previousPhotoID;
|
$return['content'][$row['id']]['previousPhoto'] = $previousPhotoID;
|
||||||
$return['content'][$row['id']]['nextPhoto'] = "";
|
$return['content'][$row['id']]['nextPhoto'] = "";
|
||||||
if ($previousPhotoID!="") $return['content'][$previousPhotoID]['nextPhoto'] = $row['id'];
|
if ($previousPhotoID!="") $return['content'][$previousPhotoID]['nextPhoto'] = $row['id'];
|
||||||
|
|
||||||
$previousPhotoID = $row['id'];
|
$previousPhotoID = $row['id'];
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,11 +197,11 @@ function setAlbumTitle($albumIDs, $title) {
|
|||||||
|
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
if (strlen($title)<1||strlen($title)>50) return false;
|
if (strlen($title)<1||strlen($title)>50) return false;
|
||||||
$result = $database->query("UPDATE lychee_albums SET title = '$title' WHERE id IN ($albumIDs);");
|
$result = $database->query("UPDATE lychee_albums SET title = '$title' WHERE id IN ($albumIDs);");
|
||||||
|
|
||||||
if (!$result) return false;
|
if (!$result) return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,17 +242,17 @@ function getAlbumArchive($albumID) {
|
|||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
switch($albumID) {
|
switch($albumID) {
|
||||||
case 's':
|
case 's':
|
||||||
$query = "SELECT url FROM lychee_photos WHERE public = '1';";
|
$query = "SELECT url FROM lychee_photos WHERE public = '1';";
|
||||||
$zipTitle = "Public";
|
$zipTitle = "Public";
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
$query = "SELECT url FROM lychee_photos WHERE star = '1';";
|
$query = "SELECT url FROM lychee_photos WHERE star = '1';";
|
||||||
$zipTitle = "Starred";
|
$zipTitle = "Starred";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$query = "SELECT url FROM lychee_photos WHERE album = '$albumID';";
|
$query = "SELECT url FROM lychee_photos WHERE album = '$albumID';";
|
||||||
$zipTitle = "Unsorted";
|
$zipTitle = "Unsorted";
|
||||||
}
|
}
|
||||||
|
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
@ -261,8 +261,8 @@ function getAlbumArchive($albumID) {
|
|||||||
$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;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $database->query("SELECT title FROM lychee_albums WHERE id = '$albumID' LIMIT 1;");
|
$result = $database->query("SELECT title FROM lychee_albums WHERE id = '$albumID' LIMIT 1;");
|
||||||
@ -271,13 +271,13 @@ function getAlbumArchive($albumID) {
|
|||||||
$filename = "../data/$zipTitle.zip";
|
$filename = "../data/$zipTitle.zip";
|
||||||
|
|
||||||
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
|
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($files AS $zipFile) {
|
foreach($files AS $zipFile) {
|
||||||
$newFile = explode("/",$zipFile);
|
$newFile = explode("/",$zipFile);
|
||||||
$newFile = array_reverse($newFile);
|
$newFile = array_reverse($newFile);
|
||||||
$zip->addFile($zipFile, $zipTitle."/".$newFile[0]);
|
$zip->addFile($zipFile, $zipTitle."/".$newFile[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name DB Module
|
* @name DB Module
|
||||||
* @author Philipp Maurer
|
* @author Philipp Maurer
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
|
|
||||||
function dbConnect() {
|
function dbConnect() {
|
||||||
|
|
||||||
global $dbUser, $dbPassword, $dbHost, $dbName;
|
global $dbUser, $dbPassword, $dbHost, $dbName;
|
||||||
|
|
||||||
$database = new mysqli($dbHost, $dbUser, $dbPassword);
|
$database = new mysqli($dbHost, $dbUser, $dbPassword);
|
||||||
|
|
||||||
if ($database->connect_errno) exit('Error: ' . $database->connect_error);
|
if ($database->connect_errno) exit('Error: ' . $database->connect_error);
|
||||||
|
|
||||||
// Avoid sql injection on older MySQL versions
|
// Avoid sql injection on older MySQL versions
|
||||||
if ($database->server_version<50500) $database->set_charset('GBK');
|
if ($database->server_version<50500) $database->set_charset('GBK');
|
||||||
@ -26,7 +26,7 @@ function dbConnect() {
|
|||||||
if (!$database->query('SELECT * FROM lychee_photos, lychee_albums, lychee_settings LIMIT 0;'))
|
if (!$database->query('SELECT * FROM lychee_photos, lychee_albums, lychee_settings LIMIT 0;'))
|
||||||
if (!dbCreateTables($database)) exit('Error: Could not create tables!');
|
if (!dbCreateTables($database)) exit('Error: Could not create tables!');
|
||||||
|
|
||||||
return $database;
|
return $database;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,9 +41,9 @@ function dbCreateConfig($dbHost = 'localhost', $dbUser, $dbPassword, $dbName = '
|
|||||||
$config = "<?php
|
$config = "<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Config
|
* @name Config
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
@ -125,11 +125,11 @@ function dbCreateTables($database) {
|
|||||||
|
|
||||||
";
|
";
|
||||||
|
|
||||||
if (!$database->query($query)) return false;
|
if (!$database->query($query)) return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$database->query('SELECT * FROM lychee_photos LIMIT 0;')) {
|
if (!$database->query('SELECT * FROM lychee_photos LIMIT 0;')) {
|
||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
|
|
||||||
@ -163,11 +163,11 @@ function dbCreateTables($database) {
|
|||||||
|
|
||||||
";
|
";
|
||||||
|
|
||||||
if (!$database->query($query)) return false;
|
if (!$database->query($query)) return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,9 +175,9 @@ function dbClose() {
|
|||||||
|
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
if (!$database->close()) exit('Error: Closing the connection failed!');
|
if (!$database->close()) exit('Error: Closing the connection failed!');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Misc Module
|
* @name Misc Module
|
||||||
* @author Philipp Maurer
|
* @author Philipp Maurer
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
@ -22,10 +22,10 @@ function openGraphHeader($photoID) {
|
|||||||
$parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
$parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
||||||
$picture = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../uploads/big/".$row->url;
|
$picture = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../uploads/big/".$row->url;
|
||||||
|
|
||||||
$return = '<!-- General Meta Data -->';
|
$return = '<!-- General Meta Data -->';
|
||||||
$return .= '<meta name="title" content="'.$row->title.'" />';
|
$return .= '<meta name="title" content="'.$row->title.'" />';
|
||||||
$return .= '<meta name="description" content="'.$row->description.' - via Lychee" />';
|
$return .= '<meta name="description" content="'.$row->description.' - via Lychee" />';
|
||||||
$return .= '<link rel="image_src" type="image/jpeg" href="'.$picture.'" />';
|
$return .= '<link rel="image_src" type="image/jpeg" href="'.$picture.'" />';
|
||||||
|
|
||||||
$return .= '<!-- Twitter Meta Data -->';
|
$return .= '<!-- Twitter Meta Data -->';
|
||||||
$return .= '<meta name="twitter:card" content="photo">';
|
$return .= '<meta name="twitter:card" content="photo">';
|
||||||
@ -47,37 +47,37 @@ function search($term) {
|
|||||||
$return['albums'] = '';
|
$return['albums'] = '';
|
||||||
|
|
||||||
// Photos
|
// 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%';");
|
$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
|
// Albums
|
||||||
$result = $database->query("SELECT id, title, public, sysdate, password FROM lychee_albums WHERE title like '%$term%' OR description like '%$term%';");
|
$result = $database->query("SELECT id, title, public, sysdate, password 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()) {
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
$return['albums'][$row->id]['id'] = $row->id;
|
$return['albums'][$row->id]['id'] = $row->id;
|
||||||
$return['albums'][$row->id]['title'] = $row->title;
|
$return['albums'][$row->id]['title'] = $row->title;
|
||||||
$return['albums'][$row->id]['public'] = $row->public;
|
$return['albums'][$row->id]['public'] = $row->public;
|
||||||
$return['albums'][$row->id]['sysdate'] = date('F Y', strtotime($row->sysdate));
|
$return['albums'][$row->id]['sysdate'] = date('F Y', strtotime($row->sysdate));
|
||||||
$return['albums'][$row->id]['password'] = ($row->password=='' ? false : true);
|
$return['albums'][$row->id]['password'] = ($row->password=='' ? false : true);
|
||||||
|
|
||||||
// Thumbs
|
// 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++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,13 +85,13 @@ function update() {
|
|||||||
|
|
||||||
global $database;
|
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 `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 `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 `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 `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 `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 `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/', '')");
|
$database->query("UPDATE `lychee_photos` SET url = replace(url, 'uploads/big/', ''), thumbUrl = replace(thumbUrl, 'uploads/thumb/', '')");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Photo Module
|
* @name Photo Module
|
||||||
* @author Philipp Maurer
|
* @author Philipp Maurer
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
@ -14,29 +14,29 @@ function getPhoto($photoID, $albumID) {
|
|||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
$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();
|
||||||
|
|
||||||
if ($albumID!='false') {
|
if ($albumID!='false') {
|
||||||
|
|
||||||
if ($return['album']!=0) {
|
if ($return['album']!=0) {
|
||||||
|
|
||||||
$result = $database->query("SELECT public FROM lychee_albums WHERE id = '" . $return['album'] . "';");
|
$result = $database->query("SELECT public FROM lychee_albums WHERE id = '" . $return['album'] . "';");
|
||||||
$return_album = $result->fetch_array();
|
$return_album = $result->fetch_array();
|
||||||
if ($return_album['public']=="1") $return['public'] = "2";
|
if ($return_album['public']=="1") $return['public'] = "2";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$return['original_album'] = $return['album'];
|
$return['original_album'] = $return['album'];
|
||||||
$return['album'] = $albumID;
|
$return['album'] = $albumID;
|
||||||
$return['sysdate'] = date('d M. Y', strtotime($return['sysdate']));
|
$return['sysdate'] = date('d M. Y', strtotime($return['sysdate']));
|
||||||
if (strlen($return['takedate'])>0) $return['takedate'] = date('d M. Y', strtotime($return['takedate']));
|
if (strlen($return['takedate'])>0) $return['takedate'] = date('d M. Y', strtotime($return['takedate']));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($return['album_public']);
|
unset($return['album_public']);
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,13 +44,13 @@ function setPhotoPublic($photoID, $url) {
|
|||||||
|
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
$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();
|
||||||
$public = ($row->public==0 ? 1 : 0);
|
$public = ($row->public==0 ? 1 : 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;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,18 +59,18 @@ function setPhotoStar($photoIDs) {
|
|||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
$error = false;
|
$error = false;
|
||||||
$result = $database->query("SELECT id, star FROM lychee_photos WHERE id IN ($photoIDs);");
|
$result = $database->query("SELECT id, star FROM lychee_photos WHERE id IN ($photoIDs);");
|
||||||
|
|
||||||
while ($row = $result->fetch_object()) {
|
while ($row = $result->fetch_object()) {
|
||||||
|
|
||||||
$star = ($row->star==0 ? 1 : 0);
|
$star = ($row->star==0 ? 1 : 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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error) return false;
|
if ($error) return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,10 +78,10 @@ function setPhotoAlbum($photoIDs, $albumID) {
|
|||||||
|
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
$result = $database->query("UPDATE lychee_photos SET album = '$albumID' WHERE id IN ($photoIDs);");
|
$result = $database->query("UPDATE lychee_photos SET album = '$albumID' WHERE id IN ($photoIDs);");
|
||||||
|
|
||||||
if (!$result) return false;
|
if (!$result) return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +89,11 @@ function setPhotoTitle($photoIDs, $title) {
|
|||||||
|
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
if (strlen($title)>50) return false;
|
if (strlen($title)>50) return false;
|
||||||
$result = $database->query("UPDATE lychee_photos SET title = '$title' WHERE id IN ($photoIDs);");
|
$result = $database->query("UPDATE lychee_photos SET title = '$title' WHERE id IN ($photoIDs);");
|
||||||
|
|
||||||
if (!$result) return false;
|
if (!$result) return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,13 +101,13 @@ function setPhotoDescription($photoID, $description) {
|
|||||||
|
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
$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;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,16 +162,16 @@ function isPhotoPublic($photoID, $password) {
|
|||||||
|
|
||||||
$query = "SELECT public, album FROM lychee_photos WHERE id = '$photoID';";
|
$query = "SELECT public, album FROM lychee_photos WHERE id = '$photoID';";
|
||||||
|
|
||||||
$result = $database->query($query);
|
$result = $database->query($query);
|
||||||
$row = $result->fetch_object();
|
$row = $result->fetch_object();
|
||||||
|
|
||||||
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;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Session Module
|
* @name Session Module
|
||||||
* @author Philipp Maurer
|
* @author Philipp Maurer
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
@ -39,16 +39,16 @@ function login($username, $password) {
|
|||||||
global $database, $settings;
|
global $database, $settings;
|
||||||
|
|
||||||
// Check login
|
// Check login
|
||||||
if ($username===$settings['username']&&$password===$settings['password']) {
|
if ($username===$settings['username']&&$password===$settings['password']) {
|
||||||
$_SESSION['login'] = true;
|
$_SESSION['login'] = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No login
|
// No login
|
||||||
if ($settings['username']===''&&$settings['password']==='') {
|
if ($settings['username']===''&&$settings['password']==='') {
|
||||||
$_SESSION['login'] = true;
|
$_SESSION['login'] = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ function login($username, $password) {
|
|||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
|
|
||||||
session_destroy();
|
session_destroy();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Settings Module
|
* @name Settings Module
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Tobias Reich
|
* @copyright 2014 by Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
@ -15,7 +15,7 @@ function getSettings() {
|
|||||||
$result = $database->query('SELECT * FROM lychee_settings;');
|
$result = $database->query('SELECT * FROM lychee_settings;');
|
||||||
|
|
||||||
while($row = $result->fetch_object()) {
|
while($row = $result->fetch_object()) {
|
||||||
$return[$row->key] = $row->value;
|
$return[$row->key] = $row->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Upload Module
|
* @name Upload Module
|
||||||
* @author Philipp Maurer
|
* @author Philipp Maurer
|
||||||
* @author Tobias Reich
|
* @author Tobias Reich
|
||||||
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
* @copyright 2014 by Philipp Maurer, Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
@ -15,66 +15,66 @@ function upload($files, $albumID) {
|
|||||||
|
|
||||||
switch($albumID) {
|
switch($albumID) {
|
||||||
// s for public (share)
|
// s for public (share)
|
||||||
case 's':
|
case 's':
|
||||||
$public = 1;
|
$public = 1;
|
||||||
$star = 0;
|
$star = 0;
|
||||||
$albumID = 0;
|
$albumID = 0;
|
||||||
break;
|
break;
|
||||||
// f for starred (fav)
|
// f for starred (fav)
|
||||||
case 'f':
|
case 'f':
|
||||||
$star = 1;
|
$star = 1;
|
||||||
$public = 0;
|
$public = 0;
|
||||||
$albumID = 0;
|
$albumID = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$star = 0;
|
$star = 0;
|
||||||
$public = 0;
|
$public = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
|
||||||
if ($file['type']!=='image/jpeg'&&
|
if ($file['type']!=='image/jpeg'&&
|
||||||
$file['type']!=='image/png'&&
|
$file['type']!=='image/png'&&
|
||||||
$file['type']!=='image/gif')
|
$file['type']!=='image/gif')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$id = str_replace('.', '', microtime(true));
|
$id = str_replace('.', '', microtime(true));
|
||||||
while(strlen($id)<14) $id .= 0;
|
while(strlen($id)<14) $id .= 0;
|
||||||
|
|
||||||
$tmp_name = $file['tmp_name'];
|
$tmp_name = $file['tmp_name'];
|
||||||
$extension = array_reverse(explode('.', $file['name']));
|
$extension = array_reverse(explode('.', $file['name']));
|
||||||
$extension = $extension[0];
|
$extension = $extension[0];
|
||||||
$photo_name = md5($id) . ".$extension";
|
$photo_name = md5($id) . ".$extension";
|
||||||
|
|
||||||
// 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 {
|
||||||
move_uploaded_file($tmp_name, '../uploads/big/' . $photo_name);
|
move_uploaded_file($tmp_name, '../uploads/big/' . $photo_name);
|
||||||
$import_name = '';
|
$import_name = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read infos
|
// Read infos
|
||||||
$info = getInfo($photo_name);
|
$info = getInfo($photo_name);
|
||||||
|
|
||||||
// Use title of file if IPTC title missing
|
// Use title of file if IPTC title missing
|
||||||
if ($info['title']==='')
|
if ($info['title']==='')
|
||||||
$info['title'] = mysqli_real_escape_string($database, substr(basename($file['name'], ".$extension"), 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'])) {
|
||||||
|
|
||||||
if ($info['orientation']==3||$info['orientation']==6||$info['orientation']==8) {
|
if ($info['orientation']==3||$info['orientation']==6||$info['orientation']==8) {
|
||||||
|
|
||||||
$newWidth = $info['width'];
|
$newWidth = $info['width'];
|
||||||
$newHeight = $info['height'];
|
$newHeight = $info['height'];
|
||||||
|
|
||||||
$sourceImg = imagecreatefromjpeg("../uploads/big/$photo_name");
|
$sourceImg = imagecreatefromjpeg("../uploads/big/$photo_name");
|
||||||
|
|
||||||
switch($info['orientation']){
|
switch($info['orientation']){
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
// mirror
|
// mirror
|
||||||
@ -88,77 +88,77 @@ function upload($files, $albumID) {
|
|||||||
case 4:
|
case 4:
|
||||||
// rotate 180 and mirror
|
// rotate 180 and mirror
|
||||||
// not yet implemented
|
// not yet implemented
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
// rotate 90 and mirror
|
// rotate 90 and mirror
|
||||||
// not yet implemented
|
// not yet implemented
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
$sourceImg = imagerotate($sourceImg, -90, 0);
|
$sourceImg = imagerotate($sourceImg, -90, 0);
|
||||||
$newWidth = $info['height'];
|
$newWidth = $info['height'];
|
||||||
$newHeight = $info['width'];
|
$newHeight = $info['width'];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
// rotate -90 and mirror
|
// rotate -90 and mirror
|
||||||
// not yet implemented
|
// not yet implemented
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
$sourceImg = imagerotate($sourceImg, 90, 0);
|
$sourceImg = imagerotate($sourceImg, 90, 0);
|
||||||
$newWidth = $info['height'];
|
$newWidth = $info['height'];
|
||||||
$newHeight = $info['width'];
|
$newHeight = $info['width'];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$newSourceImg = imagecreatetruecolor($newWidth, $newHeight);
|
$newSourceImg = imagecreatetruecolor($newWidth, $newHeight);
|
||||||
|
|
||||||
imagecopyresampled($newSourceImg, $sourceImg, 0, 0, 0, 0, $newWidth, $newHeight, $newWidth, $newHeight);
|
imagecopyresampled($newSourceImg, $sourceImg, 0, 0, 0, 0, $newWidth, $newHeight, $newWidth, $newHeight);
|
||||||
imagejpeg($newSourceImg, "../uploads/big/$photo_name", 100);
|
imagejpeg($newSourceImg, "../uploads/big/$photo_name", 100);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Thumb
|
// Create Thumb
|
||||||
if (!createThumb($photo_name)) return false;
|
if (!createThumb($photo_name)) return false;
|
||||||
|
|
||||||
// Save to DB
|
// Save to DB
|
||||||
$query = "INSERT INTO lychee_photos (id, title, url, description, type, width, height, size, sysdate, systime, iso, aperture, make, model, shutter, focal, takedate, taketime, thumbUrl, album, public, star, import_name)
|
$query = "INSERT INTO lychee_photos (id, title, url, description, type, width, height, size, sysdate, systime, iso, aperture, make, model, shutter, focal, takedate, taketime, thumbUrl, album, public, star, import_name)
|
||||||
VALUES (
|
VALUES (
|
||||||
'" . $id . "',
|
'" . $id . "',
|
||||||
'" . $info['title'] . "',
|
'" . $info['title'] . "',
|
||||||
'" . $photo_name . "',
|
'" . $photo_name . "',
|
||||||
'" . $info['description'] . "',
|
'" . $info['description'] . "',
|
||||||
'" . $info['type'] . "',
|
'" . $info['type'] . "',
|
||||||
'" . $info['width'] . "',
|
'" . $info['width'] . "',
|
||||||
'" . $info['height'] . "',
|
'" . $info['height'] . "',
|
||||||
'" . $info['size'] . "',
|
'" . $info['size'] . "',
|
||||||
'" . $info['date'] . "',
|
'" . $info['date'] . "',
|
||||||
'" . $info['time'] . "',
|
'" . $info['time'] . "',
|
||||||
'" . $info['iso'] . "',
|
'" . $info['iso'] . "',
|
||||||
'" . $info['aperture'] . "',
|
'" . $info['aperture'] . "',
|
||||||
'" . $info['make'] . "',
|
'" . $info['make'] . "',
|
||||||
'" . $info['model'] . "',
|
'" . $info['model'] . "',
|
||||||
'" . $info['shutter'] . "',
|
'" . $info['shutter'] . "',
|
||||||
'" . $info['focal'] . "',
|
'" . $info['focal'] . "',
|
||||||
'" . $info['takeDate'] . "',
|
'" . $info['takeDate'] . "',
|
||||||
'" . $info['takeTime'] . "',
|
'" . $info['takeTime'] . "',
|
||||||
'" . md5($id) . ".jpeg',
|
'" . md5($id) . ".jpeg',
|
||||||
'" . $albumID . "',
|
'" . $albumID . "',
|
||||||
'" . $public . "',
|
'" . $public . "',
|
||||||
'" . $star . "',
|
'" . $star . "',
|
||||||
'" . $import_name . "');";
|
'" . $import_name . "');";
|
||||||
$result = $database->query($query);
|
$result = $database->query($query);
|
||||||
|
|
||||||
if (!$result) return false;
|
if (!$result) return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,43 +218,43 @@ function getInfo($filename) {
|
|||||||
else $exif = false;
|
else $exif = false;
|
||||||
|
|
||||||
// EXIF Metadata
|
// EXIF Metadata
|
||||||
if ($exif!==false) {
|
if ($exif!==false) {
|
||||||
|
|
||||||
$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]);
|
||||||
$return['takeDate'] = $date[2].'.'.$date[1].'.'.$date[0];
|
$return['takeDate'] = $date[2].'.'.$date[1].'.'.$date[0];
|
||||||
$return['takeTime'] = $exifDate[1];
|
$return['takeTime'] = $exifDate[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Security
|
// Security
|
||||||
foreach(array_keys($return) as $key) $return[$key] = mysqli_real_escape_string($database, $return[$key]);
|
foreach(array_keys($return) as $key) $return[$key] = mysqli_real_escape_string($database, $return[$key]);
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,45 +262,45 @@ function createThumb($filename, $width = 200, $height = 200) {
|
|||||||
|
|
||||||
global $settings;
|
global $settings;
|
||||||
|
|
||||||
$url = "../uploads/big/$filename";
|
$url = "../uploads/big/$filename";
|
||||||
$info = getimagesize($url);
|
$info = getimagesize($url);
|
||||||
|
|
||||||
$photoName = explode(".", $filename);
|
$photoName = explode(".", $filename);
|
||||||
$newUrl = "../uploads/thumb/$photoName[0].jpeg";
|
$newUrl = "../uploads/thumb/$photoName[0].jpeg";
|
||||||
$newUrl2x = "../uploads/thumb/$photoName[0]@2x.jpeg";
|
$newUrl2x = "../uploads/thumb/$photoName[0]@2x.jpeg";
|
||||||
|
|
||||||
// Set position and size
|
// Set position and size
|
||||||
$thumb = imagecreatetruecolor($width, $height);
|
$thumb = imagecreatetruecolor($width, $height);
|
||||||
$thumb2x = imagecreatetruecolor($width*2, $height*2);
|
$thumb2x = imagecreatetruecolor($width*2, $height*2);
|
||||||
if ($info[0]<$info[1]) {
|
if ($info[0]<$info[1]) {
|
||||||
$newSize = $info[0];
|
$newSize = $info[0];
|
||||||
$startWidth = 0;
|
$startWidth = 0;
|
||||||
$startHeight = $info[1]/2 - $info[0]/2;
|
$startHeight = $info[1]/2 - $info[0]/2;
|
||||||
} else {
|
} else {
|
||||||
$newSize = $info[1];
|
$newSize = $info[1];
|
||||||
$startWidth = $info[0]/2 - $info[1]/2;
|
$startWidth = $info[0]/2 - $info[1]/2;
|
||||||
$startHeight = 0;
|
$startHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback for older version
|
// Fallback for older version
|
||||||
if ($info['mime']==='image/webp'&&floatval(phpversion())<5.5) return false;
|
if ($info['mime']==='image/webp'&&floatval(phpversion())<5.5) return false;
|
||||||
|
|
||||||
// Create new image
|
// Create new image
|
||||||
switch($info['mime']) {
|
switch($info['mime']) {
|
||||||
case 'image/jpeg': $sourceImg = imagecreatefromjpeg($url); break;
|
case 'image/jpeg': $sourceImg = imagecreatefromjpeg($url); break;
|
||||||
case 'image/png': $sourceImg = imagecreatefrompng($url); break;
|
case 'image/png': $sourceImg = imagecreatefrompng($url); break;
|
||||||
case 'image/gif': $sourceImg = imagecreatefromgif($url); break;
|
case 'image/gif': $sourceImg = imagecreatefromgif($url); break;
|
||||||
case 'image/webp': $sourceImg = imagecreatefromwebp($url); break;
|
case 'image/webp': $sourceImg = imagecreatefromwebp($url); break;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
imagecopyresampled($thumb,$sourceImg,0,0,$startWidth,$startHeight,$width,$height,$newSize,$newSize);
|
imagecopyresampled($thumb,$sourceImg,0,0,$startWidth,$startHeight,$width,$height,$newSize,$newSize);
|
||||||
imagecopyresampled($thumb2x,$sourceImg,0,0,$startWidth,$startHeight,$width*2,$height*2,$newSize,$newSize);
|
imagecopyresampled($thumb2x,$sourceImg,0,0,$startWidth,$startHeight,$width*2,$height*2,$newSize,$newSize);
|
||||||
|
|
||||||
imagejpeg($thumb,$newUrl,$settings['thumbQuality']);
|
imagejpeg($thumb,$newUrl,$settings['thumbQuality']);
|
||||||
imagejpeg($thumb2x,$newUrl2x,$settings['thumbQuality']);
|
imagejpeg($thumb2x,$newUrl2x,$settings['thumbQuality']);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user