daily pastebin goal
89%
SHARE
TWEET

Untitled

a guest Sep 23rd, 2013 280 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- ocp.php.orig        Mon Sep 23 15:51:24 2013
  2. +++ ocp.php     Mon Sep 23 15:57:16 2013
  3. @@ -31,23 +31,41 @@
  4.  */
  5.  
  6.  // ini_set('display_errors',1); error_reporting(-1);
  7. -if ( count(get_included_files())>1 || php_sapi_name()=='cli' || empty($_SERVER['REMOTE_ADDR']) ) { die; }  // weak block against indirect access
  8. +$max_included_files = 1;
  9. +if ( ini_get('auto_prepend_file') ) ++$max_included_files;
  10. +if ( count(get_included_files())>$max_included_files || getcwd() != dirname(__FILE__) || php_sapi_name()=='cli' || empty($_SERVER['REMOTE_ADDR']) ) { die; }  // weak block against indirect access
  11.  
  12.  $time=time();
  13.  define('CACHEPREFIX',function_exists('opcache_reset')?'opcache_':(function_exists('accelerator_reset')?'accelerator_':''));
  14.  
  15. +function ocp_function_exists($function_name)
  16. +{
  17. +       if ( CACHEPREFIX == '' ) {
  18. +               return false;
  19. +       }
  20. +       return function_exists(CACHEPREFIX.$function_name);
  21. +}
  22. +
  23. +function ocp_call_user_func($function_name)
  24. +{
  25. +       if ( CACHEPREFIX == '' ) {
  26. +               return false;
  27. +       }
  28. +       return call_user_func(CACHEPREFIX.$function_name);
  29. +}
  30. +
  31.  if ( !empty($_GET['RESET']) ) {       
  32. -       if ( function_exists(CACHEPREFIX.'reset') ) { call_user_func(CACHEPREFIX.'reset'); }
  33. +       if ( ocp_function_exists('reset') ) { ocp_call_user_func('reset'); }
  34.         header( 'Location: '.str_replace('?'.$_SERVER['QUERY_STRING'],'',$_SERVER['REQUEST_URI']) );
  35.         exit;
  36.  }
  37.  
  38.  if ( !empty($_GET['RECHECK']) ) {
  39. -       if ( function_exists(CACHEPREFIX.'invalidate') ) {
  40. -               $recheck=trim($_GET['RECHECK']); $files=call_user_func(CACHEPREFIX.'get_status');
  41. +       if ( ocp_function_exists('invalidate') ) {
  42. +               $recheck=trim($_GET['RECHECK']); $files=ocp_call_user_func('get_status');
  43.                 if (!empty($files['scripts'])) {
  44.                         foreach ($files['scripts'] as $file=>$value) {
  45. -                               if ( $recheck==='1' || strpos($file,$recheck)===0 )  call_user_func(CACHEPREFIX.'invalidate',$file);
  46. +                               if ( $recheck==='1' || strpos($file,$recheck)===0 )  ocp_call_user_func('invalidate',$file);
  47.                         }
  48.                 }
  49.                 header( 'Location: '.str_replace('?'.$_SERVER['QUERY_STRING'],'',$_SERVER['REQUEST_URI']) );
  50. @@ -117,7 +135,7 @@
  51.         <a href="?ALL=1">Details</a>
  52.         <a href="?FILES=1&GROUP=2&SORT=3">Files</a>
  53.         <a href="?RESET=1" onclick="return confirm('RESET cache ?')">Reset</a>
  54. -       <?php if ( function_exists(CACHEPREFIX.'invalidate') ) { ?>
  55. +       <?php if ( ocp_function_exists('invalidate') ) { ?>
  56.         <a href="?RECHECK=1" onclick="return confirm('Recheck all files in the cache ?')">Recheck</a>
  57.         <?php } ?>
  58.         <a href="?" onclick="window.location.reload(true); return false">Refresh</a>
  59. @@ -125,7 +143,7 @@
  60.  
  61.  <?php
  62.  
  63. -if ( !function_exists(CACHEPREFIX.'get_status') ) { echo '<h2>Opcache not detected?</h2>'; die; }
  64. +if ( !ocp_function_exists('get_status') ) { echo '<h2>Opcache not detected?</h2>'; die; }
  65.  
  66.  if ( !empty($_GET['FILES']) ) { echo '<h2>files cached</h2>'; files_display(); echo '</div></body></html>'; exit; }
  67.  
  68. @@ -134,7 +152,7 @@
  69.  ob_start(); phpinfo(8); $phpinfo = ob_get_contents(); ob_end_clean();           // some info is only available via phpinfo? sadly buffering capture has to be used
  70.  if ( !preg_match( '/module\_Zend (Optimizer\+|OPcache).+?(\<table[^>]*\>.+?\<\/table\>).+?(\<table[^>]*\>.+?\<\/table\>)/s', $phpinfo, $opcache) ) { }  // todo
  71.  
  72. -if ( function_exists(CACHEPREFIX.'get_configuration') ) { echo '<h2>general</h2>'; $configuration=call_user_func(CACHEPREFIX.'get_configuration'); }
  73. +if ( ocp_function_exists('get_configuration') ) { echo '<h2>general</h2>'; $configuration=ocp_call_user_func('get_configuration'); }
  74.  
  75.  $host=function_exists('gethostname')?@gethostname():@php_uname('n'); if (empty($host)) { $host=empty($_SERVER['SERVER_NAME'])?$_SERVER['HOST_NAME']:$_SERVER['SERVER_NAME']; }
  76.  $version=array('Host'=>$host);
  77. @@ -144,7 +162,7 @@
  78.  
  79.  if ( !empty($opcache[2]) ) { echo preg_replace('/\<tr\>\<td class\="e"\>[^>]+\<\/td\>\<td class\="v"\>[0-9\,\. ]+\<\/td\>\<\/tr\>/','',$opcache[2]); }
  80.  
  81. -if ( function_exists(CACHEPREFIX.'get_status') && $status=call_user_func(CACHEPREFIX.'get_status') ) {
  82. +if ( ocp_function_exists('get_status') && $status=ocp_call_user_func('get_status') ) {
  83.         $uptime=array();
  84.         if ( !empty($status[CACHEPREFIX.'statistics']['start_time']) ) {
  85.                 $uptime['uptime']=time_since($time,$status[CACHEPREFIX.'statistics']['start_time'],1,'');
  86. @@ -257,7 +275,7 @@
  87.  }
  88.  
  89.  function files_display() {                    
  90. -       $status=call_user_func(CACHEPREFIX.'get_status');
  91. +       $status=ocp_call_user_func('get_status');
  92.         if ( empty($status['scripts']) ) {return;}
  93.         if ( isset($_GET['DUMP']) ) { print_table($status['scripts']); exit;}
  94.         $time=time(); $sort=0;
  95. @@ -338,8 +356,8 @@
  96.         $graphs=array();
  97.         $colors=array('green','brown','red');
  98.         $primes=array(223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987);
  99. -       $configuration=call_user_func(CACHEPREFIX.'get_configuration');
  100. -       $status=call_user_func(CACHEPREFIX.'get_status');
  101. +       $configuration=ocp_call_user_func('get_configuration');
  102. +       $status=ocp_call_user_func('get_status');
  103.  
  104.         $graphs['memory']['total']=$configuration['directives']['opcache.memory_consumption'];
  105.         $graphs['memory']['free']=$status['memory_usage']['free_memory'];
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top