2013-01-15 20:21:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name api.php
|
|
|
|
* @author Philipp Maurer
|
|
|
|
* @author Tobias Reich
|
2013-05-03 11:57:08 +00:00
|
|
|
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
2012-10-02 15:48:08 +00:00
|
|
|
*/
|
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
if(floatval(phpversion())<5.2) die("Please upgrade to PHP 5.2 or higher!");
|
|
|
|
|
2012-10-02 15:48:08 +00:00
|
|
|
if((isset($_POST["function"])&&$_POST["function"]!="")||(isset($_GET["function"])&&$_GET["function"]!="")) {
|
|
|
|
|
|
|
|
session_start();
|
2013-05-03 11:57:08 +00:00
|
|
|
define("LYCHEE", true);
|
|
|
|
|
2012-10-02 15:48:08 +00:00
|
|
|
include("array2json.php");
|
2013-05-03 11:57:08 +00:00
|
|
|
include("config.php");
|
2012-10-02 15:48:08 +00:00
|
|
|
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
|
2013-05-03 11:57:08 +00:00
|
|
|
$database = dbConnect();
|
2012-10-02 15:48:08 +00:00
|
|
|
|
|
|
|
// 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"]);
|
2013-01-15 20:21:36 +00:00
|
|
|
if($_GET["function"]=="getAlbumArchive"&&isset($_GET["albumID"])) getAlbumArchive($_GET["albumID"]);
|
|
|
|
|
2012-10-02 15:48:08 +00:00
|
|
|
// 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"]);
|
2013-01-15 20:21:36 +00:00
|
|
|
if($_POST["function"]=="setPhotoDescription"&&isset($_POST["photoID"])&&isset($_POST["description"])) echo setPhotoDescription($_POST["photoID"], $_POST["description"]);
|
2012-10-02 15:48:08 +00:00
|
|
|
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"]));
|
2013-01-15 20:21:36 +00:00
|
|
|
|
|
|
|
// 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
|
2012-10-25 10:22:04 +00:00
|
|
|
if($_POST["function"]=="syncFolder") echo syncFolder();
|
2013-01-15 20:21:36 +00:00
|
|
|
|
2012-10-02 15:48:08 +00:00
|
|
|
// Session Functions
|
2013-05-03 11:57:08 +00:00
|
|
|
if($_POST["function"]=="login") echo login($_POST['user'], $_POST['password']);
|
2012-10-02 15:48:08 +00:00
|
|
|
if($_POST["function"]=="logout") logout();
|
|
|
|
if($_POST["function"]=="loggedIn") echo true;
|
|
|
|
|
2013-01-15 20:21:36 +00:00
|
|
|
} else {
|
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
$database = dbConnect();
|
2013-01-15 20:21:36 +00:00
|
|
|
|
2012-10-02 15:48:08 +00:00
|
|
|
// Photo Functions
|
|
|
|
if($_POST["function"]=="getPhotoInfo"&&isset($_POST["photoID"])&&isPhotoPublic($_POST["photoID"])) echo array2json(getPhotoInfo($_POST["photoID"]));
|
2013-01-15 20:21:36 +00:00
|
|
|
|
2012-10-02 15:48:08 +00:00
|
|
|
// Session Functions
|
|
|
|
if($_POST["function"]=="login") echo login($_POST['user'], $_POST['password']);
|
2013-01-15 20:21:36 +00:00
|
|
|
if($_POST["function"]=="loggedIn") echo false;
|
|
|
|
|
2012-10-02 15:48:08 +00:00
|
|
|
}
|
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
header('HTTP/1.1 401 Unauthorized');
|
|
|
|
die("Error: No permission!");
|
|
|
|
|
|
|
|
}
|
2012-10-02 15:48:08 +00:00
|
|
|
|
|
|
|
?>
|