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

141
index.php
View File

@@ -17,7 +17,7 @@ define('IN_REAL_INDEX', true);
/**
* We are in the middle of the uploading process, useful for exceptions
*/
define('IN_SUBMIT_UPLOADING' , isset($_POST['submitr']) || isset($_POST['submittxt']));
define('IN_SUBMIT_UPLOADING', isset($_POST['submitr']) || isset($_POST['submittxt']));
/**
@@ -27,7 +27,7 @@ define('IN_KLEEJA', true);
require_once 'includes/common.php';
require_once 'includes/KleejaUploader.php';
#current uploading method
//current uploading method
$uploadingMethodClass = 'includes/up_methods/defaultUploader.php';
@@ -39,11 +39,11 @@ require_once $uploadingMethodClass;
//
//Is kleeja only for members?
//
if(empty($d_groups[2]['exts']) && !$usrcp->name())
if (empty($d_groups[2]['exts']) && ! $usrcp->name())
{
// Send a 503 HTTP response code to prevent search bots from indexing this message
//header('HTTP/1.1 503 Service Temporarily Unavailable');
kleeja_info($lang['SITE_FOR_MEMBER_ONLY'], $lang['HOME']);
// Send a 503 HTTP response code to prevent search bots from indexing this message
//header('HTTP/1.1 503 Service Temporarily Unavailable');
kleeja_info($lang['SITE_FOR_MEMBER_ONLY'], $lang['HOME']);
}
@@ -52,7 +52,7 @@ $action = $config['siteurl'];
/** @var KleejaUploader $uploader */
$uploadingMethodClassBaseName = basename($uploadingMethodClass, '.php');
$uploader = new $uploadingMethodClassBaseName;
$uploader = new $uploadingMethodClassBaseName;
$uploader->setAllowedFileExtensions($d_groups[$userinfo['group_id']]['exts']);
$uploader->setUploadFieldsLimit($config['filesnum']);
@@ -60,20 +60,20 @@ $uploader->setUploadFieldsLimit($config['filesnum']);
$uploading_type = ip('submitr') ? 1 : (ip('submittxt') ? 2 : false);
if($uploading_type)
if ($uploading_type)
{
$uploader->upload($uploading_type);
}
#file input fields
$FILES_NUM_LOOP = array();
//file input fields
$FILES_NUM_LOOP = [];
if($config['filesnum'] > 0)
if ($config['filesnum'] > 0)
{
foreach(range(1, $config['filesnum']) as $i)
foreach (range(1, $config['filesnum']) as $i)
{
$FILES_NUM_LOOP[] = array('i' => $i, 'show'=>($i == 1 || (!empty($config['filesnum_show']) && (int) $config['filesnum_show'] == 1) ? '' : 'display: none'));
$FILES_NUM_LOOP[] = ['i' => $i, 'show'=>($i == 1 || (! empty($config['filesnum_show']) && (int) $config['filesnum_show'] == 1) ? '' : 'display: none')];
}
}
else
@@ -82,30 +82,31 @@ else
}
#show errors and info
$info = array();
foreach($uploader->getMessages() as $t => $s)
//show errors and info
$info = [];
foreach ($uploader->getMessages() as $t => $s)
{
$info[] = array(
't' => $s[1] == 'error' ? 'index_err' : 'index_info', #for old Kleeja versions
$info[] = [
't' => $s[1] == 'error' ? 'index_err' : 'index_info', //for old Kleeja versions
'i' => $s[0], //#for old Kleeja versions
'message_content' => $s[0],
'message_type' => $s[1],
);
'message_type' => $s[1],
];
}
#some words for template
//some words for template
$welcome_msg = $config['welcome_msg'];
$filecp_link = $usrcp->id() ? $config['siteurl'] . ($config['mod_writer'] ? 'filecp.html' : 'ucp.php?go=filecp') : false;
$terms_msg = sprintf($lang['AGREE_RULES'], '<a href="' . ($config['mod_writer'] ? 'rules.html' : 'go.php?go=rules') . '">' , '</a>');
$terms_msg = sprintf($lang['AGREE_RULES'], '<a href="' . ($config['mod_writer'] ? 'rules.html' : 'go.php?go=rules') . '">', '</a>');
$link_avater = sprintf($lang['EDIT_U_AVATER_LINK'], '<a href="https://www.gravatar.com/" target="_blank">', '</a>');
$js_allowed_extensions_types = "['" . implode("', '", array_keys($d_groups[$userinfo['group_id']]['exts'])) . "']";
$js_allowed_extensions_sizes = "[" . implode(", ", array_values($d_groups[$userinfo['group_id']]['exts'])) . "]";
$js_allowed_extensions_types = "['" . implode("', '", array_keys($d_groups[$userinfo['group_id']]['exts'])) . "']";
$js_allowed_extensions_sizes = '[' . implode(', ', array_values($d_groups[$userinfo['group_id']]['exts'])) . ']';
@@ -114,75 +115,75 @@ $js_allowed_extensions_sizes = "[" . implode(", ", array_values($d_groups[$useri
//I don't like this feature and I prefer that you disable it
//
$show_online = $config['allow_online'] == 1 ? true : false;
if ($show_online)
{
$current_online_users = 0;
$online_names = array();
$timeout = 60; //30 second
$timeout2 = time()-$timeout;
$online_names = [];
$timeout = 60; //30 second
$timeout2 = time()-$timeout;
//put another bot name
//put another bot name
is_array($plugin_run_result = Plugins::getInstance()->run('anotherbots_online_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$query = array(
'SELECT' => 'u.name',
'FROM' => "{$dbprefix}users u",
'WHERE' => "u.last_visit > $timeout2"
);
$query = [
'SELECT' => 'u.name',
'FROM' => "{$dbprefix}users u",
'WHERE' => "u.last_visit > $timeout2"
];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_online_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$result = $SQL->build($query);
$result = $SQL->build($query);
while($row=$SQL->fetch_array($result))
{
while ($row=$SQL->fetch_array($result))
{
is_array($plugin_run_result = Plugins::getInstance()->run('while_qr_select_online_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$current_online_users++;
$online_names[$row['name']] = $row['name'];
}#while
$online_names[$row['name']] = $row['name'];
}//while
$SQL->freeresult($result);
$SQL->freeresult($result);
//make names as array to print them in template
$show_names = array();
//make names as array to print them in template
$show_names = [];
$show_names_sizeof = sizeof($online_names);
foreach ($online_names as $k)
{
$show_names[] = array('name' => $k, 'separator' => $show_names_sizeof ? ',' : '');
}
foreach ($online_names as $k)
{
$show_names[] = ['name' => $k, 'separator' => $show_names_sizeof ? ',' : ''];
}
//some variables must be destroyed here
unset($online_names, $timeout, $timeout2);
//some variables must be destroyed here
unset($online_names, $timeout, $timeout2);
//check & update most ever users and visitors were online
if(empty($config['most_user_online_ever']) || trim($config['most_user_online_ever']) == '')
{
if (empty($config['most_user_online_ever']) || trim($config['most_user_online_ever']) == '')
{
$most_online = $current_online_users;
$online_time = time();
}
else
{
list($most_online, $online_time) = @explode(':', $config['most_user_online_ever']);
}
}
else
{
list($most_online, $online_time) = @explode(':', $config['most_user_online_ever']);
}
if ($most_online < $current_online_users || empty($config['most_user_online_ever']))
{
update_config('most_user_online_ever', $current_online_users . ':' . time());
}
if ($most_online < $current_online_users || empty($config['most_user_online_ever']))
{
update_config('most_user_online_ever', $current_online_users . ':' . time());
}
$online_time = kleeja_date('d-m-Y h:i a', $online_time);
$online_time = kleeja_date('d-m-Y h:i a', $online_time);
//before 1.8, styles computability
$usersnum = $current_online_users;
$shownames = $show_names;
//before 1.8, styles computability
$usersnum = $current_online_users;
$shownames = $show_names;
is_array($plugin_run_result = Plugins::getInstance()->run('if_online_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
}#allow_online
is_array($plugin_run_result = Plugins::getInstance()->run('if_online_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
}//allow_online
$show_style = true;
@@ -191,22 +192,22 @@ is_array($plugin_run_result = Plugins::getInstance()->run('end_index_page', get_
//is ajax
if(ip('ajax'))
if (ip('ajax'))
{
if(!empty($info))
if (! empty($info))
{
header('Content-Type: text/plain; charset=utf-8');
echo json_encode($info);
}
exit;
}
//show style
if($show_style)
if ($show_style)
{
Saaheader();
echo $tpl->display(($config['filesnum'] > 0 ? "index_body" : "info"));
echo $tpl->display(($config['filesnum'] > 0 ? 'index_body' : 'info'));
Saafooter();
}