Skip to content

Commit

Permalink
Config in data/
Browse files Browse the repository at this point in the history
  • Loading branch information
electerious committed Feb 7, 2014
1 parent c91b282 commit 4fd302f
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 63 deletions.
Empty file modified data/.gitignore 100644 → 100755
Empty file.
12 changes: 10 additions & 2 deletions docs/md/Installation.md
Expand Up @@ -16,12 +16,20 @@ To use Lychee without restrictions, we recommend to increase the values of the f
upload_max_size = 200M
upload_max_filesize = 20M
max_file_uploads = 100

### Download Lychee

The easiest way to download Lychee is with git:

git clone https://github.com/electerious/Lychee.git

You can also use the [direct download](https://github.com/electerious/Lychee/archive/master.zip).

### Folder permissions

Change the permissions of `uploads/` and `php/` to 777, including all subfolders:
Change the permissions of `uploads/` and `data/` to 777, including all subfolders:

chmod -R 777 uploads/ php/
chmod -R 777 uploads/ data/

### Lychee installation

Expand Down
12 changes: 6 additions & 6 deletions php/api.php
Expand Up @@ -27,7 +27,7 @@
require('modules/tags.php');
require('modules/misc.php');

if (file_exists('config.php')) require('config.php');
if (file_exists('../data/config.php')) require('../data/config.php');
else {

/**
Expand Down Expand Up @@ -55,7 +55,7 @@

// 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]));
Expand All @@ -64,7 +64,7 @@
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['photoID'])&&preg_match('/^[0-9]{14}$/', $_POST['photoID'])!==1) exit('Error: Wrong parameter type for photoID!');

if (isset($_SESSION['login'])&&$_SESSION['login']==true) {

Expand Down Expand Up @@ -158,13 +158,13 @@
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;
Expand Down
97 changes: 49 additions & 48 deletions php/modules/album.php
Expand Up @@ -236,54 +236,55 @@ function deleteAlbum($albumIDs) {
function getAlbumArchive($albumID) {

global $database;

switch($albumID) {
case 's':
$query = "SELECT * FROM lychee_photos WHERE public = '1';";
$zipTitle = "Public";
break;
case 'f':
$query = "SELECT * FROM lychee_photos WHERE star = '1';";
$zipTitle = "Starred";
break;
default:
$query = "SELECT * FROM lychee_photos WHERE album = '$albumID';";
$zipTitle = "Unsorted";
}

$result = $database->query($query);
$files = array();
$i=0;
while($row = $result->fetch_object()) {
$files[$i] = "../uploads/big/".$row->url;
$i++;
}
$result = $database->query("SELECT * FROM lychee_albums WHERE id = '$albumID';");
$row = $result->fetch_object();
if ($albumID!=0&&is_numeric($albumID))$zipTitle = $row->title;
$filename = "../uploads/".$zipTitle.".zip";

$zip = new ZipArchive();

if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
return false;
}

foreach($files AS $zipFile) {
$newFile = explode("/",$zipFile);
$newFile = array_reverse($newFile);
$zip->addFile($zipFile, $zipTitle."/".$newFile[0]);
}

$zip->close();

header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"$zipTitle.zip\"");
header("Content-Length: ".filesize($filename));
readfile($filename);
unlink($filename);

return true;

switch($albumID) {
case 's':
$query = "SELECT * FROM lychee_photos WHERE public = '1';";
$zipTitle = "Public";
break;
case 'f':
$query = "SELECT * FROM lychee_photos WHERE star = '1';";
$zipTitle = "Starred";
break;
default:
$query = "SELECT * FROM lychee_photos WHERE album = '$albumID';";
$zipTitle = "Unsorted";
}

$zip = new ZipArchive();
$result = $database->query($query);
$files = array();
$i=0;

while($row = $result->fetch_object()) {
$files[$i] = "../uploads/big/".$row->url;
$i++;
}

$result = $database->query("SELECT * FROM lychee_albums WHERE id = '$albumID';");
$row = $result->fetch_object();
if ($albumID!=0&&is_numeric($albumID)) $zipTitle = $row->title;
$filename = "../data/$zipTitle.zip";

if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
return false;
}

foreach($files AS $zipFile) {
$newFile = explode("/",$zipFile);
$newFile = array_reverse($newFile);
$zip->addFile($zipFile, $zipTitle."/".$newFile[0]);
}

$zip->close();

header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"$zipTitle.zip\"");
header("Content-Length: ".filesize($filename));
readfile($filename);
unlink($filename);

return true;

}

Expand Down
5 changes: 4 additions & 1 deletion php/modules/db.php
Expand Up @@ -61,6 +61,9 @@ function createConfig($dbHost = 'localhost', $dbUser, $dbPassword, $dbName = 'ly
if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
// Config version
\$configVersion = '2.1';
// Database configurations
\$dbHost = '$dbHost'; //Host of the Database
\$dbUser = '$dbUser'; //Username of the database
Expand All @@ -69,7 +72,7 @@ function createConfig($dbHost = 'localhost', $dbUser, $dbPassword, $dbName = 'ly
?>";

if (file_put_contents("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;
Expand Down
Empty file modified php/modules/tags.php 100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions plugins/check.php
Expand Up @@ -16,8 +16,8 @@
$error = '';

// Include
if (!file_exists('../php/config.php')) exit('Error 001: Configuration not found. Please install Lychee first.');
require('../php/config.php');
if (!file_exists('../data/config.php')) exit('Error 001: Configuration not found. Please install Lychee first.');
require('../data/config.php');
require('../php/modules/settings.php');

// Database
Expand Down Expand Up @@ -54,7 +54,7 @@
if (substr(sprintf('%o', @fileperms('../uploads/thumb/')), -4)!='0777') $error .= ('Error 501: Wrong permissions for \'uploads/thumb\' (777 required)' . PHP_EOL);
if (substr(sprintf('%o', @fileperms('../uploads/import/')), -4)!='0777') $error .= ('Error 502: Wrong permissions for \'uploads/import\' (777 required)' . PHP_EOL);
if (substr(sprintf('%o', @fileperms('../uploads/')), -4)!='0777') $error .= ('Error 503: Wrong permissions for \'uploads/\' (777 required)' . PHP_EOL);
if (substr(sprintf('%o', @fileperms('../php/')), -4)!='0777') $error .= ('Error 504: Wrong permissions for \'php/\' (777 required)' . PHP_EOL);
if (substr(sprintf('%o', @fileperms('../data/')), -4)!='0777') $error .= ('Error 504: Wrong permissions for \'data/\' (777 required)' . PHP_EOL);

if ($error=='') echo('Lychee is ready. Lets rock!' . PHP_EOL . PHP_EOL); else echo $error;

Expand Down
4 changes: 2 additions & 2 deletions readme.md
Expand Up @@ -17,11 +17,11 @@ You can use Lychee right after the installation. Here are some advanced features

### Settings

Sign in and click the gear on the top left corner to change your settings. If you want to edit them manually: MySQL details are stored in `php/config.php`. Other options and settings are stored directly in the database. [Settings »](docs/md/Settings.md)
Sign in and click the gear on the top left corner to change your settings. If you want to edit them manually: MySQL details are stored in `data/config.php`. Other options and settings are stored directly in the database. [Settings »](docs/md/Settings.md)

### Update

1. Replace all files, excluding `uploads/`
1. Replace all files, excluding `uploads/` and `data/`
2. Open Lychee and enter your database details

### FTP Upload
Expand Down
2 changes: 1 addition & 1 deletion view.php
Expand Up @@ -24,7 +24,7 @@

define("LYCHEE", true);

require("php/config.php");
require("data/config.php");
require("php/modules/db.php");
require("php/modules/misc.php");

Expand Down

0 comments on commit 4fd302f

Please sign in to comment.