template.phps 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * OPcache GUI
  4. *
  5. * A simple but effective single-file GUI for the OPcache PHP extension.
  6. *
  7. * @author Andrew Collington, andy@amnuts.com
  8. * @version 3.5.5
  9. * @link https://github.com/amnuts/opcache-gui
  10. * @license MIT, https://acollington.mit-license.org/
  11. */
  12. /*
  13. * User configuration
  14. * These are all the default values; you only really need to supply the ones
  15. * that you wish to change.
  16. */
  17. $options = [
  18. 'allow_filelist' => true, // show/hide the files tab
  19. 'allow_invalidate' => true, // give a link to invalidate files
  20. 'allow_reset' => true, // give option to reset the whole cache
  21. 'allow_realtime' => true, // give option to enable/disable real-time updates
  22. 'refresh_time' => 5, // how often the data will refresh, in seconds
  23. 'size_precision' => 2, // Digits after decimal point
  24. 'size_space' => false, // have '1MB' or '1 MB' when showing sizes
  25. 'charts' => true, // show gauge chart or just big numbers
  26. 'debounce_rate' => 250, // milliseconds after key press to send keyup event when filtering
  27. 'per_page' => 200, // How many results per page to show in the file list, false for no pagination
  28. 'cookie_name' => 'opcachegui', // name of cookie
  29. 'cookie_ttl' => 365, // days to store cookie
  30. 'datetime_format' => 'D, d M Y H:i:s O', // Show datetime in this format
  31. 'highlight' => [
  32. 'memory' => true, // show the memory chart/big number
  33. 'hits' => true, // show the hit rate chart/big number
  34. 'keys' => true, // show the keys used chart/big number
  35. 'jit' => true // show the jit buffer chart/big number
  36. ],
  37. // json structure of all text strings used, or null for default
  38. 'language_pack' => {{LANGUAGE_PACK}}
  39. ];
  40. /*
  41. * Shouldn't need to alter anything else below here
  42. */
  43. if (!extension_loaded('Zend OPcache')) {
  44. die('The Zend OPcache extension does not appear to be installed');
  45. }
  46. $ocEnabled = ini_get('opcache.enable');
  47. if (empty($ocEnabled)) {
  48. die('The Zend OPcache extension is installed but not active');
  49. }
  50. header('Cache-Control: no-cache, must-revalidate');
  51. header('Pragma: no-cache');
  52. {{PHP_OUTPUT}}
  53. $opcache = (new Service($options))->handle();
  54. ?>
  55. <!DOCTYPE html>
  56. <html lang="en">
  57. <head>
  58. <meta charset="UTF-8">
  59. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  60. <meta name="robots" content="noindex, nofollow" />
  61. <title>OPcache statistics on <?= $opcache->getData('version', 'host'); ?></title>
  62. {{JS_LIBRARIES}}
  63. <style>
  64. {{CSS_OUTPUT}}
  65. </style>
  66. </head>
  67. <body style="padding: 0; margin: 0;">
  68. <div class="opcache-gui" id="interface" />
  69. <script type="text/javascript">
  70. {{JS_OUTPUT}}
  71. ReactDOM.render(React.createElement(Interface, {
  72. allow: {
  73. filelist: <?= $opcache->getOption('allow_filelist') ? 'true' : 'false'; ?>,
  74. invalidate: <?= $opcache->getOption('allow_invalidate') ? 'true' : 'false'; ?>,
  75. reset: <?= $opcache->getOption('allow_reset') ? 'true' : 'false'; ?>,
  76. realtime: <?= $opcache->getOption('allow_realtime') ? 'true' : 'false'; ?>
  77. },
  78. cookie: {
  79. name: '<?= $opcache->getOption('cookie_name'); ?>',
  80. ttl: <?= $opcache->getOption('cookie_ttl'); ?>
  81. },
  82. opstate: <?= json_encode($opcache->getData()); ?>,
  83. useCharts: <?= json_encode($opcache->getOption('charts')); ?>,
  84. highlight: <?= json_encode($opcache->getOption('highlight')); ?>,
  85. debounceRate: <?= $opcache->getOption('debounce_rate'); ?>,
  86. perPageLimit: <?= json_encode($opcache->getOption('per_page')); ?>,
  87. realtimeRefresh: <?= json_encode($opcache->getOption('refresh_time')); ?>,
  88. language: <?= json_encode($opcache->getOption('language_pack')); ?>,
  89. }), document.getElementById('interface'));
  90. </script>
  91. </body>
  92. </html>