coding style fixes

This commit is contained in:
Abdulrahman
2019-05-03 23:52:08 +03:00
parent 87c5631b40
commit f142da94f3
62 changed files with 12149 additions and 11750 deletions

View File

@@ -8,332 +8,336 @@
*/
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
//for style ..
$stylee = "admin_configs";
$current_smt = preg_replace('/[^a-z0-9_]/i','', g('smt', 'str', 'general'));
$stylee = 'admin_configs';
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
//words
$action = basename(ADMIN_PATH) . '?cp=options&smt=' . $current_smt;
$action = basename(ADMIN_PATH) . '?cp=options&smt=' . $current_smt;
$n_submit = $lang['UPDATE_CONFIG'];
$options = '';
#$current_type = ig('type') ? g('type') : 'general';
$options = '';
//$current_type = ig('type') ? g('type') : 'general';
$CONFIGEXTEND = false;
$H_FORM_KEYS = kleeja_add_form_key('adm_configs');
$H_FORM_KEYS = kleeja_add_form_key('adm_configs');
//secondary menu
$query = array(
$query = [
'SELECT' => 'DISTINCT(c.type), c.display_order, p.plg_disabled, c.plg_id',
'FROM' => "{$dbprefix}config c",
'JOINS' => array(
array(
'FROM' => "{$dbprefix}config c",
'JOINS' => [
[
'LEFT JOIN' => "{$dbprefix}plugins p",
'ON' => 'p.plg_id=c.plg_id'
)
),
'WHERE' => "c.option <> '' AND c.type <> 'groups'",
'ON' => 'p.plg_id=c.plg_id'
]
],
'WHERE' => "c.option <> '' AND c.type <> 'groups'",
'ORDER BY' => 'c.display_order'
);
];
$result = $SQL->build($query);
while($row = $SQL->fetch_array($result))
while ($row = $SQL->fetch_array($result))
{
if($row['type'] == 'KLIVE'){
if ($row['type'] == 'KLIVE')
{
continue;
}
if ($row['plg_id'] > 0 && (is_null($row['plg_disabled']) || $row['plg_disabled'] == 1)) {
if ($row['plg_id'] > 0 && (is_null($row['plg_disabled']) || $row['plg_disabled'] == 1))
{
continue;
}
$name = !empty($lang['CONFIG_KLJ_MENUS_' . strtoupper($row['type'])]) ? $lang['CONFIG_KLJ_MENUS_' . strtoupper($row['type'])] : (!empty($olang['CONFIG_KLJ_MENUS_' . strtoupper($row['type'])]) ? $olang['CONFIG_KLJ_MENUS_' . strtoupper($row['type'])] : $lang['CONFIG_KLJ_MENUS_OTHER']);
$go_menu[$row['type']] = array('name'=>$name, 'link'=>$action . '&amp;smt=' . $row['type'], 'goto'=>$row['type'], 'current'=> $current_smt == $row['type']);
$name = ! empty($lang['CONFIG_KLJ_MENUS_' . strtoupper($row['type'])]) ? $lang['CONFIG_KLJ_MENUS_' . strtoupper($row['type'])] : (! empty($olang['CONFIG_KLJ_MENUS_' . strtoupper($row['type'])]) ? $olang['CONFIG_KLJ_MENUS_' . strtoupper($row['type'])] : $lang['CONFIG_KLJ_MENUS_OTHER']);
$go_menu[$row['type']] = ['name'=>$name, 'link'=>$action . '&amp;smt=' . $row['type'], 'goto'=>$row['type'], 'current'=> $current_smt == $row['type']];
}
$go_menu['all'] = array('name'=>$lang['CONFIG_KLJ_MENUS_ALL'], 'link'=>$action . '&amp;smt=all', 'goto'=>'all', 'current'=> $current_smt == 'all');
$go_menu['all'] = ['name'=>$lang['CONFIG_KLJ_MENUS_ALL'], 'link'=>$action . '&amp;smt=all', 'goto'=>'all', 'current'=> $current_smt == 'all'];
//
// Check form key
//
if (ip('submit'))
{
if(!kleeja_check_form_key('adm_configs'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
if (! kleeja_check_form_key('adm_configs'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
}
//general varaibles
#$action = basename(ADMIN_PATH) . '?cp=options&amp;type=' .$current_type;
$STAMP_IMG_URL = file_exists(PATH . 'images/watermark.gif') ? PATH . 'images/watermark.gif' : PATH . 'images/watermark.png';
$stylfiles = $lngfiles = $authtypes = $time_zones = '';
$optionss = array();
//$action = basename(ADMIN_PATH) . '?cp=options&amp;type=' .$current_type;
$STAMP_IMG_URL = file_exists(PATH . 'images/watermark.gif') ? PATH . 'images/watermark.gif' : PATH . 'images/watermark.png';
$stylfiles = $lngfiles = $authtypes = $time_zones = '';
$optionss = [];
$n_googleanalytics = '<a href="http://www.google.com/analytics">Google Analytics</a>';
$query = array(
'SELECT' => '*',
'FROM' => "{$dbprefix}config",
'ORDER BY' => 'display_order, type ASC'
);
$query = [
'SELECT' => '*',
'FROM' => "{$dbprefix}config",
'ORDER BY' => 'display_order, type ASC'
];
$CONFIGEXTEND = $SQL->escape($current_smt);
$CONFIGEXTEND = $SQL->escape($current_smt);
$CONFIGEXTENDLANG = $go_menu[$current_smt]['name'];
if($current_smt != 'all')
if ($current_smt != 'all')
{
$query['WHERE'] = "type = '" . $SQL->escape($current_smt) . "' OR type = ''";
if($current_smt == 'interface')
{
$query['WHERE'] .= " OR name='language'";
}
$query['WHERE'] = "type = '" . $SQL->escape($current_smt) . "' OR type = ''";
if ($current_smt == 'interface')
{
$query['WHERE'] .= " OR name='language'";
}
}
else if($current_smt == 'all')
elseif ($current_smt == 'all')
{
$query['WHERE'] = "type <> 'groups' OR type = ''";
$query['WHERE'] = "type <> 'groups' OR type = ''";
}
$result = $SQL->build($query);
$thumbs_are = get_config('thmb_dims');
while($row=$SQL->fetch_array($result))
while ($row=$SQL->fetch_array($result))
{
if($row['type'] == 'KLIVE')
if ($row['type'] == 'KLIVE')
{
continue;
}
if($row['name'] == 'language' && $current_smt == 'interface')
{
$row['type'] = 'interface';
}
#make new lovely array !!
$con[$row['name']] = $row['value'];
if($row['name'] == 'thumbs_imgs')
{
list($thmb_dim_w, $thmb_dim_h) = array_map('trim', @explode('*', $thumbs_are));
}
else if($row['name'] == 'time_zone')
{
$zones = time_zones();
foreach($zones as $z=>$t)
{
$time_zones .= '<option ' . ($con['time_zone'] == $t ? 'selected="selected"' : '') . ' value="' . $t . '">' . $z . '</option>' . "\n";
}
}
else if($row['name'] == 'language')
{
//get languages
if ($dh = @opendir(PATH . 'lang'))
{
while (($file = readdir($dh)) !== false)
{
if(strpos($file, '.') === false && $file != '..' && $file != '.')
{
$lngfiles .= '<option ' . ($con['language'] == $file ? 'selected="selected"' : '') . ' value="' . $file . '">' . $file . '</option>' . "\n";
}
}
@closedir($dh);
}
}
else if($row['name'] == 'user_system')
{
//get auth types
//fix previous choices in old kleeja
if(in_array($con['user_system'], array('2', '3', '4')))
{
$con['user_system'] = str_replace(array('2', '3', '4'), array('phpbb', 'vb', 'mysmartbb'), $con['user_system']);
}
$authtypes .= '<option value="1"' . ($con['user_system']=='1' ? ' selected="selected"' : '') . '>' . $lang['NORMAL'] . '</option>' . "\n";
if ($dh = @opendir(PATH . 'includes/auth_integration'))
{
while (($file = readdir($dh)) !== false)
{
if(strpos($file, '.php') !== false)
{
$file = trim(str_replace('.php', '', $file));
$authtypes .= '<option value="' . $file . '"' . ($con['user_system'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>' . "\n";
}
}
@closedir($dh);
}
}
is_array($plugin_run_result = Plugins::getInstance()->run('while_fetch_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
//options from database [UNDER TEST]
if(!empty($row['option']))
{
$optionss[$row['name']] = array(
'option' => '<div class="form-group">' . "\n" .
'<label for="' . $row['name'] . '">' . (!empty($lang[strtoupper($row['name'])]) ? $lang[strtoupper($row['name'])] : $olang[strtoupper($row['name'])]) . '</label>' . "\n" .
'<div class="box">' . (empty($row['option']) ? '' : $tpl->admindisplayoption($row['option'])) . '</div>' . "\n" .
'</div>' . "\n" . '<div class="clear"></div>',
'type' => $row['type'],
'display_order' => $row['display_order'],
);
}
//when submit
if (ip('submit'))
{
//-->
$new[$row['name']] = p($row['name'], 'str', $con[$row['name']]);
//save them as you want ..
if($row['name'] == 'thumbs_imgs')
{
if(p('thmb_dim_w', 'int') < 10)
{
$_POST['thmb_dim_w'] = 10;
}
if(p('thmb_dim_h', 'int') < 10)
{
$_POST['thmb_dim_h'] = 10;
}
$thumbs_were = p('thmb_dim_w', 'int') . '*' . p('thmb_dim_h', 'int');
update_config('thmb_dims', $thumbs_were);
}
else if($row['name'] == 'livexts')
{
$new['livexts'] = implode(',', array_map('trim', explode(',', p('livexts'))));
}
else if($row['name'] == 'prefixname')
{
$new['prefixname'] = preg_replace('/[^a-z0-9_\-\}\{\:\.]/', '', strtolower(p('prefixname')));
}
else if($row['name'] == 'siteurl')
{
if(p('siteurl')[strlen(p('siteurl'))-1] != '/')
{
$new['siteurl'] .= '/';
}
}
else if($row['name'] == 'mod_writer')
if ($row['name'] == 'language' && $current_smt == 'interface')
{
if($new['mod_writer'] == 1)
$row['type'] = 'interface';
}
//make new lovely array !!
$con[$row['name']] = $row['value'];
if ($row['name'] == 'thumbs_imgs')
{
list($thmb_dim_w, $thmb_dim_h) = array_map('trim', @explode('*', $thumbs_are));
}
elseif ($row['name'] == 'time_zone')
{
$zones = time_zones();
foreach ($zones as $z=>$t)
{
if(!file_exists(PATH . '.htaccess') && file_exists(PATH . 'htaccess.txt') && function_exists('rename'))
{
rename(PATH . 'htaccess.txt', PATH . '.htaccess');
}
$time_zones .= '<option ' . ($con['time_zone'] == $t ? 'selected="selected"' : '') . ' value="' . $t . '">' . $z . '</option>' . "\n";
}
}
else if($row['name'] == 'language')
{
$got_lang = preg_replace('[^a-zA-Z0-9]', '', $new[$row['name']]);
//all groups
foreach ($d_groups as $group_id => $group_info)
elseif ($row['name'] == 'language')
{
//get languages
if ($dh = @opendir(PATH . 'lang'))
{
update_config('language', $got_lang, true, $group_id);
while (($file = readdir($dh)) !== false)
{
if (strpos($file, '.') === false && $file != '..' && $file != '.')
{
$lngfiles .= '<option ' . ($con['language'] == $file ? 'selected="selected"' : '') . ' value="' . $file . '">' . $file . '</option>' . "\n";
}
}
@closedir($dh);
}
}
elseif ($row['name'] == 'user_system')
{
//get auth types
//fix previous choices in old kleeja
if (in_array($con['user_system'], ['2', '3', '4']))
{
$con['user_system'] = str_replace(['2', '3', '4'], ['phpbb', 'vb', 'mysmartbb'], $con['user_system']);
}
delete_cache('data_lang' . $got_lang);
}
is_array($plugin_run_result = Plugins::getInstance()->run('after_submit_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$authtypes .= '<option value="1"' . ($con['user_system']=='1' ? ' selected="selected"' : '') . '>' . $lang['NORMAL'] . '</option>' . "\n";
$update_query = array(
'UPDATE' => "{$dbprefix}config",
'SET' => "value='" . $SQL->escape($new[$row['name']]) . "'",
'WHERE' => "name='" . $row['name'] . "'"
);
if ($dh = @opendir(PATH . 'includes/auth_integration'))
{
while (($file = readdir($dh)) !== false)
{
if (strpos($file, '.php') !== false)
{
$file = trim(str_replace('.php', '', $file));
$authtypes .= '<option value="' . $file . '"' . ($con['user_system'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>' . "\n";
}
}
@closedir($dh);
}
}
if($current_smt != 'all')
{
$query['WHERE'] .= " AND type = '" . $SQL->escape($current_smt) . "'";
}
is_array($plugin_run_result = Plugins::getInstance()->run('while_fetch_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$SQL->build($update_query);
}
//options from database [UNDER TEST]
if (! empty($row['option']))
{
$optionss[$row['name']] = [
'option' => '<div class="form-group">' . "\n" .
'<label for="' . $row['name'] . '">' . (! empty($lang[strtoupper($row['name'])]) ? $lang[strtoupper($row['name'])] : $olang[strtoupper($row['name'])]) . '</label>' . "\n" .
'<div class="box">' . (empty($row['option']) ? '' : $tpl->admindisplayoption($row['option'])) . '</div>' . "\n" .
'</div>' . "\n" . '<div class="clear"></div>',
'type' => $row['type'],
'display_order' => $row['display_order'],
];
}
//when submit
if (ip('submit'))
{
//-->
$new[$row['name']] = p($row['name'], 'str', $con[$row['name']]);
//save them as you want ..
if ($row['name'] == 'thumbs_imgs')
{
if (p('thmb_dim_w', 'int') < 10)
{
$_POST['thmb_dim_w'] = 10;
}
if (p('thmb_dim_h', 'int') < 10)
{
$_POST['thmb_dim_h'] = 10;
}
$thumbs_were = p('thmb_dim_w', 'int') . '*' . p('thmb_dim_h', 'int');
update_config('thmb_dims', $thumbs_were);
}
elseif ($row['name'] == 'livexts')
{
$new['livexts'] = implode(',', array_map('trim', explode(',', p('livexts'))));
}
elseif ($row['name'] == 'prefixname')
{
$new['prefixname'] = preg_replace('/[^a-z0-9_\-\}\{\:\.]/', '', strtolower(p('prefixname')));
}
elseif ($row['name'] == 'siteurl')
{
if (p('siteurl')[strlen(p('siteurl'))-1] != '/')
{
$new['siteurl'] .= '/';
}
}
elseif ($row['name'] == 'mod_writer')
{
if ($new['mod_writer'] == 1)
{
if (! file_exists(PATH . '.htaccess') && file_exists(PATH . 'htaccess.txt') && function_exists('rename'))
{
rename(PATH . 'htaccess.txt', PATH . '.htaccess');
}
}
}
elseif ($row['name'] == 'language')
{
$got_lang = preg_replace('[^a-zA-Z0-9]', '', $new[$row['name']]);
//all groups
foreach ($d_groups as $group_id => $group_info)
{
update_config('language', $got_lang, true, $group_id);
}
delete_cache('data_lang' . $got_lang);
}
is_array($plugin_run_result = Plugins::getInstance()->run('after_submit_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$update_query = [
'UPDATE' => "{$dbprefix}config",
'SET' => "value='" . $SQL->escape($new[$row['name']]) . "'",
'WHERE' => "name='" . $row['name'] . "'"
];
if ($current_smt != 'all')
{
$query['WHERE'] .= " AND type = '" . $SQL->escape($current_smt) . "'";
}
$SQL->build($update_query);
}
}
$SQL->freeresult($result);
$types = array();
$types = [];
foreach($optionss as $key => $option)
foreach ($optionss as $key => $option)
{
if(empty($types[$option['type']]))
{
$types[$option['type']] = '<ol class="breadcrumb">' .
'<li class="breadcrumb-item"><a href="#">'. $lang['R_CONFIGS'] .'</a></li>' .
'<li class="breadcrumb-item active">'. $go_menu[$option['type']]['name'] .'</li>' .
if (empty($types[$option['type']]))
{
$types[$option['type']] = '<ol class="breadcrumb">' .
'<li class="breadcrumb-item"><a href="#">' . $lang['R_CONFIGS'] . '</a></li>' .
'<li class="breadcrumb-item active">' . $go_menu[$option['type']]['name'] . '</li>' .
'</ol>';
}
}
}
foreach($types as $typekey => $type)
foreach ($types as $typekey => $type)
{
$options .= $type;
$options .= $type;
foreach($optionss as $key => $option)
{
if($option['type'] == $typekey)
{
$options .= str_replace(
array('<input ', '<select ', '<td>', '</td>', '<label>', '<tr>', '</tr>'),
array('<input class="form-control" ', '<select class="form-control" ', '<div class="form-group">', '</div>', '<label class="form-check-label">', '', ''),
foreach ($optionss as $key => $option)
{
if ($option['type'] == $typekey)
{
$options .= str_replace(
['<input ', '<select ', '<td>', '</td>', '<label>', '<tr>', '</tr>'],
['<input class="form-control" ', '<select class="form-control" ', '<div class="form-group">', '</div>', '<label class="form-check-label">', '', ''],
$option['option']);
}
}
}
}
}
//after submit
if (ip('submit'))
{
#some configs need refresh page ..
$need_refresh_configs = array('language');
//some configs need refresh page ..
$need_refresh_configs = ['language'];
is_array($plugin_run_result = Plugins::getInstance()->run('after_submit_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
//empty ..
/*
if (empty(p('sitename')) || empty(p('siteurl')) || empty(p('foldername')) || empty(p('filesnum')))
{
$text = $lang['EMPTY_FIELDS'];
$stylee = "admin_err";
}
elseif (!is_numeric(p('filesnum')) || !is_numeric(p('sec_down')))
{
$text = $lang['NUMFIELD_S'];
$stylee = "admin_err";
}
else
{
*/
//empty ..
/*
if (empty(p('sitename')) || empty(p('siteurl')) || empty(p('foldername')) || empty(p('filesnum')))
{
$text = $lang['EMPTY_FIELDS'];
$stylee = "admin_err";
}
elseif (!is_numeric(p('filesnum')) || !is_numeric(p('sec_down')))
{
$text = $lang['NUMFIELD_S'];
$stylee = "admin_err";
}
else
{
*/
#delete cache ..
delete_cache('data_config');
foreach($need_refresh_configs as $l)
{
if(ip($l) && p($l) != $config[$l])
{
header('Location: ' . basename(ADMIN_PATH));
exit();
}
}
//delete cache ..
delete_cache('data_config');
kleeja_admin_info($lang['CONFIGS_UPDATED'], true, '', true, $action, 3);
//}
}#submit
foreach ($need_refresh_configs as $l)
{
if (ip($l) && p($l) != $config[$l])
{
header('Location: ' . basename(ADMIN_PATH));
exit();
}
}
kleeja_admin_info($lang['CONFIGS_UPDATED'], true, '', true, $action, 3);
//}
}//submit

View File

@@ -9,22 +9,23 @@
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
//check _GET Csrf token
if(!kleeja_check_form_key_get('GLOBAL_FORM_KEY'))
if (! kleeja_check_form_key_get('GLOBAL_FORM_KEY'))
{
kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH), 2);
kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH), 2);
}
//remove just the administator session
if ($usrcp->logout_cp())
{
redirect($config['siteurl']);
$SQL->close();
exit;
redirect($config['siteurl']);
$SQL->close();
exit;
}

View File

@@ -9,30 +9,30 @@
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
#number of images per page
//number of images per page
$files_acp_perpage = defined('ACP_FILES_PER_PAGE') ? ACP_FILES_PER_PAGE : 20;
#display
$stylee = "admin_files";
//display
$stylee = 'admin_files';
$url_or = isset($_REQUEST['order_by']) ? '&amp;order_by=' . htmlspecialchars($_REQUEST['order_by']) . (isset($_REQUEST['order_way']) ? '&amp;order_by=1' : '') : '';
$url_or2 = isset($_REQUEST['order_by']) ? '&amp;order_by=' . htmlspecialchars($_REQUEST['order_by']) : '';
$url_lst = isset($_REQUEST['last_visit']) ? '&amp;last_visit=' . htmlspecialchars($_REQUEST['last_visit']) : '';
$url_sea = ig('search_id') ? '&amp;search_id=' . g('search_id') : '';
$url_pg = ig('page') ? '&amp;page=' . g('page', 'int') : '';
$page_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_or . $url_sea . $url_lst;
$ord_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_pg . $url_sea . $url_lst;
$url_or = isset($_REQUEST['order_by']) ? '&amp;order_by=' . htmlspecialchars($_REQUEST['order_by']) . (isset($_REQUEST['order_way']) ? '&amp;order_by=1' : '') : '';
$url_or2 = isset($_REQUEST['order_by']) ? '&amp;order_by=' . htmlspecialchars($_REQUEST['order_by']) : '';
$url_lst = isset($_REQUEST['last_visit']) ? '&amp;last_visit=' . htmlspecialchars($_REQUEST['last_visit']) : '';
$url_sea = ig('search_id') ? '&amp;search_id=' . g('search_id') : '';
$url_pg = ig('page') ? '&amp;page=' . g('page', 'int') : '';
$page_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_or . $url_sea . $url_lst;
$ord_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_pg . $url_sea . $url_lst;
$page2_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_or2 . $url_sea . $url_lst;
$action = $page_action . $url_pg;
$is_search = $affected = false;
$H_FORM_KEYS = kleeja_add_form_key('adm_files');
$action = $page_action . $url_pg;
$is_search = $affected = false;
$H_FORM_KEYS = kleeja_add_form_key('adm_files');
//
// Check form key
@@ -40,360 +40,367 @@ $H_FORM_KEYS = kleeja_add_form_key('adm_files');
if (ip('submit'))
{
#wrong form
if(!kleeja_check_form_key('adm_files'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
$del = array();
#gather to-be-deleted file ids
foreach ($_POST as $key => $value)
//wrong form
if (! kleeja_check_form_key('adm_files'))
{
if(preg_match('/del_(?P<digit>\d+)/', $key))
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
$del = [];
//gather to-be-deleted file ids
foreach ($_POST as $key => $value)
{
if (preg_match('/del_(?P<digit>\d+)/', $key))
{
$del[$key] = $value;
}
}
#delete them once by once
$ids = array();
$files_num = $imgs_num = $sizes = 0;
//TODO use IN(...)
foreach ($del as $key => $id)
//delete them once by once
$ids = [];
$files_num = $imgs_num = $sizes = 0;
//TODO use IN(...)
foreach ($del as $key => $id)
{
$query = array(
'SELECT' => 'f.id, f.name, f.folder, f.size, f.type',
'FROM' => "{$dbprefix}files f",
'WHERE' => 'f.id = ' . intval($id),
);
$query = [
'SELECT' => 'f.id, f.name, f.folder, f.size, f.type',
'FROM' => "{$dbprefix}files f",
'WHERE' => 'f.id = ' . intval($id),
];
$result = $SQL->build($query);
$result = $SQL->build($query);
while($row=$SQL->fetch_array($result))
{
//delete from folder ..
@kleeja_unlink (PATH . $row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name'] ))
{
@kleeja_unlink (PATH . $row['folder'] . '/thumbs/' . $row['name'] );
}
while ($row=$SQL->fetch_array($result))
{
//delete from folder ..
@kleeja_unlink (PATH . $row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name'] ))
{
@kleeja_unlink (PATH . $row['folder'] . '/thumbs/' . $row['name'] );
}
$is_image = in_array(strtolower(trim($row['type'])), array('gif', 'jpg', 'jpeg', 'bmp', 'png')) ? true : false;
$is_image = in_array(strtolower(trim($row['type'])), ['gif', 'jpg', 'jpeg', 'bmp', 'png']) ? true : false;
$ids[] = $row['id'];
if($is_image)
{
$imgs_num++;
}
else
{
$files_num++;
}
$sizes += $row['size'];
}
}
$ids[] = $row['id'];
if ($is_image)
{
$imgs_num++;
}
else
{
$files_num++;
}
$sizes += $row['size'];
}
}
is_array($plugin_run_result = Plugins::getInstance()->run('submit_files_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$SQL->freeresult($result);
//no files to delete
if(isset($ids) && sizeof($ids))
{
$query_del = array(
'DELETE' => "{$dbprefix}files",
'WHERE' => "`id` IN (" . implode(',', $ids) . ")"
);
$SQL->build($query_del);
//update number of stats
$update_query = array(
'UPDATE' => "{$dbprefix}stats",
'SET' => "sizes=sizes-$sizes, files=files-$files_num, imgs=imgs-$imgs_num",
);
//no files to delete
if (isset($ids) && sizeof($ids))
{
$query_del = [
'DELETE' => "{$dbprefix}files",
'WHERE' => '`id` IN (' . implode(',', $ids) . ')'
];
$SQL->build($update_query);
if($SQL->affected())
{
delete_cache('data_stats');
$affected = true;
}
}
#show msg now
$text = ($affected && (isset($ids) && sizeof($ids)) ? $lang['FILES_UPDATED'] : $lang['NO_UP_CHANGE_S']) .
'<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . str_replace('&amp;', '&', $action) . '\');", 2000);</script>' . "\n";
$stylee = "admin_info";
}
else
{
$SQL->build($query_del);
//
//Delete all user files [only one user]
//
if(ig('deletefiles'))
{
$query = array(
'SELECT' => 'f.id, f.size, f.name, f.folder',
'FROM' => "{$dbprefix}files f",
);
//update number of stats
$update_query = [
'UPDATE' => "{$dbprefix}stats",
'SET' => "sizes=sizes-$sizes, files=files-$files_num, imgs=imgs-$imgs_num",
];
#get search filter
$filter = get_filter(g('search_id'), 'file_search', false, 'filter_uid');
if(!$filter)
{
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
}
$SQL->build($update_query);
$query['WHERE'] = build_search_query(unserialize(htmlspecialchars_decode($filter['filter_value'])));
if($query['WHERE'] == '')
{
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
}
$result = $SQL->build($query);
$sizes = false;
$ids = array();
$files_num = $imgs_num = 0;
while($row=$SQL->fetch_array($result))
{
//delete from folder ..
@kleeja_unlink (PATH . $row['folder'] . "/" . $row['name']);
//delete thumb
if (file_exists(PATH . $row['folder'] . "/thumbs/" . $row['name']))
{
@kleeja_unlink (PATH . $row['folder'] . "/thumbs/" . $row['name']);
}
$is_image = in_array(strtolower(trim($row['type'])), array('gif', 'jpg', 'jpeg', 'bmp', 'png')) ? true : false;
$ids[] = $row['id'];
if($is_image)
{
$imgs_num++;
}
else
{
$files_num++;
}
$sizes += $row['size'];
}
$SQL->freeresult($result);
if(($files_num + $imgs_num) == 0)
{
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
}
else
{
//update number of stats
$update_query = array(
'UPDATE' => "{$dbprefix}stats",
'SET' => "sizes=sizes-$sizes, files=files-$files_num, imgs=imgs-$imgs_num",
);
$SQL->build($update_query);
if($SQL->affected())
{
delete_cache('data_stats');
}
//delete all files in just one query
$query_del = array(
'DELETE' => "{$dbprefix}files",
'WHERE' => "`id` IN (" . implode(',', $ids) . ")"
);
$SQL->build($query_del);
kleeja_admin_info(sprintf($lang['ADMIN_DELETE_FILES_OK'], ($files_num + $imgs_num)));
}
}
//
//begin default files page
//
$query = array(
'SELECT' => 'COUNT(f.id) AS total_files',
'FROM' => "{$dbprefix}files f",
'ORDER BY' => 'f.id '
);
#if user system is default, we use users table
if((int) $config['user_system'] == 1)
{
$query['JOINS'] = array(
array(
'LEFT JOIN' => "{$dbprefix}users u",
'ON' => 'u.id=f.user'
)
);
}
$do_not_query_total_files = false;
//posts search ..
if(ig('search_id'))
{
#get search filter
$filter = get_filter(g('search_id'), 'file_search', false, 'filter_uid');
$deletelink = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&deletefiles=' . g('search_id');
$is_search = true;
$query['WHERE'] = build_search_query(unserialize(htmlspecialchars_decode($filter['filter_value'])));
}
else if(isset($_REQUEST['last_visit']))
{
$query['WHERE'] = "f.time > " . intval($_REQUEST['last_visit']);
}
#to-be-deleted
#it is becoming a headache for a big websites. We do not have the time to figure out a solution
if(isset($_REQUEST['order_by']) && in_array($_REQUEST['order_by'], array('real_filename', 'size', 'user', 'user_ip', 'uploads', 'time', 'type', 'folder', 'report')))
{
$query['ORDER BY'] = "f." . $SQL->escape($_REQUEST['order_by']);
}
else
{
$do_not_query_total_files = true;
}
if(!ig('search_id'))
{
//display files or display pics and files only in search
$img_types = array('gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG');
$query['WHERE'] = $query['WHERE'] . (empty($query['WHERE']) ? '' : ' AND ') . "f.type NOT IN ('" . implode("', '", $img_types) . "')";
}
else
{
$do_not_query_total_files = false;
}
$query['ORDER BY'] .= (isset($_REQUEST['order_way']) && (int) $_REQUEST['order_way'] == 1) ? ' ASC' : ' DESC';
$nums_rows = 0;
if($do_not_query_total_files)
{
$nums_rows = get_actual_stats('files');
}
else
{
$result_p = $SQL->build($query);
$n_fetch = $SQL->fetch_array($result_p);
$nums_rows = $n_fetch['total_files'];
$SQL->freeresult($result_p);
}
//pager
$currentPage= ig('page') ? g('page', 'int') : 1;
$Pager = new Pagination($files_acp_perpage, $nums_rows, $currentPage);
$start = $Pager->getStartRow();
$no_results = false;
is_array($plugin_run_result = Plugins::getInstance()->run('query_files_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
if ($nums_rows > 0)
{
$query['SELECT'] = 'f.*' . ((int) $config['user_system'] == 1 ? ', u.name AS username' : '');
$query['LIMIT'] = "$start, $files_acp_perpage";
$result = $SQL->build($query);
$sizes = false;
$num = 0;
#if Kleeja integtared we dont want make alot of queries
$ids_and_names = array();
while($row=$SQL->fetch_array($result))
{
$userfile = $config['siteurl'] . ($config['mod_writer'] ? 'fileuser-' . $row['user'] . '.html' : 'ucp.php?go=fileuser&amp;id=' . $row['user']);
$file_info = array('::ID::' => $row['id'], '::NAME::' => $row['name'], '::DIR::' => $row['folder'], '::FNAME::' => $row['real_filename']);
$is_image = in_array(strtolower(trim($row['type'])), array('gif', 'jpg', 'jpeg', 'bmp', 'png')) ? true : false;
$url = kleeja_get_link($is_image ? 'image': 'file', $file_info);
#for username in integrated user system
if($row['user'] != '-1' and (int) $config['user_system'] != 1)
{
if(!in_array($row['user'], $ids_and_names))
{
$row['username'] = $usrcp->usernamebyid($row['user']);
$ids_and_names[$row['user']] = $row['username'];
}
else
{
$row['username'] = $ids_and_names[$row['user']];
}
}
$file_name = $row['real_filename'] == '' ? $row['name'] : $row['real_filename'];
//make new lovely arrays !!
$arr[] = array(
'id' => $row['id'],
'name' => "<a title=\"" . $file_name . "\" href=\"" .$url . "\" target=\"blank\">" .
shorten_text($file_name, 25) . "</a>",
'fullname' => $file_name,
'size' => readable_size($row['size']),
'ups' => $row['uploads'],
'direct' => $row['id_form'] == 'direct' ? true : false,
'time_human'=> kleeja_date($row['time']),
'time' => kleeja_date($row['time'], false),
'type' => $row['type'],
'typeicon' => file_exists(PATH . "images/filetypes/". $row['type'] . ".png") ? PATH . "images/filetypes/" . $row['type'] . ".png" : PATH. 'images/filetypes/file.png',
'folder' => $row['folder'],
'report' => $row['report'] > 4 ? "<span style=\"color:red;font-weight:bold\">" . $row['report'] . "</span>":$row['report'],
'user' => $row['user'] == '-1' ? $lang['GUST'] : '<a href="' . $userfile . '" target="_blank">' . $row['username'] . '</a>',
'ip' => '<a href="http://www.ripe.net/whois?form_type=simple&amp;full_query_string=&amp;searchtext=' . $row['user_ip'] . '&amp;do_search=Search" target="_new">' . $row['user_ip'] . '</a>',
'showfilesbyip' => basename(ADMIN_PATH) . '?cp=h_search&amp;s_input=1&amp;s_value=' . $row['user_ip']
);
is_array($plugin_run_result = Plugins::getInstance()->run('arr_files_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$del[$row['id']] = p('del_' . $row['id']);
}
$SQL->freeresult($result);
}
else
{
//no result ..
$no_results = true;
}
#update f_lastvisit
if(!$is_search)
{
if (filter_exists('f_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id'])) {
update_filter('f_lastvisit', time(), 'lastvisit', false, $userinfo['id']);
} else {
insert_filter('f_lastvisit', time(), 'lastvisit', time(), $userinfo['id']);
if ($SQL->affected())
{
delete_cache('data_stats');
$affected = true;
}
}
//show msg now
$text = ($affected && (isset($ids) && sizeof($ids)) ? $lang['FILES_UPDATED'] : $lang['NO_UP_CHANGE_S']) .
'<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . str_replace('&amp;', '&', $action) . '\');", 2000);</script>' . "\n";
$stylee = 'admin_info';
}
else
{
//
//Delete all user files [only one user]
//
if (ig('deletefiles'))
{
$query = [
'SELECT' => 'f.id, f.size, f.name, f.folder',
'FROM' => "{$dbprefix}files f",
];
//get search filter
$filter = get_filter(g('search_id'), 'file_search', false, 'filter_uid');
if (! $filter)
{
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
}
$query['WHERE'] = build_search_query(unserialize(htmlspecialchars_decode($filter['filter_value'])));
if ($query['WHERE'] == '')
{
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
}
$result = $SQL->build($query);
$sizes = false;
$ids = [];
$files_num = $imgs_num = 0;
while ($row=$SQL->fetch_array($result))
{
//delete from folder ..
@kleeja_unlink (PATH . $row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name']))
{
@kleeja_unlink (PATH . $row['folder'] . '/thumbs/' . $row['name']);
}
$is_image = in_array(strtolower(trim($row['type'])), ['gif', 'jpg', 'jpeg', 'bmp', 'png']) ? true : false;
$ids[] = $row['id'];
if ($is_image)
{
$imgs_num++;
}
else
{
$files_num++;
}
$sizes += $row['size'];
}
$SQL->freeresult($result);
if (($files_num + $imgs_num) == 0)
{
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
}
else
{
//update number of stats
$update_query = [
'UPDATE' => "{$dbprefix}stats",
'SET' => "sizes=sizes-$sizes, files=files-$files_num, imgs=imgs-$imgs_num",
];
$SQL->build($update_query);
if ($SQL->affected())
{
delete_cache('data_stats');
}
//delete all files in just one query
$query_del = [
'DELETE' => "{$dbprefix}files",
'WHERE' => '`id` IN (' . implode(',', $ids) . ')'
];
$SQL->build($query_del);
kleeja_admin_info(sprintf($lang['ADMIN_DELETE_FILES_OK'], ($files_num + $imgs_num)));
}
}
//
//begin default files page
//
$query = [
'SELECT' => 'COUNT(f.id) AS total_files',
'FROM' => "{$dbprefix}files f",
'ORDER BY' => 'f.id '
];
//if user system is default, we use users table
if ((int) $config['user_system'] == 1)
{
$query['JOINS'] = [
[
'LEFT JOIN' => "{$dbprefix}users u",
'ON' => 'u.id=f.user'
]
];
}
$do_not_query_total_files = false;
//posts search ..
if (ig('search_id'))
{
//get search filter
$filter = get_filter(g('search_id'), 'file_search', false, 'filter_uid');
$deletelink = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&deletefiles=' . g('search_id');
$is_search = true;
$query['WHERE'] = build_search_query(unserialize(htmlspecialchars_decode($filter['filter_value'])));
}
elseif (isset($_REQUEST['last_visit']))
{
$query['WHERE'] = 'f.time > ' . intval($_REQUEST['last_visit']);
}
//to-be-deleted
//it is becoming a headache for a big websites. We do not have the time to figure out a solution
if (isset($_REQUEST['order_by']) && in_array($_REQUEST['order_by'], ['real_filename', 'size', 'user', 'user_ip', 'uploads', 'time', 'type', 'folder', 'report']))
{
$query['ORDER BY'] = 'f.' . $SQL->escape($_REQUEST['order_by']);
}
else
{
$do_not_query_total_files = true;
}
if (! ig('search_id'))
{
//display files or display pics and files only in search
$img_types = ['gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG'];
$query['WHERE'] = $query['WHERE'] . (empty($query['WHERE']) ? '' : ' AND ') . "f.type NOT IN ('" . implode("', '", $img_types) . "')";
}
else
{
$do_not_query_total_files = false;
}
//some vars
$total_pages = $Pager->getTotalPages();
$page_nums = $Pager->print_nums($page_action);
$query['ORDER BY'] .= (isset($_REQUEST['order_way']) && (int) $_REQUEST['order_way'] == 1) ? ' ASC' : ' DESC';
$nums_rows = 0;
if ($do_not_query_total_files)
{
$nums_rows = get_actual_stats('files');
}
else
{
$result_p = $SQL->build($query);
$n_fetch = $SQL->fetch_array($result_p);
$nums_rows = $n_fetch['total_files'];
$SQL->freeresult($result_p);
}
//pager
$currentPage= ig('page') ? g('page', 'int') : 1;
$Pager = new Pagination($files_acp_perpage, $nums_rows, $currentPage);
$start = $Pager->getStartRow();
$no_results = false;
is_array($plugin_run_result = Plugins::getInstance()->run('query_files_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
if ($nums_rows > 0)
{
$query['SELECT'] = 'f.*' . ((int) $config['user_system'] == 1 ? ', u.name AS username' : '');
$query['LIMIT'] = "$start, $files_acp_perpage";
$result = $SQL->build($query);
$sizes = false;
$num = 0;
//if Kleeja integtared we dont want make alot of queries
$ids_and_names = [];
while ($row=$SQL->fetch_array($result))
{
$userfile = $config['siteurl'] . ($config['mod_writer'] ? 'fileuser-' . $row['user'] . '.html' : 'ucp.php?go=fileuser&amp;id=' . $row['user']);
$file_info = ['::ID::' => $row['id'], '::NAME::' => $row['name'], '::DIR::' => $row['folder'], '::FNAME::' => $row['real_filename']];
$is_image = in_array(strtolower(trim($row['type'])), ['gif', 'jpg', 'jpeg', 'bmp', 'png']) ? true : false;
$url = kleeja_get_link($is_image ? 'image': 'file', $file_info);
//for username in integrated user system
if ($row['user'] != '-1' and (int) $config['user_system'] != 1)
{
if (! in_array($row['user'], $ids_and_names))
{
$row['username'] = $usrcp->usernamebyid($row['user']);
$ids_and_names[$row['user']] = $row['username'];
}
else
{
$row['username'] = $ids_and_names[$row['user']];
}
}
$file_name = $row['real_filename'] == '' ? $row['name'] : $row['real_filename'];
//make new lovely arrays !!
$arr[] = [
'id' => $row['id'],
'name' => '<a title="' . $file_name . '" href="' . $url . '" target="blank">' .
shorten_text($file_name, 25) . '</a>',
'fullname' => $file_name,
'size' => readable_size($row['size']),
'ups' => $row['uploads'],
'direct' => $row['id_form'] == 'direct' ? true : false,
'time_human' => kleeja_date($row['time']),
'time' => kleeja_date($row['time'], false),
'type' => $row['type'],
'typeicon' => file_exists(PATH . 'images/filetypes/' . $row['type'] . '.png') ? PATH . 'images/filetypes/' . $row['type'] . '.png' : PATH . 'images/filetypes/file.png',
'folder' => $row['folder'],
'report' => $row['report'] > 4 ? '<span style="color:red;font-weight:bold">' . $row['report'] . '</span>':$row['report'],
'user' => $row['user'] == '-1' ? $lang['GUST'] : '<a href="' . $userfile . '" target="_blank">' . $row['username'] . '</a>',
'ip' => '<a href="http://www.ripe.net/whois?form_type=simple&amp;full_query_string=&amp;searchtext=' . $row['user_ip'] . '&amp;do_search=Search" target="_new">' . $row['user_ip'] . '</a>',
'showfilesbyip' => basename(ADMIN_PATH) . '?cp=h_search&amp;s_input=1&amp;s_value=' . $row['user_ip']
];
is_array($plugin_run_result = Plugins::getInstance()->run('arr_files_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$del[$row['id']] = p('del_' . $row['id']);
}
$SQL->freeresult($result);
}
else
{
//no result ..
$no_results = true;
}
//update f_lastvisit
if (! $is_search)
{
if (filter_exists('f_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id']))
{
update_filter('f_lastvisit', time(), 'lastvisit', false, $userinfo['id']);
}
else
{
insert_filter('f_lastvisit', time(), 'lastvisit', time(), $userinfo['id']);
}
}
//some vars
$total_pages = $Pager->getTotalPages();
$page_nums = $Pager->print_nums($page_action);
$current_page = $Pager->getCurrentPage();
}

View File

@@ -8,41 +8,41 @@
*/
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
#number of images per page
//number of images per page
$images_acp_perpage = defined('ACP_IMAGES_PER_PAGE') ? ACP_IMAGES_PER_PAGE : 20;
#display
$stylee = "admin_img";
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . (ig('page') ? '&amp;page=' . g('page', 'int') : '') .
(ig('last_visit') ? '&amp;last_visit='.g('last_visit', 'int') : '') .
//display
$stylee = 'admin_img';
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . (ig('page') ? '&amp;page=' . g('page', 'int') : '') .
(ig('last_visit') ? '&amp;last_visit=' . g('last_visit', 'int') : '') .
(ig('smt') ? '&smt=' . g('smt') : '');
$action_search = basename(ADMIN_PATH) . "?cp=h_search";
$H_FORM_KEYS = kleeja_add_form_key('adm_img_ctrl');
$is_search = false;
$action_search = basename(ADMIN_PATH) . '?cp=h_search';
$H_FORM_KEYS = kleeja_add_form_key('adm_img_ctrl');
$is_search = false;
//
// Check form key
//
if (ip('submit'))
{
if(!kleeja_check_form_key('adm_img_ctrl'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
if (! kleeja_check_form_key('adm_img_ctrl'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
$del = array();
$del = [];
$num = $sizes = 0;
foreach ($_POST as $key => $value)
foreach ($_POST as $key => $value)
{
if(preg_match('/del_(?P<digit>\d+)/', $key))
if (preg_match('/del_(?P<digit>\d+)/', $key))
{
$del[$key] = $value;
}
@@ -51,218 +51,218 @@ if (ip('submit'))
//TODO better way
foreach ($del as $key => $id)
{
$query = array(
'SELECT' => '*',
'FROM' => "{$dbprefix}files",
'WHERE' => '`id` = ' . intval($id),
);
$query = [
'SELECT' => '*',
'FROM' => "{$dbprefix}files",
'WHERE' => '`id` = ' . intval($id),
];
$result = $SQL->build($query);
$result = $SQL->build($query);
while($row=$SQL->fetch_array($result))
{
//delete from folder ..
@kleeja_unlink(PATH . $row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name'] ))
{
@kleeja_unlink(PATH . $row['folder'] . '/thumbs/' . $row['name'] );
}
$ids[] = $row['id'];
$num++;
$sizes += $row['size'];
}
while ($row=$SQL->fetch_array($result))
{
//delete from folder ..
@kleeja_unlink(PATH . $row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name'] ))
{
@kleeja_unlink(PATH . $row['folder'] . '/thumbs/' . $row['name'] );
}
$ids[] = $row['id'];
$num++;
$sizes += $row['size'];
}
$SQL->free($result);
}
}
is_array($plugin_run_result = Plugins::getInstance()->run('submit_imgctrl_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
//no files to delete
if(isset($ids) && sizeof($ids))
{
$query_del = array(
'DELETE' => "{$dbprefix}files",
'WHERE' => "`id` IN (" . implode(',', $ids) . ")"
);
$SQL->build($query_del);
if (isset($ids) && sizeof($ids))
{
$query_del = [
'DELETE' => "{$dbprefix}files",
'WHERE' => '`id` IN (' . implode(',', $ids) . ')'
];
//update number of stats
$update_query = array(
'UPDATE' => "{$dbprefix}stats",
'SET' => "sizes=sizes-$sizes, imgs=imgs-$num",
);
$SQL->build($query_del);
//update number of stats
$update_query = [
'UPDATE' => "{$dbprefix}stats",
'SET' => "sizes=sizes-$sizes, imgs=imgs-$num",
];
$SQL->build($update_query);
if ($SQL->affected())
{
delete_cache('data_stats');
$affected = true;
}
}
$SQL->build($update_query);
if($SQL->affected())
{
delete_cache('data_stats');
$affected = true;
}
}
//after submit
$text = ($affected ? $lang['FILES_UPDATED'] : $lang['NO_UP_CHANGE_S']) .
'<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') .
'&page=' . (ig('page') ? g('page', 'int') : '1') . '\');", 2000);</script>' . "\n";
$text = ($affected ? $lang['FILES_UPDATED'] : $lang['NO_UP_CHANGE_S']) .
'<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') .
'&page=' . (ig('page') ? g('page', 'int') : '1') . '\');", 2000);</script>' . "\n";
$stylee = "admin_info";
$stylee = 'admin_info';
}
else
{
$query = [
'SELECT' => 'COUNT(f.id) AS total_files',
'FROM' => "{$dbprefix}files f",
'ORDER BY' => 'f.id DESC'
];
$query = array(
'SELECT' => 'COUNT(f.id) AS total_files',
'FROM' => "{$dbprefix}files f",
'ORDER BY' => 'f.id DESC'
);
#if user system is default, we use users table
if((int) $config['user_system'] == 1)
{
$query['JOINS'] = array(
array(
'LEFT JOIN' => "{$dbprefix}users u",
'ON' => 'u.id=f.user'
)
);
}
$img_types = array('gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG');
#
# There is a bug with IN statement in MySQL and they said it will solved at 6.0 version
# forums.mysql.com/read.php?10,243691,243888#msg-243888
# $query['WHERE'] = "f.type IN ('" . implode("', '", $img_types) . "')";
#
$query['WHERE'] = "(f.type = '" . implode("' OR f.type = '", $img_types) . "')";
$do_not_query_total_files = false;
if(ig('last_visit'))
{
$query['WHERE'] .= " AND f.time > " . g('last_visit', 'int');
}
else
{
$do_not_query_total_files = true;
}
is_array($plugin_run_result = Plugins::getInstance()->run('query_imgctrl_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$nums_rows = 0;
if($do_not_query_total_files)
{
$nums_rows = get_actual_stats('imgs');
}
else
{
$result_p = $SQL->build($query);
$n_fetch = $SQL->fetch_array($result_p);
$nums_rows = $n_fetch['total_files'];
$SQL->freeresult($result_p);
}
//pager
$currentPage= ig('page') ? g('page', 'int') : 1;
$Pager = new Pagination($images_acp_perpage, $nums_rows, $currentPage);
$start = $Pager->getStartRow();
$no_results = $affected = $sizes = false;
if ($nums_rows > 0)
{
$query['SELECT'] = 'f.*' . ((int) $config['user_system'] == 1 ? ', u.name AS username' : '');
$query['LIMIT'] = "$start, $images_acp_perpage";
$result = $SQL->build($query);
$tdnum = $num = 0;
#if Kleeja integrated we dont want make alot of queries
$ids_and_names = array();
while($row=$SQL->fetch_array($result))
{
$file_info = array('::ID::' => $row['id'], '::NAME::' => $row['name'], '::DIR::' => $row['folder'], '::FNAME::' => $row['real_filename']);
$url = kleeja_get_link('image', $file_info);
$url_thumb = kleeja_get_link('thumb', $file_info);
#for username in integrated user system
if($row['user'] != '-1' and (int) $config['user_system'] != 1)
{
if(!in_array($row['user'], $ids_and_names))
{
$row['username'] = $usrcp->usernamebyid($row['user']);
$ids_and_names[$row['user']] = $row['username'];
}
else
{
$row['username'] = $ids_and_names[$row['user']];
}
}
$file_name = $row['real_filename'] == '' ? $row['name'] : $row['real_filename'];
//make new lovely arrays !!
$arr[] = array(
'id' => $row['id'],
'tdnum' => $tdnum == 0 ? '<ul>': '',
'tdnum2' => $tdnum == 4 ? '</ul>' : '',
'name' => shorten_text($file_name, 25),
'ip' => htmlspecialchars($row['user_ip']),
'href' => $url,
'size' => readable_size($row['size']),
'ups' => $row['uploads'],
'time' => date('d-m-Y h:i a', $row['time']),
'user' => (int) $row['user'] == -1 ? $lang['GUST'] : $row['username'],
'is_user' => (int) $row['user'] == -1 ? 0 : 1,
'thumb_link'=> $url_thumb
);
//fix ...
$tdnum = $tdnum == 4 ? 0 : $tdnum+1;
$del[$row['id']] = p('del_' . $row['id']);
is_array($plugin_run_result = Plugins::getInstance()->run('arr_imgctrl_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
//if user system is default, we use users table
if ((int) $config['user_system'] == 1)
{
$query['JOINS'] = [
[
'LEFT JOIN' => "{$dbprefix}users u",
'ON' => 'u.id=f.user'
]
];
}
$SQL->freeresult($result);
$img_types = ['gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG'];
//
// There is a bug with IN statement in MySQL and they said it will solved at 6.0 version
// forums.mysql.com/read.php?10,243691,243888#msg-243888
// $query['WHERE'] = "f.type IN ('" . implode("', '", $img_types) . "')";
//
$query['WHERE'] = "(f.type = '" . implode("' OR f.type = '", $img_types) . "')";
}
else
{
$no_results = true;
}
$do_not_query_total_files = false;
#update f_lastvisit
if(!$is_search)
{
if (filter_exists('i_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id'])) {
update_filter('i_lastvisit', time(), 'lastvisit', false, $userinfo['id']);
} else {
insert_filter('i_lastvisit', time(), 'lastvisit', time(), $userinfo['id']);
if (ig('last_visit'))
{
$query['WHERE'] .= ' AND f.time > ' . g('last_visit', 'int');
}
else
{
$do_not_query_total_files = true;
}
}
//pages
$total_pages = $Pager->getTotalPages();
$page_nums = $Pager->print_nums(basename(ADMIN_PATH). '?cp=' . basename(__file__, '.php') .
is_array($plugin_run_result = Plugins::getInstance()->run('query_imgctrl_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$nums_rows = 0;
if ($do_not_query_total_files)
{
$nums_rows = get_actual_stats('imgs');
}
else
{
$result_p = $SQL->build($query);
$n_fetch = $SQL->fetch_array($result_p);
$nums_rows = $n_fetch['total_files'];
$SQL->freeresult($result_p);
}
//pager
$currentPage= ig('page') ? g('page', 'int') : 1;
$Pager = new Pagination($images_acp_perpage, $nums_rows, $currentPage);
$start = $Pager->getStartRow();
$no_results = $affected = $sizes = false;
if ($nums_rows > 0)
{
$query['SELECT'] = 'f.*' . ((int) $config['user_system'] == 1 ? ', u.name AS username' : '');
$query['LIMIT'] = "$start, $images_acp_perpage";
$result = $SQL->build($query);
$tdnum = $num = 0;
//if Kleeja integrated we dont want make alot of queries
$ids_and_names = [];
while ($row=$SQL->fetch_array($result))
{
$file_info = ['::ID::' => $row['id'], '::NAME::' => $row['name'], '::DIR::' => $row['folder'], '::FNAME::' => $row['real_filename']];
$url = kleeja_get_link('image', $file_info);
$url_thumb = kleeja_get_link('thumb', $file_info);
//for username in integrated user system
if ($row['user'] != '-1' and (int) $config['user_system'] != 1)
{
if (! in_array($row['user'], $ids_and_names))
{
$row['username'] = $usrcp->usernamebyid($row['user']);
$ids_and_names[$row['user']] = $row['username'];
}
else
{
$row['username'] = $ids_and_names[$row['user']];
}
}
$file_name = $row['real_filename'] == '' ? $row['name'] : $row['real_filename'];
//make new lovely arrays !!
$arr[] = [
'id' => $row['id'],
'tdnum' => $tdnum == 0 ? '<ul>': '',
'tdnum2' => $tdnum == 4 ? '</ul>' : '',
'name' => shorten_text($file_name, 25),
'ip' => htmlspecialchars($row['user_ip']),
'href' => $url,
'size' => readable_size($row['size']),
'ups' => $row['uploads'],
'time' => date('d-m-Y h:i a', $row['time']),
'user' => (int) $row['user'] == -1 ? $lang['GUST'] : $row['username'],
'is_user' => (int) $row['user'] == -1 ? 0 : 1,
'thumb_link'=> $url_thumb
];
//fix ...
$tdnum = $tdnum == 4 ? 0 : $tdnum+1;
$del[$row['id']] = p('del_' . $row['id']);
is_array($plugin_run_result = Plugins::getInstance()->run('arr_imgctrl_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
}
$SQL->freeresult($result);
}
else
{
$no_results = true;
}
//update f_lastvisit
if (! $is_search)
{
if (filter_exists('i_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id']))
{
update_filter('i_lastvisit', time(), 'lastvisit', false, $userinfo['id']);
}
else
{
insert_filter('i_lastvisit', time(), 'lastvisit', time(), $userinfo['id']);
}
}
//pages
$total_pages = $Pager->getTotalPages();
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') .
(ig('last_visit') ? '&last_vists=' . g('last_visit', 'int') : '') .
(ig('smt') ? '&smt=' . g('smt') : '')
, 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
$current_page = $Pager->getCurrentPage();
}
(ig('smt') ? '&smt=' . g('smt') : ''), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
$current_page = $Pager->getCurrentPage();
}

View File

@@ -6,19 +6,19 @@
* @license ./docs/license.txt
*
*/
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
//for style ..
$stylee = "admin_calls";
$stylee = 'admin_calls';
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&amp;page=' . (ig('page') ? g('page', 'int') : 1) . '&amp;smt=' . $current_smt;
$msg_sent = ig('sent') ? g('sent', 'int') : false;
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&amp;page=' . (ig('page') ? g('page', 'int') : 1) . '&amp;smt=' . $current_smt;
$msg_sent = ig('sent') ? g('sent', 'int') : false;
$H_FORM_KEYS = kleeja_add_form_key('adm_calls');
$there_queue = preg_match('!:del_[a-z0-9]{0,3}calls:!i', $config['queue']);
@@ -27,147 +27,145 @@ $there_queue = preg_match('!:del_[a-z0-9]{0,3}calls:!i', $config['queue']);
//
if (ip('submit'))
{
if(!kleeja_check_form_key('adm_calls'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
if (! kleeja_check_form_key('adm_calls'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
}
#add delete process to the queue
if($current_smt == 'del_d30' || $current_smt == 'del_all')
//add delete process to the queue
if ($current_smt == 'del_d30' || $current_smt == 'del_all')
{
if(strpos($config['queue'], ':' . $current_smt . 'calls:') !== false)
{
kleeja_admin_err($lang['DELETE_PROCESS_IN_WORK'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 1);
}
else
{
update_config('queue', $config['queue'] . ':' . $current_smt . 'calls:');
kleeja_admin_info($lang['DELETE_PROCESS_QUEUED'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
}
if (strpos($config['queue'], ':' . $current_smt . 'calls:') !== false)
{
kleeja_admin_err($lang['DELETE_PROCESS_IN_WORK'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 1);
}
else
{
update_config('queue', $config['queue'] . ':' . $current_smt . 'calls:');
kleeja_admin_info($lang['DELETE_PROCESS_QUEUED'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
}
}
$query = array(
'SELECT' => 'c.*',
'FROM' => "`{$dbprefix}call` c",
'ORDER BY' => 'c.id DESC'
);
$query = [
'SELECT' => 'c.*',
'FROM' => "`{$dbprefix}call` c",
'ORDER BY' => 'c.id DESC'
];
if($current_smt == 'show_h24')
if ($current_smt == 'show_h24')
{
$query['WHERE'] = 'c.time > ' . intval(time() - 3600 * 24);
$query['WHERE'] = 'c.time > ' . intval(time() - 3600 * 24);
}
$result = $SQL->build($query);
//pagination
$nums_rows = $SQL->num_rows($result);
$nums_rows = $SQL->num_rows($result);
$currentPage = ig('page') ? g('page', 'int') : 1;
$Pager = new Pagination($perpage, $nums_rows, $currentPage);
$start = $Pager->getStartRow();
$Pager = new Pagination($perpage, $nums_rows, $currentPage);
$start = $Pager->getStartRow();
$no_results = false;
$del_nums = array();
$del_nums = [];
if ($nums_rows > 0)
{
$query['LIMIT'] = "$start,$perpage";
$result = $SQL->build($query);
$query['LIMIT'] = "$start,$perpage";
$result = $SQL->build($query);
while($row=$SQL->fetch_array($result))
{
//make new lovely arrays !!
$arr[] = array(
'id' => $row['id'],
'name' => $row['name'],
'mail' => $row['mail'],
'text' => htmlspecialchars($row['text']),
'human_time'=> kleeja_date($row['time']),
'time' => kleeja_date($row['time'], false),
'ip' => $row['ip'],
'sent' => $row['id'] == $msg_sent,
'ip_finder' => 'http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext=' . $row['ip'] . '&do_search=Search'
);
while ($row=$SQL->fetch_array($result))
{
//make new lovely arrays !!
$arr[] = [
'id' => $row['id'],
'name' => $row['name'],
'mail' => $row['mail'],
'text' => htmlspecialchars($row['text']),
'human_time'=> kleeja_date($row['time']),
'time' => kleeja_date($row['time'], false),
'ip' => $row['ip'],
'sent' => $row['id'] == $msg_sent,
'ip_finder' => 'http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext=' . $row['ip'] . '&do_search=Search'
];
$del[$row['id']] = p('del_' . $row['id']);
$sen[$row['id']] = p('v_' . $row['id']);
$del[$row['id']] = p('del_' . $row['id']);
$sen[$row['id']] = p('v_' . $row['id']);
//when submit !!
if (ip('submit'))
{
if ($del[$row['id']])
{
$del_nums[] = $row['id'];
}
}
//when submit !!
if (ip('submit'))
{
if ($del[$row['id']])
{
$del_nums[] = $row['id'];
}
}
if (ip('reply_submit'))
{
if ($sen[$row['id']])
{
$to = $row['mail'];
$subject = $lang['REPLY_CALL'] . ':' . $config['sitename'];
$message = "\n " . $lang['REPLY_CALL'] . " " . $row['name'] . "\r\n " . $lang['REPLIED_ON_CAL'] . " : " . $config['sitename'] .
"\r\n " . $lang['BY_EMAIL'] . ": " . $row['mail'] . "\r\n" . $lang['ADMIN_REPLIED'] . "\r\n" . $sen[$row['id']] . "\r\n\r\n Kleeja.com ";
if (ip('reply_submit'))
{
if ($sen[$row['id']])
{
$to = $row['mail'];
$subject = $lang['REPLY_CALL'] . ':' . $config['sitename'];
$message = "\n " . $lang['REPLY_CALL'] . ' ' . $row['name'] . "\r\n " . $lang['REPLIED_ON_CAL'] . ' : ' . $config['sitename'] .
"\r\n " . $lang['BY_EMAIL'] . ': ' . $row['mail'] . "\r\n" . $lang['ADMIN_REPLIED'] . "\r\n" . $sen[$row['id']] . "\r\n\r\n Kleeja.com ";
$send = send_mail($to, $message, $subject, $config['sitemail'], $config['sitename']);
$send = send_mail($to, $message, $subject, $config['sitemail'], $config['sitename']);
if ($send)
{
//
//We will redirect to pages of results and show info msg there !
//
kleeja_admin_info($lang['IS_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
}
else
{
kleeja_admin_err($lang['ERR_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
}
}
}
}
$SQL->freeresult($result);
if ($send)
{
//
//We will redirect to pages of results and show info msg there !
//
kleeja_admin_info($lang['IS_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
}
else
{
kleeja_admin_err($lang['ERR_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
}
}
}
}
$SQL->freeresult($result);
}
else
{
$no_results = true;
$no_results = true;
}
//if deleted
if(sizeof($del_nums))
if (sizeof($del_nums))
{
$query_del = array(
'DELETE' => "`{$dbprefix}call`",
'WHERE' => "id IN('" . implode("', '", $del_nums) . "')"
);
$query_del = [
'DELETE' => "`{$dbprefix}call`",
'WHERE' => "id IN('" . implode("', '", $del_nums) . "')"
];
$SQL->build($query_del);
$SQL->build($query_del);
}
$total_pages = $Pager->getTotalPages();
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
//after submit
if (ip('submit'))
{
$text = ($SQL->affected() ? $lang['CALLS_UPDATED'] : $lang['NO_UP_CHANGE_S']);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . $action . '\'); check_msg_and_reports();", 2000);</script>' . "\n";
kleeja_admin_info($text, true, '', true, $action);
$text = ($SQL->affected() ? $lang['CALLS_UPDATED'] : $lang['NO_UP_CHANGE_S']);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . $action . '\'); check_msg_and_reports();", 2000);</script>' . "\n";
kleeja_admin_info($text, true, '', true, $action);
}
//secondary menu
$go_menu = array(
'general' => array('name'=>$lang['R_CALLS'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&amp;smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'),
'show_h24' => array('name'=>$lang['SHOW_FROM_24H'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&amp;smt=show_h24', 'goto'=>'show_h24', 'current'=> $current_smt == 'show_h24'),
#CHECK IF IT'S ALREADY DONE ?
'del_d30' => array('name'=>$lang['DELETE_EARLIER_30DAYS'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&amp;smt=del_d30', 'goto'=>'del_d30', 'current'=> $current_smt == 'del_d30', 'confirm'=>true),
'del_all' => array('name'=>$lang['DELETE_ALL'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&amp;smt=del_all', 'goto'=>'del_all', 'current'=> $current_smt == 'del_all', 'confirm'=>true),
);
$go_menu = [
'general' => ['name'=>$lang['R_CALLS'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&amp;smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'],
'show_h24' => ['name'=>$lang['SHOW_FROM_24H'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&amp;smt=show_h24', 'goto'=>'show_h24', 'current'=> $current_smt == 'show_h24'],
//CHECK IF IT'S ALREADY DONE ?
'del_d30' => ['name'=>$lang['DELETE_EARLIER_30DAYS'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&amp;smt=del_d30', 'goto'=>'del_d30', 'current'=> $current_smt == 'del_d30', 'confirm'=>true],
'del_all' => ['name'=>$lang['DELETE_ALL'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&amp;smt=del_all', 'goto'=>'del_all', 'current'=> $current_smt == 'del_all', 'confirm'=>true],
];

View File

@@ -6,18 +6,18 @@
* @license ./docs/license.txt
*
*/
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
//for style ..
$stylee = "admin_reports";
$current_smt = preg_replace('/[^a-z0-9_]/i','', g('smt', 'str', 'general'));
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&amp;page=' . (ig('page') ? g('page', 'int') : 1) . '&amp;smt=' . $current_smt;
$msg_sent = ig('sent') ? g('sent', 'int') : false;
$stylee = 'admin_reports';
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&amp;page=' . (ig('page') ? g('page', 'int') : 1) . '&amp;smt=' . $current_smt;
$msg_sent = ig('sent') ? g('sent', 'int') : false;
$H_FORM_KEYS = kleeja_add_form_key('adm_reports');
$there_queue = preg_match('!:del_[a-z0-9]{0,3}reports:!i', $config['queue']);
@@ -27,146 +27,144 @@ $there_queue = preg_match('!:del_[a-z0-9]{0,3}reports:!i', $config['queue']);
//
if (ip('submit'))
{
if(!kleeja_check_form_key('adm_reports'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
if (! kleeja_check_form_key('adm_reports'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
}
#add delete process to the queue
if($current_smt == 'del_d30' || $current_smt == 'del_all')
//add delete process to the queue
if ($current_smt == 'del_d30' || $current_smt == 'del_all')
{
if(strpos($config['queue'], ':' . $current_smt . 'reports:') !== false)
{
kleeja_admin_err($lang['DELETE_PROCESS_IN_WORK'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 1);
}
else
{
update_config('queue', $config['queue'] . ':' . $current_smt . 'reports:');
kleeja_admin_info($lang['DELETE_PROCESS_QUEUED'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
}
if (strpos($config['queue'], ':' . $current_smt . 'reports:') !== false)
{
kleeja_admin_err($lang['DELETE_PROCESS_IN_WORK'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 1);
}
else
{
update_config('queue', $config['queue'] . ':' . $current_smt . 'reports:');
kleeja_admin_info($lang['DELETE_PROCESS_QUEUED'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
}
}
$query = array(
'SELECT' => '*',
'FROM' => "{$dbprefix}reports r",
'ORDER BY' => 'r.id DESC'
);
$query = [
'SELECT' => '*',
'FROM' => "{$dbprefix}reports r",
'ORDER BY' => 'r.id DESC'
];
if($current_smt == 'show_h24')
if ($current_smt == 'show_h24')
{
$query['WHERE'] = 'r.time > ' . intval(time() - 3600 * 24);
$query['WHERE'] = 'r.time > ' . intval(time() - 3600 * 24);
}
$result = $SQL->build($query);
//pagination
$nums_rows = $SQL->num_rows($result);
$nums_rows = $SQL->num_rows($result);
$currentPage = ig('page') ? g('page', 'int') : 1;
$Pager = new Pagination($perpage, $nums_rows, $currentPage);
$start = $Pager->getStartRow();
$Pager = new Pagination($perpage, $nums_rows, $currentPage);
$start = $Pager->getStartRow();
$no_results = false;
$del_nums = array();
$del_nums = [];
if ($nums_rows > 0)
{
$query['LIMIT'] = "$start, $perpage";
$result = $SQL->build($query);
$query['LIMIT'] = "$start, $perpage";
$result = $SQL->build($query);
while($row=$SQL->fetch_array($result))
{
//make new lovely arrays !!
$arr[] = array(
'id' => $row['id'],
'name' => $row['name'],
'mail' => $row['mail'],
'url' => $row['url'],
'text' => $row['text'],
'human_time'=> kleeja_date($row['time']),
'time' => kleeja_date($row['time'], false),
'ip' => $row['ip'],
'sent' => $row['id'] == $msg_sent,
'ip_finder' => 'http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext=' . htmlspecialchars($row['ip']) . '&do_search=Search'
);
while ($row=$SQL->fetch_array($result))
{
//make new lovely arrays !!
$arr[] = [
'id' => $row['id'],
'name' => $row['name'],
'mail' => $row['mail'],
'url' => $row['url'],
'text' => $row['text'],
'human_time'=> kleeja_date($row['time']),
'time' => kleeja_date($row['time'], false),
'ip' => $row['ip'],
'sent' => $row['id'] == $msg_sent,
'ip_finder' => 'http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext=' . htmlspecialchars($row['ip']) . '&do_search=Search'
];
$del[$row['id']] = p('del_' . $row['id']);
$sen[$row['id']] = p('v_' . $row['id']);
$del[$row['id']] = p('del_' . $row['id']);
$sen[$row['id']] = p('v_' . $row['id']);
//when submit !!
if (ip('submit'))
{
if ($del[$row['id']])
{
$del_nums[] = $row['id'];
}
}
//when submit !!
if (ip('submit'))
{
if ($del[$row['id']])
{
$del_nums[] = $row['id'];
}
}
if (ip('reply_submit'))
{
if ($sen[$row['id']])
{
$to = $row['mail'];
$subject = $lang['REPLY_REPORT'] . ':' . $config['sitename'];
$message = "\n " . $lang['WELCOME'] . " " . $row['name'] . "\r\n " . $lang['U_REPORT_ON'] . " " . $config['sitename']. "\r\n " .
$lang['BY_EMAIL'] . " : " . $row['mail']."\r\n" . $lang['ADMIN_REPLIED'] . ": \r\n" . $sen[$row['id']] . "\r\n\r\n kleeja.com";
if (ip('reply_submit'))
{
if ($sen[$row['id']])
{
$to = $row['mail'];
$subject = $lang['REPLY_REPORT'] . ':' . $config['sitename'];
$message = "\n " . $lang['WELCOME'] . ' ' . $row['name'] . "\r\n " . $lang['U_REPORT_ON'] . ' ' . $config['sitename'] . "\r\n " .
$lang['BY_EMAIL'] . ' : ' . $row['mail'] . "\r\n" . $lang['ADMIN_REPLIED'] . ": \r\n" . $sen[$row['id']] . "\r\n\r\n kleeja.com";
$send = send_mail($to, $message, $subject, $config['sitemail'], $config['sitename']);
$send = send_mail($to, $message, $subject, $config['sitemail'], $config['sitename']);
if ($send)
{
//
//We will redirect to pages of results and show info msg there !
//
kleeja_admin_info($lang['IS_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
}
else
{
kleeja_admin_err($lang['ERR_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
}
}
}
}
$SQL->freeresult($result);
if ($send)
{
//
//We will redirect to pages of results and show info msg there !
//
kleeja_admin_info($lang['IS_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
}
else
{
kleeja_admin_err($lang['ERR_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
}
}
}
}
$SQL->freeresult($result);
}
else #num rows
{
$no_results = true;
else
{ //num rows
$no_results = true;
}
//if deleted
if(sizeof($del_nums))
if (sizeof($del_nums))
{
$query_del = array(
'DELETE' => "{$dbprefix}reports",
'WHERE' => "id IN('" . implode("', '", $del_nums) . "')"
);
$query_del = [
'DELETE' => "{$dbprefix}reports",
'WHERE' => "id IN('" . implode("', '", $del_nums) . "')"
];
$SQL->build($query_del);
$SQL->build($query_del);
}
$total_pages = $Pager->getTotalPages();
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
//after submit
if (ip('submit'))
{
$text = ($SQL->affected() ? $lang['REPORTS_UPDATED'] : $lang['NO_UP_CHANGE_S']);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . $action . '\'); check_msg_and_reports();", 2000);</script>' . "\n";
kleeja_admin_info($text, true, '', true, $action);
$text = ($SQL->affected() ? $lang['REPORTS_UPDATED'] : $lang['NO_UP_CHANGE_S']);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . $action . '\'); check_msg_and_reports();", 2000);</script>' . "\n";
kleeja_admin_info($text, true, '', true, $action);
}
//secondary menu
$go_menu = array(
'general' => array('name'=>$lang['R_REPORTS'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&amp;smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'),
'show_h24' => array('name'=>$lang['SHOW_FROM_24H'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&amp;smt=show_h24', 'goto'=>'show_h24', 'current'=> $current_smt == 'show_h24'),
#TODO : CHECK IF IT'S ALREADY DONE ?
'del_d30' => array('name'=>$lang['DELETE_EARLIER_30DAYS'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&amp;smt=del_d30', 'goto'=>'del_d30', 'current'=> $current_smt == 'del_d30', 'confirm'=>true),
'del_all' => array('name'=>$lang['DELETE_ALL'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&amp;smt=del_all', 'goto'=>'del_all', 'current'=> $current_smt == 'del_all', 'confirm'=>true),
);
$go_menu = [
'general' => ['name'=>$lang['R_REPORTS'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&amp;smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'],
'show_h24' => ['name'=>$lang['SHOW_FROM_24H'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&amp;smt=show_h24', 'goto'=>'show_h24', 'current'=> $current_smt == 'show_h24'],
//TODO : CHECK IF IT'S ALREADY DONE ?
'del_d30' => ['name'=>$lang['DELETE_EARLIER_30DAYS'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&amp;smt=del_d30', 'goto'=>'del_d30', 'current'=> $current_smt == 'del_d30', 'confirm'=>true],
'del_all' => ['name'=>$lang['DELETE_ALL'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&amp;smt=del_all', 'goto'=>'del_all', 'current'=> $current_smt == 'del_all', 'confirm'=>true],
];

File diff suppressed because it is too large Load Diff

View File

@@ -9,159 +9,162 @@
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
//for style ..
$stylee = "admin_search";
$stylee = 'admin_search';
//search files
$action = basename(ADMIN_PATH) . "?cp=h_search";
$action = basename(ADMIN_PATH) . '?cp=h_search';
//wut the default user system
$default_user_system = (int) $config['user_system'] == 1 ? true : false;
$H_FORM_KEYS = kleeja_add_form_key('adm_files_search');
$H_FORM_KEYS = kleeja_add_form_key('adm_files_search');
$H_FORM_KEYS2 = kleeja_add_form_key('adm_users_search');
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'files'));
#filling the inputs automatically via GET
//filling the inputs automatically via GET
$filled_ip = $filled_username = '';
if(ig('s_input'))
if (ig('s_input'))
{
if(g('s_input', 'int') == 2)
{
$filled_username = g('s_value');
}
elseif(g('s_input', 'int') == 1)
{
$filled_ip = g('s_value');
}
if (g('s_input', 'int') == 2)
{
$filled_username = g('s_value');
}
elseif (g('s_input', 'int') == 1)
{
$filled_ip = g('s_value');
}
}
if (ip('search_file'))
{
if(!kleeja_check_form_key('adm_files_search'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search', 1);
}
#delete all searches greater than 10
$s_del = array(
'SELECT' => "filter_id",
'FROM' => "{$dbprefix}filters",
'WHERE' => "filter_type='file_search' AND filter_user=" . $userinfo['id'],
'ORDER BY' => "filter_id DESC",
'LIMIT' => '5, 18446744073709551615'
);
if (! kleeja_check_form_key('adm_files_search'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search', 1);
}
$result = $SQL->build($s_del);
$ids = array();
while($row=$SQL->fetch_array($result))
{
$ids[] = $row['filter_id'];
}
//delete all searches greater than 10
$s_del = [
'SELECT' => 'filter_id',
'FROM' => "{$dbprefix}filters",
'WHERE' => "filter_type='file_search' AND filter_user=" . $userinfo['id'],
'ORDER BY' => 'filter_id DESC',
'LIMIT' => '5, 18446744073709551615'
];
$SQL->free($result);
$result = $SQL->build($s_del);
$ids = [];
while ($row=$SQL->fetch_array($result))
{
$ids[] = $row['filter_id'];
}
if($ids != '')
{
$query_del = array(
'DELETE' => "{$dbprefix}filters",
'WHERE' => "filter_id IN('" . implode("', '", $ids) . "')"
);
$SQL->free($result);
$SQL->build($query_del);
}
if ($ids != '')
{
$query_del = [
'DELETE' => "{$dbprefix}filters",
'WHERE' => "filter_id IN('" . implode("', '", $ids) . "')"
];
#add as a file_search filter
$s = array_map('htmlspecialchars', $_POST);
$SQL->build($query_del);
}
#reduce number of array keys
unset($s['search_file'], $s['k_form_key'], $s['k_form_time']);
foreach ($s as $key => $v)
{
if ($s[$key] == '')
{
unset($s[$key]);
}
}
//add as a file_search filter
$s = array_map('htmlspecialchars', $_POST);
$d = serialize($s);
//reduce number of array keys
unset($s['search_file'], $s['k_form_key'], $s['k_form_time']);
if(($search_id = insert_filter('file_search', $d)))
{
foreach ($s as $key => $v)
{
if ($s[$key] == '')
{
unset($s[$key]);
}
}
$d = serialize($s);
if (($search_id = insert_filter('file_search', $d)))
{
$filter = get_filter($search_id, 'file_search');
redirect(basename(ADMIN_PATH) . "?cp=c_files&search_id=" . $filter['filter_uid'], false);
}
else
{
kleeja_admin_err($lang['ERROR_TRY_AGAIN'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search', 1);
}
redirect(basename(ADMIN_PATH) . '?cp=c_files&search_id=' . $filter['filter_uid'], false);
}
else
{
kleeja_admin_err($lang['ERROR_TRY_AGAIN'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search', 1);
}
}
if (ip('search_user'))
{
if(!kleeja_check_form_key('adm_users_search'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search&smt=users', 1);
}
if (! kleeja_check_form_key('adm_users_search'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search&smt=users', 1);
}
#delete all searches greater than 10
$s_del = array(
'SELECT' => "filter_id",
'FROM' => "{$dbprefix}filters",
'WHERE' => "filter_type='user_search' AND filter_user=" . $userinfo['id'],
'ORDER BY' => "filter_id DESC",
'LIMIT' => '5, 18446744073709551615'
);
//delete all searches greater than 10
$s_del = [
'SELECT' => 'filter_id',
'FROM' => "{$dbprefix}filters",
'WHERE' => "filter_type='user_search' AND filter_user=" . $userinfo['id'],
'ORDER BY' => 'filter_id DESC',
'LIMIT' => '5, 18446744073709551615'
];
$result = $SQL->build($s_del);
$ids = array();
while($row=$SQL->fetch_array($result))
{
$ids[] = $row['filter_id'];
}
$SQL->free($result);
$result = $SQL->build($s_del);
$ids = [];
while ($row=$SQL->fetch_array($result))
{
$ids[] = $row['filter_id'];
}
$SQL->free($result);
if($ids != '')
{
$query_del = array(
'DELETE' => "{$dbprefix}filters",
'WHERE' => "filter_id IN('" . implode("', '", $ids) . "')"
);
if ($ids != '')
{
$query_del = [
'DELETE' => "{$dbprefix}filters",
'WHERE' => "filter_id IN('" . implode("', '", $ids) . "')"
];
$SQL->build($query_del);
}
$SQL->build($query_del);
}
#add as a user_search filter
$s = $_POST;
unset($s['search_user'], $s['k_form_key'], $s['k_form_time']);
$d = serialize($s);
if(($search_id = insert_filter('user_search', $d)))
{
//add as a user_search filter
$s = $_POST;
unset($s['search_user'], $s['k_form_key'], $s['k_form_time']);
$d = serialize($s);
if (($search_id = insert_filter('user_search', $d)))
{
$filter = get_filter($search_id, 'user_search');
redirect(basename(ADMIN_PATH) . "?cp=g_users&smt=show_su&search_id=" . $filter['filter_uid'], false);
}
else
{
kleeja_admin_err($lang['ERROR_TRY_AGAIN'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search&smt=users', 1);
}
redirect(basename(ADMIN_PATH) . '?cp=g_users&smt=show_su&search_id=' . $filter['filter_uid'], false);
}
else
{
kleeja_admin_err($lang['ERROR_TRY_AGAIN'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search&smt=users', 1);
}
}
//secondary menu
$go_menu = array(
'files' => array('name'=>$lang['SEARCH_FILES'], 'link'=> basename(ADMIN_PATH) . '?cp=h_search&amp;smt=files', 'goto'=>'files', 'current'=> $current_smt == 'files'),
#'sep1' => array('class'=>'separator'),
'users' => array('name'=>$lang['SEARCH_USERS'], 'link'=> basename(ADMIN_PATH) . '?cp=h_search&amp;smt=users', 'goto'=>'users', 'current'=> $current_smt == 'users'),
#'sep2' => array('class'=>'separator'),
);
if(!$default_user_system)
$go_menu = [
'files' => ['name'=>$lang['SEARCH_FILES'], 'link'=> basename(ADMIN_PATH) . '?cp=h_search&amp;smt=files', 'goto'=>'files', 'current'=> $current_smt == 'files'],
//'sep1' => array('class'=>'separator'),
'users' => ['name'=>$lang['SEARCH_USERS'], 'link'=> basename(ADMIN_PATH) . '?cp=h_search&amp;smt=users', 'goto'=>'users', 'current'=> $current_smt == 'users'],
//'sep2' => array('class'=>'separator'),
];
if (! $default_user_system)
{
unset($go_menu['users']);
unset($go_menu['users']);
}

View File

@@ -9,49 +9,51 @@
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
}
#turn time-limit off
//turn time-limit off
@set_time_limit(0);
#get current case
//get current case
$case = g('case', 'str', 'installed');
#set _get form key
//set _get form key
$GET_FORM_KEY = kleeja_add_form_key_get('PLUGINS_FORM_KEY');
$H_FORM_KEYS = kleeja_add_form_key('adm_plugins');
$H_FORM_KEYS = kleeja_add_form_key('adm_plugins');
$action = ADMIN_PATH . '?cp=' . basename(__file__, '.php');
$plugin_install_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=install&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_install_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=install&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_uninstall_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=uninstall&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_enable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=enable&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_disable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=disable&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_download_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=download&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_update_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=update&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_enable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=enable&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_disable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=disable&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_download_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=download&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_update_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=update&amp;' . $GET_FORM_KEY . '&amp;plg=';
//check _GET Csrf token
if (!empty($case) && in_array($case, array('install', 'uninstall', 'enable', 'disable' , 'download' , 'update')))
if (! empty($case) && in_array($case, ['install', 'uninstall', 'enable', 'disable' , 'download' , 'update']))
{
if (!kleeja_check_form_key_get('PLUGINS_FORM_KEY'))
if (! kleeja_check_form_key_get('PLUGINS_FORM_KEY'))
{
kleeja_admin_err($lang['INVALID_GET_KEY'], $action);
exit;
}
}
if(ip('newplugin'))
if (ip('newplugin'))
{
if(!kleeja_check_form_key('adm_plugins'))
if (! kleeja_check_form_key('adm_plugins'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action);
exit;
}
@@ -65,43 +67,42 @@ switch ($case):
case 'store':
case 'check':
# Get installed plugins
$query = array(
'SELECT' => "plg_id, plg_name, plg_ver, plg_disabled, plg_author, plg_dsc",
'FROM' => "{$dbprefix}plugins",
'ORDER BY' => "plg_id ASC",
);
// Get installed plugins
$query = [
'SELECT' => 'plg_id, plg_name, plg_ver, plg_disabled, plg_author, plg_dsc',
'FROM' => "{$dbprefix}plugins",
'ORDER BY' => 'plg_id ASC',
];
$result = $SQL->build($query);
$installed_plugins = array();
$installed_plugins = [];
while ($row = $SQL->fetch($result))
{
$installed_plugins[$row['plg_name']] = $row;
$installed_plugins[$row['plg_name']]['extra_info'] = Plugins::getInstance()->installed_plugin_info($row['plg_name']);
$installed_plugins[$row['plg_name']]['icon'] = file_exists(
PATH . KLEEJA_PLUGINS_FOLDER . '/' . $row['plg_name'] . "/icon.png"
PATH . KLEEJA_PLUGINS_FOLDER . '/' . $row['plg_name'] . '/icon.png'
)
? PATH . KLEEJA_PLUGINS_FOLDER . '/' . $row['plg_name'] . "/icon.png"
? PATH . KLEEJA_PLUGINS_FOLDER . '/' . $row['plg_name'] . '/icon.png'
: $STYLE_PATH_ADMIN . 'images/plugin.png';
foreach (array('plugin_title', 'plugin_description') as $localizedInfo)
foreach (['plugin_title', 'plugin_description'] as $localizedInfo)
{
if (is_array($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]))
{
if (!empty($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo][$config['language']]))
if (! empty($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo][$config['language']]))
{
$installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo] =
shorten_text($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo][$config['language']], 100);
}
else if (!empty($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]['en']))
elseif (! empty($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]['en']))
{
$installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo] =
shorten_text($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]['en'], 100);
@@ -117,23 +118,23 @@ switch ($case):
$SQL->free($result);
#get available plugins
$dh = opendir(PATH . KLEEJA_PLUGINS_FOLDER);
$available_plugins = array();
//get available plugins
$dh = opendir(PATH . KLEEJA_PLUGINS_FOLDER);
$available_plugins = [];
while (false !== ($folder_name = readdir($dh)))
{
if (is_dir(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
if (is_dir(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
{
if (empty($installed_plugins[$folder_name]))
{
array_push($available_plugins,
array(
[
'name' => $folder_name,
'icon' => file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name . "/icon.png")
? PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name . "/icon.png"
'icon' => file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name . '/icon.png')
? PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name . '/icon.png'
: $STYLE_PATH_ADMIN . 'images/plugin.png',
)
]
);
}
}
@@ -142,23 +143,23 @@ switch ($case):
$no_plugins = sizeof($available_plugins) == 0 && sizeof($installed_plugins) == 0;
$stylee = "admin_plugins";
$stylee = 'admin_plugins';
//do not proceed if not store case
if(! in_array($case, ['store', 'check']))
if (! in_array($case, ['store', 'check']))
{
break;
}
// plugins avilable in kleeja remote catalog
if (!($catalog_plugins = $cache->get('catalog_plugins')))
if (! ($catalog_plugins = $cache->get('catalog_plugins')))
{
$store_link = 'https://raw.githubusercontent.com/kleeja-official/store-catalog/master/catalog.json';
$catalog_plugins = fetch_remote_file($store_link);
$catalog_plugins = json_decode($catalog_plugins , true);
$catalog_plugins = json_decode($catalog_plugins, true);
if(json_last_error() == JSON_ERROR_NONE)
if (json_last_error() == JSON_ERROR_NONE)
{
$cache->save('catalog_plugins', $catalog_plugins);
}
@@ -166,14 +167,14 @@ switch ($case):
// make an array for all plugins in kleeja remote catalog
// that are not exsisted locally.
$store_plugins = array();
$store_plugins = [];
$available_plugins_names = array_column($available_plugins, 'name');
foreach ($catalog_plugins as $plugin_info)
foreach ($catalog_plugins as $plugin_info)
{
if ($case == 'store' && (in_array($plugin_info['name'] , $available_plugins_names) ||
if ($case == 'store' && (in_array($plugin_info['name'], $available_plugins_names) ||
! empty($installed_plugins[$plugin_info['name']]) )
)
{
) {
continue;
}
@@ -183,25 +184,25 @@ switch ($case):
strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']),
strtolower($plugin_info['file']['version']),
'>=') || empty($installed_plugins[$plugin_info['name']]))
) {
) {
continue;
}
$store_plugins[$plugin_info['name']] = array(
'name' => $plugin_info['name'],
'developer' => $plugin_info['developer'],
'version' => $plugin_info['file']['version'],
'title' => ! empty($plugin_info['title'][$config['language']]) ? $plugin_info['title'][$config['language']] : $plugin_info['title']['en'],
'website' => $plugin_info['website'],
'current_version' => ! empty($installed_plugins[$plugin_info['name']]) ? strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']) : '',
'kj_min_version' => $plugin_info['kleeja_version']['min'],
'kj_max_version' => $plugin_info['kleeja_version']['max'],
$store_plugins[$plugin_info['name']] = [
'name' => $plugin_info['name'],
'developer' => $plugin_info['developer'],
'version' => $plugin_info['file']['version'],
'title' => ! empty($plugin_info['title'][$config['language']]) ? $plugin_info['title'][$config['language']] : $plugin_info['title']['en'],
'website' => $plugin_info['website'],
'current_version' => ! empty($installed_plugins[$plugin_info['name']]) ? strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']) : '',
'kj_min_version' => $plugin_info['kleeja_version']['min'],
'kj_max_version' => $plugin_info['kleeja_version']['max'],
'kj_version_cmtp' => sprintf($lang[ 'KLJ_VER_NO_PLUGIN'], $plugin_info['kleeja_version']['min'], $plugin_info['kleeja_version']['max']),
'icon' => $plugin_info['icon'] ,
'NotCompatible' => version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION , '<=')
&& version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION , '>=')
? false : true,
);
'icon' => $plugin_info['icon'] ,
'NotCompatible' => version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION, '<=')
&& version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION, '>=')
? false : true,
];
}
$no_store_plugins = sizeof($store_plugins) == 0;
@@ -212,28 +213,29 @@ switch ($case):
//upload a plugin
//
case 'upload':
$ERRORS = array();
$ERRORS = [];
if(intval($userinfo['founder']) !== 1)
if (intval($userinfo['founder']) !== 1)
{
$ERRORS[] = $lang['HV_NOT_PRVLG_ACCESS'];
}
#is uploaded?
if(empty($_FILES['plugin_file']['tmp_name']))
//is uploaded?
if (empty($_FILES['plugin_file']['tmp_name']))
{
$ERRORS[] = $lang['CHOSE_F'];
}
#extract it to plugins folder
if(!sizeof($ERRORS))
//extract it to plugins folder
if (! sizeof($ERRORS))
{
if(class_exists('ZipArchive'))
if (class_exists('ZipArchive'))
{
$zip = new ZipArchive;
if ($zip->open($_FILES['plugin_file']['tmp_name']) === true)
{
if(!$zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
if (! $zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
{
$ERRORS[] = sprintf($lang['EXTRACT_ZIP_FAILED'], KLEEJA_PLUGINS_FOLDER);
}
@@ -250,12 +252,12 @@ switch ($case):
}
}
if(!empty($_FILES['plugin_file']['tmp_name']))
if (! empty($_FILES['plugin_file']['tmp_name']))
{
@unlink($_FILES['plugin_file']['tmp_name']);
}
if(!sizeof($ERRORS))
if (! sizeof($ERRORS))
{
kleeja_admin_info($lang['NO_PROBLEM_AFTER_ZIP'], true, '', true, $action);
}
@@ -272,9 +274,10 @@ switch ($case):
//
case 'install':
if(intval($userinfo['founder']) !== 1)
if (intval($userinfo['founder']) !== 1)
{
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
@@ -287,56 +290,59 @@ switch ($case):
exit('empty($plg_name)');
}
//no plugin selected? back
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
}
else
{
if (!file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php'))
if (! file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php'))
{
if (defined('DEBUG'))
{
exit('!file_exists($plg_name)');
}
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
#if already installed, show a message
if (!empty(Plugins::getInstance()->installed_plugin_info($plg_name)))
//if already installed, show a message
if (! empty(Plugins::getInstance()->installed_plugin_info($plg_name)))
{
kleeja_admin_info($lang['PLUGIN_EXISTS_BEFORE'], true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
$kleeja_plugin = array();
$kleeja_plugin = [];
include PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php';
$install_callback = $kleeja_plugin[$plg_name]['install'];
$plugin_info = $kleeja_plugin[$plg_name]['information'];
$plugin_info = $kleeja_plugin[$plg_name]['information'];
$plugin_first_run = false;
if (!empty($kleeja_plugin[$plg_name]['first_run'][$config['language']]))
if (! empty($kleeja_plugin[$plg_name]['first_run'][$config['language']]))
{
$plugin_first_run = $kleeja_plugin[$plg_name]['first_run'][$config['language']];
}
else if (!empty($kleeja_plugin[$plg_name]['first_run']['en']))
elseif (! empty($kleeja_plugin[$plg_name]['first_run']['en']))
{
$plugin_first_run = $kleeja_plugin[$plg_name]['first_run']['en'];
}
#check if compatible with kleeja
#'plugin_kleeja_version_min' => '1.8',
# Max version of Kleeja that's required to run this plugin
#'plugin_kleeja_version_max' => '3.8',
//check if compatible with kleeja
//'plugin_kleeja_version_min' => '1.8',
// Max version of Kleeja that's required to run this plugin
//'plugin_kleeja_version_max' => '3.8',
if (version_compare(KLEEJA_VERSION, $plugin_info['plugin_kleeja_version_min'], '<'))
{
kleeja_admin_info(
$lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|<|p.min:' . $plugin_info['plugin_kleeja_version_min'],
$lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|<|p.min:' . $plugin_info['plugin_kleeja_version_min'],
true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php')
);
exit;
}
@@ -345,9 +351,10 @@ switch ($case):
if (version_compare(KLEEJA_VERSION, $plugin_info['plugin_kleeja_version_max'], '>'))
{
kleeja_admin_info(
$lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|>|p.max:' . $plugin_info['plugin_kleeja_version_max'],
$lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|>|p.max:' . $plugin_info['plugin_kleeja_version_max'],
true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php')
);
exit;
}
}
@@ -356,26 +363,27 @@ switch ($case):
if (is_array($plugin_info['plugin_description']))
{
$plugin_info['plugin_description'] = !empty($plugin_info['plugin_description']['en']) ? $plugin_info['plugin_description']['en'] : $plugin_info['plugin_description'][0];
$plugin_info['plugin_description'] = ! empty($plugin_info['plugin_description']['en']) ? $plugin_info['plugin_description']['en'] : $plugin_info['plugin_description'][0];
}
#add to database
$insert_query = array(
//add to database
$insert_query = [
'INSERT' => '`plg_name` ,`plg_ver`, `plg_author`, `plg_dsc`, `plg_icon`, `plg_uninstall`, `plg_instructions`, `plg_store`, `plg_files`',
'INTO' => "{$dbprefix}plugins",
'INTO' => "{$dbprefix}plugins",
'VALUES' => "'" . $SQL->escape($plg_name) . "','" . $SQL->escape($plugin_info['plugin_version']) . "', '" . $SQL->escape($plugin_info['plugin_developer']) . "','" . $SQL->escape($plugin_info['plugin_description']) . "', '', '', '', '', ''",
);
];
$SQL->build($insert_query);
#may God protect you brother.
if(is_callable($install_callback))
//may God protect you brother.
if (is_callable($install_callback))
{
$install_callback($SQL->insert_id());
}
#show done, msg
//show done, msg
$text = '<h3>' . $lang['NEW_PLUGIN_ADDED'] . '</h3>';
if ($plugin_first_run)
{
$text .= $plugin_first_run;
@@ -397,9 +405,10 @@ switch ($case):
//
case 'uninstall':
if(intval($userinfo['founder']) !== 1)
if (intval($userinfo['founder']) !== 1)
{
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
@@ -413,58 +422,60 @@ switch ($case):
}
//no plugin selected? back
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
}
else
{
if (!file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php'))
if (! file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php'))
{
if (defined('DEV_STAGE'))
{
exit('!file_exists($plg_name)');
}
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
$kleeja_plugin = array();
$kleeja_plugin = [];
include PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php';
$uninstall_callback = $kleeja_plugin[$plg_name]['uninstall'];
if (!is_callable($uninstall_callback))
if (! is_callable($uninstall_callback))
{
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
$query = array(
'SELECT' => "plg_id",
'FROM' => "{$dbprefix}plugins",
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
);
$query = [
'SELECT' => 'plg_id',
'FROM' => "{$dbprefix}plugins",
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
];
$result = $SQL->build($query);
$pluginDatabaseInfo = $SQL->fetch($result);
#sad to see you go, brother
$uninstall_callback(!empty($pluginDatabaseInfo) ? $pluginDatabaseInfo['plg_id'] : 0);
//sad to see you go, brother
$uninstall_callback(! empty($pluginDatabaseInfo) ? $pluginDatabaseInfo['plg_id'] : 0);
delete_cache('', true);
#remove from database
$query_del = array(
//remove from database
$query_del = [
'DELETE' => "`{$dbprefix}plugins`",
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
);
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
];
$SQL->build($query_del);
#show done, msg
//show done, msg
$text = '<h3>' . $lang['PLUGIN_DELETED'] . '</h3>';
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
@@ -480,9 +491,10 @@ switch ($case):
case 'disable':
case 'enable':
if(intval($userinfo['founder']) !== 1)
if (intval($userinfo['founder']) !== 1)
{
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
@@ -495,23 +507,23 @@ switch ($case):
exit('empty($plg_name)');
}
//no plugin selected? back
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
}
else
{
#update database
$update_query = array(
//update database
$update_query = [
'UPDATE' => "{$dbprefix}plugins",
'SET' => "plg_disabled=" . ($case == 'disable' ? 1 : 0),
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
);
'SET' => 'plg_disabled=' . ($case == 'disable' ? 1 : 0),
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
];
$SQL->build($update_query);
delete_cache('', true);
#show done, msg
//show done, msg
$text = '<h3>' . $lang['PLGUIN_DISABLED_ENABLED'] . '</h3>';
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
@@ -523,18 +535,20 @@ switch ($case):
case 'download':
if(intval($userinfo['founder']) !== 1)
if (intval($userinfo['founder']) !== 1)
{
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
$download_plugin = g('plg');
// update it , rename function doesn't move the folder , if the folder is exists on the new dir
if( file_exists( PATH . KLEEJA_PLUGINS_FOLDER. '/' . $download_plugin . '/init.php' ) )
if ( file_exists( PATH . KLEEJA_PLUGINS_FOLDER . '/' . $download_plugin . '/init.php' ) )
{
redirect( $plugin_update_link . $download_plugin );
exit;
}
@@ -543,22 +557,22 @@ switch ($case):
$catalog_plugins = fetch_remote_file($store_link);
if ($catalog_plugins)
if ($catalog_plugins)
{
$catalog_plugins = json_decode($catalog_plugins , true);
$catalog_plugins = json_decode($catalog_plugins, true);
$store_plugins = [];
$store_plugins = array();
// make an arry for all plugins in kleeja store that not included in our server
foreach ($catalog_plugins as $plugin_info)
foreach ($catalog_plugins as $plugin_info)
{
$store_plugins[$plugin_info['name']] = array(
'name' => $plugin_info['name'] ,
'plg_version' => $plugin_info['file']['version'] ,
'url' => $plugin_info['file']['url'] ,
$store_plugins[$plugin_info['name']] = [
'name' => $plugin_info['name'] ,
'plg_version' => $plugin_info['file']['version'] ,
'url' => $plugin_info['file']['url'] ,
'kj_min_version' => $plugin_info['kleeja_version']['min'] ,
'kj_max_version' => $plugin_info['kleeja_version']['max'] ,
);
];
}
// // => this plugin is hosted in our store
@@ -566,22 +580,22 @@ switch ($case):
{
// check if the version of the plugin is compatible with our kleeja version or not
if (
version_compare(strtolower($store_plugins[$download_plugin]['kj_min_version']), KLEEJA_VERSION , '<=')
&& version_compare(strtolower($store_plugins[$download_plugin]['kj_max_version']), KLEEJA_VERSION , '>=')
)
{
version_compare(strtolower($store_plugins[$download_plugin]['kj_min_version']), KLEEJA_VERSION, '<=')
&& version_compare(strtolower($store_plugins[$download_plugin]['kj_max_version']), KLEEJA_VERSION, '>=')
) {
$download_plugin_link = $store_plugins[$download_plugin]['url'];
$downloaded_plugin_zip = fetch_remote_file($download_plugin_link, PATH . 'cache/' . $download_plugin . '.zip', 60, false, 10, true);
if ($downloaded_plugin_zip)
if ($downloaded_plugin_zip)
{
if (file_exists(PATH . 'cache/' . $download_plugin . '.zip' ) )
if (file_exists(PATH . 'cache/' . $download_plugin . '.zip' ) )
{
$zip = new ZipArchive();
if ($zip->open(PATH . 'cache/' . $download_plugin . '.zip' ) === true)
{
if( $zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
if ( $zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
{
$zip->close();
// we dont need the zip file anymore
@@ -590,18 +604,18 @@ switch ($case):
// for example :: When we extract zip file , the name will be ( advanced-extras-1.0 )
// so we need to remove the version from folder name and replace ( - ) with ( _ )
// and done
$plugin_folder_name = PATH . KLEEJA_PLUGINS_FOLDER. '/' . str_replace('_' , '-' , $download_plugin) . '-' . $store_plugins[$download_plugin]['plg_version'];
rename($plugin_folder_name , PATH . KLEEJA_PLUGINS_FOLDER. '/' . $download_plugin);
$plugin_folder_name = PATH . KLEEJA_PLUGINS_FOLDER . '/' . str_replace('_', '-', $download_plugin) . '-' . $store_plugins[$download_plugin]['plg_version'];
rename($plugin_folder_name, PATH . KLEEJA_PLUGINS_FOLDER . '/' . $download_plugin);
// download or update msg
kleeja_admin_info(
sprintf($lang[ig('update') ? 'PLUGIN_UPDATED' : 'PLUGIN_DOWNLOADED'], $download_plugin),
sprintf($lang[ig('update') ? 'PLUGIN_UPDATED' : 'PLUGIN_DOWNLOADED'], $download_plugin),
ADMIN_PATH . '?cp=' . basename(__file__, '.php')
);
exit;
}
else
else
{
kleeja_admin_err($lang['EXTRACT_ZIP_FAILED']);
}
@@ -612,7 +626,7 @@ switch ($case):
kleeja_admin_err($lang['PLUGIN_FILE_NOT_FOUND']);
}
}
else
else
{
kleeja_admin_err($lang['PLUGINS_SERVER_ERROR']);
}
@@ -622,7 +636,7 @@ switch ($case):
kleeja_admin_err($lang['PLUGIN_N_CMPT_KLJ']);
}
}
else
else
{
kleeja_admin_err(sprintf($lang['PLUGIN_REMOTE_FILE_MISSING'], $download_plugin));
}
@@ -640,12 +654,13 @@ switch ($case):
$plugin_folder_name = PATH . KLEEJA_PLUGINS_FOLDER . '/' . $update_plugin;
if (is_dir($plugin_folder_name))
if (is_dir($plugin_folder_name))
{
delete_plugin_folder($plugin_folder_name);
}
redirect($plugin_download_link . $update_plugin . '&amp;update' );
break;
endswitch;

View File

@@ -9,16 +9,16 @@
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
//for style ..
$stylee = "admin_ban";
$stylee = 'admin_ban';
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php');
$affected = false;
$affected = false;
$H_FORM_KEYS = kleeja_add_form_key('adm_ban');
//
@@ -26,17 +26,17 @@ $H_FORM_KEYS = kleeja_add_form_key('adm_ban');
//
if (ip('submit'))
{
if(!kleeja_check_form_key('adm_ban'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
if (! kleeja_check_form_key('adm_ban'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
}
$query = array(
'SELECT' => 'ban',
'FROM' => "{$dbprefix}stats"
);
$query = [
'SELECT' => 'ban',
'FROM' => "{$dbprefix}stats"
];
$result = $SQL->build($query);
@@ -48,13 +48,14 @@ $ban = p('ban_text', 'str', $current_ban_data['ban']);
if (ip('submit'))
{
//update
$update_query = array(
'UPDATE' => "{$dbprefix}stats",
'SET' => "ban='" . $SQL->escape($ban) . "'"
);
$update_query = [
'UPDATE' => "{$dbprefix}stats",
'SET' => "ban='" . $SQL->escape($ban) . "'"
];
$SQL->build($update_query);
if($SQL->affected())
if ($SQL->affected())
{
$affected = true;
delete_cache('data_ban');
@@ -67,7 +68,7 @@ $SQL->freeresult($result);
//after submit
if (ip('submit'))
{
$text = ($affected ? $lang['BAN_UPDATED'] : $lang['NO_UP_CHANGE_S']);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
$stylee = "admin_info";
$text = ($affected ? $lang['BAN_UPDATED'] : $lang['NO_UP_CHANGE_S']);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
$stylee = 'admin_info';
}

View File

@@ -9,16 +9,16 @@
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
//for style ..
$stylee = "admin_rules";
$stylee = 'admin_rules';
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php');
$affected = false;
$affected = false;
$H_FORM_KEYS = kleeja_add_form_key('adm_rules');
//
@@ -26,40 +26,41 @@ $H_FORM_KEYS = kleeja_add_form_key('adm_rules');
//
if (ip('submit'))
{
if(!kleeja_check_form_key('adm_rules'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
if (! kleeja_check_form_key('adm_rules'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
}
$query = array(
'SELECT' => 'rules',
'FROM' => "{$dbprefix}stats"
);
$query = [
'SELECT' => 'rules',
'FROM' => "{$dbprefix}stats"
];
$result = $SQL->build($query);
while($row=$SQL->fetch_array($result))
while ($row=$SQL->fetch_array($result))
{
$rules = p('rules_text', 'str', $row['rules']);
//when submit
if (ip('submit'))
{
//update
$update_query = array(
'UPDATE' => "{$dbprefix}stats",
'SET' => "rules = '" . $SQL->real_escape(htmlspecialchars_decode($rules)) . "'"
);
$rules = p('rules_text', 'str', $row['rules']);
$SQL->build($update_query);
if($SQL->affected())
{
$affected = true;
delete_cache('data_rules');
}
}
//when submit
if (ip('submit'))
{
//update
$update_query = [
'UPDATE' => "{$dbprefix}stats",
'SET' => "rules = '" . $SQL->real_escape(htmlspecialchars_decode($rules)) . "'"
];
$SQL->build($update_query);
if ($SQL->affected())
{
$affected = true;
delete_cache('data_rules');
}
}
}
$SQL->freeresult($result);
@@ -68,7 +69,7 @@ $SQL->freeresult($result);
//after submit
if (ip('submit'))
{
$text = ($affected ? $lang['RULES_UPDATED'] : $lang['NO_UP_CHANGE_S']);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
$stylee = "admin_info";
$text = ($affected ? $lang['RULES_UPDATED'] : $lang['NO_UP_CHANGE_S']);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
$stylee = 'admin_info';
}

View File

@@ -8,14 +8,14 @@
*/
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
#current secondary menu action
$current_smt = preg_replace('/[^a-z0-9_]/i','', g('smt', 'str', 'general'));
//current secondary menu action
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
$action = ADMIN_PATH . '?cp=' . basename(__file__, '.php');
@@ -23,7 +23,7 @@ $H_FORM_KEYS = kleeja_add_form_key('adm_styles');
//for style ..
$stylee = "admin_styles";
$stylee = 'admin_styles';
@@ -44,7 +44,7 @@ if (ip('style_choose') || ig('style_choose'))
// make style as default
//check _GET Csrf token
if (isset($_REQUEST['home']) && !kleeja_check_form_key_get('adm_start_actions'))
if (isset($_REQUEST['home']) && ! kleeja_check_form_key_get('adm_start_actions'))
{
kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=start', 2);
}
@@ -55,7 +55,7 @@ if (ip('style_choose') || ig('style_choose'))
//
if (($style_info = kleeja_style_info($style_id)) != false)
{
if (isset($style_info['depend_on']) && !file_exists(PATH . 'styles/' . $style_info['depend_on']))
if (isset($style_info['depend_on']) && ! file_exists(PATH . 'styles/' . $style_info['depend_on']))
{
kleeja_admin_err(sprintf($lang['DEPEND_ON_NO_STYLE_ERR'], $style_info['depend_on']));
}
@@ -71,10 +71,10 @@ if (ip('style_choose') || ig('style_choose'))
$plugins_required = explode(',', $style_info['plugins_required']);
$plugins_required = array_map('trim', $plugins_required);
$query = array(
$query = [
'SELECT' => 'plg_name, plg_disabled',
'FROM' => "{$dbprefix}plugins",
);
'FROM' => "{$dbprefix}plugins",
];
$result = $SQL->build($query);
@@ -93,6 +93,7 @@ if (ip('style_choose') || ig('style_choose'))
$SQL->freeresult($result);
$plugins_required = array_flip($plugins_required);
if (sizeof($plugins_required))
{
kleeja_admin_err(sprintf($lang['PLUGINS_REQ_NO_STYLE_ERR'], implode(', ', $plugins_required)));
@@ -110,42 +111,41 @@ if (ip('style_choose') || ig('style_choose'))
//show msg
kleeja_admin_info(sprintf($lang['STYLE_NOW_IS_DEFAULT'], htmlspecialchars($style_id)), true, '', true, basename(ADMIN_PATH) . '?cp=' . (isset($_REQUEST['home']) ? 'start' : basename(__file__, '.php')));
}
else if (ip('newstyle'))
elseif (ip('newstyle'))
{
if(intval($userinfo['founder']) !== 1)
if (intval($userinfo['founder']) !== 1)
{
$ERRORS[] = $lang['HV_NOT_PRVLG_ACCESS'];
}
if(!kleeja_check_form_key('adm_styles'))
if (! kleeja_check_form_key('adm_styles'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action);
}
$ERRORS = array();
$ERRORS = [];
#is uploaded?
if(empty($_FILES['style_file']['tmp_name']))
//is uploaded?
if (empty($_FILES['style_file']['tmp_name']))
{
$ERRORS[] = $lang['CHOSE_F'];
}
#extract it to plugins folder
if(!sizeof($ERRORS))
//extract it to plugins folder
if (! sizeof($ERRORS))
{
if(class_exists('ZipArchive'))
if (class_exists('ZipArchive'))
{
$zip = new ZipArchive;
if ($zip->open($_FILES['style_file']['tmp_name']) === true)
{
if(!$zip->extractTo(PATH . 'styles'))
if (! $zip->extractTo(PATH . 'styles'))
{
$ERRORS[] = sprintf($lang['EXTRACT_ZIP_FAILED'], 'styles');
}
@@ -162,13 +162,13 @@ else if (ip('newstyle'))
}
}
if(!empty($_FILES['style_file']['tmp_name']))
if (! empty($_FILES['style_file']['tmp_name']))
{
@unlink($_FILES['style_file']['tmp_name']);
}
if(!sizeof($ERRORS))
if (! sizeof($ERRORS))
{
kleeja_admin_info($lang['NO_PROBLEM_AFTER_ZIP'], true, '', true, $action);
}
@@ -180,33 +180,34 @@ else if (ip('newstyle'))
//get styles
$arr = array();
$arr = [];
if ($dh = @opendir(PATH . 'styles'))
{
while (false !== ($folder_name = readdir($dh)))
{
if (is_dir(PATH . 'styles/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
if (is_dir(PATH . 'styles/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
{
#info
$style_info_arr = array
(
'name' => $folder_name,
'desc' => '',
//info
$style_info_arr =
[
'name' => $folder_name,
'desc' => '',
'copyright'=> '',
'version'=> ''
);
'version' => ''
];
if(($style_info = kleeja_style_info($folder_name)) != false)
if (($style_info = kleeja_style_info($folder_name)) != false)
{
foreach (array('name', 'desc', 'copyright', 'version') as $InfoKey)
foreach (['name', 'desc', 'copyright', 'version'] as $InfoKey)
{
if (array_key_exists($InfoKey, $style_info))
{
if(is_array($style_info[$InfoKey]))
if (is_array($style_info[$InfoKey]))
{
$style_info_arr[$InfoKey] = !empty($style_info[$InfoKey][$config['language']])
$style_info_arr[$InfoKey] = ! empty($style_info[$InfoKey][$config['language']])
? htmlspecialchars($style_info[$InfoKey][$config['language']])
: htmlspecialchars($style_info[$InfoKey]['en']);
}
@@ -218,16 +219,16 @@ if ($dh = @opendir(PATH . 'styles'))
}
}
$arr[] = array
(
'style_name' => $folder_name,
'is_default' => $config['style'] == $folder_name ? true : false,
$arr[] =
[
'style_name' => $folder_name,
'is_default' => $config['style'] == $folder_name ? true : false,
'link_mk_default' => basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&amp;style_choose=' . $folder_name,
'icon' => file_exists(PATH . 'styles/' . $folder_name . "/screenshot.png")
? PATH . 'styles/' . $folder_name . "/screenshot.png"
'icon' => file_exists(PATH . 'styles/' . $folder_name . '/screenshot.png')
? PATH . 'styles/' . $folder_name . '/screenshot.png'
: $STYLE_PATH_ADMIN . 'images/style.png',
'info' => $style_info_arr
);
];
}
}

View File

@@ -7,18 +7,18 @@
*
*/
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
//for style ..
$stylee = "admin_extra";
$stylee = 'admin_extra';
$current_smt= preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'he'));
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&amp;smt=' . $current_smt;
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&amp;smt=' . $current_smt;
$H_FORM_KEYS= kleeja_add_form_key('adm_extra');
//
@@ -26,19 +26,19 @@ $H_FORM_KEYS= kleeja_add_form_key('adm_extra');
//
if (ip('submit'))
{
if(!kleeja_check_form_key('adm_extra'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
if (! kleeja_check_form_key('adm_extra'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
}
$query = array(
'SELECT' => 'ex_header,ex_footer',
'FROM' => "{$dbprefix}stats"
);
$query = [
'SELECT' => 'ex_header,ex_footer',
'FROM' => "{$dbprefix}stats"
];
$result = $SQL->build($query);
//is there any change !
$affected = false;
@@ -51,28 +51,28 @@ if (ip('submit'))
$update_sql = '';
if(g('smt') == 'fe')
if (g('smt') == 'fe')
{
$ex_footer = p('ex_footer', 'str');
$ex_footer = p('ex_footer', 'str');
$update_sql = "ex_footer = '" . $SQL->real_escape(htmlspecialchars_decode($ex_footer)) . "'";
}
else
{
$ex_header = p('ex_header', 'str');
$ex_header = p('ex_header', 'str');
$update_sql = "ex_header = '" . $SQL->real_escape(htmlspecialchars_decode($ex_header)) . "'";
}
//update
$update_query = array(
'UPDATE' => "{$dbprefix}stats",
'SET' => $update_sql
);
$update_query = [
'UPDATE' => "{$dbprefix}stats",
'SET' => $update_sql
];
$SQL->build($update_query);
if($SQL->affected())
if ($SQL->affected())
{
$affected = true;
//delete cache ..
@@ -95,12 +95,12 @@ $SQL->freeresult($result);
//after submit
if (ip('submit'))
{
kleeja_admin_info(($affected ? $lang['EXTRA_UPDATED'] : $lang['NO_UP_CHANGE_S']), true, '', true, $action);
kleeja_admin_info(($affected ? $lang['EXTRA_UPDATED'] : $lang['NO_UP_CHANGE_S']), true, '', true, $action);
}
//secondary menu
$go_menu = array(
'he' => array('name'=>$lang['ADD_HEADER_EXTRA'], 'link'=> basename(ADMIN_PATH) . '?cp=n_extra&amp;smt=he', 'goto'=>'he', 'current'=> $current_smt == 'he'),
'fe' => array('name'=>$lang['ADD_FOOTER_EXTRA'], 'link'=> basename(ADMIN_PATH) . '?cp=n_extra&amp;smt=fe', 'goto'=>'fe', 'current'=> $current_smt == 'fe'),
);
$go_menu = [
'he' => ['name'=>$lang['ADD_HEADER_EXTRA'], 'link'=> basename(ADMIN_PATH) . '?cp=n_extra&amp;smt=he', 'goto'=>'he', 'current'=> $current_smt == 'he'],
'fe' => ['name'=>$lang['ADD_FOOTER_EXTRA'], 'link'=> basename(ADMIN_PATH) . '?cp=n_extra&amp;smt=fe', 'goto'=>'fe', 'current'=> $current_smt == 'fe'],
];

View File

@@ -8,95 +8,95 @@
*/
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
$stylee = "admin_check_update";
$stylee = 'admin_check_update';
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
$update_link = $config['siteurl'] . 'install/update.php?lang=' . $config['language'];
#to prevent getting the url data for all cats
if($current_smt == 'check'):
//to prevent getting the url data for all cats
if ($current_smt == 'check'):
//get data from kleeja github repo
if (! ($version_data = $cache->get('kleeja_repo_version')))
{
$github_data = fetch_remote_file('https://raw.githubusercontent.com/awssat/kleeja/master/includes/version.php', false, 6);
//get data from kleeja github repo
if (! ($version_data = $cache->get('kleeja_repo_version')))
{
$github_data = fetch_remote_file('https://raw.githubusercontent.com/awssat/kleeja/master/includes/version.php', false, 6);
if (! empty($github_data))
{
preg_match_all('/define\(\'KLEEJA_VERSION\',\s{1,4}\'([^\']+)\'\);/', $github_data, $matches, PREG_SET_ORDER, 0);
$version_data = trim(htmlspecialchars($matches[0][1]));
$cache->save('kleeja_repo_version', $version_data, 3600 * 2);
}
}
if (! empty($github_data))
{
preg_match_all('/define\(\'KLEEJA_VERSION\',\s{1,4}\'([^\']+)\'\);/', $github_data, $matches, PREG_SET_ORDER, 0);
$version_data = trim(htmlspecialchars($matches[0][1]));
$cache->save('kleeja_repo_version', $version_data, 3600 * 2);
}
}
$error = 0;
$error = 0;
if(empty($version_data))
{
$text = $lang['ERROR_CHECK_VER'];
$error = 1;
}
else
{
if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '<'))
{
$text = sprintf($lang['UPDATE_NOW_S'] , KLEEJA_VERSION, strtolower($version_data)) . '<br /><br />' . $lang['UPDATE_KLJ_NOW'];
$error = 1;
}
else if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '='))
{
$text = $lang['U_LAST_VER_KLJ'];
}
else if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '>'))
{
$text = $lang['U_USE_PRE_RE'];
}
else
{
$text = $lang['ERROR_CHECK_VER'] . ' [code: ' . htmlspecialchars($version_data) .']';
}
}
if (empty($version_data))
{
$text = $lang['ERROR_CHECK_VER'];
$error = 1;
}
else
{
if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '<'))
{
$text = sprintf($lang['UPDATE_NOW_S'], KLEEJA_VERSION, strtolower($version_data)) . '<br /><br />' . $lang['UPDATE_KLJ_NOW'];
$error = 1;
}
elseif (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '='))
{
$text = $lang['U_LAST_VER_KLJ'];
}
elseif (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '>'))
{
$text = $lang['U_USE_PRE_RE'];
}
else
{
$text = $lang['ERROR_CHECK_VER'] . ' [code: ' . htmlspecialchars($version_data) . ']';
}
}
$data = array(
'version_number' => $version_data,
'last_check' => time()
);
$data = [
'version_number' => $version_data,
'last_check' => time()
];
$data = serialize($data);
update_config('new_version', $SQL->real_escape($data), false);
delete_cache('data_config');
$adminAjaxContent = $error . ':::' . $text;
$adminAjaxContent = $error . ':::' . $text;
elseif($current_smt == 'general'):
elseif ($current_smt == 'general'):
// if(!$error)
// {
//To prevent expected error [ infinit loop ]
if(ig('show_msg'))
{
$query_get = array(
'SELECT' => '*',
'FROM' => "{$dbprefix}config",
'WHERE' => "name = 'new_version'"
);
//To prevent expected error [ infinit loop ]
if (ig('show_msg'))
{
$query_get = [
'SELECT' => '*',
'FROM' => "{$dbprefix}config",
'WHERE' => "name = 'new_version'"
];
$result_get = $SQL->build($query_get);
$result_get = $SQL->build($query_get);
if(!$SQL->num_rows($result_get))
{
//add new config value
add_config('new_version', '');
}
}
if (! $SQL->num_rows($result_get))
{
//add new config value
add_config('new_version', '');
}
}
// }
@@ -104,12 +104,12 @@ elseif($current_smt == 'general'):
$showMessage = ig('show_msg');
#end current_smt == general
//end current_smt == general
endif;
//secondary menu
$go_menu = array(
'general' => array('name'=>$lang['R_CHECK_UPDATE'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&amp;smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'),
'howto' => array('name'=>$lang['HOW_UPDATE_KLEEJA'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&amp;smt=howto', 'goto'=>'howto', 'current'=> $current_smt == 'howto'),
'site' => array('name'=>'Kleeja.com', 'link'=> 'http://www.kleeja.com', 'goto'=>'site', 'current'=> $current_smt == 'site'),
);
$go_menu = [
'general' => ['name'=>$lang['R_CHECK_UPDATE'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&amp;smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'],
'howto' => ['name'=>$lang['HOW_UPDATE_KLEEJA'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&amp;smt=howto', 'goto'=>'howto', 'current'=> $current_smt == 'howto'],
'site' => ['name'=>'Kleeja.com', 'link'=> 'http://www.kleeja.com', 'goto'=>'site', 'current'=> $current_smt == 'site'],
];

View File

@@ -9,58 +9,59 @@
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
#turn time-limit off
//turn time-limit off
@set_time_limit(0);
#get current case
//get current case
$case = false;
if(ig('case'))
if (ig('case'))
{
$case = g('case');
$case = g('case');
}
#set form ket
//set form ket
$GET_FORM_KEY = kleeja_add_form_key_get('REPAIR_FORM_KEY');
//check _GET Csrf token
if($case && in_array($case, array('clearc', 'sync_files', 'sync_images', 'sync_users', 'tables', 'sync_sizes', 'status_file')))
if ($case && in_array($case, ['clearc', 'sync_files', 'sync_images', 'sync_users', 'tables', 'sync_sizes', 'status_file']))
{
if(!kleeja_check_form_key_get('REPAIR_FORM_KEY'))
{
kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH), 2);
}
if (! kleeja_check_form_key_get('REPAIR_FORM_KEY'))
{
kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH), 2);
}
}
switch($case):
switch ($case):
default:
# Get real number from database right now
$all_files = get_actual_stats('files');
// Get real number from database right now
$all_files = get_actual_stats('files');
$all_images = get_actual_stats('imgs');
$all_users = get_actual_stats('users');
$all_sizes = readable_size(get_actual_stats('sizes'));
$all_users = get_actual_stats('users');
$all_sizes = readable_size(get_actual_stats('sizes'));
#links
$del_cache_link = basename(ADMIN_PATH) . '?cp=r_repair&amp;case=clearc&amp;' . $GET_FORM_KEY;
$resync_files_link = $config['siteurl'] . 'go.php?go=resync&amp;case=sync_files';
//links
$del_cache_link = basename(ADMIN_PATH) . '?cp=r_repair&amp;case=clearc&amp;' . $GET_FORM_KEY;
$resync_files_link = $config['siteurl'] . 'go.php?go=resync&amp;case=sync_files';
$resync_images_link = $config['siteurl'] . 'go.php?go=resync&amp;case=sync_images';
$resync_users_link = basename(ADMIN_PATH) . '?cp=r_repair&amp;case=sync_users&amp;' . $GET_FORM_KEY;
$resync_sizes_link = basename(ADMIN_PATH) . '?cp=r_repair&amp;case=sync_sizes&amp;' . $GET_FORM_KEY;
$resync_users_link = basename(ADMIN_PATH) . '?cp=r_repair&amp;case=sync_users&amp;' . $GET_FORM_KEY;
$resync_sizes_link = basename(ADMIN_PATH) . '?cp=r_repair&amp;case=sync_sizes&amp;' . $GET_FORM_KEY;
$repair_tables_link = basename(ADMIN_PATH) . '?cp=r_repair&amp;case=tables&amp;' . $GET_FORM_KEY;
$queue_cron_job_url = $config['siteurl'] . 'go.php?go=queue';
$stylee = "admin_repair";
$stylee = 'admin_repair';
break;
@@ -70,23 +71,24 @@ break;
//
case 'tables':
$query = "SHOW TABLE STATUS";
$query = 'SHOW TABLE STATUS';
$result = $SQL->query($query);
$text = '';
while($row=$SQL->fetch_array($result))
$text = '';
while ($row=$SQL->fetch_array($result))
{
$queryf = "REPAIR TABLE `" . $row['Name'] . "`";
$resultf = $SQL->query($queryf);
if ($resultf)
{
$text .= '<li>' . $lang['REPAIRE_TABLE'] . $row['Name'] . '</li>';
}
$queryf = 'REPAIR TABLE `' . $row['Name'] . '`';
$resultf = $SQL->query($queryf);
if ($resultf)
{
$text .= '<li>' . $lang['REPAIRE_TABLE'] . $row['Name'] . '</li>';
}
}
$SQL->freeresult($result);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
$stylee = 'admin_info';
@@ -98,31 +100,31 @@ break;
case 'sync_sizes':
$query_s = array(
'SELECT' => 'size',
'FROM' => "{$dbprefix}files"
);
$query_s = [
'SELECT' => 'size',
'FROM' => "{$dbprefix}files"
];
$result_s = $SQL->build($query_s);
$files_number = $files_sizes = 0;
while($row=$SQL->fetch_array($result_s))
while ($row=$SQL->fetch_array($result_s))
{
$files_number++;
$files_sizes = $files_sizes+$row['size'];
$files_number++;
$files_sizes = $files_sizes+$row['size'];
}
$SQL->freeresult($result_s);
$update_query = array(
'UPDATE' => "{$dbprefix}stats",
'SET' => "files=" . $files_number . ", sizes=" . $files_sizes
);
$update_query = [
'UPDATE' => "{$dbprefix}stats",
'SET' => 'files=' . $files_number . ', sizes=' . $files_sizes
];
if ($SQL->build($update_query))
{
$text .= '<li>' . $lang['REPAIRE_F_STAT'] . '</li>';
$text .= '<li>' . $lang['REPAIRE_F_STAT'] . '</li>';
}
delete_cache('data_stats');
@@ -137,31 +139,31 @@ break;
//
case 'sync_users':
$query_w = array(
'SELECT' => 'name',
'FROM' => "{$dbprefix}users"
);
$query_w = [
'SELECT' => 'name',
'FROM' => "{$dbprefix}users"
];
$result_w = $SQL->build($query_w);
$user_number = 0;
while($row=$SQL->fetch_array($result_w))
while ($row=$SQL->fetch_array($result_w))
{
$user_number++;
$user_number++;
}
$SQL->freeresult($result_w);
$update_query = array(
'UPDATE' => "{$dbprefix}stats",
'SET' => "users=" . $user_number
);
$update_query = [
'UPDATE' => "{$dbprefix}stats",
'SET' => 'users=' . $user_number
];
$result = $SQL->build($update_query);
delete_cache('data_stats');
$text = sprintf($lang['SYNCING'], $lang['USERS_ST']);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
$stylee = 'admin_info';
@@ -174,12 +176,12 @@ break;
//
case 'clearc':
#clear cache
//clear cache
delete_cache('', true);
#show done, msg
//show done, msg
$text .= '<li>' . $lang['REPAIRE_CACHE'] . '</li>';
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
$stylee = 'admin_info';
@@ -188,41 +190,37 @@ break;
//toggle admin start boxes
case 'toggle_start_box':
if(! kleeja_check_form_key_get('adm_start_actions', 3600))
{
header('HTTP/1.1 405 Method Not Allowed');
$adminAjaxContent = $lang['INVALID_FORM_KEY'];
}
else
{
$items = explode(':', $config['hidden_start_boxes']);
$items = array_filter($items);
if (! kleeja_check_form_key_get('adm_start_actions', 3600))
{
header('HTTP/1.1 405 Method Not Allowed');
$adminAjaxContent = $lang['INVALID_FORM_KEY'];
}
else
{
$items = explode(':', $config['hidden_start_boxes']);
$items = array_filter($items);
$name = g('name');
$hide = g('toggle', 'int') == 1;
if(in_array($name, $items) && ! $hide)
{
$new_items = array_diff($items, [$name]);
}
else if($hide)
{
$new_items = $items;
$new_items[] = $name;
}
$name = g('name');
$hide = g('toggle', 'int') == 1;
if (in_array($name, $items) && ! $hide)
{
$new_items = array_diff($items, [$name]);
}
elseif ($hide)
{
$new_items = $items;
$new_items[] = $name;
}
if ($new_items != $items)
{
update_config('hidden_start_boxes', implode(':', $new_items));
}
$adminAjaxContent = $lang['CONFIGS_UPDATED'];
}
if($new_items != $items)
{
update_config('hidden_start_boxes', implode(':', $new_items));
}
$adminAjaxContent = $lang['CONFIGS_UPDATED'];
}
break;
endswitch;

View File

@@ -9,51 +9,51 @@
// not for directly open
if (!defined('IN_ADMIN'))
if (! defined('IN_ADMIN'))
{
exit();
exit();
}
//style of
$stylee = "admin_start";
$h_lst_files = basename(ADMIN_PATH) . '?cp=c_files&amp;last_visit=';
$h_lst_imgs = basename(ADMIN_PATH) . '?cp=d_img_ctrl&amp;last_visit=';
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
$stylee = 'admin_start';
$h_lst_files = basename(ADMIN_PATH) . '?cp=c_files&amp;last_visit=';
$h_lst_imgs = basename(ADMIN_PATH) . '?cp=d_img_ctrl&amp;last_visit=';
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
$GET_FORM_KEY = kleeja_add_form_key_get('adm_start_actions');
//data
$lst_reg = empty($stat_last_user) ? $lang['UNKNOWN'] : $stat_last_user;
$files_number = $stat_files + $stat_imgs;
$files_sizes = readable_size($stat_sizes);
$users_number = $stat_users;
$last_del_fles = (int) $config['del_f_day'] <= 0 ? $lang['CLOSED_FEATURE'] : kleeja_date($stat_last_f_del);
$php_version = isset($NO_PHPINFO) || !function_exists('phpinfo') ? phpversion() : 'PHP ' . phpversion();
$mysql_version = 'MySQL ' . $SQL->mysql_version();
$lst_reg = empty($stat_last_user) ? $lang['UNKNOWN'] : $stat_last_user;
$files_number = $stat_files + $stat_imgs;
$files_sizes = readable_size($stat_sizes);
$users_number = $stat_users;
$last_del_fles = (int) $config['del_f_day'] <= 0 ? $lang['CLOSED_FEATURE'] : kleeja_date($stat_last_f_del);
$php_version = isset($NO_PHPINFO) || ! function_exists('phpinfo') ? phpversion() : 'PHP ' . phpversion();
$mysql_version = 'MySQL ' . $SQL->mysql_version();
$max_execution_time = function_exists('ini_get') ? @ini_get('max_execution_time') : @get_cfg_var('max_execution_time');
$upload_max_filesize= function_exists('ini_get') ? @ini_get('upload_max_filesize') : @get_cfg_var('upload_max_filesize');
$post_max_size = function_exists('ini_get') ? @ini_get('post_max_size') : @get_cfg_var('post_max_size');
$memory_limit = function_exists('ini_get') ? @ini_get('memory_limit') : @get_cfg_var('memory_limit');
$s_last_google = $stat_last_google == 0 ? '[ ? ]' : kleeja_date($stat_last_google);
$s_google_num = $stat_google_num;
$s_last_bing = $stat_last_bing == 0 ? '[ ? ]' : kleeja_date($stat_last_bing);
$s_bing_num = $stat_bing_num;
$usernamelang = sprintf($lang['KLEEJA_CP_W'], $username);
$current_year = date('Y');
$post_max_size = function_exists('ini_get') ? @ini_get('post_max_size') : @get_cfg_var('post_max_size');
$memory_limit = function_exists('ini_get') ? @ini_get('memory_limit') : @get_cfg_var('memory_limit');
$s_last_google = $stat_last_google == 0 ? '[ ? ]' : kleeja_date($stat_last_google);
$s_google_num = $stat_google_num;
$s_last_bing = $stat_last_bing == 0 ? '[ ? ]' : kleeja_date($stat_last_bing);
$s_bing_num = $stat_bing_num;
$usernamelang = sprintf($lang['KLEEJA_CP_W'], $username);
$current_year = date('Y');
$startBoxes = array(
'notifications' => array('title' => $lang['NOTIFICATIONS'], 'hidden' => (int) adm_is_start_box_hidden('notifications')),
'statsBoxes' => array('title' => $lang['STATS_BOXES'], 'hidden' => (int) adm_is_start_box_hidden('statsBoxes')),
'lastVisitActions' => array('title' => $lang['LAST_VISIT'], 'hidden' => (int) adm_is_start_box_hidden('lastVisitActions')),
'statsChart' => array('title' => $lang['STATS'], 'hidden' => (int) adm_is_start_box_hidden('statsChart')),
'hurryActions' => array('title' => $lang['HURRY_HURRY'], 'hidden' => (int) adm_is_start_box_hidden('hurryActions')),
'extraStats' => array('title' => $lang['OTHER_INFO'], 'hidden' => (int) adm_is_start_box_hidden('extraStats')),
);
$startBoxes = [
'notifications' => ['title' => $lang['NOTIFICATIONS'], 'hidden' => (int) adm_is_start_box_hidden('notifications')],
'statsBoxes' => ['title' => $lang['STATS_BOXES'], 'hidden' => (int) adm_is_start_box_hidden('statsBoxes')],
'lastVisitActions' => ['title' => $lang['LAST_VISIT'], 'hidden' => (int) adm_is_start_box_hidden('lastVisitActions')],
'statsChart' => ['title' => $lang['STATS'], 'hidden' => (int) adm_is_start_box_hidden('statsChart')],
'hurryActions' => ['title' => $lang['HURRY_HURRY'], 'hidden' => (int) adm_is_start_box_hidden('hurryActions')],
'extraStats' => ['title' => $lang['OTHER_INFO'], 'hidden' => (int) adm_is_start_box_hidden('extraStats')],
];
$extra_adm_start_html = '';
//size board by percent
$per = $stat_sizes / ($config['total_size'] * 1048576);
$per = $stat_sizes / ($config['total_size'] * 1048576);
$per1 = round($per*100, 2);
$per1 = $per1 >= 100 ? 100 : $per1;
@@ -61,38 +61,40 @@ $per1 = $per1 >= 100 ? 100 : $per1;
$kleeja_version = '<a href="' . basename(ADMIN_PATH) . '?cp=p_check_update" onclick="javascript:get_kleeja_link(this.href, \'#content\'); return false;" title="' . $lang['R_CHECK_UPDATE'] . '">' . KLEEJA_VERSION . '</a>';
//admin messages system
$ADM_NOTIFICATIONS = array();
$ADM_NOTIFICATIONS = [];
//useing IE6 ! and he is admin ? omg !
$u_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? htmlspecialchars((string) strtolower($_SERVER['HTTP_USER_AGENT'])) : (function_exists('getenv') ? getenv('HTTP_USER_AGENT') : '');
if(is_browser('ie6, ie8, ie7'))
$u_agent = ! empty($_SERVER['HTTP_USER_AGENT']) ? htmlspecialchars((string) strtolower($_SERVER['HTTP_USER_AGENT'])) : (function_exists('getenv') ? getenv('HTTP_USER_AGENT') : '');
if (is_browser('ie6, ie8, ie7'))
{
$ADM_NOTIFICATIONS['IE6'] = array('id' => 'IE6', 'msg_type'=> 'error', 'title'=> $lang['NOTE'], 'msg'=> $lang['ADMIN_USING_IE6']);
$ADM_NOTIFICATIONS['IE6'] = ['id' => 'IE6', 'msg_type'=> 'error', 'title'=> $lang['NOTE'], 'msg'=> $lang['ADMIN_USING_IE6']];
}
//if upgrading from 1rc6 to 1.0, some files must be deleted !
if(file_exists(PATH . 'includes/adm/files.php') || file_exists(PATH . 'admin.php'))
if (file_exists(PATH . 'includes/adm/files.php') || file_exists(PATH . 'admin.php'))
{
$ADM_NOTIFICATIONS['old_files'] = array('id' => 'old_files', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['ADM_UNWANTED_FILES']);
$ADM_NOTIFICATIONS['old_files'] = ['id' => 'old_files', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['ADM_UNWANTED_FILES']];
}
//if html url is enabled but .htaccess is not available in the root dir !
if(!file_exists(PATH . '.htaccess') && (int) $config['mod_writer'] == 1)
if (! file_exists(PATH . '.htaccess') && (int) $config['mod_writer'] == 1)
{
$ADM_NOTIFICATIONS['htmlurlshtaccess'] = array('id' => 'htmlurlshtaccess', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['HTML_URLS_ENABLED_NO_HTCC']);
$ADM_NOTIFICATIONS['htmlurlshtaccess'] = ['id' => 'htmlurlshtaccess', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['HTML_URLS_ENABLED_NO_HTCC']];
}
//updating
$v = @unserialize($config['new_version']);
if(version_compare(strtolower(KLEEJA_VERSION), strtolower($v['version_number']), '<'))
{
$ADM_NOTIFICATIONS['up_ver_klj'] = array(
'id' => 'up_ver_klj',//this not so important row
'msg_type'=> 'error', 'title'=> $lang['R_CHECK_UPDATE'],
'msg'=> sprintf($lang['UPDATE_NOW_S'] , KLEEJA_VERSION, $v['version_number']) . '<br />' . '<a href="http://www.kleeja.com/">www.kleeja.com</a>'
);
is_array($plugin_run_result = Plugins::getInstance()->run('admin_update_now', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
if (version_compare(strtolower(KLEEJA_VERSION), strtolower($v['version_number']), '<'))
{
$ADM_NOTIFICATIONS['up_ver_klj'] = [
'id' => 'up_ver_klj',//this not so important row
'msg_type'=> 'error', 'title'=> $lang['R_CHECK_UPDATE'],
'msg' => sprintf($lang['UPDATE_NOW_S'], KLEEJA_VERSION, $v['version_number']) . '<br />' . '<a href="http://www.kleeja.com/">www.kleeja.com</a>'
];
is_array($plugin_run_result = Plugins::getInstance()->run('admin_update_now', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
}
@@ -101,18 +103,18 @@ is_array($plugin_run_result = Plugins::getInstance()->run('default_admin_page',
//check upload_max_filesize
if(!empty($d_groups) && is_array($d_groups))
if (! empty($d_groups) && is_array($d_groups))
{
$biggest_size = 0;
foreach($d_groups as $gid => $gdata)
foreach ($d_groups as $gid => $gdata)
{
if(!empty($d_groups[$gid]['exts']) && is_array($d_groups[$gid]['exts']))
if (! empty($d_groups[$gid]['exts']) && is_array($d_groups[$gid]['exts']))
{
$u_e_s = $d_groups[$gid]['exts'];
arsort($u_e_s);
if(!empty($u_e_s))
if (! empty($u_e_s))
{
$current_size = array_shift($u_e_s);
$biggest_size = $current_size > $biggest_size ? $current_size : $biggest_size;
@@ -121,50 +123,53 @@ if(!empty($d_groups) && is_array($d_groups))
}
if(strpos($upload_max_filesize, 'M') !== false)
{
$upload_max_filesize_s = ((int) trim(str_replace('M', '', $upload_max_filesize))) * 1048576;
}
else if(strpos($upload_max_filesize, 'G') !== false)
{
$upload_max_filesize_s = ((int) trim(str_replace('G', '', $upload_max_filesize))) * 1073741824;
}else{
if (strpos($upload_max_filesize, 'M') !== false)
{
$upload_max_filesize_s = ((int) trim(str_replace('M', '', $upload_max_filesize))) * 1048576;
}
elseif (strpos($upload_max_filesize, 'G') !== false)
{
$upload_max_filesize_s = ((int) trim(str_replace('G', '', $upload_max_filesize))) * 1073741824;
}
else
{
$upload_max_filesize_s = $upload_max_filesize;
}
if(!empty($upload_max_filesize) && $upload_max_filesize_s < $biggest_size)
{
$ADM_NOTIFICATIONS['file_size_ini_low'] = array(
'id' => 'file_size_ini_low',
'msg_type'=> 'info', 'title'=> $lang['NOTE'],
'msg'=> sprintf($lang['PHPINI_FILESIZE_SMALL'] , readable_size($biggest_size), readable_size($upload_max_filesize_s))
);
}
if (! empty($upload_max_filesize) && $upload_max_filesize_s < $biggest_size)
{
$ADM_NOTIFICATIONS['file_size_ini_low'] = [
'id' => 'file_size_ini_low',
'msg_type'=> 'info', 'title'=> $lang['NOTE'],
'msg' => sprintf($lang['PHPINI_FILESIZE_SMALL'], readable_size($biggest_size), readable_size($upload_max_filesize_s))
];
}
//check post_max_size
if(strpos($post_max_size, 'M') !== false)
{
$post_max_size_s = ((int) trim(str_replace('M', '', $post_max_size))) * 1048576;
}
else if(strpos($post_max_size, 'G') !== false)
{
$post_max_size_s = ((int) trim(str_replace('G', '', $post_max_size))) * 1073741824;
}else
//check post_max_size
if (strpos($post_max_size, 'M') !== false)
{
$post_max_size_s = ((int) trim(str_replace('M', '', $post_max_size))) * 1048576;
}
elseif (strpos($post_max_size, 'G') !== false)
{
$post_max_size_s = ((int) trim(str_replace('G', '', $post_max_size))) * 1073741824;
}
else
{
$post_max_size_s = $post_max_size;
}
$post_max_size_s_must_be = ($config['filesnum'] * $biggest_size) + 5242880;//+ 5 mega to make sure it's ok
$post_max_size_s_must_be = ($config['filesnum'] * $biggest_size) + 5242880;//+ 5 mega to make sure it's ok
if(!empty($post_max_size) && $post_max_size_s < $post_max_size_s_must_be)
{
$ADM_NOTIFICATIONS['post_m_size_ini_low'] = array(
'id' => 'post_m_size_ini_low',
'msg_type'=> 'info', 'title'=> $lang['NOTE'],
'msg'=> sprintf($lang['PHPINI_MPOSTSIZE_SMALL'] , $config['filesnum'], readable_size($post_max_size_s_must_be))
);
}
if (! empty($post_max_size) && $post_max_size_s < $post_max_size_s_must_be)
{
$ADM_NOTIFICATIONS['post_m_size_ini_low'] = [
'id' => 'post_m_size_ini_low',
'msg_type'=> 'info', 'title'=> $lang['NOTE'],
'msg' => sprintf($lang['PHPINI_MPOSTSIZE_SMALL'], $config['filesnum'], readable_size($post_max_size_s_must_be))
];
}
}
//
@@ -172,44 +177,46 @@ if(!empty($d_groups) && is_array($d_groups))
// rev: let's say cache is not refreshed, so we will redirect alots of time,
// so update_done will be good solution
//
if (empty($v['last_check']) || ((time() - $v['last_check']) > 3600 * 24 * 10 && $_SERVER['SERVER_NAME'] != 'localhost' && !ig('update_done')))
if (empty($v['last_check']) || ((time() - $v['last_check']) > 3600 * 24 * 10 && $_SERVER['SERVER_NAME'] != 'localhost' && ! ig('update_done')))
{
redirect(basename(ADMIN_PATH) . '?cp=p_check_update&amp;show_msg=1');
$SQL->close();
exit;
redirect(basename(ADMIN_PATH) . '?cp=p_check_update&amp;show_msg=1');
$SQL->close();
exit;
}
//if config not safe
if(function_exists('fileperms') && !defined('KLEEJA_NO_CONFIG_CHECK') && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' && !@ini_get('safe_mode'))
if (function_exists('fileperms') && ! defined('KLEEJA_NO_CONFIG_CHECK') && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' && ! @ini_get('safe_mode'))
{
if((bool) (@fileperms(PATH . KLEEJA_CONFIG_FILE) & 0x0002))
{
$ADM_NOTIFICATIONS['config_perm'] = array('id' => 'config_perm', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['CONFIG_WRITEABLE']);
}
if ((bool) (@fileperms(PATH . KLEEJA_CONFIG_FILE) & 0x0002))
{
$ADM_NOTIFICATIONS['config_perm'] = ['id' => 'config_perm', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['CONFIG_WRITEABLE']];
}
}
//no htaccess
if(!file_exists(PATH . $config['foldername'] . '/.htaccess'))
if (! file_exists(PATH . $config['foldername'] . '/.htaccess'))
{
$ADM_NOTIFICATIONS['htaccess_u'] = array('id' => 'htaccess_u', 'msg_type'=> 'error', 'title'=> $lang['WARN'], 'msg'=> sprintf($lang['NO_HTACCESS_DIR_UP'], $config['foldername']));
$ADM_NOTIFICATIONS['htaccess_u'] = ['id' => 'htaccess_u', 'msg_type'=> 'error', 'title'=> $lang['WARN'], 'msg'=> sprintf($lang['NO_HTACCESS_DIR_UP'], $config['foldername'])];
}
if(!file_exists(PATH . $config['foldername'] . '/thumbs/.htaccess'))
if (! file_exists(PATH . $config['foldername'] . '/thumbs/.htaccess'))
{
$ADM_NOTIFICATIONS['htaccess_t'] = array('id' => 'htaccess_t', 'msg_type'=> 'error', 'title'=> $lang['WARN'], 'msg'=> sprintf($lang['NO_HTACCESS_DIR_UP_THUMB'], $config['foldername'] . '/thumbs'));
$ADM_NOTIFICATIONS['htaccess_t'] = ['id' => 'htaccess_t', 'msg_type'=> 'error', 'title'=> $lang['WARN'], 'msg'=> sprintf($lang['NO_HTACCESS_DIR_UP_THUMB'], $config['foldername'] . '/thumbs')];
}
//there is cleaning files process now
if((int)$config['klj_clean_files_from'] > 0)
if ((int) $config['klj_clean_files_from'] > 0)
{
$ADM_NOTIFICATIONS['klj_clean_files'] = array('id' => 'klj_clean_files', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['T_CLEANING_FILES_NOW']);
$ADM_NOTIFICATIONS['klj_clean_files'] = ['id' => 'klj_clean_files', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['T_CLEANING_FILES_NOW']];
}
//if there is no thumbs folder
if(!file_exists(PATH . $config['foldername'] . '/thumbs') && (int) $config['thumbs_imgs'] != 0)
if (! file_exists(PATH . $config['foldername'] . '/thumbs') && (int) $config['thumbs_imgs'] != 0)
{
$ADM_NOTIFICATIONS['no_thumbs'] = array('id' => 'no_thumbs', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> sprintf($lang['NO_THUMB_FOLDER'], PATH . $config['foldername'] . '/thumbs'));
$ADM_NOTIFICATIONS['no_thumbs'] = ['id' => 'no_thumbs', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> sprintf($lang['NO_THUMB_FOLDER'], PATH . $config['foldername'] . '/thumbs')];
}
@@ -220,15 +227,15 @@ $translator_copyrights = isset($lang['S_TRANSLATED_BY']) ? $lang['S_TRANSLATED_
//secondary menu
$go_menu = array(
'general' => array('name'=>$lang['GENERAL_STAT'], 'link'=> basename(ADMIN_PATH) . '?cp=start&amp;smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'),
'other' => array('name'=>$lang['OTHER_INFO'], 'link'=> basename(ADMIN_PATH) . '?cp=start&amp;smt=other', 'goto'=>'other', 'current'=> $current_smt == 'other'),
'team' => array('name'=>$lang['KLEEJA_TEAM'], 'link'=> basename(ADMIN_PATH) . '?cp=start&amp;smt=team', 'goto'=>'team', 'current'=> $current_smt == 'team'),
'kj_news' => array('name'=> $lang['KJ_TWEETS'], 'link'=> basename(ADMIN_PATH) . '?cp=start&amp;smt=kj_tweets', 'goto'=>'kj_tweets', 'current'=> $current_smt == 'kj_tweets'),
);
$go_menu = [
'general' => ['name'=>$lang['GENERAL_STAT'], 'link'=> basename(ADMIN_PATH) . '?cp=start&amp;smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'],
'other' => ['name'=>$lang['OTHER_INFO'], 'link'=> basename(ADMIN_PATH) . '?cp=start&amp;smt=other', 'goto'=>'other', 'current'=> $current_smt == 'other'],
'team' => ['name'=>$lang['KLEEJA_TEAM'], 'link'=> basename(ADMIN_PATH) . '?cp=start&amp;smt=team', 'goto'=>'team', 'current'=> $current_smt == 'team'],
'kj_news' => ['name'=> $lang['KJ_TWEETS'], 'link'=> basename(ADMIN_PATH) . '?cp=start&amp;smt=kj_tweets', 'goto'=>'kj_tweets', 'current'=> $current_smt == 'kj_tweets'],
];
# is there a last visit of images and files ?
// is there a last visit of images and files ?
$files_last_visit = filter_exists('f_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id'])
? get_filter('f_lastvisit', 'lastvisit', true, 'filter_uid', $userinfo['id']) : false;
$image_last_visit = filter_exists('i_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id'])
@@ -236,127 +243,130 @@ $image_last_visit = filter_exists('i_lastvisit', 'filter_uid', 'lastvisit', $use
#hurry, hurry section, get styles
$hurry_style_link = basename(ADMIN_PATH) . '?cp=m_styles&amp;sty_t=st&amp;method=2&amp;home=1&amp;smt=curstyle&amp;' . $GET_FORM_KEY . '&amp;style_choose=';
//hurry, hurry section, get styles
$hurry_style_link = basename(ADMIN_PATH) . '?cp=m_styles&amp;sty_t=st&amp;method=2&amp;home=1&amp;smt=curstyle&amp;' . $GET_FORM_KEY . '&amp;style_choose=';
$hurry_styles_list = '';
if ($dh = @opendir(PATH . 'styles'))
{
while (($file = @readdir($dh)) !== false)
{
if(strpos($file, '.') === false && $file != '..' && $file != '.')
{
$hurry_styles_list .= '<option value="' . htmlspecialchars($file) . '"' . ($config['style'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>';
}
}
@closedir($dh);
while (($file = @readdir($dh)) !== false)
{
if (strpos($file, '.') === false && $file != '..' && $file != '.')
{
$hurry_styles_list .= '<option value="' . htmlspecialchars($file) . '"' . ($config['style'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>';
}
}
@closedir($dh);
}
#hurry, hurry section, get languages
$hurry_lang_link = basename(ADMIN_PATH) . '?cp=g_users&smt=general&amp;smt=group_data&' . $GET_FORM_KEY . '&amp;lang_change=';
//hurry, hurry section, get languages
$hurry_lang_link = basename(ADMIN_PATH) . '?cp=g_users&smt=general&amp;smt=group_data&' . $GET_FORM_KEY . '&amp;lang_change=';
$hurry_langs_list = '';
if ($dh = @opendir(PATH . 'lang'))
{
while (($file = @readdir($dh)) !== false)
{
if(strpos($file, '.') === false && $file != '..' && $file != '.')
{
$hurry_langs_list .= '<option value="' . htmlspecialchars($file) . '"' . ($d_groups[$config['default_group']]['configs']['language'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>';
}
}
@closedir($dh);
while (($file = @readdir($dh)) !== false)
{
if (strpos($file, '.') === false && $file != '..' && $file != '.')
{
$hurry_langs_list .= '<option value="' . htmlspecialchars($file) . '"' . ($d_groups[$config['default_group']]['configs']['language'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>';
}
}
@closedir($dh);
}
$hurry_groups_list = '<option value="-1" selected="selected">' . $lang['ALL'] . '</option>';
$hurry_groups_list .= '<option value="' . $config['default_group'] . '">' . $lang['DEFAULT_GROUP'] . '</option>';
foreach($d_groups as $id=>$ddt)
foreach ($d_groups as $id=>$ddt)
{
$hurry_groups_list .= '<option value="' . $id . '">' .
str_replace(array('{lang.ADMINS}', '{lang.USERS}', '{lang.GUESTS}'),
array($lang['ADMINS'], $lang['USERS'], $lang['GUESTS']),
$d_groups[$id]['data']['group_name']) .
'</option>';
$hurry_groups_list .= '<option value="' . $id . '">' .
str_replace(['{lang.ADMINS}', '{lang.USERS}', '{lang.GUESTS}'],
[$lang['ADMINS'], $lang['USERS'], $lang['GUESTS']],
$d_groups[$id]['data']['group_name']) .
'</option>';
}
#hurry, hurry section, links
//hurry, hurry section, links
$del_cache_link = basename(ADMIN_PATH) . '?cp=r_repair&amp;case=clearc&amp;' . kleeja_add_form_key_get('REPAIR_FORM_KEY');
# get stats filter so we can draw a chart for the user
// get stats filter so we can draw a chart for the user
$stats_chart = false;
$cf_query = array(
'SELECT' => 'f.filter_uid, f.filter_value, f.filter_time',
'FROM' => "{$dbprefix}filters f",
'WHERE' => "f.filter_type = 'stats_for_acp'",
'ORDER BY' => 'f.filter_time DESC',
);
$cf_query = [
'SELECT' => 'f.filter_uid, f.filter_value, f.filter_time',
'FROM' => "{$dbprefix}filters f",
'WHERE' => "f.filter_type = 'stats_for_acp'",
'ORDER BY' => 'f.filter_time DESC',
];
$cf_result = $SQL->build($cf_query);
$cf_num = $SQL->num_rows($cf_result);
if($cf_num > 3)
$cf_num = $SQL->num_rows($cf_result);
if ($cf_num > 3)
{
$stats_chart = 'arrayOfDataMulti = new Array(';
$stats_chart = 'arrayOfDataMulti = new Array(';
$comma = false;
#get currently right now stats
$prv_files = get_actual_stats('files');
$prev_imgs = get_actual_stats('imgs');
$prev_date = date('d-n-Y');
$todayIsGone = false;
$comma = false;
//get currently right now stats
$prv_files = get_actual_stats('files');
$prev_imgs = get_actual_stats('imgs');
$prev_date = date('d-n-Y');
$todayIsGone = false;
while($row=$SQL->fetch_array($cf_result))
{
#jump today
if($prev_date == $row['filter_uid'])
{
continue;
}
while ($row=$SQL->fetch_array($cf_result))
{
//jump today
if ($prev_date == $row['filter_uid'])
{
continue;
}
#get this row data
list($s_files, $s_imgs, $s_sizes) = explode(':', $row['filter_value']);
$t_files = $prv_files - $s_files;
$t_imgs = $prev_imgs - $s_imgs;
//get this row data
list($s_files, $s_imgs, $s_sizes) = explode(':', $row['filter_value']);
if(date('d-n-Y') == $prev_date)
{
$day = $lang['TODAY'] . ' ~ ' . $lang['NOW'];
$t_files = $prv_files - $s_files;
$t_imgs = $prev_imgs - $s_imgs;
if($todayIsGone)
{
continue;
}
if (date('d-n-Y') == $prev_date)
{
$day = $lang['TODAY'] . ' ~ ' . $lang['NOW'];
$todayIsGone = true;
}
else
{
$day = $prev_date;
}
if ($todayIsGone)
{
continue;
}
$stats_chart .= ($comma ? ',': '') . "[[$t_files,$t_imgs],'" . ($cf_num > 6 ? str_replace(date('-Y'), '', $day) : $day) . "']";
$todayIsGone = true;
}
else
{
$day = $prev_date;
}
$comma = true;
$prv_files = $s_files;
$prev_imgs = $s_imgs;
$prev_date = $row['filter_uid'];
}
$stats_chart .= ($comma ? ',': '') . "[[$t_files,$t_imgs],'" . ($cf_num > 6 ? str_replace(date('-Y'), '', $day) : $day) . "']";
$stats_chart .= ');';
$comma = true;
$prv_files = $s_files;
$prev_imgs = $s_imgs;
$prev_date = $row['filter_uid'];
}
$stats_chart .= ');';
is_array($plugin_run_result = Plugins::getInstance()->run('stats_start_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$SQL->freeresult($cf_result);
#clean old chart stats
if($cf_num > 10)
{
$query_del = array(
'DELETE' => "{$dbprefix}filters",
'WHERE' => "filter_type = 'stats_for_acp' AND filter_time < " . (time() - (3600 * 24 * 10))
);
$SQL->build($query_del);
}
//clean old chart stats
if ($cf_num > 10)
{
$query_del = [
'DELETE' => "{$dbprefix}filters",
'WHERE' => "filter_type = 'stats_for_acp' AND filter_time < " . (time() - (3600 * 24 * 10))
];
$SQL->build($query_del);
}
}