index.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. ###
  3. # @name Check Plugin
  4. # @author Tobias Reich
  5. # @copyright 2014 by Tobias Reich
  6. # @description This file takes a look at your Lychee-configuration and displays all errors it can find.
  7. ###
  8. # Location
  9. $lychee = __DIR__ . '/../../';
  10. # Load requirements
  11. require($lychee . 'php/define.php');
  12. require($lychee . 'php/autoload.php');
  13. require($lychee . 'php/modules/misc.php');
  14. # Set content
  15. header('content-type: text/plain');
  16. # Declare
  17. $error = '';
  18. # Show separator
  19. echo('Diagnostics' . PHP_EOL);
  20. echo('-----------' . PHP_EOL);
  21. # PHP Version
  22. if (floatval(phpversion())<5.2) $error .= ('Error: Upgrade to PHP 5.2 or higher!' . PHP_EOL);
  23. # Extensions
  24. if (!extension_loaded('session')) $error .= ('Error: PHP session extension not activated' . PHP_EOL);
  25. if (!extension_loaded('exif')) $error .= ('Error: PHP exif extension not activated' . PHP_EOL);
  26. if (!extension_loaded('mbstring')) $error .= ('Error: PHP mbstring extension not activated' . PHP_EOL);
  27. if (!extension_loaded('gd')) $error .= ('Error: PHP gd extension not activated' . PHP_EOL);
  28. if (!extension_loaded('mysqli')) $error .= ('Error: PHP mysqli extension not activated' . PHP_EOL);
  29. if (!extension_loaded('json')) $error .= ('Error: PHP json extension not activated' . PHP_EOL);
  30. if (!extension_loaded('zip')) $error .= ('Error: PHP zip extension not activated' . PHP_EOL);
  31. # Permissions
  32. if (hasPermissions(LYCHEE_UPLOADS_BIG)===false) $error .= ('Error: \'uploads/big\' missing or not readable and writable (777 required)' . PHP_EOL);
  33. if (hasPermissions(LYCHEE_UPLOADS_MEDIUM)===false) $error .= ('Error: \'uploads/medium\' missing or not readable and writable (777 required)' . PHP_EOL);
  34. if (hasPermissions(LYCHEE_UPLOADS_THUMB)===false) $error .= ('Error: \'uploads/thumb\' missing or not readable and writable (777 required)' . PHP_EOL);
  35. if (hasPermissions(LYCHEE_UPLOADS_IMPORT)===false) $error .= ('Error: \'uploads/import\' missing or not readable and writable (777 required)' . PHP_EOL);
  36. if (hasPermissions(LYCHEE_UPLOADS)===false) $error .= ('Error: \'uploads/\' missing or not readable and writable (777 required)' . PHP_EOL);
  37. if (hasPermissions(LYCHEE_DATA)===false) $error .= ('Error: \'data/\' missing or not readable and writable (777 required)' . PHP_EOL);
  38. # Load config
  39. if (!file_exists(LYCHEE_CONFIG_FILE)) exit('Error: Configuration not found. Please install Lychee for additional tests.');
  40. else require(LYCHEE_CONFIG_FILE);
  41. # Define the table prefix
  42. if (!isset($dbTablePrefix)) $dbTablePrefix = '';
  43. defineTablePrefix($dbTablePrefix);
  44. # Database
  45. $database = new mysqli($dbHost, $dbUser, $dbPassword, $dbName);
  46. if (mysqli_connect_errno()!=0) $error .= ('Error: ' . mysqli_connect_errno() . ': ' . mysqli_connect_error() . '' . PHP_EOL);
  47. # Load settings
  48. $settings = new Settings($database);
  49. $settings = $settings->get();
  50. # Config
  51. if (!isset($dbName)||$dbName==='') $error .= ('Error: No property for $dbName in config.php' . PHP_EOL);
  52. if (!isset($dbUser)||$dbUser==='') $error .= ('Error: No property for $dbUser in config.php' . PHP_EOL);
  53. if (!isset($dbPassword)) $error .= ('Error: No property for $dbPassword in config.php' . PHP_EOL);
  54. if (!isset($dbHost)||$dbHost==='') $error .= ('Error: No property for $dbHost in config.php' . PHP_EOL);
  55. # Settings
  56. if (!isset($settings['username'])||$settings['username']=='') $error .= ('Error: Username empty or not set in database' . PHP_EOL);
  57. if (!isset($settings['password'])||$settings['password']=='') $error .= ('Error: Password empty or not set in database' . PHP_EOL);
  58. if (!isset($settings['thumbQuality'])||$settings['thumbQuality']=='') $error .= ('Error: No or wrong property for thumbQuality in database' . PHP_EOL);
  59. if (!isset($settings['sorting'])||$settings['sorting']=='') $error .= ('Error: Wrong property for sorting in database' . PHP_EOL);
  60. if (!isset($settings['plugins'])) $error .= ('Error: No property for plugins in database' . PHP_EOL);
  61. if (!isset($settings['imagick'])||$settings['imagick']=='') $error .= ('Error: No or wrong property for imagick in database' . PHP_EOL);
  62. if (!isset($settings['checkForUpdates'])||($settings['checkForUpdates']!='0'&&$settings['checkForUpdates']!='1')) $error .= ('Error: No or wrong property for checkForUpdates in database' . PHP_EOL);
  63. # Check dropboxKey
  64. if (!$settings['dropboxKey']) echo('Warning: Dropbox import not working. No property for dropboxKey.' . PHP_EOL);
  65. # Check php.ini Settings
  66. 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);
  67. # Check mysql version
  68. 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);
  69. # Output
  70. if ($error==='') echo('No critical problems found. Lychee should work without problems!' . PHP_EOL);
  71. else echo $error;
  72. # Show separator
  73. echo(PHP_EOL . PHP_EOL . 'System Information' . PHP_EOL);
  74. echo('------------------' . PHP_EOL);
  75. # Load json
  76. $json = file_get_contents(LYCHEE_SRC . 'package.json');
  77. $json = json_decode($json, true);
  78. # About imagick
  79. $imagick = extension_loaded('imagick');
  80. if ($imagick===true) $imagickVersion = @Imagick::getVersion();
  81. else $imagick = '-';
  82. if (!isset($imagickVersion, $imagickVersion['versionNumber'])||$imagickVersion==='') $imagickVersion = '-';
  83. else $imagickVersion = $imagickVersion['versionNumber'];
  84. # About GD
  85. $gdVersion = gd_info();
  86. # Output system information
  87. echo('Lychee Version: ' . $json['version'] . PHP_EOL);
  88. echo('DB Version: ' . $settings['version'] . PHP_EOL);
  89. echo('System: ' . PHP_OS . PHP_EOL);
  90. echo('PHP Version: ' . floatval(phpversion()) . PHP_EOL);
  91. echo('MySQL Version: ' . $database->server_version . PHP_EOL);
  92. echo('Imagick: ' . $imagick . PHP_EOL);
  93. echo('Imagick Active: ' . $settings['imagick'] . PHP_EOL);
  94. echo('Imagick Version: ' . $imagickVersion . PHP_EOL);
  95. echo('GD Version: ' . $gdVersion['GD Version'] . PHP_EOL);
  96. ?>