dcc51497c3
- FTP Sharing - New Upload & New Search - Performance and stuff under the hood - Desktop Notifications - Right-Click on photos and albums - Retina Thumbs - Improved Interface
86 lines
4.1 KiB
PHP
86 lines
4.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @name api.php
|
|
* @author Philipp Maurer
|
|
* @author Tobias Reich
|
|
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
|
*/
|
|
|
|
if(floatval(phpversion())<5.2) die("Please upgrade to PHP 5.2 or higher!");
|
|
|
|
if((isset($_POST["function"])&&$_POST["function"]!="")||(isset($_GET["function"])&&$_GET["function"]!="")) {
|
|
|
|
session_start();
|
|
define("LYCHEE", true);
|
|
|
|
include("array2json.php");
|
|
include("config.php");
|
|
include("functions.php");
|
|
|
|
// Security
|
|
if(isset($_POST["albumID"])&&($_POST["albumID"]==""||$_POST["albumID"]<0)) exit("Wrong parameter type for 'albumID'!");
|
|
if(isset($_POST["photoID"])&&$_POST["photoID"]=="") exit("Wrong parameter type for 'photoID'!");
|
|
|
|
if($_SESSION["login"]==true) {
|
|
|
|
//Connect to DB
|
|
$database = dbConnect();
|
|
|
|
// Album Functions
|
|
if($_POST["function"]=="getAlbums") echo array2json(getAlbums());
|
|
if($_POST["function"]=="getSmartInfo") echo array2json(getSmartInfo());
|
|
if($_POST["function"]=="addAlbum"&&isset($_POST["title"])) echo addAlbum($_POST["title"]);
|
|
if($_POST["function"]=="getAlbumInfo"&&isset($_POST["albumID"])) echo array2json(getAlbumInfo($_POST["albumID"]));
|
|
if($_POST["function"]=="setAlbumTitle"&&isset($_POST["albumID"])&&isset($_POST["title"])) echo setAlbumTitle($_POST["albumID"], $_POST["title"]);
|
|
if($_POST["function"]=="deleteAlbum"&&isset($_POST["albumID"])&&isset($_POST["delAll"])) echo deleteAlbum($_POST["albumID"], $_POST["delAll"]);
|
|
if($_GET["function"]=="getAlbumArchive"&&isset($_GET["albumID"])) getAlbumArchive($_GET["albumID"]);
|
|
|
|
// Photo Functions
|
|
if($_POST["function"]=="getPhotos"&&isset($_POST["albumID"])) echo array2json(getPhotos($_POST["albumID"]));
|
|
if($_POST["function"]=="getPhotoInfo"&&isset($_POST["photoID"])) echo array2json(getPhotoInfo($_POST["photoID"]));
|
|
if($_POST["function"]=="movePhoto"&&isset($_POST["photoID"])&&isset($_POST["albumID"])) echo movePhoto($_POST["photoID"], $_POST["albumID"]);
|
|
if($_POST["function"]=="deletePhoto"&&isset($_POST["photoID"])) echo deletePhoto($_POST["photoID"]);
|
|
if($_POST["function"]=="setPhotoTitle"&&isset($_POST["photoID"])&&isset($_POST["title"])) echo setPhotoTitle($_POST["photoID"], $_POST["title"]);
|
|
if($_POST["function"]=="setPhotoStar"&&isset($_POST["photoID"])) echo setPhotoStar($_POST["photoID"]);
|
|
if($_POST["function"]=="setPhotoPublic"&&isset($_POST["photoID"])&&isset($_POST["url"])) echo setPhotoPublic($_POST["photoID"], $_POST["url"]);
|
|
if($_POST["function"]=="setPhotoDescription"&&isset($_POST["photoID"])&&isset($_POST["description"])) echo setPhotoDescription($_POST["photoID"], $_POST["description"]);
|
|
if($_POST["function"]=="sharePhoto"&&isset($_POST["photoID"])&&isset($_POST["url"])) echo array2json(sharePhoto($_POST["photoID"], $_POST["url"]));
|
|
if($_POST["function"]=="previousPhoto"&&isset($_POST["photoID"])&&isset($_POST["albumID"])) echo array2json(previousPhoto($_POST["photoID"], $_POST["albumID"]));
|
|
if($_POST["function"]=="nextPhoto"&&isset($_POST["photoID"])&&isset($_POST["albumID"])) echo array2json(nextPhoto($_POST["photoID"], $_POST["albumID"]));
|
|
|
|
// Upload Function
|
|
if($_POST["function"]=="upload"&&isset($_FILES)&&isset($_POST["albumID"])) echo upload($_FILES, $_POST["albumID"]);
|
|
|
|
// Search Function
|
|
if($_POST["function"]=="search"&&isset($_POST["term"])) echo array2json(search($_POST["term"]));
|
|
|
|
// Sync Function
|
|
if($_POST["function"]=="syncFolder") echo syncFolder();
|
|
|
|
// Session Functions
|
|
if($_POST["function"]=="login") echo login($_POST['user'], $_POST['password']);
|
|
if($_POST["function"]=="logout") logout();
|
|
if($_POST["function"]=="loggedIn") echo true;
|
|
|
|
} else {
|
|
|
|
$database = dbConnect();
|
|
|
|
// Photo Functions
|
|
if($_POST["function"]=="getPhotoInfo"&&isset($_POST["photoID"])&&isPhotoPublic($_POST["photoID"])) echo array2json(getPhotoInfo($_POST["photoID"]));
|
|
|
|
// Session Functions
|
|
if($_POST["function"]=="login") echo login($_POST['user'], $_POST['password']);
|
|
if($_POST["function"]=="loggedIn") echo false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('HTTP/1.1 401 Unauthorized');
|
|
die("Error: No permission!");
|
|
|
|
}
|
|
|
|
?>
|