2014-01-22 10:12:51 +00:00
< ? php
2014-04-22 09:49:25 +00:00
###
2014-04-22 10:02:49 +00:00
# @name Check Plugin
2014-04-22 09:49:25 +00:00
# @author Tobias Reich
2015-03-29 16:56:08 +00:00
# @copyright 2015 by Tobias Reich
2014-04-22 09:49:25 +00:00
# @description This file takes a look at your Lychee-configuration and displays all errors it can find.
###
# Location
2014-04-22 10:06:23 +00:00
$lychee = __DIR__ . '/../../' ;
2014-04-22 09:49:25 +00:00
# Load requirements
require ( $lychee . 'php/define.php' );
require ( $lychee . 'php/autoload.php' );
2016-01-24 21:30:37 +00:00
require ( $lychee . 'php/misc.php' );
2014-04-22 09:49:25 +00:00
2016-01-24 12:07:25 +00:00
# Start the session
session_start ();
2014-04-22 09:49:25 +00:00
# Set content
2014-01-22 10:12:51 +00:00
header ( 'content-type: text/plain' );
2014-04-22 09:49:25 +00:00
# Declare
2014-01-22 10:12:51 +00:00
$error = '' ;
2015-01-16 18:52:54 +00:00
# Show separator
echo ( 'Diagnostics' . PHP_EOL );
echo ( '-----------' . PHP_EOL );
# PHP Version
2015-11-14 12:08:21 +00:00
if ( floatval ( phpversion ()) < 5.5 ) $error .= ( 'Error: Upgrade to PHP 5.5 or higher' . PHP_EOL );
2015-01-16 18:52:54 +00:00
# Extensions
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 ( '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 ( '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 ( 'zip' )) $error .= ( 'Error: PHP zip extension not activated' . PHP_EOL );
# Permissions
2015-05-31 09:18:15 +00:00
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_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 ) === 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 );
2015-01-16 18:52:54 +00:00
2016-01-10 16:17:06 +00:00
# About GD
$gdVersion = gd_info ();
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 [ 'GIF Read Support' ] || ! $gdVersion [ 'GIF Create Support' ]) $error .= ( 'Error: PHP gd extension without full gif support' . PHP_EOL );
2014-04-22 09:49:25 +00:00
# Load config
2015-05-31 09:21:38 +00:00
if ( ! file_exists ( LYCHEE_CONFIG_FILE )) exit ( 'Error: Configuration not found. Please install Lychee for additional tests' );
2015-01-16 18:52:54 +00:00
else require ( LYCHEE_CONFIG_FILE );
2014-01-22 10:12:51 +00:00
2014-04-22 09:49:25 +00:00
# Database
2014-01-22 10:12:51 +00:00
$database = new mysqli ( $dbHost , $dbUser , $dbPassword , $dbName );
2015-01-16 18:52:54 +00:00
if ( mysqli_connect_errno () != 0 ) $error .= ( 'Error: ' . mysqli_connect_errno () . ': ' . mysqli_connect_error () . '' . PHP_EOL );
2014-01-22 10:12:51 +00:00
2014-04-22 09:49:25 +00:00
# Load settings
2016-01-24 21:14:20 +00:00
$settings = Settings :: get ();
2014-01-22 10:12:51 +00:00
2014-04-22 09:49:25 +00:00
# Config
2015-01-16 18:52:54 +00:00
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 ( $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 );
2014-04-22 09:49:25 +00:00
# Settings
2015-06-28 21:17:09 +00:00
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 [ 'thumbQuality' ]) || $settings [ 'thumbQuality' ] == '' ) $error .= ( 'Error: No or wrong property for thumbQuality 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 [ '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 [ '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 );
2015-01-16 18:52:54 +00:00
if ( ! isset ( $settings [ 'checkForUpdates' ]) || ( $settings [ 'checkForUpdates' ] != '0' && $settings [ 'checkForUpdates' ] != '1' )) $error .= ( 'Error: No or wrong property for checkForUpdates in database' . PHP_EOL );
2014-04-22 09:49:25 +00:00
# Check dropboxKey
2015-05-31 09:21:38 +00:00
if ( ! $settings [ 'dropboxKey' ]) echo ( 'Warning: Dropbox import not working. No property for dropboxKey' . PHP_EOL );
2014-03-16 12:54:53 +00:00
2014-04-22 09:49:25 +00:00
# Check php.ini Settings
2014-03-01 22:12:37 +00:00
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 );
2015-04-04 22:55:15 +00:00
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 );
2014-01-22 10:12:51 +00:00
2014-04-22 09:49:25 +00:00
# Check mysql version
2014-01-26 22:33:21 +00:00
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 );
2014-01-22 10:12:51 +00:00
2014-08-28 15:02:27 +00:00
# Output
2015-01-16 18:52:54 +00:00
if ( $error === '' ) echo ( 'No critical problems found. Lychee should work without problems!' . PHP_EOL );
else echo $error ;
2014-08-28 15:02:27 +00:00
# Show separator
echo ( PHP_EOL . PHP_EOL . 'System Information' . PHP_EOL );
echo ( '------------------' . PHP_EOL );
2016-01-10 12:07:21 +00:00
# Ensure that user is logged in
if (( isset ( $_SESSION [ 'login' ]) && $_SESSION [ 'login' ] === true ) &&
( isset ( $_SESSION [ 'identifier' ]) && $_SESSION [ 'identifier' ] === $settings [ 'identifier' ])) {
# Load json
$json = file_get_contents ( LYCHEE_SRC . 'package.json' );
$json = json_decode ( $json , true );
# About imagick
$imagick = extension_loaded ( 'imagick' );
if ( $imagick === true ) $imagickVersion = @ Imagick :: getVersion ();
else $imagick = '-' ;
if ( ! isset ( $imagickVersion , $imagickVersion [ 'versionNumber' ]) || $imagickVersion === '' ) $imagickVersion = '-' ;
else $imagickVersion = $imagickVersion [ 'versionNumber' ];
# Output system information
echo ( 'Lychee Version: ' . $json [ 'version' ] . PHP_EOL );
echo ( 'DB Version: ' . $settings [ 'version' ] . PHP_EOL );
echo ( 'System: ' . PHP_OS . PHP_EOL );
echo ( 'PHP Version: ' . floatval ( phpversion ()) . PHP_EOL );
echo ( 'MySQL Version: ' . $database -> server_version . PHP_EOL );
echo ( 'Imagick: ' . $imagick . PHP_EOL );
echo ( 'Imagick Active: ' . $settings [ 'imagick' ] . PHP_EOL );
echo ( 'Imagick Version: ' . $imagickVersion . PHP_EOL );
echo ( 'GD Version: ' . $gdVersion [ 'GD Version' ] . PHP_EOL );
2016-01-24 21:14:20 +00:00
echo ( 'Plugins: ' . implode ( $settings [ 'plugins' ], ', ' ) . PHP_EOL );
2016-01-10 12:07:21 +00:00
} else {
# Don't go further if the user is not logged in
echo ( 'You have to be logged in to see more information.' );
exit ();
}
2014-08-28 15:02:27 +00:00
2015-02-21 08:50:38 +00:00
?>