| Server IP : 23.254.227.96 / Your IP : 216.73.216.183 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/local/cwpsrv/var/services/pma/libraries/classes/ |
Upload File : |
<?php
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Utils\SessionCache;
use function is_array;
/**
* Statement resource usage.
*/
final class Profiling
{
public static function isSupported(DatabaseInterface $dbi): bool
{
if (SessionCache::has('profiling_supported')) {
return SessionCache::get('profiling_supported');
}
/**
* 5.0.37 has profiling but for example, 5.1.20 does not
* (avoid a trip to the server for MySQL before 5.0.37)
* and do not set a constant as we might be switching servers
*/
if ($dbi->fetchValue('SELECT @@have_profiling')) {
SessionCache::set('profiling_supported', true);
return true;
}
SessionCache::set('profiling_supported', false);
return false;
}
public static function enable(DatabaseInterface $dbi): void
{
if (! isset($_SESSION['profiling']) || ! self::isSupported($dbi)) {
return;
}
$dbi->query('SET PROFILING=1;');
}
/** @return array<string, string>|null */
public static function getInformation(DatabaseInterface $dbi): ?array
{
if (! isset($_SESSION['profiling']) || ! self::isSupported($dbi)) {
return null;
}
$result = $dbi->fetchResult('SHOW PROFILE;');
if (! is_array($result)) {
return null;
}
return $result;
}
/**
* Check if profiling was requested and remember it.
*/
public static function check(DatabaseInterface $dbi, Response $response): void
{
if (isset($_REQUEST['profiling']) && self::isSupported($dbi)) {
$_SESSION['profiling'] = true;
} elseif (isset($_REQUEST['profiling_form'])) {
// the checkbox was unchecked
unset($_SESSION['profiling']);
}
if (! isset($_SESSION['profiling'])) {
return;
}
$scripts = $response->getHeader()->getScripts();
$scripts->addFiles([
'chart.js',
'vendor/jqplot/jquery.jqplot.js',
'vendor/jqplot/plugins/jqplot.pieRenderer.js',
'vendor/jqplot/plugins/jqplot.highlighter.js',
'vendor/jquery/jquery.tablesorter.js',
]);
}
}