From f142da94f3097fe751fc60814b76e386ff80c1bf Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Fri, 3 May 2019 23:52:08 +0300
Subject: [PATCH] coding style fixes
---
.gitignore | 1 +
admin/index.php | 420 ++--
do.php | 374 +--
download.php | 2 +-
go.php | 962 ++++----
includes/KleejaUploader.php | 40 +-
includes/adm/a_configs.php | 494 ++--
includes/adm/b_lgoutcp.php | 15 +-
includes/adm/c_files.php | 697 +++---
includes/adm/d_img_ctrl.php | 412 ++--
includes/adm/e_calls.php | 206 +-
includes/adm/f_reports.php | 212 +-
includes/adm/g_users.php | 2033 ++++++++--------
includes/adm/h_search.php | 225 +-
includes/adm/j_plugins.php | 311 +--
includes/adm/k_ban.php | 41 +-
includes/adm/l_rules.php | 67 +-
includes/adm/m_styles.php | 89 +-
includes/adm/n_extra.php | 56 +-
includes/adm/p_check_update.php | 138 +-
includes/adm/r_repair.php | 190 +-
includes/adm/start.php | 396 ++--
includes/auth_integration/api.php | 146 +-
includes/auth_integration/phpbb.php | 497 ++--
includes/auth_integration/vb.php | 361 +--
includes/cache.php | 507 ++--
includes/captcha.php | 121 +-
includes/common.php | 325 +--
includes/functions.php | 2233 +++++++++---------
includes/functions_adm.php | 424 ++--
includes/functions_alternative.php | 282 ++-
includes/functions_display.php | 1048 ++++----
includes/mysql.php | 843 +++----
includes/mysqli.php | 839 +++----
includes/pager.php | 146 +-
includes/phpass.php | 484 ++--
includes/plugins.php | 88 +-
includes/style.php | 129 +-
includes/up_helpers/BMP.php | 204 +-
includes/up_helpers/others.php | 235 +-
includes/up_helpers/remote_uploading.php | 100 +-
includes/up_helpers/thumbs.php | 376 +--
includes/up_helpers/watermark.php | 287 +--
includes/up_methods/defaultUploader.php | 398 ++--
includes/usr.php | 984 ++++----
includes/version.php | 7 +-
index.php | 141 +-
install/includes/default_values.php | 188 +-
install/includes/functions_install.php | 277 +--
install/includes/install_sqls.php | 14 +-
install/includes/update_files/1.7_to_2.0.php | 16 +-
install/index.php | 73 +-
install/install.php | 532 +++--
install/update.php | 263 ++-
lang/ar/acp.php | 520 ++--
lang/ar/common.php | 534 ++---
lang/ar/install.php | 206 +-
lang/en/acp.php | 514 ++--
lang/en/common.php | 528 ++---
lang/en/install.php | 208 +-
serve.php | 55 +-
ucp.php | 1385 +++++------
62 files changed, 12149 insertions(+), 11750 deletions(-)
diff --git a/.gitignore b/.gitignore
index cf17d51..9d57f68 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,4 @@ Project_Default.xml
.project
.vscode/launch.json
.htaccess
+.php_cs.cache
diff --git a/admin/index.php b/admin/index.php
index d7d7574..a4fbe15 100755
--- a/admin/index.php
+++ b/admin/index.php
@@ -12,160 +12,166 @@
* @ignore
*/
define('IN_KLEEJA', true);
-define ('PATH' , '../');
-define ('IN_ADMIN' , true);
+define ('PATH', '../');
+define ('IN_ADMIN', true);
require_once PATH . 'includes/common.php';
-$go_to = ig('cp') ? g('cp') : 'start';
-$username = $usrcp->name();
-$AJAX_ACP = defined('AJAX_ACP');
+$go_to = ig('cp') ? g('cp') : 'start';
+$username = $usrcp->name();
+$AJAX_ACP = defined('AJAX_ACP');
$config['enable_captcha'] = ! defined('STOP_CAPTCHA');
-#for security
-if (!$username)
+//for security
+if (! $username)
{
is_array($plugin_run_result = Plugins::getInstance()->run('user_not_admin_admin_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- redirect(PATH . 'ucp.php?go=login&return=' . urlencode(ADMIN_PATH . '?cp=' . $go_to));
+ redirect(PATH . 'ucp.php?go=login&return=' . urlencode(ADMIN_PATH . '?cp=' . $go_to));
}
-#get language of admin
+//get language of admin
get_lang('acp');
//
//need to login again
//
-if(
- (empty($_SESSION['ADMINLOGIN']) || $_SESSION['ADMINLOGIN'] != md5(sha1($config['h_key']) . $usrcp->name() . $config['siteurl'])) ||
- (empty($_SESSION['USER_SESS']) || $_SESSION['USER_SESS'] != session_id()) ||
- (empty($_SESSION['ADMINLOGIN_T']) || $_SESSION['ADMINLOGIN_T'] < time())
-)
-{
- if(ig('go') && g('go') == 'login')
- {
- if (ip('submit'))
- {
- //login
- $ERRORS = array();
- $pass_field = 'lpass_' . preg_replace('/[^0-9]/', '', sha1($klj_session . sha1($config['h_key']) . p('kid')));
+if (
+ (empty($_SESSION['ADMINLOGIN']) || $_SESSION['ADMINLOGIN'] != md5(sha1($config['h_key']) . $usrcp->name() . $config['siteurl'])) ||
+ (empty($_SESSION['USER_SESS']) || $_SESSION['USER_SESS'] != session_id()) ||
+ (empty($_SESSION['ADMINLOGIN_T']) || $_SESSION['ADMINLOGIN_T'] < time())
+) {
+ if (ig('go') && g('go') == 'login')
+ {
+ if (ip('submit'))
+ {
+ //login
+ $ERRORS = [];
+ $pass_field = 'lpass_' . preg_replace('/[^0-9]/', '', sha1($klj_session . sha1($config['h_key']) . p('kid')));
- if(!empty($_SESSION['SHOW_CAPTCHA']))
+ if (! empty($_SESSION['SHOW_CAPTCHA']))
{
- if(!kleeja_check_captcha())
+ if (! kleeja_check_captcha())
{
$ERRORS[] = $lang['WRONG_VERTY_CODE'];
}
}
if (empty(p('lname')) || empty(p($pass_field)))
- {
- $ERRORS[] = $lang['EMPTY_FIELDS'];
- }
- elseif(!user_can('enter_acp'))
- {
- $ERRORS[] = $lang['U_NOT_ADMIN'];
- }
- elseif(!kleeja_check_form_key('admin_login'))
- {
- $ERRORS[] = $lang['INVALID_FORM_KEY'];
- }
+ {
+ $ERRORS[] = $lang['EMPTY_FIELDS'];
+ }
+ elseif (! user_can('enter_acp'))
+ {
+ $ERRORS[] = $lang['U_NOT_ADMIN'];
+ }
+ elseif (! kleeja_check_form_key('admin_login'))
+ {
+ $ERRORS[] = $lang['INVALID_FORM_KEY'];
+ }
is_array($plugin_run_result = Plugins::getInstance()->run('admin_login_submit', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- if(empty($ERRORS))
- {
- if($f = $usrcp->data(p('lname'), p($pass_field), false, 3600*6, true))
- {
- $_SESSION['USER_SESS'] = session_id();
- $_SESSION['ADMINLOGIN'] = md5(sha1($config['h_key']) . $usrcp->name() . $config['siteurl']);
- //to make sure, sometime setting time from functions doesn't work
+ if (empty($ERRORS))
+ {
+ if ($f = $usrcp->data(p('lname'), p($pass_field), false, 3600*6, true))
+ {
+ $_SESSION['USER_SESS'] = session_id();
+ $_SESSION['ADMINLOGIN'] = md5(sha1($config['h_key']) . $usrcp->name() . $config['siteurl']);
+ //to make sure, sometime setting time from functions doesn't work
$_SESSION['ADMINLOGIN_T'] = time() + 18000;
unset($_SESSION['SHOW_CAPTCHA']);
- redirect('./' . basename(ADMIN_PATH) . '?cp=' . $go_to);
- $SQL->close();
- exit;
- }
- else
- {
- //Wrong entries
- $ERRORS[] = $lang['LOGIN_ERROR'];
+ redirect('./' . basename(ADMIN_PATH) . '?cp=' . $go_to);
+ $SQL->close();
+
+ exit;
+ }
+ else
+ {
+ //Wrong entries
+ $ERRORS[] = $lang['LOGIN_ERROR'];
$_SESSION['SHOW_CAPTCHA'] = function_exists('gd_info') && ! defined('STOP_CAPTCHA');
- }
- }
+ }
+ }
- //let's see if there is errors
- if(sizeof($ERRORS))
- {
- $errs = '';
- foreach($ERRORS as $r)
- {
- $errs .= '- ' . $r . '.
';
- }
- }
- }
- }
+ //let's see if there is errors
+ if (sizeof($ERRORS))
+ {
+ $errs = '';
- //show template login .
- $action = './' . basename(ADMIN_PATH) . '?go=login&cp=' . $go_to;
- $H_FORM_KEYS = kleeja_add_form_key('admin_login');
- $KEY_FOR_WEE = sha1(microtime() . sha1($config['h_key']));
- $KEY_FOR_PASS = preg_replace('/[^0-9]/', '', sha1($klj_session . sha1($config['h_key']) . $KEY_FOR_WEE));
- $not_you = sprintf($lang['USERNAME_NOT_YOU'], '', '');
+ foreach ($ERRORS as $r)
+ {
+ $errs .= '- ' . $r . '.
';
+ }
+ }
+ }
+ }
- $show_captcha = !empty($_SESSION['SHOW_CAPTCHA']);
+ //show template login .
+ $action = './' . basename(ADMIN_PATH) . '?go=login&cp=' . $go_to;
+ $H_FORM_KEYS = kleeja_add_form_key('admin_login');
+ $KEY_FOR_WEE = sha1(microtime() . sha1($config['h_key']));
+ $KEY_FOR_PASS = preg_replace('/[^0-9]/', '', sha1($klj_session . sha1($config['h_key']) . $KEY_FOR_WEE));
+ $not_you = sprintf($lang['USERNAME_NOT_YOU'], '', '');
+
+ $show_captcha = ! empty($_SESSION['SHOW_CAPTCHA']);
$extra_header_admin_login = '';
- $err = false;
- if(!empty($errs))
- {
- $err = true;
- }
+ $err = false;
+
+ if (! empty($errs))
+ {
+ $err = true;
+ }
is_array($plugin_run_result = Plugins::getInstance()->run('before_display_template_admin_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- header('HTTP/1.0 401 Unauthorized');
- if (ig('_ajax_') || ig('check_msgs'))
- {
- echo_ajax(401, $lang['HV_NOT_PRVLG_ACCESS']);
- }
- else
- {
- echo $tpl->display('admin_login');
- }
+ header('HTTP/1.0 401 Unauthorized');
- $SQL->close();
- exit;
-}#end login
+ if (ig('_ajax_') || ig('check_msgs'))
+ {
+ echo_ajax(401, $lang['HV_NOT_PRVLG_ACCESS']);
+ }
+ else
+ {
+ echo $tpl->display('admin_login');
+ }
+
+ $SQL->close();
+
+ exit;
+}//end login
//ummm let's say it's illegal action
if ($_SERVER['REQUEST_METHOD'] == 'POST' && defined('STOP_CSRF'))
{
- $t_reff = explode('/', $_SERVER['HTTP_REFERER']);
- $t_host = explode('/', $_SERVER['HTTP_HOST']);
- if ($t_reff[2] != $t_host[0])
- {
- $usrcp->logout_cp();
+ $t_reff = explode('/', $_SERVER['HTTP_REFERER']);
+ $t_host = explode('/', $_SERVER['HTTP_HOST']);
- redirect($config['siteurl']);
- $SQL->close();
- exit;
- }
+ if ($t_reff[2] != $t_host[0])
+ {
+ $usrcp->logout_cp();
+
+ redirect($config['siteurl']);
+ $SQL->close();
+
+ exit;
+ }
}
//current admin theme color
-if(ig('change_theme'))
+if (ig('change_theme'))
{
$admin_theme_color = g('change_theme', 'str', 'dark');
- if(in_array($admin_theme_color, array('dark', 'light')))
+ if (in_array($admin_theme_color, ['dark', 'light']))
{
$usrcp->kleeja_set_cookie('klj_adm_theme_color', $admin_theme_color, time() + 31536000);
}
@@ -176,14 +182,14 @@ if(ig('change_theme'))
}
else
{
- if (!($admin_theme_color = $usrcp->kleeja_get_cookie('klj_adm_theme_color')))
+ if (! ($admin_theme_color = $usrcp->kleeja_get_cookie('klj_adm_theme_color')))
{
$admin_theme_color = 'dark';
}
}
-(!defined('LAST_VISIT')) ? define('LAST_VISIT', time() - 3600 * 12) : null;
+(! defined('LAST_VISIT')) ? define('LAST_VISIT', time() - 3600 * 12) : null;
//last visit
$last_visit = defined('LAST_VISIT') && preg_match('/[0-9]{10}/', LAST_VISIT) ? kleeja_date(LAST_VISIT) : false;
@@ -191,39 +197,39 @@ $last_visit = defined('LAST_VISIT') && preg_match('/[0-9]{10}/', LAST_VISIT) ?
//exceptional
//it won't be included in the menu list
//
-$ext_expt = array(
+$ext_expt = [
'start',
'b_lgoutcp',
'i_exts'
- );
+];
//confirm message
-$ext_confirm = array();
+$ext_confirm = [];
//formkey extension, CSRF protection
$GET_FORM_KEY_GLOBAL = kleeja_add_form_key_get('GLOBAL_FORM_KEY');
-$ext_formkey = array();
+$ext_formkey = [];
//default icons
-$ext_icons = array(
- 'configs' => 'sliders',
- 'files' => 'folder-open-o',
- 'img_ctrl' => 'image',
- 'calls' => 'envelope',
- 'reports' => 'bell',
- 'users' => 'user-o',
- 'search' => 'search',
- 'plugins' => 'plug',
- 'ban' => 'minus-circle',
- 'rules' => 'institution',
- 'styles' => 'paint-brush',
- 'extra' => 'window-restore',
+$ext_icons = [
+ 'configs' => 'sliders',
+ 'files' => 'folder-open-o',
+ 'img_ctrl' => 'image',
+ 'calls' => 'envelope',
+ 'reports' => 'bell',
+ 'users' => 'user-o',
+ 'search' => 'search',
+ 'plugins' => 'plug',
+ 'ban' => 'minus-circle',
+ 'rules' => 'institution',
+ 'styles' => 'paint-brush',
+ 'extra' => 'window-restore',
'check_update' => 'download',
- 'repair' => 'wrench',
+ 'repair' => 'wrench',
-);
+];
@@ -233,29 +239,29 @@ $ext_icons = array(
$SHOW_LIST = true;
//get adm extensions
-$adm_extensions = array();
+$adm_extensions = [];
if (($dh = @opendir(ADM_FILES_PATH)) !== false)
{
- while (($file = readdir($dh)) !== false)
- {
- if(strpos($file, '.php') !== false)
- {
- $adm_extensions[] = str_replace('.php', '', $file);
- }
- }
- closedir($dh);
+ while (($file = readdir($dh)) !== false)
+ {
+ if (strpos($file, '.php') !== false)
+ {
+ $adm_extensions[] = str_replace('.php', '', $file);
+ }
+ }
+ closedir($dh);
}
//no extensions ?
-if(!$adm_extensions || !is_array($adm_extensions))
+if (! $adm_extensions || ! is_array($adm_extensions))
{
- if(ig('_ajax_'))
- {
- echo_ajax(888, 'Error while loading admin extensions!.');
- }
+ if (ig('_ajax_'))
+ {
+ echo_ajax(888, 'Error while loading admin extensions!.');
+ }
- big_error('No Extensions', 'Error while loading admin extensions !');
+ big_error('No Extensions', 'Error while loading admin extensions !');
}
@@ -268,54 +274,55 @@ is_array($plugin_run_result = Plugins::getInstance()->run('begin_admin_page', ge
* 'configs' word listed as dangrous requested word
* so we replaced this word with 'options' instead.
*/
-if($go_to == 'options')
+if ($go_to == 'options')
{
- $go_to = 'a_configs';
+ $go_to = 'a_configs';
}
//no request or wrong !
-if(!$go_to || empty($go_to) || !in_array($go_to, $adm_extensions))
+if (! $go_to || empty($go_to) || ! in_array($go_to, $adm_extensions))
{
- $go_to = 'start';
+ $go_to = 'start';
}
//make array for menu
-$adm_extensions_menu = $adm_topmenu = array();
+$adm_extensions_menu = $adm_topmenu = [];
//sort the items as alphabetic !
sort($adm_extensions);
-$i = 0;
+$i = 0;
$cr_time = LAST_VISIT > 0 ? LAST_VISIT : time() - 3600*12;
// check calls and reports numbers
-if(ig('check_msgs') || !ig('_ajax_')):
+if (ig('check_msgs') || ! ig('_ajax_')):
//small bubble system
//any item can show what is inside it as unread messages
-$kbubbles = array();
+$kbubbles = [];
//for calls and reports
-foreach(array('call'=>'calls', 'reports'=>'reports') as $table=>$n)
+foreach (['call'=>'calls', 'reports'=>'reports'] as $table=>$n)
{
- $query = array(
- 'SELECT' => 'COUNT(' . $table[0] . '.id) AS total_rows',
- 'FROM' => "`{$dbprefix}" . $table . "` " . $table[0]
- );
+ $query = [
+ 'SELECT' => 'COUNT(' . $table[0] . '.id) AS total_rows',
+ 'FROM' => "`{$dbprefix}" . $table . '` ' . $table[0]
+ ];
- $fetched = $SQL->fetch_array($SQL->build($query));
+ $fetched = $SQL->fetch_array($SQL->build($query));
- $kbubbles[$n] = $fetched['total_rows'];
+ $kbubbles[$n] = $fetched['total_rows'];
- $SQL->freeresult();
+ $SQL->freeresult();
}
-#if ajax, echo differntly
-if(ig('check_msgs'))
+//if ajax, echo differntly
+if (ig('check_msgs'))
{
- $SQL->close();
- exit($kbubbles['calls'] . '::' . $kbubbles['reports']);
+ $SQL->close();
+
+ exit($kbubbles['calls'] . '::' . $kbubbles['reports']);
}
//add your own bubbles here
@@ -324,48 +331,48 @@ is_array($plugin_run_result = Plugins::getInstance()->run('kbubbles_admin_page',
endif;
-foreach($adm_extensions as $m)
+foreach ($adm_extensions as $m)
{
- //some exceptions
- if(@in_array($m, $ext_expt))
- {
- continue;
- }
+ //some exceptions
+ if (@in_array($m, $ext_expt))
+ {
+ continue;
+ }
is_array($plugin_run_result = Plugins::getInstance()->run('foreach_ext_admin_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- $s = $m;
- $m = isset($m[1]) && $m[1] == '_' ? substr($m , 2) : $m;
+ $s = $m;
+ $m = isset($m[1]) && $m[1] == '_' ? substr($m, 2) : $m;
- ++$i;
- $adm_extensions_menu[$i] = array(
- 'm' => $m,
- 'i' => $i+1,
- 'i2' => $i+2,
- 'icon' => !empty($ext_icons[$m]) ? $ext_icons[$m] : 'puzzle-piece',
+ ++$i;
+ $adm_extensions_menu[$i] = [
+ 'm' => $m,
+ 'i' => $i+1,
+ 'i2' => $i+2,
+ 'icon' => ! empty($ext_icons[$m]) ? $ext_icons[$m] : 'puzzle-piece',
- 'lang' => !empty($lang['R_'. strtoupper($m)]) ? $lang['R_'. strtoupper($m)] : (!empty($olang['R_' . strtoupper($m)]) ? $olang['R_' . strtoupper($m)] : strtoupper($m)),
- 'link' => './' . basename(ADMIN_PATH) . '?cp=' . ($m == 'configs' ? 'options' : $s) . (@in_array($m, $ext_formkey) ? '&' . $GET_FORM_KEY_GLOBAL : ''),
- 'confirm' => (@in_array($m, $ext_confirm)) ? true : false,
- 'current' => ($s == $go_to) ? true : false,
- 'goto' => str_replace('a_configs', 'options', $s),
- 'bubble' => !emptY($kbubbles[$m]) ? '' . $kbubbles[$m] . '' : '',
- 'counter' => !emptY($kbubbles[$m]) ? $kbubbles[$m] : ''
- );
+ 'lang' => ! empty($lang['R_' . strtoupper($m)]) ? $lang['R_' . strtoupper($m)] : (! empty($olang['R_' . strtoupper($m)]) ? $olang['R_' . strtoupper($m)] : strtoupper($m)),
+ 'link' => './' . basename(ADMIN_PATH) . '?cp=' . ($m == 'configs' ? 'options' : $s) . (@in_array($m, $ext_formkey) ? '&' . $GET_FORM_KEY_GLOBAL : ''),
+ 'confirm' => (@in_array($m, $ext_confirm)) ? true : false,
+ 'current' => ($s == $go_to) ? true : false,
+ 'goto' => str_replace('a_configs', 'options', $s),
+ 'bubble' => ! emptY($kbubbles[$m]) ? '' . $kbubbles[$m] . '' : '',
+ 'counter' => ! emptY($kbubbles[$m]) ? $kbubbles[$m] : ''
+ ];
- //add another item to array for title='' in href or other thing
- $adm_extensions_menu[$i]['title'] = $adm_extensions_menu[$i]['lang'];
+ //add another item to array for title='' in href or other thing
+ $adm_extensions_menu[$i]['title'] = $adm_extensions_menu[$i]['lang'];
is_array($plugin_run_result = Plugins::getInstance()->run('endforeach_ext_admin_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
}
-#to attach kleeja version in the menu start item
+//to attach kleeja version in the menu start item
$assigned_klj_ver = preg_replace('!#([a-z0-9]+)!', '', KLEEJA_VERSION);
-#for plugins
+//for plugins
$styleePath = null;
//get it
@@ -375,13 +382,12 @@ if (file_exists(ADM_FILES_PATH . '/' . $go_to . '.php'))
is_array($plugin_run_result = Plugins::getInstance()->run("require_admin_page_begin_{$go_to}", get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- if($include)
- {
- include_once ADM_FILES_PATH . '/' . $go_to . '.php';
- }
+ if ($include)
+ {
+ include_once ADM_FILES_PATH . '/' . $go_to . '.php';
+ }
is_array($plugin_run_result = Plugins::getInstance()->run("require_admin_page_end_{$go_to}", get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
-
}
else
{
@@ -389,7 +395,7 @@ else
is_array($plugin_run_result = Plugins::getInstance()->run("not_exists_{$go_to}", get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- if(!empty($include_alternative) && file_exists($include_alternative))
+ if (! empty($include_alternative) && file_exists($include_alternative))
{
include_once $include_alternative;
}
@@ -407,22 +413,23 @@ else
//no style defined
-if(empty($stylee))
+if (empty($stylee))
{
- $text = $lang['NO_TPL_SHOOSED'];
- $stylee = 'admin_info';
+ $text = $lang['NO_TPL_SHOOSED'];
+ $stylee = 'admin_info';
}
$go_menu_html = '';
-if(isset($go_menu))
+
+if (isset($go_menu))
{
- foreach($go_menu as $m=>$d)
- {
+ foreach ($go_menu as $m=>$d)
+ {
$go_menu_html .= '' .
- '' .
+ '' .
$d['name'] . '';
- }
+ }
}
//add extra html to header or footer
@@ -432,33 +439,34 @@ is_array($plugin_run_result = Plugins::getInstance()->run('end_admin_page', get_
//header
-if(!ig('_ajax_'))
+if (! ig('_ajax_'))
{
- echo $tpl->display("admin_header");
+ echo $tpl->display('admin_header');
}
//body
-if(!ig('_ajax_'))
+if (! ig('_ajax_'))
{
- $is_ajax = 'no';
- echo $tpl->display($stylee, $styleePath);
+ $is_ajax = 'no';
+ echo $tpl->display($stylee, $styleePath);
}
else
{
- $is_ajax = 'yes';
+ $is_ajax = 'yes';
- echo_ajax(1,
- empty($adminAjaxContent) ? $tpl->display($stylee, $styleePath) : $adminAjaxContent,
- $go_menu_html
- );
+ echo_ajax(1,
+ empty($adminAjaxContent) ? $tpl->display($stylee, $styleePath) : $adminAjaxContent,
+ $go_menu_html
+ );
}
//footer
-if(!ig('_ajax_'))
+if (! ig('_ajax_'))
{
- echo $tpl->display("admin_footer");
+ echo $tpl->display('admin_footer');
}
//close db
$SQL->close();
+
exit;
diff --git a/do.php b/do.php
index eeaff3c..02998a3 100755
--- a/do.php
+++ b/do.php
@@ -30,120 +30,121 @@ if (ig('id') || ig('filename'))
{
is_array($plugin_run_result = Plugins::getInstance()->run('begin_download_id_filename', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- $query = array(
- 'SELECT' => 'f.id, f.real_filename, f.name, f.folder, f.size, f.time, f.uploads, f.type',
- 'FROM' => "{$dbprefix}files f",
- 'LIMIT' => "1",
- );
+ $query = [
+ 'SELECT' => 'f.id, f.real_filename, f.name, f.folder, f.size, f.time, f.uploads, f.type',
+ 'FROM' => "{$dbprefix}files f",
+ 'LIMIT' => '1',
+ ];
- #if user system is default, we use users table
- if((int) $config['user_system'] == 1)
- {
- $query['SELECT'] .= ', u.name AS fusername, u.id AS fuserid';
- $query['JOINS'] = array(
- array(
- 'LEFT JOIN' => "{$dbprefix}users u",
- 'ON' => 'u.id=f.user'
- )
- );
- }
+ //if user system is default, we use users table
+ if ((int) $config['user_system'] == 1)
+ {
+ $query['SELECT'] .= ', u.name AS fusername, u.id AS fuserid';
+ $query['JOINS'] = [
+ [
+ 'LEFT JOIN' => "{$dbprefix}users u",
+ 'ON' => 'u.id=f.user'
+ ]
+ ];
+ }
- if (ig('filename'))
- {
- $filename_l = (string) $SQL->escape(g('filename'));
- if(ig('x'))
- {
- $query['WHERE'] = "f.name='" . $filename_l . '.' . $SQL->escape(g('x')) . "'";
- }
- else
- {
- $query['WHERE'] = "f.name='" . $filename_l . "'";
- }
- }
- else
- {
- $id_l = g('id', 'int');
- $query['WHERE'] = "f.id=" . $id_l;
- }
+ if (ig('filename'))
+ {
+ $filename_l = (string) $SQL->escape(g('filename'));
+
+ if (ig('x'))
+ {
+ $query['WHERE'] = "f.name='" . $filename_l . '.' . $SQL->escape(g('x')) . "'";
+ }
+ else
+ {
+ $query['WHERE'] = "f.name='" . $filename_l . "'";
+ }
+ }
+ else
+ {
+ $id_l = g('id', 'int');
+ $query['WHERE'] = 'f.id=' . $id_l;
+ }
is_array($plugin_run_result = Plugins::getInstance()->run('qr_download_id_filename', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- $result = $SQL->build($query);
+ $result = $SQL->build($query);
- if ($SQL->num_rows($result) != 0)
- {
- $file_info = $SQL->fetch_array($result);
+ if ($SQL->num_rows($result) != 0)
+ {
+ $file_info = $SQL->fetch_array($result);
- $SQL->freeresult($result);
+ $SQL->freeresult($result);
- // some vars
- $id = $file_info['id'];
- $name = $fname = $file_info['name'];
+ // some vars
+ $id = $file_info['id'];
+ $name = $fname = $file_info['name'];
$real_filename = $file_info['real_filename'];
- $type = $file_info['type'];
- $size = $file_info['size'];
- $time = $file_info['time'];
- $uploads = $file_info['uploads'];
+ $type = $file_info['type'];
+ $size = $file_info['size'];
+ $time = $file_info['time'];
+ $uploads = $file_info['uploads'];
- $fname2 = str_replace('.', '-', htmlspecialchars($name));
- $name = $real_filename != '' ? str_replace('.' . $type, '', htmlspecialchars($real_filename)) : $name;
- $name = strlen($name) > 70 ? substr($name, 0, 70) . '...' : $name;
- $fusername = $config['user_system'] == 1 && $file_info['fuserid'] > -1 ? $file_info['fusername'] : false;
- $userfolder = $config['siteurl'] . ($config['mod_writer'] ? 'fileuser-' . $file_info['fuserid'] . '.html' : 'ucp.php?go=fileuser&id=' . $file_info['fuserid']);
+ $fname2 = str_replace('.', '-', htmlspecialchars($name));
+ $name = $real_filename != '' ? str_replace('.' . $type, '', htmlspecialchars($real_filename)) : $name;
+ $name = strlen($name) > 70 ? substr($name, 0, 70) . '...' : $name;
+ $fusername = $config['user_system'] == 1 && $file_info['fuserid'] > -1 ? $file_info['fusername'] : false;
+ $userfolder = $config['siteurl'] . ($config['mod_writer'] ? 'fileuser-' . $file_info['fuserid'] . '.html' : 'ucp.php?go=fileuser&id=' . $file_info['fuserid']);
- if (ig('filename'))
- {
- $url_file = $config['mod_writer'] ? $config['siteurl'] . "downf-" . $fname2 . ".html" : $config['siteurl'] . "do.php?downf=" . $fname;
- }
- else
- {
- $url_file = $config['mod_writer'] ? $config['siteurl'] . "down-" . $file_info['id'] . ".html" : $config['siteurl'] . "do.php?down=" . $file_info['id'];
- }
+ if (ig('filename'))
+ {
+ $url_file = $config['mod_writer'] ? $config['siteurl'] . 'downf-' . $fname2 . '.html' : $config['siteurl'] . 'do.php?downf=' . $fname;
+ }
+ else
+ {
+ $url_file = $config['mod_writer'] ? $config['siteurl'] . 'down-' . $file_info['id'] . '.html' : $config['siteurl'] . 'do.php?down=' . $file_info['id'];
+ }
- if(!empty($config['livexts']))
- {
- $livexts = explode(',', $config['livexts']);
+ if (! empty($config['livexts']))
+ {
+ $livexts = explode(',', $config['livexts']);
if (in_array($type, $livexts))
- {
- if (ig('filename'))
- {
- $url_filex = $config['mod_writer'] ? $config['siteurl'] . "downexf-" . $fname2 . ".html" : $config['siteurl'] . "do.php?downexf=" . $fname;
- }
- else
- {
- $url_filex = $config['mod_writer'] ? $config['siteurl'] . "downex-" . $file_info['id'] . ".html" : $config['siteurl'] . "do.php?downex=" . $file_info['id'];
- }
-
- redirect($url_filex, false);
- }
- }
+ {
+ if (ig('filename'))
+ {
+ $url_filex = $config['mod_writer'] ? $config['siteurl'] . 'downexf-' . $fname2 . '.html' : $config['siteurl'] . 'do.php?downexf=' . $fname;
+ }
+ else
+ {
+ $url_filex = $config['mod_writer'] ? $config['siteurl'] . 'downex-' . $file_info['id'] . '.html' : $config['siteurl'] . 'do.php?downex=' . $file_info['id'];
+ }
- $REPORT = ($config['mod_writer']) ? $config['siteurl'] . "report-" . $file_info['id'] . ".html" : $config['siteurl'] . "go.php?go=report&id=" . $file_info['id'];
- $seconds_w = user_can('enter_acp') ? 0 : $config['sec_down'];
- $time = kleeja_date($time);
- $size = readable_size($size);
+ redirect($url_filex, false);
+ }
+ }
- $file_ext_icon = file_exists('images/filetypes/' . $type . '.png') ? 'images/filetypes/' . $type . '.png' : 'images/filetypes/file.png';
- $sty = 'download';
- $title = $name . ' - ' . $lang['DOWNLAOD'];
- }
- else
- {
- //file not exists
+ $REPORT = ($config['mod_writer']) ? $config['siteurl'] . 'report-' . $file_info['id'] . '.html' : $config['siteurl'] . 'go.php?go=report&id=' . $file_info['id'];
+ $seconds_w = user_can('enter_acp') ? 0 : $config['sec_down'];
+ $time = kleeja_date($time);
+ $size = readable_size($size);
+
+ $file_ext_icon = file_exists('images/filetypes/' . $type . '.png') ? 'images/filetypes/' . $type . '.png' : 'images/filetypes/file.png';
+ $sty = 'download';
+ $title = $name . ' - ' . $lang['DOWNLAOD'];
+ }
+ else
+ {
+ //file not exists
is_array($plugin_run_result = Plugins::getInstance()->run('not_exists_qr_downlaod_file', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- kleeja_err($lang['FILE_NO_FOUNDED']);
- }
+ kleeja_err($lang['FILE_NO_FOUNDED']);
+ }
$show_style = true;
is_array($plugin_run_result = Plugins::getInstance()->run('b4_showsty_downlaod_id_filename', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- //add http reffer to session to prevent errors with some browsers !
+ //add http reffer to session to prevent errors with some browsers !
$_SESSION['HTTP_REFERER'] = $file_info['id'];
// show style
- if($show_style)
+ if ($show_style)
{
Saaheader($title);
echo $tpl->display($sty);
@@ -157,24 +158,24 @@ if (ig('id') || ig('filename'))
//
//download file
//
-# guidelines for _get variable names
-#
-# down: [0-9], default, came from do.php?id=[0-9]
-# downf: [a-z0-9].[ext], came from do.php?filename=[a-z0-9].[ext]
-#
-# img: [0-9], default, direct from do.php?img=[0-9]
-# imgf: [a-z0-9].[ext], direct from do.php?imgf=[a-z0-9].[ext]
-#
-# thmb: [0-9], default, direct from do.php?thmb=[0-9]
-# thmbf: [a-z0-9].[ext], direct from do.php?thmbf=[a-z0-9].[ext]
-#
-# live extensions feature uses downex, downexf as in down & downf
-#
-# x : used only for html links, where x = extension, downf is filename without extension
+// guidelines for _get variable names
+//
+// down: [0-9], default, came from do.php?id=[0-9]
+// downf: [a-z0-9].[ext], came from do.php?filename=[a-z0-9].[ext]
+//
+// img: [0-9], default, direct from do.php?img=[0-9]
+// imgf: [a-z0-9].[ext], direct from do.php?imgf=[a-z0-9].[ext]
+//
+// thmb: [0-9], default, direct from do.php?thmb=[0-9]
+// thmbf: [a-z0-9].[ext], direct from do.php?thmbf=[a-z0-9].[ext]
+//
+// live extensions feature uses downex, downexf as in down & downf
+//
+// x : used only for html links, where x = extension, downf is filename without extension
-else if (ig('down') || ig('downf') ||
- ig('img') || ig('imgf') ||
- ig('thmb') || ig('thmbf') ||
+elseif (ig('down') || ig('downf') ||
+ ig('img') || ig('imgf') ||
+ ig('thmb') || ig('thmbf') ||
ig('downex') || ig('downexf'))
{
is_array($plugin_run_result = Plugins::getInstance()->run('begin_down_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -192,7 +193,7 @@ else if (ig('down') || ig('downf') ||
$isset_down_h = ig('downf') && ig('x') ? 'downloadf-' . g('downf') . '-' . g('x') . '.html' : (ig('down') ? 'download' . g('down') . '.html' : '');
- if (!empty($_SERVER['HTTP_REFERER'])
+ if (! empty($_SERVER['HTTP_REFERER'])
&& strpos($_SERVER['HTTP_REFERER'], $isset_down_h) !== false)
{
$not_reffer = false;
@@ -200,24 +201,24 @@ else if (ig('down') || ig('downf') ||
$isset_down = ig('downf') ? 'do.php?filename=' . g('downf') : (ig('down') ? 'do.php?id=' . g('down') : '');
- if (!empty($_SERVER['HTTP_REFERER'])
+ if (! empty($_SERVER['HTTP_REFERER'])
&& strpos($_SERVER['HTTP_REFERER'], $isset_down) !== false)
{
$not_reffer = false;
}
- if (!empty($_SERVER['HTTP_REFERER'])
- && strpos($config['siteurl'], str_replace(array('http://', 'www.', 'https://'), '', htmlspecialchars($_SERVER['HTTP_REFERER']))))
+ if (! empty($_SERVER['HTTP_REFERER'])
+ && strpos($config['siteurl'], str_replace(['http://', 'www.', 'https://'], '', htmlspecialchars($_SERVER['HTTP_REFERER']))))
{
$not_reffer = false;
}
- if (isset($_SERVER["HTTP_RANGE"]))
+ if (isset($_SERVER['HTTP_RANGE']))
{
$not_reffer = false;
}
- if(isset($_SESSION['HTTP_REFERER']))
+ if (isset($_SESSION['HTTP_REFERER']))
{
$not_reffer = false;
@@ -230,7 +231,7 @@ else if (ig('down') || ig('downf') ||
{
if (ig('downf'))
{
- $go_to = $config['siteurl'] . ($config['mod_writer'] && ig('x') ? "downloadf-" . g('downf') . '-' . g('x') . ".html" : "do.php?filename=" . g('downf'));
+ $go_to = $config['siteurl'] . ($config['mod_writer'] && ig('x') ? 'downloadf-' . g('downf') . '-' . g('x') . '.html' : 'do.php?filename=' . g('downf'));
}
else
{
@@ -239,6 +240,7 @@ else if (ig('down') || ig('downf') ||
redirect($go_to);
$SQL->close();
+
exit;
}
}
@@ -255,7 +257,7 @@ else if (ig('down') || ig('downf') ||
{
$var = ig('downf') ? 'downf' : (ig('imgf') ? 'imgf' : (ig('thmbf') ? 'thmbf' : (ig('downexf') ? 'downexf' : false)));
- #x, represent the extension, came from html links
+ //x, represent the extension, came from html links
if (ig('x') && $var)
{
$filename = $SQL->escape(g($var)) . '.' . $SQL->escape(g('x'));
@@ -275,54 +277,53 @@ else if (ig('down') || ig('downf') ||
//is internet explore 6 ?
$is_ie6 = is_browser('ie6');
- $livexts = explode(",", $config['livexts']);
+ $livexts = explode(',', $config['livexts']);
//get info file
- $query = array('SELECT' => 'f.id, f.name, f.real_filename, f.folder, f.type, f.size, f.time',
- 'FROM' => "{$dbprefix}files f",
- 'WHERE' => $is_id_filename ? "f.name='" . $filename . "'" . (ig('downexf') ? " AND f.type IN ('" . implode("', '", $livexts) . "')" : '') :
+ $query = ['SELECT' => 'f.id, f.name, f.real_filename, f.folder, f.type, f.size, f.time',
+ 'FROM' => "{$dbprefix}files f",
+ 'WHERE' => $is_id_filename ? "f.name='" . $filename . "'" . (ig('downexf') ? " AND f.type IN ('" . implode("', '", $livexts) . "')" : '') :
'f.id=' . $id . (ig('downex') ? " AND f.type IN ('" . implode("', '", $livexts) . "')" : ''),
'LIMIT' => '1'
- );
+ ];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_down_go_page_filename', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$result = $SQL->build($query);
$is_live = false;
- $pre_ext = !empty($filename) && strpos($filename, '.') !== false ? explode('.', $filename) : array();
+ $pre_ext = ! empty($filename) && strpos($filename, '.') !== false ? explode('.', $filename) : [];
$pre_ext = array_pop($pre_ext);
- $is_image = in_array(strtolower(trim($pre_ext)), array('gif', 'jpg', 'jpeg', 'bmp', 'png')) ? true : false;
+ $is_image = in_array(strtolower(trim($pre_ext)), ['gif', 'jpg', 'jpeg', 'bmp', 'png']) ? true : false;
- #initiate variables
+ //initiate variables
$ii = $n = $rn = $t = $f = $ftime = $d_size = null;
if ($SQL->num_rows($result))
{
-
$row = $SQL->fetch($result);
- $ii = $row['id'];
- $n = $row['name'];
- $rn = $row['real_filename'];
- $t = strtolower(trim($row['type']));
- $f = $row['folder'];
- $ftime = $row['time'];
+ $ii = $row['id'];
+ $n = $row['name'];
+ $rn = $row['real_filename'];
+ $t = strtolower(trim($row['type']));
+ $f = $row['folder'];
+ $ftime = $row['time'];
$d_size = $row['size'];
- #img or not
- $is_image = in_array($t, array('gif', 'jpg', 'jpeg', 'bmp', 'png')) ? true : false;
- #live url
+ //img or not
+ $is_image = in_array($t, ['gif', 'jpg', 'jpeg', 'bmp', 'png']) ? true : false;
+ //live url
$is_live = in_array($t, $livexts) ? true : false;
$SQL->free($result);
//fix bug where a user can override files wait counter
- if (!$is_image && (ig('img') || ig('thmb')))
+ if (! $is_image && (ig('img') || ig('thmb')))
{
$go_to = $config['siteurl'] . ($config['mod_writer'] ? 'download' . $ii . '.html' : 'do.php?id=' . $ii);
redirect($go_to);
@@ -330,14 +331,14 @@ else if (ig('down') || ig('downf') ||
//check if the vistor is new in this page before updating kleeja counter
- if (!preg_match('/,' . $ii . ',/i', $usrcp->kleeja_get_cookie('oldvistor')) && !isset($_SERVER['HTTP_RANGE']))
+ if (! preg_match('/,' . $ii . ',/i', $usrcp->kleeja_get_cookie('oldvistor')) && ! isset($_SERVER['HTTP_RANGE']))
{
//updates number of uploads ..
- $update_query = array(
+ $update_query = [
'UPDATE' => "{$dbprefix}files",
- 'SET' => 'uploads=uploads+1, last_down=' . time(),
- 'WHERE' => $is_id_filename ? "name='" . $filename . "'" : 'id=' . $id,
- );
+ 'SET' => 'uploads=uploads+1, last_down=' . time(),
+ 'WHERE' => $is_id_filename ? "name='" . $filename . "'" : 'id=' . $id,
+ ];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_update_no_uploads_down', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$SQL->build($update_query);
@@ -380,25 +381,26 @@ else if (ig('down') || ig('downf') ||
}
//download process
- $path_file = ig('thmb') || ig('thmbf') ? "./{$f}/thumbs/{$n}" : "./{$f}/{$n}";
- $chunksize = 8192;
+ $path_file = ig('thmb') || ig('thmbf') ? "./{$f}/thumbs/{$n}" : "./{$f}/{$n}";
+ $chunksize = 8192;
$resuming_on = true;
is_array($plugin_run_result = Plugins::getInstance()->run('down_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- # this is a solution to ignore downloading through the file, redirect to the actual file
- # where you can add 'define("MAKE_DOPHP_301_HEADER", true);' in config.php to stop the load
- # if there is any.ead
+ // this is a solution to ignore downloading through the file, redirect to the actual file
+ // where you can add 'define("MAKE_DOPHP_301_HEADER", true);' in config.php to stop the load
+ // if there is any.ead
if (defined('MAKE_DOPHP_301_HEADER'))
{
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $path_file);
$SQL->close();
+
exit;
}
//start download ,,
- if (!is_readable($path_file))
+ if (! is_readable($path_file))
{
is_array($plugin_run_result = Plugins::getInstance()->run('down_file_not_exists', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -412,7 +414,7 @@ else if (ig('down') || ig('downf') ||
}
}
- if (!($size = @kleeja_filesize($path_file)))
+ if (! ($size = @kleeja_filesize($path_file)))
{
$size = $d_size;
}
@@ -423,7 +425,7 @@ else if (ig('down') || ig('downf') ||
{
$h_name = "filename*=UTF-8''" . rawurlencode(htmlspecialchars_decode($name));
}
- else if (is_browser('opera, safari, konqueror'))
+ elseif (is_browser('opera, safari, konqueror'))
{
$h_name = 'filename="' . str_replace('"', '', htmlspecialchars_decode($name)) . '"';
}
@@ -439,11 +441,11 @@ else if (ig('down') || ig('downf') ||
$mime_type = get_mime_for_header($ext);
- #disable execution time limit
+ //disable execution time limit
@set_time_limit(0);
- #disable output buffering
- #TODO check effectiveness
+ //disable output buffering
+ //TODO check effectiveness
$level = ob_get_level();
while ($level > 0)
{
@@ -451,7 +453,7 @@ else if (ig('down') || ig('downf') ||
$level--;
}
- if (!is_null($SQL))
+ if (! is_null($SQL))
{
$SQL->close();
}
@@ -459,64 +461,64 @@ else if (ig('down') || ig('downf') ||
session_write_close();
- // required for IE, otherwise Content-Disposition may be ignored
- if(@ini_get('zlib.output_compression'))
- {
- @ini_set('zlib.output_compression', 'Off');
- }
+ // required for IE, otherwise Content-Disposition may be ignored
+ if (@ini_get('zlib.output_compression'))
+ {
+ @ini_set('zlib.output_compression', 'Off');
+ }
- #open the file
+ //open the file
if (($fp = @fopen($path_file, 'rb')) === false)
{
- #so ... it's failed to open !
- header("HTTP/1.0 404 Not Found");
+ //so ... it's failed to open !
+ header('HTTP/1.0 404 Not Found');
@fclose($fp);
big_error($lang['FILE_NO_FOUNDED'], $lang['NOT_FOUND']);
}
- #Unsetting all previously set headers.
+ //Unsetting all previously set headers.
header_remove();
is_array($plugin_run_result = Plugins::getInstance()->run('do_page_before_headers_set', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- #send file headers
+ //send file headers
header('Pragma: public');
header('Accept-Ranges: bytes');
- header("Content-Description: File Transfer");
+ header('Content-Description: File Transfer');
header("Content-Type: $mime_type");
header('Date: ' . gmdate('D, d M Y H:i:s', empty($ftime) ? time() : $ftime) . ' GMT');
- #header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $ftime) . ' GMT');
- #header('Content-Encoding: none');
+ //header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $ftime) . ' GMT');
+ //header('Content-Encoding: none');
header('Content-Disposition: ' . ($is_image || $is_live ? 'inline' : 'attachment') . '; ' . $h_name);
is_array($plugin_run_result = Plugins::getInstance()->run('do_page_headers_set', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- #if(!$is_image && !$is_live && $is_ie8)
- #{
- # header('X-Download-Options: noopen');
- #}
+ //if(!$is_image && !$is_live && $is_ie8)
+ //{
+ // header('X-Download-Options: noopen');
+ //}
- #header(($is_ie6 ? 'Expires: -1' : 'Expires: Mon, 26 Jul 1997 05:00:00 GMT'));
- #(($is_ie8) ? '; authoritative=true; X-Content-Type-Options: nosniff;' : '')
+ //header(($is_ie6 ? 'Expires: -1' : 'Expires: Mon, 26 Jul 1997 05:00:00 GMT'));
+ //(($is_ie8) ? '; authoritative=true; X-Content-Type-Options: nosniff;' : '')
- #add multipart download and resume support
- if (isset($_SERVER["HTTP_RANGE"]) && $resuming_on)
+ //add multipart download and resume support
+ if (isset($_SERVER['HTTP_RANGE']) && $resuming_on)
{
- list($a, $range) = explode("=", $_SERVER["HTTP_RANGE"], 2);
- list($range) = explode(",", $range, 2);
- list($range, $range_end) = explode("=", $range);
- $range = round(floatval($range), 0);
- $range_end = !$range_end ? $size - 1 : round(floatval($range_end), 0);
+ list($a, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
+ list($range) = explode(',', $range, 2);
+ list($range, $range_end) = explode('=', $range);
+ $range = round(floatval($range), 0);
+ $range_end = ! $range_end ? $size - 1 : round(floatval($range_end), 0);
$partial_length = $range_end - $range + 1;
- header("HTTP/1.1 206 Partial Content");
+ header('HTTP/1.1 206 Partial Content');
header("Content-Length: $partial_length");
- header("Content-Range: bytes " . ($range - $range_end / $size));
+ header('Content-Range: bytes ' . ($range - $range_end / $size));
fseek($fp, $range);
}
@@ -526,27 +528,27 @@ else if (ig('down') || ig('downf') ||
header("Content-Length: $partial_length");
}
- #output file
+ //output file
$bytes_sent = 0;
- #read and output the file in chunks
- while (!feof($fp) && (!connection_aborted()) && ($bytes_sent < $partial_length))
+ //read and output the file in chunks
+ while (! feof($fp) && (! connection_aborted()) && ($bytes_sent < $partial_length))
{
$buffer = fread($fp, $chunksize);
print($buffer);
flush();
$bytes_sent += strlen($buffer);
- if(defined('TrottleLimit'))
+ if (defined('TrottleLimit'))
{
- usleep(1000000 * 0.3);
+ usleep(1000000 * 0.3);
}
}
fclose($fp);
- if(function_exists('fastcgi_finish_request'))
+ if (function_exists('fastcgi_finish_request'))
{
fastcgi_finish_request();
}
@@ -563,7 +565,7 @@ else
is_array($plugin_run_result = Plugins::getInstance()->run('err_navig_download_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- if($error)
+ if ($error)
{
kleeja_err($lang['ERROR_NAVIGATATION']);
}
@@ -572,4 +574,4 @@ else
is_array($plugin_run_result = Plugins::getInstance()->run('end_download_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
-#<-- EOF
+//<-- EOF
diff --git a/download.php b/download.php
index 7e124d6..eb75d82 100755
--- a/download.php
+++ b/download.php
@@ -11,4 +11,4 @@
// we deprecated download.php , so we have to put it for those who upgraded
// to this version
//
-require 'do.php';
\ No newline at end of file
+require 'do.php';
diff --git a/go.php b/go.php
index b5059bc..b1cb390 100755
--- a/go.php
+++ b/go.php
@@ -13,401 +13,412 @@
* @ignore
*/
define('IN_KLEEJA', true);
-define('IN_GO' , true);
+define('IN_GO', true);
require_once 'includes/common.php';
$current_go_case = g('go');
-$show_style = true;
-$styleePath = null;
+$show_style = true;
+$styleePath = null;
is_array($plugin_run_result = Plugins::getInstance()->run('begin_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
-switch($current_go_case)
+switch ($current_go_case)
{
- //
- //Page of allowed extensions for all groups
- //
- case 'exts' :
- case 'guide' :
+ //
+ //Page of allowed extensions for all groups
+ //
+ case 'exts' :
+ case 'guide' :
- $stylee = 'guide';
- $titlee = $lang['GUIDE'];
+ $stylee = 'guide';
+ $titlee = $lang['GUIDE'];
- $tgroups = $ttgroups = array();
- $tgroups = array_keys($d_groups);
- $same_group= $rando = 0;
- foreach($tgroups as $gid)
- {
- #if this is admin group, dont show it public
- if($gid == 1 && (int) $userinfo['group_id'] != 1)
- {
- continue;
- }
+ $tgroups = $ttgroups = [];
+ $tgroups = array_keys($d_groups);
+ $same_group= $rando = 0;
- #TODO: if no exts, show that
- foreach($d_groups[$gid]['exts'] as $ext=>$size)
- {
- $ttgroups[] = array(
- 'ext' => $ext,
- 'size' => readable_size($size),
- 'group' => $gid,
- 'group_name'=> str_replace(array('{lang.ADMINS}', '{lang.USERS}', '{lang.GUESTS}'),
- array($lang['ADMINS'], $lang['USERS'], $lang['GUESTS']),
- $d_groups[$gid]['data']['group_name']),
- 'most_firstrow'=> $same_group == 0 ? true : false,
- 'firstrow'=> $same_group ==0 or $same_group != $gid ? true : false,
- 'rando' => $rando,
- );
- $same_group = $gid;
- }
- $rando = $rando ? 0 : 1;
- }
+ foreach ($tgroups as $gid)
+ {
+ //if this is admin group, dont show it public
+ if ($gid == 1 && (int) $userinfo['group_id'] != 1)
+ {
+ continue;
+ }
+
+ //TODO: if no exts, show that
+ foreach ($d_groups[$gid]['exts'] as $ext=>$size)
+ {
+ $ttgroups[] = [
+ 'ext' => $ext,
+ 'size' => readable_size($size),
+ 'group' => $gid,
+ 'group_name'=> str_replace(['{lang.ADMINS}', '{lang.USERS}', '{lang.GUESTS}'],
+ [$lang['ADMINS'], $lang['USERS'], $lang['GUESTS']],
+ $d_groups[$gid]['data']['group_name']),
+ 'most_firstrow'=> $same_group == 0 ? true : false,
+ 'firstrow' => $same_group ==0 or $same_group != $gid ? true : false,
+ 'rando' => $rando,
+ ];
+ $same_group = $gid;
+ }
+ $rando = $rando ? 0 : 1;
+ }
is_array($plugin_run_result = Plugins::getInstance()->run('guide_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- break;
+ break;
- //
- //Page of reporting
- //
- case 'report' :
+ //
+ //Page of reporting
+ //
+ case 'report' :
- if(!user_can('access_report'))
+ if (! user_can('access_report'))
{
is_array($plugin_run_result = Plugins::getInstance()->run('user_cannot_access_report', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
kleeja_info($lang['HV_NOT_PRVLG_ACCESS']);
}
- //page info
- $stylee = 'report';
- $titlee = $lang['REPORT'];
- $id_d = ig('id') ? g('id', 'int') : (ip('rid') ? p('rid', 'int') : 0);
- $url_id = (int) $config['mod_writer'] == 1 ? $config['siteurl'] . 'download' . $id_d . '.html' : $config['siteurl'] . 'do.php?id=' . $id_d;
- $action = $config['siteurl'] . 'go.php?go=report';
- $H_FORM_KEYS = kleeja_add_form_key('report');
- $NOT_USER = !$usrcp->name() ? true : false;
- $s_url = p('surl');
+ //page info
+ $stylee = 'report';
+ $titlee = $lang['REPORT'];
+ $id_d = ig('id') ? g('id', 'int') : (ip('rid') ? p('rid', 'int') : 0);
+ $url_id = (int) $config['mod_writer'] == 1 ? $config['siteurl'] . 'download' . $id_d . '.html' : $config['siteurl'] . 'do.php?id=' . $id_d;
+ $action = $config['siteurl'] . 'go.php?go=report';
+ $H_FORM_KEYS = kleeja_add_form_key('report');
+ $NOT_USER = ! $usrcp->name() ? true : false;
+ $s_url = p('surl');
- #Does this file exists ?
- if(ig('id') || ip('rid'))
- {
- $query = array(
- 'SELECT' => 'f.real_filename, f.name',
- 'FROM' => "{$dbprefix}files f",
- 'WHERE' => 'id=' . $id_d
- );
+ //Does this file exists ?
+ if (ig('id') || ip('rid'))
+ {
+ $query = [
+ 'SELECT' => 'f.real_filename, f.name',
+ 'FROM' => "{$dbprefix}files f",
+ 'WHERE' => 'id=' . $id_d
+ ];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_report_go_id', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- $result = $SQL->build($query);
+ $result = $SQL->build($query);
- if ($SQL->num_rows($result))
- {
- $row = $SQL->fetch_array($result);
- $filename_for_show = $row['real_filename'] == '' ? $row['name'] : $row['real_filename'];
- }
- else
- {
+ if ($SQL->num_rows($result))
+ {
+ $row = $SQL->fetch_array($result);
+ $filename_for_show = $row['real_filename'] == '' ? $row['name'] : $row['real_filename'];
+ }
+ else
+ {
is_array($plugin_run_result = Plugins::getInstance()->run('not_exists_qr_report_go_id', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- kleeja_err($lang['FILE_NO_FOUNDED']);
- }
- $SQL->freeresult($result);
- }
+ kleeja_err($lang['FILE_NO_FOUNDED']);
+ }
+ $SQL->freeresult($result);
+ }
- //no error yet
- $ERRORS = false;
+ //no error yet
+ $ERRORS = false;
- //_post
- $t_rname = p('rname');
- $t_rmail = p('rmail');
- $t_rtext = p('rtext');
+ //_post
+ $t_rname = p('rname');
+ $t_rmail = p('rmail');
+ $t_rtext = p('rtext');
- if (!ip('submit'))
- {
- // first
+ if (! ip('submit'))
+ {
+ // first
is_array($plugin_run_result = Plugins::getInstance()->run('no_submit_report_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- }
- else
- {
- $ERRORS = array();
+ }
+ else
+ {
+ $ERRORS = [];
is_array($plugin_run_result = Plugins::getInstance()->run('submit_report_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- //check for form key
- if(!kleeja_check_form_key('report'))
- {
- $ERRORS['form_key'] = $lang['INVALID_FORM_KEY'];
- }
- if(!kleeja_check_captcha())
- {
- $ERRORS['captcha'] = $lang['WRONG_VERTY_CODE'];
- }
- if ((empty(p('rname')) && $NOT_USER))
- {
- $ERRORS['rname'] = $lang['EMPTY_FIELDS'] . ' : ' . (empty(p('rname')) && $NOT_USER ? ' [ ' . $lang['YOURNAME'] . ' ] ' : '')
- . (empty(p('rurl')) ? ' [ ' . $lang['URL'] . ' ] ': '');
- }
- if(ip('surl') && trim(p('surl')) == '')
- {
- $ERRORS['surl'] = $lang['EMPTY_FIELDS'] . ' : [ ' . $lang['URL_F_FILE'] . ' ]';
- }
- if (ip('rmail') && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i", trim(strtolower(p('rmail')))) && $NOT_USER)
- {
- $ERRORS['rmail'] = $lang['WRONG_EMAIL'];
- }
- if (strlen(p('rtext')) > 300)
- {
- $ERRORS['rtext'] = $lang['NO_ME300RES'];
- }
- if (!ip('surl') && !ip('rid'))
- {
- $ERRORS['rid'] = $lang['NO_ID'];
- }
+ //check for form key
+ if (! kleeja_check_form_key('report'))
+ {
+ $ERRORS['form_key'] = $lang['INVALID_FORM_KEY'];
+ }
+
+ if (! kleeja_check_captcha())
+ {
+ $ERRORS['captcha'] = $lang['WRONG_VERTY_CODE'];
+ }
+
+ if ((empty(p('rname')) && $NOT_USER))
+ {
+ $ERRORS['rname'] = $lang['EMPTY_FIELDS'] . ' : ' . (empty(p('rname')) && $NOT_USER ? ' [ ' . $lang['YOURNAME'] . ' ] ' : '')
+ . (empty(p('rurl')) ? ' [ ' . $lang['URL'] . ' ] ': '');
+ }
+
+ if (ip('surl') && trim(p('surl')) == '')
+ {
+ $ERRORS['surl'] = $lang['EMPTY_FIELDS'] . ' : [ ' . $lang['URL_F_FILE'] . ' ]';
+ }
+
+ if (ip('rmail') && ! preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i", trim(strtolower(p('rmail')))) && $NOT_USER)
+ {
+ $ERRORS['rmail'] = $lang['WRONG_EMAIL'];
+ }
+
+ if (strlen(p('rtext')) > 300)
+ {
+ $ERRORS['rtext'] = $lang['NO_ME300RES'];
+ }
+
+ if (! ip('surl') && ! ip('rid'))
+ {
+ $ERRORS['rid'] = $lang['NO_ID'];
+ }
is_array($plugin_run_result = Plugins::getInstance()->run('submit_report_go_page2', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- //no error , lets do process
- if(empty($ERRORS))
- {
- $name = $NOT_USER ? (string) $SQL->escape(p('rname')) : $usrcp->name();
- $text = (string) $SQL->escape(p('rtext'));
- $mail = $NOT_USER ? (string) strtolower(trim($SQL->escape(p('rmail')))) : $usrcp->mail();
- $url = (string) ip('rid') ? $SQL->escape($url_id) : $SQL->real_escape(p('surl'));
- $time = (int) time();
- $rid = ip('rid') ? 0 : p('rid', 'int');
- $ip = get_ip();
-
+ //no error , lets do process
+ if (empty($ERRORS))
+ {
+ $name = $NOT_USER ? (string) $SQL->escape(p('rname')) : $usrcp->name();
+ $text = (string) $SQL->escape(p('rtext'));
+ $mail = $NOT_USER ? (string) strtolower(trim($SQL->escape(p('rmail')))) : $usrcp->mail();
+ $url = (string) ip('rid') ? $SQL->escape($url_id) : $SQL->real_escape(p('surl'));
+ $time = (int) time();
+ $rid = ip('rid') ? 0 : p('rid', 'int');
+ $ip = get_ip();
- $insert_query = array(
- 'INSERT' => 'name ,mail ,url ,text ,time ,ip',
- 'INTO' => "{$dbprefix}reports",
- 'VALUES' => "'$name', '$mail', '$url', '$text', $time, '$ip'"
- );
+
+ $insert_query = [
+ 'INSERT' => 'name ,mail ,url ,text ,time ,ip',
+ 'INTO' => "{$dbprefix}reports",
+ 'VALUES' => "'$name', '$mail', '$url', '$text', $time, '$ip'"
+ ];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_insert_new_report', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- $SQL->build($insert_query);
+ $SQL->build($insert_query);
- //update number of reports
- $update_query = array(
- 'UPDATE' => "{$dbprefix}files",
- 'SET' => 'report=report+1',
- 'WHERE' => 'id=' . $rid,
- );
+ //update number of reports
+ $update_query = [
+ 'UPDATE' => "{$dbprefix}files",
+ 'SET' => 'report=report+1',
+ 'WHERE' => 'id=' . $rid,
+ ];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_update_no_file_report', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- $SQL->build($update_query);
+ $SQL->build($update_query);
- $to = $config['sitemail2']; //administrator e-mail
- $message = $text . "\n\n\n\n" . 'URL :' . $url . ' - TIME : ' . date('d-m-Y h:i a', $time) . ' - IP:' . $ip;
- $subject = $lang['REPORT'];
- send_mail($to, $message, $subject, $mail, $name);
+ $to = $config['sitemail2']; //administrator e-mail
+ $message = $text . "\n\n\n\n" . 'URL :' . $url . ' - TIME : ' . date('d-m-Y h:i a', $time) . ' - IP:' . $ip;
+ $subject = $lang['REPORT'];
+ send_mail($to, $message, $subject, $mail, $name);
- kleeja_info($lang['THNX_REPORTED']);
- }
- }
+ kleeja_info($lang['THNX_REPORTED']);
+ }
+ }
is_array($plugin_run_result = Plugins::getInstance()->run('report_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- break;
-
- //
- //Pages of rules
- //
- case 'rules' :
+ break;
- $stylee = 'rules';
- $titlee = $lang['RULES'];
- $contents = strlen($ruless) > 3 ? stripslashes($ruless) : $lang['NO_RULES_NOW'];
+ //
+ //Pages of rules
+ //
+ case 'rules' :
+
+ $stylee = 'rules';
+ $titlee = $lang['RULES'];
+ $contents = strlen($ruless) > 3 ? stripslashes($ruless) : $lang['NO_RULES_NOW'];
is_array($plugin_run_result = Plugins::getInstance()->run('rules_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- break;
+ break;
- //
- //Page of call-us
- //
- case 'call' :
+ //
+ //Page of call-us
+ //
+ case 'call' :
- //Not allowed to access this page ?
- if (!user_can('access_call'))
- {
+ //Not allowed to access this page ?
+ if (! user_can('access_call'))
+ {
is_array($plugin_run_result = Plugins::getInstance()->run('user_cannot_access_call', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- kleeja_info($lang['HV_NOT_PRVLG_ACCESS']);
- }
+ kleeja_info($lang['HV_NOT_PRVLG_ACCESS']);
+ }
- //page info
- $stylee = 'call';
- $titlee = $lang['CALL'];
- $action = './go.php?go=call';
- $H_FORM_KEYS = kleeja_add_form_key('call');
- $NOT_USER = !$usrcp->name() ? true : false;
- //no error yet
- $ERRORS = false;
+ //page info
+ $stylee = 'call';
+ $titlee = $lang['CALL'];
+ $action = './go.php?go=call';
+ $H_FORM_KEYS = kleeja_add_form_key('call');
+ $NOT_USER = ! $usrcp->name() ? true : false;
+ //no error yet
+ $ERRORS = false;
- //_post
- $t_cname = p('cname');
- $t_cmail = p('cmail');
+ //_post
+ $t_cname = p('cname');
+ $t_cmail = p('cmail');
$t_ctext = p('ctext');
is_array($plugin_run_result = Plugins::getInstance()->run('no_submit_call_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- if (ip('submit'))
- {
- //after sumit
- $ERRORS = array();
+ if (ip('submit'))
+ {
+ //after sumit
+ $ERRORS = [];
is_array($plugin_run_result = Plugins::getInstance()->run('submit_call_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- //check for form key
- if(!kleeja_check_form_key('call'))
- {
- $ERRORS['form_key'] = $lang['INVALID_FORM_KEY'];
- }
- if(!kleeja_check_captcha())
- {
- $ERRORS['captcha'] = $lang['WRONG_VERTY_CODE'];
- }
- if ((empty(p('cname')) && $NOT_USER) || empty(p('ctext')) )
- {
- $ERRORS['cname'] = $lang['EMPTY_FIELDS'] . ' : ' . (empty(p('cname')) && $NOT_USER ? ' [ ' . $lang['YOURNAME'] . ' ] ' : '')
- . (empty(p('ctext')) ? ' [ ' . $lang['TEXT'] . ' ] ': '');
- }
- if (ip('cmail') && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i", trim(strtolower(p('cmail')))) && $NOT_USER)
- {
- $ERRORS['cmail'] = $lang['WRONG_EMAIL'];
- }
- if (strlen(p('ctext')) > 300)
- {
- $ERRORS['ctext'] = $lang['NO_ME300TEXT'];
- }
+ //check for form key
+ if (! kleeja_check_form_key('call'))
+ {
+ $ERRORS['form_key'] = $lang['INVALID_FORM_KEY'];
+ }
- if($t_cname == '_kleeja_')
- {
- update_config('new_version', '');
- }
+ if (! kleeja_check_captcha())
+ {
+ $ERRORS['captcha'] = $lang['WRONG_VERTY_CODE'];
+ }
+
+ if ((empty(p('cname')) && $NOT_USER) || empty(p('ctext')) )
+ {
+ $ERRORS['cname'] = $lang['EMPTY_FIELDS'] . ' : ' . (empty(p('cname')) && $NOT_USER ? ' [ ' . $lang['YOURNAME'] . ' ] ' : '')
+ . (empty(p('ctext')) ? ' [ ' . $lang['TEXT'] . ' ] ': '');
+ }
+
+ if (ip('cmail') && ! preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i", trim(strtolower(p('cmail')))) && $NOT_USER)
+ {
+ $ERRORS['cmail'] = $lang['WRONG_EMAIL'];
+ }
+
+ if (strlen(p('ctext')) > 300)
+ {
+ $ERRORS['ctext'] = $lang['NO_ME300TEXT'];
+ }
+
+ if ($t_cname == '_kleeja_')
+ {
+ update_config('new_version', '');
+ }
is_array($plugin_run_result = Plugins::getInstance()->run('submit_call_go_page2', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- //no errors ,lets do process
- if(empty($ERRORS))
- {
- $name = $NOT_USER ? (string) $SQL->escape(p('cname')) : $usrcp->name();
- $text = (string) $SQL->escape(p('ctext'));
- $mail = $NOT_USER ? (string) strtolower(trim($SQL->escape(p('cmail')))) : $usrcp->mail();
- $timee = (int) time();
- $ip = get_ip();
+ //no errors ,lets do process
+ if (empty($ERRORS))
+ {
+ $name = $NOT_USER ? (string) $SQL->escape(p('cname')) : $usrcp->name();
+ $text = (string) $SQL->escape(p('ctext'));
+ $mail = $NOT_USER ? (string) strtolower(trim($SQL->escape(p('cmail')))) : $usrcp->mail();
+ $timee = (int) time();
+ $ip = get_ip();
- $insert_query = array(
- 'INSERT' => "name ,text ,mail ,time ,ip",
- 'INTO' => "`{$dbprefix}call`",
- 'VALUES' => "'$name', '$text', '$mail', $timee, '$ip'"
- );
+ $insert_query = [
+ 'INSERT' => 'name ,text ,mail ,time ,ip',
+ 'INTO' => "`{$dbprefix}call`",
+ 'VALUES' => "'$name', '$text', '$mail', $timee, '$ip'"
+ ];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_insert_new_call', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- if ($SQL->build($insert_query))
- {
- send_mail($config['sitemail2'], $text . "\n\n\n\n" . 'TIME : ' . date('d-m-Y h:i a', $timee) . ' - IP:' . $ip, $lang['CALL'], $mail, $name);
- kleeja_info($lang['THNX_CALLED']);
- }
- }
- }
+ if ($SQL->build($insert_query))
+ {
+ send_mail($config['sitemail2'], $text . "\n\n\n\n" . 'TIME : ' . date('d-m-Y h:i a', $timee) . ' - IP:' . $ip, $lang['CALL'], $mail, $name);
+ kleeja_info($lang['THNX_CALLED']);
+ }
+ }
+ }
is_array($plugin_run_result = Plugins::getInstance()->run('call_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- break;
-
- //
- //Page for requesting delete file
- //
- case 'del' :
+ break;
+
+ //
+ //Page for requesting delete file
+ //
+ case 'del' :
is_array($plugin_run_result = Plugins::getInstance()->run('del_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- //stop .. check first ..
- if (!$config['del_url_file'])
- {
- kleeja_info($lang['NO_DEL_F'], $lang['E_DEL_F']);
- }
+ //stop .. check first ..
+ if (! $config['del_url_file'])
+ {
+ kleeja_info($lang['NO_DEL_F'], $lang['E_DEL_F']);
+ }
- //examples :
- //f2b3a82060a22a80283ed961d080b79f
- //aa92468375a456de21d7ca05ef945212
- //
- $cd = preg_replace('/[^0-9a-z]/i', '', $SQL->escape(g('cd'))); // may.. will protect
+ //examples :
+ //f2b3a82060a22a80283ed961d080b79f
+ //aa92468375a456de21d7ca05ef945212
+ //
+ $cd = preg_replace('/[^0-9a-z]/i', '', $SQL->escape(g('cd'))); // may.. will protect
- if (empty($cd))
- {
- kleeja_err($lang['WRONG_URL']);
- }
- else
- {
- //to check
- if(ig('sure') && g('sure') == 'ok')
- {
- $query = array(
- 'SELECT'=> 'f.id, f.name, f.folder, f.size, f.type',
- 'FROM' => "{$dbprefix}files f",
- 'WHERE' => "f.code_del='" . $cd . "'",
- 'LIMIT' => '1',
- );
+ if (empty($cd))
+ {
+ kleeja_err($lang['WRONG_URL']);
+ }
+ else
+ {
+ //to check
+ if (ig('sure') && g('sure') == 'ok')
+ {
+ $query = [
+ 'SELECT'=> 'f.id, f.name, f.folder, f.size, f.type',
+ 'FROM' => "{$dbprefix}files f",
+ 'WHERE' => "f.code_del='" . $cd . "'",
+ 'LIMIT' => '1',
+ ];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_file_with_code_del', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- $result = $SQL->build($query);
+ $result = $SQL->build($query);
- if ($SQL->num_rows($result) != 0)
- {
- while($row=$SQL->fetch_array($result))
- {
- @kleeja_unlink($row['folder'] . '/' . $row['name']);
- //delete thumb
- if (file_exists($row['folder'] . '/thumbs/' . $row['name']))
- {
- @kleeja_unlink($row['folder'] . '/thumbs/' . $row['name']);
- }
-
- $is_img = in_array($row['type'], array('png','gif','jpg','jpeg','tif','tiff', 'bmp')) ? true : false;
+ if ($SQL->num_rows($result) != 0)
+ {
+ while ($row=$SQL->fetch_array($result))
+ {
+ @kleeja_unlink($row['folder'] . '/' . $row['name']);
+ //delete thumb
+ if (file_exists($row['folder'] . '/thumbs/' . $row['name']))
+ {
+ @kleeja_unlink($row['folder'] . '/thumbs/' . $row['name']);
+ }
- $query_del = array(
- 'DELETE' => "{$dbprefix}files",
- 'WHERE' => 'id=' . $row['id']
- );
+ $is_img = in_array($row['type'], ['png','gif','jpg','jpeg','tif','tiff', 'bmp']) ? true : false;
+
+ $query_del = [
+ 'DELETE' => "{$dbprefix}files",
+ 'WHERE' => 'id=' . $row['id']
+ ];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_del_file_with_code_del', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- $SQL->build($query_del);
-
- if($SQL->affected())
- {
- //update number of stats
- $update_query = array(
- 'UPDATE' => "{$dbprefix}stats",
- 'SET' => ($is_img ? 'imgs=imgs-1':'files=files-1') . ',sizes=sizes-' . $row['size'],
- );
+ $SQL->build($query_del);
- $SQL->build($update_query);
- kleeja_info($lang['DELETE_SUCCESFUL']);
- }
- else
- {
- kleeja_info($lang['ERROR_TRY_AGAIN']);
- }
+ if ($SQL->affected())
+ {
+ //update number of stats
+ $update_query = [
+ 'UPDATE' => "{$dbprefix}stats",
+ 'SET' => ($is_img ? 'imgs=imgs-1':'files=files-1') . ',sizes=sizes-' . $row['size'],
+ ];
- break;//to prevent divel actions
- }
+ $SQL->build($update_query);
+ kleeja_info($lang['DELETE_SUCCESFUL']);
+ }
+ else
+ {
+ kleeja_info($lang['ERROR_TRY_AGAIN']);
+ }
- $SQL->freeresult($result);
- }
- }
- else
- {
- //fix for IE+
- $extra_codes = '';
- kleeja_info($lang['ARE_YOU_SURE_DO_THIS'], '', true, false, 0, $extra_codes);
- }
- }#else
+ kleeja_info($lang['ARE_YOU_SURE_DO_THIS'], '', true, false, 0, $extra_codes);
+ }
+ }//else
- break;
+ break;
- //
- //Page of Kleeja stats
- //
- case 'stats' :
+ //
+ //Page of Kleeja stats
+ //
+ case 'stats' :
- //Not allowed to access this page ?
- if (!user_can('access_stats'))
- {
+ //Not allowed to access this page ?
+ if (! user_can('access_stats'))
+ {
is_array($plugin_run_result = Plugins::getInstance()->run('user_cannot_access_stats', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- kleeja_info($lang['HV_NOT_PRVLG_ACCESS']);
- }
+ kleeja_info($lang['HV_NOT_PRVLG_ACCESS']);
+ }
- //stop .. check first ..
- if (!$config['allow_stat_pg'])
- {
- kleeja_info($lang['STATS_CLOSED'], $lang['STATS_CLOSED']);
- }
+ //stop .. check first ..
+ if (! $config['allow_stat_pg'])
+ {
+ kleeja_info($lang['STATS_CLOSED'], $lang['STATS_CLOSED']);
+ }
- //stats of most online users
- if(empty($config['most_user_online_ever']) || trim($config['most_user_online_ever']) == '')
- {
- $most_online = 1;// 1 == you
- $on_muoe = time();
- }
- else
- {
- list($most_online, $on_muoe) = @explode(':', $config['most_user_online_ever']);
- }
+ //stats of most online users
+ if (empty($config['most_user_online_ever']) || trim($config['most_user_online_ever']) == '')
+ {
+ $most_online = 1;// 1 == you
+ $on_muoe = time();
+ }
+ else
+ {
+ list($most_online, $on_muoe) = @explode(':', $config['most_user_online_ever']);
+ }
- //ok .. go on
- $titlee = $lang['STATS'];
- $stylee = 'stats';
- $files_st = $stat_files;
- $imgs_st = $stat_imgs;
- $users_st = $stat_users;
- $sizes_st = readable_size($stat_sizes);
- $lst_dl_st = (int) $config['del_f_day'] <= 0 ? false : kleeja_date($stat_last_f_del);
- $lst_reg = empty($stat_last_user) ? $lang['UNKNOWN'] : $stat_last_user;
- $on_muoe = kleeja_date($on_muoe);
+ //ok .. go on
+ $titlee = $lang['STATS'];
+ $stylee = 'stats';
+ $files_st = $stat_files;
+ $imgs_st = $stat_imgs;
+ $users_st = $stat_users;
+ $sizes_st = readable_size($stat_sizes);
+ $lst_dl_st = (int) $config['del_f_day'] <= 0 ? false : kleeja_date($stat_last_f_del);
+ $lst_reg = empty($stat_last_user) ? $lang['UNKNOWN'] : $stat_last_user;
+ $on_muoe = kleeja_date($on_muoe);
is_array($plugin_run_result = Plugins::getInstance()->run('stats_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- break;
-
- //
- // Page for redirect to downloading a file
- // [!] depreacted from 1rc6+, see do.php
- //
- case 'down':
+ break;
- //go.php?go=down&n=$1&f=$2&i=$3
- if(ig('n'))
- {
- $url_file = (int) $config['mod_writer'] == 1 ? $config['siteurl'] . 'download' . g('i', 'int') . '.html' : $config['siteurl'] . 'do.php?id=' . g('n', 'int');
- }
- else
- {
- $url_file = $config['siteurl'];
- }
-
- $SQL->close();
- redirect($url_file);
- exit;
+ //
+ // Page for redirect to downloading a file
+ // [!] depreacted from 1rc6+, see do.php
+ //
+ case 'down':
- break;
-
- //
- // for queue
- //
- case 'queue':
+ //go.php?go=down&n=$1&f=$2&i=$3
+ if (ig('n'))
+ {
+ $url_file = (int) $config['mod_writer'] == 1 ? $config['siteurl'] . 'download' . g('i', 'int') . '.html' : $config['siteurl'] . 'do.php?id=' . g('n', 'int');
+ }
+ else
+ {
+ $url_file = $config['siteurl'];
+ }
- #img header and print spacer gif
- header('Cache-Control: no-cache');
- header('Content-type: image/gif');
- header('Content-length: 43');
- echo base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
+ $SQL->close();
+ redirect($url_file);
+
+ exit;
+
+ break;
+
+ //
+ // for queue
+ //
+ case 'queue':
+
+ //img header and print spacer gif
+ header('Cache-Control: no-cache');
+ header('Content-type: image/gif');
+ header('Content-length: 43');
+ echo base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
- #do some of the queue ..
- if(preg_match('/:del_[a-z0-9]{0,3}calls:/i', $config['queue']))
- {
- klj_clean_old('call', (strpos(':del_allcalls:', $config['queue']) !== false ? 'all': 30));
- }
- elseif(preg_match('/:del_[a-z0-9]{0,3}reports:/i', $config['queue']))
- {
- klj_clean_old('reports', (strpos(':del_allreports:', $config['queue']) !== false ? 'all': 30));
- }
- elseif((int) $config['del_f_day'] > 0)
- {
- klj_clean_old_files($config['klj_clean_files_from']);
- }
+ //do some of the queue ..
+ if (preg_match('/:del_[a-z0-9]{0,3}calls:/i', $config['queue']))
+ {
+ klj_clean_old('call', (strpos(':del_allcalls:', $config['queue']) !== false ? 'all': 30));
+ }
+ elseif (preg_match('/:del_[a-z0-9]{0,3}reports:/i', $config['queue']))
+ {
+ klj_clean_old('reports', (strpos(':del_allreports:', $config['queue']) !== false ? 'all': 30));
+ }
+ elseif ((int) $config['del_f_day'] > 0)
+ {
+ klj_clean_old_files($config['klj_clean_files_from']);
+ }
is_array($plugin_run_result = Plugins::getInstance()->run('go_queue', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
- #end
- $SQL->close();
- exit;
+ //end
+ $SQL->close();
- break;
-
- //
- //this is a part of ACP, only admins can access this part of page
- //
- case 'resync':
-
- if(!user_can('enter_acp'))
- {
- kleeja_info($lang['HV_NOT_PRVLG_ACCESS']);
- exit;
- }
+ exit;
- #get admin functions
- include 'includes/functions_adm.php';
- #get admin langauge
- get_lang('acp');
+ break;
- switch(g('case')):
- //
- //re-sync total files number ..
- //
- case 'sync_files':
+ //
+ //this is a part of ACP, only admins can access this part of page
+ //
+ case 'resync':
- #no start ? or there
- $start = !ig('start') ? false : g('start', 'int');
+ if (! user_can('enter_acp'))
+ {
+ kleeja_info($lang['HV_NOT_PRVLG_ACCESS']);
- $end = sync_total_files(true, $start);
+ exit;
+ }
- #no end, then sync'ing is done...
- if(!$end)
- {
- delete_cache('data_stats');
- $text = $title = sprintf($lang['SYNCING_DONE'], $lang['ALL_FILES']);
- $link_to_go = './admin/?cp=r_repair#!cp=r_repair';
- }
- else
- {
- $text = $title = sprintf($lang['SYNCING'], $lang['ALL_FILES']) . ' (' . (!$start ? 0 : $start) . '->' . (!$end ? '?' : $end) . ')';
- $link_to_go = './go.php?go=resync&case=sync_files&start=' . $end;
- }
+ //get admin functions
+ include 'includes/functions_adm.php';
+ //get admin langauge
+ get_lang('acp');
- //to be sure !
- $text .= '' . "\n";
-
- kleeja_info($text, $title, true, $link_to_go, 2);
+ switch (g('case')):
+ //
+ //re-sync total files number ..
+ //
+ case 'sync_files':
- break;
+ //no start ? or there
+ $start = ! ig('start') ? false : g('start', 'int');
+
+ $end = sync_total_files(true, $start);
+
+ //no end, then sync'ing is done...
+ if (! $end)
+ {
+ delete_cache('data_stats');
+ $text = $title = sprintf($lang['SYNCING_DONE'], $lang['ALL_FILES']);
+ $link_to_go = './admin/?cp=r_repair#!cp=r_repair';
+ }
+ else
+ {
+ $text = $title = sprintf($lang['SYNCING'], $lang['ALL_FILES']) . ' (' . (! $start ? 0 : $start) . '->' . (! $end ? '?' : $end) . ')';
+ $link_to_go = './go.php?go=resync&case=sync_files&start=' . $end;
+ }
+
+ //to be sure !
+ $text .= '' . "\n";
+
+ kleeja_info($text, $title, true, $link_to_go, 2);
+
+ break;
- //
- //re-sync total images number ..
- //
- case 'sync_images':
+ //
+ //re-sync total images number ..
+ //
+ case 'sync_images':
- #no start ? or there
- $start = !ig('start') ? false : g('start', 'int');
+ //no start ? or there
+ $start = ! ig('start') ? false : g('start', 'int');
- $end = sync_total_files(false, $start);
+ $end = sync_total_files(false, $start);
- #no end, then sync'ing is done...
- if(!$end)
- {
- delete_cache('data_stats');
- $text = $title = sprintf($lang['SYNCING_DONE'], $lang['ALL_IMAGES']) . ' (' . (!$start ? 0 : $start) . '->' . (!$end ? '?' : $end) . ')';
- $link_to_go = './admin/?cp=r_repair#!cp=r_repair';
- }
- else
- {
- $text = $title = sprintf($lang['SYNCING'], $lang['ALL_IMAGES']);
- $link_to_go = './go.php?go=resync&case=sync_images&start=' . $end;
- }
+ //no end, then sync'ing is done...
+ if (! $end)
+ {
+ delete_cache('data_stats');
+ $text = $title = sprintf($lang['SYNCING_DONE'], $lang['ALL_IMAGES']) . ' (' . (! $start ? 0 : $start) . '->' . (! $end ? '?' : $end) . ')';
+ $link_to_go = './admin/?cp=r_repair#!cp=r_repair';
+ }
+ else
+ {
+ $text = $title = sprintf($lang['SYNCING'], $lang['ALL_IMAGES']);
+ $link_to_go = './go.php?go=resync&case=sync_images&start=' . $end;
+ }
- //to be sure !
- $text .= '' . "\n";
-
- kleeja_info($text, $title, true, $link_to_go, 2);
+ //to be sure !
+ $text .= '' . "\n";
- break;
- endswitch;
+ kleeja_info($text, $title, true, $link_to_go, 2);
- break;
+ break;
+ endswitch;
+
+ break;
/**
@@ -617,9 +631,9 @@ switch($current_go_case)
$field_value = ig('value') ? g('value', 'int') : 0;
- $result_data = array(
+ $result_data = [
'current_progress' => 0,
- );
+ ];
// if($field_value == 0)
// {
@@ -627,16 +641,16 @@ switch($current_go_case)
// }
- if(!function_exists('ini_get'))
+ if (! function_exists('ini_get'))
{
exit(json_encode($result_data));
}
- $key = ini_get("session.upload_progress.prefix") . $field_value;
+ $key = ini_get('session.upload_progress.prefix') . $field_value;
$progress_session_info = empty($_SESSION[$key]) ? null : $_SESSION[$key];
- if(empty($progress_session_info))
+ if (empty($progress_session_info))
{
exit(json_encode($result_data));
}
@@ -649,22 +663,22 @@ switch($current_go_case)
//
- // Default , if you are a developer , you can embed your page here with this hook
- // by using g('go') and your codes.
- //
- default:
+ // Default , if you are a developer , you can embed your page here with this hook
+ // by using g('go') and your codes.
+ //
+ default:
- $no_request = true;
+ $no_request = true;
is_array($plugin_run_result = Plugins::getInstance()->run('default_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
-
- if($no_request)
- {
- kleeja_err($lang['ERROR_NAVIGATATION']);
- }
- break;
-}#end switch
+ if ($no_request)
+ {
+ kleeja_err($lang['ERROR_NAVIGATATION']);
+ }
+
+ break;
+}//end switch
is_array($plugin_run_result = Plugins::getInstance()->run('end_go_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -673,9 +687,9 @@ $stylee = empty($stylee) ? 'info' : $stylee;
$titlee = empty($titlee) ? '' : $titlee;
//show style
-if($show_style)
+if ($show_style)
{
- Saaheader($titlee);
- echo $tpl->display($stylee , $styleePath);
- Saafooter();
+ Saaheader($titlee);
+ echo $tpl->display($stylee, $styleePath);
+ Saafooter();
}
diff --git a/includes/KleejaUploader.php b/includes/KleejaUploader.php
index a4f0482..76bb55d 100755
--- a/includes/KleejaUploader.php
+++ b/includes/KleejaUploader.php
@@ -8,10 +8,10 @@
*/
-#no direct access
-if (!defined('IN_COMMON'))
+//no direct access
+if (! defined('IN_COMMON'))
{
- exit();
+ exit();
}
@@ -21,73 +21,73 @@ interface KleejaUploader
/**
* set the allowed extensions of uploaded files
- * @param array $allowed_file_extensions an array of allowed extensions, and sizes ['gif'=>122, 'png'=>2421 ..]
+ * @param array $allowed_file_extensions an array of allowed extensions, and sizes ['gif'=>122, 'png'=>2421 ..]
* @return void
*/
- function setAllowedFileExtensions($allowed_file_extensions);
+ public function setAllowedFileExtensions($allowed_file_extensions);
/**
* get the allowed extensions of uploaded files
* @return array
*/
- function getAllowedFileExtensions();
+ public function getAllowedFileExtensions();
/**
* set the allowed limit of the uploaded files
- * @param int $limit
+ * @param int $limit
* @return void
*/
- function setUploadFieldsLimit($limit);
+ public function setUploadFieldsLimit($limit);
/**
* get the allowed limit of the uploaded files
* @return int
*/
- function getUploadFieldsLimit();
+ public function getUploadFieldsLimit();
/**
* add an information message to output it to the user
- * @param string $message
+ * @param string $message
* @return void
*/
- function addInfoMessage($message);
+ public function addInfoMessage($message);
/**
* add an error message to output it to the user
- * @param string $message
+ * @param string $message
* @return void
*/
- function addErrorMessage($message);
+ public function addErrorMessage($message);
/**
* get all the messages
* @return array
*/
- function getMessages();
+ public function getMessages();
/**
* save the file information to the database
- * @param array $fileInfo
+ * @param array $fileInfo
* @return void
*/
- function saveToDatabase($fileInfo);
+ public function saveToDatabase($fileInfo);
/**
* generate a box of the result and add it to addInfoMessage
- * @param array $fileInfo
+ * @param array $fileInfo
* @return void
*/
- function generateOutputBox($fileInfo);
+ public function generateOutputBox($fileInfo);
/**
* here happens the magic, call this on upload submit
- * @param int $uploadType upload from files input or links
+ * @param int $uploadType upload from files input or links
* @return void
*/
- function upload($uploadType);
+ public function upload($uploadType);
}
diff --git a/includes/adm/a_configs.php b/includes/adm/a_configs.php
index 18ae904..e6734d9 100755
--- a/includes/adm/a_configs.php
+++ b/includes/adm/a_configs.php
@@ -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 . '&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 . '&smt=' . $row['type'], 'goto'=>$row['type'], 'current'=> $current_smt == $row['type']];
}
-$go_menu['all'] = array('name'=>$lang['CONFIG_KLJ_MENUS_ALL'], 'link'=>$action . '&smt=all', 'goto'=>'all', 'current'=> $current_smt == 'all');
+$go_menu['all'] = ['name'=>$lang['CONFIG_KLJ_MENUS_ALL'], 'link'=>$action . '&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&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&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 = 'Google Analytics';
-$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 .= '' . "\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 .= '' . "\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 .= '' . "\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 .= '' . "\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' => '' . "\n" . '',
- '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 .= '' . "\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 .= '' . "\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 .= '' . "\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 .= '' . "\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' => '' . "\n" . '',
+ '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']] = '' .
- '- '. $lang['R_CONFIGS'] .'
' .
- '- '. $go_menu[$option['type']]['name'] .'
' .
+ if (empty($types[$option['type']]))
+ {
+ $types[$option['type']] = '' .
+ '- ' . $lang['R_CONFIGS'] . '
' .
+ '- ' . $go_menu[$option['type']]['name'] . '
' .
'
';
- }
+ }
}
-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('', '', '
';
- echo 'Gzip : ' . ($do_gzip_compress !=0 ? "Enabled" : "Disabled") . '
';
- echo 'Queries Number : ' . $SQL->query_num . '
';
- echo 'Hook System : ' . ((!defined('STOP_PLUGINS')) ? "Enabled" : "Disabled") . '
';
+ echo 'Gzip : ' . ($do_gzip_compress !=0 ? 'Enabled' : 'Disabled') . '
';
+ echo 'Queries Number : ' . $SQL->query_num . '
';
+ echo 'Hook System : ' . ((! defined('STOP_PLUGINS')) ? 'Enabled' : 'Disabled') . '
';
echo '' . $debug_output . '
';
echo '
';
echo 'SQL Information :
';
- if(is_array($SQL->debugr))
+ if (is_array($SQL->debugr))
{
- foreach($SQL->debugr as $key=>$val)
+ foreach ($SQL->debugr as $key=>$val)
{
echo '