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
# @copyright 2014 by Tobias Reich
# @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' );
2014-05-17 21:19:48 +00:00
require ( $lychee . 'php/modules/misc.php' );
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 = '' ;
2014-04-22 09:49:25 +00:00
# Load config
if ( ! file_exists ( LYCHEE_CONFIG_FILE )) exit ( 'Error 001: Configuration not found. Please install Lychee first.' );
require ( LYCHEE_CONFIG_FILE );
2014-01-22 10:12:51 +00:00
2014-08-29 21:53:52 +00:00
# Define the table prefix
2014-09-04 19:22:58 +00:00
if ( ! isset ( $dbTablePrefix )) $dbTablePrefix = '' ;
2014-08-29 21:53:52 +00:00
defineTablePrefix ( $dbTablePrefix );
2014-08-28 15:02:27 +00:00
# Show separator
echo ( 'Diagnostics' . PHP_EOL );
echo ( '-----------' . PHP_EOL );
2014-04-22 09:49:25 +00:00
# Database
2014-01-22 10:12:51 +00:00
$database = new mysqli ( $dbHost , $dbUser , $dbPassword , $dbName );
2014-04-22 09:49:25 +00:00
if ( mysqli_connect_errno () != 0 ) $error .= ( 'Error 100: ' . 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
$settings = new Settings ( $database );
$settings = $settings -> get ();
2014-01-22 10:12:51 +00:00
2014-04-22 09:49:25 +00:00
# PHP Version
2014-02-23 14:58:39 +00:00
if ( floatval ( phpversion ()) < 5.2 ) $error .= ( 'Error 200: Please upgrade to PHP 5.2 or higher!' . PHP_EOL );
2014-01-22 10:12:51 +00:00
2014-04-22 09:49:25 +00:00
# Extensions
2014-02-23 14:58:39 +00:00
if ( ! extension_loaded ( 'exif' )) $error .= ( 'Error 300: PHP exif extension not activated' . PHP_EOL );
if ( ! extension_loaded ( 'mbstring' )) $error .= ( 'Error 301: PHP mbstring extension not activated' . PHP_EOL );
if ( ! extension_loaded ( 'gd' )) $error .= ( 'Error 302: PHP gd extension not activated' . PHP_EOL );
if ( ! extension_loaded ( 'mysqli' )) $error .= ( 'Error 303: PHP mysqli extension not activated' . PHP_EOL );
if ( ! extension_loaded ( 'json' )) $error .= ( 'Error 304: PHP json extension not activated' . PHP_EOL );
2014-04-04 13:14:11 +00:00
if ( ! extension_loaded ( 'zip' )) $error .= ( 'Error 305: PHP zip extension not activated' . PHP_EOL );
2014-01-22 10:12:51 +00:00
2014-04-22 09:49:25 +00:00
# Config
if ( ! isset ( $dbName ) || $dbName === '' ) $error .= ( 'Error 400: No property for $dbName in config.php' . PHP_EOL );
if ( ! isset ( $dbUser ) || $dbUser === '' ) $error .= ( 'Error 401: No property for $dbUser in config.php' . PHP_EOL );
2014-02-23 14:58:39 +00:00
if ( ! isset ( $dbPassword )) $error .= ( 'Error 402: No property for $dbPassword in config.php' . PHP_EOL );
2014-04-22 09:49:25 +00:00
if ( ! isset ( $dbHost ) || $dbHost === '' ) $error .= ( 'Error 403: No property for $dbHost in config.php' . PHP_EOL );
# Settings
2014-04-26 12:35:17 +00:00
if ( ! isset ( $settings [ 'username' ]) || $settings [ 'username' ] == '' ) $error .= ( 'Error 404: Username empty or not set in database' . PHP_EOL );
if ( ! isset ( $settings [ 'password' ]) || $settings [ 'password' ] == '' ) $error .= ( 'Error 405: Password empty or not set in database' . PHP_EOL );
if ( ! isset ( $settings [ 'thumbQuality' ]) || $settings [ 'thumbQuality' ] == '' ) $error .= ( 'Error 406: No or wrong property for thumbQuality in database' . PHP_EOL );
2014-05-17 21:19:48 +00:00
if ( ! isset ( $settings [ 'sorting' ]) || $settings [ 'sorting' ] == '' ) $error .= ( 'Error 407: Wrong property for sorting in database' . PHP_EOL );
2014-04-26 12:35:17 +00:00
if ( ! isset ( $settings [ 'plugins' ])) $error .= ( 'Error 408: No property for plugins in database' . PHP_EOL );
2014-08-29 22:11:26 +00:00
if ( ! isset ( $settings [ 'imagick' ]) || $settings [ 'imagick' ] == '' ) $error .= ( 'Error 409: No or wrong property for imagick in database' . PHP_EOL );
if ( ! isset ( $settings [ 'checkForUpdates' ]) || ( $settings [ 'checkForUpdates' ] != '0' && $settings [ 'checkForUpdates' ] != '1' )) $error .= ( 'Error 410: No or wrong property for checkForUpdates in database' . PHP_EOL );
2014-04-22 09:49:25 +00:00
# Permissions
2014-11-06 21:25:27 +00:00
if ( hasPermissions ( LYCHEE_UPLOADS_BIG ) === false ) $error .= ( 'Error 500: \'uploads/big\' missing or not readable and writable (777 required)' . PHP_EOL );
if ( hasPermissions ( LYCHEE_UPLOADS_MEDIUM ) === false ) $error .= ( 'Error 500: \'uploads/medium\' missing or not readable and writable (777 required)' . PHP_EOL );
if ( hasPermissions ( LYCHEE_UPLOADS_THUMB ) === false ) $error .= ( 'Error 501: \'uploads/thumb\' missing or not readable and writable (777 required)' . PHP_EOL );
if ( hasPermissions ( LYCHEE_UPLOADS_IMPORT ) === false ) $error .= ( 'Error 502: \'uploads/import\' missing or not readable and writable (777 required)' . PHP_EOL );
if ( hasPermissions ( LYCHEE_UPLOADS ) === false ) $error .= ( 'Error 503: \'uploads/\' missing or not readable and writable (777 required)' . PHP_EOL );
if ( hasPermissions ( LYCHEE_DATA ) === false ) $error .= ( 'Error 504: \'data/\' missing or not readable and writable (777 required)' . PHP_EOL );
2014-04-22 09:49:25 +00:00
# Check dropboxKey
2014-05-17 21:19:48 +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 );
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
if ( $error == '' ) echo ( 'No critical problems found. Lychee should work without problems!' . PHP_EOL );
else echo $error ;
# Show separator
echo ( PHP_EOL . PHP_EOL . 'System Information' . PHP_EOL );
echo ( '------------------' . PHP_EOL );
# Load json
2014-11-19 22:31:35 +00:00
$json = file_get_contents ( LYCHEE_SRC . 'package.json' );
2014-08-28 15:02:27 +00:00
$json = json_decode ( $json , true );
2014-09-04 19:14:57 +00:00
$imagick = extension_loaded ( 'imagick' );
if ( $imagick === false ) $imagick = '-' ;
2014-09-04 19:31:33 +00:00
if ( $imagick === true ) $imagickVersion = @ Imagick :: getVersion ();
2014-09-27 10:33:53 +00:00
if ( ! isset ( $imagickVersion , $imagickVersion [ 'versionNumber' ]) || $imagickVersion === '' ) $imagickVersion = '-' ;
else $imagickVersion = $imagickVersion [ 'versionNumber' ];
2014-09-04 19:14:57 +00:00
$gdVersion = gd_info ();
2014-08-28 15:02:27 +00:00
# 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 );
2014-09-04 19:14:57 +00:00
echo ( 'Imagick: ' . $imagick . PHP_EOL );
2014-08-29 22:11:26 +00:00
echo ( 'Imagick Active: ' . $settings [ 'imagick' ] . PHP_EOL );
2014-09-27 10:33:53 +00:00
echo ( 'Imagick Version: ' . $imagickVersion . PHP_EOL );
2014-08-30 05:21:13 +00:00
echo ( 'GD Version: ' . $gdVersion [ 'GD Version' ] . PHP_EOL );
2014-08-28 15:02:27 +00:00
2014-01-22 10:12:51 +00:00
?>