yf_admin_home admin moduleAdministrators home page.
| File | plugins/admin_home/admin_modules/yf_admin_home.class.php |
|---|---|
| Use | admin URL ?object=admin_home |
A site sets them in its config with $PROJECT_CONF['admin_home']['NAME'] = ...;
| Property | Default | Description |
|---|---|---|
$ADMIN_HOME_CACHE_TIMEint |
600 |
|
$CACHE_NAMEstring |
'admin_statistics' |
@conf_skip |
$DISPLAY_STATSbool |
false |
|
$SHOW_CUR_SETTINGS |
null |
|
$SHOW_GENERAL_INFO |
null |
|
$SUPERADMIN_ONLYbool |
false |
When true, only super-admins (ADMIN_GROUP 1) may use this action |
public function clear_core_cache()
Helper method.
public function clear_core_cache()
{
_class('cache')->_clear_cache_files();
return js_redirect('./?object=' . ($_GET['object'] ?? null));
}
public function show()
public function show()
{
if (main()->ADMIN_GROUP != 1) {
$url = null;
$admin_user = db()->get('SELECT * FROM ' . db('admin') . ' WHERE id=' . (int) main()->ADMIN_ID);
if ($admin_user['go_after_login']) {
$url = $admin_user['go_after_login'];
} else {
$admin_group = db()->get('SELECT * FROM ' . db('admin_groups') . ' WHERE id=' . (int) main()->ADMIN_GROUP);
if ($admin_group['go_after_login']) {
$url = $admin_group['go_after_login'];
}
}
if ($url) {
return js_redirect($url);
}
}
return '';
}
public function show_old()
public function show_old()
{
$admin_statistics_array = null;
// Path to project.conf.php
$proj_conf_path = INCLUDE_PATH . 'project_conf.php';
$cur_settings = null;
$general_info = null;
$statistics = null;
$admin_statistics_array = null;
if ($this->SHOW_CUR_SETTINGS && ($_SESSION['admin_group'] ?? null) == 1) {
// Current settings
$replace2 = [
'rewrite_mode' => (int) conf('rewrite_mode'),
'output_caching' => (int) conf('output_caching'),
// "gzip_compress" => (int)conf("gzip_compress"),
// "compress_output" => (int)conf("compress_output"),
'language' => _prepare_html(strtoupper(conf('language'))),
'charset' => _prepare_html(strtoupper(conf('charset'))),
'admin_email' => _prepare_html(conf('admin_email')),
'mail_debug' => (int) conf('mail_debug'),
'site_enabled' => (int) conf('site_enabled'),
'settings_link' => $this->_url_allowed('./?object=settings'),
];
$cur_settings = tpl()->parse(($_GET['object'] ?? null) . '/cur_settings', $replace2);
} else {
$this->DISPLAY_STATS = false;
}
if ($this->DISPLAY_STATS) {
$admin_statistics_array = cache_get($this->CACHE_NAME, $this->ADMIN_HOME_CACHE_TIME);
}
if ($this->DISPLAY_STATS && empty($admin_statistics_array)) {
// General info
$db_size = 0;
$Q = db()->query('SHOW TABLE STATUS FROM ' . DB_NAME . '');
while ($A = db()->fetch_assoc($Q)) {
$db_size += $A['Data_length'];
}
$admin_statistics_array['db_size'] = common()->format_file_size($db_size);
$admin_statistics_array['project_dir_size'] = common()->format_file_size(_class('dir')->dirsize(INCLUDE_PATH));
// Statistics
$A = db()->query_fetch_all('SELECT * FROM ' . db('user_groups') . " WHERE active='1'");
$sql_parts[] = "SELECT 'total_users' AS '0', COUNT(id) AS '1' FROM " . db('user') . " WHERE active='1'";
foreach ((array) $A as $V1) {
$sql_parts[] = "SELECT 'total_" . strtolower($V1['name']) . "' AS '0', COUNT(id) AS '1' FROM " . db('user') . " WHERE `group`='" . $V1['id'] . "' AND active='1'";
}
$sql_parts2 = [
"SELECT 'forum_topics' AS '0', COUNT(id) AS '1' FROM " . db('forum_topics') . ' WHERE 1=1',
"SELECT 'forum_posts' AS '0', COUNT(id) AS '1' FROM " . db('forum_posts') . ' WHERE 1=1',
"SELECT 'gallery_photos' AS '0', COUNT(id) AS '1' FROM " . db('gallery_photos') . ' WHERE 1=1',
"SELECT 'blog_posts' AS '0', COUNT(id) AS '1' FROM " . db('blog_posts') . ' WHERE 1=1',
"SELECT 'articles' AS '0', COUNT(id) AS '1' FROM " . db('articles_texts') . ' WHERE 1=1',
];
$sql_parts = array_merge($sql_parts, $sql_parts2);
$sql = "(\r\n" . implode("\r\n) UNION ALL (\r\n", $sql_parts) . "\r\n)";
$B = db()->query_fetch_all($sql);
foreach ((array) $B as $V) {
$admin_statistics_array[$V[0]] = $V[1];
}
cache_set($this->CACHE_NAME, $admin_statistics_array);
}
if ($this->DISPLAY_STATS) {
$statistics = tpl()->parse(($_GET['object'] ?? null) . '/statistics', $admin_statistics_array);
}
if ($this->SHOW_GENERAL_INFO && $_SESSION['admin_group'] == 1) {
$replace3 = [
'php_ver' => phpversion(),
'mysql_serv_ver' => db()->get_server_version(),
'mysql_host_info' => db()->get_host_info(),
'db_name' => DB_NAME,
'db_size' => $admin_statistics_array['db_size'],
'project_dir_size' => $admin_statistics_array['project_dir_size'],
];
$general_info = tpl()->parse($_GET['object'] . '/general_info', $replace3);
}
$replace = [
'proj_conf_link' => file_exists($proj_conf_path) ? './?object=file_manager&action=edit_item&f_=' . basename($proj_conf_path) . '&dir_name=' . urlencode(dirname($proj_conf_path)) : '',
'current_date' => _format_date(time(), 'long'),
'my_id' => ($_SESSION['admin_id'] ?? null),
'cur_settings' => $cur_settings,
'general_info' => $general_info,
'statistics' => $statistics,
'cache_time' => ceil($this->ADMIN_HOME_CACHE_TIME / 60),
'custom_content' => $this->_custom_content(),
'suggests' => $this->_show_suggesting_messages(),
// Common actions here
];
return tpl()->parse(($_GET['object'] ?? null) . '/main', $replace);
}
public function show_php_info()
Display php info.
public function show_php_info()
{
if ($this->SUPERADMIN_ONLY && main()->ADMIN_GROUP != 1) {
return _class('graphics')->_action_on_block_denied('center_area') ?: '';
}
main()->NO_GRAPHICS = true;
phpinfo();
}
_ hooks and helpers; not routable as page actionspublic function _custom_content()
Custom content specific only for this project (designed to be inherited).
public function _custom_content()
{
}
public function _hook_settings(&$selected = [])
public function _hook_settings(&$selected = [])
{
return [];
}
public function _init()
public function _init()
{
}
public function _show_suggesting_messages()
public function _show_suggesting_messages()
{
$admin_modules = module('admin_modules')->_get_modules();
$user_modules_methods = module('admin_modules')->_get_methods(['private' => '1']);
$suggests = [];
foreach ((array) $user_modules_methods as $module_name => $module_methods) {
if ( ! isset($admin_modules[$module_name])) {
continue;
}
foreach ((array) $module_methods as $method_name) {
if (substr($method_name, 0, 17) != '_account_suggests') {
continue;
}
$module_suggests = module_safe($module_name)->$method_name();
foreach ((array) $module_suggests as $val) {
$suggests[] = $val;
}
}
}
if ( ! empty($suggests)) {
$replace = [
'suggests' => $suggests,
];
return tpl()->parse(__CLASS__ . '/suggests', $replace);
}
}
public function _url_allowed($url = '')
public function _url_allowed($url = '')
{
return _class('admin_methods')->_admin_link_is_allowed($url);
}