1 || php_sapi_name()=='cli' || empty($_server['remote_addr']) ) { die; } // weak block against indirect access $time=time(); define('cacheprefix',function_exists('opcache_reset')?'opcache_':(function_exists('accelerator_reset')?'accelerator_':'')); if ( !empty($_get['reset']) ) { if ( function_exists(cacheprefix.'reset') ) { call_user_func(cacheprefix.'reset'); } header( 'location: '.str_replace('?'.$_server['query_string'],'',$_server['request_uri']) ); exit; } if ( !empty($_get['recheck']) ) { if ( function_exists(cacheprefix.'invalidate') ) { $recheck=trim($_get['recheck']); $files=call_user_func(cacheprefix.'get_status'); if (!empty($files['scripts'])) { foreach ($files['scripts'] as $file=>$value) { if ( $recheck==='1' || strpos($file,$recheck)===0 ) call_user_func(cacheprefix.'invalidate',$file); } } header( 'location: '.str_replace('?'.$_server['query_string'],'',$_server['request_uri']) ); } else { echo 'sorry, this feature requires zend opcache newer than april 8th 2013'; } exit; } ?> ocp -凯发平台

ocp -凯发平台

details files reset recheck refresh
opcache not detected?'; die; } if ( !empty($_get['files']) ) { echo '

files cached

'; files_display(); echo '
'; exit; } if ( !(isset($_request['graphs']) && !$_request['graphs']) && cacheprefix=='opcache_') { graphs_display(); if ( !empty($_request['graphs']) ) { exit; } } 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 if ( !preg_match( '/module\_zend.(optimizer\ |opcache). ?(\]*\>. ?\<\/table\>). ?(\]*\>. ?\<\/table\>)/is', $phpinfo, $opcache) ) { } // todo if ( function_exists(cacheprefix.'get_configuration') ) { echo '

general

'; $configuration=call_user_func(cacheprefix.'get_configuration'); } $host=function_exists('gethostname')?@gethostname():@php_uname('n'); if (empty($host)) { $host=empty($_server['server_name'])?$_server['host_name']:$_server['server_name']; } $version=array('host'=>$host); $version['php version']='php '.(defined('php_version')?php_version:'???').' '.(defined('php_sapi')?php_sapi:'').' '.(defined('php_os')?' '.php_os:''); $version['opcache version']=empty($configuration['version']['version'])?'???':$configuration['version'][cacheprefix.'product_name'].' '.$configuration['version']['version']; print_table($version); if ( !empty($opcache[2]) ) { echo preg_replace('/\\[^>] \<\/td\>\[0-9\,\. ] \<\/td\>\<\/tr\>/','',$opcache[2]); } if ( function_exists(cacheprefix.'get_status') && $status=call_user_func(cacheprefix.'get_status') ) { $uptime=array(); if ( !empty($status[cacheprefix.'statistics']['start_time']) ) { $uptime['uptime']=time_since($time,$status[cacheprefix.'statistics']['start_time'],1,''); } if ( !empty($status[cacheprefix.'statistics']['last_restart_time']) ) { $uptime['last_restart']=time_since($time,$status[cacheprefix.'statistics']['last_restart_time']); } if (!empty($uptime)) {print_table($uptime);} if ( !empty($status['cache_full']) ) { $status['memory_usage']['cache_full']=$status['cache_full']; } echo '

memory

'; print_table($status['memory_usage']); unset($status[cacheprefix.'statistics']['start_time'],$status[cacheprefix.'statistics']['last_restart_time']); echo '

statistics

'; print_table($status[cacheprefix.'statistics']); } if ( empty($_get['all']) ) { meta_display(); exit; } if ( !empty($configuration['blacklist']) ) { echo '

blacklist

'; print_table($configuration['blacklist']); } if ( !empty($opcache[3]) ) { echo '

runtime

'; echo $opcache[3]; } $name='zend opcache'; $functions=get_extension_funcs($name); if (!$functions) { $name='zend optimizer '; $functions=get_extension_funcs($name); } if ($functions) { echo '

functions

'; print_table($functions); } else { $name=''; } $level=trim(cacheprefix,'_').'.optimization_level'; if (isset($configuration['directives'][$level])) { echo '

optimization levels

'; $levelset=strrev(base_convert($configuration['directives'][$level], 10, 2)); $levels=array( 1=>' (cse) true, false, null, etc.
optimize series of add_string / add_char
convert cast(is_bool,x) into bool(x)
convert into ', 2=>'convert constant operands to expected types
convert conditional with constant operands
optimize static and ', 3=>'convert $a = $a expr into $a = expr
convert $a into $a
optimize series of ', 4=>'print and echo optimization ()', 5=>'block optimization - most expensive pass
performs many different optimization patterns based on (cfg)', 9=>'optimize (allows re-usage of temporary variables)', 10=>'remove nops' ); echo ''; foreach ($levels as $pass=>$description) { $disabled=substr($levelset,$pass-1,1)!=='1' || $pass==4 ? ' white':''; echo ''; } echo '
passdescription
'.$pass.''.$description.'
'; } if ( isset($_get['dump']) ) { if ($name) { echo '

ini

'; print_table(ini_get_all($name,true)); } foreach ($configuration as $key=>$value) { echo '

',$key,'

'; print_table($configuration[$key]); } exit; } meta_display(); echo ''; exit; function time_since($time,$original,$extended=0,$text='ago') { $time = $time - $original; $day = $extended? floor($time/86400) : round($time/86400,0); $amount=0; $unit=''; if ( $time < 86400) { if ( $time < 60) { $amount=$time; $unit='second'; } elseif ( $time < 3600) { $amount=floor($time/60); $unit='minute'; } else { $amount=floor($time/3600); $unit='hour'; } } elseif ( $day < 14) { $amount=$day; $unit='day'; } elseif ( $day < 56) { $amount=floor($day/7); $unit='week'; } elseif ( $day < 672) { $amount=floor($day/30); $unit='month'; } else { $amount=intval(2*($day/365))/2; $unit='year'; } if ( $amount!=1) {$unit.='s';} if ($extended && $time>60) { $text=' and '.time_since($time,$time<86400?($time<3600?$amount*60:$amount*3600):$day*86400,0,'').$text; } return $amount.' '.$unit.' '.$text; } function print_table($array,$headers=false) { if ( empty($array) || !is_array($array) ) {return;} echo ''; if (!empty($headers)) { if (!is_array($headers)) {$headers=array_keys(reset($array));} echo ''; foreach ($headers as $value) { echo ''; } echo ''; } foreach ($array as $key=>$value) { echo ''; if ( !is_numeric($key) ) { $key=ucwords(str_replace('_',' ',$key)); echo ''; if ( is_numeric($value) ) { if ( $value>1048576) { $value=round($value/1048576,1).'m'; } elseif ( is_float($value) ) { $value=round($value,1); } } } if ( is_array($value) ) { foreach ($value as $column) { echo ''; } echo ''; } else { echo ''; } } echo '
',$value,'
',$key,'',$column,'
',$value,'
'; } function files_display() { $status=call_user_func(cacheprefix.'get_status'); if ( empty($status['scripts']) ) {return;} if ( isset($_get['dump']) ) { print_table($status['scripts']); exit;} $time=time(); $sort=0; $nogroup=preg_replace('/\&?group\=[\-0-9] /','',$_server['request_uri']); $nosort=preg_replace('/\&?sort\=[\-0-9] /','',$_server['request_uri']); $group=empty($_get['group'])?0:intval($_get['group']); if ( $group<0 || $group>9) { $group=1;} $groupset=array_fill(0,9,''); $groupset[$group]=' class="b" '; echo '
| | | | |
'; if ( !$group ) { $files =& $status['scripts']; } else { $files=array(); foreach ($status['scripts'] as $data) { if ( preg_match('@^[/]([^/] [/]){'.$group.'}@',$data['full_path'],$path) ) { if ( empty($files[$path[0]])) { $files[$path[0]]=array('full_path'=>'','files'=>0,'hits'=>0,'memory_consumption'=>0,'last_used_timestamp'=>'','timestamp'=>''); } $files[$path[0]]['full_path']=$path[0]; $files[$path[0]]['files'] ; $files[$path[0]]['memory_consumption'] =$data['memory_consumption']; $files[$path[0]]['hits'] =$data['hits']; if ( $data['last_used_timestamp']>$files[$path[0]]['last_used_timestamp']) {$files[$path[0]]['last_used_timestamp']=$data['last_used_timestamp'];} if ( $data['timestamp']>$files[$path[0]]['timestamp']) {$files[$path[0]]['timestamp']=$data['timestamp'];} } } } if ( !empty($_get['sort']) ) { $keys=array( 'full_path'=>sort_string, 'files'=>sort_numeric, 'memory_consumption'=>sort_numeric, 'hits'=>sort_numeric, 'last_used_timestamp'=>sort_numeric, 'timestamp'=>sort_numeric ); $titles=array('','path',$group?'files':'','size','hits','last used','created'); $offsets=array_keys($keys); $key=intval($_get['sort']); $direction=$key>0?1:-1; $key=abs($key)-1; $key=isset($offsets[$key])&&!($key==1&&empty($group))?$offsets[$key]:reset($offsets); $sort=array_search($key,$offsets) 1; $sortflip=range(0,7); $sortflip[$sort]=-$direction*$sort; if ( $keys[$key]==sort_string) {$direction=-$direction; } $arrow=array_fill(0,7,''); $arrow[$sort]=$direction>0?' ▼':' ▲'; $direction=$direction>0?sort_desc:sort_asc; $column=array(); foreach ($files as $data) { $column[]=$data[$key]; } array_multisort($column, $keys[$key], $direction, $files); } echo ''; foreach ($titles as $column=>$title) { if ($title) echo ''; } echo ' '; foreach ($files as $data) { echo '', ($group?'':''), '', '', '', ''; } echo '
x',$data['full_path'],''.number_format($data['files']).'',number_format(round($data['memory_consumption']/1024)),'k',number_format($data['hits']),'',time_since($time,$data['last_used_timestamp']),'',empty($data['timestamp'])?'':time_since($time,$data['timestamp']),'
'; } function graphs_display() { $graphs=array(); $colors=array('green','brown','red'); $primes=array(223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987); $configuration=call_user_func(cacheprefix.'get_configuration'); $status=call_user_func(cacheprefix.'get_status'); $graphs['memory']['total']=$configuration['directives']['opcache.memory_consumption']; $graphs['memory']['free']=$status['memory_usage']['free_memory']; $graphs['memory']['used']=$status['memory_usage']['used_memory']; $graphs['memory']['wasted']=$status['memory_usage']['wasted_memory']; $graphs['keys']['total']=$status[cacheprefix.'statistics']['max_cached_keys']; foreach ($primes as $prime) { if ($prime>=$graphs['keys']['total']) { $graphs['keys']['total']=$prime; break;} } $graphs['keys']['free']=$graphs['keys']['total']-$status[cacheprefix.'statistics']['num_cached_keys']; $graphs['keys']['scripts']=$status[cacheprefix.'statistics']['num_cached_scripts']; $graphs['keys']['wasted']=$status[cacheprefix.'statistics']['num_cached_keys']-$status[cacheprefix.'statistics']['num_cached_scripts']; $graphs['hits']['total']=0; $graphs['hits']['hits']=$status[cacheprefix.'statistics']['hits']; $graphs['hits']['misses']=$status[cacheprefix.'statistics']['misses']; $graphs['hits']['blacklist']=$status[cacheprefix.'statistics']['blacklist_misses']; $graphs['hits']['total']=array_sum($graphs['hits']); $graphs['restarts']['total']=0; $graphs['restarts']['manual']=$status[cacheprefix.'statistics']['manual_restarts']; $graphs['restarts']['keys']=$status[cacheprefix.'statistics']['hash_restarts']; $graphs['restarts']['memory']=$status[cacheprefix.'statistics']['oom_restarts']; $graphs['restarts']['total']=array_sum($graphs['restarts']); foreach ( $graphs as $caption=>$graph) { echo '
',$caption,'
'; foreach ($graph as $label=>$value) { if ($label=='total') { $key=0; $total=$value; $totaldisplay=''; continue;} $percent=$total?floor($value*100/$total):''; $percent=!$percent||$percent>99?'':$percent.'%'; echo '',$totaldisplay,''; $key ; $totaldisplay=''; } echo '
'.($total>999999?round($total/1024/1024).'m':($total>9999?round($total/1024).'k':$total)).'
', ($value>999999?round($value/1024/1024).'m':($value>9999?round($value/1024).'k':$value)),'',$percent,'',$label,'
',"\n"; } } function meta_display() { ?>
| | | | |
网站地图