initial commit

This commit is contained in:
2026-06-25 13:03:45 +06:00
commit 4589f4a8d0
3229 changed files with 941958 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*
*/
App::uses('DebugPanel', 'DebugKit.Lib');
/**
* Provides information about your PHP and CakePHP environment to assist with debugging.
*
*/
class EnvironmentPanel extends DebugPanel {
/**
* beforeRender - Get necessary data about environment to pass back to controller
*
* @param Controller $controller
* @return array
*/
public function beforeRender(Controller $controller) {
parent::beforeRender($controller);
$return = array();
// PHP Data
$phpVer = phpversion();
$return['php'] = array_merge(array('PHP_VERSION' => $phpVer), $_SERVER);
unset($return['php']['argv']);
// CakePHP Data
$return['cake'] = array(
'APP' => APP,
'APP_DIR' => APP_DIR,
'APPLIBS' => APPLIBS,
'CACHE' => CACHE,
'CAKE' => CAKE,
'CAKE_CORE_INCLUDE_PATH' => CAKE_CORE_INCLUDE_PATH,
'CORE_PATH' => CORE_PATH,
'CAKE_VERSION' => Configure::version(),
'CSS' => CSS,
'CSS_URL' => CSS_URL,
'DS' => DS,
'FULL_BASE_URL' => FULL_BASE_URL,
'IMAGES' => IMAGES,
'IMAGES_URL' => IMAGES_URL,
'JS' => JS,
'JS_URL' => JS_URL,
'LOGS' => LOGS,
'ROOT' => ROOT,
'TESTS' => TESTS,
'TMP' => TMP,
'VENDORS' => VENDORS,
'WEBROOT_DIR' => WEBROOT_DIR,
'WWW_ROOT' => WWW_ROOT
);
$cakeConstants = array_fill_keys(
array(
'DS', 'ROOT', 'FULL_BASE_URL', 'TIME_START', 'SECOND', 'MINUTE', 'HOUR', 'DAY', 'WEEK', 'MONTH', 'YEAR',
'LOG_ERROR', 'FULL_BASE_URL'
), ''
);
$var = get_defined_constants(true);
$return['app'] = array_diff_key($var['user'], $return['cake'], $cakeConstants);
if (isset($var['hidef'])) {
$return['hidef'] = $var['hidef'];
}
return $return;
}
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('DebugPanel', 'DebugKit.Lib');
/**
* Provides debug information on previous requests.
*
*/
class HistoryPanel extends DebugPanel {
/**
* Number of history elements to keep
*
* @var string
*/
public $history = 5;
/**
* Constructor
*
* @param array $settings Array of settings.
* @return \HistoryPanel
*/
public function __construct($settings) {
if (isset($settings['history'])) {
$this->history = $settings['history'];
}
}
/**
* beforeRender callback function
*
* @param Controller $controller
* @return array contents for panel
*/
public function beforeRender(Controller $controller) {
$cacheKey = $controller->Toolbar->cacheKey;
$toolbarHistory = Cache::read($cacheKey, 'debug_kit');
$historyStates = array();
if (is_array($toolbarHistory) && !empty($toolbarHistory)) {
$prefix = array();
if (!empty($controller->request->params['prefix'])) {
$prefix[$controller->request->params['prefix']] = false;
}
foreach ($toolbarHistory as $i => $state) {
if (!isset($state['request']['content']['url'])) {
continue;
}
$title = $state['request']['content']['url'];
$query = @$state['request']['content']['query'];
if (isset($query['url'])) {
unset($query['url']);
}
if (!empty($query)) {
$title .= '?' . urldecode(http_build_query($query));
}
$historyStates[] = array(
'title' => $title,
'url' => array_merge($prefix, array(
'plugin' => 'debug_kit',
'controller' => 'toolbar_access',
'action' => 'history_state',
$i + 1))
);
}
}
if (count($historyStates) >= $this->history) {
array_pop($historyStates);
}
return $historyStates;
}
}

View File

@@ -0,0 +1,160 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('DebugPanel', 'DebugKit.Lib');
/**
* Provides a list of included files for the current request
*
*/
class IncludePanel extends DebugPanel {
/**
* The list of plugins within the application
*
* @var <type>
*/
protected $_pluginPaths = array();
/**
* File Types
*
* @var array
*/
protected $_fileTypes = array(
'Cache', 'Config', 'Configure', 'Console', 'Component', 'Controller',
'Behavior', 'Datasource', 'Model', 'Plugin', 'Test', 'View', 'Utility',
'Network', 'Routing', 'I18n', 'Log', 'Error'
);
/**
* Get a list of plugins on construct for later use
*/
public function __construct() {
foreach (CakePlugin::loaded() as $plugin) {
$this->_pluginPaths[$plugin] = CakePlugin::path($plugin);
}
parent::__construct();
}
/**
* Get a list of files that were included and split them out into the various parts of the app
*
* @param Controller $controller
* @return array
*/
public function beforeRender(Controller $controller) {
$return = array('core' => array(), 'app' => array(), 'plugins' => array());
foreach (get_included_files() as $file) {
$pluginName = $this->_isPluginFile($file);
if ($pluginName) {
$return['plugins'][$pluginName][$this->_getFileType($file)][] = $this->_niceFileName($file, $pluginName);
} elseif ($this->_isAppFile($file)) {
$return['app'][$this->_getFileType($file)][] = $this->_niceFileName($file, 'app');
} elseif ($this->_isCoreFile($file)) {
$return['core'][$this->_getFileType($file)][] = $this->_niceFileName($file, 'core');
}
}
$return['paths'] = $this->_includePaths();
ksort($return['core']);
ksort($return['plugins']);
ksort($return['app']);
return $return;
}
/**
* Get the possible include paths
* @return array
*/
protected function _includePaths() {
$paths = array_flip(array_merge(explode(PATH_SEPARATOR, get_include_path()), array(CAKE)));
unset($paths['.']);
return array_flip($paths);
}
/**
* Check if a path is part of cake core
* @param string $file
* @return boolean
*/
protected function _isCoreFile($file) {
return strstr($file, CAKE);
}
/**
* Check if a path is from APP but not a plugin
* @param string $file
* @return boolean
*/
protected function _isAppFile($file) {
return strstr($file, APP);
}
/**
* Check if a path is from a plugin
* @param string $file
* @return boolean
*/
protected function _isPluginFile($file) {
foreach ($this->_pluginPaths as $plugin => $path) {
if (strstr($file, $path)) {
return $plugin;
}
}
return false;
}
/**
* Replace the path with APP, CORE or the plugin name
* @param string $file
* @param string
* - app for app files
* - core for core files
* - PluginName for the name of a plugin
* @return boolean
*/
protected function _niceFileName($file, $type) {
switch ($type) {
case 'app':
return str_replace(APP, 'APP/', $file);
case 'core':
return str_replace(CAKE, 'CORE/', $file);
default:
return str_replace($this->_pluginPaths[$type], $type . '/', $file);
}
}
/**
* Get the type of file (model, controller etc)
* @param string $file
* @return string
*/
protected function _getFileType($file) {
foreach ($this->_fileTypes as $type) {
if (stripos($file, '/' . $type . '/') !== false) {
return $type;
}
}
return 'Other';
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('DebugPanel', 'DebugKit.Lib');
/**
* Log Panel - Reads log entries made this request.
*
*/
class LogPanel extends DebugPanel {
/**
* Constructor - sets up the log listener.
*
* @return \LogPanel
*/
public function __construct() {
parent::__construct();
$existing = CakeLog::configured();
if (empty($existing)) {
CakeLog::config('default', array(
'engine' => 'FileLog'
));
}
CakeLog::config('debug_kit_log_panel', array(
'engine' => 'DebugKit.DebugKitLog',
'panel' => $this
));
}
/**
* beforeRender Callback
*
* @param Controller $controller
* @return array
*/
public function beforeRender(Controller $controller) {
$logger = $this->logger;
return $logger;
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('DebugPanel', 'DebugKit.Lib');
/**
* Provides debug information on the Current request params.
*
*/
class RequestPanel extends DebugPanel {
/**
* beforeRender callback - grabs request params
*
* @param Controller $controller
* @return array
*/
public function beforeRender(Controller $controller) {
$out = array();
$out['params'] = $controller->request->params;
$out['url'] = $controller->request->url;
$out['query'] = $controller->request->query;
$out['data'] = $controller->request->data;
if (isset($controller->Cookie)) {
$out['cookie'] = $controller->Cookie->read();
}
$out['get'] = $_GET;
$out['currentRoute'] = Router::currentRoute();
return $out;
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('DebugPanel', 'DebugKit.Lib');
/**
* Provides debug information on the Session contents.
*
*/
class SessionPanel extends DebugPanel {
/**
* beforeRender callback
*
* @param \Controller|object $controller
* @return array
*/
public function beforeRender(Controller $controller) {
$sessions = $controller->Toolbar->Session->read();
return $sessions;
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('DebugPanel', 'DebugKit.Lib');
/**
* Provides debug information on the SQL logs and provides links to an ajax explain interface.
*
*/
class SqlLogPanel extends DebugPanel {
/**
* Minimum number of Rows Per Millisecond that must be returned by a query before an explain
* is done.
*
* @var integer
*/
public $slowRate = 20;
/**
* Gets the connection names that should have logs + dumps generated.
*
* @param \Controller|string $controller
* @return array
*/
public function beforeRender(Controller $controller) {
if (!class_exists('ConnectionManager')) {
return array();
}
$connections = array();
$dbConfigs = ConnectionManager::sourceList();
foreach ($dbConfigs as $configName) {
$driver = null;
$db = ConnectionManager::getDataSource($configName);
if (
(empty($db->config['driver']) && empty($db->config['datasource'])) ||
!method_exists($db, 'getLog')
) {
continue;
}
if (isset($db->config['datasource'])) {
$driver = $db->config['datasource'];
}
$explain = false;
$isExplainable = (preg_match('/(Mysql|Postgres)$/', $driver));
if ($isExplainable) {
$explain = true;
}
$connections[$configName] = $explain;
}
return array('connections' => $connections, 'threshold' => $this->slowRate);
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('DebugPanel', 'DebugKit.Lib');
/**
* Provides debug information on all timers used in a request.
*
*/
class TimerPanel extends DebugPanel {
/**
* startup - add in necessary helpers
*
* @param Controller $controller
* @return void
*/
public function startup(Controller $controller) {
if (!in_array('Number', array_keys(HelperCollection::normalizeObjectArray($controller->helpers)))) {
$controller->helpers[] = 'Number';
}
if (!in_array('SimpleGraph', array_keys(HelperCollection::normalizeObjectArray($controller->helpers)))) {
$controller->helpers[] = 'DebugKit.SimpleGraph';
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('DebugPanel', 'DebugKit.Lib');
/**
* Provides debug information on the View variables.
*
*/
class VariablesPanel extends DebugPanel {
/**
* beforeRender callback
*
* @param Controller $controller
* @return array
*/
public function beforeRender(Controller $controller) {
return array_merge($controller->viewVars, array('$request->data' => $controller->request->data));
}
}