Updated code syntax of Log and Diagnostics

pull/462/head
Tobias Reich 8 years ago
parent be5bb7ee6e
commit 34f87367e3

@ -1,11 +1,10 @@
<?php <?php
### /**
# @name Check Plugin * @author Tobias Reich
# @author Tobias Reich * @copyright 2015 by Tobias Reich
# @copyright 2015 by Tobias Reich * @description This file takes a look at your Lychee-configuration and displays all errors it can find.
# @description This file takes a look at your Lychee-configuration and displays all errors it can find. */
###
namespace Diagnostics; namespace Diagnostics;
@ -19,107 +18,107 @@ require($lychee . 'php/autoload.php');
require($lychee . 'php/helpers/hasPermissions.php'); require($lychee . 'php/helpers/hasPermissions.php');
# Start the session // Start the session
session_start(); session_start();
# Set content // Set content
header('content-type: text/plain'); header('content-type: text/plain');
# Declare // Declare
$error = ''; $error = '';
# Show separator // Show separator
echo('Diagnostics' . PHP_EOL); echo('Diagnostics' . PHP_EOL);
echo('-----------' . PHP_EOL); echo('-----------' . PHP_EOL);
# PHP Version // PHP Version
if (floatval(phpversion())<5.5) $error .= ('Error: Upgrade to PHP 5.5 or higher' . PHP_EOL); if (floatval(phpversion())<5.5) $error .= ('Error: Upgrade to PHP 5.5 or higher' . PHP_EOL);
# Extensions // Extensions
if (!extension_loaded('session')) $error .= ('Error: PHP session extension not activated' . PHP_EOL); if (!extension_loaded('session')) $error .= ('Error: PHP session extension not activated' . PHP_EOL);
if (!extension_loaded('exif')) $error .= ('Error: PHP exif extension not activated' . PHP_EOL); if (!extension_loaded('exif')) $error .= ('Error: PHP exif extension not activated' . PHP_EOL);
if (!extension_loaded('mbstring')) $error .= ('Error: PHP mbstring extension not activated' . PHP_EOL); if (!extension_loaded('mbstring')) $error .= ('Error: PHP mbstring extension not activated' . PHP_EOL);
if (!extension_loaded('gd')) $error .= ('Error: PHP gd extension not activated' . PHP_EOL); if (!extension_loaded('gd')) $error .= ('Error: PHP gd extension not activated' . PHP_EOL);
if (!extension_loaded('mysqli')) $error .= ('Error: PHP mysqli extension not activated' . PHP_EOL); if (!extension_loaded('mysqli')) $error .= ('Error: PHP mysqli extension not activated' . PHP_EOL);
if (!extension_loaded('json')) $error .= ('Error: PHP json extension not activated' . PHP_EOL); if (!extension_loaded('json')) $error .= ('Error: PHP json extension not activated' . PHP_EOL);
if (!extension_loaded('zip')) $error .= ('Error: PHP zip extension not activated' . PHP_EOL); if (!extension_loaded('zip')) $error .= ('Error: PHP zip extension not activated' . PHP_EOL);
# Permissions // Permissions
if (hasPermissions(LYCHEE_UPLOADS_BIG)===false) $error .= ('Error: \'uploads/big\' is missing or has insufficient read/write privileges' . PHP_EOL); if (hasPermissions(LYCHEE_UPLOADS_BIG)===false) $error .= ('Error: \'uploads/big\' is missing or has insufficient read/write privileges' . PHP_EOL);
if (hasPermissions(LYCHEE_UPLOADS_MEDIUM)===false) $error .= ('Error: \'uploads/medium\' is missing or has insufficient read/write privileges' . PHP_EOL); if (hasPermissions(LYCHEE_UPLOADS_MEDIUM)===false) $error .= ('Error: \'uploads/medium\' is missing or has insufficient read/write privileges' . PHP_EOL);
if (hasPermissions(LYCHEE_UPLOADS_THUMB)===false) $error .= ('Error: \'uploads/thumb\' is missing or has insufficient read/write privileges' . PHP_EOL); if (hasPermissions(LYCHEE_UPLOADS_THUMB)===false) $error .= ('Error: \'uploads/thumb\' is missing or has insufficient read/write privileges' . PHP_EOL);
if (hasPermissions(LYCHEE_UPLOADS_IMPORT)===false) $error .= ('Error: \'uploads/import\' is missing or has insufficient read/write privileges' . PHP_EOL); if (hasPermissions(LYCHEE_UPLOADS_IMPORT)===false) $error .= ('Error: \'uploads/import\' is missing or has insufficient read/write privileges' . PHP_EOL);
if (hasPermissions(LYCHEE_UPLOADS)===false) $error .= ('Error: \'uploads/\' is missing or has insufficient read/write privileges' . PHP_EOL); if (hasPermissions(LYCHEE_UPLOADS)===false) $error .= ('Error: \'uploads/\' is missing or has insufficient read/write privileges' . PHP_EOL);
if (hasPermissions(LYCHEE_DATA)===false) $error .= ('Error: \'data/\' is missing or has insufficient read/write privileges' . PHP_EOL); if (hasPermissions(LYCHEE_DATA)===false) $error .= ('Error: \'data/\' is missing or has insufficient read/write privileges' . PHP_EOL);
# About GD // About GD
$gdVersion = gd_info(); $gdVersion = gd_info();
if (!$gdVersion['JPEG Support']) $error .= ('Error: PHP gd extension without jpeg support' . PHP_EOL); if (!$gdVersion['JPEG Support']) $error .= ('Error: PHP gd extension without jpeg support' . PHP_EOL);
if (!$gdVersion['PNG Support']) $error .= ('Error: PHP gd extension without png support' . PHP_EOL); if (!$gdVersion['PNG Support']) $error .= ('Error: PHP gd extension without png support' . PHP_EOL);
if (!$gdVersion['GIF Read Support'] || !$gdVersion['GIF Create Support']) $error .= ('Error: PHP gd extension without full gif support' . PHP_EOL); if (!$gdVersion['GIF Read Support'] || !$gdVersion['GIF Create Support']) $error .= ('Error: PHP gd extension without full gif support' . PHP_EOL);
# Load config // Load config
if (!file_exists(LYCHEE_CONFIG_FILE)) exit('Error: Configuration not found. Please install Lychee for additional tests'); if (!file_exists(LYCHEE_CONFIG_FILE)) exit('Error: Configuration not found. Please install Lychee for additional tests');
else require(LYCHEE_CONFIG_FILE); require(LYCHEE_CONFIG_FILE);
# Database // Database
$database = new Mysqli($dbHost, $dbUser, $dbPassword, $dbName); $database = new Mysqli($dbHost, $dbUser, $dbPassword, $dbName);
if (mysqli_connect_errno()!=0) $error .= ('Error: ' . mysqli_connect_errno() . ': ' . mysqli_connect_error() . '' . PHP_EOL); if (mysqli_connect_errno()!=0) $error .= ('Error: ' . mysqli_connect_errno() . ': ' . mysqli_connect_error() . '' . PHP_EOL);
# Config // Config
if (!isset($dbName)||$dbName==='') $error .= ('Error: No property for $dbName in config.php' . PHP_EOL); if (!isset($dbName)||$dbName==='') $error .= ('Error: No property for $dbName in config.php' . PHP_EOL);
if (!isset($dbUser)||$dbUser==='') $error .= ('Error: No property for $dbUser in config.php' . PHP_EOL); if (!isset($dbUser)||$dbUser==='') $error .= ('Error: No property for $dbUser in config.php' . PHP_EOL);
if (!isset($dbPassword)) $error .= ('Error: No property for $dbPassword in config.php' . PHP_EOL); if (!isset($dbPassword)) $error .= ('Error: No property for $dbPassword in config.php' . PHP_EOL);
if (!isset($dbHost)||$dbHost==='') $error .= ('Error: No property for $dbHost in config.php' . PHP_EOL); if (!isset($dbHost)||$dbHost==='') $error .= ('Error: No property for $dbHost in config.php' . PHP_EOL);
# Load settings // Load settings
$settings = Settings::get(); $settings = Settings::get();
# Settings // Settings
if (!isset($settings['username'])||$settings['username']=='') $error .= ('Error: Username empty or not set in database' . PHP_EOL); if (!isset($settings['username'])||$settings['username']=='') $error .= ('Error: Username empty or not set in database' . PHP_EOL);
if (!isset($settings['password'])||$settings['password']=='') $error .= ('Error: Password empty or not set in database' . PHP_EOL); if (!isset($settings['password'])||$settings['password']=='') $error .= ('Error: Password empty or not set in database' . PHP_EOL);
if (!isset($settings['sortingPhotos'])||$settings['sortingPhotos']=='') $error .= ('Error: Wrong property for sortingPhotos in database' . PHP_EOL); if (!isset($settings['sortingPhotos'])||$settings['sortingPhotos']=='') $error .= ('Error: Wrong property for sortingPhotos in database' . PHP_EOL);
if (!isset($settings['sortingAlbums'])||$settings['sortingAlbums']=='') $error .= ('Error: Wrong property for sortingAlbums in database' . PHP_EOL); if (!isset($settings['sortingAlbums'])||$settings['sortingAlbums']=='') $error .= ('Error: Wrong property for sortingAlbums in database' . PHP_EOL);
if (!isset($settings['plugins'])) $error .= ('Error: No property for plugins in database' . PHP_EOL); if (!isset($settings['plugins'])) $error .= ('Error: No property for plugins in database' . PHP_EOL);
if (!isset($settings['imagick'])||$settings['imagick']=='') $error .= ('Error: No or wrong property for imagick in database' . PHP_EOL); if (!isset($settings['imagick'])||$settings['imagick']=='') $error .= ('Error: No or wrong property for imagick in database' . PHP_EOL);
if (!isset($settings['identifier'])||$settings['identifier']=='') $error .= ('Error: No or wrong property for identifier in database' . PHP_EOL); if (!isset($settings['identifier'])||$settings['identifier']=='') $error .= ('Error: No or wrong property for identifier in database' . PHP_EOL);
if (!isset($settings['skipDuplicates'])||$settings['skipDuplicates']=='') $error .= ('Error: No or wrong property for skipDuplicates in database' . PHP_EOL); if (!isset($settings['skipDuplicates'])||$settings['skipDuplicates']=='') $error .= ('Error: No or wrong property for skipDuplicates in database' . PHP_EOL);
if (!isset($settings['checkForUpdates'])||($settings['checkForUpdates']!='0'&&$settings['checkForUpdates']!='1')) $error .= ('Error: No or wrong property for checkForUpdates in database' . PHP_EOL); if (!isset($settings['checkForUpdates'])||($settings['checkForUpdates']!='0'&&$settings['checkForUpdates']!='1')) $error .= ('Error: No or wrong property for checkForUpdates in database' . PHP_EOL);
# Check dropboxKey // Check dropboxKey
if (!$settings['dropboxKey']) echo('Warning: Dropbox import not working. No property for dropboxKey' . PHP_EOL); if (!$settings['dropboxKey']) echo('Warning: Dropbox import not working. No property for dropboxKey.' . PHP_EOL);
# Check php.ini Settings // Check php.ini Settings
if (ini_get('max_execution_time')<200&&ini_set('upload_max_filesize', '20M')===false) echo('Warning: You may experience problems when uploading a large amount of photos. Take a look in the FAQ for details.' . PHP_EOL); if (ini_get('max_execution_time')<200&&ini_set('upload_max_filesize', '20M')===false) echo('Warning: You may experience problems when uploading a large amount of photos. Take a look in the FAQ for details.' . PHP_EOL);
if (!ini_get('allow_url_fopen')) echo('Warning: You may experience problems with the Dropbox- and URL-Import. Edit your php.ini and set allow_url_fopen to 1.' . PHP_EOL); if (!ini_get('allow_url_fopen')) echo('Warning: You may experience problems with the Dropbox- and URL-Import. Edit your php.ini and set allow_url_fopen to 1.' . PHP_EOL);
# Check mysql version // Check mysql version
if ($database->server_version<50500) echo('Warning: Lychee uses the GBK charset to avoid sql injections on your MySQL version. Please update to MySQL 5.5 or higher to enable UTF-8 support.' . PHP_EOL); if ($database->server_version<50500) echo('Warning: Lychee uses the GBK charset to avoid sql injections on your MySQL version. Please update to MySQL 5.5 or higher to enable UTF-8 support.' . PHP_EOL);
# Output // Output
if ($error==='') echo('No critical problems found. Lychee should work without problems!' . PHP_EOL); if ($error==='') echo('No critical problems found. Lychee should work without problems!' . PHP_EOL);
else echo $error; else echo $error;
# Show separator // Show separator
echo(PHP_EOL . PHP_EOL . 'System Information' . PHP_EOL); echo(PHP_EOL . PHP_EOL . 'System Information' . PHP_EOL);
echo('------------------' . PHP_EOL); echo('------------------' . PHP_EOL);
# Ensure that user is logged in // Ensure that user is logged in
if ((isset($_SESSION['login'])&&$_SESSION['login']===true)&& if ((isset($_SESSION['login'])&&$_SESSION['login']===true)&&
(isset($_SESSION['identifier'])&&$_SESSION['identifier']===$settings['identifier'])) { (isset($_SESSION['identifier'])&&$_SESSION['identifier']===$settings['identifier'])) {
# Load json // Load json
$json = file_get_contents(LYCHEE_SRC . 'package.json'); $json = file_get_contents(LYCHEE_SRC . 'package.json');
$json = json_decode($json, true); $json = json_decode($json, true);
# About imagick // About imagick
$imagick = extension_loaded('imagick'); $imagick = extension_loaded('imagick');
if ($imagick===true) $imagickVersion = @Imagick::getVersion(); if ($imagick===true) $imagickVersion = @Imagick::getVersion();
else $imagick = '-'; else $imagick = '-';
if (!isset($imagickVersion, $imagickVersion['versionNumber'])||$imagickVersion==='') $imagickVersion = '-'; if (!isset($imagickVersion, $imagickVersion['versionNumber'])||$imagickVersion==='') $imagickVersion = '-';
else $imagickVersion = $imagickVersion['versionNumber']; else $imagickVersion = $imagickVersion['versionNumber'];
# Output system information // Output system information
echo('Lychee Version: ' . $json['version'] . PHP_EOL); echo('Lychee Version: ' . $json['version'] . PHP_EOL);
echo('DB Version: ' . $settings['version'] . PHP_EOL); echo('DB Version: ' . $settings['version'] . PHP_EOL);
echo('System: ' . PHP_OS . PHP_EOL); echo('System: ' . PHP_OS . PHP_EOL);
@ -133,10 +132,10 @@ if ((isset($_SESSION['login'])&&$_SESSION['login']===true)&&
} else { } else {
# Don't go further if the user is not logged in // Don't go further if the user is not logged in
echo('You have to be logged in to see more information.'); echo('You have to be logged in to see more information.');
exit(); exit();
} }
?> ?>

@ -1,11 +1,10 @@
<?php <?php
### /**
# @name Log * @author Tobias Reich
# @author Tobias Reich * @copyright 2015 by Tobias Reich
# @copyright 2015 by Tobias Reich * @description This file queries the database for log messages and displays them if present.
# @description This file queries the database for log messages and displays them if present. */
###
namespace Log; namespace Log;
@ -18,25 +17,25 @@ $lychee = __DIR__ . '/../../';
require($lychee . 'php/define.php'); require($lychee . 'php/define.php');
require($lychee . 'php/autoload.php'); require($lychee . 'php/autoload.php');
# Start the session // Start the session
session_start(); session_start();
# Set content // Set content
header('content-type: text/plain'); header('content-type: text/plain');
# Load config // Load config
if (!file_exists(LYCHEE_CONFIG_FILE)) exit('Error 001: Configuration not found. Please install Lychee first.'); if (!file_exists(LYCHEE_CONFIG_FILE)) exit('Error 001: Configuration not found. Please install Lychee first.');
require(LYCHEE_CONFIG_FILE); require(LYCHEE_CONFIG_FILE);
# Ensure that user is logged in // Ensure that user is logged in
if ((isset($_SESSION['login'])&&$_SESSION['login']===true)&& if ((isset($_SESSION['login'])&&$_SESSION['login']===true)&&
(isset($_SESSION['identifier'])&&$_SESSION['identifier']===Settings::get()['identifier'])) { (isset($_SESSION['identifier'])&&$_SESSION['identifier']===Settings::get()['identifier'])) {
# Result // Result
$query = Database::prepare(Database::get(), "SELECT FROM_UNIXTIME(time), type, function, line, text FROM ?", array(LYCHEE_TABLE_LOG)); $query = Database::prepare(Database::get(), "SELECT FROM_UNIXTIME(time), type, function, line, text FROM ?", array(LYCHEE_TABLE_LOG));
$result = Database::get()->query($query); $result = Database::get()->query($query);
# Output // Output
if ($result->num_rows===0) { if ($result->num_rows===0) {
echo('Everything looks fine, Lychee has not reported any problems!'); echo('Everything looks fine, Lychee has not reported any problems!');
@ -45,11 +44,11 @@ if ((isset($_SESSION['login'])&&$_SESSION['login']===true)&&
while($row = $result->fetch_row()) { while($row = $result->fetch_row()) {
# Encode result before printing // Encode result before printing
$row = array_map('htmlentities', $row); $row = array_map('htmlentities', $row);
# Format: time TZ - type - function(line) - text // Format: time TZ - type - function(line) - text
printf ("%s - %s - %s (%s) \t- %s\n", $row[0], $row[1], $row[2], $row[3], $row[4]); printf("%s - %s - %s (%s) \t- %s\n", $row[0], $row[1], $row[2], $row[3], $row[4]);
} }
@ -57,10 +56,10 @@ if ((isset($_SESSION['login'])&&$_SESSION['login']===true)&&
} else { } else {
# Don't go further if the user is not logged in // Don't go further if the user is not logged in
echo('You have to be logged in to see the log.'); echo('You have to be logged in to see the log.');
exit(); exit();
} }
?> ?>
Loading…
Cancel
Save