index.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. # Load config
  19. if (!file_exists(LYCHEE_CONFIG_FILE)) exit('Error 001: Configuration not found. Please install Lychee first.');
  20. require(LYCHEE_CONFIG_FILE);
  21. # Define the table prefix
  22. if (!isset($dbTablePrefix)) $dbTablePrefix = '';
  23. defineTablePrefix($dbTablePrefix);
  24. # Show separator
  25. echo('Diagnostics' . PHP_EOL);
  26. echo('-----------' . PHP_EOL);
  27. # Database
  28. $database = new mysqli($dbHost, $dbUser, $dbPassword, $dbName);
  29. if (mysqli_connect_errno()!=0) $error .= ('Error 100: ' . mysqli_connect_errno() . ': ' . mysqli_connect_error() . '' . PHP_EOL);
  30. # Load settings
  31. $settings = new Settings($database);
  32. $settings = $settings->get();
  33. # PHP Version
  34. if (floatval(phpversion())<5.2) $error .= ('Error 200: Please upgrade to PHP 5.2 or higher!' . PHP_EOL);
  35. # Extensions
  36. if (!extension_loaded('exif')) $error .= ('Error 300: PHP exif extension not activated' . PHP_EOL);
  37. if (!extension_loaded('mbstring')) $error .= ('Error 301: PHP mbstring extension not activated' . PHP_EOL);
  38. if (!extension_loaded('gd')) $error .= ('Error 302: PHP gd extension not activated' . PHP_EOL);
  39. if (!extension_loaded('mysqli')) $error .= ('Error 303: PHP mysqli extension not activated' . PHP_EOL);
  40. if (!extension_loaded('json')) $error .= ('Error 304: PHP json extension not activated' . PHP_EOL);
  41. if (!extension_loaded('zip')) $error .= ('Error 305: PHP zip extension not activated' . PHP_EOL);
  42. # Config
  43. if (!isset($dbName)||$dbName==='') $error .= ('Error 400: No property for $dbName in config.php' . PHP_EOL);
  44. if (!isset($dbUser)||$dbUser==='') $error .= ('Error 401: No property for $dbUser in config.php' . PHP_EOL);
  45. if (!isset($dbPassword)) $error .= ('Error 402: No property for $dbPassword in config.php' . PHP_EOL);
  46. if (!isset($dbHost)||$dbHost==='') $error .= ('Error 403: No property for $dbHost in config.php' . PHP_EOL);
  47. # Settings
  48. if (!isset($settings['username'])||$settings['username']=='') $error .= ('Error 404: Username empty or not set in database' . PHP_EOL);
  49. if (!isset($settings['password'])||$settings['password']=='') $error .= ('Error 405: Password empty or not set in database' . PHP_EOL);
  50. if (!isset($settings['thumbQuality'])||$settings['thumbQuality']=='') $error .= ('Error 406: No or wrong property for thumbQuality in database' . PHP_EOL);
  51. if (!isset($settings['sorting'])||$settings['sorting']=='') $error .= ('Error 407: Wrong property for sorting in database' . PHP_EOL);
  52. if (!isset($settings['plugins'])) $error .= ('Error 408: No property for plugins in database' . PHP_EOL);
  53. if (!isset($settings['imagick'])||$settings['imagick']=='') $error .= ('Error 409: No or wrong property for imagick in database' . PHP_EOL);
  54. if (!isset($settings['checkForUpdates'])||($settings['checkForUpdates']!='0'&&$settings['checkForUpdates']!='1')) $error .= ('Error 410: No or wrong property for checkForUpdates in database' . PHP_EOL);
  55. # Permissions
  56. if (hasPermissions(LYCHEE_UPLOADS_BIG)===false) $error .= ('Error 500: \'uploads/big\' missing or not readable and writable (777 required)' . PHP_EOL);
  57. if (hasPermissions(LYCHEE_UPLOADS_MEDIUM)===false) $error .= ('Error 500: \'uploads/medium\' missing or not readable and writable (777 required)' . PHP_EOL);
  58. if (hasPermissions(LYCHEE_UPLOADS_THUMB)===false) $error .= ('Error 501: \'uploads/thumb\' missing or not readable and writable (777 required)' . PHP_EOL);
  59. if (hasPermissions(LYCHEE_UPLOADS_IMPORT)===false) $error .= ('Error 502: \'uploads/import\' missing or not readable and writable (777 required)' . PHP_EOL);
  60. if (hasPermissions(LYCHEE_UPLOADS)===false) $error .= ('Error 503: \'uploads/\' missing or not readable and writable (777 required)' . PHP_EOL);
  61. if (hasPermissions(LYCHEE_DATA)===false) $error .= ('Error 504: \'data/\' missing or not readable and writable (777 required)' . PHP_EOL);
  62. # Check dropboxKey
  63. if (!$settings['dropboxKey']) echo('Warning: Dropbox import not working. No property for dropboxKey.' . PHP_EOL);
  64. # Check php.ini Settings
  65. 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);
  66. # Check mysql version
  67. 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);
  68. # Output
  69. if ($error=='') echo('No critical problems found. Lychee should work without problems!' . PHP_EOL);
  70. else echo $error;
  71. # Show separator
  72. echo(PHP_EOL . PHP_EOL . 'System Information' . PHP_EOL);
  73. echo('------------------' . PHP_EOL);
  74. # Load json
  75. $json = file_get_contents(LYCHEE_SRC . 'package.json');
  76. $json = json_decode($json, true);
  77. $imagick = extension_loaded('imagick');
  78. if ($imagick===false) $imagick = '-';
  79. if ($imagick===true) $imagickVersion = @Imagick::getVersion();
  80. if (!isset($imagickVersion, $imagickVersion['versionNumber'])||$imagickVersion==='') $imagickVersion = '-';
  81. else $imagickVersion = $imagickVersion['versionNumber'];
  82. $gdVersion = gd_info();
  83. # Output system information
  84. echo('Lychee Version: ' . $json['version'] . PHP_EOL);
  85. echo('DB Version: ' . $settings['version'] . PHP_EOL);
  86. echo('System: ' . PHP_OS . PHP_EOL);
  87. echo('PHP Version: ' . floatval(phpversion()) . PHP_EOL);
  88. echo('MySQL Version: ' . $database->server_version . PHP_EOL);
  89. echo('Imagick: ' . $imagick . PHP_EOL);
  90. echo('Imagick Active: ' . $settings['imagick'] . PHP_EOL);
  91. echo('Imagick Version: ' . $imagickVersion . PHP_EOL);
  92. echo('GD Version: ' . $gdVersion['GD Version'] . PHP_EOL);
  93. ?>