示例#1
0
 /**
  * @return object Returns a new or cached connection.
  */
 public static function get()
 {
     if (!self::$instance) {
         $credentials = Config::get();
         self::$instance = new self($credentials['host'], $credentials['user'], $credentials['password'], $credentials['name'], $credentials['prefix']);
     }
     return self::$instance->connection;
 }
示例#2
0
 private static function configCreateAction()
 {
     Validator::required(isset($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName'], $_POST['dbTablePrefix']), __METHOD__);
     Response::json(Config::create($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName'], $_POST['dbTablePrefix']));
 }
示例#3
0
$uploadsPath = realpath($uploadsPath);
if (empty($_GET['type']) || empty($_GET['url'])) {
    exit('Error: Unable to find your photo.');
}
$type = $_GET['type'];
$url = $_GET['url'];
# Usual startup (taken from php/index.php file)
use Lychee\Modules\Album;
use Lychee\Modules\Config;
use Lychee\Modules\Settings;
use Lychee\Modules\Database;
require __DIR__ . '/../../php/define.php';
require __DIR__ . '/../../php/autoload.php';
session_start();
date_default_timezone_set('UTC');
if (Config::exists() === false) {
    exit('Error: no config file.');
}
$isAdmin = false;
if (isset($_SESSION['login']) && $_SESSION['login'] === true && (isset($_SESSION['identifier']) && $_SESSION['identifier'] === Settings::get()['identifier'])) {
    $isAdmin = true;
}
# end of startup
$database = Database::get();
# return the photo if the current user has acces to it or false otherwise (taken from php/module/photo.php)
function getPhoto($database, $type, $photoUrl, $isAdmin)
{
    $retinaSuffix = '@2x';
    $urlParts = explode('.', $photoUrl);
    $dbUrl = $photoUrl;
    # If the filename ends in $retinaSuffix, remove it for the database query