mirror of
https://github.com/kleeja-official/kleeja.git
synced 2025-12-16 04:59:42 +01:00
coding style fixes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 = '<a href="http://www.google.com/analytics">Google Analytics</a>';
|
||||
|
||||
$query = array(
|
||||
'SELECT' => '*',
|
||||
'FROM' => "{$dbprefix}config",
|
||||
'ORDER BY' => 'display_order, type ASC'
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => '*',
|
||||
'FROM' => "{$dbprefix}config",
|
||||
'ORDER BY' => 'display_order, type ASC'
|
||||
];
|
||||
|
||||
$CONFIGEXTEND = $SQL->escape($current_smt);
|
||||
$CONFIGEXTEND = $SQL->escape($current_smt);
|
||||
$CONFIGEXTENDLANG = $go_menu[$current_smt]['name'];
|
||||
|
||||
if($current_smt != 'all')
|
||||
|
||||
if ($current_smt != 'all')
|
||||
{
|
||||
$query['WHERE'] = "type = '" . $SQL->escape($current_smt) . "' OR type = ''";
|
||||
|
||||
if($current_smt == 'interface')
|
||||
{
|
||||
$query['WHERE'] .= " OR name='language'";
|
||||
}
|
||||
$query['WHERE'] = "type = '" . $SQL->escape($current_smt) . "' OR type = ''";
|
||||
|
||||
if ($current_smt == 'interface')
|
||||
{
|
||||
$query['WHERE'] .= " OR name='language'";
|
||||
}
|
||||
}
|
||||
else if($current_smt == 'all')
|
||||
elseif ($current_smt == 'all')
|
||||
{
|
||||
$query['WHERE'] = "type <> 'groups' OR type = ''";
|
||||
$query['WHERE'] = "type <> 'groups' OR type = ''";
|
||||
}
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
$thumbs_are = get_config('thmb_dims');
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
if($row['type'] == 'KLIVE')
|
||||
if ($row['type'] == 'KLIVE')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if($row['name'] == 'language' && $current_smt == 'interface')
|
||||
{
|
||||
$row['type'] = 'interface';
|
||||
}
|
||||
|
||||
|
||||
#make new lovely array !!
|
||||
$con[$row['name']] = $row['value'];
|
||||
|
||||
if($row['name'] == 'thumbs_imgs')
|
||||
{
|
||||
list($thmb_dim_w, $thmb_dim_h) = array_map('trim', @explode('*', $thumbs_are));
|
||||
}
|
||||
else if($row['name'] == 'time_zone')
|
||||
{
|
||||
$zones = time_zones();
|
||||
foreach($zones as $z=>$t)
|
||||
{
|
||||
$time_zones .= '<option ' . ($con['time_zone'] == $t ? 'selected="selected"' : '') . ' value="' . $t . '">' . $z . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
else if($row['name'] == 'language')
|
||||
{
|
||||
//get languages
|
||||
if ($dh = @opendir(PATH . 'lang'))
|
||||
{
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if(strpos($file, '.') === false && $file != '..' && $file != '.')
|
||||
{
|
||||
$lngfiles .= '<option ' . ($con['language'] == $file ? 'selected="selected"' : '') . ' value="' . $file . '">' . $file . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
}
|
||||
}
|
||||
else if($row['name'] == 'user_system')
|
||||
{
|
||||
//get auth types
|
||||
//fix previous choices in old kleeja
|
||||
if(in_array($con['user_system'], array('2', '3', '4')))
|
||||
{
|
||||
$con['user_system'] = str_replace(array('2', '3', '4'), array('phpbb', 'vb', 'mysmartbb'), $con['user_system']);
|
||||
}
|
||||
|
||||
$authtypes .= '<option value="1"' . ($con['user_system']=='1' ? ' selected="selected"' : '') . '>' . $lang['NORMAL'] . '</option>' . "\n";
|
||||
if ($dh = @opendir(PATH . 'includes/auth_integration'))
|
||||
{
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if(strpos($file, '.php') !== false)
|
||||
{
|
||||
$file = trim(str_replace('.php', '', $file));
|
||||
$authtypes .= '<option value="' . $file . '"' . ($con['user_system'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
}
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('while_fetch_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
//options from database [UNDER TEST]
|
||||
if(!empty($row['option']))
|
||||
{
|
||||
$optionss[$row['name']] = array(
|
||||
'option' => '<div class="form-group">' . "\n" .
|
||||
'<label for="' . $row['name'] . '">' . (!empty($lang[strtoupper($row['name'])]) ? $lang[strtoupper($row['name'])] : $olang[strtoupper($row['name'])]) . '</label>' . "\n" .
|
||||
'<div class="box">' . (empty($row['option']) ? '' : $tpl->admindisplayoption($row['option'])) . '</div>' . "\n" .
|
||||
'</div>' . "\n" . '<div class="clear"></div>',
|
||||
'type' => $row['type'],
|
||||
'display_order' => $row['display_order'],
|
||||
);
|
||||
}
|
||||
|
||||
//when submit
|
||||
if (ip('submit'))
|
||||
{
|
||||
//-->
|
||||
$new[$row['name']] = p($row['name'], 'str', $con[$row['name']]);
|
||||
|
||||
//save them as you want ..
|
||||
if($row['name'] == 'thumbs_imgs')
|
||||
{
|
||||
if(p('thmb_dim_w', 'int') < 10)
|
||||
{
|
||||
$_POST['thmb_dim_w'] = 10;
|
||||
}
|
||||
|
||||
if(p('thmb_dim_h', 'int') < 10)
|
||||
{
|
||||
$_POST['thmb_dim_h'] = 10;
|
||||
}
|
||||
|
||||
$thumbs_were = p('thmb_dim_w', 'int') . '*' . p('thmb_dim_h', 'int');
|
||||
update_config('thmb_dims', $thumbs_were);
|
||||
}
|
||||
else if($row['name'] == 'livexts')
|
||||
{
|
||||
$new['livexts'] = implode(',', array_map('trim', explode(',', p('livexts'))));
|
||||
}
|
||||
else if($row['name'] == 'prefixname')
|
||||
{
|
||||
$new['prefixname'] = preg_replace('/[^a-z0-9_\-\}\{\:\.]/', '', strtolower(p('prefixname')));
|
||||
}
|
||||
else if($row['name'] == 'siteurl')
|
||||
{
|
||||
if(p('siteurl')[strlen(p('siteurl'))-1] != '/')
|
||||
{
|
||||
$new['siteurl'] .= '/';
|
||||
}
|
||||
}
|
||||
else if($row['name'] == 'mod_writer')
|
||||
if ($row['name'] == 'language' && $current_smt == 'interface')
|
||||
{
|
||||
if($new['mod_writer'] == 1)
|
||||
$row['type'] = 'interface';
|
||||
}
|
||||
|
||||
|
||||
//make new lovely array !!
|
||||
$con[$row['name']] = $row['value'];
|
||||
|
||||
if ($row['name'] == 'thumbs_imgs')
|
||||
{
|
||||
list($thmb_dim_w, $thmb_dim_h) = array_map('trim', @explode('*', $thumbs_are));
|
||||
}
|
||||
elseif ($row['name'] == 'time_zone')
|
||||
{
|
||||
$zones = time_zones();
|
||||
|
||||
foreach ($zones as $z=>$t)
|
||||
{
|
||||
if(!file_exists(PATH . '.htaccess') && file_exists(PATH . 'htaccess.txt') && function_exists('rename'))
|
||||
{
|
||||
rename(PATH . 'htaccess.txt', PATH . '.htaccess');
|
||||
}
|
||||
$time_zones .= '<option ' . ($con['time_zone'] == $t ? 'selected="selected"' : '') . ' value="' . $t . '">' . $z . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
else if($row['name'] == 'language')
|
||||
{
|
||||
$got_lang = preg_replace('[^a-zA-Z0-9]', '', $new[$row['name']]);
|
||||
|
||||
|
||||
//all groups
|
||||
foreach ($d_groups as $group_id => $group_info)
|
||||
elseif ($row['name'] == 'language')
|
||||
{
|
||||
//get languages
|
||||
if ($dh = @opendir(PATH . 'lang'))
|
||||
{
|
||||
update_config('language', $got_lang, true, $group_id);
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if (strpos($file, '.') === false && $file != '..' && $file != '.')
|
||||
{
|
||||
$lngfiles .= '<option ' . ($con['language'] == $file ? 'selected="selected"' : '') . ' value="' . $file . '">' . $file . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
}
|
||||
}
|
||||
elseif ($row['name'] == 'user_system')
|
||||
{
|
||||
//get auth types
|
||||
//fix previous choices in old kleeja
|
||||
if (in_array($con['user_system'], ['2', '3', '4']))
|
||||
{
|
||||
$con['user_system'] = str_replace(['2', '3', '4'], ['phpbb', 'vb', 'mysmartbb'], $con['user_system']);
|
||||
}
|
||||
|
||||
delete_cache('data_lang' . $got_lang);
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('after_submit_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
$authtypes .= '<option value="1"' . ($con['user_system']=='1' ? ' selected="selected"' : '') . '>' . $lang['NORMAL'] . '</option>' . "\n";
|
||||
|
||||
$update_query = array(
|
||||
'UPDATE' => "{$dbprefix}config",
|
||||
'SET' => "value='" . $SQL->escape($new[$row['name']]) . "'",
|
||||
'WHERE' => "name='" . $row['name'] . "'"
|
||||
);
|
||||
if ($dh = @opendir(PATH . 'includes/auth_integration'))
|
||||
{
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if (strpos($file, '.php') !== false)
|
||||
{
|
||||
$file = trim(str_replace('.php', '', $file));
|
||||
$authtypes .= '<option value="' . $file . '"' . ($con['user_system'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
}
|
||||
}
|
||||
|
||||
if($current_smt != 'all')
|
||||
{
|
||||
$query['WHERE'] .= " AND type = '" . $SQL->escape($current_smt) . "'";
|
||||
}
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('while_fetch_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$SQL->build($update_query);
|
||||
}
|
||||
//options from database [UNDER TEST]
|
||||
if (! empty($row['option']))
|
||||
{
|
||||
$optionss[$row['name']] = [
|
||||
'option' => '<div class="form-group">' . "\n" .
|
||||
'<label for="' . $row['name'] . '">' . (! empty($lang[strtoupper($row['name'])]) ? $lang[strtoupper($row['name'])] : $olang[strtoupper($row['name'])]) . '</label>' . "\n" .
|
||||
'<div class="box">' . (empty($row['option']) ? '' : $tpl->admindisplayoption($row['option'])) . '</div>' . "\n" .
|
||||
'</div>' . "\n" . '<div class="clear"></div>',
|
||||
'type' => $row['type'],
|
||||
'display_order' => $row['display_order'],
|
||||
];
|
||||
}
|
||||
|
||||
//when submit
|
||||
if (ip('submit'))
|
||||
{
|
||||
//-->
|
||||
$new[$row['name']] = p($row['name'], 'str', $con[$row['name']]);
|
||||
|
||||
//save them as you want ..
|
||||
if ($row['name'] == 'thumbs_imgs')
|
||||
{
|
||||
if (p('thmb_dim_w', 'int') < 10)
|
||||
{
|
||||
$_POST['thmb_dim_w'] = 10;
|
||||
}
|
||||
|
||||
if (p('thmb_dim_h', 'int') < 10)
|
||||
{
|
||||
$_POST['thmb_dim_h'] = 10;
|
||||
}
|
||||
|
||||
$thumbs_were = p('thmb_dim_w', 'int') . '*' . p('thmb_dim_h', 'int');
|
||||
update_config('thmb_dims', $thumbs_were);
|
||||
}
|
||||
elseif ($row['name'] == 'livexts')
|
||||
{
|
||||
$new['livexts'] = implode(',', array_map('trim', explode(',', p('livexts'))));
|
||||
}
|
||||
elseif ($row['name'] == 'prefixname')
|
||||
{
|
||||
$new['prefixname'] = preg_replace('/[^a-z0-9_\-\}\{\:\.]/', '', strtolower(p('prefixname')));
|
||||
}
|
||||
elseif ($row['name'] == 'siteurl')
|
||||
{
|
||||
if (p('siteurl')[strlen(p('siteurl'))-1] != '/')
|
||||
{
|
||||
$new['siteurl'] .= '/';
|
||||
}
|
||||
}
|
||||
elseif ($row['name'] == 'mod_writer')
|
||||
{
|
||||
if ($new['mod_writer'] == 1)
|
||||
{
|
||||
if (! file_exists(PATH . '.htaccess') && file_exists(PATH . 'htaccess.txt') && function_exists('rename'))
|
||||
{
|
||||
rename(PATH . 'htaccess.txt', PATH . '.htaccess');
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($row['name'] == 'language')
|
||||
{
|
||||
$got_lang = preg_replace('[^a-zA-Z0-9]', '', $new[$row['name']]);
|
||||
|
||||
|
||||
//all groups
|
||||
foreach ($d_groups as $group_id => $group_info)
|
||||
{
|
||||
update_config('language', $got_lang, true, $group_id);
|
||||
}
|
||||
|
||||
delete_cache('data_lang' . $got_lang);
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('after_submit_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}config",
|
||||
'SET' => "value='" . $SQL->escape($new[$row['name']]) . "'",
|
||||
'WHERE' => "name='" . $row['name'] . "'"
|
||||
];
|
||||
|
||||
if ($current_smt != 'all')
|
||||
{
|
||||
$query['WHERE'] .= " AND type = '" . $SQL->escape($current_smt) . "'";
|
||||
}
|
||||
|
||||
$SQL->build($update_query);
|
||||
}
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
$types = array();
|
||||
$types = [];
|
||||
|
||||
foreach($optionss as $key => $option)
|
||||
foreach ($optionss as $key => $option)
|
||||
{
|
||||
if(empty($types[$option['type']]))
|
||||
{
|
||||
$types[$option['type']] = '<ol class="breadcrumb">' .
|
||||
'<li class="breadcrumb-item"><a href="#">'. $lang['R_CONFIGS'] .'</a></li>' .
|
||||
'<li class="breadcrumb-item active">'. $go_menu[$option['type']]['name'] .'</li>' .
|
||||
if (empty($types[$option['type']]))
|
||||
{
|
||||
$types[$option['type']] = '<ol class="breadcrumb">' .
|
||||
'<li class="breadcrumb-item"><a href="#">' . $lang['R_CONFIGS'] . '</a></li>' .
|
||||
'<li class="breadcrumb-item active">' . $go_menu[$option['type']]['name'] . '</li>' .
|
||||
'</ol>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($types as $typekey => $type)
|
||||
foreach ($types as $typekey => $type)
|
||||
{
|
||||
$options .= $type;
|
||||
|
||||
$options .= $type;
|
||||
foreach($optionss as $key => $option)
|
||||
{
|
||||
if($option['type'] == $typekey)
|
||||
{
|
||||
$options .= str_replace(
|
||||
array('<input ', '<select ', '<td>', '</td>', '<label>', '<tr>', '</tr>'),
|
||||
array('<input class="form-control" ', '<select class="form-control" ', '<div class="form-group">', '</div>', '<label class="form-check-label">', '', ''),
|
||||
foreach ($optionss as $key => $option)
|
||||
{
|
||||
if ($option['type'] == $typekey)
|
||||
{
|
||||
$options .= str_replace(
|
||||
['<input ', '<select ', '<td>', '</td>', '<label>', '<tr>', '</tr>'],
|
||||
['<input class="form-control" ', '<select class="form-control" ', '<div class="form-group">', '</div>', '<label class="form-check-label">', '', ''],
|
||||
$option['option']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//after submit
|
||||
if (ip('submit'))
|
||||
{
|
||||
|
||||
#some configs need refresh page ..
|
||||
$need_refresh_configs = array('language');
|
||||
|
||||
|
||||
|
||||
//some configs need refresh page ..
|
||||
$need_refresh_configs = ['language'];
|
||||
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('after_submit_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
//empty ..
|
||||
/*
|
||||
if (empty(p('sitename')) || empty(p('siteurl')) || empty(p('foldername')) || empty(p('filesnum')))
|
||||
{
|
||||
$text = $lang['EMPTY_FIELDS'];
|
||||
$stylee = "admin_err";
|
||||
}
|
||||
elseif (!is_numeric(p('filesnum')) || !is_numeric(p('sec_down')))
|
||||
{
|
||||
$text = $lang['NUMFIELD_S'];
|
||||
$stylee = "admin_err";
|
||||
}
|
||||
else
|
||||
{
|
||||
*/
|
||||
//empty ..
|
||||
/*
|
||||
if (empty(p('sitename')) || empty(p('siteurl')) || empty(p('foldername')) || empty(p('filesnum')))
|
||||
{
|
||||
$text = $lang['EMPTY_FIELDS'];
|
||||
$stylee = "admin_err";
|
||||
}
|
||||
elseif (!is_numeric(p('filesnum')) || !is_numeric(p('sec_down')))
|
||||
{
|
||||
$text = $lang['NUMFIELD_S'];
|
||||
$stylee = "admin_err";
|
||||
}
|
||||
else
|
||||
{
|
||||
*/
|
||||
|
||||
#delete cache ..
|
||||
delete_cache('data_config');
|
||||
|
||||
|
||||
foreach($need_refresh_configs as $l)
|
||||
{
|
||||
if(ip($l) && p($l) != $config[$l])
|
||||
{
|
||||
header('Location: ' . basename(ADMIN_PATH));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
//delete cache ..
|
||||
delete_cache('data_config');
|
||||
|
||||
kleeja_admin_info($lang['CONFIGS_UPDATED'], true, '', true, $action, 3);
|
||||
//}
|
||||
}#submit
|
||||
|
||||
foreach ($need_refresh_configs as $l)
|
||||
{
|
||||
if (ip($l) && p($l) != $config[$l])
|
||||
{
|
||||
header('Location: ' . basename(ADMIN_PATH));
|
||||
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
kleeja_admin_info($lang['CONFIGS_UPDATED'], true, '', true, $action, 3);
|
||||
//}
|
||||
}//submit
|
||||
|
||||
@@ -9,22 +9,23 @@
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
//check _GET Csrf token
|
||||
if(!kleeja_check_form_key_get('GLOBAL_FORM_KEY'))
|
||||
if (! kleeja_check_form_key_get('GLOBAL_FORM_KEY'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH), 2);
|
||||
kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH), 2);
|
||||
}
|
||||
|
||||
|
||||
//remove just the administator session
|
||||
if ($usrcp->logout_cp())
|
||||
{
|
||||
redirect($config['siteurl']);
|
||||
$SQL->close();
|
||||
exit;
|
||||
redirect($config['siteurl']);
|
||||
$SQL->close();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -9,30 +9,30 @@
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
#number of images per page
|
||||
//number of images per page
|
||||
$files_acp_perpage = defined('ACP_FILES_PER_PAGE') ? ACP_FILES_PER_PAGE : 20;
|
||||
|
||||
|
||||
#display
|
||||
$stylee = "admin_files";
|
||||
//display
|
||||
$stylee = 'admin_files';
|
||||
|
||||
$url_or = isset($_REQUEST['order_by']) ? '&order_by=' . htmlspecialchars($_REQUEST['order_by']) . (isset($_REQUEST['order_way']) ? '&order_by=1' : '') : '';
|
||||
$url_or2 = isset($_REQUEST['order_by']) ? '&order_by=' . htmlspecialchars($_REQUEST['order_by']) : '';
|
||||
$url_lst = isset($_REQUEST['last_visit']) ? '&last_visit=' . htmlspecialchars($_REQUEST['last_visit']) : '';
|
||||
$url_sea = ig('search_id') ? '&search_id=' . g('search_id') : '';
|
||||
$url_pg = ig('page') ? '&page=' . g('page', 'int') : '';
|
||||
$page_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_or . $url_sea . $url_lst;
|
||||
$ord_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_pg . $url_sea . $url_lst;
|
||||
$url_or = isset($_REQUEST['order_by']) ? '&order_by=' . htmlspecialchars($_REQUEST['order_by']) . (isset($_REQUEST['order_way']) ? '&order_by=1' : '') : '';
|
||||
$url_or2 = isset($_REQUEST['order_by']) ? '&order_by=' . htmlspecialchars($_REQUEST['order_by']) : '';
|
||||
$url_lst = isset($_REQUEST['last_visit']) ? '&last_visit=' . htmlspecialchars($_REQUEST['last_visit']) : '';
|
||||
$url_sea = ig('search_id') ? '&search_id=' . g('search_id') : '';
|
||||
$url_pg = ig('page') ? '&page=' . g('page', 'int') : '';
|
||||
$page_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_or . $url_sea . $url_lst;
|
||||
$ord_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_pg . $url_sea . $url_lst;
|
||||
$page2_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_or2 . $url_sea . $url_lst;
|
||||
$action = $page_action . $url_pg;
|
||||
$is_search = $affected = false;
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_files');
|
||||
$action = $page_action . $url_pg;
|
||||
$is_search = $affected = false;
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_files');
|
||||
|
||||
//
|
||||
// Check form key
|
||||
@@ -40,360 +40,367 @@ $H_FORM_KEYS = kleeja_add_form_key('adm_files');
|
||||
|
||||
if (ip('submit'))
|
||||
{
|
||||
#wrong form
|
||||
if(!kleeja_check_form_key('adm_files'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
|
||||
$del = array();
|
||||
|
||||
#gather to-be-deleted file ids
|
||||
foreach ($_POST as $key => $value)
|
||||
//wrong form
|
||||
if (! kleeja_check_form_key('adm_files'))
|
||||
{
|
||||
if(preg_match('/del_(?P<digit>\d+)/', $key))
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
|
||||
$del = [];
|
||||
|
||||
//gather to-be-deleted file ids
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match('/del_(?P<digit>\d+)/', $key))
|
||||
{
|
||||
$del[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
#delete them once by once
|
||||
$ids = array();
|
||||
$files_num = $imgs_num = $sizes = 0;
|
||||
|
||||
//TODO use IN(...)
|
||||
foreach ($del as $key => $id)
|
||||
//delete them once by once
|
||||
$ids = [];
|
||||
$files_num = $imgs_num = $sizes = 0;
|
||||
|
||||
//TODO use IN(...)
|
||||
foreach ($del as $key => $id)
|
||||
{
|
||||
$query = array(
|
||||
'SELECT' => 'f.id, f.name, f.folder, f.size, f.type',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
'WHERE' => 'f.id = ' . intval($id),
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 'f.id, f.name, f.folder, f.size, f.type',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
'WHERE' => 'f.id = ' . intval($id),
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$result = $SQL->build($query);
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
//delete from folder ..
|
||||
@kleeja_unlink (PATH . $row['folder'] . '/' . $row['name']);
|
||||
//delete thumb
|
||||
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name'] ))
|
||||
{
|
||||
@kleeja_unlink (PATH . $row['folder'] . '/thumbs/' . $row['name'] );
|
||||
}
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
//delete from folder ..
|
||||
@kleeja_unlink (PATH . $row['folder'] . '/' . $row['name']);
|
||||
//delete thumb
|
||||
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name'] ))
|
||||
{
|
||||
@kleeja_unlink (PATH . $row['folder'] . '/thumbs/' . $row['name'] );
|
||||
}
|
||||
|
||||
$is_image = in_array(strtolower(trim($row['type'])), array('gif', 'jpg', 'jpeg', 'bmp', 'png')) ? true : false;
|
||||
$is_image = in_array(strtolower(trim($row['type'])), ['gif', 'jpg', 'jpeg', 'bmp', 'png']) ? true : false;
|
||||
|
||||
$ids[] = $row['id'];
|
||||
if($is_image)
|
||||
{
|
||||
$imgs_num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$files_num++;
|
||||
}
|
||||
$sizes += $row['size'];
|
||||
}
|
||||
}
|
||||
$ids[] = $row['id'];
|
||||
|
||||
if ($is_image)
|
||||
{
|
||||
$imgs_num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$files_num++;
|
||||
}
|
||||
$sizes += $row['size'];
|
||||
}
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('submit_files_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
$SQL->freeresult($result);
|
||||
|
||||
//no files to delete
|
||||
if(isset($ids) && sizeof($ids))
|
||||
{
|
||||
$query_del = array(
|
||||
'DELETE' => "{$dbprefix}files",
|
||||
'WHERE' => "`id` IN (" . implode(',', $ids) . ")"
|
||||
);
|
||||
|
||||
$SQL->build($query_del);
|
||||
|
||||
//update number of stats
|
||||
$update_query = array(
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "sizes=sizes-$sizes, files=files-$files_num, imgs=imgs-$imgs_num",
|
||||
);
|
||||
//no files to delete
|
||||
if (isset($ids) && sizeof($ids))
|
||||
{
|
||||
$query_del = [
|
||||
'DELETE' => "{$dbprefix}files",
|
||||
'WHERE' => '`id` IN (' . implode(',', $ids) . ')'
|
||||
];
|
||||
|
||||
$SQL->build($update_query);
|
||||
if($SQL->affected())
|
||||
{
|
||||
delete_cache('data_stats');
|
||||
$affected = true;
|
||||
}
|
||||
}
|
||||
|
||||
#show msg now
|
||||
$text = ($affected && (isset($ids) && sizeof($ids)) ? $lang['FILES_UPDATED'] : $lang['NO_UP_CHANGE_S']) .
|
||||
'<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . str_replace('&', '&', $action) . '\');", 2000);</script>' . "\n";
|
||||
$stylee = "admin_info";
|
||||
}
|
||||
else
|
||||
{
|
||||
$SQL->build($query_del);
|
||||
|
||||
//
|
||||
//Delete all user files [only one user]
|
||||
//
|
||||
if(ig('deletefiles'))
|
||||
{
|
||||
$query = array(
|
||||
'SELECT' => 'f.id, f.size, f.name, f.folder',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
);
|
||||
//update number of stats
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "sizes=sizes-$sizes, files=files-$files_num, imgs=imgs-$imgs_num",
|
||||
];
|
||||
|
||||
#get search filter
|
||||
$filter = get_filter(g('search_id'), 'file_search', false, 'filter_uid');
|
||||
|
||||
if(!$filter)
|
||||
{
|
||||
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
|
||||
}
|
||||
$SQL->build($update_query);
|
||||
|
||||
$query['WHERE'] = build_search_query(unserialize(htmlspecialchars_decode($filter['filter_value'])));
|
||||
|
||||
if($query['WHERE'] == '')
|
||||
{
|
||||
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
|
||||
}
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$sizes = false;
|
||||
$ids = array();
|
||||
$files_num = $imgs_num = 0;
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
//delete from folder ..
|
||||
@kleeja_unlink (PATH . $row['folder'] . "/" . $row['name']);
|
||||
|
||||
//delete thumb
|
||||
if (file_exists(PATH . $row['folder'] . "/thumbs/" . $row['name']))
|
||||
{
|
||||
@kleeja_unlink (PATH . $row['folder'] . "/thumbs/" . $row['name']);
|
||||
}
|
||||
|
||||
$is_image = in_array(strtolower(trim($row['type'])), array('gif', 'jpg', 'jpeg', 'bmp', 'png')) ? true : false;
|
||||
|
||||
$ids[] = $row['id'];
|
||||
if($is_image)
|
||||
{
|
||||
$imgs_num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$files_num++;
|
||||
}
|
||||
$sizes += $row['size'];
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
|
||||
if(($files_num + $imgs_num) == 0)
|
||||
{
|
||||
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
|
||||
}
|
||||
else
|
||||
{
|
||||
//update number of stats
|
||||
$update_query = array(
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "sizes=sizes-$sizes, files=files-$files_num, imgs=imgs-$imgs_num",
|
||||
);
|
||||
|
||||
$SQL->build($update_query);
|
||||
if($SQL->affected())
|
||||
{
|
||||
delete_cache('data_stats');
|
||||
}
|
||||
|
||||
//delete all files in just one query
|
||||
$query_del = array(
|
||||
'DELETE' => "{$dbprefix}files",
|
||||
'WHERE' => "`id` IN (" . implode(',', $ids) . ")"
|
||||
);
|
||||
|
||||
$SQL->build($query_del);
|
||||
|
||||
kleeja_admin_info(sprintf($lang['ADMIN_DELETE_FILES_OK'], ($files_num + $imgs_num)));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//begin default files page
|
||||
//
|
||||
|
||||
$query = array(
|
||||
'SELECT' => 'COUNT(f.id) AS total_files',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
'ORDER BY' => 'f.id '
|
||||
);
|
||||
|
||||
#if user system is default, we use users table
|
||||
if((int) $config['user_system'] == 1)
|
||||
{
|
||||
$query['JOINS'] = array(
|
||||
array(
|
||||
'LEFT JOIN' => "{$dbprefix}users u",
|
||||
'ON' => 'u.id=f.user'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$do_not_query_total_files = false;
|
||||
|
||||
//posts search ..
|
||||
if(ig('search_id'))
|
||||
{
|
||||
#get search filter
|
||||
$filter = get_filter(g('search_id'), 'file_search', false, 'filter_uid');
|
||||
$deletelink = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&deletefiles=' . g('search_id');
|
||||
$is_search = true;
|
||||
$query['WHERE'] = build_search_query(unserialize(htmlspecialchars_decode($filter['filter_value'])));
|
||||
}
|
||||
else if(isset($_REQUEST['last_visit']))
|
||||
{
|
||||
$query['WHERE'] = "f.time > " . intval($_REQUEST['last_visit']);
|
||||
}
|
||||
|
||||
#to-be-deleted
|
||||
#it is becoming a headache for a big websites. We do not have the time to figure out a solution
|
||||
|
||||
if(isset($_REQUEST['order_by']) && in_array($_REQUEST['order_by'], array('real_filename', 'size', 'user', 'user_ip', 'uploads', 'time', 'type', 'folder', 'report')))
|
||||
{
|
||||
$query['ORDER BY'] = "f." . $SQL->escape($_REQUEST['order_by']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$do_not_query_total_files = true;
|
||||
}
|
||||
|
||||
if(!ig('search_id'))
|
||||
{
|
||||
//display files or display pics and files only in search
|
||||
$img_types = array('gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG');
|
||||
$query['WHERE'] = $query['WHERE'] . (empty($query['WHERE']) ? '' : ' AND ') . "f.type NOT IN ('" . implode("', '", $img_types) . "')";
|
||||
}
|
||||
else
|
||||
{
|
||||
$do_not_query_total_files = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$query['ORDER BY'] .= (isset($_REQUEST['order_way']) && (int) $_REQUEST['order_way'] == 1) ? ' ASC' : ' DESC';
|
||||
|
||||
$nums_rows = 0;
|
||||
if($do_not_query_total_files)
|
||||
{
|
||||
$nums_rows = get_actual_stats('files');
|
||||
}
|
||||
else
|
||||
{
|
||||
$result_p = $SQL->build($query);
|
||||
$n_fetch = $SQL->fetch_array($result_p);
|
||||
$nums_rows = $n_fetch['total_files'];
|
||||
$SQL->freeresult($result_p);
|
||||
}
|
||||
|
||||
|
||||
//pager
|
||||
$currentPage= ig('page') ? g('page', 'int') : 1;
|
||||
$Pager = new Pagination($files_acp_perpage, $nums_rows, $currentPage);
|
||||
$start = $Pager->getStartRow();
|
||||
|
||||
$no_results = false;
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('query_files_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
if ($nums_rows > 0)
|
||||
{
|
||||
$query['SELECT'] = 'f.*' . ((int) $config['user_system'] == 1 ? ', u.name AS username' : '');
|
||||
$query['LIMIT'] = "$start, $files_acp_perpage";
|
||||
$result = $SQL->build($query);
|
||||
$sizes = false;
|
||||
$num = 0;
|
||||
#if Kleeja integtared we dont want make alot of queries
|
||||
$ids_and_names = array();
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$userfile = $config['siteurl'] . ($config['mod_writer'] ? 'fileuser-' . $row['user'] . '.html' : 'ucp.php?go=fileuser&id=' . $row['user']);
|
||||
|
||||
|
||||
$file_info = array('::ID::' => $row['id'], '::NAME::' => $row['name'], '::DIR::' => $row['folder'], '::FNAME::' => $row['real_filename']);
|
||||
|
||||
$is_image = in_array(strtolower(trim($row['type'])), array('gif', 'jpg', 'jpeg', 'bmp', 'png')) ? true : false;
|
||||
|
||||
$url = kleeja_get_link($is_image ? 'image': 'file', $file_info);
|
||||
|
||||
|
||||
#for username in integrated user system
|
||||
if($row['user'] != '-1' and (int) $config['user_system'] != 1)
|
||||
{
|
||||
if(!in_array($row['user'], $ids_and_names))
|
||||
{
|
||||
$row['username'] = $usrcp->usernamebyid($row['user']);
|
||||
$ids_and_names[$row['user']] = $row['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$row['username'] = $ids_and_names[$row['user']];
|
||||
}
|
||||
}
|
||||
|
||||
$file_name = $row['real_filename'] == '' ? $row['name'] : $row['real_filename'];
|
||||
|
||||
//make new lovely arrays !!
|
||||
$arr[] = array(
|
||||
'id' => $row['id'],
|
||||
'name' => "<a title=\"" . $file_name . "\" href=\"" .$url . "\" target=\"blank\">" .
|
||||
shorten_text($file_name, 25) . "</a>",
|
||||
'fullname' => $file_name,
|
||||
'size' => readable_size($row['size']),
|
||||
'ups' => $row['uploads'],
|
||||
'direct' => $row['id_form'] == 'direct' ? true : false,
|
||||
'time_human'=> kleeja_date($row['time']),
|
||||
'time' => kleeja_date($row['time'], false),
|
||||
'type' => $row['type'],
|
||||
'typeicon' => file_exists(PATH . "images/filetypes/". $row['type'] . ".png") ? PATH . "images/filetypes/" . $row['type'] . ".png" : PATH. 'images/filetypes/file.png',
|
||||
'folder' => $row['folder'],
|
||||
'report' => $row['report'] > 4 ? "<span style=\"color:red;font-weight:bold\">" . $row['report'] . "</span>":$row['report'],
|
||||
'user' => $row['user'] == '-1' ? $lang['GUST'] : '<a href="' . $userfile . '" target="_blank">' . $row['username'] . '</a>',
|
||||
'ip' => '<a href="http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext=' . $row['user_ip'] . '&do_search=Search" target="_new">' . $row['user_ip'] . '</a>',
|
||||
'showfilesbyip' => basename(ADMIN_PATH) . '?cp=h_search&s_input=1&s_value=' . $row['user_ip']
|
||||
);
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('arr_files_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$del[$row['id']] = p('del_' . $row['id']);
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
//no result ..
|
||||
$no_results = true;
|
||||
}
|
||||
|
||||
|
||||
#update f_lastvisit
|
||||
if(!$is_search)
|
||||
{
|
||||
if (filter_exists('f_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id'])) {
|
||||
update_filter('f_lastvisit', time(), 'lastvisit', false, $userinfo['id']);
|
||||
} else {
|
||||
insert_filter('f_lastvisit', time(), 'lastvisit', time(), $userinfo['id']);
|
||||
if ($SQL->affected())
|
||||
{
|
||||
delete_cache('data_stats');
|
||||
$affected = true;
|
||||
}
|
||||
}
|
||||
|
||||
//show msg now
|
||||
$text = ($affected && (isset($ids) && sizeof($ids)) ? $lang['FILES_UPDATED'] : $lang['NO_UP_CHANGE_S']) .
|
||||
'<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . str_replace('&', '&', $action) . '\');", 2000);</script>' . "\n";
|
||||
$stylee = 'admin_info';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//
|
||||
//Delete all user files [only one user]
|
||||
//
|
||||
if (ig('deletefiles'))
|
||||
{
|
||||
$query = [
|
||||
'SELECT' => 'f.id, f.size, f.name, f.folder',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
];
|
||||
|
||||
//get search filter
|
||||
$filter = get_filter(g('search_id'), 'file_search', false, 'filter_uid');
|
||||
|
||||
if (! $filter)
|
||||
{
|
||||
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
|
||||
}
|
||||
|
||||
$query['WHERE'] = build_search_query(unserialize(htmlspecialchars_decode($filter['filter_value'])));
|
||||
|
||||
if ($query['WHERE'] == '')
|
||||
{
|
||||
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
|
||||
}
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$sizes = false;
|
||||
$ids = [];
|
||||
$files_num = $imgs_num = 0;
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
//delete from folder ..
|
||||
@kleeja_unlink (PATH . $row['folder'] . '/' . $row['name']);
|
||||
|
||||
//delete thumb
|
||||
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name']))
|
||||
{
|
||||
@kleeja_unlink (PATH . $row['folder'] . '/thumbs/' . $row['name']);
|
||||
}
|
||||
|
||||
$is_image = in_array(strtolower(trim($row['type'])), ['gif', 'jpg', 'jpeg', 'bmp', 'png']) ? true : false;
|
||||
|
||||
$ids[] = $row['id'];
|
||||
|
||||
if ($is_image)
|
||||
{
|
||||
$imgs_num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$files_num++;
|
||||
}
|
||||
$sizes += $row['size'];
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
|
||||
if (($files_num + $imgs_num) == 0)
|
||||
{
|
||||
kleeja_admin_err($lang['ADMIN_DELETE_FILES_NOF']);
|
||||
}
|
||||
else
|
||||
{
|
||||
//update number of stats
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "sizes=sizes-$sizes, files=files-$files_num, imgs=imgs-$imgs_num",
|
||||
];
|
||||
|
||||
$SQL->build($update_query);
|
||||
|
||||
if ($SQL->affected())
|
||||
{
|
||||
delete_cache('data_stats');
|
||||
}
|
||||
|
||||
//delete all files in just one query
|
||||
$query_del = [
|
||||
'DELETE' => "{$dbprefix}files",
|
||||
'WHERE' => '`id` IN (' . implode(',', $ids) . ')'
|
||||
];
|
||||
|
||||
$SQL->build($query_del);
|
||||
|
||||
kleeja_admin_info(sprintf($lang['ADMIN_DELETE_FILES_OK'], ($files_num + $imgs_num)));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//begin default files page
|
||||
//
|
||||
|
||||
$query = [
|
||||
'SELECT' => 'COUNT(f.id) AS total_files',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
'ORDER BY' => 'f.id '
|
||||
];
|
||||
|
||||
//if user system is default, we use users table
|
||||
if ((int) $config['user_system'] == 1)
|
||||
{
|
||||
$query['JOINS'] = [
|
||||
[
|
||||
'LEFT JOIN' => "{$dbprefix}users u",
|
||||
'ON' => 'u.id=f.user'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$do_not_query_total_files = false;
|
||||
|
||||
//posts search ..
|
||||
if (ig('search_id'))
|
||||
{
|
||||
//get search filter
|
||||
$filter = get_filter(g('search_id'), 'file_search', false, 'filter_uid');
|
||||
$deletelink = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&deletefiles=' . g('search_id');
|
||||
$is_search = true;
|
||||
$query['WHERE'] = build_search_query(unserialize(htmlspecialchars_decode($filter['filter_value'])));
|
||||
}
|
||||
elseif (isset($_REQUEST['last_visit']))
|
||||
{
|
||||
$query['WHERE'] = 'f.time > ' . intval($_REQUEST['last_visit']);
|
||||
}
|
||||
|
||||
//to-be-deleted
|
||||
//it is becoming a headache for a big websites. We do not have the time to figure out a solution
|
||||
|
||||
if (isset($_REQUEST['order_by']) && in_array($_REQUEST['order_by'], ['real_filename', 'size', 'user', 'user_ip', 'uploads', 'time', 'type', 'folder', 'report']))
|
||||
{
|
||||
$query['ORDER BY'] = 'f.' . $SQL->escape($_REQUEST['order_by']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$do_not_query_total_files = true;
|
||||
}
|
||||
|
||||
if (! ig('search_id'))
|
||||
{
|
||||
//display files or display pics and files only in search
|
||||
$img_types = ['gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG'];
|
||||
$query['WHERE'] = $query['WHERE'] . (empty($query['WHERE']) ? '' : ' AND ') . "f.type NOT IN ('" . implode("', '", $img_types) . "')";
|
||||
}
|
||||
else
|
||||
{
|
||||
$do_not_query_total_files = false;
|
||||
}
|
||||
|
||||
|
||||
//some vars
|
||||
$total_pages = $Pager->getTotalPages();
|
||||
$page_nums = $Pager->print_nums($page_action);
|
||||
|
||||
$query['ORDER BY'] .= (isset($_REQUEST['order_way']) && (int) $_REQUEST['order_way'] == 1) ? ' ASC' : ' DESC';
|
||||
|
||||
$nums_rows = 0;
|
||||
|
||||
if ($do_not_query_total_files)
|
||||
{
|
||||
$nums_rows = get_actual_stats('files');
|
||||
}
|
||||
else
|
||||
{
|
||||
$result_p = $SQL->build($query);
|
||||
$n_fetch = $SQL->fetch_array($result_p);
|
||||
$nums_rows = $n_fetch['total_files'];
|
||||
$SQL->freeresult($result_p);
|
||||
}
|
||||
|
||||
|
||||
//pager
|
||||
$currentPage= ig('page') ? g('page', 'int') : 1;
|
||||
$Pager = new Pagination($files_acp_perpage, $nums_rows, $currentPage);
|
||||
$start = $Pager->getStartRow();
|
||||
|
||||
$no_results = false;
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('query_files_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
if ($nums_rows > 0)
|
||||
{
|
||||
$query['SELECT'] = 'f.*' . ((int) $config['user_system'] == 1 ? ', u.name AS username' : '');
|
||||
$query['LIMIT'] = "$start, $files_acp_perpage";
|
||||
$result = $SQL->build($query);
|
||||
$sizes = false;
|
||||
$num = 0;
|
||||
//if Kleeja integtared we dont want make alot of queries
|
||||
$ids_and_names = [];
|
||||
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$userfile = $config['siteurl'] . ($config['mod_writer'] ? 'fileuser-' . $row['user'] . '.html' : 'ucp.php?go=fileuser&id=' . $row['user']);
|
||||
|
||||
|
||||
$file_info = ['::ID::' => $row['id'], '::NAME::' => $row['name'], '::DIR::' => $row['folder'], '::FNAME::' => $row['real_filename']];
|
||||
|
||||
$is_image = in_array(strtolower(trim($row['type'])), ['gif', 'jpg', 'jpeg', 'bmp', 'png']) ? true : false;
|
||||
|
||||
$url = kleeja_get_link($is_image ? 'image': 'file', $file_info);
|
||||
|
||||
|
||||
//for username in integrated user system
|
||||
if ($row['user'] != '-1' and (int) $config['user_system'] != 1)
|
||||
{
|
||||
if (! in_array($row['user'], $ids_and_names))
|
||||
{
|
||||
$row['username'] = $usrcp->usernamebyid($row['user']);
|
||||
$ids_and_names[$row['user']] = $row['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$row['username'] = $ids_and_names[$row['user']];
|
||||
}
|
||||
}
|
||||
|
||||
$file_name = $row['real_filename'] == '' ? $row['name'] : $row['real_filename'];
|
||||
|
||||
//make new lovely arrays !!
|
||||
$arr[] = [
|
||||
'id' => $row['id'],
|
||||
'name' => '<a title="' . $file_name . '" href="' . $url . '" target="blank">' .
|
||||
shorten_text($file_name, 25) . '</a>',
|
||||
'fullname' => $file_name,
|
||||
'size' => readable_size($row['size']),
|
||||
'ups' => $row['uploads'],
|
||||
'direct' => $row['id_form'] == 'direct' ? true : false,
|
||||
'time_human' => kleeja_date($row['time']),
|
||||
'time' => kleeja_date($row['time'], false),
|
||||
'type' => $row['type'],
|
||||
'typeicon' => file_exists(PATH . 'images/filetypes/' . $row['type'] . '.png') ? PATH . 'images/filetypes/' . $row['type'] . '.png' : PATH . 'images/filetypes/file.png',
|
||||
'folder' => $row['folder'],
|
||||
'report' => $row['report'] > 4 ? '<span style="color:red;font-weight:bold">' . $row['report'] . '</span>':$row['report'],
|
||||
'user' => $row['user'] == '-1' ? $lang['GUST'] : '<a href="' . $userfile . '" target="_blank">' . $row['username'] . '</a>',
|
||||
'ip' => '<a href="http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext=' . $row['user_ip'] . '&do_search=Search" target="_new">' . $row['user_ip'] . '</a>',
|
||||
'showfilesbyip' => basename(ADMIN_PATH) . '?cp=h_search&s_input=1&s_value=' . $row['user_ip']
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('arr_files_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$del[$row['id']] = p('del_' . $row['id']);
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
//no result ..
|
||||
$no_results = true;
|
||||
}
|
||||
|
||||
|
||||
//update f_lastvisit
|
||||
if (! $is_search)
|
||||
{
|
||||
if (filter_exists('f_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id']))
|
||||
{
|
||||
update_filter('f_lastvisit', time(), 'lastvisit', false, $userinfo['id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
insert_filter('f_lastvisit', time(), 'lastvisit', time(), $userinfo['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//some vars
|
||||
$total_pages = $Pager->getTotalPages();
|
||||
$page_nums = $Pager->print_nums($page_action);
|
||||
$current_page = $Pager->getCurrentPage();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,41 +8,41 @@
|
||||
*/
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
#number of images per page
|
||||
//number of images per page
|
||||
$images_acp_perpage = defined('ACP_IMAGES_PER_PAGE') ? ACP_IMAGES_PER_PAGE : 20;
|
||||
|
||||
|
||||
#display
|
||||
$stylee = "admin_img";
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . (ig('page') ? '&page=' . g('page', 'int') : '') .
|
||||
(ig('last_visit') ? '&last_visit='.g('last_visit', 'int') : '') .
|
||||
//display
|
||||
$stylee = 'admin_img';
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . (ig('page') ? '&page=' . g('page', 'int') : '') .
|
||||
(ig('last_visit') ? '&last_visit=' . g('last_visit', 'int') : '') .
|
||||
(ig('smt') ? '&smt=' . g('smt') : '');
|
||||
$action_search = basename(ADMIN_PATH) . "?cp=h_search";
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_img_ctrl');
|
||||
$is_search = false;
|
||||
$action_search = basename(ADMIN_PATH) . '?cp=h_search';
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_img_ctrl');
|
||||
$is_search = false;
|
||||
|
||||
//
|
||||
// Check form key
|
||||
//
|
||||
if (ip('submit'))
|
||||
{
|
||||
if(!kleeja_check_form_key('adm_img_ctrl'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
if (! kleeja_check_form_key('adm_img_ctrl'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
|
||||
$del = array();
|
||||
$del = [];
|
||||
$num = $sizes = 0;
|
||||
|
||||
|
||||
foreach ($_POST as $key => $value)
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
if(preg_match('/del_(?P<digit>\d+)/', $key))
|
||||
if (preg_match('/del_(?P<digit>\d+)/', $key))
|
||||
{
|
||||
$del[$key] = $value;
|
||||
}
|
||||
@@ -51,218 +51,218 @@ if (ip('submit'))
|
||||
//TODO better way
|
||||
foreach ($del as $key => $id)
|
||||
{
|
||||
$query = array(
|
||||
'SELECT' => '*',
|
||||
'FROM' => "{$dbprefix}files",
|
||||
'WHERE' => '`id` = ' . intval($id),
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => '*',
|
||||
'FROM' => "{$dbprefix}files",
|
||||
'WHERE' => '`id` = ' . intval($id),
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$result = $SQL->build($query);
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
//delete from folder ..
|
||||
@kleeja_unlink(PATH . $row['folder'] . '/' . $row['name']);
|
||||
//delete thumb
|
||||
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name'] ))
|
||||
{
|
||||
@kleeja_unlink(PATH . $row['folder'] . '/thumbs/' . $row['name'] );
|
||||
}
|
||||
$ids[] = $row['id'];
|
||||
$num++;
|
||||
$sizes += $row['size'];
|
||||
}
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
//delete from folder ..
|
||||
@kleeja_unlink(PATH . $row['folder'] . '/' . $row['name']);
|
||||
//delete thumb
|
||||
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name'] ))
|
||||
{
|
||||
@kleeja_unlink(PATH . $row['folder'] . '/thumbs/' . $row['name'] );
|
||||
}
|
||||
$ids[] = $row['id'];
|
||||
$num++;
|
||||
$sizes += $row['size'];
|
||||
}
|
||||
|
||||
$SQL->free($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('submit_imgctrl_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
//no files to delete
|
||||
if(isset($ids) && sizeof($ids))
|
||||
{
|
||||
$query_del = array(
|
||||
'DELETE' => "{$dbprefix}files",
|
||||
'WHERE' => "`id` IN (" . implode(',', $ids) . ")"
|
||||
);
|
||||
|
||||
$SQL->build($query_del);
|
||||
if (isset($ids) && sizeof($ids))
|
||||
{
|
||||
$query_del = [
|
||||
'DELETE' => "{$dbprefix}files",
|
||||
'WHERE' => '`id` IN (' . implode(',', $ids) . ')'
|
||||
];
|
||||
|
||||
//update number of stats
|
||||
$update_query = array(
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "sizes=sizes-$sizes, imgs=imgs-$num",
|
||||
);
|
||||
$SQL->build($query_del);
|
||||
|
||||
//update number of stats
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "sizes=sizes-$sizes, imgs=imgs-$num",
|
||||
];
|
||||
|
||||
$SQL->build($update_query);
|
||||
|
||||
if ($SQL->affected())
|
||||
{
|
||||
delete_cache('data_stats');
|
||||
$affected = true;
|
||||
}
|
||||
}
|
||||
|
||||
$SQL->build($update_query);
|
||||
if($SQL->affected())
|
||||
{
|
||||
delete_cache('data_stats');
|
||||
$affected = true;
|
||||
}
|
||||
}
|
||||
|
||||
//after submit
|
||||
$text = ($affected ? $lang['FILES_UPDATED'] : $lang['NO_UP_CHANGE_S']) .
|
||||
'<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') .
|
||||
'&page=' . (ig('page') ? g('page', 'int') : '1') . '\');", 2000);</script>' . "\n";
|
||||
$text = ($affected ? $lang['FILES_UPDATED'] : $lang['NO_UP_CHANGE_S']) .
|
||||
'<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') .
|
||||
'&page=' . (ig('page') ? g('page', 'int') : '1') . '\');", 2000);</script>' . "\n";
|
||||
|
||||
$stylee = "admin_info";
|
||||
$stylee = 'admin_info';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = [
|
||||
'SELECT' => 'COUNT(f.id) AS total_files',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
'ORDER BY' => 'f.id DESC'
|
||||
];
|
||||
|
||||
$query = array(
|
||||
'SELECT' => 'COUNT(f.id) AS total_files',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
'ORDER BY' => 'f.id DESC'
|
||||
);
|
||||
|
||||
#if user system is default, we use users table
|
||||
if((int) $config['user_system'] == 1)
|
||||
{
|
||||
$query['JOINS'] = array(
|
||||
array(
|
||||
'LEFT JOIN' => "{$dbprefix}users u",
|
||||
'ON' => 'u.id=f.user'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$img_types = array('gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG');
|
||||
|
||||
#
|
||||
# There is a bug with IN statement in MySQL and they said it will solved at 6.0 version
|
||||
# forums.mysql.com/read.php?10,243691,243888#msg-243888
|
||||
# $query['WHERE'] = "f.type IN ('" . implode("', '", $img_types) . "')";
|
||||
#
|
||||
|
||||
$query['WHERE'] = "(f.type = '" . implode("' OR f.type = '", $img_types) . "')";
|
||||
|
||||
|
||||
$do_not_query_total_files = false;
|
||||
|
||||
if(ig('last_visit'))
|
||||
{
|
||||
$query['WHERE'] .= " AND f.time > " . g('last_visit', 'int');
|
||||
}
|
||||
else
|
||||
{
|
||||
$do_not_query_total_files = true;
|
||||
}
|
||||
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('query_imgctrl_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
$nums_rows = 0;
|
||||
if($do_not_query_total_files)
|
||||
{
|
||||
$nums_rows = get_actual_stats('imgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
$result_p = $SQL->build($query);
|
||||
$n_fetch = $SQL->fetch_array($result_p);
|
||||
$nums_rows = $n_fetch['total_files'];
|
||||
$SQL->freeresult($result_p);
|
||||
}
|
||||
|
||||
//pager
|
||||
$currentPage= ig('page') ? g('page', 'int') : 1;
|
||||
$Pager = new Pagination($images_acp_perpage, $nums_rows, $currentPage);
|
||||
$start = $Pager->getStartRow();
|
||||
|
||||
|
||||
$no_results = $affected = $sizes = false;
|
||||
if ($nums_rows > 0)
|
||||
{
|
||||
|
||||
$query['SELECT'] = 'f.*' . ((int) $config['user_system'] == 1 ? ', u.name AS username' : '');
|
||||
$query['LIMIT'] = "$start, $images_acp_perpage";
|
||||
$result = $SQL->build($query);
|
||||
|
||||
$tdnum = $num = 0;
|
||||
#if Kleeja integrated we dont want make alot of queries
|
||||
$ids_and_names = array();
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$file_info = array('::ID::' => $row['id'], '::NAME::' => $row['name'], '::DIR::' => $row['folder'], '::FNAME::' => $row['real_filename']);
|
||||
|
||||
$url = kleeja_get_link('image', $file_info);
|
||||
|
||||
$url_thumb = kleeja_get_link('thumb', $file_info);
|
||||
|
||||
|
||||
#for username in integrated user system
|
||||
if($row['user'] != '-1' and (int) $config['user_system'] != 1)
|
||||
{
|
||||
if(!in_array($row['user'], $ids_and_names))
|
||||
{
|
||||
$row['username'] = $usrcp->usernamebyid($row['user']);
|
||||
$ids_and_names[$row['user']] = $row['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$row['username'] = $ids_and_names[$row['user']];
|
||||
}
|
||||
}
|
||||
|
||||
$file_name = $row['real_filename'] == '' ? $row['name'] : $row['real_filename'];
|
||||
|
||||
|
||||
//make new lovely arrays !!
|
||||
$arr[] = array(
|
||||
'id' => $row['id'],
|
||||
'tdnum' => $tdnum == 0 ? '<ul>': '',
|
||||
'tdnum2' => $tdnum == 4 ? '</ul>' : '',
|
||||
'name' => shorten_text($file_name, 25),
|
||||
'ip' => htmlspecialchars($row['user_ip']),
|
||||
'href' => $url,
|
||||
'size' => readable_size($row['size']),
|
||||
'ups' => $row['uploads'],
|
||||
'time' => date('d-m-Y h:i a', $row['time']),
|
||||
'user' => (int) $row['user'] == -1 ? $lang['GUST'] : $row['username'],
|
||||
'is_user' => (int) $row['user'] == -1 ? 0 : 1,
|
||||
'thumb_link'=> $url_thumb
|
||||
);
|
||||
|
||||
//fix ...
|
||||
$tdnum = $tdnum == 4 ? 0 : $tdnum+1;
|
||||
|
||||
$del[$row['id']] = p('del_' . $row['id']);
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('arr_imgctrl_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
//if user system is default, we use users table
|
||||
if ((int) $config['user_system'] == 1)
|
||||
{
|
||||
$query['JOINS'] = [
|
||||
[
|
||||
'LEFT JOIN' => "{$dbprefix}users u",
|
||||
'ON' => 'u.id=f.user'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
|
||||
$img_types = ['gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG'];
|
||||
|
||||
//
|
||||
// There is a bug with IN statement in MySQL and they said it will solved at 6.0 version
|
||||
// forums.mysql.com/read.php?10,243691,243888#msg-243888
|
||||
// $query['WHERE'] = "f.type IN ('" . implode("', '", $img_types) . "')";
|
||||
//
|
||||
|
||||
$query['WHERE'] = "(f.type = '" . implode("' OR f.type = '", $img_types) . "')";
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_results = true;
|
||||
}
|
||||
$do_not_query_total_files = false;
|
||||
|
||||
#update f_lastvisit
|
||||
if(!$is_search)
|
||||
{
|
||||
if (filter_exists('i_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id'])) {
|
||||
update_filter('i_lastvisit', time(), 'lastvisit', false, $userinfo['id']);
|
||||
} else {
|
||||
insert_filter('i_lastvisit', time(), 'lastvisit', time(), $userinfo['id']);
|
||||
if (ig('last_visit'))
|
||||
{
|
||||
$query['WHERE'] .= ' AND f.time > ' . g('last_visit', 'int');
|
||||
}
|
||||
else
|
||||
{
|
||||
$do_not_query_total_files = true;
|
||||
}
|
||||
}
|
||||
|
||||
//pages
|
||||
$total_pages = $Pager->getTotalPages();
|
||||
$page_nums = $Pager->print_nums(basename(ADMIN_PATH). '?cp=' . basename(__file__, '.php') .
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('query_imgctrl_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
$nums_rows = 0;
|
||||
|
||||
if ($do_not_query_total_files)
|
||||
{
|
||||
$nums_rows = get_actual_stats('imgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
$result_p = $SQL->build($query);
|
||||
$n_fetch = $SQL->fetch_array($result_p);
|
||||
$nums_rows = $n_fetch['total_files'];
|
||||
$SQL->freeresult($result_p);
|
||||
}
|
||||
|
||||
//pager
|
||||
$currentPage= ig('page') ? g('page', 'int') : 1;
|
||||
$Pager = new Pagination($images_acp_perpage, $nums_rows, $currentPage);
|
||||
$start = $Pager->getStartRow();
|
||||
|
||||
|
||||
$no_results = $affected = $sizes = false;
|
||||
|
||||
if ($nums_rows > 0)
|
||||
{
|
||||
$query['SELECT'] = 'f.*' . ((int) $config['user_system'] == 1 ? ', u.name AS username' : '');
|
||||
$query['LIMIT'] = "$start, $images_acp_perpage";
|
||||
$result = $SQL->build($query);
|
||||
|
||||
$tdnum = $num = 0;
|
||||
//if Kleeja integrated we dont want make alot of queries
|
||||
$ids_and_names = [];
|
||||
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$file_info = ['::ID::' => $row['id'], '::NAME::' => $row['name'], '::DIR::' => $row['folder'], '::FNAME::' => $row['real_filename']];
|
||||
|
||||
$url = kleeja_get_link('image', $file_info);
|
||||
|
||||
$url_thumb = kleeja_get_link('thumb', $file_info);
|
||||
|
||||
|
||||
//for username in integrated user system
|
||||
if ($row['user'] != '-1' and (int) $config['user_system'] != 1)
|
||||
{
|
||||
if (! in_array($row['user'], $ids_and_names))
|
||||
{
|
||||
$row['username'] = $usrcp->usernamebyid($row['user']);
|
||||
$ids_and_names[$row['user']] = $row['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$row['username'] = $ids_and_names[$row['user']];
|
||||
}
|
||||
}
|
||||
|
||||
$file_name = $row['real_filename'] == '' ? $row['name'] : $row['real_filename'];
|
||||
|
||||
|
||||
//make new lovely arrays !!
|
||||
$arr[] = [
|
||||
'id' => $row['id'],
|
||||
'tdnum' => $tdnum == 0 ? '<ul>': '',
|
||||
'tdnum2' => $tdnum == 4 ? '</ul>' : '',
|
||||
'name' => shorten_text($file_name, 25),
|
||||
'ip' => htmlspecialchars($row['user_ip']),
|
||||
'href' => $url,
|
||||
'size' => readable_size($row['size']),
|
||||
'ups' => $row['uploads'],
|
||||
'time' => date('d-m-Y h:i a', $row['time']),
|
||||
'user' => (int) $row['user'] == -1 ? $lang['GUST'] : $row['username'],
|
||||
'is_user' => (int) $row['user'] == -1 ? 0 : 1,
|
||||
'thumb_link'=> $url_thumb
|
||||
];
|
||||
|
||||
//fix ...
|
||||
$tdnum = $tdnum == 4 ? 0 : $tdnum+1;
|
||||
|
||||
$del[$row['id']] = p('del_' . $row['id']);
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('arr_imgctrl_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_results = true;
|
||||
}
|
||||
|
||||
//update f_lastvisit
|
||||
if (! $is_search)
|
||||
{
|
||||
if (filter_exists('i_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id']))
|
||||
{
|
||||
update_filter('i_lastvisit', time(), 'lastvisit', false, $userinfo['id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
insert_filter('i_lastvisit', time(), 'lastvisit', time(), $userinfo['id']);
|
||||
}
|
||||
}
|
||||
|
||||
//pages
|
||||
$total_pages = $Pager->getTotalPages();
|
||||
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') .
|
||||
(ig('last_visit') ? '&last_vists=' . g('last_visit', 'int') : '') .
|
||||
(ig('smt') ? '&smt=' . g('smt') : '')
|
||||
, 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
|
||||
$current_page = $Pager->getCurrentPage();
|
||||
}
|
||||
(ig('smt') ? '&smt=' . g('smt') : ''), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
|
||||
$current_page = $Pager->getCurrentPage();
|
||||
}
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* @license ./docs/license.txt
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//for style ..
|
||||
$stylee = "admin_calls";
|
||||
$stylee = 'admin_calls';
|
||||
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&smt=' . $current_smt;
|
||||
$msg_sent = ig('sent') ? g('sent', 'int') : false;
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&smt=' . $current_smt;
|
||||
$msg_sent = ig('sent') ? g('sent', 'int') : false;
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_calls');
|
||||
$there_queue = preg_match('!:del_[a-z0-9]{0,3}calls:!i', $config['queue']);
|
||||
|
||||
@@ -27,147 +27,145 @@ $there_queue = preg_match('!:del_[a-z0-9]{0,3}calls:!i', $config['queue']);
|
||||
//
|
||||
if (ip('submit'))
|
||||
{
|
||||
if(!kleeja_check_form_key('adm_calls'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
if (! kleeja_check_form_key('adm_calls'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#add delete process to the queue
|
||||
if($current_smt == 'del_d30' || $current_smt == 'del_all')
|
||||
//add delete process to the queue
|
||||
if ($current_smt == 'del_d30' || $current_smt == 'del_all')
|
||||
{
|
||||
|
||||
if(strpos($config['queue'], ':' . $current_smt . 'calls:') !== false)
|
||||
{
|
||||
kleeja_admin_err($lang['DELETE_PROCESS_IN_WORK'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
update_config('queue', $config['queue'] . ':' . $current_smt . 'calls:');
|
||||
kleeja_admin_info($lang['DELETE_PROCESS_QUEUED'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
|
||||
}
|
||||
if (strpos($config['queue'], ':' . $current_smt . 'calls:') !== false)
|
||||
{
|
||||
kleeja_admin_err($lang['DELETE_PROCESS_IN_WORK'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
update_config('queue', $config['queue'] . ':' . $current_smt . 'calls:');
|
||||
kleeja_admin_info($lang['DELETE_PROCESS_QUEUED'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query = array(
|
||||
'SELECT' => 'c.*',
|
||||
'FROM' => "`{$dbprefix}call` c",
|
||||
'ORDER BY' => 'c.id DESC'
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 'c.*',
|
||||
'FROM' => "`{$dbprefix}call` c",
|
||||
'ORDER BY' => 'c.id DESC'
|
||||
];
|
||||
|
||||
|
||||
if($current_smt == 'show_h24')
|
||||
if ($current_smt == 'show_h24')
|
||||
{
|
||||
$query['WHERE'] = 'c.time > ' . intval(time() - 3600 * 24);
|
||||
$query['WHERE'] = 'c.time > ' . intval(time() - 3600 * 24);
|
||||
}
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
|
||||
//pagination
|
||||
$nums_rows = $SQL->num_rows($result);
|
||||
$nums_rows = $SQL->num_rows($result);
|
||||
$currentPage = ig('page') ? g('page', 'int') : 1;
|
||||
$Pager = new Pagination($perpage, $nums_rows, $currentPage);
|
||||
$start = $Pager->getStartRow();
|
||||
$Pager = new Pagination($perpage, $nums_rows, $currentPage);
|
||||
$start = $Pager->getStartRow();
|
||||
|
||||
|
||||
$no_results = false;
|
||||
$del_nums = array();
|
||||
$del_nums = [];
|
||||
|
||||
if ($nums_rows > 0)
|
||||
{
|
||||
$query['LIMIT'] = "$start,$perpage";
|
||||
$result = $SQL->build($query);
|
||||
$query['LIMIT'] = "$start,$perpage";
|
||||
$result = $SQL->build($query);
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
//make new lovely arrays !!
|
||||
$arr[] = array(
|
||||
'id' => $row['id'],
|
||||
'name' => $row['name'],
|
||||
'mail' => $row['mail'],
|
||||
'text' => htmlspecialchars($row['text']),
|
||||
'human_time'=> kleeja_date($row['time']),
|
||||
'time' => kleeja_date($row['time'], false),
|
||||
'ip' => $row['ip'],
|
||||
'sent' => $row['id'] == $msg_sent,
|
||||
'ip_finder' => 'http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext=' . $row['ip'] . '&do_search=Search'
|
||||
);
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
//make new lovely arrays !!
|
||||
$arr[] = [
|
||||
'id' => $row['id'],
|
||||
'name' => $row['name'],
|
||||
'mail' => $row['mail'],
|
||||
'text' => htmlspecialchars($row['text']),
|
||||
'human_time'=> kleeja_date($row['time']),
|
||||
'time' => kleeja_date($row['time'], false),
|
||||
'ip' => $row['ip'],
|
||||
'sent' => $row['id'] == $msg_sent,
|
||||
'ip_finder' => 'http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext=' . $row['ip'] . '&do_search=Search'
|
||||
];
|
||||
|
||||
$del[$row['id']] = p('del_' . $row['id']);
|
||||
$sen[$row['id']] = p('v_' . $row['id']);
|
||||
$del[$row['id']] = p('del_' . $row['id']);
|
||||
$sen[$row['id']] = p('v_' . $row['id']);
|
||||
|
||||
|
||||
//when submit !!
|
||||
if (ip('submit'))
|
||||
{
|
||||
if ($del[$row['id']])
|
||||
{
|
||||
$del_nums[] = $row['id'];
|
||||
}
|
||||
}
|
||||
//when submit !!
|
||||
if (ip('submit'))
|
||||
{
|
||||
if ($del[$row['id']])
|
||||
{
|
||||
$del_nums[] = $row['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (ip('reply_submit'))
|
||||
{
|
||||
if ($sen[$row['id']])
|
||||
{
|
||||
$to = $row['mail'];
|
||||
$subject = $lang['REPLY_CALL'] . ':' . $config['sitename'];
|
||||
$message = "\n " . $lang['REPLY_CALL'] . " " . $row['name'] . "\r\n " . $lang['REPLIED_ON_CAL'] . " : " . $config['sitename'] .
|
||||
"\r\n " . $lang['BY_EMAIL'] . ": " . $row['mail'] . "\r\n" . $lang['ADMIN_REPLIED'] . "\r\n" . $sen[$row['id']] . "\r\n\r\n Kleeja.com ";
|
||||
if (ip('reply_submit'))
|
||||
{
|
||||
if ($sen[$row['id']])
|
||||
{
|
||||
$to = $row['mail'];
|
||||
$subject = $lang['REPLY_CALL'] . ':' . $config['sitename'];
|
||||
$message = "\n " . $lang['REPLY_CALL'] . ' ' . $row['name'] . "\r\n " . $lang['REPLIED_ON_CAL'] . ' : ' . $config['sitename'] .
|
||||
"\r\n " . $lang['BY_EMAIL'] . ': ' . $row['mail'] . "\r\n" . $lang['ADMIN_REPLIED'] . "\r\n" . $sen[$row['id']] . "\r\n\r\n Kleeja.com ";
|
||||
|
||||
$send = send_mail($to, $message, $subject, $config['sitemail'], $config['sitename']);
|
||||
$send = send_mail($to, $message, $subject, $config['sitemail'], $config['sitename']);
|
||||
|
||||
if ($send)
|
||||
{
|
||||
//
|
||||
//We will redirect to pages of results and show info msg there !
|
||||
//
|
||||
kleeja_admin_info($lang['IS_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
kleeja_admin_err($lang['ERR_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$SQL->freeresult($result);
|
||||
if ($send)
|
||||
{
|
||||
//
|
||||
//We will redirect to pages of results and show info msg there !
|
||||
//
|
||||
kleeja_admin_info($lang['IS_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
kleeja_admin_err($lang['ERR_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$SQL->freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_results = true;
|
||||
$no_results = true;
|
||||
}
|
||||
|
||||
//if deleted
|
||||
if(sizeof($del_nums))
|
||||
if (sizeof($del_nums))
|
||||
{
|
||||
$query_del = array(
|
||||
'DELETE' => "`{$dbprefix}call`",
|
||||
'WHERE' => "id IN('" . implode("', '", $del_nums) . "')"
|
||||
);
|
||||
$query_del = [
|
||||
'DELETE' => "`{$dbprefix}call`",
|
||||
'WHERE' => "id IN('" . implode("', '", $del_nums) . "')"
|
||||
];
|
||||
|
||||
$SQL->build($query_del);
|
||||
$SQL->build($query_del);
|
||||
}
|
||||
|
||||
$total_pages = $Pager->getTotalPages();
|
||||
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
|
||||
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
|
||||
|
||||
//after submit
|
||||
if (ip('submit'))
|
||||
{
|
||||
$text = ($SQL->affected() ? $lang['CALLS_UPDATED'] : $lang['NO_UP_CHANGE_S']);
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . $action . '\'); check_msg_and_reports();", 2000);</script>' . "\n";
|
||||
kleeja_admin_info($text, true, '', true, $action);
|
||||
$text = ($SQL->affected() ? $lang['CALLS_UPDATED'] : $lang['NO_UP_CHANGE_S']);
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . $action . '\'); check_msg_and_reports();", 2000);</script>' . "\n";
|
||||
kleeja_admin_info($text, true, '', true, $action);
|
||||
}
|
||||
|
||||
|
||||
//secondary menu
|
||||
$go_menu = array(
|
||||
'general' => array('name'=>$lang['R_CALLS'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'),
|
||||
'show_h24' => array('name'=>$lang['SHOW_FROM_24H'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&smt=show_h24', 'goto'=>'show_h24', 'current'=> $current_smt == 'show_h24'),
|
||||
#CHECK IF IT'S ALREADY DONE ?
|
||||
'del_d30' => array('name'=>$lang['DELETE_EARLIER_30DAYS'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&smt=del_d30', 'goto'=>'del_d30', 'current'=> $current_smt == 'del_d30', 'confirm'=>true),
|
||||
'del_all' => array('name'=>$lang['DELETE_ALL'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&smt=del_all', 'goto'=>'del_all', 'current'=> $current_smt == 'del_all', 'confirm'=>true),
|
||||
);
|
||||
$go_menu = [
|
||||
'general' => ['name'=>$lang['R_CALLS'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'],
|
||||
'show_h24' => ['name'=>$lang['SHOW_FROM_24H'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&smt=show_h24', 'goto'=>'show_h24', 'current'=> $current_smt == 'show_h24'],
|
||||
//CHECK IF IT'S ALREADY DONE ?
|
||||
'del_d30' => ['name'=>$lang['DELETE_EARLIER_30DAYS'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&smt=del_d30', 'goto'=>'del_d30', 'current'=> $current_smt == 'del_d30', 'confirm'=>true],
|
||||
'del_all' => ['name'=>$lang['DELETE_ALL'], 'link'=> basename(ADMIN_PATH) . '?cp=e_calls&smt=del_all', 'goto'=>'del_all', 'current'=> $current_smt == 'del_all', 'confirm'=>true],
|
||||
];
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
* @license ./docs/license.txt
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
//for style ..
|
||||
$stylee = "admin_reports";
|
||||
$current_smt = preg_replace('/[^a-z0-9_]/i','', g('smt', 'str', 'general'));
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&smt=' . $current_smt;
|
||||
$msg_sent = ig('sent') ? g('sent', 'int') : false;
|
||||
$stylee = 'admin_reports';
|
||||
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&smt=' . $current_smt;
|
||||
$msg_sent = ig('sent') ? g('sent', 'int') : false;
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_reports');
|
||||
$there_queue = preg_match('!:del_[a-z0-9]{0,3}reports:!i', $config['queue']);
|
||||
|
||||
@@ -27,146 +27,144 @@ $there_queue = preg_match('!:del_[a-z0-9]{0,3}reports:!i', $config['queue']);
|
||||
//
|
||||
if (ip('submit'))
|
||||
{
|
||||
if(!kleeja_check_form_key('adm_reports'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
if (! kleeja_check_form_key('adm_reports'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#add delete process to the queue
|
||||
if($current_smt == 'del_d30' || $current_smt == 'del_all')
|
||||
//add delete process to the queue
|
||||
if ($current_smt == 'del_d30' || $current_smt == 'del_all')
|
||||
{
|
||||
|
||||
if(strpos($config['queue'], ':' . $current_smt . 'reports:') !== false)
|
||||
{
|
||||
kleeja_admin_err($lang['DELETE_PROCESS_IN_WORK'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
update_config('queue', $config['queue'] . ':' . $current_smt . 'reports:');
|
||||
kleeja_admin_info($lang['DELETE_PROCESS_QUEUED'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
|
||||
}
|
||||
if (strpos($config['queue'], ':' . $current_smt . 'reports:') !== false)
|
||||
{
|
||||
kleeja_admin_err($lang['DELETE_PROCESS_IN_WORK'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
update_config('queue', $config['queue'] . ':' . $current_smt . 'reports:');
|
||||
kleeja_admin_info($lang['DELETE_PROCESS_QUEUED'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
|
||||
}
|
||||
}
|
||||
|
||||
$query = array(
|
||||
'SELECT' => '*',
|
||||
'FROM' => "{$dbprefix}reports r",
|
||||
'ORDER BY' => 'r.id DESC'
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => '*',
|
||||
'FROM' => "{$dbprefix}reports r",
|
||||
'ORDER BY' => 'r.id DESC'
|
||||
];
|
||||
|
||||
if($current_smt == 'show_h24')
|
||||
if ($current_smt == 'show_h24')
|
||||
{
|
||||
$query['WHERE'] = 'r.time > ' . intval(time() - 3600 * 24);
|
||||
$query['WHERE'] = 'r.time > ' . intval(time() - 3600 * 24);
|
||||
}
|
||||
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
//pagination
|
||||
$nums_rows = $SQL->num_rows($result);
|
||||
$nums_rows = $SQL->num_rows($result);
|
||||
$currentPage = ig('page') ? g('page', 'int') : 1;
|
||||
$Pager = new Pagination($perpage, $nums_rows, $currentPage);
|
||||
$start = $Pager->getStartRow();
|
||||
$Pager = new Pagination($perpage, $nums_rows, $currentPage);
|
||||
$start = $Pager->getStartRow();
|
||||
|
||||
|
||||
$no_results = false;
|
||||
$del_nums = array();
|
||||
$del_nums = [];
|
||||
|
||||
if ($nums_rows > 0)
|
||||
{
|
||||
$query['LIMIT'] = "$start, $perpage";
|
||||
$result = $SQL->build($query);
|
||||
$query['LIMIT'] = "$start, $perpage";
|
||||
$result = $SQL->build($query);
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
//make new lovely arrays !!
|
||||
$arr[] = array(
|
||||
'id' => $row['id'],
|
||||
'name' => $row['name'],
|
||||
'mail' => $row['mail'],
|
||||
'url' => $row['url'],
|
||||
'text' => $row['text'],
|
||||
'human_time'=> kleeja_date($row['time']),
|
||||
'time' => kleeja_date($row['time'], false),
|
||||
'ip' => $row['ip'],
|
||||
'sent' => $row['id'] == $msg_sent,
|
||||
'ip_finder' => 'http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext=' . htmlspecialchars($row['ip']) . '&do_search=Search'
|
||||
);
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
//make new lovely arrays !!
|
||||
$arr[] = [
|
||||
'id' => $row['id'],
|
||||
'name' => $row['name'],
|
||||
'mail' => $row['mail'],
|
||||
'url' => $row['url'],
|
||||
'text' => $row['text'],
|
||||
'human_time'=> kleeja_date($row['time']),
|
||||
'time' => kleeja_date($row['time'], false),
|
||||
'ip' => $row['ip'],
|
||||
'sent' => $row['id'] == $msg_sent,
|
||||
'ip_finder' => 'http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext=' . htmlspecialchars($row['ip']) . '&do_search=Search'
|
||||
];
|
||||
|
||||
$del[$row['id']] = p('del_' . $row['id']);
|
||||
$sen[$row['id']] = p('v_' . $row['id']);
|
||||
$del[$row['id']] = p('del_' . $row['id']);
|
||||
$sen[$row['id']] = p('v_' . $row['id']);
|
||||
|
||||
//when submit !!
|
||||
if (ip('submit'))
|
||||
{
|
||||
if ($del[$row['id']])
|
||||
{
|
||||
$del_nums[] = $row['id'];
|
||||
}
|
||||
}
|
||||
//when submit !!
|
||||
if (ip('submit'))
|
||||
{
|
||||
if ($del[$row['id']])
|
||||
{
|
||||
$del_nums[] = $row['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (ip('reply_submit'))
|
||||
{
|
||||
if ($sen[$row['id']])
|
||||
{
|
||||
$to = $row['mail'];
|
||||
$subject = $lang['REPLY_REPORT'] . ':' . $config['sitename'];
|
||||
$message = "\n " . $lang['WELCOME'] . " " . $row['name'] . "\r\n " . $lang['U_REPORT_ON'] . " " . $config['sitename']. "\r\n " .
|
||||
$lang['BY_EMAIL'] . " : " . $row['mail']."\r\n" . $lang['ADMIN_REPLIED'] . ": \r\n" . $sen[$row['id']] . "\r\n\r\n kleeja.com";
|
||||
if (ip('reply_submit'))
|
||||
{
|
||||
if ($sen[$row['id']])
|
||||
{
|
||||
$to = $row['mail'];
|
||||
$subject = $lang['REPLY_REPORT'] . ':' . $config['sitename'];
|
||||
$message = "\n " . $lang['WELCOME'] . ' ' . $row['name'] . "\r\n " . $lang['U_REPORT_ON'] . ' ' . $config['sitename'] . "\r\n " .
|
||||
$lang['BY_EMAIL'] . ' : ' . $row['mail'] . "\r\n" . $lang['ADMIN_REPLIED'] . ": \r\n" . $sen[$row['id']] . "\r\n\r\n kleeja.com";
|
||||
|
||||
$send = send_mail($to, $message, $subject, $config['sitemail'], $config['sitename']);
|
||||
$send = send_mail($to, $message, $subject, $config['sitemail'], $config['sitename']);
|
||||
|
||||
if ($send)
|
||||
{
|
||||
//
|
||||
//We will redirect to pages of results and show info msg there !
|
||||
//
|
||||
kleeja_admin_info($lang['IS_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
kleeja_admin_err($lang['ERR_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$SQL->freeresult($result);
|
||||
if ($send)
|
||||
{
|
||||
//
|
||||
//We will redirect to pages of results and show info msg there !
|
||||
//
|
||||
kleeja_admin_info($lang['IS_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
kleeja_admin_err($lang['ERR_SEND_MAIL'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&page=' . (ig('page') ? g('page', 'int') : 1) . '&sent=' . $row['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$SQL->freeresult($result);
|
||||
}
|
||||
else #num rows
|
||||
{
|
||||
$no_results = true;
|
||||
else
|
||||
{ //num rows
|
||||
$no_results = true;
|
||||
}
|
||||
|
||||
|
||||
//if deleted
|
||||
if(sizeof($del_nums))
|
||||
if (sizeof($del_nums))
|
||||
{
|
||||
$query_del = array(
|
||||
'DELETE' => "{$dbprefix}reports",
|
||||
'WHERE' => "id IN('" . implode("', '", $del_nums) . "')"
|
||||
);
|
||||
$query_del = [
|
||||
'DELETE' => "{$dbprefix}reports",
|
||||
'WHERE' => "id IN('" . implode("', '", $del_nums) . "')"
|
||||
];
|
||||
|
||||
$SQL->build($query_del);
|
||||
$SQL->build($query_del);
|
||||
}
|
||||
|
||||
$total_pages = $Pager->getTotalPages();
|
||||
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
|
||||
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
|
||||
|
||||
//after submit
|
||||
if (ip('submit'))
|
||||
{
|
||||
$text = ($SQL->affected() ? $lang['REPORTS_UPDATED'] : $lang['NO_UP_CHANGE_S']);
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . $action . '\'); check_msg_and_reports();", 2000);</script>' . "\n";
|
||||
kleeja_admin_info($text, true, '', true, $action);
|
||||
$text = ($SQL->affected() ? $lang['REPORTS_UPDATED'] : $lang['NO_UP_CHANGE_S']);
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . $action . '\'); check_msg_and_reports();", 2000);</script>' . "\n";
|
||||
kleeja_admin_info($text, true, '', true, $action);
|
||||
}
|
||||
|
||||
|
||||
//secondary menu
|
||||
$go_menu = array(
|
||||
'general' => array('name'=>$lang['R_REPORTS'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'),
|
||||
'show_h24' => array('name'=>$lang['SHOW_FROM_24H'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&smt=show_h24', 'goto'=>'show_h24', 'current'=> $current_smt == 'show_h24'),
|
||||
#TODO : CHECK IF IT'S ALREADY DONE ?
|
||||
'del_d30' => array('name'=>$lang['DELETE_EARLIER_30DAYS'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&smt=del_d30', 'goto'=>'del_d30', 'current'=> $current_smt == 'del_d30', 'confirm'=>true),
|
||||
'del_all' => array('name'=>$lang['DELETE_ALL'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&smt=del_all', 'goto'=>'del_all', 'current'=> $current_smt == 'del_all', 'confirm'=>true),
|
||||
);
|
||||
$go_menu = [
|
||||
'general' => ['name'=>$lang['R_REPORTS'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'],
|
||||
'show_h24' => ['name'=>$lang['SHOW_FROM_24H'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&smt=show_h24', 'goto'=>'show_h24', 'current'=> $current_smt == 'show_h24'],
|
||||
//TODO : CHECK IF IT'S ALREADY DONE ?
|
||||
'del_d30' => ['name'=>$lang['DELETE_EARLIER_30DAYS'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&smt=del_d30', 'goto'=>'del_d30', 'current'=> $current_smt == 'del_d30', 'confirm'=>true],
|
||||
'del_all' => ['name'=>$lang['DELETE_ALL'], 'link'=> basename(ADMIN_PATH) . '?cp=f_reports&smt=del_all', 'goto'=>'del_all', 'current'=> $current_smt == 'del_all', 'confirm'=>true],
|
||||
];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,159 +9,162 @@
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
//for style ..
|
||||
$stylee = "admin_search";
|
||||
$stylee = 'admin_search';
|
||||
//search files
|
||||
$action = basename(ADMIN_PATH) . "?cp=h_search";
|
||||
$action = basename(ADMIN_PATH) . '?cp=h_search';
|
||||
|
||||
//wut the default user system
|
||||
$default_user_system = (int) $config['user_system'] == 1 ? true : false;
|
||||
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_files_search');
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_files_search');
|
||||
$H_FORM_KEYS2 = kleeja_add_form_key('adm_users_search');
|
||||
|
||||
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'files'));
|
||||
|
||||
#filling the inputs automatically via GET
|
||||
//filling the inputs automatically via GET
|
||||
$filled_ip = $filled_username = '';
|
||||
if(ig('s_input'))
|
||||
|
||||
if (ig('s_input'))
|
||||
{
|
||||
if(g('s_input', 'int') == 2)
|
||||
{
|
||||
$filled_username = g('s_value');
|
||||
}
|
||||
elseif(g('s_input', 'int') == 1)
|
||||
{
|
||||
$filled_ip = g('s_value');
|
||||
}
|
||||
if (g('s_input', 'int') == 2)
|
||||
{
|
||||
$filled_username = g('s_value');
|
||||
}
|
||||
elseif (g('s_input', 'int') == 1)
|
||||
{
|
||||
$filled_ip = g('s_value');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ip('search_file'))
|
||||
{
|
||||
if(!kleeja_check_form_key('adm_files_search'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search', 1);
|
||||
}
|
||||
|
||||
#delete all searches greater than 10
|
||||
$s_del = array(
|
||||
'SELECT' => "filter_id",
|
||||
'FROM' => "{$dbprefix}filters",
|
||||
'WHERE' => "filter_type='file_search' AND filter_user=" . $userinfo['id'],
|
||||
'ORDER BY' => "filter_id DESC",
|
||||
'LIMIT' => '5, 18446744073709551615'
|
||||
);
|
||||
if (! kleeja_check_form_key('adm_files_search'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search', 1);
|
||||
}
|
||||
|
||||
$result = $SQL->build($s_del);
|
||||
$ids = array();
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$ids[] = $row['filter_id'];
|
||||
}
|
||||
//delete all searches greater than 10
|
||||
$s_del = [
|
||||
'SELECT' => 'filter_id',
|
||||
'FROM' => "{$dbprefix}filters",
|
||||
'WHERE' => "filter_type='file_search' AND filter_user=" . $userinfo['id'],
|
||||
'ORDER BY' => 'filter_id DESC',
|
||||
'LIMIT' => '5, 18446744073709551615'
|
||||
];
|
||||
|
||||
$SQL->free($result);
|
||||
$result = $SQL->build($s_del);
|
||||
$ids = [];
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$ids[] = $row['filter_id'];
|
||||
}
|
||||
|
||||
if($ids != '')
|
||||
{
|
||||
$query_del = array(
|
||||
'DELETE' => "{$dbprefix}filters",
|
||||
'WHERE' => "filter_id IN('" . implode("', '", $ids) . "')"
|
||||
);
|
||||
$SQL->free($result);
|
||||
|
||||
$SQL->build($query_del);
|
||||
}
|
||||
if ($ids != '')
|
||||
{
|
||||
$query_del = [
|
||||
'DELETE' => "{$dbprefix}filters",
|
||||
'WHERE' => "filter_id IN('" . implode("', '", $ids) . "')"
|
||||
];
|
||||
|
||||
#add as a file_search filter
|
||||
$s = array_map('htmlspecialchars', $_POST);
|
||||
$SQL->build($query_del);
|
||||
}
|
||||
|
||||
#reduce number of array keys
|
||||
unset($s['search_file'], $s['k_form_key'], $s['k_form_time']);
|
||||
foreach ($s as $key => $v)
|
||||
{
|
||||
if ($s[$key] == '')
|
||||
{
|
||||
unset($s[$key]);
|
||||
}
|
||||
}
|
||||
//add as a file_search filter
|
||||
$s = array_map('htmlspecialchars', $_POST);
|
||||
|
||||
$d = serialize($s);
|
||||
//reduce number of array keys
|
||||
unset($s['search_file'], $s['k_form_key'], $s['k_form_time']);
|
||||
|
||||
if(($search_id = insert_filter('file_search', $d)))
|
||||
{
|
||||
foreach ($s as $key => $v)
|
||||
{
|
||||
if ($s[$key] == '')
|
||||
{
|
||||
unset($s[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$d = serialize($s);
|
||||
|
||||
if (($search_id = insert_filter('file_search', $d)))
|
||||
{
|
||||
$filter = get_filter($search_id, 'file_search');
|
||||
redirect(basename(ADMIN_PATH) . "?cp=c_files&search_id=" . $filter['filter_uid'], false);
|
||||
}
|
||||
else
|
||||
{
|
||||
kleeja_admin_err($lang['ERROR_TRY_AGAIN'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search', 1);
|
||||
}
|
||||
redirect(basename(ADMIN_PATH) . '?cp=c_files&search_id=' . $filter['filter_uid'], false);
|
||||
}
|
||||
else
|
||||
{
|
||||
kleeja_admin_err($lang['ERROR_TRY_AGAIN'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search', 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ip('search_user'))
|
||||
{
|
||||
if(!kleeja_check_form_key('adm_users_search'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search&smt=users', 1);
|
||||
}
|
||||
if (! kleeja_check_form_key('adm_users_search'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search&smt=users', 1);
|
||||
}
|
||||
|
||||
#delete all searches greater than 10
|
||||
$s_del = array(
|
||||
'SELECT' => "filter_id",
|
||||
'FROM' => "{$dbprefix}filters",
|
||||
'WHERE' => "filter_type='user_search' AND filter_user=" . $userinfo['id'],
|
||||
'ORDER BY' => "filter_id DESC",
|
||||
'LIMIT' => '5, 18446744073709551615'
|
||||
);
|
||||
//delete all searches greater than 10
|
||||
$s_del = [
|
||||
'SELECT' => 'filter_id',
|
||||
'FROM' => "{$dbprefix}filters",
|
||||
'WHERE' => "filter_type='user_search' AND filter_user=" . $userinfo['id'],
|
||||
'ORDER BY' => 'filter_id DESC',
|
||||
'LIMIT' => '5, 18446744073709551615'
|
||||
];
|
||||
|
||||
$result = $SQL->build($s_del);
|
||||
$ids = array();
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$ids[] = $row['filter_id'];
|
||||
}
|
||||
$SQL->free($result);
|
||||
$result = $SQL->build($s_del);
|
||||
$ids = [];
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$ids[] = $row['filter_id'];
|
||||
}
|
||||
$SQL->free($result);
|
||||
|
||||
if($ids != '')
|
||||
{
|
||||
$query_del = array(
|
||||
'DELETE' => "{$dbprefix}filters",
|
||||
'WHERE' => "filter_id IN('" . implode("', '", $ids) . "')"
|
||||
);
|
||||
if ($ids != '')
|
||||
{
|
||||
$query_del = [
|
||||
'DELETE' => "{$dbprefix}filters",
|
||||
'WHERE' => "filter_id IN('" . implode("', '", $ids) . "')"
|
||||
];
|
||||
|
||||
$SQL->build($query_del);
|
||||
}
|
||||
$SQL->build($query_del);
|
||||
}
|
||||
|
||||
#add as a user_search filter
|
||||
$s = $_POST;
|
||||
unset($s['search_user'], $s['k_form_key'], $s['k_form_time']);
|
||||
$d = serialize($s);
|
||||
if(($search_id = insert_filter('user_search', $d)))
|
||||
{
|
||||
//add as a user_search filter
|
||||
$s = $_POST;
|
||||
unset($s['search_user'], $s['k_form_key'], $s['k_form_time']);
|
||||
$d = serialize($s);
|
||||
|
||||
if (($search_id = insert_filter('user_search', $d)))
|
||||
{
|
||||
$filter = get_filter($search_id, 'user_search');
|
||||
redirect(basename(ADMIN_PATH) . "?cp=g_users&smt=show_su&search_id=" . $filter['filter_uid'], false);
|
||||
}
|
||||
else
|
||||
{
|
||||
kleeja_admin_err($lang['ERROR_TRY_AGAIN'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search&smt=users', 1);
|
||||
}
|
||||
redirect(basename(ADMIN_PATH) . '?cp=g_users&smt=show_su&search_id=' . $filter['filter_uid'], false);
|
||||
}
|
||||
else
|
||||
{
|
||||
kleeja_admin_err($lang['ERROR_TRY_AGAIN'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search&smt=users', 1);
|
||||
}
|
||||
}
|
||||
|
||||
//secondary menu
|
||||
$go_menu = array(
|
||||
'files' => array('name'=>$lang['SEARCH_FILES'], 'link'=> basename(ADMIN_PATH) . '?cp=h_search&smt=files', 'goto'=>'files', 'current'=> $current_smt == 'files'),
|
||||
#'sep1' => array('class'=>'separator'),
|
||||
'users' => array('name'=>$lang['SEARCH_USERS'], 'link'=> basename(ADMIN_PATH) . '?cp=h_search&smt=users', 'goto'=>'users', 'current'=> $current_smt == 'users'),
|
||||
#'sep2' => array('class'=>'separator'),
|
||||
);
|
||||
|
||||
if(!$default_user_system)
|
||||
$go_menu = [
|
||||
'files' => ['name'=>$lang['SEARCH_FILES'], 'link'=> basename(ADMIN_PATH) . '?cp=h_search&smt=files', 'goto'=>'files', 'current'=> $current_smt == 'files'],
|
||||
//'sep1' => array('class'=>'separator'),
|
||||
'users' => ['name'=>$lang['SEARCH_USERS'], 'link'=> basename(ADMIN_PATH) . '?cp=h_search&smt=users', 'goto'=>'users', 'current'=> $current_smt == 'users'],
|
||||
//'sep2' => array('class'=>'separator'),
|
||||
];
|
||||
|
||||
if (! $default_user_system)
|
||||
{
|
||||
unset($go_menu['users']);
|
||||
unset($go_menu['users']);
|
||||
}
|
||||
|
||||
@@ -9,49 +9,51 @@
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
#turn time-limit off
|
||||
//turn time-limit off
|
||||
@set_time_limit(0);
|
||||
|
||||
|
||||
#get current case
|
||||
//get current case
|
||||
$case = g('case', 'str', 'installed');
|
||||
|
||||
#set _get form key
|
||||
//set _get form key
|
||||
$GET_FORM_KEY = kleeja_add_form_key_get('PLUGINS_FORM_KEY');
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_plugins');
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_plugins');
|
||||
|
||||
$action = ADMIN_PATH . '?cp=' . basename(__file__, '.php');
|
||||
|
||||
$plugin_install_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=install&' . $GET_FORM_KEY . '&plg=';
|
||||
$plugin_install_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=install&' . $GET_FORM_KEY . '&plg=';
|
||||
$plugin_uninstall_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=uninstall&' . $GET_FORM_KEY . '&plg=';
|
||||
$plugin_enable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=enable&' . $GET_FORM_KEY . '&plg=';
|
||||
$plugin_disable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=disable&' . $GET_FORM_KEY . '&plg=';
|
||||
$plugin_download_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=download&' . $GET_FORM_KEY . '&plg=';
|
||||
$plugin_update_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=update&' . $GET_FORM_KEY . '&plg=';
|
||||
$plugin_enable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=enable&' . $GET_FORM_KEY . '&plg=';
|
||||
$plugin_disable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=disable&' . $GET_FORM_KEY . '&plg=';
|
||||
$plugin_download_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=download&' . $GET_FORM_KEY . '&plg=';
|
||||
$plugin_update_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=update&' . $GET_FORM_KEY . '&plg=';
|
||||
|
||||
|
||||
//check _GET Csrf token
|
||||
if (!empty($case) && in_array($case, array('install', 'uninstall', 'enable', 'disable' , 'download' , 'update')))
|
||||
if (! empty($case) && in_array($case, ['install', 'uninstall', 'enable', 'disable' , 'download' , 'update']))
|
||||
{
|
||||
if (!kleeja_check_form_key_get('PLUGINS_FORM_KEY'))
|
||||
if (! kleeja_check_form_key_get('PLUGINS_FORM_KEY'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_GET_KEY'], $action);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(ip('newplugin'))
|
||||
if (ip('newplugin'))
|
||||
{
|
||||
if(!kleeja_check_form_key('adm_plugins'))
|
||||
if (! kleeja_check_form_key('adm_plugins'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -65,43 +67,42 @@ switch ($case):
|
||||
case 'store':
|
||||
case 'check':
|
||||
|
||||
# Get installed plugins
|
||||
$query = array(
|
||||
'SELECT' => "plg_id, plg_name, plg_ver, plg_disabled, plg_author, plg_dsc",
|
||||
'FROM' => "{$dbprefix}plugins",
|
||||
'ORDER BY' => "plg_id ASC",
|
||||
);
|
||||
// Get installed plugins
|
||||
$query = [
|
||||
'SELECT' => 'plg_id, plg_name, plg_ver, plg_disabled, plg_author, plg_dsc',
|
||||
'FROM' => "{$dbprefix}plugins",
|
||||
'ORDER BY' => 'plg_id ASC',
|
||||
];
|
||||
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
$installed_plugins = array();
|
||||
$installed_plugins = [];
|
||||
|
||||
while ($row = $SQL->fetch($result))
|
||||
{
|
||||
|
||||
$installed_plugins[$row['plg_name']] = $row;
|
||||
|
||||
$installed_plugins[$row['plg_name']]['extra_info'] = Plugins::getInstance()->installed_plugin_info($row['plg_name']);
|
||||
|
||||
|
||||
$installed_plugins[$row['plg_name']]['icon'] = file_exists(
|
||||
PATH . KLEEJA_PLUGINS_FOLDER . '/' . $row['plg_name'] . "/icon.png"
|
||||
PATH . KLEEJA_PLUGINS_FOLDER . '/' . $row['plg_name'] . '/icon.png'
|
||||
)
|
||||
? PATH . KLEEJA_PLUGINS_FOLDER . '/' . $row['plg_name'] . "/icon.png"
|
||||
? PATH . KLEEJA_PLUGINS_FOLDER . '/' . $row['plg_name'] . '/icon.png'
|
||||
: $STYLE_PATH_ADMIN . 'images/plugin.png';
|
||||
|
||||
|
||||
foreach (array('plugin_title', 'plugin_description') as $localizedInfo)
|
||||
foreach (['plugin_title', 'plugin_description'] as $localizedInfo)
|
||||
{
|
||||
if (is_array($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]))
|
||||
{
|
||||
if (!empty($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo][$config['language']]))
|
||||
if (! empty($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo][$config['language']]))
|
||||
{
|
||||
$installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo] =
|
||||
shorten_text($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo][$config['language']], 100);
|
||||
}
|
||||
else if (!empty($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]['en']))
|
||||
elseif (! empty($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]['en']))
|
||||
{
|
||||
$installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo] =
|
||||
shorten_text($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]['en'], 100);
|
||||
@@ -117,23 +118,23 @@ switch ($case):
|
||||
$SQL->free($result);
|
||||
|
||||
|
||||
#get available plugins
|
||||
$dh = opendir(PATH . KLEEJA_PLUGINS_FOLDER);
|
||||
$available_plugins = array();
|
||||
//get available plugins
|
||||
$dh = opendir(PATH . KLEEJA_PLUGINS_FOLDER);
|
||||
$available_plugins = [];
|
||||
while (false !== ($folder_name = readdir($dh)))
|
||||
{
|
||||
if (is_dir(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
|
||||
if (is_dir(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
|
||||
{
|
||||
if (empty($installed_plugins[$folder_name]))
|
||||
{
|
||||
array_push($available_plugins,
|
||||
array(
|
||||
[
|
||||
'name' => $folder_name,
|
||||
'icon' => file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name . "/icon.png")
|
||||
? PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name . "/icon.png"
|
||||
'icon' => file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name . '/icon.png')
|
||||
? PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name . '/icon.png'
|
||||
: $STYLE_PATH_ADMIN . 'images/plugin.png',
|
||||
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -142,23 +143,23 @@ switch ($case):
|
||||
|
||||
$no_plugins = sizeof($available_plugins) == 0 && sizeof($installed_plugins) == 0;
|
||||
|
||||
$stylee = "admin_plugins";
|
||||
$stylee = 'admin_plugins';
|
||||
|
||||
//do not proceed if not store case
|
||||
if(! in_array($case, ['store', 'check']))
|
||||
if (! in_array($case, ['store', 'check']))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// plugins avilable in kleeja remote catalog
|
||||
if (!($catalog_plugins = $cache->get('catalog_plugins')))
|
||||
if (! ($catalog_plugins = $cache->get('catalog_plugins')))
|
||||
{
|
||||
$store_link = 'https://raw.githubusercontent.com/kleeja-official/store-catalog/master/catalog.json';
|
||||
|
||||
$catalog_plugins = fetch_remote_file($store_link);
|
||||
$catalog_plugins = json_decode($catalog_plugins , true);
|
||||
$catalog_plugins = json_decode($catalog_plugins, true);
|
||||
|
||||
if(json_last_error() == JSON_ERROR_NONE)
|
||||
if (json_last_error() == JSON_ERROR_NONE)
|
||||
{
|
||||
$cache->save('catalog_plugins', $catalog_plugins);
|
||||
}
|
||||
@@ -166,14 +167,14 @@ switch ($case):
|
||||
|
||||
// make an array for all plugins in kleeja remote catalog
|
||||
// that are not exsisted locally.
|
||||
$store_plugins = array();
|
||||
$store_plugins = [];
|
||||
$available_plugins_names = array_column($available_plugins, 'name');
|
||||
foreach ($catalog_plugins as $plugin_info)
|
||||
|
||||
foreach ($catalog_plugins as $plugin_info)
|
||||
{
|
||||
if ($case == 'store' && (in_array($plugin_info['name'] , $available_plugins_names) ||
|
||||
if ($case == 'store' && (in_array($plugin_info['name'], $available_plugins_names) ||
|
||||
! empty($installed_plugins[$plugin_info['name']]) )
|
||||
)
|
||||
{
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -183,25 +184,25 @@ switch ($case):
|
||||
strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']),
|
||||
strtolower($plugin_info['file']['version']),
|
||||
'>=') || empty($installed_plugins[$plugin_info['name']]))
|
||||
) {
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$store_plugins[$plugin_info['name']] = array(
|
||||
'name' => $plugin_info['name'],
|
||||
'developer' => $plugin_info['developer'],
|
||||
'version' => $plugin_info['file']['version'],
|
||||
'title' => ! empty($plugin_info['title'][$config['language']]) ? $plugin_info['title'][$config['language']] : $plugin_info['title']['en'],
|
||||
'website' => $plugin_info['website'],
|
||||
'current_version' => ! empty($installed_plugins[$plugin_info['name']]) ? strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']) : '',
|
||||
'kj_min_version' => $plugin_info['kleeja_version']['min'],
|
||||
'kj_max_version' => $plugin_info['kleeja_version']['max'],
|
||||
$store_plugins[$plugin_info['name']] = [
|
||||
'name' => $plugin_info['name'],
|
||||
'developer' => $plugin_info['developer'],
|
||||
'version' => $plugin_info['file']['version'],
|
||||
'title' => ! empty($plugin_info['title'][$config['language']]) ? $plugin_info['title'][$config['language']] : $plugin_info['title']['en'],
|
||||
'website' => $plugin_info['website'],
|
||||
'current_version' => ! empty($installed_plugins[$plugin_info['name']]) ? strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']) : '',
|
||||
'kj_min_version' => $plugin_info['kleeja_version']['min'],
|
||||
'kj_max_version' => $plugin_info['kleeja_version']['max'],
|
||||
'kj_version_cmtp' => sprintf($lang[ 'KLJ_VER_NO_PLUGIN'], $plugin_info['kleeja_version']['min'], $plugin_info['kleeja_version']['max']),
|
||||
'icon' => $plugin_info['icon'] ,
|
||||
'NotCompatible' => version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION , '<=')
|
||||
&& version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION , '>=')
|
||||
? false : true,
|
||||
);
|
||||
'icon' => $plugin_info['icon'] ,
|
||||
'NotCompatible' => version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION, '<=')
|
||||
&& version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION, '>=')
|
||||
? false : true,
|
||||
];
|
||||
}
|
||||
|
||||
$no_store_plugins = sizeof($store_plugins) == 0;
|
||||
@@ -212,28 +213,29 @@ switch ($case):
|
||||
//upload a plugin
|
||||
//
|
||||
case 'upload':
|
||||
$ERRORS = array();
|
||||
$ERRORS = [];
|
||||
|
||||
if(intval($userinfo['founder']) !== 1)
|
||||
if (intval($userinfo['founder']) !== 1)
|
||||
{
|
||||
$ERRORS[] = $lang['HV_NOT_PRVLG_ACCESS'];
|
||||
}
|
||||
|
||||
#is uploaded?
|
||||
if(empty($_FILES['plugin_file']['tmp_name']))
|
||||
//is uploaded?
|
||||
if (empty($_FILES['plugin_file']['tmp_name']))
|
||||
{
|
||||
$ERRORS[] = $lang['CHOSE_F'];
|
||||
}
|
||||
|
||||
#extract it to plugins folder
|
||||
if(!sizeof($ERRORS))
|
||||
//extract it to plugins folder
|
||||
if (! sizeof($ERRORS))
|
||||
{
|
||||
if(class_exists('ZipArchive'))
|
||||
if (class_exists('ZipArchive'))
|
||||
{
|
||||
$zip = new ZipArchive;
|
||||
|
||||
if ($zip->open($_FILES['plugin_file']['tmp_name']) === true)
|
||||
{
|
||||
if(!$zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
|
||||
if (! $zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
|
||||
{
|
||||
$ERRORS[] = sprintf($lang['EXTRACT_ZIP_FAILED'], KLEEJA_PLUGINS_FOLDER);
|
||||
}
|
||||
@@ -250,12 +252,12 @@ switch ($case):
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($_FILES['plugin_file']['tmp_name']))
|
||||
if (! empty($_FILES['plugin_file']['tmp_name']))
|
||||
{
|
||||
@unlink($_FILES['plugin_file']['tmp_name']);
|
||||
}
|
||||
|
||||
if(!sizeof($ERRORS))
|
||||
if (! sizeof($ERRORS))
|
||||
{
|
||||
kleeja_admin_info($lang['NO_PROBLEM_AFTER_ZIP'], true, '', true, $action);
|
||||
}
|
||||
@@ -272,9 +274,10 @@ switch ($case):
|
||||
//
|
||||
case 'install':
|
||||
|
||||
if(intval($userinfo['founder']) !== 1)
|
||||
if (intval($userinfo['founder']) !== 1)
|
||||
{
|
||||
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -287,56 +290,59 @@ switch ($case):
|
||||
exit('empty($plg_name)');
|
||||
}
|
||||
//no plugin selected? back
|
||||
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
|
||||
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php'))
|
||||
if (! file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php'))
|
||||
{
|
||||
if (defined('DEBUG'))
|
||||
{
|
||||
exit('!file_exists($plg_name)');
|
||||
}
|
||||
|
||||
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
|
||||
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
#if already installed, show a message
|
||||
if (!empty(Plugins::getInstance()->installed_plugin_info($plg_name)))
|
||||
//if already installed, show a message
|
||||
if (! empty(Plugins::getInstance()->installed_plugin_info($plg_name)))
|
||||
{
|
||||
kleeja_admin_info($lang['PLUGIN_EXISTS_BEFORE'], true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$kleeja_plugin = array();
|
||||
$kleeja_plugin = [];
|
||||
|
||||
include PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php';
|
||||
|
||||
$install_callback = $kleeja_plugin[$plg_name]['install'];
|
||||
$plugin_info = $kleeja_plugin[$plg_name]['information'];
|
||||
$plugin_info = $kleeja_plugin[$plg_name]['information'];
|
||||
$plugin_first_run = false;
|
||||
|
||||
if (!empty($kleeja_plugin[$plg_name]['first_run'][$config['language']]))
|
||||
if (! empty($kleeja_plugin[$plg_name]['first_run'][$config['language']]))
|
||||
{
|
||||
$plugin_first_run = $kleeja_plugin[$plg_name]['first_run'][$config['language']];
|
||||
}
|
||||
else if (!empty($kleeja_plugin[$plg_name]['first_run']['en']))
|
||||
elseif (! empty($kleeja_plugin[$plg_name]['first_run']['en']))
|
||||
{
|
||||
$plugin_first_run = $kleeja_plugin[$plg_name]['first_run']['en'];
|
||||
}
|
||||
|
||||
#check if compatible with kleeja
|
||||
#'plugin_kleeja_version_min' => '1.8',
|
||||
# Max version of Kleeja that's required to run this plugin
|
||||
#'plugin_kleeja_version_max' => '3.8',
|
||||
//check if compatible with kleeja
|
||||
//'plugin_kleeja_version_min' => '1.8',
|
||||
// Max version of Kleeja that's required to run this plugin
|
||||
//'plugin_kleeja_version_max' => '3.8',
|
||||
|
||||
if (version_compare(KLEEJA_VERSION, $plugin_info['plugin_kleeja_version_min'], '<'))
|
||||
{
|
||||
kleeja_admin_info(
|
||||
$lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|<|p.min:' . $plugin_info['plugin_kleeja_version_min'],
|
||||
$lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|<|p.min:' . $plugin_info['plugin_kleeja_version_min'],
|
||||
true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php')
|
||||
);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -345,9 +351,10 @@ switch ($case):
|
||||
if (version_compare(KLEEJA_VERSION, $plugin_info['plugin_kleeja_version_max'], '>'))
|
||||
{
|
||||
kleeja_admin_info(
|
||||
$lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|>|p.max:' . $plugin_info['plugin_kleeja_version_max'],
|
||||
$lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|>|p.max:' . $plugin_info['plugin_kleeja_version_max'],
|
||||
true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php')
|
||||
);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -356,26 +363,27 @@ switch ($case):
|
||||
|
||||
if (is_array($plugin_info['plugin_description']))
|
||||
{
|
||||
$plugin_info['plugin_description'] = !empty($plugin_info['plugin_description']['en']) ? $plugin_info['plugin_description']['en'] : $plugin_info['plugin_description'][0];
|
||||
$plugin_info['plugin_description'] = ! empty($plugin_info['plugin_description']['en']) ? $plugin_info['plugin_description']['en'] : $plugin_info['plugin_description'][0];
|
||||
}
|
||||
|
||||
#add to database
|
||||
$insert_query = array(
|
||||
//add to database
|
||||
$insert_query = [
|
||||
'INSERT' => '`plg_name` ,`plg_ver`, `plg_author`, `plg_dsc`, `plg_icon`, `plg_uninstall`, `plg_instructions`, `plg_store`, `plg_files`',
|
||||
'INTO' => "{$dbprefix}plugins",
|
||||
'INTO' => "{$dbprefix}plugins",
|
||||
'VALUES' => "'" . $SQL->escape($plg_name) . "','" . $SQL->escape($plugin_info['plugin_version']) . "', '" . $SQL->escape($plugin_info['plugin_developer']) . "','" . $SQL->escape($plugin_info['plugin_description']) . "', '', '', '', '', ''",
|
||||
);
|
||||
];
|
||||
|
||||
$SQL->build($insert_query);
|
||||
|
||||
#may God protect you brother.
|
||||
if(is_callable($install_callback))
|
||||
//may God protect you brother.
|
||||
if (is_callable($install_callback))
|
||||
{
|
||||
$install_callback($SQL->insert_id());
|
||||
}
|
||||
|
||||
#show done, msg
|
||||
//show done, msg
|
||||
$text = '<h3>' . $lang['NEW_PLUGIN_ADDED'] . '</h3>';
|
||||
|
||||
if ($plugin_first_run)
|
||||
{
|
||||
$text .= $plugin_first_run;
|
||||
@@ -397,9 +405,10 @@ switch ($case):
|
||||
//
|
||||
case 'uninstall':
|
||||
|
||||
if(intval($userinfo['founder']) !== 1)
|
||||
if (intval($userinfo['founder']) !== 1)
|
||||
{
|
||||
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -413,58 +422,60 @@ switch ($case):
|
||||
}
|
||||
|
||||
//no plugin selected? back
|
||||
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
|
||||
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php'))
|
||||
if (! file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php'))
|
||||
{
|
||||
if (defined('DEV_STAGE'))
|
||||
{
|
||||
exit('!file_exists($plg_name)');
|
||||
}
|
||||
|
||||
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
|
||||
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$kleeja_plugin = array();
|
||||
$kleeja_plugin = [];
|
||||
|
||||
include PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php';
|
||||
|
||||
$uninstall_callback = $kleeja_plugin[$plg_name]['uninstall'];
|
||||
|
||||
if (!is_callable($uninstall_callback))
|
||||
if (! is_callable($uninstall_callback))
|
||||
{
|
||||
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
|
||||
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$query = array(
|
||||
'SELECT' => "plg_id",
|
||||
'FROM' => "{$dbprefix}plugins",
|
||||
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 'plg_id',
|
||||
'FROM' => "{$dbprefix}plugins",
|
||||
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
$pluginDatabaseInfo = $SQL->fetch($result);
|
||||
|
||||
#sad to see you go, brother
|
||||
$uninstall_callback(!empty($pluginDatabaseInfo) ? $pluginDatabaseInfo['plg_id'] : 0);
|
||||
//sad to see you go, brother
|
||||
$uninstall_callback(! empty($pluginDatabaseInfo) ? $pluginDatabaseInfo['plg_id'] : 0);
|
||||
|
||||
delete_cache('', true);
|
||||
|
||||
#remove from database
|
||||
$query_del = array(
|
||||
//remove from database
|
||||
$query_del = [
|
||||
'DELETE' => "`{$dbprefix}plugins`",
|
||||
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
|
||||
);
|
||||
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
|
||||
];
|
||||
|
||||
$SQL->build($query_del);
|
||||
|
||||
#show done, msg
|
||||
//show done, msg
|
||||
$text = '<h3>' . $lang['PLUGIN_DELETED'] . '</h3>';
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
|
||||
|
||||
@@ -480,9 +491,10 @@ switch ($case):
|
||||
case 'disable':
|
||||
case 'enable':
|
||||
|
||||
if(intval($userinfo['founder']) !== 1)
|
||||
if (intval($userinfo['founder']) !== 1)
|
||||
{
|
||||
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -495,23 +507,23 @@ switch ($case):
|
||||
exit('empty($plg_name)');
|
||||
}
|
||||
//no plugin selected? back
|
||||
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
|
||||
redirect(ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
}
|
||||
else
|
||||
{
|
||||
#update database
|
||||
$update_query = array(
|
||||
//update database
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}plugins",
|
||||
'SET' => "plg_disabled=" . ($case == 'disable' ? 1 : 0),
|
||||
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
|
||||
);
|
||||
'SET' => 'plg_disabled=' . ($case == 'disable' ? 1 : 0),
|
||||
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
|
||||
];
|
||||
|
||||
|
||||
$SQL->build($update_query);
|
||||
|
||||
delete_cache('', true);
|
||||
|
||||
#show done, msg
|
||||
//show done, msg
|
||||
$text = '<h3>' . $lang['PLGUIN_DISABLED_ENABLED'] . '</h3>';
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
|
||||
|
||||
@@ -523,18 +535,20 @@ switch ($case):
|
||||
|
||||
case 'download':
|
||||
|
||||
if(intval($userinfo['founder']) !== 1)
|
||||
if (intval($userinfo['founder']) !== 1)
|
||||
{
|
||||
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$download_plugin = g('plg');
|
||||
|
||||
// update it , rename function doesn't move the folder , if the folder is exists on the new dir
|
||||
if( file_exists( PATH . KLEEJA_PLUGINS_FOLDER. '/' . $download_plugin . '/init.php' ) )
|
||||
if ( file_exists( PATH . KLEEJA_PLUGINS_FOLDER . '/' . $download_plugin . '/init.php' ) )
|
||||
{
|
||||
redirect( $plugin_update_link . $download_plugin );
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -543,22 +557,22 @@ switch ($case):
|
||||
|
||||
$catalog_plugins = fetch_remote_file($store_link);
|
||||
|
||||
if ($catalog_plugins)
|
||||
if ($catalog_plugins)
|
||||
{
|
||||
$catalog_plugins = json_decode($catalog_plugins , true);
|
||||
$catalog_plugins = json_decode($catalog_plugins, true);
|
||||
|
||||
$store_plugins = [];
|
||||
|
||||
$store_plugins = array();
|
||||
|
||||
// make an arry for all plugins in kleeja store that not included in our server
|
||||
foreach ($catalog_plugins as $plugin_info)
|
||||
foreach ($catalog_plugins as $plugin_info)
|
||||
{
|
||||
$store_plugins[$plugin_info['name']] = array(
|
||||
'name' => $plugin_info['name'] ,
|
||||
'plg_version' => $plugin_info['file']['version'] ,
|
||||
'url' => $plugin_info['file']['url'] ,
|
||||
$store_plugins[$plugin_info['name']] = [
|
||||
'name' => $plugin_info['name'] ,
|
||||
'plg_version' => $plugin_info['file']['version'] ,
|
||||
'url' => $plugin_info['file']['url'] ,
|
||||
'kj_min_version' => $plugin_info['kleeja_version']['min'] ,
|
||||
'kj_max_version' => $plugin_info['kleeja_version']['max'] ,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// // => this plugin is hosted in our store
|
||||
@@ -566,22 +580,22 @@ switch ($case):
|
||||
{
|
||||
// check if the version of the plugin is compatible with our kleeja version or not
|
||||
if (
|
||||
version_compare(strtolower($store_plugins[$download_plugin]['kj_min_version']), KLEEJA_VERSION , '<=')
|
||||
&& version_compare(strtolower($store_plugins[$download_plugin]['kj_max_version']), KLEEJA_VERSION , '>=')
|
||||
)
|
||||
{
|
||||
version_compare(strtolower($store_plugins[$download_plugin]['kj_min_version']), KLEEJA_VERSION, '<=')
|
||||
&& version_compare(strtolower($store_plugins[$download_plugin]['kj_max_version']), KLEEJA_VERSION, '>=')
|
||||
) {
|
||||
$download_plugin_link = $store_plugins[$download_plugin]['url'];
|
||||
|
||||
$downloaded_plugin_zip = fetch_remote_file($download_plugin_link, PATH . 'cache/' . $download_plugin . '.zip', 60, false, 10, true);
|
||||
|
||||
if ($downloaded_plugin_zip)
|
||||
if ($downloaded_plugin_zip)
|
||||
{
|
||||
if (file_exists(PATH . 'cache/' . $download_plugin . '.zip' ) )
|
||||
if (file_exists(PATH . 'cache/' . $download_plugin . '.zip' ) )
|
||||
{
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if ($zip->open(PATH . 'cache/' . $download_plugin . '.zip' ) === true)
|
||||
{
|
||||
if( $zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
|
||||
if ( $zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
|
||||
{
|
||||
$zip->close();
|
||||
// we dont need the zip file anymore
|
||||
@@ -590,18 +604,18 @@ switch ($case):
|
||||
// for example :: When we extract zip file , the name will be ( advanced-extras-1.0 )
|
||||
// so we need to remove the version from folder name and replace ( - ) with ( _ )
|
||||
// and done
|
||||
$plugin_folder_name = PATH . KLEEJA_PLUGINS_FOLDER. '/' . str_replace('_' , '-' , $download_plugin) . '-' . $store_plugins[$download_plugin]['plg_version'];
|
||||
rename($plugin_folder_name , PATH . KLEEJA_PLUGINS_FOLDER. '/' . $download_plugin);
|
||||
$plugin_folder_name = PATH . KLEEJA_PLUGINS_FOLDER . '/' . str_replace('_', '-', $download_plugin) . '-' . $store_plugins[$download_plugin]['plg_version'];
|
||||
rename($plugin_folder_name, PATH . KLEEJA_PLUGINS_FOLDER . '/' . $download_plugin);
|
||||
|
||||
// download or update msg
|
||||
kleeja_admin_info(
|
||||
sprintf($lang[ig('update') ? 'PLUGIN_UPDATED' : 'PLUGIN_DOWNLOADED'], $download_plugin),
|
||||
sprintf($lang[ig('update') ? 'PLUGIN_UPDATED' : 'PLUGIN_DOWNLOADED'], $download_plugin),
|
||||
ADMIN_PATH . '?cp=' . basename(__file__, '.php')
|
||||
);
|
||||
|
||||
|
||||
exit;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
kleeja_admin_err($lang['EXTRACT_ZIP_FAILED']);
|
||||
}
|
||||
@@ -612,7 +626,7 @@ switch ($case):
|
||||
kleeja_admin_err($lang['PLUGIN_FILE_NOT_FOUND']);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
kleeja_admin_err($lang['PLUGINS_SERVER_ERROR']);
|
||||
}
|
||||
@@ -622,7 +636,7 @@ switch ($case):
|
||||
kleeja_admin_err($lang['PLUGIN_N_CMPT_KLJ']);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
kleeja_admin_err(sprintf($lang['PLUGIN_REMOTE_FILE_MISSING'], $download_plugin));
|
||||
}
|
||||
@@ -640,12 +654,13 @@ switch ($case):
|
||||
|
||||
$plugin_folder_name = PATH . KLEEJA_PLUGINS_FOLDER . '/' . $update_plugin;
|
||||
|
||||
if (is_dir($plugin_folder_name))
|
||||
if (is_dir($plugin_folder_name))
|
||||
{
|
||||
delete_plugin_folder($plugin_folder_name);
|
||||
}
|
||||
|
||||
redirect($plugin_download_link . $update_plugin . '&update' );
|
||||
|
||||
break;
|
||||
|
||||
endswitch;
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
//for style ..
|
||||
$stylee = "admin_ban";
|
||||
$stylee = 'admin_ban';
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php');
|
||||
|
||||
$affected = false;
|
||||
$affected = false;
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_ban');
|
||||
|
||||
//
|
||||
@@ -26,17 +26,17 @@ $H_FORM_KEYS = kleeja_add_form_key('adm_ban');
|
||||
//
|
||||
if (ip('submit'))
|
||||
{
|
||||
if(!kleeja_check_form_key('adm_ban'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
if (! kleeja_check_form_key('adm_ban'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query = array(
|
||||
'SELECT' => 'ban',
|
||||
'FROM' => "{$dbprefix}stats"
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 'ban',
|
||||
'FROM' => "{$dbprefix}stats"
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
@@ -48,13 +48,14 @@ $ban = p('ban_text', 'str', $current_ban_data['ban']);
|
||||
if (ip('submit'))
|
||||
{
|
||||
//update
|
||||
$update_query = array(
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "ban='" . $SQL->escape($ban) . "'"
|
||||
);
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "ban='" . $SQL->escape($ban) . "'"
|
||||
];
|
||||
|
||||
$SQL->build($update_query);
|
||||
if($SQL->affected())
|
||||
|
||||
if ($SQL->affected())
|
||||
{
|
||||
$affected = true;
|
||||
delete_cache('data_ban');
|
||||
@@ -67,7 +68,7 @@ $SQL->freeresult($result);
|
||||
//after submit
|
||||
if (ip('submit'))
|
||||
{
|
||||
$text = ($affected ? $lang['BAN_UPDATED'] : $lang['NO_UP_CHANGE_S']);
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
|
||||
$stylee = "admin_info";
|
||||
$text = ($affected ? $lang['BAN_UPDATED'] : $lang['NO_UP_CHANGE_S']);
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
|
||||
$stylee = 'admin_info';
|
||||
}
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
//for style ..
|
||||
$stylee = "admin_rules";
|
||||
$stylee = 'admin_rules';
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php');
|
||||
|
||||
$affected = false;
|
||||
$affected = false;
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_rules');
|
||||
|
||||
//
|
||||
@@ -26,40 +26,41 @@ $H_FORM_KEYS = kleeja_add_form_key('adm_rules');
|
||||
//
|
||||
if (ip('submit'))
|
||||
{
|
||||
if(!kleeja_check_form_key('adm_rules'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
if (! kleeja_check_form_key('adm_rules'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query = array(
|
||||
'SELECT' => 'rules',
|
||||
'FROM' => "{$dbprefix}stats"
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 'rules',
|
||||
'FROM' => "{$dbprefix}stats"
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$rules = p('rules_text', 'str', $row['rules']);
|
||||
|
||||
//when submit
|
||||
if (ip('submit'))
|
||||
{
|
||||
//update
|
||||
$update_query = array(
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "rules = '" . $SQL->real_escape(htmlspecialchars_decode($rules)) . "'"
|
||||
);
|
||||
$rules = p('rules_text', 'str', $row['rules']);
|
||||
|
||||
$SQL->build($update_query);
|
||||
if($SQL->affected())
|
||||
{
|
||||
$affected = true;
|
||||
delete_cache('data_rules');
|
||||
}
|
||||
}
|
||||
//when submit
|
||||
if (ip('submit'))
|
||||
{
|
||||
//update
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "rules = '" . $SQL->real_escape(htmlspecialchars_decode($rules)) . "'"
|
||||
];
|
||||
|
||||
$SQL->build($update_query);
|
||||
|
||||
if ($SQL->affected())
|
||||
{
|
||||
$affected = true;
|
||||
delete_cache('data_rules');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
@@ -68,7 +69,7 @@ $SQL->freeresult($result);
|
||||
//after submit
|
||||
if (ip('submit'))
|
||||
{
|
||||
$text = ($affected ? $lang['RULES_UPDATED'] : $lang['NO_UP_CHANGE_S']);
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
|
||||
$stylee = "admin_info";
|
||||
$text = ($affected ? $lang['RULES_UPDATED'] : $lang['NO_UP_CHANGE_S']);
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
|
||||
$stylee = 'admin_info';
|
||||
}
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
*/
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
#current secondary menu action
|
||||
$current_smt = preg_replace('/[^a-z0-9_]/i','', g('smt', 'str', 'general'));
|
||||
//current secondary menu action
|
||||
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
|
||||
|
||||
$action = ADMIN_PATH . '?cp=' . basename(__file__, '.php');
|
||||
|
||||
@@ -23,7 +23,7 @@ $H_FORM_KEYS = kleeja_add_form_key('adm_styles');
|
||||
|
||||
|
||||
//for style ..
|
||||
$stylee = "admin_styles";
|
||||
$stylee = 'admin_styles';
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ if (ip('style_choose') || ig('style_choose'))
|
||||
// make style as default
|
||||
|
||||
//check _GET Csrf token
|
||||
if (isset($_REQUEST['home']) && !kleeja_check_form_key_get('adm_start_actions'))
|
||||
if (isset($_REQUEST['home']) && ! kleeja_check_form_key_get('adm_start_actions'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=start', 2);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ if (ip('style_choose') || ig('style_choose'))
|
||||
//
|
||||
if (($style_info = kleeja_style_info($style_id)) != false)
|
||||
{
|
||||
if (isset($style_info['depend_on']) && !file_exists(PATH . 'styles/' . $style_info['depend_on']))
|
||||
if (isset($style_info['depend_on']) && ! file_exists(PATH . 'styles/' . $style_info['depend_on']))
|
||||
{
|
||||
kleeja_admin_err(sprintf($lang['DEPEND_ON_NO_STYLE_ERR'], $style_info['depend_on']));
|
||||
}
|
||||
@@ -71,10 +71,10 @@ if (ip('style_choose') || ig('style_choose'))
|
||||
$plugins_required = explode(',', $style_info['plugins_required']);
|
||||
$plugins_required = array_map('trim', $plugins_required);
|
||||
|
||||
$query = array(
|
||||
$query = [
|
||||
'SELECT' => 'plg_name, plg_disabled',
|
||||
'FROM' => "{$dbprefix}plugins",
|
||||
);
|
||||
'FROM' => "{$dbprefix}plugins",
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
@@ -93,6 +93,7 @@ if (ip('style_choose') || ig('style_choose'))
|
||||
$SQL->freeresult($result);
|
||||
|
||||
$plugins_required = array_flip($plugins_required);
|
||||
|
||||
if (sizeof($plugins_required))
|
||||
{
|
||||
kleeja_admin_err(sprintf($lang['PLUGINS_REQ_NO_STYLE_ERR'], implode(', ', $plugins_required)));
|
||||
@@ -110,42 +111,41 @@ if (ip('style_choose') || ig('style_choose'))
|
||||
|
||||
//show msg
|
||||
kleeja_admin_info(sprintf($lang['STYLE_NOW_IS_DEFAULT'], htmlspecialchars($style_id)), true, '', true, basename(ADMIN_PATH) . '?cp=' . (isset($_REQUEST['home']) ? 'start' : basename(__file__, '.php')));
|
||||
|
||||
}
|
||||
else if (ip('newstyle'))
|
||||
elseif (ip('newstyle'))
|
||||
{
|
||||
|
||||
if(intval($userinfo['founder']) !== 1)
|
||||
if (intval($userinfo['founder']) !== 1)
|
||||
{
|
||||
$ERRORS[] = $lang['HV_NOT_PRVLG_ACCESS'];
|
||||
}
|
||||
|
||||
|
||||
if(!kleeja_check_form_key('adm_styles'))
|
||||
if (! kleeja_check_form_key('adm_styles'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action);
|
||||
}
|
||||
|
||||
|
||||
$ERRORS = array();
|
||||
$ERRORS = [];
|
||||
|
||||
#is uploaded?
|
||||
if(empty($_FILES['style_file']['tmp_name']))
|
||||
//is uploaded?
|
||||
if (empty($_FILES['style_file']['tmp_name']))
|
||||
{
|
||||
$ERRORS[] = $lang['CHOSE_F'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
#extract it to plugins folder
|
||||
if(!sizeof($ERRORS))
|
||||
//extract it to plugins folder
|
||||
if (! sizeof($ERRORS))
|
||||
{
|
||||
if(class_exists('ZipArchive'))
|
||||
if (class_exists('ZipArchive'))
|
||||
{
|
||||
$zip = new ZipArchive;
|
||||
|
||||
if ($zip->open($_FILES['style_file']['tmp_name']) === true)
|
||||
{
|
||||
if(!$zip->extractTo(PATH . 'styles'))
|
||||
if (! $zip->extractTo(PATH . 'styles'))
|
||||
{
|
||||
$ERRORS[] = sprintf($lang['EXTRACT_ZIP_FAILED'], 'styles');
|
||||
}
|
||||
@@ -162,13 +162,13 @@ else if (ip('newstyle'))
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($_FILES['style_file']['tmp_name']))
|
||||
if (! empty($_FILES['style_file']['tmp_name']))
|
||||
{
|
||||
@unlink($_FILES['style_file']['tmp_name']);
|
||||
}
|
||||
|
||||
|
||||
if(!sizeof($ERRORS))
|
||||
if (! sizeof($ERRORS))
|
||||
{
|
||||
kleeja_admin_info($lang['NO_PROBLEM_AFTER_ZIP'], true, '', true, $action);
|
||||
}
|
||||
@@ -180,33 +180,34 @@ else if (ip('newstyle'))
|
||||
|
||||
|
||||
//get styles
|
||||
$arr = array();
|
||||
$arr = [];
|
||||
|
||||
if ($dh = @opendir(PATH . 'styles'))
|
||||
{
|
||||
while (false !== ($folder_name = readdir($dh)))
|
||||
{
|
||||
if (is_dir(PATH . 'styles/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
|
||||
if (is_dir(PATH . 'styles/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
|
||||
{
|
||||
|
||||
#info
|
||||
$style_info_arr = array
|
||||
(
|
||||
'name' => $folder_name,
|
||||
'desc' => '',
|
||||
//info
|
||||
$style_info_arr =
|
||||
[
|
||||
'name' => $folder_name,
|
||||
'desc' => '',
|
||||
'copyright'=> '',
|
||||
'version'=> ''
|
||||
);
|
||||
'version' => ''
|
||||
];
|
||||
|
||||
|
||||
if(($style_info = kleeja_style_info($folder_name)) != false)
|
||||
if (($style_info = kleeja_style_info($folder_name)) != false)
|
||||
{
|
||||
foreach (array('name', 'desc', 'copyright', 'version') as $InfoKey)
|
||||
foreach (['name', 'desc', 'copyright', 'version'] as $InfoKey)
|
||||
{
|
||||
if (array_key_exists($InfoKey, $style_info))
|
||||
{
|
||||
if(is_array($style_info[$InfoKey]))
|
||||
if (is_array($style_info[$InfoKey]))
|
||||
{
|
||||
$style_info_arr[$InfoKey] = !empty($style_info[$InfoKey][$config['language']])
|
||||
$style_info_arr[$InfoKey] = ! empty($style_info[$InfoKey][$config['language']])
|
||||
? htmlspecialchars($style_info[$InfoKey][$config['language']])
|
||||
: htmlspecialchars($style_info[$InfoKey]['en']);
|
||||
}
|
||||
@@ -218,16 +219,16 @@ if ($dh = @opendir(PATH . 'styles'))
|
||||
}
|
||||
}
|
||||
|
||||
$arr[] = array
|
||||
(
|
||||
'style_name' => $folder_name,
|
||||
'is_default' => $config['style'] == $folder_name ? true : false,
|
||||
$arr[] =
|
||||
[
|
||||
'style_name' => $folder_name,
|
||||
'is_default' => $config['style'] == $folder_name ? true : false,
|
||||
'link_mk_default' => basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&style_choose=' . $folder_name,
|
||||
'icon' => file_exists(PATH . 'styles/' . $folder_name . "/screenshot.png")
|
||||
? PATH . 'styles/' . $folder_name . "/screenshot.png"
|
||||
'icon' => file_exists(PATH . 'styles/' . $folder_name . '/screenshot.png')
|
||||
? PATH . 'styles/' . $folder_name . '/screenshot.png'
|
||||
: $STYLE_PATH_ADMIN . 'images/style.png',
|
||||
'info' => $style_info_arr
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,18 +7,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//for style ..
|
||||
$stylee = "admin_extra";
|
||||
$stylee = 'admin_extra';
|
||||
$current_smt= preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'he'));
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&smt=' . $current_smt;
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&smt=' . $current_smt;
|
||||
$H_FORM_KEYS= kleeja_add_form_key('adm_extra');
|
||||
|
||||
//
|
||||
@@ -26,19 +26,19 @@ $H_FORM_KEYS= kleeja_add_form_key('adm_extra');
|
||||
//
|
||||
if (ip('submit'))
|
||||
{
|
||||
if(!kleeja_check_form_key('adm_extra'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
if (! kleeja_check_form_key('adm_extra'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
|
||||
}
|
||||
}
|
||||
|
||||
$query = array(
|
||||
'SELECT' => 'ex_header,ex_footer',
|
||||
'FROM' => "{$dbprefix}stats"
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 'ex_header,ex_footer',
|
||||
'FROM' => "{$dbprefix}stats"
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
|
||||
//is there any change !
|
||||
$affected = false;
|
||||
|
||||
@@ -51,28 +51,28 @@ if (ip('submit'))
|
||||
$update_sql = '';
|
||||
|
||||
|
||||
if(g('smt') == 'fe')
|
||||
if (g('smt') == 'fe')
|
||||
{
|
||||
$ex_footer = p('ex_footer', 'str');
|
||||
$ex_footer = p('ex_footer', 'str');
|
||||
$update_sql = "ex_footer = '" . $SQL->real_escape(htmlspecialchars_decode($ex_footer)) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$ex_header = p('ex_header', 'str');
|
||||
$ex_header = p('ex_header', 'str');
|
||||
$update_sql = "ex_header = '" . $SQL->real_escape(htmlspecialchars_decode($ex_header)) . "'";
|
||||
}
|
||||
|
||||
|
||||
|
||||
//update
|
||||
$update_query = array(
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => $update_sql
|
||||
);
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => $update_sql
|
||||
];
|
||||
|
||||
$SQL->build($update_query);
|
||||
|
||||
if($SQL->affected())
|
||||
if ($SQL->affected())
|
||||
{
|
||||
$affected = true;
|
||||
//delete cache ..
|
||||
@@ -95,12 +95,12 @@ $SQL->freeresult($result);
|
||||
//after submit
|
||||
if (ip('submit'))
|
||||
{
|
||||
kleeja_admin_info(($affected ? $lang['EXTRA_UPDATED'] : $lang['NO_UP_CHANGE_S']), true, '', true, $action);
|
||||
kleeja_admin_info(($affected ? $lang['EXTRA_UPDATED'] : $lang['NO_UP_CHANGE_S']), true, '', true, $action);
|
||||
}
|
||||
|
||||
|
||||
//secondary menu
|
||||
$go_menu = array(
|
||||
'he' => array('name'=>$lang['ADD_HEADER_EXTRA'], 'link'=> basename(ADMIN_PATH) . '?cp=n_extra&smt=he', 'goto'=>'he', 'current'=> $current_smt == 'he'),
|
||||
'fe' => array('name'=>$lang['ADD_FOOTER_EXTRA'], 'link'=> basename(ADMIN_PATH) . '?cp=n_extra&smt=fe', 'goto'=>'fe', 'current'=> $current_smt == 'fe'),
|
||||
);
|
||||
$go_menu = [
|
||||
'he' => ['name'=>$lang['ADD_HEADER_EXTRA'], 'link'=> basename(ADMIN_PATH) . '?cp=n_extra&smt=he', 'goto'=>'he', 'current'=> $current_smt == 'he'],
|
||||
'fe' => ['name'=>$lang['ADD_FOOTER_EXTRA'], 'link'=> basename(ADMIN_PATH) . '?cp=n_extra&smt=fe', 'goto'=>'fe', 'current'=> $current_smt == 'fe'],
|
||||
];
|
||||
|
||||
@@ -8,95 +8,95 @@
|
||||
*/
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
$stylee = "admin_check_update";
|
||||
$stylee = 'admin_check_update';
|
||||
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
|
||||
$update_link = $config['siteurl'] . 'install/update.php?lang=' . $config['language'];
|
||||
|
||||
#to prevent getting the url data for all cats
|
||||
if($current_smt == 'check'):
|
||||
//to prevent getting the url data for all cats
|
||||
if ($current_smt == 'check'):
|
||||
|
||||
//get data from kleeja github repo
|
||||
if (! ($version_data = $cache->get('kleeja_repo_version')))
|
||||
{
|
||||
$github_data = fetch_remote_file('https://raw.githubusercontent.com/awssat/kleeja/master/includes/version.php', false, 6);
|
||||
//get data from kleeja github repo
|
||||
if (! ($version_data = $cache->get('kleeja_repo_version')))
|
||||
{
|
||||
$github_data = fetch_remote_file('https://raw.githubusercontent.com/awssat/kleeja/master/includes/version.php', false, 6);
|
||||
|
||||
if (! empty($github_data))
|
||||
{
|
||||
preg_match_all('/define\(\'KLEEJA_VERSION\',\s{1,4}\'([^\']+)\'\);/', $github_data, $matches, PREG_SET_ORDER, 0);
|
||||
$version_data = trim(htmlspecialchars($matches[0][1]));
|
||||
$cache->save('kleeja_repo_version', $version_data, 3600 * 2);
|
||||
}
|
||||
}
|
||||
if (! empty($github_data))
|
||||
{
|
||||
preg_match_all('/define\(\'KLEEJA_VERSION\',\s{1,4}\'([^\']+)\'\);/', $github_data, $matches, PREG_SET_ORDER, 0);
|
||||
$version_data = trim(htmlspecialchars($matches[0][1]));
|
||||
$cache->save('kleeja_repo_version', $version_data, 3600 * 2);
|
||||
}
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
$error = 0;
|
||||
|
||||
if(empty($version_data))
|
||||
{
|
||||
$text = $lang['ERROR_CHECK_VER'];
|
||||
$error = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '<'))
|
||||
{
|
||||
$text = sprintf($lang['UPDATE_NOW_S'] , KLEEJA_VERSION, strtolower($version_data)) . '<br /><br />' . $lang['UPDATE_KLJ_NOW'];
|
||||
$error = 1;
|
||||
}
|
||||
else if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '='))
|
||||
{
|
||||
$text = $lang['U_LAST_VER_KLJ'];
|
||||
}
|
||||
else if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '>'))
|
||||
{
|
||||
$text = $lang['U_USE_PRE_RE'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = $lang['ERROR_CHECK_VER'] . ' [code: ' . htmlspecialchars($version_data) .']';
|
||||
}
|
||||
}
|
||||
if (empty($version_data))
|
||||
{
|
||||
$text = $lang['ERROR_CHECK_VER'];
|
||||
$error = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '<'))
|
||||
{
|
||||
$text = sprintf($lang['UPDATE_NOW_S'], KLEEJA_VERSION, strtolower($version_data)) . '<br /><br />' . $lang['UPDATE_KLJ_NOW'];
|
||||
$error = 1;
|
||||
}
|
||||
elseif (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '='))
|
||||
{
|
||||
$text = $lang['U_LAST_VER_KLJ'];
|
||||
}
|
||||
elseif (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '>'))
|
||||
{
|
||||
$text = $lang['U_USE_PRE_RE'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = $lang['ERROR_CHECK_VER'] . ' [code: ' . htmlspecialchars($version_data) . ']';
|
||||
}
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'version_number' => $version_data,
|
||||
'last_check' => time()
|
||||
);
|
||||
$data = [
|
||||
'version_number' => $version_data,
|
||||
'last_check' => time()
|
||||
];
|
||||
|
||||
$data = serialize($data);
|
||||
|
||||
update_config('new_version', $SQL->real_escape($data), false);
|
||||
delete_cache('data_config');
|
||||
|
||||
$adminAjaxContent = $error . ':::' . $text;
|
||||
$adminAjaxContent = $error . ':::' . $text;
|
||||
|
||||
elseif($current_smt == 'general'):
|
||||
elseif ($current_smt == 'general'):
|
||||
|
||||
// if(!$error)
|
||||
// {
|
||||
|
||||
|
||||
|
||||
//To prevent expected error [ infinit loop ]
|
||||
if(ig('show_msg'))
|
||||
{
|
||||
$query_get = array(
|
||||
'SELECT' => '*',
|
||||
'FROM' => "{$dbprefix}config",
|
||||
'WHERE' => "name = 'new_version'"
|
||||
);
|
||||
//To prevent expected error [ infinit loop ]
|
||||
if (ig('show_msg'))
|
||||
{
|
||||
$query_get = [
|
||||
'SELECT' => '*',
|
||||
'FROM' => "{$dbprefix}config",
|
||||
'WHERE' => "name = 'new_version'"
|
||||
];
|
||||
|
||||
$result_get = $SQL->build($query_get);
|
||||
$result_get = $SQL->build($query_get);
|
||||
|
||||
if(!$SQL->num_rows($result_get))
|
||||
{
|
||||
//add new config value
|
||||
add_config('new_version', '');
|
||||
}
|
||||
}
|
||||
if (! $SQL->num_rows($result_get))
|
||||
{
|
||||
//add new config value
|
||||
add_config('new_version', '');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// }
|
||||
@@ -104,12 +104,12 @@ elseif($current_smt == 'general'):
|
||||
$showMessage = ig('show_msg');
|
||||
|
||||
|
||||
#end current_smt == general
|
||||
//end current_smt == general
|
||||
endif;
|
||||
|
||||
//secondary menu
|
||||
$go_menu = array(
|
||||
'general' => array('name'=>$lang['R_CHECK_UPDATE'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'),
|
||||
'howto' => array('name'=>$lang['HOW_UPDATE_KLEEJA'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&smt=howto', 'goto'=>'howto', 'current'=> $current_smt == 'howto'),
|
||||
'site' => array('name'=>'Kleeja.com', 'link'=> 'http://www.kleeja.com', 'goto'=>'site', 'current'=> $current_smt == 'site'),
|
||||
);
|
||||
$go_menu = [
|
||||
'general' => ['name'=>$lang['R_CHECK_UPDATE'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'],
|
||||
'howto' => ['name'=>$lang['HOW_UPDATE_KLEEJA'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&smt=howto', 'goto'=>'howto', 'current'=> $current_smt == 'howto'],
|
||||
'site' => ['name'=>'Kleeja.com', 'link'=> 'http://www.kleeja.com', 'goto'=>'site', 'current'=> $current_smt == 'site'],
|
||||
];
|
||||
|
||||
@@ -9,58 +9,59 @@
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
#turn time-limit off
|
||||
//turn time-limit off
|
||||
@set_time_limit(0);
|
||||
|
||||
#get current case
|
||||
//get current case
|
||||
$case = false;
|
||||
if(ig('case'))
|
||||
|
||||
if (ig('case'))
|
||||
{
|
||||
$case = g('case');
|
||||
$case = g('case');
|
||||
}
|
||||
|
||||
|
||||
#set form ket
|
||||
//set form ket
|
||||
$GET_FORM_KEY = kleeja_add_form_key_get('REPAIR_FORM_KEY');
|
||||
|
||||
|
||||
//check _GET Csrf token
|
||||
if($case && in_array($case, array('clearc', 'sync_files', 'sync_images', 'sync_users', 'tables', 'sync_sizes', 'status_file')))
|
||||
if ($case && in_array($case, ['clearc', 'sync_files', 'sync_images', 'sync_users', 'tables', 'sync_sizes', 'status_file']))
|
||||
{
|
||||
if(!kleeja_check_form_key_get('REPAIR_FORM_KEY'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH), 2);
|
||||
}
|
||||
if (! kleeja_check_form_key_get('REPAIR_FORM_KEY'))
|
||||
{
|
||||
kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH), 2);
|
||||
}
|
||||
}
|
||||
|
||||
switch($case):
|
||||
switch ($case):
|
||||
|
||||
default:
|
||||
|
||||
# Get real number from database right now
|
||||
$all_files = get_actual_stats('files');
|
||||
// Get real number from database right now
|
||||
$all_files = get_actual_stats('files');
|
||||
$all_images = get_actual_stats('imgs');
|
||||
$all_users = get_actual_stats('users');
|
||||
$all_sizes = readable_size(get_actual_stats('sizes'));
|
||||
$all_users = get_actual_stats('users');
|
||||
$all_sizes = readable_size(get_actual_stats('sizes'));
|
||||
|
||||
|
||||
#links
|
||||
$del_cache_link = basename(ADMIN_PATH) . '?cp=r_repair&case=clearc&' . $GET_FORM_KEY;
|
||||
$resync_files_link = $config['siteurl'] . 'go.php?go=resync&case=sync_files';
|
||||
//links
|
||||
$del_cache_link = basename(ADMIN_PATH) . '?cp=r_repair&case=clearc&' . $GET_FORM_KEY;
|
||||
$resync_files_link = $config['siteurl'] . 'go.php?go=resync&case=sync_files';
|
||||
$resync_images_link = $config['siteurl'] . 'go.php?go=resync&case=sync_images';
|
||||
$resync_users_link = basename(ADMIN_PATH) . '?cp=r_repair&case=sync_users&' . $GET_FORM_KEY;
|
||||
$resync_sizes_link = basename(ADMIN_PATH) . '?cp=r_repair&case=sync_sizes&' . $GET_FORM_KEY;
|
||||
$resync_users_link = basename(ADMIN_PATH) . '?cp=r_repair&case=sync_users&' . $GET_FORM_KEY;
|
||||
$resync_sizes_link = basename(ADMIN_PATH) . '?cp=r_repair&case=sync_sizes&' . $GET_FORM_KEY;
|
||||
$repair_tables_link = basename(ADMIN_PATH) . '?cp=r_repair&case=tables&' . $GET_FORM_KEY;
|
||||
|
||||
$queue_cron_job_url = $config['siteurl'] . 'go.php?go=queue';
|
||||
|
||||
$stylee = "admin_repair";
|
||||
$stylee = 'admin_repair';
|
||||
|
||||
break;
|
||||
|
||||
@@ -70,23 +71,24 @@ break;
|
||||
//
|
||||
case 'tables':
|
||||
|
||||
$query = "SHOW TABLE STATUS";
|
||||
$query = 'SHOW TABLE STATUS';
|
||||
$result = $SQL->query($query);
|
||||
$text = '';
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
$text = '';
|
||||
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$queryf = "REPAIR TABLE `" . $row['Name'] . "`";
|
||||
$resultf = $SQL->query($queryf);
|
||||
if ($resultf)
|
||||
{
|
||||
$text .= '<li>' . $lang['REPAIRE_TABLE'] . $row['Name'] . '</li>';
|
||||
}
|
||||
$queryf = 'REPAIR TABLE `' . $row['Name'] . '`';
|
||||
$resultf = $SQL->query($queryf);
|
||||
|
||||
if ($resultf)
|
||||
{
|
||||
$text .= '<li>' . $lang['REPAIRE_TABLE'] . $row['Name'] . '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$SQL->freeresult($result);
|
||||
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
|
||||
$stylee = 'admin_info';
|
||||
|
||||
|
||||
@@ -98,31 +100,31 @@ break;
|
||||
case 'sync_sizes':
|
||||
|
||||
|
||||
$query_s = array(
|
||||
'SELECT' => 'size',
|
||||
'FROM' => "{$dbprefix}files"
|
||||
);
|
||||
$query_s = [
|
||||
'SELECT' => 'size',
|
||||
'FROM' => "{$dbprefix}files"
|
||||
];
|
||||
|
||||
$result_s = $SQL->build($query_s);
|
||||
|
||||
$files_number = $files_sizes = 0;
|
||||
|
||||
while($row=$SQL->fetch_array($result_s))
|
||||
while ($row=$SQL->fetch_array($result_s))
|
||||
{
|
||||
$files_number++;
|
||||
$files_sizes = $files_sizes+$row['size'];
|
||||
$files_number++;
|
||||
$files_sizes = $files_sizes+$row['size'];
|
||||
}
|
||||
|
||||
$SQL->freeresult($result_s);
|
||||
|
||||
$update_query = array(
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "files=" . $files_number . ", sizes=" . $files_sizes
|
||||
);
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => 'files=' . $files_number . ', sizes=' . $files_sizes
|
||||
];
|
||||
|
||||
if ($SQL->build($update_query))
|
||||
{
|
||||
$text .= '<li>' . $lang['REPAIRE_F_STAT'] . '</li>';
|
||||
$text .= '<li>' . $lang['REPAIRE_F_STAT'] . '</li>';
|
||||
}
|
||||
|
||||
delete_cache('data_stats');
|
||||
@@ -137,31 +139,31 @@ break;
|
||||
//
|
||||
case 'sync_users':
|
||||
|
||||
$query_w = array(
|
||||
'SELECT' => 'name',
|
||||
'FROM' => "{$dbprefix}users"
|
||||
);
|
||||
$query_w = [
|
||||
'SELECT' => 'name',
|
||||
'FROM' => "{$dbprefix}users"
|
||||
];
|
||||
|
||||
$result_w = $SQL->build($query_w);
|
||||
|
||||
|
||||
$user_number = 0;
|
||||
while($row=$SQL->fetch_array($result_w))
|
||||
while ($row=$SQL->fetch_array($result_w))
|
||||
{
|
||||
$user_number++;
|
||||
$user_number++;
|
||||
}
|
||||
|
||||
|
||||
$SQL->freeresult($result_w);
|
||||
|
||||
$update_query = array(
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => "users=" . $user_number
|
||||
);
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => 'users=' . $user_number
|
||||
];
|
||||
|
||||
$result = $SQL->build($update_query);
|
||||
|
||||
delete_cache('data_stats');
|
||||
$text = sprintf($lang['SYNCING'], $lang['USERS_ST']);
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
|
||||
|
||||
$stylee = 'admin_info';
|
||||
|
||||
@@ -174,12 +176,12 @@ break;
|
||||
//
|
||||
case 'clearc':
|
||||
|
||||
#clear cache
|
||||
//clear cache
|
||||
delete_cache('', true);
|
||||
|
||||
#show done, msg
|
||||
//show done, msg
|
||||
$text .= '<li>' . $lang['REPAIRE_CACHE'] . '</li>';
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
|
||||
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
|
||||
|
||||
$stylee = 'admin_info';
|
||||
|
||||
@@ -188,41 +190,37 @@ break;
|
||||
//toggle admin start boxes
|
||||
case 'toggle_start_box':
|
||||
|
||||
if(! kleeja_check_form_key_get('adm_start_actions', 3600))
|
||||
{
|
||||
header('HTTP/1.1 405 Method Not Allowed');
|
||||
$adminAjaxContent = $lang['INVALID_FORM_KEY'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$items = explode(':', $config['hidden_start_boxes']);
|
||||
$items = array_filter($items);
|
||||
if (! kleeja_check_form_key_get('adm_start_actions', 3600))
|
||||
{
|
||||
header('HTTP/1.1 405 Method Not Allowed');
|
||||
$adminAjaxContent = $lang['INVALID_FORM_KEY'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$items = explode(':', $config['hidden_start_boxes']);
|
||||
$items = array_filter($items);
|
||||
|
||||
$name = g('name');
|
||||
$hide = g('toggle', 'int') == 1;
|
||||
|
||||
if(in_array($name, $items) && ! $hide)
|
||||
{
|
||||
$new_items = array_diff($items, [$name]);
|
||||
}
|
||||
else if($hide)
|
||||
{
|
||||
$new_items = $items;
|
||||
$new_items[] = $name;
|
||||
}
|
||||
$name = g('name');
|
||||
$hide = g('toggle', 'int') == 1;
|
||||
|
||||
if (in_array($name, $items) && ! $hide)
|
||||
{
|
||||
$new_items = array_diff($items, [$name]);
|
||||
}
|
||||
elseif ($hide)
|
||||
{
|
||||
$new_items = $items;
|
||||
$new_items[] = $name;
|
||||
}
|
||||
|
||||
if ($new_items != $items)
|
||||
{
|
||||
update_config('hidden_start_boxes', implode(':', $new_items));
|
||||
}
|
||||
|
||||
$adminAjaxContent = $lang['CONFIGS_UPDATED'];
|
||||
}
|
||||
|
||||
if($new_items != $items)
|
||||
{
|
||||
update_config('hidden_start_boxes', implode(':', $new_items));
|
||||
}
|
||||
|
||||
$adminAjaxContent = $lang['CONFIGS_UPDATED'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
endswitch;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,51 +9,51 @@
|
||||
|
||||
|
||||
// not for directly open
|
||||
if (!defined('IN_ADMIN'))
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
//style of
|
||||
$stylee = "admin_start";
|
||||
$h_lst_files = basename(ADMIN_PATH) . '?cp=c_files&last_visit=';
|
||||
$h_lst_imgs = basename(ADMIN_PATH) . '?cp=d_img_ctrl&last_visit=';
|
||||
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
|
||||
$stylee = 'admin_start';
|
||||
$h_lst_files = basename(ADMIN_PATH) . '?cp=c_files&last_visit=';
|
||||
$h_lst_imgs = basename(ADMIN_PATH) . '?cp=d_img_ctrl&last_visit=';
|
||||
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
|
||||
$GET_FORM_KEY = kleeja_add_form_key_get('adm_start_actions');
|
||||
|
||||
//data
|
||||
$lst_reg = empty($stat_last_user) ? $lang['UNKNOWN'] : $stat_last_user;
|
||||
$files_number = $stat_files + $stat_imgs;
|
||||
$files_sizes = readable_size($stat_sizes);
|
||||
$users_number = $stat_users;
|
||||
$last_del_fles = (int) $config['del_f_day'] <= 0 ? $lang['CLOSED_FEATURE'] : kleeja_date($stat_last_f_del);
|
||||
$php_version = isset($NO_PHPINFO) || !function_exists('phpinfo') ? phpversion() : 'PHP ' . phpversion();
|
||||
$mysql_version = 'MySQL ' . $SQL->mysql_version();
|
||||
$lst_reg = empty($stat_last_user) ? $lang['UNKNOWN'] : $stat_last_user;
|
||||
$files_number = $stat_files + $stat_imgs;
|
||||
$files_sizes = readable_size($stat_sizes);
|
||||
$users_number = $stat_users;
|
||||
$last_del_fles = (int) $config['del_f_day'] <= 0 ? $lang['CLOSED_FEATURE'] : kleeja_date($stat_last_f_del);
|
||||
$php_version = isset($NO_PHPINFO) || ! function_exists('phpinfo') ? phpversion() : 'PHP ' . phpversion();
|
||||
$mysql_version = 'MySQL ' . $SQL->mysql_version();
|
||||
$max_execution_time = function_exists('ini_get') ? @ini_get('max_execution_time') : @get_cfg_var('max_execution_time');
|
||||
$upload_max_filesize= function_exists('ini_get') ? @ini_get('upload_max_filesize') : @get_cfg_var('upload_max_filesize');
|
||||
$post_max_size = function_exists('ini_get') ? @ini_get('post_max_size') : @get_cfg_var('post_max_size');
|
||||
$memory_limit = function_exists('ini_get') ? @ini_get('memory_limit') : @get_cfg_var('memory_limit');
|
||||
$s_last_google = $stat_last_google == 0 ? '[ ? ]' : kleeja_date($stat_last_google);
|
||||
$s_google_num = $stat_google_num;
|
||||
$s_last_bing = $stat_last_bing == 0 ? '[ ? ]' : kleeja_date($stat_last_bing);
|
||||
$s_bing_num = $stat_bing_num;
|
||||
$usernamelang = sprintf($lang['KLEEJA_CP_W'], $username);
|
||||
$current_year = date('Y');
|
||||
$post_max_size = function_exists('ini_get') ? @ini_get('post_max_size') : @get_cfg_var('post_max_size');
|
||||
$memory_limit = function_exists('ini_get') ? @ini_get('memory_limit') : @get_cfg_var('memory_limit');
|
||||
$s_last_google = $stat_last_google == 0 ? '[ ? ]' : kleeja_date($stat_last_google);
|
||||
$s_google_num = $stat_google_num;
|
||||
$s_last_bing = $stat_last_bing == 0 ? '[ ? ]' : kleeja_date($stat_last_bing);
|
||||
$s_bing_num = $stat_bing_num;
|
||||
$usernamelang = sprintf($lang['KLEEJA_CP_W'], $username);
|
||||
$current_year = date('Y');
|
||||
|
||||
$startBoxes = array(
|
||||
'notifications' => array('title' => $lang['NOTIFICATIONS'], 'hidden' => (int) adm_is_start_box_hidden('notifications')),
|
||||
'statsBoxes' => array('title' => $lang['STATS_BOXES'], 'hidden' => (int) adm_is_start_box_hidden('statsBoxes')),
|
||||
'lastVisitActions' => array('title' => $lang['LAST_VISIT'], 'hidden' => (int) adm_is_start_box_hidden('lastVisitActions')),
|
||||
'statsChart' => array('title' => $lang['STATS'], 'hidden' => (int) adm_is_start_box_hidden('statsChart')),
|
||||
'hurryActions' => array('title' => $lang['HURRY_HURRY'], 'hidden' => (int) adm_is_start_box_hidden('hurryActions')),
|
||||
'extraStats' => array('title' => $lang['OTHER_INFO'], 'hidden' => (int) adm_is_start_box_hidden('extraStats')),
|
||||
);
|
||||
$startBoxes = [
|
||||
'notifications' => ['title' => $lang['NOTIFICATIONS'], 'hidden' => (int) adm_is_start_box_hidden('notifications')],
|
||||
'statsBoxes' => ['title' => $lang['STATS_BOXES'], 'hidden' => (int) adm_is_start_box_hidden('statsBoxes')],
|
||||
'lastVisitActions' => ['title' => $lang['LAST_VISIT'], 'hidden' => (int) adm_is_start_box_hidden('lastVisitActions')],
|
||||
'statsChart' => ['title' => $lang['STATS'], 'hidden' => (int) adm_is_start_box_hidden('statsChart')],
|
||||
'hurryActions' => ['title' => $lang['HURRY_HURRY'], 'hidden' => (int) adm_is_start_box_hidden('hurryActions')],
|
||||
'extraStats' => ['title' => $lang['OTHER_INFO'], 'hidden' => (int) adm_is_start_box_hidden('extraStats')],
|
||||
];
|
||||
|
||||
$extra_adm_start_html = '';
|
||||
|
||||
//size board by percent
|
||||
$per = $stat_sizes / ($config['total_size'] * 1048576);
|
||||
$per = $stat_sizes / ($config['total_size'] * 1048576);
|
||||
$per1 = round($per*100, 2);
|
||||
$per1 = $per1 >= 100 ? 100 : $per1;
|
||||
|
||||
@@ -61,38 +61,40 @@ $per1 = $per1 >= 100 ? 100 : $per1;
|
||||
$kleeja_version = '<a href="' . basename(ADMIN_PATH) . '?cp=p_check_update" onclick="javascript:get_kleeja_link(this.href, \'#content\'); return false;" title="' . $lang['R_CHECK_UPDATE'] . '">' . KLEEJA_VERSION . '</a>';
|
||||
|
||||
//admin messages system
|
||||
$ADM_NOTIFICATIONS = array();
|
||||
$ADM_NOTIFICATIONS = [];
|
||||
|
||||
//useing IE6 ! and he is admin ? omg !
|
||||
$u_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? htmlspecialchars((string) strtolower($_SERVER['HTTP_USER_AGENT'])) : (function_exists('getenv') ? getenv('HTTP_USER_AGENT') : '');
|
||||
if(is_browser('ie6, ie8, ie7'))
|
||||
$u_agent = ! empty($_SERVER['HTTP_USER_AGENT']) ? htmlspecialchars((string) strtolower($_SERVER['HTTP_USER_AGENT'])) : (function_exists('getenv') ? getenv('HTTP_USER_AGENT') : '');
|
||||
|
||||
if (is_browser('ie6, ie8, ie7'))
|
||||
{
|
||||
$ADM_NOTIFICATIONS['IE6'] = array('id' => 'IE6', 'msg_type'=> 'error', 'title'=> $lang['NOTE'], 'msg'=> $lang['ADMIN_USING_IE6']);
|
||||
$ADM_NOTIFICATIONS['IE6'] = ['id' => 'IE6', 'msg_type'=> 'error', 'title'=> $lang['NOTE'], 'msg'=> $lang['ADMIN_USING_IE6']];
|
||||
}
|
||||
|
||||
//if upgrading from 1rc6 to 1.0, some files must be deleted !
|
||||
if(file_exists(PATH . 'includes/adm/files.php') || file_exists(PATH . 'admin.php'))
|
||||
if (file_exists(PATH . 'includes/adm/files.php') || file_exists(PATH . 'admin.php'))
|
||||
{
|
||||
$ADM_NOTIFICATIONS['old_files'] = array('id' => 'old_files', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['ADM_UNWANTED_FILES']);
|
||||
$ADM_NOTIFICATIONS['old_files'] = ['id' => 'old_files', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['ADM_UNWANTED_FILES']];
|
||||
}
|
||||
|
||||
//if html url is enabled but .htaccess is not available in the root dir !
|
||||
if(!file_exists(PATH . '.htaccess') && (int) $config['mod_writer'] == 1)
|
||||
if (! file_exists(PATH . '.htaccess') && (int) $config['mod_writer'] == 1)
|
||||
{
|
||||
$ADM_NOTIFICATIONS['htmlurlshtaccess'] = array('id' => 'htmlurlshtaccess', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['HTML_URLS_ENABLED_NO_HTCC']);
|
||||
$ADM_NOTIFICATIONS['htmlurlshtaccess'] = ['id' => 'htmlurlshtaccess', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['HTML_URLS_ENABLED_NO_HTCC']];
|
||||
}
|
||||
|
||||
//updating
|
||||
$v = @unserialize($config['new_version']);
|
||||
if(version_compare(strtolower(KLEEJA_VERSION), strtolower($v['version_number']), '<'))
|
||||
{
|
||||
$ADM_NOTIFICATIONS['up_ver_klj'] = array(
|
||||
'id' => 'up_ver_klj',//this not so important row
|
||||
'msg_type'=> 'error', 'title'=> $lang['R_CHECK_UPDATE'],
|
||||
'msg'=> sprintf($lang['UPDATE_NOW_S'] , KLEEJA_VERSION, $v['version_number']) . '<br />' . '<a href="http://www.kleeja.com/">www.kleeja.com</a>'
|
||||
);
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('admin_update_now', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
if (version_compare(strtolower(KLEEJA_VERSION), strtolower($v['version_number']), '<'))
|
||||
{
|
||||
$ADM_NOTIFICATIONS['up_ver_klj'] = [
|
||||
'id' => 'up_ver_klj',//this not so important row
|
||||
'msg_type'=> 'error', 'title'=> $lang['R_CHECK_UPDATE'],
|
||||
'msg' => sprintf($lang['UPDATE_NOW_S'], KLEEJA_VERSION, $v['version_number']) . '<br />' . '<a href="http://www.kleeja.com/">www.kleeja.com</a>'
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('admin_update_now', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
}
|
||||
|
||||
|
||||
@@ -101,18 +103,18 @@ is_array($plugin_run_result = Plugins::getInstance()->run('default_admin_page',
|
||||
|
||||
|
||||
//check upload_max_filesize
|
||||
if(!empty($d_groups) && is_array($d_groups))
|
||||
if (! empty($d_groups) && is_array($d_groups))
|
||||
{
|
||||
$biggest_size = 0;
|
||||
|
||||
foreach($d_groups as $gid => $gdata)
|
||||
foreach ($d_groups as $gid => $gdata)
|
||||
{
|
||||
if(!empty($d_groups[$gid]['exts']) && is_array($d_groups[$gid]['exts']))
|
||||
if (! empty($d_groups[$gid]['exts']) && is_array($d_groups[$gid]['exts']))
|
||||
{
|
||||
$u_e_s = $d_groups[$gid]['exts'];
|
||||
arsort($u_e_s);
|
||||
|
||||
if(!empty($u_e_s))
|
||||
if (! empty($u_e_s))
|
||||
{
|
||||
$current_size = array_shift($u_e_s);
|
||||
$biggest_size = $current_size > $biggest_size ? $current_size : $biggest_size;
|
||||
@@ -121,50 +123,53 @@ if(!empty($d_groups) && is_array($d_groups))
|
||||
}
|
||||
|
||||
|
||||
if(strpos($upload_max_filesize, 'M') !== false)
|
||||
{
|
||||
$upload_max_filesize_s = ((int) trim(str_replace('M', '', $upload_max_filesize))) * 1048576;
|
||||
}
|
||||
else if(strpos($upload_max_filesize, 'G') !== false)
|
||||
{
|
||||
$upload_max_filesize_s = ((int) trim(str_replace('G', '', $upload_max_filesize))) * 1073741824;
|
||||
}else{
|
||||
if (strpos($upload_max_filesize, 'M') !== false)
|
||||
{
|
||||
$upload_max_filesize_s = ((int) trim(str_replace('M', '', $upload_max_filesize))) * 1048576;
|
||||
}
|
||||
elseif (strpos($upload_max_filesize, 'G') !== false)
|
||||
{
|
||||
$upload_max_filesize_s = ((int) trim(str_replace('G', '', $upload_max_filesize))) * 1073741824;
|
||||
}
|
||||
else
|
||||
{
|
||||
$upload_max_filesize_s = $upload_max_filesize;
|
||||
}
|
||||
|
||||
|
||||
if(!empty($upload_max_filesize) && $upload_max_filesize_s < $biggest_size)
|
||||
{
|
||||
$ADM_NOTIFICATIONS['file_size_ini_low'] = array(
|
||||
'id' => 'file_size_ini_low',
|
||||
'msg_type'=> 'info', 'title'=> $lang['NOTE'],
|
||||
'msg'=> sprintf($lang['PHPINI_FILESIZE_SMALL'] , readable_size($biggest_size), readable_size($upload_max_filesize_s))
|
||||
);
|
||||
}
|
||||
if (! empty($upload_max_filesize) && $upload_max_filesize_s < $biggest_size)
|
||||
{
|
||||
$ADM_NOTIFICATIONS['file_size_ini_low'] = [
|
||||
'id' => 'file_size_ini_low',
|
||||
'msg_type'=> 'info', 'title'=> $lang['NOTE'],
|
||||
'msg' => sprintf($lang['PHPINI_FILESIZE_SMALL'], readable_size($biggest_size), readable_size($upload_max_filesize_s))
|
||||
];
|
||||
}
|
||||
|
||||
//check post_max_size
|
||||
if(strpos($post_max_size, 'M') !== false)
|
||||
{
|
||||
$post_max_size_s = ((int) trim(str_replace('M', '', $post_max_size))) * 1048576;
|
||||
}
|
||||
else if(strpos($post_max_size, 'G') !== false)
|
||||
{
|
||||
$post_max_size_s = ((int) trim(str_replace('G', '', $post_max_size))) * 1073741824;
|
||||
}else
|
||||
//check post_max_size
|
||||
if (strpos($post_max_size, 'M') !== false)
|
||||
{
|
||||
$post_max_size_s = ((int) trim(str_replace('M', '', $post_max_size))) * 1048576;
|
||||
}
|
||||
elseif (strpos($post_max_size, 'G') !== false)
|
||||
{
|
||||
$post_max_size_s = ((int) trim(str_replace('G', '', $post_max_size))) * 1073741824;
|
||||
}
|
||||
else
|
||||
{
|
||||
$post_max_size_s = $post_max_size;
|
||||
}
|
||||
|
||||
$post_max_size_s_must_be = ($config['filesnum'] * $biggest_size) + 5242880;//+ 5 mega to make sure it's ok
|
||||
$post_max_size_s_must_be = ($config['filesnum'] * $biggest_size) + 5242880;//+ 5 mega to make sure it's ok
|
||||
|
||||
if(!empty($post_max_size) && $post_max_size_s < $post_max_size_s_must_be)
|
||||
{
|
||||
$ADM_NOTIFICATIONS['post_m_size_ini_low'] = array(
|
||||
'id' => 'post_m_size_ini_low',
|
||||
'msg_type'=> 'info', 'title'=> $lang['NOTE'],
|
||||
'msg'=> sprintf($lang['PHPINI_MPOSTSIZE_SMALL'] , $config['filesnum'], readable_size($post_max_size_s_must_be))
|
||||
);
|
||||
}
|
||||
if (! empty($post_max_size) && $post_max_size_s < $post_max_size_s_must_be)
|
||||
{
|
||||
$ADM_NOTIFICATIONS['post_m_size_ini_low'] = [
|
||||
'id' => 'post_m_size_ini_low',
|
||||
'msg_type'=> 'info', 'title'=> $lang['NOTE'],
|
||||
'msg' => sprintf($lang['PHPINI_MPOSTSIZE_SMALL'], $config['filesnum'], readable_size($post_max_size_s_must_be))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -172,44 +177,46 @@ if(!empty($d_groups) && is_array($d_groups))
|
||||
// rev: let's say cache is not refreshed, so we will redirect alots of time,
|
||||
// so update_done will be good solution
|
||||
//
|
||||
if (empty($v['last_check']) || ((time() - $v['last_check']) > 3600 * 24 * 10 && $_SERVER['SERVER_NAME'] != 'localhost' && !ig('update_done')))
|
||||
if (empty($v['last_check']) || ((time() - $v['last_check']) > 3600 * 24 * 10 && $_SERVER['SERVER_NAME'] != 'localhost' && ! ig('update_done')))
|
||||
{
|
||||
redirect(basename(ADMIN_PATH) . '?cp=p_check_update&show_msg=1');
|
||||
$SQL->close();
|
||||
exit;
|
||||
redirect(basename(ADMIN_PATH) . '?cp=p_check_update&show_msg=1');
|
||||
$SQL->close();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
//if config not safe
|
||||
if(function_exists('fileperms') && !defined('KLEEJA_NO_CONFIG_CHECK') && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' && !@ini_get('safe_mode'))
|
||||
if (function_exists('fileperms') && ! defined('KLEEJA_NO_CONFIG_CHECK') && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' && ! @ini_get('safe_mode'))
|
||||
{
|
||||
if((bool) (@fileperms(PATH . KLEEJA_CONFIG_FILE) & 0x0002))
|
||||
{
|
||||
$ADM_NOTIFICATIONS['config_perm'] = array('id' => 'config_perm', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['CONFIG_WRITEABLE']);
|
||||
}
|
||||
if ((bool) (@fileperms(PATH . KLEEJA_CONFIG_FILE) & 0x0002))
|
||||
{
|
||||
$ADM_NOTIFICATIONS['config_perm'] = ['id' => 'config_perm', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['CONFIG_WRITEABLE']];
|
||||
}
|
||||
}
|
||||
|
||||
//no htaccess
|
||||
if(!file_exists(PATH . $config['foldername'] . '/.htaccess'))
|
||||
if (! file_exists(PATH . $config['foldername'] . '/.htaccess'))
|
||||
{
|
||||
$ADM_NOTIFICATIONS['htaccess_u'] = array('id' => 'htaccess_u', 'msg_type'=> 'error', 'title'=> $lang['WARN'], 'msg'=> sprintf($lang['NO_HTACCESS_DIR_UP'], $config['foldername']));
|
||||
$ADM_NOTIFICATIONS['htaccess_u'] = ['id' => 'htaccess_u', 'msg_type'=> 'error', 'title'=> $lang['WARN'], 'msg'=> sprintf($lang['NO_HTACCESS_DIR_UP'], $config['foldername'])];
|
||||
}
|
||||
if(!file_exists(PATH . $config['foldername'] . '/thumbs/.htaccess'))
|
||||
|
||||
if (! file_exists(PATH . $config['foldername'] . '/thumbs/.htaccess'))
|
||||
{
|
||||
$ADM_NOTIFICATIONS['htaccess_t'] = array('id' => 'htaccess_t', 'msg_type'=> 'error', 'title'=> $lang['WARN'], 'msg'=> sprintf($lang['NO_HTACCESS_DIR_UP_THUMB'], $config['foldername'] . '/thumbs'));
|
||||
$ADM_NOTIFICATIONS['htaccess_t'] = ['id' => 'htaccess_t', 'msg_type'=> 'error', 'title'=> $lang['WARN'], 'msg'=> sprintf($lang['NO_HTACCESS_DIR_UP_THUMB'], $config['foldername'] . '/thumbs')];
|
||||
}
|
||||
|
||||
|
||||
//there is cleaning files process now
|
||||
if((int)$config['klj_clean_files_from'] > 0)
|
||||
if ((int) $config['klj_clean_files_from'] > 0)
|
||||
{
|
||||
$ADM_NOTIFICATIONS['klj_clean_files'] = array('id' => 'klj_clean_files', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['T_CLEANING_FILES_NOW']);
|
||||
$ADM_NOTIFICATIONS['klj_clean_files'] = ['id' => 'klj_clean_files', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> $lang['T_CLEANING_FILES_NOW']];
|
||||
}
|
||||
|
||||
//if there is no thumbs folder
|
||||
if(!file_exists(PATH . $config['foldername'] . '/thumbs') && (int) $config['thumbs_imgs'] != 0)
|
||||
if (! file_exists(PATH . $config['foldername'] . '/thumbs') && (int) $config['thumbs_imgs'] != 0)
|
||||
{
|
||||
$ADM_NOTIFICATIONS['no_thumbs'] = array('id' => 'no_thumbs', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> sprintf($lang['NO_THUMB_FOLDER'], PATH . $config['foldername'] . '/thumbs'));
|
||||
$ADM_NOTIFICATIONS['no_thumbs'] = ['id' => 'no_thumbs', 'msg_type'=> 'info', 'title'=> $lang['NOTE'], 'msg'=> sprintf($lang['NO_THUMB_FOLDER'], PATH . $config['foldername'] . '/thumbs')];
|
||||
}
|
||||
|
||||
|
||||
@@ -220,15 +227,15 @@ $translator_copyrights = isset($lang['S_TRANSLATED_BY']) ? $lang['S_TRANSLATED_
|
||||
|
||||
|
||||
//secondary menu
|
||||
$go_menu = array(
|
||||
'general' => array('name'=>$lang['GENERAL_STAT'], 'link'=> basename(ADMIN_PATH) . '?cp=start&smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'),
|
||||
'other' => array('name'=>$lang['OTHER_INFO'], 'link'=> basename(ADMIN_PATH) . '?cp=start&smt=other', 'goto'=>'other', 'current'=> $current_smt == 'other'),
|
||||
'team' => array('name'=>$lang['KLEEJA_TEAM'], 'link'=> basename(ADMIN_PATH) . '?cp=start&smt=team', 'goto'=>'team', 'current'=> $current_smt == 'team'),
|
||||
'kj_news' => array('name'=> $lang['KJ_TWEETS'], 'link'=> basename(ADMIN_PATH) . '?cp=start&smt=kj_tweets', 'goto'=>'kj_tweets', 'current'=> $current_smt == 'kj_tweets'),
|
||||
);
|
||||
$go_menu = [
|
||||
'general' => ['name'=>$lang['GENERAL_STAT'], 'link'=> basename(ADMIN_PATH) . '?cp=start&smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'],
|
||||
'other' => ['name'=>$lang['OTHER_INFO'], 'link'=> basename(ADMIN_PATH) . '?cp=start&smt=other', 'goto'=>'other', 'current'=> $current_smt == 'other'],
|
||||
'team' => ['name'=>$lang['KLEEJA_TEAM'], 'link'=> basename(ADMIN_PATH) . '?cp=start&smt=team', 'goto'=>'team', 'current'=> $current_smt == 'team'],
|
||||
'kj_news' => ['name'=> $lang['KJ_TWEETS'], 'link'=> basename(ADMIN_PATH) . '?cp=start&smt=kj_tweets', 'goto'=>'kj_tweets', 'current'=> $current_smt == 'kj_tweets'],
|
||||
];
|
||||
|
||||
|
||||
# is there a last visit of images and files ?
|
||||
// is there a last visit of images and files ?
|
||||
$files_last_visit = filter_exists('f_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id'])
|
||||
? get_filter('f_lastvisit', 'lastvisit', true, 'filter_uid', $userinfo['id']) : false;
|
||||
$image_last_visit = filter_exists('i_lastvisit', 'filter_uid', 'lastvisit', $userinfo['id'])
|
||||
@@ -236,127 +243,130 @@ $image_last_visit = filter_exists('i_lastvisit', 'filter_uid', 'lastvisit', $use
|
||||
|
||||
|
||||
|
||||
#hurry, hurry section, get styles
|
||||
$hurry_style_link = basename(ADMIN_PATH) . '?cp=m_styles&sty_t=st&method=2&home=1&smt=curstyle&' . $GET_FORM_KEY . '&style_choose=';
|
||||
//hurry, hurry section, get styles
|
||||
$hurry_style_link = basename(ADMIN_PATH) . '?cp=m_styles&sty_t=st&method=2&home=1&smt=curstyle&' . $GET_FORM_KEY . '&style_choose=';
|
||||
$hurry_styles_list = '';
|
||||
|
||||
if ($dh = @opendir(PATH . 'styles'))
|
||||
{
|
||||
while (($file = @readdir($dh)) !== false)
|
||||
{
|
||||
if(strpos($file, '.') === false && $file != '..' && $file != '.')
|
||||
{
|
||||
$hurry_styles_list .= '<option value="' . htmlspecialchars($file) . '"' . ($config['style'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>';
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
while (($file = @readdir($dh)) !== false)
|
||||
{
|
||||
if (strpos($file, '.') === false && $file != '..' && $file != '.')
|
||||
{
|
||||
$hurry_styles_list .= '<option value="' . htmlspecialchars($file) . '"' . ($config['style'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>';
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
}
|
||||
|
||||
#hurry, hurry section, get languages
|
||||
$hurry_lang_link = basename(ADMIN_PATH) . '?cp=g_users&smt=general&smt=group_data&' . $GET_FORM_KEY . '&lang_change=';
|
||||
//hurry, hurry section, get languages
|
||||
$hurry_lang_link = basename(ADMIN_PATH) . '?cp=g_users&smt=general&smt=group_data&' . $GET_FORM_KEY . '&lang_change=';
|
||||
$hurry_langs_list = '';
|
||||
|
||||
if ($dh = @opendir(PATH . 'lang'))
|
||||
{
|
||||
while (($file = @readdir($dh)) !== false)
|
||||
{
|
||||
if(strpos($file, '.') === false && $file != '..' && $file != '.')
|
||||
{
|
||||
$hurry_langs_list .= '<option value="' . htmlspecialchars($file) . '"' . ($d_groups[$config['default_group']]['configs']['language'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>';
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
while (($file = @readdir($dh)) !== false)
|
||||
{
|
||||
if (strpos($file, '.') === false && $file != '..' && $file != '.')
|
||||
{
|
||||
$hurry_langs_list .= '<option value="' . htmlspecialchars($file) . '"' . ($d_groups[$config['default_group']]['configs']['language'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>';
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
}
|
||||
|
||||
$hurry_groups_list = '<option value="-1" selected="selected">' . $lang['ALL'] . '</option>';
|
||||
$hurry_groups_list .= '<option value="' . $config['default_group'] . '">' . $lang['DEFAULT_GROUP'] . '</option>';
|
||||
foreach($d_groups as $id=>$ddt)
|
||||
|
||||
foreach ($d_groups as $id=>$ddt)
|
||||
{
|
||||
$hurry_groups_list .= '<option value="' . $id . '">' .
|
||||
str_replace(array('{lang.ADMINS}', '{lang.USERS}', '{lang.GUESTS}'),
|
||||
array($lang['ADMINS'], $lang['USERS'], $lang['GUESTS']),
|
||||
$d_groups[$id]['data']['group_name']) .
|
||||
'</option>';
|
||||
$hurry_groups_list .= '<option value="' . $id . '">' .
|
||||
str_replace(['{lang.ADMINS}', '{lang.USERS}', '{lang.GUESTS}'],
|
||||
[$lang['ADMINS'], $lang['USERS'], $lang['GUESTS']],
|
||||
$d_groups[$id]['data']['group_name']) .
|
||||
'</option>';
|
||||
}
|
||||
|
||||
#hurry, hurry section, links
|
||||
//hurry, hurry section, links
|
||||
$del_cache_link = basename(ADMIN_PATH) . '?cp=r_repair&case=clearc&' . kleeja_add_form_key_get('REPAIR_FORM_KEY');
|
||||
|
||||
|
||||
# get stats filter so we can draw a chart for the user
|
||||
// get stats filter so we can draw a chart for the user
|
||||
$stats_chart = false;
|
||||
|
||||
$cf_query = array(
|
||||
'SELECT' => 'f.filter_uid, f.filter_value, f.filter_time',
|
||||
'FROM' => "{$dbprefix}filters f",
|
||||
'WHERE' => "f.filter_type = 'stats_for_acp'",
|
||||
'ORDER BY' => 'f.filter_time DESC',
|
||||
);
|
||||
$cf_query = [
|
||||
'SELECT' => 'f.filter_uid, f.filter_value, f.filter_time',
|
||||
'FROM' => "{$dbprefix}filters f",
|
||||
'WHERE' => "f.filter_type = 'stats_for_acp'",
|
||||
'ORDER BY' => 'f.filter_time DESC',
|
||||
];
|
||||
|
||||
$cf_result = $SQL->build($cf_query);
|
||||
$cf_num = $SQL->num_rows($cf_result);
|
||||
if($cf_num > 3)
|
||||
$cf_num = $SQL->num_rows($cf_result);
|
||||
|
||||
if ($cf_num > 3)
|
||||
{
|
||||
$stats_chart = 'arrayOfDataMulti = new Array(';
|
||||
$stats_chart = 'arrayOfDataMulti = new Array(';
|
||||
|
||||
$comma = false;
|
||||
#get currently right now stats
|
||||
$prv_files = get_actual_stats('files');
|
||||
$prev_imgs = get_actual_stats('imgs');
|
||||
$prev_date = date('d-n-Y');
|
||||
$todayIsGone = false;
|
||||
$comma = false;
|
||||
//get currently right now stats
|
||||
$prv_files = get_actual_stats('files');
|
||||
$prev_imgs = get_actual_stats('imgs');
|
||||
$prev_date = date('d-n-Y');
|
||||
$todayIsGone = false;
|
||||
|
||||
while($row=$SQL->fetch_array($cf_result))
|
||||
{
|
||||
#jump today
|
||||
if($prev_date == $row['filter_uid'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
while ($row=$SQL->fetch_array($cf_result))
|
||||
{
|
||||
//jump today
|
||||
if ($prev_date == $row['filter_uid'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
#get this row data
|
||||
list($s_files, $s_imgs, $s_sizes) = explode(':', $row['filter_value']);
|
||||
|
||||
$t_files = $prv_files - $s_files;
|
||||
$t_imgs = $prev_imgs - $s_imgs;
|
||||
//get this row data
|
||||
list($s_files, $s_imgs, $s_sizes) = explode(':', $row['filter_value']);
|
||||
|
||||
if(date('d-n-Y') == $prev_date)
|
||||
{
|
||||
$day = $lang['TODAY'] . ' ~ ' . $lang['NOW'];
|
||||
$t_files = $prv_files - $s_files;
|
||||
$t_imgs = $prev_imgs - $s_imgs;
|
||||
|
||||
if($todayIsGone)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (date('d-n-Y') == $prev_date)
|
||||
{
|
||||
$day = $lang['TODAY'] . ' ~ ' . $lang['NOW'];
|
||||
|
||||
$todayIsGone = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$day = $prev_date;
|
||||
}
|
||||
if ($todayIsGone)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$stats_chart .= ($comma ? ',': '') . "[[$t_files,$t_imgs],'" . ($cf_num > 6 ? str_replace(date('-Y'), '', $day) : $day) . "']";
|
||||
$todayIsGone = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$day = $prev_date;
|
||||
}
|
||||
|
||||
$comma = true;
|
||||
$prv_files = $s_files;
|
||||
$prev_imgs = $s_imgs;
|
||||
$prev_date = $row['filter_uid'];
|
||||
}
|
||||
$stats_chart .= ($comma ? ',': '') . "[[$t_files,$t_imgs],'" . ($cf_num > 6 ? str_replace(date('-Y'), '', $day) : $day) . "']";
|
||||
|
||||
$stats_chart .= ');';
|
||||
$comma = true;
|
||||
$prv_files = $s_files;
|
||||
$prev_imgs = $s_imgs;
|
||||
$prev_date = $row['filter_uid'];
|
||||
}
|
||||
|
||||
$stats_chart .= ');';
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('stats_start_admin', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
$SQL->freeresult($cf_result);
|
||||
|
||||
#clean old chart stats
|
||||
if($cf_num > 10)
|
||||
{
|
||||
$query_del = array(
|
||||
'DELETE' => "{$dbprefix}filters",
|
||||
'WHERE' => "filter_type = 'stats_for_acp' AND filter_time < " . (time() - (3600 * 24 * 10))
|
||||
);
|
||||
$SQL->build($query_del);
|
||||
}
|
||||
//clean old chart stats
|
||||
if ($cf_num > 10)
|
||||
{
|
||||
$query_del = [
|
||||
'DELETE' => "{$dbprefix}filters",
|
||||
'WHERE' => "filter_type = 'stats_for_acp' AND filter_time < " . (time() - (3600 * 24 * 10))
|
||||
];
|
||||
$SQL->build($query_del);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,101 +9,99 @@
|
||||
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = false, $return_username = false)
|
||||
{
|
||||
global $lang, $config, $usrcp, $userinfo;
|
||||
global $script_path, $script_api_key, $script_cp1256;
|
||||
global $lang, $config, $usrcp, $userinfo;
|
||||
global $script_path, $script_api_key, $script_cp1256;
|
||||
|
||||
//URL must be begin with http://
|
||||
if(empty($script_path) || $script_path[0] != 'h')
|
||||
{
|
||||
big_error('Forum URL must be begin with http://', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'API'));
|
||||
}
|
||||
//URL must be begin with http://
|
||||
if (empty($script_path) || $script_path[0] != 'h')
|
||||
{
|
||||
big_error('Forum URL must be begin with http://', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'API'));
|
||||
}
|
||||
|
||||
//api key is the key to make the query between the remote script and kleeja more secure !
|
||||
//this must be changed in the real use
|
||||
if(empty($script_api_key))
|
||||
{
|
||||
big_error('api key', 'To connect to the remote script you have to write the API key ...');
|
||||
}
|
||||
//api key is the key to make the query between the remote script and kleeja more secure !
|
||||
//this must be changed in the real use
|
||||
if (empty($script_api_key))
|
||||
{
|
||||
big_error('api key', 'To connect to the remote script you have to write the API key ...');
|
||||
}
|
||||
|
||||
$pass = empty($script_cp1256) || !$script_cp1256 ? $pass : $usrcp->kleeja_utf8($pass, false);
|
||||
$name = empty($script_cp1256) || !$script_cp1256 || $hashed ? $name : $usrcp->kleeja_utf8($name, false);
|
||||
$pass = empty($script_cp1256) || ! $script_cp1256 ? $pass : $usrcp->kleeja_utf8($pass, false);
|
||||
$name = empty($script_cp1256) || ! $script_cp1256 || $hashed ? $name : $usrcp->kleeja_utf8($name, false);
|
||||
|
||||
/*
|
||||
@see file : docs/kleeja_(vb,mysmartbb,phpbb)_api.txt
|
||||
*/
|
||||
// @see file : docs/kleeja_(vb,mysmartbb,phpbb)_api.txt
|
||||
|
||||
$api_http_query = 'api_key=' . kleeja_base64_encode($script_api_key) . '&' . ($hashed ? 'userid' : 'username') . '=' . urlencode($name) . '&pass=' . kleeja_base64_encode($pass);
|
||||
//if only username, let tell him in the query
|
||||
$api_http_query .= $return_username ? '&return_username=1' : '';
|
||||
$api_http_query = 'api_key=' . kleeja_base64_encode($script_api_key) . '&' . ($hashed ? 'userid' : 'username') . '=' . urlencode($name) . '&pass=' . kleeja_base64_encode($pass);
|
||||
//if only username, let tell him in the query
|
||||
$api_http_query .= $return_username ? '&return_username=1' : '';
|
||||
|
||||
|
||||
//get it
|
||||
$remote_data = fetch_remote_file($script_path . '?' . $api_http_query);
|
||||
//get it
|
||||
$remote_data = fetch_remote_file($script_path . '?' . $api_http_query);
|
||||
|
||||
//no responde
|
||||
//empty or can not connect
|
||||
if ($remote_data == false || empty($remote_data))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//no responde
|
||||
//empty or can not connect
|
||||
if ($remote_data == false || empty($remote_data))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//see kleeja_api.php file
|
||||
//split the data , the first one is always 0 or 1
|
||||
//0 : error
|
||||
//1: ok
|
||||
$user_info = explode('%|%', kleeja_base64_decode($remote_data));
|
||||
//see kleeja_api.php file
|
||||
//split the data , the first one is always 0 or 1
|
||||
//0 : error
|
||||
//1: ok
|
||||
$user_info = explode('%|%', kleeja_base64_decode($remote_data));
|
||||
|
||||
//omg, it's 0 , 0 : error, lets die here
|
||||
if((int)$user_info[0] == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//omg, it's 0 , 0 : error, lets die here
|
||||
if ((int) $user_info[0] == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
//if we want username only we have to return it quickly and die here
|
||||
//
|
||||
if($return_username)
|
||||
{
|
||||
return empty($script_cp1256) || !$script_cp1256 ? $user_info[1] : $usrcp->kleeja_utf8($user_info[1]);
|
||||
}
|
||||
//
|
||||
//if we want username only we have to return it quickly and die here
|
||||
//
|
||||
if ($return_username)
|
||||
{
|
||||
return empty($script_cp1256) || ! $script_cp1256 ? $user_info[1] : $usrcp->kleeja_utf8($user_info[1]);
|
||||
}
|
||||
|
||||
//
|
||||
//when loggin to admin, we just want a check, no data setup ..
|
||||
//
|
||||
if(!$loginadm)
|
||||
{
|
||||
define('USER_ID', $user_info[1]);
|
||||
define('GROUP_ID', 3);
|
||||
define('USER_NAME', empty($script_cp1256) || !$script_cp1256 ? $user_info[2] : $usrcp->kleeja_utf8($user_info[2]));
|
||||
define('USER_MAIL', $user_info[3]);
|
||||
define('USER_ADMIN', ((int) $user_info[5] == 1) ? 1 : 0);
|
||||
}
|
||||
//
|
||||
//when loggin to admin, we just want a check, no data setup ..
|
||||
//
|
||||
if (! $loginadm)
|
||||
{
|
||||
define('USER_ID', $user_info[1]);
|
||||
define('GROUP_ID', 3);
|
||||
define('USER_NAME', empty($script_cp1256) || ! $script_cp1256 ? $user_info[2] : $usrcp->kleeja_utf8($user_info[2]));
|
||||
define('USER_MAIL', $user_info[3]);
|
||||
define('USER_ADMIN', ((int) $user_info[5] == 1) ? 1 : 0);
|
||||
}
|
||||
|
||||
//user ifo
|
||||
//and this must be filled with user data comming from url
|
||||
$userinfo = array();
|
||||
$userinfo['group_id'] = GROUP_ID;
|
||||
$user_y = kleeja_base64_encode(serialize(array('id'=>USER_ID, 'name'=>USER_NAME, 'mail'=>USER_MAIL, 'last_visit'=>time())));
|
||||
//user ifo
|
||||
//and this must be filled with user data comming from url
|
||||
$userinfo = [];
|
||||
$userinfo['group_id'] = GROUP_ID;
|
||||
$user_y = kleeja_base64_encode(serialize(['id'=>USER_ID, 'name'=>USER_NAME, 'mail'=>USER_MAIL, 'last_visit'=>time()]));
|
||||
|
||||
|
||||
//add cookies
|
||||
if(!$loginadm)
|
||||
{
|
||||
$usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt($user_info[1] . '|' . $user_info[4] . '|' . $expire . '|' . sha1(md5($config['h_key'] . $user_info[4]) . $expire) . '|' . GROUP_ID . '|' . $user_y), $expire);
|
||||
}
|
||||
//add cookies
|
||||
if (! $loginadm)
|
||||
{
|
||||
$usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt($user_info[1] . '|' . $user_info[4] . '|' . $expire . '|' . sha1(md5($config['h_key'] . $user_info[4]) . $expire) . '|' . GROUP_ID . '|' . $user_y), $expire);
|
||||
}
|
||||
|
||||
//no need after now
|
||||
unset($pass);
|
||||
//no need after now
|
||||
unset($pass);
|
||||
|
||||
//yes ! he is a real user
|
||||
return true;
|
||||
//yes ! he is a real user
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -111,7 +109,7 @@ function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm =
|
||||
//
|
||||
function kleeja_auth_username ($user_id)
|
||||
{
|
||||
return kleeja_auth_login($user_id, false, false, false, false, true);
|
||||
return kleeja_auth_login($user_id, false, false, false, false, true);
|
||||
}
|
||||
|
||||
//<-- EOF
|
||||
|
||||
@@ -9,209 +9,206 @@
|
||||
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//Path of config file in phpBB3
|
||||
//
|
||||
if(!defined('SCRIPT_CONFIG_PATH'))
|
||||
if (! defined('SCRIPT_CONFIG_PATH'))
|
||||
{
|
||||
define('SCRIPT_CONFIG_PATH', '/config.php');
|
||||
define('SCRIPT_CONFIG_PATH', '/config.php');
|
||||
}
|
||||
|
||||
function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = false, $return_name = false)
|
||||
{
|
||||
global $lang, $config, $usrcp, $userinfo;
|
||||
global $script_path, $script_encoding, $script_srv, $script_db, $script_user, $script_pass, $script_prefix;
|
||||
|
||||
//check for last slash /
|
||||
if(isset($script_path))
|
||||
{
|
||||
if(isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/')
|
||||
{
|
||||
$script_path = substr($script_path, 0, strlen($script_path));
|
||||
}
|
||||
global $lang, $config, $usrcp, $userinfo;
|
||||
global $script_path, $script_encoding, $script_srv, $script_db, $script_user, $script_pass, $script_prefix;
|
||||
|
||||
//get some useful data from phbb config file
|
||||
if(file_exists(PATH . $script_path . SCRIPT_CONFIG_PATH))
|
||||
{
|
||||
include (PATH . $script_path . SCRIPT_CONFIG_PATH);
|
||||
//check for last slash /
|
||||
if (isset($script_path))
|
||||
{
|
||||
if (isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/')
|
||||
{
|
||||
$script_path = substr($script_path, 0, strlen($script_path));
|
||||
}
|
||||
|
||||
$forum_srv = $dbhost;
|
||||
$forum_db = $dbname;
|
||||
$forum_user = $dbuser;
|
||||
$forum_pass = $dbpasswd;
|
||||
$forum_prefix = $table_prefix;
|
||||
//get some useful data from phbb config file
|
||||
if (file_exists(PATH . $script_path . SCRIPT_CONFIG_PATH))
|
||||
{
|
||||
include PATH . $script_path . SCRIPT_CONFIG_PATH;
|
||||
|
||||
if(empty($dbhost))
|
||||
{
|
||||
$forum_srv = 'localhost';
|
||||
}
|
||||
$forum_srv = $dbhost;
|
||||
$forum_db = $dbname;
|
||||
$forum_user = $dbuser;
|
||||
$forum_pass = $dbpasswd;
|
||||
$forum_prefix = $table_prefix;
|
||||
|
||||
if(!empty($dbport))
|
||||
{
|
||||
$forum_srv .= ':' . $dbport;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
big_error('Forum path is not correct', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'phpBB3'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_srv = $script_srv;
|
||||
$forum_db = $script_db;
|
||||
$forum_user = $script_user;
|
||||
$forum_pass = $script_pass;
|
||||
$forum_prefix = $script_prefix;
|
||||
}
|
||||
if (empty($dbhost))
|
||||
{
|
||||
$forum_srv = 'localhost';
|
||||
}
|
||||
|
||||
//if no variables of db
|
||||
if(empty($forum_srv) || empty($forum_user) || empty($forum_db))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (! empty($dbport))
|
||||
{
|
||||
$forum_srv .= ':' . $dbport;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
big_error('Forum path is not correct', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'phpBB3'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_srv = $script_srv;
|
||||
$forum_db = $script_db;
|
||||
$forum_user = $script_user;
|
||||
$forum_pass = $script_pass;
|
||||
$forum_prefix = $script_prefix;
|
||||
}
|
||||
|
||||
//conecting ...
|
||||
//if no variables of db
|
||||
if (empty($forum_srv) || empty($forum_user) || empty($forum_db))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//conecting ...
|
||||
$SQLBB = new KleejaDatabase($forum_srv, $forum_user, $forum_pass, $forum_db, true);
|
||||
|
||||
$SQLBB->set_names('utf8');
|
||||
$SQLBB->set_names('utf8');
|
||||
|
||||
unset($forum_pass); // We do not need this any longer
|
||||
unset($forum_pass); // We do not need this any longer
|
||||
|
||||
//get utf tools
|
||||
global $phpbb_root_path, $phpEx;
|
||||
$phpbb_root_path = PATH . $script_path . '/';
|
||||
$phpEx = 'php';
|
||||
define('IN_PHPBB', true);
|
||||
include_once (PATH . $script_path . '/includes/utf/utf_tools.' . $phpEx);
|
||||
//get utf tools
|
||||
global $phpbb_root_path, $phpEx;
|
||||
$phpbb_root_path = PATH . $script_path . '/';
|
||||
$phpEx = 'php';
|
||||
define('IN_PHPBB', true);
|
||||
include_once PATH . $script_path . '/includes/utf/utf_tools.' . $phpEx;
|
||||
|
||||
$row_leve = 'user_type';
|
||||
$admin_level = 3;
|
||||
$query2 = array(
|
||||
'SELECT' => '*',
|
||||
'FROM' => "`{$forum_prefix}users`",
|
||||
);
|
||||
$row_leve = 'user_type';
|
||||
$admin_level = 3;
|
||||
$query2 = [
|
||||
'SELECT' => '*',
|
||||
'FROM' => "`{$forum_prefix}users`",
|
||||
];
|
||||
|
||||
$query2['WHERE'] = $hashed ? "user_id=" . intval($name) . " AND user_password='" . $SQLBB->real_escape($pass) . "' " : "username_clean='" . $SQLBB->real_escape(utf8_clean_string($name)) . "'";
|
||||
|
||||
if($return_name)
|
||||
{
|
||||
$query2['SELECT'] = "username";
|
||||
$query2['WHERE'] = "user_id=" . intval($name);
|
||||
}
|
||||
|
||||
$query = '';
|
||||
$query2['WHERE'] = $hashed ? 'user_id=' . intval($name) . " AND user_password='" . $SQLBB->real_escape($pass) . "' " : "username_clean='" . $SQLBB->real_escape(utf8_clean_string($name)) . "'";
|
||||
|
||||
if(!$hashed)
|
||||
{
|
||||
$result2 = $SQLBB->build($query2);
|
||||
while($row=$SQLBB->fetch_array($result2))
|
||||
{
|
||||
$SQLBB->freeresult($result2);
|
||||
if ($return_name)
|
||||
{
|
||||
$query2['SELECT'] = 'username';
|
||||
$query2['WHERE'] = 'user_id=' . intval($name);
|
||||
}
|
||||
|
||||
if($return_name)
|
||||
{
|
||||
return $row['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(phpbb_check_hash($pass, $row['user_password']))
|
||||
{
|
||||
$query = $query2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $query2;
|
||||
}
|
||||
$query = '';
|
||||
|
||||
if(empty($query))
|
||||
{
|
||||
$SQLBB->close();
|
||||
return false;
|
||||
}
|
||||
if (! $hashed)
|
||||
{
|
||||
$result2 = $SQLBB->build($query2);
|
||||
while ($row=$SQLBB->fetch_array($result2))
|
||||
{
|
||||
$SQLBB->freeresult($result2);
|
||||
|
||||
if ($return_name)
|
||||
{
|
||||
return $row['username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (phpbb_check_hash($pass, $row['user_password']))
|
||||
{
|
||||
$query = $query2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $query2;
|
||||
}
|
||||
|
||||
if (empty($query))
|
||||
{
|
||||
$SQLBB->close();
|
||||
return false;
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_usrdata_phpbb_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
$result = $SQLBB->build($query);
|
||||
$result = $SQLBB->build($query);
|
||||
|
||||
|
||||
if ($SQLBB->num_rows($result) != 0)
|
||||
{
|
||||
while($row=$SQLBB->fetch_array($result))
|
||||
{
|
||||
if($SQLBB->num_rows($SQLBB->query("SELECT ban_userid FROM `{$forum_prefix}banlist` WHERE ban_userid=" . intval($row['user_id']))) == 0)
|
||||
{
|
||||
if(!$loginadm)
|
||||
{
|
||||
define('USER_ID', $row['user_id']);
|
||||
define('GROUP_ID', ($row[$row_leve] == $admin_level ? '1' : '3'));
|
||||
define('USER_NAME', $row['username']);
|
||||
define('USER_MAIL',$row['user_email']);
|
||||
if($row[$row_leve] == $admin_level)
|
||||
{
|
||||
define('USER_ADMIN', true);
|
||||
}
|
||||
}
|
||||
if ($SQLBB->num_rows($result) != 0)
|
||||
{
|
||||
while ($row=$SQLBB->fetch_array($result))
|
||||
{
|
||||
if ($SQLBB->num_rows($SQLBB->query("SELECT ban_userid FROM `{$forum_prefix}banlist` WHERE ban_userid=" . intval($row['user_id']))) == 0)
|
||||
{
|
||||
if (! $loginadm)
|
||||
{
|
||||
define('USER_ID', $row['user_id']);
|
||||
define('GROUP_ID', ($row[$row_leve] == $admin_level ? '1' : '3'));
|
||||
define('USER_NAME', $row['username']);
|
||||
define('USER_MAIL', $row['user_email']);
|
||||
|
||||
$userinfo = $row;
|
||||
$userinfo['group_id'] = ($row[$row_leve] == $admin_level ? '1' : '3');
|
||||
if ($row[$row_leve] == $admin_level)
|
||||
{
|
||||
define('USER_ADMIN', true);
|
||||
}
|
||||
}
|
||||
|
||||
$user_y = kleeja_base64_encode(serialize(array('id'=>$row['user_id'], 'name'=>$row['username'], 'mail'=>$row['user_email'], 'last_visit'=>time())));
|
||||
$userinfo = $row;
|
||||
$userinfo['group_id'] = ($row[$row_leve] == $admin_level ? '1' : '3');
|
||||
|
||||
if(!$hashed && !$loginadm)
|
||||
{
|
||||
$usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt(
|
||||
$row['user_id'] . '|' .
|
||||
$row['user_password'] . '|' .
|
||||
$expire . '|' .
|
||||
sha1(md5($config['h_key'] . $row['user_password']) . $expire) . '|' .
|
||||
($row[$row_leve] == $admin_level ? '1' : '3') . '|' .
|
||||
$user_y
|
||||
), $expire);
|
||||
}
|
||||
$user_y = kleeja_base64_encode(serialize(['id'=>$row['user_id'], 'name'=>$row['username'], 'mail'=>$row['user_email'], 'last_visit'=>time()]));
|
||||
|
||||
if (! $hashed && ! $loginadm)
|
||||
{
|
||||
$usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt(
|
||||
$row['user_id'] . '|' .
|
||||
$row['user_password'] . '|' .
|
||||
$expire . '|' .
|
||||
sha1(md5($config['h_key'] . $row['user_password']) . $expire) . '|' .
|
||||
($row[$row_leve] == $admin_level ? '1' : '3') . '|' .
|
||||
$user_y
|
||||
), $expire);
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_while_usrdata_phpbb_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
}
|
||||
else
|
||||
{
|
||||
//he is banned from phpBB
|
||||
$SQLBB->freeresult($result);
|
||||
unset($pass);
|
||||
$SQLBB->close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//he is banned from phpBB
|
||||
$SQLBB->freeresult($result);
|
||||
unset($pass);
|
||||
$SQLBB->close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$SQLBB->freeresult($result);
|
||||
unset($pass);
|
||||
$SQLBB->close();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$SQLBB->freeresult($result);
|
||||
$SQLBB->close();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQLBB->freeresult($result);
|
||||
unset($pass);
|
||||
$SQLBB->close();
|
||||
return true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$SQLBB->freeresult($result);
|
||||
$SQLBB->close();
|
||||
return false;
|
||||
}
|
||||
|
||||
//dont know why they come here !
|
||||
return false;
|
||||
//dont know why they come here !
|
||||
return false;
|
||||
}
|
||||
|
||||
function kleeja_auth_username ($user_id)
|
||||
{
|
||||
return kleeja_auth_login ($user_id, false, false, 0, false, true);
|
||||
return kleeja_auth_login ($user_id, false, false, 0, false, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -220,13 +217,14 @@ function kleeja_auth_username ($user_id)
|
||||
*/
|
||||
function phpbb_check_hash($password, $hash)
|
||||
{
|
||||
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
if (strlen($hash) == 34)
|
||||
{
|
||||
return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
|
||||
}
|
||||
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
return (md5($password) === $hash) ? true : false;
|
||||
if (strlen($hash) == 34)
|
||||
{
|
||||
return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
|
||||
}
|
||||
|
||||
return (md5($password) === $hash) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,16 +232,16 @@ function phpbb_check_hash($password, $hash)
|
||||
*/
|
||||
function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
|
||||
{
|
||||
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
|
||||
{
|
||||
$iteration_count_log2 = 8;
|
||||
}
|
||||
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
|
||||
{
|
||||
$iteration_count_log2 = 8;
|
||||
}
|
||||
|
||||
$output = '$H$';
|
||||
$output .= $itoa64[min($iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30)];
|
||||
$output .= _hash_encode64($input, 6, $itoa64);
|
||||
$output = '$H$';
|
||||
$output .= $itoa64[min($iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30)];
|
||||
$output .= _hash_encode64($input, 6, $itoa64);
|
||||
|
||||
return $output;
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,43 +249,42 @@ function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
|
||||
*/
|
||||
function _hash_encode64($input, $count, &$itoa64)
|
||||
{
|
||||
$output = '';
|
||||
$i = 0;
|
||||
$output = '';
|
||||
$i = 0;
|
||||
|
||||
do
|
||||
{
|
||||
$value = ord($input[$i++]);
|
||||
$output .= $itoa64[$value & 0x3f];
|
||||
do
|
||||
{
|
||||
$value = ord($input[$i++]);
|
||||
$output .= $itoa64[$value & 0x3f];
|
||||
|
||||
if ($i < $count)
|
||||
{
|
||||
$value |= ord($input[$i]) << 8;
|
||||
}
|
||||
if ($i < $count)
|
||||
{
|
||||
$value |= ord($input[$i]) << 8;
|
||||
}
|
||||
|
||||
$output .= $itoa64[($value >> 6) & 0x3f];
|
||||
$output .= $itoa64[($value >> 6) & 0x3f];
|
||||
|
||||
if ($i++ >= $count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if ($i++ >= $count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if ($i < $count)
|
||||
{
|
||||
$value |= ord($input[$i]) << 16;
|
||||
}
|
||||
if ($i < $count)
|
||||
{
|
||||
$value |= ord($input[$i]) << 16;
|
||||
}
|
||||
|
||||
$output .= $itoa64[($value >> 12) & 0x3f];
|
||||
$output .= $itoa64[($value >> 12) & 0x3f];
|
||||
|
||||
if ($i++ >= $count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if ($i++ >= $count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
$output .= $itoa64[($value >> 18) & 0x3f];
|
||||
}
|
||||
while ($i < $count);
|
||||
$output .= $itoa64[($value >> 18) & 0x3f];
|
||||
} while ($i < $count);
|
||||
|
||||
return $output;
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,58 +292,56 @@ function _hash_encode64($input, $count, &$itoa64)
|
||||
*/
|
||||
function _hash_crypt_private($password, $setting, &$itoa64)
|
||||
{
|
||||
$output = '*';
|
||||
$output = '*';
|
||||
|
||||
// Check for correct hash
|
||||
if (substr($setting, 0, 3) != '$H$')
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
// Check for correct hash
|
||||
if (substr($setting, 0, 3) != '$H$')
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
$count_log2 = strpos($itoa64, $setting[3]);
|
||||
$count_log2 = strpos($itoa64, $setting[3]);
|
||||
|
||||
if ($count_log2 < 7 || $count_log2 > 30)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
if ($count_log2 < 7 || $count_log2 > 30)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
$count = 1 << $count_log2;
|
||||
$salt = substr($setting, 4, 8);
|
||||
$count = 1 << $count_log2;
|
||||
$salt = substr($setting, 4, 8);
|
||||
|
||||
if (strlen($salt) != 8)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
if (strlen($salt) != 8)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* We're kind of forced to use MD5 here since it's the only
|
||||
* cryptographic primitive available in all versions of PHP
|
||||
* currently in use. To implement our own low-level crypto
|
||||
* in PHP would result in much worse performance and
|
||||
* consequently in lower iteration counts and hashes that are
|
||||
* quicker to crack (by non-PHP code).
|
||||
*/
|
||||
if (PHP_VERSION >= 5)
|
||||
{
|
||||
$hash = md5($salt . $password, true);
|
||||
do
|
||||
{
|
||||
$hash = md5($hash . $password, true);
|
||||
}
|
||||
while (--$count);
|
||||
}
|
||||
else
|
||||
{
|
||||
$hash = pack('H*', md5($salt . $password));
|
||||
do
|
||||
{
|
||||
$hash = pack('H*', md5($hash . $password));
|
||||
}
|
||||
while (--$count);
|
||||
}
|
||||
/**
|
||||
* We're kind of forced to use MD5 here since it's the only
|
||||
* cryptographic primitive available in all versions of PHP
|
||||
* currently in use. To implement our own low-level crypto
|
||||
* in PHP would result in much worse performance and
|
||||
* consequently in lower iteration counts and hashes that are
|
||||
* quicker to crack (by non-PHP code).
|
||||
*/
|
||||
if (PHP_VERSION >= 5)
|
||||
{
|
||||
$hash = md5($salt . $password, true);
|
||||
do
|
||||
{
|
||||
$hash = md5($hash . $password, true);
|
||||
} while (--$count);
|
||||
}
|
||||
else
|
||||
{
|
||||
$hash = pack('H*', md5($salt . $password));
|
||||
do
|
||||
{
|
||||
$hash = pack('H*', md5($hash . $password));
|
||||
} while (--$count);
|
||||
}
|
||||
|
||||
$output = substr($setting, 0, 12);
|
||||
$output .= _hash_encode64($hash, 16, $itoa64);
|
||||
$output = substr($setting, 0, 12);
|
||||
$output .= _hash_encode64($hash, 16, $itoa64);
|
||||
|
||||
return $output;
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -8,229 +8,230 @@
|
||||
*/
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
//
|
||||
//Path of config file in vb
|
||||
//
|
||||
if(! defined('SCRIPT_CONFIG_PATH'))
|
||||
if (! defined('SCRIPT_CONFIG_PATH'))
|
||||
{
|
||||
define('SCRIPT_CONFIG_PATH', '/includes/config.php');
|
||||
define('SCRIPT_CONFIG_PATH', '/includes/config.php');
|
||||
}
|
||||
|
||||
function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = false, $return_name = false)
|
||||
{
|
||||
global $lang, $config, $usrcp, $userinfo;
|
||||
global $script_path, $script_cp1256, $script_srv, $script_db, $script_user, $script_pass, $script_prefix, $script_db_charset;
|
||||
global $lang, $config, $usrcp, $userinfo;
|
||||
global $script_path, $script_cp1256, $script_srv, $script_db, $script_user, $script_pass, $script_prefix, $script_db_charset;
|
||||
|
||||
if(isset($script_path))
|
||||
{
|
||||
//check for last slash
|
||||
if(isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/')
|
||||
{
|
||||
$script_path = substr($script_path, 0, strlen($script_path));
|
||||
}
|
||||
if (isset($script_path))
|
||||
{
|
||||
//check for last slash
|
||||
if (isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/')
|
||||
{
|
||||
$script_path = substr($script_path, 0, strlen($script_path));
|
||||
}
|
||||
|
||||
$configExists = false;
|
||||
|
||||
if(file_exists(PATH . $script_path . SCRIPT_CONFIG_PATH))
|
||||
{
|
||||
$configPath = PATH . $script_path . SCRIPT_CONFIG_PATH;
|
||||
$configExists = true;
|
||||
}
|
||||
else if(file_exists(PATH . $script_path . '/core/includes/config.php'))
|
||||
{
|
||||
$configPath = PATH . $script_path . '/core/includes/config.php';
|
||||
$configExists = true;
|
||||
$isVB5 = true;
|
||||
}
|
||||
$configExists = false;
|
||||
|
||||
//get some useful data from vb config file
|
||||
if($configExists)
|
||||
{
|
||||
require_once $configPath;
|
||||
if (file_exists(PATH . $script_path . SCRIPT_CONFIG_PATH))
|
||||
{
|
||||
$configPath = PATH . $script_path . SCRIPT_CONFIG_PATH;
|
||||
$configExists = true;
|
||||
}
|
||||
elseif (file_exists(PATH . $script_path . '/core/includes/config.php'))
|
||||
{
|
||||
$configPath = PATH . $script_path . '/core/includes/config.php';
|
||||
$configExists = true;
|
||||
$isVB5 = true;
|
||||
}
|
||||
|
||||
//
|
||||
//get config from config file
|
||||
//
|
||||
$forum_srv = $config['MasterServer']['servername'];
|
||||
$forum_db = $config['Database']['dbname'];
|
||||
$forum_user = $config['MasterServer']['username'];
|
||||
$forum_pass = $config['MasterServer']['password'];
|
||||
$forum_prefix= $config['Database']['tableprefix'];
|
||||
if($config['MasterServer']['port'] != 3306)
|
||||
{
|
||||
$forum_srv .= ':' . $config['MasterServer']['port'];
|
||||
}
|
||||
//get some useful data from vb config file
|
||||
if ($configExists)
|
||||
{
|
||||
require_once $configPath;
|
||||
|
||||
//some people change their db charset
|
||||
if(isset($config['Mysqli']['charset']))
|
||||
{
|
||||
$forum_db_charset = $config['Mysqli']['charset'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
big_error('Forum path is not correct', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'Vbulletin'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
//custom config data
|
||||
//
|
||||
$forum_srv = $script_srv;
|
||||
$forum_db = $script_db;
|
||||
$forum_user = $script_user;
|
||||
$forum_pass = $script_pass;
|
||||
$forum_prefix = $script_prefix;
|
||||
//
|
||||
//get config from config file
|
||||
//
|
||||
$forum_srv = $config['MasterServer']['servername'];
|
||||
$forum_db = $config['Database']['dbname'];
|
||||
$forum_user = $config['MasterServer']['username'];
|
||||
$forum_pass = $config['MasterServer']['password'];
|
||||
$forum_prefix= $config['Database']['tableprefix'];
|
||||
|
||||
//some people change their db charset
|
||||
if(isset($script_db_charset))
|
||||
{
|
||||
$forum_db_charset = $script_db_charset;
|
||||
}
|
||||
}
|
||||
if ($config['MasterServer']['port'] != 3306)
|
||||
{
|
||||
$forum_srv .= ':' . $config['MasterServer']['port'];
|
||||
}
|
||||
|
||||
if(empty($forum_srv) || empty($forum_user) || empty($forum_db))
|
||||
{
|
||||
return;
|
||||
}
|
||||
//some people change their db charset
|
||||
if (isset($config['Mysqli']['charset']))
|
||||
{
|
||||
$forum_db_charset = $config['Mysqli']['charset'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
big_error('Forum path is not correct', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'Vbulletin'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
//custom config data
|
||||
//
|
||||
$forum_srv = $script_srv;
|
||||
$forum_db = $script_db;
|
||||
$forum_user = $script_user;
|
||||
$forum_pass = $script_pass;
|
||||
$forum_prefix = $script_prefix;
|
||||
|
||||
//some people change their db charset
|
||||
if (isset($script_db_charset))
|
||||
{
|
||||
$forum_db_charset = $script_db_charset;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($forum_srv) || empty($forum_user) || empty($forum_db))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$SQLVB = new KleejaDatabase($forum_srv, $forum_user, $forum_pass, $forum_db, true);
|
||||
|
||||
|
||||
if(isset($forum_db_charset))
|
||||
{ //config
|
||||
$SQLVB->set_names($forum_db_charset);
|
||||
}
|
||||
else //auto
|
||||
{
|
||||
$SQLVB->set_names('latin1');
|
||||
}
|
||||
if (isset($forum_db_charset))
|
||||
{ //config
|
||||
$SQLVB->set_names($forum_db_charset);
|
||||
}
|
||||
else
|
||||
{ //auto
|
||||
$SQLVB->set_names('latin1');
|
||||
}
|
||||
|
||||
|
||||
unset($forum_pass); // We do not need this any longer
|
||||
unset($forum_pass); // We do not need this any longer
|
||||
|
||||
$pass = empty($script_cp1256) || !$script_cp1256 ? $pass : $usrcp->kleeja_utf8($pass, false);
|
||||
$name = empty($script_cp1256) || !$script_cp1256 || $hashed ? $name : $usrcp->kleeja_utf8($name, false);
|
||||
$pass = empty($script_cp1256) || ! $script_cp1256 ? $pass : $usrcp->kleeja_utf8($pass, false);
|
||||
$name = empty($script_cp1256) || ! $script_cp1256 || $hashed ? $name : $usrcp->kleeja_utf8($name, false);
|
||||
|
||||
$query_salt = array(
|
||||
'SELECT' => $hashed ? '*' : ($isVB5 ? 'token' : 'salt'),
|
||||
'FROM' => "`{$forum_prefix}user`",
|
||||
);
|
||||
$query_salt = [
|
||||
'SELECT' => $hashed ? '*' : ($isVB5 ? 'token' : 'salt'),
|
||||
'FROM' => "`{$forum_prefix}user`",
|
||||
];
|
||||
|
||||
$query_salt['WHERE'] = $hashed ? "userid=" . intval($name) . " AND ". ($isVB5 ? 'token' : 'password') ."='" . $SQLVB->real_escape($pass) . "' AND usergroupid != '8'" : "username='" . $SQLVB->real_escape($name) . "' AND usergroupid != '8'";
|
||||
|
||||
//if return only name let's ignore the above
|
||||
if($return_name)
|
||||
{
|
||||
$query_salt['SELECT'] = "username";
|
||||
$query_salt['WHERE'] = "userid=" . intval($name);
|
||||
}
|
||||
$query_salt['WHERE'] = $hashed ? 'userid=' . intval($name) . ' AND ' . ($isVB5 ? 'token' : 'password') . "='" . $SQLVB->real_escape($pass) . "' AND usergroupid != '8'" : "username='" . $SQLVB->real_escape($name) . "' AND usergroupid != '8'";
|
||||
|
||||
//if return only name let's ignore the above
|
||||
if ($return_name)
|
||||
{
|
||||
$query_salt['SELECT'] = 'username';
|
||||
$query_salt['WHERE'] = 'userid=' . intval($name);
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_usrdata_vb_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
$result_salt = $SQLVB->build($query_salt);
|
||||
$result_salt = $SQLVB->build($query_salt);
|
||||
|
||||
if ($SQLVB->num_rows($result_salt) > 0)
|
||||
{
|
||||
while($row1=$SQLVB->fetch_array($result_salt))
|
||||
{
|
||||
if($return_name)
|
||||
{
|
||||
return empty($script_cp1256) || !$script_cp1256 ? $row1['username'] : $usrcp->kleeja_utf8($row1['username']);
|
||||
}
|
||||
if ($SQLVB->num_rows($result_salt) > 0)
|
||||
{
|
||||
while ($row1=$SQLVB->fetch_array($result_salt))
|
||||
{
|
||||
if ($return_name)
|
||||
{
|
||||
return empty($script_cp1256) || ! $script_cp1256 ? $row1['username'] : $usrcp->kleeja_utf8($row1['username']);
|
||||
}
|
||||
|
||||
if(!$hashed)
|
||||
{
|
||||
$pass = ! $isVB5
|
||||
? md5(md5($pass) . $row1['salt']) // without normal md5
|
||||
: crypt(md5($pass), $row1['token']);
|
||||
if (! $hashed)
|
||||
{
|
||||
$pass = ! $isVB5
|
||||
? md5(md5($pass) . $row1['salt']) // without normal md5
|
||||
: crypt(md5($pass), $row1['token']);
|
||||
|
||||
$query = array(
|
||||
'SELECT' => '*',
|
||||
'FROM' => "`{$forum_prefix}user`",
|
||||
'WHERE' => "username='" . $SQLVB->real_escape($name) . "' AND ".($isVB5 ? 'token' : 'password')."='" . $SQLVB->real_escape($pass) . "' AND usergroupid != '8'"
|
||||
);
|
||||
|
||||
$result = $SQLVB->build($query);
|
||||
$query = [
|
||||
'SELECT' => '*',
|
||||
'FROM' => "`{$forum_prefix}user`",
|
||||
'WHERE' => "username='" . $SQLVB->real_escape($name) . "' AND " . ($isVB5 ? 'token' : 'password') . "='" . $SQLVB->real_escape($pass) . "' AND usergroupid != '8'"
|
||||
];
|
||||
|
||||
if ($SQLVB->num_rows($result) != 0)
|
||||
{
|
||||
while($row=$SQLVB->fetch_array($result))
|
||||
{
|
||||
if(!$loginadm)
|
||||
{
|
||||
define('USER_ID', $row['userid']);
|
||||
define('GROUP_ID', ($row['usergroupid'] == 6 ? 1 : 3));
|
||||
define('USER_NAME', empty($script_cp1256) || !$script_cp1256 ? $row['username'] : $usrcp->kleeja_utf8($row['username']));
|
||||
define('USER_MAIL', $row['email']);
|
||||
define('USER_ADMIN', ($row['usergroupid'] == 6 ? 1 : 0));
|
||||
}
|
||||
$result = $SQLVB->build($query);
|
||||
|
||||
//define('LAST_VISIT',$row['last_visit']);
|
||||
if ($SQLVB->num_rows($result) != 0)
|
||||
{
|
||||
while ($row=$SQLVB->fetch_array($result))
|
||||
{
|
||||
if (! $loginadm)
|
||||
{
|
||||
define('USER_ID', $row['userid']);
|
||||
define('GROUP_ID', ($row['usergroupid'] == 6 ? 1 : 3));
|
||||
define('USER_NAME', empty($script_cp1256) || ! $script_cp1256 ? $row['username'] : $usrcp->kleeja_utf8($row['username']));
|
||||
define('USER_MAIL', $row['email']);
|
||||
define('USER_ADMIN', ($row['usergroupid'] == 6 ? 1 : 0));
|
||||
}
|
||||
|
||||
$userinfo = $row;
|
||||
$userinfo['group_id'] = ($row['usergroupid'] == 6 ? 1 : 3);
|
||||
$user_y = kleeja_base64_encode(serialize(array('id'=>$row['userid'], 'name'=>USER_NAME, 'mail'=>$row['email'], 'last_visit'=>time())));
|
||||
|
||||
$hash_key_expire = sha1(md5($config['h_key'] . ($isVB5 ? $row['token'] : $row['password'])) . $expire);
|
||||
//define('LAST_VISIT',$row['last_visit']);
|
||||
|
||||
if(!$loginadm)
|
||||
{
|
||||
$usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt(
|
||||
$row['userid'] . '|' .
|
||||
($isVB5 ? $row['token'] : $row['password']) . '|' .
|
||||
$expire . '|' .
|
||||
$hash_key_expire . '|' .
|
||||
($row['usergroupid'] == 6 ? 1 : 3) . '|' .
|
||||
$user_y
|
||||
), $expire);
|
||||
}
|
||||
$userinfo = $row;
|
||||
$userinfo['group_id'] = ($row['usergroupid'] == 6 ? 1 : 3);
|
||||
$user_y = kleeja_base64_encode(serialize(['id'=>$row['userid'], 'name'=>USER_NAME, 'mail'=>$row['email'], 'last_visit'=>time()]));
|
||||
|
||||
$hash_key_expire = sha1(md5($config['h_key'] . ($isVB5 ? $row['token'] : $row['password'])) . $expire);
|
||||
|
||||
if (! $loginadm)
|
||||
{
|
||||
$usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt(
|
||||
$row['userid'] . '|' .
|
||||
($isVB5 ? $row['token'] : $row['password']) . '|' .
|
||||
$expire . '|' .
|
||||
$hash_key_expire . '|' .
|
||||
($row['usergroupid'] == 6 ? 1 : 3) . '|' .
|
||||
$user_y
|
||||
), $expire);
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_while_usrdata_vb_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
}
|
||||
$SQLVB->freeresult($result);
|
||||
}#nums_sql2
|
||||
else
|
||||
{
|
||||
$SQLVB->close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$loginadm)
|
||||
{
|
||||
define('USER_ID', $row1['userid']);
|
||||
define('USER_NAME', empty($script_cp1256) || !$script_cp1256 ? $row1['username'] : $usrcp->kleeja_utf8($row1['username']));
|
||||
define('USER_MAIL',$row1['email']);
|
||||
define('USER_ADMIN',($row1['usergroupid'] == 6) ? 1 : 0);
|
||||
define('GROUP_ID',($row1['usergroupid'] == 6) ? 1 : 3);
|
||||
$userinfo = $row1;
|
||||
$userinfo['group_id'] = ($row1['usergroupid'] == 6 ? 1 : 3);
|
||||
}
|
||||
}
|
||||
}#whil1
|
||||
}
|
||||
$SQLVB->freeresult($result);
|
||||
}//nums_sql2
|
||||
else
|
||||
{
|
||||
$SQLVB->close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $loginadm)
|
||||
{
|
||||
define('USER_ID', $row1['userid']);
|
||||
define('USER_NAME', empty($script_cp1256) || ! $script_cp1256 ? $row1['username'] : $usrcp->kleeja_utf8($row1['username']));
|
||||
define('USER_MAIL', $row1['email']);
|
||||
define('USER_ADMIN', ($row1['usergroupid'] == 6) ? 1 : 0);
|
||||
define('GROUP_ID', ($row1['usergroupid'] == 6) ? 1 : 3);
|
||||
$userinfo = $row1;
|
||||
$userinfo['group_id'] = ($row1['usergroupid'] == 6 ? 1 : 3);
|
||||
}
|
||||
}
|
||||
}//whil1
|
||||
|
||||
$SQLVB->freeresult($result_salt);
|
||||
$SQLVB->freeresult($result_salt);
|
||||
|
||||
unset($pass);
|
||||
$SQLVB->close();
|
||||
unset($pass);
|
||||
$SQLVB->close();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$SQLVB->close();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$SQLVB->close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function kleeja_auth_username ($user_id)
|
||||
{
|
||||
return kleeja_auth_login ($user_id, false, true, 0, false, true);
|
||||
return kleeja_auth_login ($user_id, false, true, 0, false, true);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
|
||||
//we are in cache now ..
|
||||
@@ -28,81 +28,80 @@ $SQL->set_utf8();
|
||||
//
|
||||
class cache
|
||||
{
|
||||
function get($name)
|
||||
{
|
||||
if(defined('DEV_STAGE'))
|
||||
{
|
||||
return false;
|
||||
public function get($name)
|
||||
{
|
||||
if (defined('DEV_STAGE'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$name = preg_replace('![^a-z0-9_]!', '_', $name);
|
||||
|
||||
if (file_exists(PATH . 'cache/' . $name . '.php'))
|
||||
{
|
||||
include PATH . 'cache/' . $name . '.php';
|
||||
return empty($data) ? false : $data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function exists($name)
|
||||
{
|
||||
$name = preg_replace('![^a-z0-9_]!', '_', $name);
|
||||
|
||||
if (file_exists(PATH . 'cache/' . $name . '.php'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function save($name, $data, $time = 86400)
|
||||
{
|
||||
//
|
||||
//We have problems if APC is enabled, so we disable our cache
|
||||
//system if it's lodoed to prevent those problems, but we will
|
||||
//try to fix it in the near future .. I hope that.
|
||||
//
|
||||
if(defined('APC_CACHE'))
|
||||
{
|
||||
//return;
|
||||
}
|
||||
|
||||
$name = preg_replace('![^a-z0-9_]!i', '_', $name);
|
||||
$data_for_save = '<?' . 'php' . "\n";
|
||||
$data_for_save .= '//Cache file, generated for Kleeja at ' . gmdate('d-m-Y h:i A') . "\n\n";
|
||||
$data_for_save .= '//No direct opening' . "\n";
|
||||
$data_for_save .= '(!defined("IN_COMMON") ? exit("hacking attemp!") : null);' . "\n\n";
|
||||
$data_for_save .= '//return false after x time' . "\n";
|
||||
$data_for_save .= 'if(time() > ' . (time() + $time) . ') return false;' . "\n\n";
|
||||
$data_for_save .= '$data = ' . var_export($data, true) . ";\n\n//end of cache";
|
||||
$name = preg_replace('![^a-z0-9_]!', '_', $name);
|
||||
|
||||
if($fd = @fopen(PATH . 'cache/' . $name . '.php', 'w'))
|
||||
{
|
||||
@flock($fd, LOCK_EX); // exlusive look
|
||||
@fwrite($fd, $data_for_save);
|
||||
@flock($fd, LOCK_UN);
|
||||
@fclose($fd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (file_exists(PATH . 'cache/' . $name . '.php'))
|
||||
{
|
||||
include PATH . 'cache/' . $name . '.php';
|
||||
return empty($data) ? false : $data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function clean($name)
|
||||
{
|
||||
if(is_array($name))
|
||||
{
|
||||
foreach($name as $n)
|
||||
{
|
||||
$this->clean($n);
|
||||
}
|
||||
return;
|
||||
}
|
||||
public function exists($name)
|
||||
{
|
||||
$name = preg_replace('![^a-z0-9_]!', '_', $name);
|
||||
|
||||
$name = preg_replace('![^a-z0-9_]!i', '_', $name);
|
||||
kleeja_unlink(PATH . 'cache/' . $name . '.php');
|
||||
}
|
||||
if (file_exists(PATH . 'cache/' . $name . '.php'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function save($name, $data, $time = 86400)
|
||||
{
|
||||
//
|
||||
//We have problems if APC is enabled, so we disable our cache
|
||||
//system if it's lodoed to prevent those problems, but we will
|
||||
//try to fix it in the near future .. I hope that.
|
||||
//
|
||||
if (defined('APC_CACHE'))
|
||||
{
|
||||
//return;
|
||||
}
|
||||
|
||||
$name = preg_replace('![^a-z0-9_]!i', '_', $name);
|
||||
$data_for_save = '<?' . 'php' . "\n";
|
||||
$data_for_save .= '//Cache file, generated for Kleeja at ' . gmdate('d-m-Y h:i A') . "\n\n";
|
||||
$data_for_save .= '//No direct opening' . "\n";
|
||||
$data_for_save .= '(!defined("IN_COMMON") ? exit("hacking attemp!") : null);' . "\n\n";
|
||||
$data_for_save .= '//return false after x time' . "\n";
|
||||
$data_for_save .= 'if(time() > ' . (time() + $time) . ') return false;' . "\n\n";
|
||||
$data_for_save .= '$data = ' . var_export($data, true) . ";\n\n//end of cache";
|
||||
|
||||
if ($fd = @fopen(PATH . 'cache/' . $name . '.php', 'w'))
|
||||
{
|
||||
@flock($fd, LOCK_EX); // exlusive look
|
||||
@fwrite($fd, $data_for_save);
|
||||
@flock($fd, LOCK_UN);
|
||||
@fclose($fd);
|
||||
}
|
||||
}
|
||||
|
||||
public function clean($name)
|
||||
{
|
||||
if (is_array($name))
|
||||
{
|
||||
foreach ($name as $n)
|
||||
{
|
||||
$this->clean($n);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$name = preg_replace('![^a-z0-9_]!i', '_', $name);
|
||||
kleeja_unlink(PATH . 'cache/' . $name . '.php');
|
||||
}
|
||||
}
|
||||
|
||||
$cache = new cache;
|
||||
@@ -113,50 +112,50 @@ $cache = new cache;
|
||||
//
|
||||
//get config data from config table ...
|
||||
//
|
||||
if (!($config = $cache->get('data_config')))
|
||||
if (! ($config = $cache->get('data_config')))
|
||||
{
|
||||
$query = array(
|
||||
'SELECT' => 'c.name, c.value',
|
||||
'FROM' => "{$dbprefix}config c",
|
||||
'WHERE' => 'c.dynamic = 0',
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 'c.name, c.value',
|
||||
'FROM' => "{$dbprefix}config c",
|
||||
'WHERE' => 'c.dynamic = 0',
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_config_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$config[$row['name']] = $row['value'];
|
||||
}
|
||||
$result = $SQL->build($query);
|
||||
|
||||
$SQL->freeresult($result);
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$config[$row['name']] = $row['value'];
|
||||
}
|
||||
|
||||
$cache->save('data_config', $config);
|
||||
$SQL->freeresult($result);
|
||||
|
||||
$cache->save('data_config', $config);
|
||||
}
|
||||
|
||||
//
|
||||
//get language terms from lang table ...
|
||||
//
|
||||
|
||||
if (!($olang = $cache->get('data_lang' . $config['language']))) {
|
||||
|
||||
$query = array(
|
||||
'SELECT' => 'l.word, l.trans',
|
||||
'FROM' => "{$dbprefix}lang l",
|
||||
'WHERE' => "l.lang_id='" . $SQL->escape($config['language']) . "'",
|
||||
);
|
||||
if (! ($olang = $cache->get('data_lang' . $config['language'])))
|
||||
{
|
||||
$query = [
|
||||
'SELECT' => 'l.word, l.trans',
|
||||
'FROM' => "{$dbprefix}lang l",
|
||||
'WHERE' => "l.lang_id='" . $SQL->escape($config['language']) . "'",
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_lang_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$result = $SQL->build($query);
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$olang[$row['word']] = $row['trans'];
|
||||
}
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$olang[$row['word']] = $row['trans'];
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
$SQL->freeresult($result);
|
||||
|
||||
$cache->save('data_lang' . $config['language'], $olang);
|
||||
}
|
||||
@@ -165,70 +164,70 @@ if (!($olang = $cache->get('data_lang' . $config['language']))) {
|
||||
//
|
||||
//stats to cache
|
||||
//
|
||||
if (!($stats = $cache->get('data_stats')))
|
||||
if (! ($stats = $cache->get('data_stats')))
|
||||
{
|
||||
$query = array(
|
||||
'SELECT' => 's.files, s.imgs, s.sizes, s.users, s.last_file, s.last_f_del, s.last_google' .
|
||||
', s.last_bing, s.google_num, s.bing_num, s.lastuser',
|
||||
'FROM' => "{$dbprefix}stats s"
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 's.files, s.imgs, s.sizes, s.users, s.last_file, s.last_f_del, s.last_google' .
|
||||
', s.last_bing, s.google_num, s.bing_num, s.lastuser',
|
||||
'FROM' => "{$dbprefix}stats s"
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_stats_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$result = $SQL->build($query);
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$stats = array(
|
||||
'stat_files' => $row['files'],
|
||||
'stat_imgs' => $row['imgs'],
|
||||
'stat_sizes' => $row['sizes'],
|
||||
'stat_users' => $row['users'],
|
||||
'stat_last_file' => $row['last_file'],
|
||||
'stat_last_f_del' => $row['last_f_del'],
|
||||
'stat_last_google' => $row['last_google'],
|
||||
'stat_last_bing' => $row['last_bing'],
|
||||
'stat_google_num' => $row['google_num'],
|
||||
'stat_bing_num' => $row['bing_num'],
|
||||
'stat_last_user' => $row['lastuser']
|
||||
);
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$stats = [
|
||||
'stat_files' => $row['files'],
|
||||
'stat_imgs' => $row['imgs'],
|
||||
'stat_sizes' => $row['sizes'],
|
||||
'stat_users' => $row['users'],
|
||||
'stat_last_file' => $row['last_file'],
|
||||
'stat_last_f_del' => $row['last_f_del'],
|
||||
'stat_last_google' => $row['last_google'],
|
||||
'stat_last_bing' => $row['last_bing'],
|
||||
'stat_google_num' => $row['google_num'],
|
||||
'stat_bing_num' => $row['bing_num'],
|
||||
'stat_last_user' => $row['lastuser']
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('while_fetch_stats_in_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
}
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
$SQL->freeresult($result);
|
||||
|
||||
#save the stats for hour and then refresh them
|
||||
$cache->save('data_stats', $stats, 3600);
|
||||
//save the stats for hour and then refresh them
|
||||
$cache->save('data_stats', $stats, 3600);
|
||||
|
||||
#also, save the data for the charts later
|
||||
$query = array(
|
||||
'SELECT' => 'f.filter_uid',
|
||||
'FROM' => "{$dbprefix}filters f",
|
||||
'WHERE' => "f.filter_type='stats_for_acp' AND f.filter_uid = '" . date('d-n-Y') . "'"
|
||||
);
|
||||
//also, save the data for the charts later
|
||||
$query = [
|
||||
'SELECT' => 'f.filter_uid',
|
||||
'FROM' => "{$dbprefix}filters f",
|
||||
'WHERE' => "f.filter_type='stats_for_acp' AND f.filter_uid = '" . date('d-n-Y') . "'"
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$result = $SQL->build($query);
|
||||
|
||||
#if already there is stats for this day, just update it, if not insert a new one
|
||||
if($SQL->num_rows($result))
|
||||
{
|
||||
$f_query = array(
|
||||
'UPDATE' => "{$dbprefix}filters",
|
||||
'SET' => "filter_value='" . implode(':', array($stats['stat_files'], $stats['stat_imgs'], $stats['stat_sizes'])) . "'",
|
||||
'WHERE' => "filter_type='stats_for_acp' AND filter_uid = '" . date('d-n-Y') . "'"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$f_query = array(
|
||||
'INSERT' => 'filter_uid, filter_type ,filter_value ,filter_time',
|
||||
'INTO' => "{$dbprefix}filters",
|
||||
'VALUES' => "'" . date('d-n-Y') . "', 'stats_for_acp', '" . implode(':', array($stats['stat_files'], $stats['stat_imgs'], $stats['stat_sizes'])) . "', " . time()
|
||||
);
|
||||
}
|
||||
//if already there is stats for this day, just update it, if not insert a new one
|
||||
if ($SQL->num_rows($result))
|
||||
{
|
||||
$f_query = [
|
||||
'UPDATE' => "{$dbprefix}filters",
|
||||
'SET' => "filter_value='" . implode(':', [$stats['stat_files'], $stats['stat_imgs'], $stats['stat_sizes']]) . "'",
|
||||
'WHERE' => "filter_type='stats_for_acp' AND filter_uid = '" . date('d-n-Y') . "'"
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$f_query = [
|
||||
'INSERT' => 'filter_uid, filter_type ,filter_value ,filter_time',
|
||||
'INTO' => "{$dbprefix}filters",
|
||||
'VALUES' => "'" . date('d-n-Y') . "', 'stats_for_acp', '" . implode(':', [$stats['stat_files'], $stats['stat_imgs'], $stats['stat_sizes']]) . "', " . time()
|
||||
];
|
||||
}
|
||||
|
||||
$SQL->build($f_query);
|
||||
$SQL->build($f_query);
|
||||
}
|
||||
|
||||
|
||||
@@ -239,167 +238,167 @@ unset($stats);
|
||||
//
|
||||
//get banned ips data from stats table ...
|
||||
//
|
||||
if (!($banss = $cache->get('data_ban')))
|
||||
if (! ($banss = $cache->get('data_ban')))
|
||||
{
|
||||
$query = array(
|
||||
'SELECT' => 's.ban',
|
||||
'FROM' => "{$dbprefix}stats s"
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 's.ban',
|
||||
'FROM' => "{$dbprefix}stats s"
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_ban_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
$result = $SQL->build($query);
|
||||
$result = $SQL->build($query);
|
||||
|
||||
$row = $SQL->fetch_array($result);
|
||||
$ban1 = $row['ban'];
|
||||
$SQL->freeresult($result);
|
||||
$row = $SQL->fetch_array($result);
|
||||
$ban1 = $row['ban'];
|
||||
$SQL->freeresult($result);
|
||||
|
||||
$banss = array();
|
||||
$banss = [];
|
||||
|
||||
if (!empty($ban1) || $ban1 != ' '|| $ban1 != ' ')
|
||||
{
|
||||
//seperate ips ..
|
||||
$ban2 = explode('|', $ban1);
|
||||
for ($i=0; $i<sizeof($ban2); $i++)
|
||||
{
|
||||
$banss[$i] = $ban2[$i];
|
||||
}
|
||||
}
|
||||
if (! empty($ban1) || $ban1 != ' '|| $ban1 != ' ')
|
||||
{
|
||||
//seperate ips ..
|
||||
$ban2 = explode('|', $ban1);
|
||||
|
||||
for ($i=0; $i<sizeof($ban2); $i++)
|
||||
{
|
||||
$banss[$i] = $ban2[$i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
unset($ban1, $ban2, $gt);
|
||||
unset($ban1, $ban2, $gt);
|
||||
|
||||
$cache->save('data_ban', $banss);
|
||||
$cache->save('data_ban', $banss);
|
||||
}
|
||||
|
||||
//
|
||||
//get rules data from stats table ...
|
||||
//
|
||||
if (!($ruless = $cache->get('data_rules')))
|
||||
if (! ($ruless = $cache->get('data_rules')))
|
||||
{
|
||||
$query = array(
|
||||
'SELECT' => 's.rules',
|
||||
'FROM' => "{$dbprefix}stats s"
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 's.rules',
|
||||
'FROM' => "{$dbprefix}stats s"
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_rules_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
$result = $SQL->build($query);
|
||||
$result = $SQL->build($query);
|
||||
|
||||
$row = $SQL->fetch_array($result);
|
||||
$ruless = $row['rules'];
|
||||
$SQL->freeresult($result);
|
||||
$row = $SQL->fetch_array($result);
|
||||
$ruless = $row['rules'];
|
||||
$SQL->freeresult($result);
|
||||
|
||||
$cache->save('data_rules', $ruless);
|
||||
$cache->save('data_rules', $ruless);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//get ex-header-footer data from stats table …
|
||||
//
|
||||
if (!($extras = $cache->get('data_extra')))
|
||||
if (! ($extras = $cache->get('data_extra')))
|
||||
{
|
||||
$query = array(
|
||||
'SELECT' => 's.ex_header, s.ex_footer',
|
||||
'FROM' => "{$dbprefix}stats s"
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 's.ex_header, s.ex_footer',
|
||||
'FROM' => "{$dbprefix}stats s"
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_extra_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
$result = $SQL->build($query);
|
||||
$result = $SQL->build($query);
|
||||
|
||||
$row = $SQL->fetch_array($result);
|
||||
|
||||
$extras = array(
|
||||
'header' => $row['ex_header'],
|
||||
'footer' => $row['ex_footer']
|
||||
);
|
||||
$row = $SQL->fetch_array($result);
|
||||
|
||||
$SQL->freeresult($result);
|
||||
$extras = [
|
||||
'header' => $row['ex_header'],
|
||||
'footer' => $row['ex_footer']
|
||||
];
|
||||
|
||||
$cache->save('data_extra', $extras);
|
||||
$SQL->freeresult($result);
|
||||
|
||||
$cache->save('data_extra', $extras);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//Get groups data
|
||||
//
|
||||
if (!($d_groups = $cache->get('data_groups')))
|
||||
if (! ($d_groups = $cache->get('data_groups')))
|
||||
{
|
||||
$d_groups = array();
|
||||
|
||||
#data
|
||||
$query = array(
|
||||
'SELECT' => 'g.*',
|
||||
'FROM' => "{$dbprefix}groups g",
|
||||
'ORDER_BY' => 'g.group_id ASC',
|
||||
);
|
||||
$d_groups = [];
|
||||
|
||||
//data
|
||||
$query = [
|
||||
'SELECT' => 'g.*',
|
||||
'FROM' => "{$dbprefix}groups g",
|
||||
'ORDER_BY' => 'g.group_id ASC',
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_groups_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
$result = $SQL->build($query);
|
||||
|
||||
#Initiating
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$d_groups[$row['group_id']]['data'] = $row;
|
||||
$d_groups[$row['group_id']]['configs'] = array();
|
||||
$d_groups[$row['group_id']]['acls'] = array();
|
||||
$d_groups[$row['group_id']]['exts'] = array();
|
||||
}
|
||||
$SQL->freeresult($result);
|
||||
$result = $SQL->build($query);
|
||||
|
||||
#configs
|
||||
$query = array(
|
||||
'SELECT' => 'g.group_id, g.name, g.value',
|
||||
'FROM' => "{$dbprefix}groups_data g",
|
||||
'ORDER_BY' => 'g.group_id ASC',
|
||||
);
|
||||
//Initiating
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$d_groups[$row['group_id']]['data'] = $row;
|
||||
$d_groups[$row['group_id']]['configs'] = [];
|
||||
$d_groups[$row['group_id']]['acls'] = [];
|
||||
$d_groups[$row['group_id']]['exts'] = [];
|
||||
}
|
||||
$SQL->freeresult($result);
|
||||
|
||||
//configs
|
||||
$query = [
|
||||
'SELECT' => 'g.group_id, g.name, g.value',
|
||||
'FROM' => "{$dbprefix}groups_data g",
|
||||
'ORDER_BY' => 'g.group_id ASC',
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_groups_data_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
$result = $SQL->build($query);
|
||||
$result = $SQL->build($query);
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$d_groups[$row['group_id']]['configs'][$row['name']] = $row['value'];
|
||||
}
|
||||
$SQL->freeresult($result);
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$d_groups[$row['group_id']]['configs'][$row['name']] = $row['value'];
|
||||
}
|
||||
$SQL->freeresult($result);
|
||||
|
||||
#acl
|
||||
$query2 = array(
|
||||
'SELECT' => 'g.group_id, g.acl_name, g.acl_can',
|
||||
'FROM' => "{$dbprefix}groups_acl g",
|
||||
'ORDER_BY' => 'g.group_id ASC',
|
||||
);
|
||||
//acl
|
||||
$query2 = [
|
||||
'SELECT' => 'g.group_id, g.acl_name, g.acl_can',
|
||||
'FROM' => "{$dbprefix}groups_acl g",
|
||||
'ORDER_BY' => 'g.group_id ASC',
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_groups_acls_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
$result2 = $SQL->build($query2);
|
||||
$result2 = $SQL->build($query2);
|
||||
|
||||
while($row=$SQL->fetch_array($result2))
|
||||
{
|
||||
$d_groups[$row['group_id']]['acls'][$row['acl_name']] = (int) $row['acl_can'];
|
||||
}
|
||||
$SQL->freeresult($result2);
|
||||
while ($row=$SQL->fetch_array($result2))
|
||||
{
|
||||
$d_groups[$row['group_id']]['acls'][$row['acl_name']] = (int) $row['acl_can'];
|
||||
}
|
||||
$SQL->freeresult($result2);
|
||||
|
||||
#exts
|
||||
$query3 = array(
|
||||
'SELECT' => 'g.group_id, g.ext, g.size',
|
||||
'FROM' => "{$dbprefix}groups_exts g",
|
||||
'ORDER_BY' => 'g.group_id ASC',
|
||||
);
|
||||
//exts
|
||||
$query3 = [
|
||||
'SELECT' => 'g.group_id, g.ext, g.size',
|
||||
'FROM' => "{$dbprefix}groups_exts g",
|
||||
'ORDER_BY' => 'g.group_id ASC',
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_groups_exts_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
$result3 = $SQL->build($query3);
|
||||
$result3 = $SQL->build($query3);
|
||||
|
||||
while($row=$SQL->fetch_array($result3))
|
||||
{
|
||||
$d_groups[$row['group_id']]['exts'][$row['ext']] = (int) $row['size'];
|
||||
}
|
||||
$SQL->freeresult($result3);
|
||||
while ($row=$SQL->fetch_array($result3))
|
||||
{
|
||||
$d_groups[$row['group_id']]['exts'][$row['ext']] = (int) $row['size'];
|
||||
}
|
||||
$SQL->freeresult($result3);
|
||||
|
||||
unset($query, $query2, $query3, $result, $result2, $result3);
|
||||
unset($query, $query2, $query3, $result, $result2, $result3);
|
||||
|
||||
$cache->save('data_groups', $d_groups);
|
||||
$cache->save('data_groups', $d_groups);
|
||||
}
|
||||
|
||||
|
||||
// ummm, does this useful here
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('in_cache_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
@@ -7,23 +7,20 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Fix bug with path of font When using versions of the GD library lower than 2.0.18
|
||||
*/
|
||||
if(function_exists('putenv'))
|
||||
// Fix bug with path of font When using versions of the GD library lower than 2.0.18
|
||||
if (function_exists('putenv'))
|
||||
{
|
||||
@putenv('GDFONTPATH=' . realpath('.'));
|
||||
@putenv('GDFONTPATH=' . realpath('.'));
|
||||
}
|
||||
else if(function_exists('ini_set'))
|
||||
elseif (function_exists('ini_set'))
|
||||
{
|
||||
@ini_set('GDFONTPATH', realpath('.'));
|
||||
@ini_set('GDFONTPATH', realpath('.'));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* When any body request this file , he will see an image ..
|
||||
*/
|
||||
// When any body request this file , he will see an image ..
|
||||
kleeja_cpatcha_image();
|
||||
|
||||
exit();
|
||||
|
||||
//
|
||||
@@ -32,68 +29,68 @@ exit();
|
||||
//
|
||||
function kleeja_cpatcha_image()
|
||||
{
|
||||
//Let's generate a totally random string using md5
|
||||
$md5_hash = md5(rand(0,999));
|
||||
//Let's generate a totally random string using md5
|
||||
$md5_hash = md5(rand(0, 999));
|
||||
|
||||
//I think the bad things in captcha is two things, O and 0 , so let's remove zero.
|
||||
$security_code = str_replace('0', '', $md5_hash);
|
||||
//I think the bad things in captcha is two things, O and 0 , so let's remove zero.
|
||||
$security_code = str_replace('0', '', $md5_hash);
|
||||
|
||||
//We don't need a 32 character long string so we trim it down to 5
|
||||
$security_code = substr($security_code, 15, 4);
|
||||
//We don't need a 32 character long string so we trim it down to 5
|
||||
$security_code = substr($security_code, 15, 4);
|
||||
|
||||
//Set the session to store the security code
|
||||
$_SESSION["klj_sec_code"] = $security_code;
|
||||
//Set the session to store the security code
|
||||
$_SESSION['klj_sec_code'] = $security_code;
|
||||
|
||||
//Set the image width and height
|
||||
$width = 150;
|
||||
$height = 25;
|
||||
//Set the image width and height
|
||||
$width = 150;
|
||||
$height = 25;
|
||||
|
||||
//Create the image resource
|
||||
$image = ImageCreate($width, $height);
|
||||
//Create the image resource
|
||||
$image = imagecreate($width, $height);
|
||||
|
||||
//We are making three colors, white, black and gray
|
||||
$white = ImageColorAllocate($image, 255, 255, 255);
|
||||
$black = ImageColorAllocate($image, rand(0, 100), 0, rand(0, 50));
|
||||
$grey = ImageColorAllocate($image, 204, 204, 204);
|
||||
//We are making three colors, white, black and gray
|
||||
$white = imagecolorallocate($image, 255, 255, 255);
|
||||
$black = imagecolorallocate($image, rand(0, 100), 0, rand(0, 50));
|
||||
$grey = imagecolorallocate($image, 204, 204, 204);
|
||||
|
||||
//Make the background black
|
||||
ImageFill($image, 0, 0, $black);
|
||||
|
||||
//options
|
||||
$x = 10;
|
||||
$y = 14;
|
||||
$angle = rand(-7, -10);
|
||||
//Make the background black
|
||||
imagefill($image, 0, 0, $black);
|
||||
|
||||
//Add randomly generated string in white to the image
|
||||
if(function_exists('imagettftext'))
|
||||
{
|
||||
//
|
||||
// We figure a bug that happens when you add font name without './' before it ..
|
||||
// he search in the Linux fonts cache , but when you add './' he will know it's our font.
|
||||
//
|
||||
imagettftext ($image, 16,$angle , rand(50, $x), $y+rand(1,3), $white, dirname(__FILE__) . '/arial.ttf', $security_code);
|
||||
#imagettftext ($image, 7, 0, $width-30, $height-4, $white,'./arial.ttf', 'Kleeja');
|
||||
}
|
||||
else
|
||||
{
|
||||
imagestring ($image, imageloadfont(dirname(__FILE__) . '/arial.gdf'), $x+rand(10,15), $y-rand(10,15), $security_code, $white);
|
||||
#imagestring ($image, 1, $width-35, $height-10, 'Kleeja', ImageColorAllocate($image, 200, 200, 200));
|
||||
}
|
||||
//options
|
||||
$x = 10;
|
||||
$y = 14;
|
||||
$angle = rand(-7, -10);
|
||||
|
||||
//Throw in some lines to make it a little bit harder for any bots to break
|
||||
ImageRectangle($image,0,0,$width-1,$height-1,$grey);
|
||||
imageline($image, 0, $height/2, $width, $height/2, $grey);
|
||||
imageline($image, $width/2, 0, $width/2, $height, $grey);
|
||||
|
||||
|
||||
//Tell the browser what kind of file is come in
|
||||
header("Content-Type: image/png");
|
||||
//Add randomly generated string in white to the image
|
||||
if (function_exists('imagettftext'))
|
||||
{
|
||||
//
|
||||
// We figure a bug that happens when you add font name without './' before it ..
|
||||
// he search in the Linux fonts cache , but when you add './' he will know it's our font.
|
||||
//
|
||||
imagettftext ($image, 16, $angle, rand(50, $x), $y+rand(1, 3), $white, dirname(__FILE__) . '/arial.ttf', $security_code);
|
||||
//imagettftext ($image, 7, 0, $width-30, $height-4, $white,'./arial.ttf', 'Kleeja');
|
||||
}
|
||||
else
|
||||
{
|
||||
imagestring ($image, imageloadfont(dirname(__FILE__) . '/arial.gdf'), $x+rand(10, 15), $y-rand(10, 15), $security_code, $white);
|
||||
//imagestring ($image, 1, $width-35, $height-10, 'Kleeja', ImageColorAllocate($image, 200, 200, 200));
|
||||
}
|
||||
|
||||
//Output the newly created image in jpeg format
|
||||
ImagePng($image);
|
||||
|
||||
//Free up resources
|
||||
ImageDestroy($image);
|
||||
//Throw in some lines to make it a little bit harder for any bots to break
|
||||
imagerectangle($image, 0, 0, $width-1, $height-1, $grey);
|
||||
imageline($image, 0, $height/2, $width, $height/2, $grey);
|
||||
imageline($image, $width/2, 0, $width/2, $height, $grey);
|
||||
|
||||
|
||||
//Tell the browser what kind of file is come in
|
||||
header('Content-Type: image/png');
|
||||
|
||||
//Output the newly created image in jpeg format
|
||||
imagepng($image);
|
||||
|
||||
//Free up resources
|
||||
imagedestroy($image);
|
||||
}
|
||||
|
||||
//<--- EOF
|
||||
|
||||
@@ -7,55 +7,56 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#not for directly open
|
||||
if (!defined('IN_KLEEJA'))
|
||||
//not for directly open
|
||||
if (! defined('IN_KLEEJA'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
#we are in the common file
|
||||
//we are in the common file
|
||||
define('IN_COMMON', true);
|
||||
|
||||
|
||||
#filename of config.php
|
||||
//filename of config.php
|
||||
define('KLEEJA_CONFIG_FILE', 'config.php');
|
||||
|
||||
#plugins folder
|
||||
//plugins folder
|
||||
define('KLEEJA_PLUGINS_FOLDER', 'plugins');
|
||||
|
||||
|
||||
|
||||
if(@extension_loaded('apc'))
|
||||
if (@extension_loaded('apc'))
|
||||
{
|
||||
define('APC_CACHE', true);
|
||||
define('APC_CACHE', true);
|
||||
}
|
||||
|
||||
#path
|
||||
if(!defined('PATH'))
|
||||
//path
|
||||
if (! defined('PATH'))
|
||||
{
|
||||
if(!defined('__DIR__'))
|
||||
if (! defined('__DIR__'))
|
||||
{
|
||||
define('__DIR__', dirname(__FILE__));
|
||||
}
|
||||
define('PATH', str_replace(DIRECTORY_SEPARATOR . 'includes', '', __DIR__) . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
#no config
|
||||
if (!file_exists(PATH . KLEEJA_CONFIG_FILE))
|
||||
//no config
|
||||
if (! file_exists(PATH . KLEEJA_CONFIG_FILE))
|
||||
{
|
||||
header('Location: ./install/index.php');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
#there is a config
|
||||
//there is a config
|
||||
require_once PATH . KLEEJA_CONFIG_FILE;
|
||||
|
||||
|
||||
#admin files path
|
||||
//admin files path
|
||||
define('ADM_FILES_PATH', PATH . 'includes/adm');
|
||||
|
||||
#Report all errors, except notices
|
||||
//Report all errors, except notices
|
||||
error_reporting( defined('DEV_STAGE') ? E_ALL : E_ALL ^ E_NOTICE);
|
||||
|
||||
|
||||
@@ -64,50 +65,55 @@ error_reporting( defined('DEV_STAGE') ? E_ALL : E_ALL ^ E_NOTICE);
|
||||
*/
|
||||
function kleeja_show_error($error_number, $error_string = '', $error_file = '', $error_line = '')
|
||||
{
|
||||
switch ($error_number)
|
||||
{
|
||||
case E_NOTICE: case E_WARNING: case E_USER_WARNING: case E_USER_NOTICE: case E_STRICT: break;
|
||||
default:
|
||||
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">' . "\n<head>\n";
|
||||
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n";
|
||||
echo '<title>Kleeja Error</title>' . "\n" . '<style type="text/css">' . "\n\t";
|
||||
echo '.error {color: #333;background:#ffebe8;float:left;width:73%;text-align:left;margin-top:10px;border: 1px solid #dd3c10; padding: 10px;font-family:tahoma,arial;font-size: 12px;}' . "\n";
|
||||
echo "</style>\n</head>\n<body>\n\t" . '<div class="error">' . "\n\n\t\t<h2>Kleeja error : </h2><br />" . "\n";
|
||||
echo "\n\t\t<strong> [ " . $error_number . ':' . basename($error_file) . ':' . $error_line . ' ] </strong><br /><br />' . "\n\t\t" . $error_string . "\n\t";
|
||||
echo "\n\t\t" . '<br /><br /><small>Visit <a href="http://www.kleeja.com/" title="kleeja">Kleeja</a> Website for more details.</small>' . "\n\t";
|
||||
echo "</div>\n</body>\n</html>";
|
||||
global $SQL;
|
||||
if(isset($SQL))
|
||||
{
|
||||
@$SQL->close();
|
||||
}
|
||||
exit;
|
||||
break;
|
||||
switch ($error_number)
|
||||
{
|
||||
case E_NOTICE: case E_WARNING: case E_USER_WARNING: case E_USER_NOTICE: case E_STRICT: break;
|
||||
|
||||
default:
|
||||
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">' . "\n<head>\n";
|
||||
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n";
|
||||
echo '<title>Kleeja Error</title>' . "\n" . '<style type="text/css">' . "\n\t";
|
||||
echo '.error {color: #333;background:#ffebe8;float:left;width:73%;text-align:left;margin-top:10px;border: 1px solid #dd3c10; padding: 10px;font-family:tahoma,arial;font-size: 12px;}' . "\n";
|
||||
echo "</style>\n</head>\n<body>\n\t" . '<div class="error">' . "\n\n\t\t<h2>Kleeja error : </h2><br />" . "\n";
|
||||
echo "\n\t\t<strong> [ " . $error_number . ':' . basename($error_file) . ':' . $error_line . ' ] </strong><br /><br />' . "\n\t\t" . $error_string . "\n\t";
|
||||
echo "\n\t\t" . '<br /><br /><small>Visit <a href="http://www.kleeja.com/" title="kleeja">Kleeja</a> Website for more details.</small>' . "\n\t";
|
||||
echo "</div>\n</body>\n</html>";
|
||||
global $SQL;
|
||||
|
||||
if (isset($SQL))
|
||||
{
|
||||
@$SQL->close();
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
set_error_handler('kleeja_show_error');
|
||||
|
||||
#time of start and end and whatever
|
||||
//time of start and end and whatever
|
||||
function get_microtime()
|
||||
{
|
||||
list($usec, $sec) = explode(' ', microtime()); return ((float)$usec + (float)$sec);
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
return ((float) $usec + (float) $sec);
|
||||
}
|
||||
|
||||
//is bot ?
|
||||
function is_bot($bots = array('googlebot', 'bing' ,'msnbot'))
|
||||
function is_bot($bots = ['googlebot', 'bing' ,'msnbot'])
|
||||
{
|
||||
if(isset($_SERVER['HTTP_USER_AGENT']))
|
||||
{
|
||||
return preg_match('/(' . implode('|', $bots) . ')/i', ($_SERVER['HTTP_USER_AGENT'] ? $_SERVER['HTTP_USER_AGENT'] : @getenv('HTTP_USER_AGENT'))) ? true : false;
|
||||
}
|
||||
return false;
|
||||
if (isset($_SERVER['HTTP_USER_AGENT']))
|
||||
{
|
||||
return preg_match('/(' . implode('|', $bots) . ')/i', ($_SERVER['HTTP_USER_AGENT'] ? $_SERVER['HTTP_USER_AGENT'] : @getenv('HTTP_USER_AGENT'))) ? true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$starttm = get_microtime();
|
||||
|
||||
|
||||
if (!is_bot() && !isset($_SESSION))
|
||||
if (! is_bot() && ! isset($_SESSION))
|
||||
{
|
||||
session_start();
|
||||
}
|
||||
@@ -115,14 +121,15 @@ if (!is_bot() && !isset($_SESSION))
|
||||
|
||||
|
||||
|
||||
#no enough data
|
||||
//no enough data
|
||||
if (empty($dbname) || empty($dbuser))
|
||||
{
|
||||
header('Location: ./install/index.php');
|
||||
exit;
|
||||
header('Location: ./install/index.php');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
#include files .. & classes ..
|
||||
//include files .. & classes ..
|
||||
$root_path = PATH;
|
||||
// $db_type = isset($db_type) ? $db_type : 'mysqli';
|
||||
|
||||
@@ -137,82 +144,82 @@ include PATH . 'includes/functions_display.php';
|
||||
include PATH . 'includes/plugins.php';
|
||||
|
||||
|
||||
if(defined('IN_ADMIN'))
|
||||
if (defined('IN_ADMIN'))
|
||||
{
|
||||
include PATH . 'includes/functions_adm.php';
|
||||
include PATH . 'includes/functions_adm.php';
|
||||
}
|
||||
|
||||
|
||||
#fix integration problems
|
||||
if(empty($script_encoding))
|
||||
//fix integration problems
|
||||
if (empty($script_encoding))
|
||||
{
|
||||
$script_encoding = 'utf-8';
|
||||
$script_encoding = 'utf-8';
|
||||
}
|
||||
|
||||
#start classes ..
|
||||
//start classes ..
|
||||
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
|
||||
#no need after now
|
||||
//no need after now
|
||||
unset($dbpass);
|
||||
|
||||
|
||||
|
||||
$tpl = new kleeja_style;
|
||||
$tpl = new kleeja_style;
|
||||
$usrcp = new usrcp;
|
||||
|
||||
//then get caches
|
||||
include PATH . 'includes/cache.php';
|
||||
|
||||
#getting dynamic configs
|
||||
$query = array(
|
||||
'SELECT' => 'c.name, c.value',
|
||||
'FROM' => "{$dbprefix}config c",
|
||||
'WHERE' => 'c.dynamic = 1',
|
||||
);
|
||||
//getting dynamic configs
|
||||
$query = [
|
||||
'SELECT' => 'c.name, c.value',
|
||||
'FROM' => "{$dbprefix}config c",
|
||||
'WHERE' => 'c.dynamic = 1',
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
while($row=$SQL->fetch_array($result))
|
||||
while ($row=$SQL->fetch_array($result))
|
||||
{
|
||||
$config[$row['name']] = $row['value'];
|
||||
$config[$row['name']] = $row['value'];
|
||||
}
|
||||
|
||||
$SQL->freeresult($result);
|
||||
|
||||
#check user or guest
|
||||
//check user or guest
|
||||
$usrcp->kleeja_check_user();
|
||||
|
||||
#+ configs of the current group
|
||||
//+ configs of the current group
|
||||
$config = array_merge($config, (array) $d_groups[$usrcp->group_id()]['configs']);
|
||||
|
||||
|
||||
#admin path
|
||||
//admin path
|
||||
define('ADMIN_PATH', rtrim($config['siteurl'], '/') . '/admin/index.php');
|
||||
|
||||
|
||||
//no tpl caching in dev stage
|
||||
if(defined('DEV_STAGE'))
|
||||
if (defined('DEV_STAGE'))
|
||||
{
|
||||
$tpl->caching = false;
|
||||
$tpl->caching = false;
|
||||
}
|
||||
|
||||
|
||||
if(isset($config['foldername']))
|
||||
if (isset($config['foldername']))
|
||||
{
|
||||
$config['foldername'] = str_replace(
|
||||
array(
|
||||
[
|
||||
'{year}',
|
||||
'{month}',
|
||||
'{week}',
|
||||
'{day}',
|
||||
'{username}',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('W'),
|
||||
date('d'),
|
||||
$usrcp->name() ? preg_replace('/[^a-z0-9\._-]/', '', strtolower($usrcp->name())) : 'guest'
|
||||
),
|
||||
],
|
||||
$config['foldername']
|
||||
);
|
||||
}
|
||||
@@ -234,145 +241,145 @@ $klj_session = $SQL->escape(session_id());
|
||||
|
||||
|
||||
//site url must end with /
|
||||
if($config['siteurl'])
|
||||
if ($config['siteurl'])
|
||||
{
|
||||
$config['siteurl'] = $config['siteurl'][strlen($config['siteurl'])-1] != '/'
|
||||
$config['siteurl'] = $config['siteurl'][strlen($config['siteurl'])-1] != '/'
|
||||
? $config['siteurl'] . '/'
|
||||
: $config['siteurl'];
|
||||
}
|
||||
|
||||
|
||||
#check lang
|
||||
if(!$config['language'] || empty($config['language']))
|
||||
//check lang
|
||||
if (! $config['language'] || empty($config['language']))
|
||||
{
|
||||
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) > 2)
|
||||
{
|
||||
$config['language'] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
||||
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) > 2)
|
||||
{
|
||||
$config['language'] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
||||
|
||||
if(!file_exists(PATH . 'lang/' . $config['language'] . '/common.php'))
|
||||
{
|
||||
$config['language'] = 'en';
|
||||
}
|
||||
}
|
||||
if (! file_exists(PATH . 'lang/' . $config['language'] . '/common.php'))
|
||||
{
|
||||
$config['language'] = 'en';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#check style
|
||||
if(is_null($config['style']) || empty($config['style']))
|
||||
//check style
|
||||
if (is_null($config['style']) || empty($config['style']))
|
||||
{
|
||||
$config['style'] = 'default';
|
||||
$config['style'] = 'default';
|
||||
}
|
||||
|
||||
#check h_kay, important for kleeja
|
||||
if(empty($config['h_key']))
|
||||
//check h_kay, important for kleeja
|
||||
if (empty($config['h_key']))
|
||||
{
|
||||
$h_k = sha1(microtime() . rand(0, 100));
|
||||
$h_k = sha1(microtime() . rand(0, 100));
|
||||
|
||||
if(!update_config('h_key', $h_k))
|
||||
{
|
||||
add_config('h_key', $h_k);
|
||||
}
|
||||
if (! update_config('h_key', $h_k))
|
||||
{
|
||||
add_config('h_key', $h_k);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#current Kleeja admin style
|
||||
//current Kleeja admin style
|
||||
define('ACP_STYLE_NAME', 'Masmak');
|
||||
|
||||
#path variables for Kleeja
|
||||
$STYLE_PATH = $config['siteurl'] . 'styles/' . (trim($config['style_depend_on']) == '' ? $config['style'] : $config['style_depend_on']) . '/';
|
||||
$THIS_STYLE_PATH = $config['siteurl'] . 'styles/' . $config['style'] . '/';
|
||||
$THIS_STYLE_PATH_ABS = PATH . 'styles/' . $config['style'] . '/';
|
||||
$STYLE_PATH_ADMIN = $config['siteurl'] . 'admin/'. (is_browser('mobile') || defined('IN_MOBILE') ? ACP_STYLE_NAME : ACP_STYLE_NAME) . '/';
|
||||
$STYLE_PATH_ADMIN_ABS = PATH . 'admin/'. (is_browser('mobile') || defined('IN_MOBILE') ? ACP_STYLE_NAME . '/' : ACP_STYLE_NAME . '/');
|
||||
//path variables for Kleeja
|
||||
$STYLE_PATH = $config['siteurl'] . 'styles/' . (trim($config['style_depend_on']) == '' ? $config['style'] : $config['style_depend_on']) . '/';
|
||||
$THIS_STYLE_PATH = $config['siteurl'] . 'styles/' . $config['style'] . '/';
|
||||
$THIS_STYLE_PATH_ABS = PATH . 'styles/' . $config['style'] . '/';
|
||||
$STYLE_PATH_ADMIN = $config['siteurl'] . 'admin/' . (is_browser('mobile') || defined('IN_MOBILE') ? ACP_STYLE_NAME : ACP_STYLE_NAME) . '/';
|
||||
$STYLE_PATH_ADMIN_ABS = PATH . 'admin/' . (is_browser('mobile') || defined('IN_MOBILE') ? ACP_STYLE_NAME . '/' : ACP_STYLE_NAME . '/');
|
||||
$DEFAULT_PATH_ADMIN_ABS = PATH . 'admin/' . ACP_STYLE_NAME . '/';
|
||||
$DEFAULT_PATH_ADMIN = $config['siteurl'] . 'admin/'. ACP_STYLE_NAME . '/';
|
||||
$DEFAULT_PATH_ADMIN = $config['siteurl'] . 'admin/' . ACP_STYLE_NAME . '/';
|
||||
|
||||
|
||||
#get languge of common
|
||||
//get languge of common
|
||||
get_lang('common');
|
||||
|
||||
#run ban system
|
||||
//run ban system
|
||||
get_ban();
|
||||
|
||||
if(isset($_GET['go']) && $_GET['go'] == 'login')
|
||||
if (isset($_GET['go']) && $_GET['go'] == 'login')
|
||||
{
|
||||
define('IN_LOGIN', true);
|
||||
define('IN_LOGIN', true);
|
||||
}
|
||||
|
||||
#install.php exists
|
||||
//install.php exists
|
||||
if (
|
||||
file_exists(PATH . 'install') &&
|
||||
!defined('IN_ADMIN') &&
|
||||
!defined('IN_LOGIN') &&
|
||||
!defined('DEV_STAGE') &&
|
||||
!(defined('IN_GO') && in_array(g('go'), array('queue'))) &&
|
||||
!(defined('IN_UCP') && in_array(g('go'), array('captcha', 'login')))
|
||||
)
|
||||
{
|
||||
#Different message for admins! delete install folder
|
||||
kleeja_info((user_can('enter_acp') ? $lang['DELETE_INSTALL_FOLDER'] : $lang['WE_UPDATING_KLEEJA_NOW']), $lang['SITE_CLOSED']);
|
||||
file_exists(PATH . 'install') &&
|
||||
! defined('IN_ADMIN') &&
|
||||
! defined('IN_LOGIN') &&
|
||||
! defined('DEV_STAGE') &&
|
||||
! (defined('IN_GO') && in_array(g('go'), ['queue'])) &&
|
||||
! (defined('IN_UCP') && in_array(g('go'), ['captcha', 'login']))
|
||||
) {
|
||||
//Different message for admins! delete install folder
|
||||
kleeja_info((user_can('enter_acp') ? $lang['DELETE_INSTALL_FOLDER'] : $lang['WE_UPDATING_KLEEJA_NOW']), $lang['SITE_CLOSED']);
|
||||
}
|
||||
|
||||
|
||||
#is site close
|
||||
//is site close
|
||||
$login_page = '';
|
||||
|
||||
if (
|
||||
$config['siteclose'] == '1' &&
|
||||
!user_can('enter_acp') &&
|
||||
!defined('IN_LOGIN') &&
|
||||
!defined('IN_ADMIN') &&
|
||||
!(defined('IN_GO') && in_array(g('go'), array('queue'))) &&
|
||||
!(defined('IN_UCP') && in_array(g('go'), array('captcha', 'login', 'register', 'logout')))
|
||||
)
|
||||
{
|
||||
//if download, images ?
|
||||
if(
|
||||
( defined('IN_DOWNLOAD') && (ig('img') || ig('thmb') || ig('thmbf') || ig('imgf')) )
|
||||
$config['siteclose'] == '1' &&
|
||||
! user_can('enter_acp') &&
|
||||
! defined('IN_LOGIN') &&
|
||||
! defined('IN_ADMIN') &&
|
||||
! (defined('IN_GO') && in_array(g('go'), ['queue'])) &&
|
||||
! (defined('IN_UCP') && in_array(g('go'), ['captcha', 'login', 'register', 'logout']))
|
||||
) {
|
||||
//if download, images ?
|
||||
if (
|
||||
( defined('IN_DOWNLOAD') && (ig('img') || ig('thmb') || ig('thmbf') || ig('imgf')) )
|
||||
|| g('go', 'str', '') == 'queue'
|
||||
)
|
||||
{
|
||||
@$SQL->close();
|
||||
$fullname = "images/site_closed.jpg";
|
||||
$filesize = filesize($fullname);
|
||||
header("Content-length: $filesize");
|
||||
header("Content-type: image/jpg");
|
||||
readfile($fullname);
|
||||
exit;
|
||||
}
|
||||
) {
|
||||
@$SQL->close();
|
||||
$fullname = 'images/site_closed.jpg';
|
||||
$filesize = filesize($fullname);
|
||||
header("Content-length: $filesize");
|
||||
header('Content-type: image/jpg');
|
||||
readfile($fullname);
|
||||
|
||||
// Send a 503 HTTP response code to prevent search bots from indexing the maintenace message
|
||||
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
kleeja_info($config['closemsg'], $lang['SITE_CLOSED']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Send a 503 HTTP response code to prevent search bots from indexing the maintenace message
|
||||
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
kleeja_info($config['closemsg'], $lang['SITE_CLOSED']);
|
||||
}
|
||||
|
||||
#exceed total size
|
||||
if (($stat_sizes >= ($config['total_size'] *(1048576))) && !defined('IN_LOGIN') && !defined('IN_ADMIN'))// convert megabytes to bytes
|
||||
{
|
||||
// Send a 503 HTTP response code to prevent search bots from indexing the maintenace message
|
||||
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
kleeja_info($lang['SIZES_EXCCEDED'], $lang['STOP_FOR_SIZE']);
|
||||
//exceed total size
|
||||
if (($stat_sizes >= ($config['total_size'] *(1048576))) && ! defined('IN_LOGIN') && ! defined('IN_ADMIN'))
|
||||
{// convert megabytes to bytes
|
||||
// Send a 503 HTTP response code to prevent search bots from indexing the maintenace message
|
||||
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
kleeja_info($lang['SIZES_EXCCEDED'], $lang['STOP_FOR_SIZE']);
|
||||
}
|
||||
|
||||
#detect bots and save stats
|
||||
//detect bots and save stats
|
||||
kleeja_detecting_bots();
|
||||
|
||||
#check for page number
|
||||
if(empty($perpage) || intval($perpage) == 0)
|
||||
//check for page number
|
||||
if (empty($perpage) || intval($perpage) == 0)
|
||||
{
|
||||
$perpage = 14;
|
||||
$perpage = 14;
|
||||
}
|
||||
|
||||
|
||||
#captcha file
|
||||
//captcha file
|
||||
$captcha_file_path = $config['siteurl'] . 'ucp.php?go=captcha';
|
||||
if(defined('STOP_CAPTCHA'))
|
||||
|
||||
if (defined('STOP_CAPTCHA'))
|
||||
{
|
||||
$config['enable_captcha'] = 0;
|
||||
$config['enable_captcha'] = 0;
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('end_common', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
if(function_exists('session_register_shutdown'))
|
||||
if (function_exists('session_register_shutdown'))
|
||||
{
|
||||
session_register_shutdown();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,9 +9,9 @@
|
||||
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,42 +21,44 @@ if (!defined('IN_COMMON'))
|
||||
*/
|
||||
function kleeja_admin_err($msg, $navigation = true, $title='', $exit = true, $redirect = false, $rs = 3, $style = 'admin_err')
|
||||
{
|
||||
global $text, $tpl, $SHOW_LIST, $adm_extensions, $adm_extensions_menu;
|
||||
global $STYLE_PATH_ADMIN, $lang, $olang, $SQL, $MINI_MENU;
|
||||
global $text, $tpl, $SHOW_LIST, $adm_extensions, $adm_extensions_menu;
|
||||
global $STYLE_PATH_ADMIN, $lang, $olang, $SQL, $MINI_MENU;
|
||||
|
||||
|
||||
if(is_string($navigation))
|
||||
if (is_string($navigation))
|
||||
{
|
||||
$redirect = $navigation;
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('kleeja_admin_err_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
#Exception for ajax
|
||||
if(ig('_ajax_'))
|
||||
{
|
||||
//Exception for ajax
|
||||
if (ig('_ajax_'))
|
||||
{
|
||||
$text = $msg . ($redirect ? "\n" . '<script type="text/javascript">setTimeout("get_kleeja_link(\'' . str_replace('&', '&', $redirect) . '\');", ' . ($rs * 1000) . ');</script>' : '');
|
||||
echo_ajax(1, $tpl->display($style));
|
||||
$SQL->close();
|
||||
exit();
|
||||
}
|
||||
echo_ajax(1, $tpl->display($style));
|
||||
$SQL->close();
|
||||
|
||||
// assign {text} in err template
|
||||
$text = $msg . ($redirect != false ? redirect($redirect, false, false, $rs, true) : '');
|
||||
$SHOW_LIST = $navigation;
|
||||
exit();
|
||||
}
|
||||
|
||||
//header
|
||||
echo $tpl->display("admin_header");
|
||||
//show tpl
|
||||
echo $tpl->display($style);
|
||||
//footer
|
||||
echo $tpl->display("admin_footer");
|
||||
|
||||
if($exit)
|
||||
{
|
||||
$SQL->close();
|
||||
exit();
|
||||
}
|
||||
// assign {text} in err template
|
||||
$text = $msg . ($redirect != false ? redirect($redirect, false, false, $rs, true) : '');
|
||||
$SHOW_LIST = $navigation;
|
||||
|
||||
//header
|
||||
echo $tpl->display('admin_header');
|
||||
//show tpl
|
||||
echo $tpl->display($style);
|
||||
//footer
|
||||
echo $tpl->display('admin_footer');
|
||||
|
||||
if ($exit)
|
||||
{
|
||||
$SQL->close();
|
||||
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,12 +66,12 @@ function kleeja_admin_err($msg, $navigation = true, $title='', $exit = true, $re
|
||||
* Print information message on admin panel
|
||||
*
|
||||
* @adm
|
||||
* @param string $msg information message
|
||||
* @param bool $navigation show navigation menu or not
|
||||
* @param string $title information heading title
|
||||
* @param bool $exit if true, then halt after message
|
||||
* @param bool $redirect redirect after showing the message
|
||||
* @param int $rs delay the redirect in seconds
|
||||
* @param string $msg information message
|
||||
* @param bool $navigation show navigation menu or not
|
||||
* @param string $title information heading title
|
||||
* @param bool $exit if true, then halt after message
|
||||
* @param bool $redirect redirect after showing the message
|
||||
* @param int $rs delay the redirect in seconds
|
||||
*/
|
||||
function kleeja_admin_info($msg, $navigation=true, $title='', $exit=true, $redirect = false, $rs = 2)
|
||||
{
|
||||
@@ -81,62 +83,63 @@ function kleeja_admin_info($msg, $navigation=true, $title='', $exit=true, $redir
|
||||
/**
|
||||
* generate a filter..
|
||||
* @adm
|
||||
* @param string|integer $type filter_id or filter_uid
|
||||
* @param string $value filter value
|
||||
* @param bool $time filter time
|
||||
* @param bool $user user Id
|
||||
* @param string $status filter status
|
||||
* @param bool $uid filter unique id
|
||||
* @param string|integer $type filter_id or filter_uid
|
||||
* @param string $value filter value
|
||||
* @param bool $time filter time
|
||||
* @param bool $user user Id
|
||||
* @param string $status filter status
|
||||
* @param bool $uid filter unique id
|
||||
* @return bool|int|string
|
||||
*/
|
||||
function insert_filter($type, $value, $time = false, $user = false, $status = '', $uid = false)
|
||||
{
|
||||
global $SQL, $dbprefix, $userinfo;
|
||||
global $SQL, $dbprefix, $userinfo;
|
||||
|
||||
$user = !$user ? $userinfo['id'] : $user;
|
||||
$time = !$time ? time() : $time;
|
||||
$uid = $uid ? $uid : uniqid();
|
||||
$user = ! $user ? $userinfo['id'] : $user;
|
||||
$time = ! $time ? time() : $time;
|
||||
$uid = $uid ? $uid : uniqid();
|
||||
|
||||
$insert_query = array(
|
||||
'INSERT' => 'filter_uid, filter_type ,filter_value ,filter_time ,filter_user, filter_status',
|
||||
'INTO' => "{$dbprefix}filters",
|
||||
'VALUES' => "'" .$uid . "', '" . $SQL->escape($type) . "','" . $SQL->escape($value) . "', " . intval($time) . "," . intval($user) . ",'" . $SQL->escape($status) . "'"
|
||||
);
|
||||
$insert_query = [
|
||||
'INSERT' => 'filter_uid, filter_type ,filter_value ,filter_time ,filter_user, filter_status',
|
||||
'INTO' => "{$dbprefix}filters",
|
||||
'VALUES' => "'" . $uid . "', '" . $SQL->escape($type) . "','" . $SQL->escape($value) . "', " . intval($time) . ',' . intval($user) . ",'" . $SQL->escape($status) . "'"
|
||||
];
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('insert_sql_insert_filter_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$SQL->build($insert_query);
|
||||
$SQL->build($insert_query);
|
||||
|
||||
return $SQL->insert_id() ? $uid : false;
|
||||
return $SQL->insert_id() ? $uid : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update filter value..
|
||||
*
|
||||
* @param int|string $id_or_uid Number of filter_id or the unique id string of filter_uid
|
||||
* @param string $value The modified value of filter
|
||||
* @param string $filter_type if given, use it with sql where
|
||||
* @param bool|string $filter_status if given, update the filter status
|
||||
* @param bool $user_id
|
||||
* @param int|string $id_or_uid Number of filter_id or the unique id string of filter_uid
|
||||
* @param string $value The modified value of filter
|
||||
* @param string $filter_type if given, use it with sql where
|
||||
* @param bool|string $filter_status if given, update the filter status
|
||||
* @param bool $user_id
|
||||
* @return bool
|
||||
*/
|
||||
function update_filter($id_or_uid, $value, $filter_type = 'general', $filter_status = false, $user_id = false)
|
||||
{
|
||||
global $SQL, $dbprefix;
|
||||
|
||||
$update_query = array(
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}filters",
|
||||
'SET' => "filter_value='" . $SQL->escape($value) . "'" . ($filter_status ? ", filter_status='" . $SQL->escape($filter_status) . "'" : ''),
|
||||
'WHERE' => (strval(intval($id_or_uid)) == strval($id_or_uid) ? 'filter_id=' . intval($id_or_uid) : "filter_uid='" . $SQL->escape($id_or_uid) . "'")
|
||||
'SET' => "filter_value='" . $SQL->escape($value) . "'" . ($filter_status ? ", filter_status='" . $SQL->escape($filter_status) . "'" : ''),
|
||||
'WHERE' => (strval(intval($id_or_uid)) == strval($id_or_uid) ? 'filter_id=' . intval($id_or_uid) : "filter_uid='" . $SQL->escape($id_or_uid) . "'")
|
||||
. ($filter_type ? " AND filter_type='" . $SQL->escape($filter_type) . "'" : '')
|
||||
. ($user_id ? " AND filter_user=" . intval($user_id) . "" : '')
|
||||
);
|
||||
. ($user_id ? ' AND filter_user=' . intval($user_id) . '' : '')
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('update_filter_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$SQL->build($update_query);
|
||||
if ($SQL->affected())
|
||||
{
|
||||
|
||||
if ($SQL->affected())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -147,41 +150,42 @@ function update_filter($id_or_uid, $value, $filter_type = 'general', $filter_sta
|
||||
/**
|
||||
* Get filter from db..
|
||||
*
|
||||
* @param string|int $item The value of $get_by, to get the filter depend on it
|
||||
* @param bool|string $filter_type if given, use it with sql where
|
||||
* @param bool $just_value If true the return value should be just filter_value otherwise all filter rows
|
||||
* @param string $get_by The name of filter column we want to get the filter value from
|
||||
* @param bool $user_id
|
||||
* @param string|int $item The value of $get_by, to get the filter depend on it
|
||||
* @param bool|string $filter_type if given, use it with sql where
|
||||
* @param bool $just_value If true the return value should be just filter_value otherwise all filter rows
|
||||
* @param string $get_by The name of filter column we want to get the filter value from
|
||||
* @param bool $user_id
|
||||
* @return mixed
|
||||
*/
|
||||
function get_filter($item, $filter_type = false, $just_value = false, $get_by = 'filter_uid', $user_id = false)
|
||||
{
|
||||
global $dbprefix, $SQL;
|
||||
|
||||
$valid_filter_columns = array('filter_id', 'filter_uid', 'filter_user', 'filter_status');
|
||||
$valid_filter_columns = ['filter_id', 'filter_uid', 'filter_user', 'filter_status'];
|
||||
|
||||
if (!in_array($get_by, $valid_filter_columns))
|
||||
{
|
||||
if (! in_array($get_by, $valid_filter_columns))
|
||||
{
|
||||
$get_by = 'filter_uid';
|
||||
}
|
||||
|
||||
$query = array(
|
||||
$query = [
|
||||
'SELECT' => $just_value ? 'f.filter_value' : 'f.*',
|
||||
'FROM' => "{$dbprefix}filters f",
|
||||
'WHERE' => "f." . $get_by . " = " . ($get_by == 'filter_id' ? intval($item) : "'" . $SQL->escape($item) . "'")
|
||||
'FROM' => "{$dbprefix}filters f",
|
||||
'WHERE' => 'f.' . $get_by . ' = ' . ($get_by == 'filter_id' ? intval($item) : "'" . $SQL->escape($item) . "'")
|
||||
. ($filter_type ? " AND f.filter_type='" . $SQL->escape($filter_type) . "'" : '')
|
||||
. ($user_id ? " AND f.filter_user=" . intval($user_id) . "" : '')
|
||||
);
|
||||
. ($user_id ? ' AND f.filter_user=' . intval($user_id) . '' : '')
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('get_filter_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$v = $SQL->fetch($result);
|
||||
$v = $SQL->fetch($result);
|
||||
|
||||
$SQL->free($result);
|
||||
if ($just_value)
|
||||
{
|
||||
|
||||
if ($just_value)
|
||||
{
|
||||
return $v['filter_value'];
|
||||
}
|
||||
|
||||
@@ -191,24 +195,24 @@ function get_filter($item, $filter_type = false, $just_value = false, $get_by =
|
||||
/**
|
||||
* check if filter exists or not
|
||||
*
|
||||
* @param string|int $item The value of $get_by, to find the filter depend on it
|
||||
* @param string $get_by The name of filter column we want to get the filter from
|
||||
* @param bool $filter_type
|
||||
* @param bool $user_id
|
||||
* @param string|int $item The value of $get_by, to find the filter depend on it
|
||||
* @param string $get_by The name of filter column we want to get the filter from
|
||||
* @param bool $filter_type
|
||||
* @param bool $user_id
|
||||
* @return bool|int
|
||||
*/
|
||||
function filter_exists($item, $get_by = 'filter_id', $filter_type = false, $user_id = false)
|
||||
{
|
||||
global $dbprefix, $SQL;
|
||||
|
||||
$query = array(
|
||||
$query = [
|
||||
'SELECT' => 'f.filter_id',
|
||||
'FROM' => "{$dbprefix}filters f",
|
||||
'WHERE' => "f." . $get_by . " = " . ($get_by == 'filter_id' ? intval($item) : "'" . $SQL->escape($item) . "'")
|
||||
'FROM' => "{$dbprefix}filters f",
|
||||
'WHERE' => 'f.' . $get_by . ' = ' . ($get_by == 'filter_id' ? intval($item) : "'" . $SQL->escape($item) . "'")
|
||||
. ($filter_type ? " AND f.filter_type='" . $SQL->escape($filter_type) . "'" : '')
|
||||
. ($user_id ? " AND f.filter_user=" . intval($user_id) . "" : '')
|
||||
. ($user_id ? ' AND f.filter_user=' . intval($user_id) . '' : '')
|
||||
|
||||
);
|
||||
];
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('filter_exists_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
@@ -221,190 +225,192 @@ function filter_exists($item, $get_by = 'filter_id', $filter_type = false, $user
|
||||
/**
|
||||
* costruct a query for the searches..
|
||||
* @adm
|
||||
* @param array $search Search options
|
||||
* @param array $search Search options
|
||||
* @return string
|
||||
*/
|
||||
function build_search_query($search)
|
||||
{
|
||||
if(!is_array($search))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
if (! is_array($search))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
global $SQL;
|
||||
global $SQL;
|
||||
|
||||
$search['filename'] = !isset($search['filename']) ? '' : $search['filename'];
|
||||
$search['username'] = !isset($search['username']) ? '' : $search['username'];
|
||||
$search['than'] = !isset($search['than']) ? '' : $search['than'];
|
||||
$search['size'] = !isset($search['size']) ? '' : $search['size'];
|
||||
$search['ups'] = !isset($search['ups']) ? '' : $search['ups'];
|
||||
$search['uthan'] = !isset($search['uthan']) ? '' : $search['uthan'];
|
||||
$search['rep'] = !isset($search['rep']) ? '' : $search['rep'];
|
||||
$search['rthan'] = !isset($search['rthan']) ? '' : $search['rthan'];
|
||||
$search['lastdown'] = !isset($search['lastdown']) ? '' : $search['lastdown'];
|
||||
$search['ext'] = !isset($search['ext']) ? '' : $search['ext'];
|
||||
$search['user_ip'] = !isset($search['user_ip']) ? '' : $search['user_ip'];
|
||||
$search['filename'] = ! isset($search['filename']) ? '' : $search['filename'];
|
||||
$search['username'] = ! isset($search['username']) ? '' : $search['username'];
|
||||
$search['than'] = ! isset($search['than']) ? '' : $search['than'];
|
||||
$search['size'] = ! isset($search['size']) ? '' : $search['size'];
|
||||
$search['ups'] = ! isset($search['ups']) ? '' : $search['ups'];
|
||||
$search['uthan'] = ! isset($search['uthan']) ? '' : $search['uthan'];
|
||||
$search['rep'] = ! isset($search['rep']) ? '' : $search['rep'];
|
||||
$search['rthan'] = ! isset($search['rthan']) ? '' : $search['rthan'];
|
||||
$search['lastdown'] = ! isset($search['lastdown']) ? '' : $search['lastdown'];
|
||||
$search['ext'] = ! isset($search['ext']) ? '' : $search['ext'];
|
||||
$search['user_ip'] = ! isset($search['user_ip']) ? '' : $search['user_ip'];
|
||||
|
||||
$file_namee = $search['filename'] != '' ? 'AND (f.real_filename LIKE \'%' . $SQL->escape($search['filename']) . '%\' OR f.name LIKE \'%' . $SQL->escape($search['filename']) . '%\')' : '';
|
||||
$usernamee = $search['username'] != '' ? 'AND u.name LIKE \'%' . $SQL->escape($search['username']) . '%\'' : '';
|
||||
$size_than = ' f.size ' . ($search['than']!=1 ? '<=' : '>=') . (intval($search['size']) * 1024) . ' ';
|
||||
$ups_than = $search['ups'] != '' ? 'AND f.uploads ' . ($search['uthan']!=1 ? '<' : '>') . intval($search['ups']) . ' ' : '';
|
||||
$rep_than = $search['rep'] != '' ? 'AND f.report ' . ($search['rthan']!=1 ? '<' : '>') . intval($search['rep']) . ' ' : '';
|
||||
$lstd_than = $search['lastdown'] != '' ? 'AND f.last_down =' . (time()-(intval($search['lastdown']) * (24 * 60 * 60))) . ' ' : '';
|
||||
$exte = $search['ext'] != '' ? "AND f.type IN ('" . implode("', '", @explode(",", $SQL->escape($search['ext']))) . "')" : '';
|
||||
$ipp = $search['user_ip'] != '' ? 'AND f.user_ip LIKE \'%' . $SQL->escape($search['user_ip']) . '%\' ' : '';
|
||||
$file_namee = $search['filename'] != '' ? 'AND (f.real_filename LIKE \'%' . $SQL->escape($search['filename']) . '%\' OR f.name LIKE \'%' . $SQL->escape($search['filename']) . '%\')' : '';
|
||||
$usernamee = $search['username'] != '' ? 'AND u.name LIKE \'%' . $SQL->escape($search['username']) . '%\'' : '';
|
||||
$size_than = ' f.size ' . ($search['than']!=1 ? '<=' : '>=') . (intval($search['size']) * 1024) . ' ';
|
||||
$ups_than = $search['ups'] != '' ? 'AND f.uploads ' . ($search['uthan']!=1 ? '<' : '>') . intval($search['ups']) . ' ' : '';
|
||||
$rep_than = $search['rep'] != '' ? 'AND f.report ' . ($search['rthan']!=1 ? '<' : '>') . intval($search['rep']) . ' ' : '';
|
||||
$lstd_than = $search['lastdown'] != '' ? 'AND f.last_down =' . (time()-(intval($search['lastdown']) * (24 * 60 * 60))) . ' ' : '';
|
||||
$exte = $search['ext'] != '' ? "AND f.type IN ('" . implode("', '", @explode(',', $SQL->escape($search['ext']))) . "')" : '';
|
||||
$ipp = $search['user_ip'] != '' ? 'AND f.user_ip LIKE \'%' . $SQL->escape($search['user_ip']) . '%\' ' : '';
|
||||
|
||||
return "$size_than $file_namee $ups_than $exte $rep_than $usernamee $lstd_than $exte $ipp";
|
||||
return "$size_than $file_namee $ups_than $exte $rep_than $usernamee $lstd_than $exte $ipp";
|
||||
}
|
||||
|
||||
/**
|
||||
* To re-count the total files, without making the server goes down haha
|
||||
* @param bool $files
|
||||
* @param bool $start
|
||||
* @param bool $files
|
||||
* @param bool $start
|
||||
* @return bool|int
|
||||
*/
|
||||
function sync_total_files($files = true, $start = false)
|
||||
{
|
||||
global $SQL, $dbprefix;
|
||||
global $SQL, $dbprefix;
|
||||
|
||||
$query = array(
|
||||
'SELECT' => 'MIN(f.id) as min_file_id, MAX(f.id) as max_file_id',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 'MIN(f.id) as min_file_id, MAX(f.id) as max_file_id',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
];
|
||||
|
||||
#!files == images
|
||||
$img_types = array('gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG');
|
||||
$query['WHERE'] = "f.type" . ($files ? ' NOT' : '') ." IN ('" . implode("', '", $img_types) . "')";
|
||||
//!files == images
|
||||
$img_types = ['gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG'];
|
||||
$query['WHERE'] = 'f.type' . ($files ? ' NOT' : '') . " IN ('" . implode("', '", $img_types) . "')";
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$v = $SQL->fetch($result);
|
||||
$SQL->freeresult($result);
|
||||
|
||||
#if no data, turn them to number
|
||||
$min_id = (int) $v['min_file_id'];
|
||||
// $max_id = (int) $v['max_file_id'];
|
||||
$result = $SQL->build($query);
|
||||
$v = $SQL->fetch($result);
|
||||
$SQL->freeresult($result);
|
||||
|
||||
#every time batch
|
||||
$batch_size = 1500;
|
||||
//if no data, turn them to number
|
||||
$min_id = (int) $v['min_file_id'];
|
||||
// $max_id = (int) $v['max_file_id'];
|
||||
|
||||
#no start? start = min
|
||||
$first_loop = !$start ? true : false;
|
||||
$start = !$start ? $min_id : $start;
|
||||
$end = $start + $batch_size;
|
||||
//every time batch
|
||||
$batch_size = 1500;
|
||||
|
||||
#now lets get this step's files number
|
||||
unset($v, $result);
|
||||
//no start? start = min
|
||||
$first_loop = ! $start ? true : false;
|
||||
$start = ! $start ? $min_id : $start;
|
||||
$end = $start + $batch_size;
|
||||
|
||||
$query['SELECT'] = 'COUNT(f.id) as num_files';
|
||||
$query['WHERE'] .= ' AND f.id BETWEEN ' . $start . ' AND ' . $end;
|
||||
//now lets get this step's files number
|
||||
unset($v, $result);
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$v = $SQL->fetch($result);
|
||||
$SQL->freeresult($result);
|
||||
$query['SELECT'] = 'COUNT(f.id) as num_files';
|
||||
$query['WHERE'] .= ' AND f.id BETWEEN ' . $start . ' AND ' . $end;
|
||||
|
||||
$this_step_count = $v['num_files'];
|
||||
if($this_step_count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$result = $SQL->build($query);
|
||||
$v = $SQL->fetch($result);
|
||||
$SQL->freeresult($result);
|
||||
|
||||
#update stats table
|
||||
$this_step_count = $v['num_files'];
|
||||
|
||||
$update_query = array(
|
||||
'UPDATE' => "{$dbprefix}stats"
|
||||
);
|
||||
if ($this_step_count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#make it zero, firstly
|
||||
if($first_loop)
|
||||
{
|
||||
$update_query['SET'] = ($files ? 'files' : 'imgs') . "= 0";
|
||||
$SQL->build($update_query);
|
||||
}
|
||||
|
||||
$update_query['SET'] = ($files ? 'files' : 'imgs') . "=" . ($files ? 'files' : 'imgs') . '+' . $this_step_count;
|
||||
$SQL->build($update_query);
|
||||
//update stats table
|
||||
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}stats"
|
||||
];
|
||||
|
||||
//make it zero, firstly
|
||||
if ($first_loop)
|
||||
{
|
||||
$update_query['SET'] = ($files ? 'files' : 'imgs') . '= 0';
|
||||
$SQL->build($update_query);
|
||||
}
|
||||
|
||||
$update_query['SET'] = ($files ? 'files' : 'imgs') . '=' . ($files ? 'files' : 'imgs') . '+' . $this_step_count;
|
||||
$SQL->build($update_query);
|
||||
|
||||
|
||||
return $end;
|
||||
return $end;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the *right* now number of the given stat fro stats table
|
||||
* @param string $name Stat name
|
||||
* @param string $name Stat name
|
||||
* @return int
|
||||
*/
|
||||
function get_actual_stats($name)
|
||||
{
|
||||
global $dbprefix, $SQL;
|
||||
global $dbprefix, $SQL;
|
||||
|
||||
$query = array(
|
||||
'SELECT' => 's.' . $name,
|
||||
'FROM' => "{$dbprefix}stats s"
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 's.' . $name,
|
||||
'FROM' => "{$dbprefix}stats s"
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
$v = $SQL->fetch($result);
|
||||
$result = $SQL->build($query);
|
||||
$v = $SQL->fetch($result);
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('get_actual_stats_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$SQL->freeresult($result);
|
||||
|
||||
return $v[$name];
|
||||
$SQL->freeresult($result);
|
||||
|
||||
return $v[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* check wether a start box is hidden or not
|
||||
* @param string $name box name
|
||||
* @param string $name box name
|
||||
* @return bool
|
||||
*/
|
||||
function adm_is_start_box_hidden($name)
|
||||
{
|
||||
global $config;
|
||||
global $config;
|
||||
|
||||
if(! isset($config['hidden_start_boxes']))
|
||||
{
|
||||
add_config('hidden_start_boxes', '');
|
||||
if (! isset($config['hidden_start_boxes']))
|
||||
{
|
||||
add_config('hidden_start_boxes', '');
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static $boxes;
|
||||
|
||||
if(empty($boxes))
|
||||
{
|
||||
$boxes = explode(':', $config['hidden_start_boxes']);
|
||||
$boxes = array_filter($boxes);
|
||||
}
|
||||
static $boxes;
|
||||
|
||||
if (empty($boxes))
|
||||
{
|
||||
$boxes = explode(':', $config['hidden_start_boxes']);
|
||||
$boxes = array_filter($boxes);
|
||||
}
|
||||
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('adm_start_boxes_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('adm_start_boxes_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
return in_array($name, $boxes);
|
||||
return in_array($name, $boxes);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete plugin folder
|
||||
* @param string $dir plugin folder path
|
||||
* @param string $dir plugin folder path
|
||||
* @return void
|
||||
*/
|
||||
function delete_plugin_folder($dir)
|
||||
{
|
||||
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if ($file->isLink())
|
||||
{
|
||||
unlink($file->getPathname());
|
||||
}
|
||||
else if ($file->isDir())
|
||||
{
|
||||
rmdir($file->getPathname());
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink($file->getPathname());
|
||||
}
|
||||
}
|
||||
rmdir($dir);
|
||||
}
|
||||
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if ($file->isLink())
|
||||
{
|
||||
unlink($file->getPathname());
|
||||
}
|
||||
elseif ($file->isDir())
|
||||
{
|
||||
rmdir($file->getPathname());
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink($file->getPathname());
|
||||
}
|
||||
}
|
||||
rmdir($dir);
|
||||
}
|
||||
|
||||
@@ -16,172 +16,212 @@
|
||||
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if(!function_exists('htmlspecialchars_decode'))
|
||||
if (! function_exists('htmlspecialchars_decode'))
|
||||
{
|
||||
function htmlspecialchars_decode($string, $style=ENT_COMPAT)
|
||||
{
|
||||
$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $style));
|
||||
if($style === ENT_QUOTES)
|
||||
{
|
||||
$translation['''] = '\'';
|
||||
}
|
||||
return strtr($string, $translation);
|
||||
}
|
||||
function htmlspecialchars_decode($string, $style=ENT_COMPAT)
|
||||
{
|
||||
$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $style));
|
||||
|
||||
if ($style === ENT_QUOTES)
|
||||
{
|
||||
$translation['''] = '\'';
|
||||
}
|
||||
return strtr($string, $translation);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//http://us2.php.net/manual/en/function.str-split.php#84891
|
||||
if(!function_exists('str_split'))
|
||||
if (! function_exists('str_split'))
|
||||
{
|
||||
function str_split($string, $string_length=1)
|
||||
{
|
||||
if(strlen($string) > $string_length || !$string_length)
|
||||
{
|
||||
do
|
||||
{
|
||||
$c = strlen($string);
|
||||
$parts[] = substr($string, 0, $string_length);
|
||||
$string = substr($string, $string_length);
|
||||
}
|
||||
while($string !== false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$parts = array($string);
|
||||
}
|
||||
return $parts;
|
||||
{
|
||||
if (strlen($string) > $string_length || ! $string_length)
|
||||
{
|
||||
do
|
||||
{
|
||||
$c = strlen($string);
|
||||
$parts[] = substr($string, 0, $string_length);
|
||||
$string = substr($string, $string_length);
|
||||
} while ($string !== false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$parts = [$string];
|
||||
}
|
||||
return $parts;
|
||||
}
|
||||
}
|
||||
|
||||
//Custom base64_* functions
|
||||
function kleeja_base64_encode($str = ''){ return function_exists('base64_encode') ? base64_encode($str) : base64encode($str); }
|
||||
function kleeja_base64_decode($str = ''){ return function_exists('base64_decode') ? base64_decode($str) : base64decode($str); }
|
||||
function kleeja_base64_encode($str = '')
|
||||
{
|
||||
return function_exists('base64_encode') ? base64_encode($str) : base64encode($str);
|
||||
}
|
||||
function kleeja_base64_decode($str = '')
|
||||
{
|
||||
return function_exists('base64_decode') ? base64_decode($str) : base64decode($str);
|
||||
}
|
||||
|
||||
//http://www.php.net/manual/en/function.base64-encode.php#63270
|
||||
function base64encode($string = '')
|
||||
{
|
||||
if(!function_exists('convert_binary_str'))
|
||||
{
|
||||
function convert_binary_str($string)
|
||||
{
|
||||
if (strlen($string) <= 0)
|
||||
return;
|
||||
if (! function_exists('convert_binary_str'))
|
||||
{
|
||||
function convert_binary_str($string)
|
||||
{
|
||||
if (strlen($string) <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$tmp = decbin(ord($string[0]));
|
||||
$tmp = str_repeat('0', 8-strlen($tmp)) . $tmp;
|
||||
return $tmp . convert_binary_str(substr($string,1));
|
||||
}
|
||||
}
|
||||
$tmp = decbin(ord($string[0]));
|
||||
$tmp = str_repeat('0', 8-strlen($tmp)) . $tmp;
|
||||
return $tmp . convert_binary_str(substr($string, 1));
|
||||
}
|
||||
}
|
||||
|
||||
$binval = convert_binary_str($string);
|
||||
$final = '';
|
||||
$start = 0;
|
||||
$binval = convert_binary_str($string);
|
||||
$final = '';
|
||||
$start = 0;
|
||||
|
||||
while ($start < strlen($binval))
|
||||
{
|
||||
if (strlen(substr($binval,$start)) < 6)
|
||||
$binval .= str_repeat("0", 6-strlen(substr($binval,$start)));
|
||||
$tmp = bindec(substr($binval, $start,6));
|
||||
if ($tmp < 26)
|
||||
$final .= chr($tmp+65);
|
||||
elseif ($tmp > 25 && $tmp < 52)
|
||||
$final .= chr($tmp+71);
|
||||
elseif ($tmp == 62)
|
||||
$final .= "+";
|
||||
elseif ($tmp == 63)
|
||||
$final .= "/";
|
||||
elseif (!$tmp)
|
||||
$final .= "A";
|
||||
else
|
||||
$final .= chr($tmp-4);
|
||||
$start += 6;
|
||||
}
|
||||
if (strlen($final)%4>0)
|
||||
$final .= str_repeat('=', 4-strlen($final)%4);
|
||||
return $final;
|
||||
while ($start < strlen($binval))
|
||||
{
|
||||
if (strlen(substr($binval, $start)) < 6)
|
||||
{
|
||||
$binval .= str_repeat('0', 6-strlen(substr($binval, $start)));
|
||||
}
|
||||
$tmp = bindec(substr($binval, $start, 6));
|
||||
|
||||
if ($tmp < 26)
|
||||
{
|
||||
$final .= chr($tmp+65);
|
||||
}
|
||||
elseif ($tmp > 25 && $tmp < 52)
|
||||
{
|
||||
$final .= chr($tmp+71);
|
||||
}
|
||||
elseif ($tmp == 62)
|
||||
{
|
||||
$final .= '+';
|
||||
}
|
||||
elseif ($tmp == 63)
|
||||
{
|
||||
$final .= '/';
|
||||
}
|
||||
elseif (! $tmp)
|
||||
{
|
||||
$final .= 'A';
|
||||
}
|
||||
else
|
||||
{
|
||||
$final .= chr($tmp-4);
|
||||
}
|
||||
$start += 6;
|
||||
}
|
||||
|
||||
if (strlen($final)%4>0)
|
||||
{
|
||||
$final .= str_repeat('=', 4-strlen($final)%4);
|
||||
}
|
||||
return $final;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function base64decode($str)
|
||||
{
|
||||
$len = strlen($str);
|
||||
$ret = '';
|
||||
$b64 = array();
|
||||
$base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
$len_base64 = strlen($base64);
|
||||
|
||||
for ($i = 0; $i < 256; $i++)
|
||||
$b64[$i] = 0;
|
||||
for ($i = 0; $i < $len_base64 ; $i++)
|
||||
$b64[ord($base64[$i])] = $i;
|
||||
$len = strlen($str);
|
||||
$ret = '';
|
||||
$b64 = [];
|
||||
$base64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
$len_base64 = strlen($base64);
|
||||
|
||||
for($j=0;$j<$len;$j+=4)
|
||||
{
|
||||
for ($i = 0; $i < 4; $i++)
|
||||
{
|
||||
$c = ord($str[$j+$i]);
|
||||
$a[$i] = $c;
|
||||
$b[$i] = $b64[$c];
|
||||
}
|
||||
for ($i = 0; $i < 256; $i++)
|
||||
{
|
||||
$b64[$i] = 0;
|
||||
}
|
||||
|
||||
$o[0] = ($b[0] << 2) | ($b[1] >> 4);
|
||||
$o[1] = ($b[1] << 4) | ($b[2] >> 2);
|
||||
$o[2] = ($b[2] << 6) | $b[3];
|
||||
if ($a[2] == ord('='))
|
||||
$i = 1;
|
||||
else if ($a[3] == ord('='))
|
||||
$i = 2;
|
||||
else
|
||||
$i = 3;
|
||||
for ($i = 0; $i < $len_base64; $i++)
|
||||
{
|
||||
$b64[ord($base64[$i])] = $i;
|
||||
}
|
||||
|
||||
for($k=0;$k<$i;$k++)
|
||||
$ret .= chr((int) $o[$k] & 255);
|
||||
for ($j=0;$j<$len;$j+=4)
|
||||
{
|
||||
for ($i = 0; $i < 4; $i++)
|
||||
{
|
||||
$c = ord($str[$j+$i]);
|
||||
$a[$i] = $c;
|
||||
$b[$i] = $b64[$c];
|
||||
}
|
||||
|
||||
if ($i < 3)
|
||||
break;
|
||||
}
|
||||
$o[0] = ($b[0] << 2) | ($b[1] >> 4);
|
||||
$o[1] = ($b[1] << 4) | ($b[2] >> 2);
|
||||
$o[2] = ($b[2] << 6) | $b[3];
|
||||
|
||||
return $ret;
|
||||
if ($a[2] == ord('='))
|
||||
{
|
||||
$i = 1;
|
||||
}
|
||||
elseif ($a[3] == ord('='))
|
||||
{
|
||||
$i = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$i = 3;
|
||||
}
|
||||
|
||||
for ($k=0;$k<$i;$k++)
|
||||
{
|
||||
$ret .= chr((int) $o[$k] & 255);
|
||||
}
|
||||
|
||||
if ($i < 3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if(!function_exists('filesize'))
|
||||
if (! function_exists('filesize'))
|
||||
{
|
||||
function kleeja_filesize($filename)
|
||||
{
|
||||
$a = fopen($filename, 'r');
|
||||
fseek($a, 0, SEEK_END);
|
||||
$filesize = ftell($a);
|
||||
fclose($a);
|
||||
return $filesize;
|
||||
}
|
||||
function kleeja_filesize($filename)
|
||||
{
|
||||
$a = fopen($filename, 'r');
|
||||
fseek($a, 0, SEEK_END);
|
||||
$filesize = ftell($a);
|
||||
fclose($a);
|
||||
return $filesize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
function kleeja_filesize($filename)
|
||||
{
|
||||
return filesize($filename);
|
||||
}
|
||||
function kleeja_filesize($filename)
|
||||
{
|
||||
return filesize($filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!function_exists("array_column"))
|
||||
if (! function_exists('array_column'))
|
||||
{
|
||||
function array_column($array, $column_name)
|
||||
{
|
||||
return array_map(
|
||||
function($element) use($column_name)
|
||||
{
|
||||
return $element[$column_name];
|
||||
},
|
||||
array_values($array)
|
||||
);
|
||||
function($element) use ($column_name) {
|
||||
return $element[$column_name];
|
||||
},
|
||||
array_values($array)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,483 +9,490 @@
|
||||
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if(!defined("SQL_LAYER")):
|
||||
|
||||
define("SQL_LAYER","mysql4");
|
||||
if (! defined('SQL_LAYER')):
|
||||
|
||||
class SSQL
|
||||
define('SQL_LAYER', 'mysql4');
|
||||
|
||||
class SSQL
|
||||
{
|
||||
|
||||
var $connect_id = null;
|
||||
var $result;
|
||||
var $query_num = 0;
|
||||
var $in_transaction = 0;
|
||||
var $debugr = false;
|
||||
var $show_errors = true;
|
||||
public $connect_id = null;
|
||||
public $result;
|
||||
public $query_num = 0;
|
||||
public $in_transaction = 0;
|
||||
public $debugr = false;
|
||||
public $show_errors = true;
|
||||
|
||||
|
||||
/*
|
||||
* initiate the class
|
||||
* wirth basic data
|
||||
*/
|
||||
function __construct($host, $db_username, $db_password, $db_name, $new_link=false)
|
||||
{
|
||||
global $script_encoding;
|
||||
|
||||
$this->host= $host;
|
||||
$this->db_username = $db_username;
|
||||
$this->db_name = $db_name;
|
||||
$this->db_password = 'hidden';
|
||||
|
||||
//no error
|
||||
if(defined('MYSQL_NO_ERRORS'))
|
||||
{
|
||||
$this->show_errors = false;
|
||||
}
|
||||
/*
|
||||
* initiate the class
|
||||
* wirth basic data
|
||||
*/
|
||||
public function __construct($host, $db_username, $db_password, $db_name, $new_link=false)
|
||||
{
|
||||
global $script_encoding;
|
||||
|
||||
$this->connect_id = @mysql_connect($this->host, $this->db_username, $db_password, $new_link) or die($this->error_msg("we can not connect to the server ..."));
|
||||
$this->host = $host;
|
||||
$this->db_username = $db_username;
|
||||
$this->db_name = $db_name;
|
||||
$this->db_password = 'hidden';
|
||||
|
||||
if($this->connect_id)
|
||||
{
|
||||
#loggin -> connecting
|
||||
kleeja_log('[Connected] : ' . kleeja_get_page());
|
||||
//no error
|
||||
if (defined('MYSQL_NO_ERRORS'))
|
||||
{
|
||||
$this->show_errors = false;
|
||||
}
|
||||
|
||||
if(!empty($db_name))
|
||||
{
|
||||
$dbselect = @mysql_select_db($this->db_name) or die($this->error_msg("we can not select database"));
|
||||
|
||||
if ($dbselect)
|
||||
{
|
||||
#login -> selecting database
|
||||
kleeja_log('[Selected Database] :' . $this->connect_id);
|
||||
$this->connect_id = @mysql_connect($this->host, $this->db_username, $db_password, $new_link) or die($this->error_msg('we can not connect to the server ...'));
|
||||
|
||||
if ((!preg_match('/utf/i', strtolower($script_encoding)) && !defined('IN_LOGINPAGE') && !defined('IN_ADMIN_LOGIN') && !defined('DISABLE_INTR')) || ((empty($script_encoding) || preg_match('/utf/i', strtolower($script_encoding)) || defined('DISABLE_INTR'))))
|
||||
{
|
||||
if(mysql_query("SET NAMES 'utf8'"))
|
||||
{
|
||||
#loggin -> set utf8
|
||||
kleeja_log('[Set to UTF8] :' . $this->connect_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!$dbselect)
|
||||
{
|
||||
#loggin -> no database -> close connection
|
||||
$this->close($this->connect_id);
|
||||
$this->connect_id = $dbselect;
|
||||
}
|
||||
}
|
||||
if ($this->connect_id)
|
||||
{
|
||||
//loggin -> connecting
|
||||
kleeja_log('[Connected] : ' . kleeja_get_page());
|
||||
|
||||
return $this->connect_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (! empty($db_name))
|
||||
{
|
||||
$dbselect = @mysql_select_db($this->db_name) or die($this->error_msg('we can not select database'));
|
||||
|
||||
/*
|
||||
* close the connection
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
if( $this->connect_id )
|
||||
{
|
||||
// Commit any remaining transactions
|
||||
if( $this->in_transaction )
|
||||
{
|
||||
mysql_query("COMMIT", $this->connect_id);
|
||||
}
|
||||
if ($dbselect)
|
||||
{
|
||||
//login -> selecting database
|
||||
kleeja_log('[Selected Database] :' . $this->connect_id);
|
||||
|
||||
#loggin -> close connection
|
||||
kleeja_log('[Closing connection] :' . kleeja_get_page());
|
||||
if ((! preg_match('/utf/i', strtolower($script_encoding)) && ! defined('IN_LOGINPAGE') && ! defined('IN_ADMIN_LOGIN') && ! defined('DISABLE_INTR')) || ((empty($script_encoding) || preg_match('/utf/i', strtolower($script_encoding)) || defined('DISABLE_INTR'))))
|
||||
{
|
||||
if (mysql_query("SET NAMES 'utf8'"))
|
||||
{
|
||||
//loggin -> set utf8
|
||||
kleeja_log('[Set to UTF8] :' . $this->connect_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (! $dbselect)
|
||||
{
|
||||
//loggin -> no database -> close connection
|
||||
$this->close($this->connect_id);
|
||||
$this->connect_id = $dbselect;
|
||||
}
|
||||
}
|
||||
|
||||
return @mysql_close($this->connect_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $this->connect_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* encoding functions
|
||||
*/
|
||||
function set_utf8()
|
||||
{
|
||||
return $this->set_names('utf8');
|
||||
}
|
||||
|
||||
function set_names($charset)
|
||||
{
|
||||
@mysql_query("SET NAMES '" . $charset . "'", $this->connect_id);
|
||||
}
|
||||
|
||||
function client_encoding()
|
||||
{
|
||||
return mysql_client_encoding($this->connect_id);
|
||||
}
|
||||
// close the connection
|
||||
public function close()
|
||||
{
|
||||
if ( $this->connect_id )
|
||||
{
|
||||
// Commit any remaining transactions
|
||||
if ( $this->in_transaction )
|
||||
{
|
||||
mysql_query('COMMIT', $this->connect_id);
|
||||
}
|
||||
|
||||
function mysql_version()
|
||||
{
|
||||
//version of mysql
|
||||
$vr = $this->query('SELECT VERSION() AS v');
|
||||
$vs = $this->fetch_array($vr);
|
||||
$vs = $vs['v'];
|
||||
return preg_replace('/^([^-]+).*$/', '\\1', $vs);
|
||||
}
|
||||
//loggin -> close connection
|
||||
kleeja_log('[Closing connection] :' . kleeja_get_page());
|
||||
|
||||
/*
|
||||
the query func . its so important to do
|
||||
the quries and give results
|
||||
*/
|
||||
function query($query, $transaction = FALSE)
|
||||
{
|
||||
//no connection
|
||||
if(!$this->connect_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove any pre-existing queries
|
||||
//
|
||||
unset($this->result);
|
||||
return @mysql_close($this->connect_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($query))
|
||||
{
|
||||
//debug .. //////////////
|
||||
$srartum_sql = get_microtime();
|
||||
////////////////
|
||||
// encoding functions
|
||||
public function set_utf8()
|
||||
{
|
||||
return $this->set_names('utf8');
|
||||
}
|
||||
|
||||
if( $transaction == 1 && !$this->in_transaction )
|
||||
{
|
||||
$result = mysql_query("BEGIN", $this->connect_id);
|
||||
if(!$result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->in_transaction = TRUE;
|
||||
}
|
||||
public function set_names($charset)
|
||||
{
|
||||
@mysql_query("SET NAMES '" . $charset . "'", $this->connect_id);
|
||||
}
|
||||
|
||||
$this->result = mysql_query($query, $this->connect_id);
|
||||
public function client_encoding()
|
||||
{
|
||||
return mysql_client_encoding($this->connect_id);
|
||||
}
|
||||
|
||||
//debug .. //////////////
|
||||
$this->debugr[$this->query_num+1] = array($query, sprintf('%.5f', get_microtime() - $srartum_sql));
|
||||
////////////////
|
||||
public function mysql_version()
|
||||
{
|
||||
//version of mysql
|
||||
$vr = $this->query('SELECT VERSION() AS v');
|
||||
$vs = $this->fetch_array($vr);
|
||||
$vs = $vs['v'];
|
||||
return preg_replace('/^([^-]+).*$/', '\\1', $vs);
|
||||
}
|
||||
|
||||
if(!$this->result)
|
||||
{
|
||||
$this->error_msg('Error In query');
|
||||
}
|
||||
else
|
||||
{
|
||||
//let's debug it
|
||||
kleeja_log('[Query] : --> ' . $query);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $transaction == 2 && $this->in_transaction )
|
||||
{
|
||||
$this->result = mysql_query("COMMIT", $this->connect_id);
|
||||
}
|
||||
}
|
||||
/*
|
||||
the query func . its so important to do
|
||||
the quries and give results
|
||||
*/
|
||||
public function query($query, $transaction = false)
|
||||
{
|
||||
//no connection
|
||||
if (! $this->connect_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//is there any result
|
||||
if($this->result)
|
||||
{
|
||||
if($transaction == 2 && $this->in_transaction)
|
||||
{
|
||||
$this->in_transaction = FALSE;
|
||||
//
|
||||
// Remove any pre-existing queries
|
||||
//
|
||||
unset($this->result);
|
||||
|
||||
if (!mysql_query("COMMIT", $this->connect_id))
|
||||
{
|
||||
mysql_query("ROLLBACK", $this->connect_id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (! empty($query))
|
||||
{
|
||||
//debug .. //////////////
|
||||
$srartum_sql = get_microtime();
|
||||
////////////////
|
||||
|
||||
$this->query_num++;
|
||||
if ( $transaction == 1 && ! $this->in_transaction )
|
||||
{
|
||||
$result = mysql_query('BEGIN', $this->connect_id);
|
||||
|
||||
return $this->result;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $this->in_transaction )
|
||||
{
|
||||
mysql_query("ROLLBACK", $this->connect_id);
|
||||
$this->in_transaction = FALSE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (! $result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* query build
|
||||
*/
|
||||
function build($query)
|
||||
{
|
||||
$sql = '';
|
||||
$this->in_transaction = true;
|
||||
}
|
||||
|
||||
if (isset($query['SELECT']))
|
||||
{
|
||||
$sql = 'SELECT '.$query['SELECT'].' FROM '.$query['FROM'];
|
||||
$this->result = mysql_query($query, $this->connect_id);
|
||||
|
||||
if (isset($query['JOINS']))
|
||||
{
|
||||
foreach ($query['JOINS'] as $cur_join)
|
||||
$sql .= ' '.key($cur_join).' '. @current($cur_join).' ON '.$cur_join['ON'];
|
||||
}
|
||||
//debug .. //////////////
|
||||
$this->debugr[$this->query_num+1] = [$query, sprintf('%.5f', get_microtime() - $srartum_sql)];
|
||||
////////////////
|
||||
|
||||
if (!empty($query['WHERE']))
|
||||
$sql .= ' WHERE '.$query['WHERE'];
|
||||
if (!empty($query['GROUP BY']))
|
||||
$sql .= ' GROUP BY '.$query['GROUP BY'];
|
||||
if (!empty($query['HAVING']))
|
||||
$sql .= ' HAVING '.$query['HAVING'];
|
||||
if (!empty($query['ORDER BY']))
|
||||
$sql .= ' ORDER BY '.$query['ORDER BY'];
|
||||
if (!empty($query['LIMIT']))
|
||||
$sql .= ' LIMIT '.$query['LIMIT'];
|
||||
}
|
||||
else if (isset($query['INSERT']))
|
||||
{
|
||||
$sql = 'INSERT INTO '.$query['INTO'];
|
||||
if (! $this->result)
|
||||
{
|
||||
$this->error_msg('Error In query');
|
||||
}
|
||||
else
|
||||
{
|
||||
//let's debug it
|
||||
kleeja_log('[Query] : --> ' . $query);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $transaction == 2 && $this->in_transaction )
|
||||
{
|
||||
$this->result = mysql_query('COMMIT', $this->connect_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($query['INSERT']))
|
||||
$sql .= ' ('.$query['INSERT'].')';
|
||||
//is there any result
|
||||
if ($this->result)
|
||||
{
|
||||
if ($transaction == 2 && $this->in_transaction)
|
||||
{
|
||||
$this->in_transaction = false;
|
||||
|
||||
$sql .= ' VALUES('.$query['VALUES'].')';
|
||||
}
|
||||
else if (isset($query['UPDATE']))
|
||||
{
|
||||
$query['UPDATE'] = $query['UPDATE'];
|
||||
if (! mysql_query('COMMIT', $this->connect_id))
|
||||
{
|
||||
mysql_query('ROLLBACK', $this->connect_id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($query['PARAMS']['LOW_PRIORITY']))
|
||||
$query['UPDATE'] = 'LOW_PRIORITY '.$query['UPDATE'];
|
||||
$this->query_num++;
|
||||
|
||||
$sql = 'UPDATE '.$query['UPDATE'].' SET '.$query['SET'];
|
||||
return $this->result;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $this->in_transaction )
|
||||
{
|
||||
mysql_query('ROLLBACK', $this->connect_id);
|
||||
$this->in_transaction = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($query['WHERE']))
|
||||
$sql .= ' WHERE '.$query['WHERE'];
|
||||
}
|
||||
else if (isset($query['DELETE']))
|
||||
{
|
||||
$sql = 'DELETE FROM '.$query['DELETE'];
|
||||
// query build
|
||||
public function build($query)
|
||||
{
|
||||
$sql = '';
|
||||
|
||||
if (!empty($query['WHERE']))
|
||||
$sql .= ' WHERE '.$query['WHERE'];
|
||||
}
|
||||
else if (isset($query['REPLACE']))
|
||||
{
|
||||
$sql = 'REPLACE INTO '.$query['INTO'];
|
||||
if (isset($query['SELECT']))
|
||||
{
|
||||
$sql = 'SELECT ' . $query['SELECT'] . ' FROM ' . $query['FROM'];
|
||||
|
||||
if (!empty($query['REPLACE']))
|
||||
$sql .= ' ('.$query['REPLACE'].')';
|
||||
if (isset($query['JOINS']))
|
||||
{
|
||||
foreach ($query['JOINS'] as $cur_join)
|
||||
{
|
||||
$sql .= ' ' . key($cur_join) . ' ' . @current($cur_join) . ' ON ' . $cur_join['ON'];
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= ' VALUES('.$query['VALUES'].')';
|
||||
}
|
||||
if (! empty($query['WHERE']))
|
||||
{
|
||||
$sql .= ' WHERE ' . $query['WHERE'];
|
||||
}
|
||||
|
||||
return $this->query($sql);
|
||||
}
|
||||
if (! empty($query['GROUP BY']))
|
||||
{
|
||||
$sql .= ' GROUP BY ' . $query['GROUP BY'];
|
||||
}
|
||||
|
||||
/*
|
||||
* free the memmory from the last results
|
||||
*/
|
||||
function free($query_id = 0)
|
||||
{
|
||||
return $this->freeresult($query_id);
|
||||
}
|
||||
if (! empty($query['HAVING']))
|
||||
{
|
||||
$sql .= ' HAVING ' . $query['HAVING'];
|
||||
}
|
||||
|
||||
function freeresult($query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
if (! empty($query['ORDER BY']))
|
||||
{
|
||||
$sql .= ' ORDER BY ' . $query['ORDER BY'];
|
||||
}
|
||||
|
||||
if ($query_id)
|
||||
{
|
||||
mysql_free_result($query_id);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (! empty($query['LIMIT']))
|
||||
{
|
||||
$sql .= ' LIMIT ' . $query['LIMIT'];
|
||||
}
|
||||
}
|
||||
elseif (isset($query['INSERT']))
|
||||
{
|
||||
$sql = 'INSERT INTO ' . $query['INTO'];
|
||||
|
||||
/*
|
||||
* if the result is an arry ,
|
||||
* this func is so important to order them as a array
|
||||
*/
|
||||
function fetch($query_id = 0)
|
||||
{
|
||||
return $this->fetch_array($query_id);
|
||||
}
|
||||
if (! empty($query['INSERT']))
|
||||
{
|
||||
$sql .= ' (' . $query['INSERT'] . ')';
|
||||
}
|
||||
|
||||
function fetch_array($query_id = 0)
|
||||
{
|
||||
if( !$query_id )
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
$sql .= ' VALUES(' . $query['VALUES'] . ')';
|
||||
}
|
||||
elseif (isset($query['UPDATE']))
|
||||
{
|
||||
$query['UPDATE'] = $query['UPDATE'];
|
||||
|
||||
return $query_id ? mysql_fetch_array($query_id, MYSQL_ASSOC) : false;
|
||||
}
|
||||
if (isset($query['PARAMS']['LOW_PRIORITY']))
|
||||
{
|
||||
$query['UPDATE'] = 'LOW_PRIORITY ' . $query['UPDATE'];
|
||||
}
|
||||
|
||||
/*
|
||||
* if we have a result and we have to know
|
||||
* the number of it , this is a func ..
|
||||
*/
|
||||
function num_rows($query_id = 0)
|
||||
{
|
||||
if( !$query_id )
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
$sql = 'UPDATE ' . $query['UPDATE'] . ' SET ' . $query['SET'];
|
||||
|
||||
return $query_id ? mysql_num_rows($query_id) : false;
|
||||
}
|
||||
if (! empty($query['WHERE']))
|
||||
{
|
||||
$sql .= ' WHERE ' . $query['WHERE'];
|
||||
}
|
||||
}
|
||||
elseif (isset($query['DELETE']))
|
||||
{
|
||||
$sql = 'DELETE FROM ' . $query['DELETE'];
|
||||
|
||||
|
||||
/*
|
||||
* last id inserted in sql
|
||||
*/
|
||||
function insert_id()
|
||||
{
|
||||
return ($this->connect_id) ? mysql_insert_id($this->connect_id) : false;
|
||||
}
|
||||
if (! empty($query['WHERE']))
|
||||
{
|
||||
$sql .= ' WHERE ' . $query['WHERE'];
|
||||
}
|
||||
}
|
||||
elseif (isset($query['REPLACE']))
|
||||
{
|
||||
$sql = 'REPLACE INTO ' . $query['INTO'];
|
||||
|
||||
/*
|
||||
* clean the qurery before insert it
|
||||
*/
|
||||
function escape($msg)
|
||||
{
|
||||
$msg = htmlspecialchars($msg , ENT_QUOTES);
|
||||
#$msg = (!get_magic_quotes_gpc()) ? addslashes ($msg) : $msg;
|
||||
$msg = $this->real_escape($msg);
|
||||
return $msg;
|
||||
}
|
||||
if (! empty($query['REPLACE']))
|
||||
{
|
||||
$sql .= ' (' . $query['REPLACE'] . ')';
|
||||
}
|
||||
|
||||
/*
|
||||
* real escape ..
|
||||
*/
|
||||
function real_escape($msg)
|
||||
{
|
||||
if (is_array($msg))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
else if (function_exists('mysql_real_escape_string'))
|
||||
{
|
||||
if(!$this-connect_id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return mysql_real_escape_string($msg, $this->connect_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// because mysql_escape_string doesnt escape % & _[php.net/mysql_escape_string]
|
||||
//return addcslashes(mysql_escape_string($msg),'%_');
|
||||
return mysql_escape_string($msg);
|
||||
}
|
||||
}
|
||||
$sql .= ' VALUES(' . $query['VALUES'] . ')';
|
||||
}
|
||||
|
||||
/*
|
||||
* get affected records
|
||||
*/
|
||||
function affected()
|
||||
{
|
||||
return ( $this->connect_id ) ? mysql_affected_rows($this->connect_id) : false;
|
||||
}
|
||||
return $this->query($sql);
|
||||
}
|
||||
|
||||
/*
|
||||
* get the information of mysql server
|
||||
*/
|
||||
function server_info()
|
||||
{
|
||||
return 'MySQL ' . $this->mysql_version;
|
||||
}
|
||||
// free the memmory from the last results
|
||||
public function free($query_id = 0)
|
||||
{
|
||||
return $this->freeresult($query_id);
|
||||
}
|
||||
|
||||
/*
|
||||
error message func
|
||||
*/
|
||||
function error_msg($msg)
|
||||
{
|
||||
global $dbprefix;
|
||||
|
||||
if(!$this->show_errors)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public function freeresult($query_id = 0)
|
||||
{
|
||||
if (! $query_id)
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
|
||||
$error_no = mysql_errno();
|
||||
$error_msg = mysql_error();
|
||||
$error_sql = @current($this->debugr[$this->query_num+1]);
|
||||
|
||||
//some ppl want hide their table names, not in develoment stage
|
||||
if(!defined('DEV_STAGE'))
|
||||
{
|
||||
$error_sql = preg_replace("#\s{1,3}`*{$dbprefix}([a-z0-9]+)`*\s{1,3}#e", "' <span style=\"color:blue\">' . substr('$1', 0, 1) . '</span> '", $error_sql);
|
||||
$error_msg = preg_replace("#{$this->db_name}.{$dbprefix}([a-z0-9]+)#e", "' <span style=\"color:blue\">' . substr('$1', 0, 1) . '</span> '", $error_msg);
|
||||
$error_sql = preg_replace("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#ie", "' $1 <span style=\"color:blue\">' . substr('$2', 0, 1) . '</span> '", $error_sql);
|
||||
$error_msg = preg_replace("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#ie", "' $1 <span style=\"color:blue\">' . substr('$2', 0, 1) . '</span> '", $error_msg);
|
||||
$error_msg = preg_replace("#\s'([^']+)'@'([^']+)'#ie", "' <span style=\"color:blue\">hidden</span>@$2 '", $error_msg);
|
||||
$error_sql = preg_replace("#password\s*=\s*'[^']+'#i", "password='<span style=\"color:blue\">hidden</span>'", $error_sql);
|
||||
}
|
||||
if ($query_id)
|
||||
{
|
||||
mysql_free_result($query_id);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#is this error related to updating?
|
||||
$updating_related = false;
|
||||
if(strpos($error_msg, 'Unknown column') !== false)
|
||||
{
|
||||
$updating_related = true;
|
||||
}
|
||||
/*
|
||||
* if the result is an arry ,
|
||||
* this func is so important to order them as a array
|
||||
*/
|
||||
public function fetch($query_id = 0)
|
||||
{
|
||||
return $this->fetch_array($query_id);
|
||||
}
|
||||
|
||||
echo "<html><head><title>ERROR IM MYSQL</title>";
|
||||
echo "<style>BODY{FONT-FAMILY:tahoma;FONT-SIZE:12px;}.error {}</style></head><body>";
|
||||
echo '<br />';
|
||||
echo '<div class="error">';
|
||||
echo " <a href='#' onclick='window.location.reload( false );'>click to Refresh this page ...</a><br />";
|
||||
echo "<h2>Sorry , There is an error in mysql " . ($msg !='' ? ", error : $msg" : "") ."</h2>";
|
||||
if($error_sql != '')
|
||||
{
|
||||
echo "<br />--[query]-------------------------- <br />$error_sql<br />---------------------------------<br /><br />";
|
||||
}
|
||||
echo "[$error_no : $error_msg] <br />";
|
||||
if($updating_related)
|
||||
{
|
||||
global $config;
|
||||
echo "<br /><strong>Your Kleeja database seems to be old, try to update it now from: " . $config['siteurl'] . "install/</strong>";
|
||||
}
|
||||
echo "<br /><br /><strong>Script: Kleeja <br /><a href='http://www.kleeja.com'>Kleeja Website</a></strong>";
|
||||
echo '</b></div>';
|
||||
echo '</body></html>';
|
||||
|
||||
#loggin -> error
|
||||
kleeja_log('[SQL ERROR] : "' . $error_no . ' : ' . $error_msg . '" ' . $this->connect_id);
|
||||
|
||||
@$this->close();
|
||||
exit();
|
||||
}
|
||||
public function fetch_array($query_id = 0)
|
||||
{
|
||||
if ( ! $query_id )
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
|
||||
/*
|
||||
* return last error
|
||||
*/
|
||||
function get_error()
|
||||
{
|
||||
return array(mysql_errno(), mysql_error());
|
||||
}
|
||||
return $query_id ? mysql_fetch_array($query_id, MYSQL_ASSOC) : false;
|
||||
}
|
||||
|
||||
}#end of class
|
||||
/*
|
||||
* if we have a result and we have to know
|
||||
* the number of it , this is a func ..
|
||||
*/
|
||||
public function num_rows($query_id = 0)
|
||||
{
|
||||
if ( ! $query_id )
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
|
||||
return $query_id ? mysql_num_rows($query_id) : false;
|
||||
}
|
||||
|
||||
|
||||
// last id inserted in sql
|
||||
public function insert_id()
|
||||
{
|
||||
return ($this->connect_id) ? mysql_insert_id($this->connect_id) : false;
|
||||
}
|
||||
|
||||
// clean the qurery before insert it
|
||||
public function escape($msg)
|
||||
{
|
||||
$msg = htmlspecialchars($msg, ENT_QUOTES);
|
||||
//$msg = (!get_magic_quotes_gpc()) ? addslashes ($msg) : $msg;
|
||||
$msg = $this->real_escape($msg);
|
||||
return $msg;
|
||||
}
|
||||
|
||||
// real escape ..
|
||||
public function real_escape($msg)
|
||||
{
|
||||
if (is_array($msg))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
elseif (function_exists('mysql_real_escape_string'))
|
||||
{
|
||||
if (! $this-connect_id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return mysql_real_escape_string($msg, $this->connect_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// because mysql_escape_string doesnt escape % & _[php.net/mysql_escape_string]
|
||||
//return addcslashes(mysql_escape_string($msg),'%_');
|
||||
return mysql_escape_string($msg);
|
||||
}
|
||||
}
|
||||
|
||||
// get affected records
|
||||
public function affected()
|
||||
{
|
||||
return ( $this->connect_id ) ? mysql_affected_rows($this->connect_id) : false;
|
||||
}
|
||||
|
||||
// get the information of mysql server
|
||||
public function server_info()
|
||||
{
|
||||
return 'MySQL ' . $this->mysql_version;
|
||||
}
|
||||
|
||||
// error message func
|
||||
public function error_msg($msg)
|
||||
{
|
||||
global $dbprefix;
|
||||
|
||||
if (! $this->show_errors)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$error_no = mysql_errno();
|
||||
$error_msg = mysql_error();
|
||||
$error_sql = @current($this->debugr[$this->query_num+1]);
|
||||
|
||||
//some ppl want hide their table names, not in develoment stage
|
||||
if (! defined('DEV_STAGE'))
|
||||
{
|
||||
$error_sql = preg_replace("#\s{1,3}`*{$dbprefix}([a-z0-9]+)`*\s{1,3}#e", "' <span style=\"color:blue\">' . substr('$1', 0, 1) . '</span> '", $error_sql);
|
||||
$error_msg = preg_replace("#{$this->db_name}.{$dbprefix}([a-z0-9]+)#e", "' <span style=\"color:blue\">' . substr('$1', 0, 1) . '</span> '", $error_msg);
|
||||
$error_sql = preg_replace("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#ie", "' $1 <span style=\"color:blue\">' . substr('$2', 0, 1) . '</span> '", $error_sql);
|
||||
$error_msg = preg_replace("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#ie", "' $1 <span style=\"color:blue\">' . substr('$2', 0, 1) . '</span> '", $error_msg);
|
||||
$error_msg = preg_replace("#\s'([^']+)'@'([^']+)'#ie", "' <span style=\"color:blue\">hidden</span>@$2 '", $error_msg);
|
||||
$error_sql = preg_replace("#password\s*=\s*'[^']+'#i", "password='<span style=\"color:blue\">hidden</span>'", $error_sql);
|
||||
}
|
||||
|
||||
//is this error related to updating?
|
||||
$updating_related = false;
|
||||
|
||||
if (strpos($error_msg, 'Unknown column') !== false)
|
||||
{
|
||||
$updating_related = true;
|
||||
}
|
||||
|
||||
echo '<html><head><title>ERROR IM MYSQL</title>';
|
||||
echo '<style>BODY{FONT-FAMILY:tahoma;FONT-SIZE:12px;}.error {}</style></head><body>';
|
||||
echo '<br />';
|
||||
echo '<div class="error">';
|
||||
echo " <a href='#' onclick='window.location.reload( false );'>click to Refresh this page ...</a><br />";
|
||||
echo '<h2>Sorry , There is an error in mysql ' . ($msg !='' ? ", error : $msg" : '') . '</h2>';
|
||||
|
||||
if ($error_sql != '')
|
||||
{
|
||||
echo "<br />--[query]-------------------------- <br />$error_sql<br />---------------------------------<br /><br />";
|
||||
}
|
||||
echo "[$error_no : $error_msg] <br />";
|
||||
|
||||
if ($updating_related)
|
||||
{
|
||||
global $config;
|
||||
echo '<br /><strong>Your Kleeja database seems to be old, try to update it now from: ' . $config['siteurl'] . 'install/</strong>';
|
||||
}
|
||||
echo "<br /><br /><strong>Script: Kleeja <br /><a href='http://www.kleeja.com'>Kleeja Website</a></strong>";
|
||||
echo '</b></div>';
|
||||
echo '</body></html>';
|
||||
|
||||
//loggin -> error
|
||||
kleeja_log('[SQL ERROR] : "' . $error_no . ' : ' . $error_msg . '" ' . $this->connect_id);
|
||||
|
||||
@$this->close();
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
// return last error
|
||||
public function get_error()
|
||||
{
|
||||
return [mysql_errno(), mysql_error()];
|
||||
}
|
||||
}//end of class
|
||||
|
||||
endif;
|
||||
|
||||
@@ -9,483 +9,488 @@
|
||||
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
if(!defined("SQL_LAYER")):
|
||||
if (! defined('SQL_LAYER')):
|
||||
|
||||
define("SQL_LAYER","mysqli");
|
||||
define('SQL_LAYER', 'mysqli');
|
||||
|
||||
class KleejaDatabase
|
||||
{
|
||||
var $connect_id = null;
|
||||
var $result;
|
||||
var $query_num = 0;
|
||||
var $in_transaction = 0;
|
||||
var $debugr = false;
|
||||
var $show_errors = true;
|
||||
public $connect_id = null;
|
||||
public $result;
|
||||
public $query_num = 0;
|
||||
public $in_transaction = 0;
|
||||
public $debugr = false;
|
||||
public $show_errors = true;
|
||||
|
||||
|
||||
/*
|
||||
* initiate the class
|
||||
* with basic data
|
||||
*/
|
||||
function __construct($host, $db_username, $db_password, $db_name, $new_link = false)
|
||||
{
|
||||
global $script_encoding;
|
||||
|
||||
$host .= strpos($host, ':') !== false ? '' : ':';
|
||||
$this->host = substr($host, 0, strpos($host, ':'));
|
||||
$this->port = (int) substr($host, strpos($host, ':')+1);
|
||||
$this->db_username = $db_username;
|
||||
$this->db_name = $db_name;
|
||||
$this->db_password = 'hidden';
|
||||
|
||||
$this->connect_id = @mysqli_connect($this->host, $this->db_username, $db_password, $this->db_name, (!$this->port ? 3306 : $this->port ));
|
||||
|
||||
//no error
|
||||
if(defined('MYSQL_NO_ERRORS'))
|
||||
{
|
||||
$this->show_errors = false;
|
||||
}
|
||||
|
||||
|
||||
if(!$this->connect_id)
|
||||
{
|
||||
#loggin -> no database -> close connection
|
||||
$this->close();
|
||||
$this->error_msg("we can not connect to the server ...");
|
||||
return false;
|
||||
}
|
||||
|
||||
#loggin -> connecting
|
||||
kleeja_log('[Connected] : ' . kleeja_get_page());
|
||||
|
||||
|
||||
if ((!preg_match('/utf/i', strtolower($script_encoding)) && !defined('IN_LOGINPAGE') && !defined('IN_ADMIN_LOGIN') && !defined('DISABLE_INTR')) || (empty($script_encoding) || preg_match('/utf/i', strtolower($script_encoding)) || defined('DISABLE_INTR')))
|
||||
{
|
||||
if(mysqli_set_charset($this->connect_id, 'utf8'))
|
||||
{
|
||||
#loggin -> set utf8
|
||||
kleeja_log('[Set to UTF8] : --> ');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->connect_id;
|
||||
}
|
||||
|
||||
function is_connected()
|
||||
/*
|
||||
* initiate the class
|
||||
* with basic data
|
||||
*/
|
||||
public function __construct($host, $db_username, $db_password, $db_name, $new_link = false)
|
||||
{
|
||||
return !(is_null($this->connect_id) || empty($this->connect_id));
|
||||
global $script_encoding;
|
||||
|
||||
$host .= strpos($host, ':') !== false ? '' : ':';
|
||||
$this->host = substr($host, 0, strpos($host, ':'));
|
||||
$this->port = (int) substr($host, strpos($host, ':')+1);
|
||||
$this->db_username = $db_username;
|
||||
$this->db_name = $db_name;
|
||||
$this->db_password = 'hidden';
|
||||
|
||||
$this->connect_id = @mysqli_connect($this->host, $this->db_username, $db_password, $this->db_name, (! $this->port ? 3306 : $this->port ));
|
||||
|
||||
//no error
|
||||
if (defined('MYSQL_NO_ERRORS'))
|
||||
{
|
||||
$this->show_errors = false;
|
||||
}
|
||||
|
||||
|
||||
if (! $this->connect_id)
|
||||
{
|
||||
//loggin -> no database -> close connection
|
||||
$this->close();
|
||||
$this->error_msg('we can not connect to the server ...');
|
||||
return false;
|
||||
}
|
||||
|
||||
//loggin -> connecting
|
||||
kleeja_log('[Connected] : ' . kleeja_get_page());
|
||||
|
||||
|
||||
if ((! preg_match('/utf/i', strtolower($script_encoding)) && ! defined('IN_LOGINPAGE') && ! defined('IN_ADMIN_LOGIN') && ! defined('DISABLE_INTR')) || (empty($script_encoding) || preg_match('/utf/i', strtolower($script_encoding)) || defined('DISABLE_INTR')))
|
||||
{
|
||||
if (mysqli_set_charset($this->connect_id, 'utf8'))
|
||||
{
|
||||
//loggin -> set utf8
|
||||
kleeja_log('[Set to UTF8] : --> ');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->connect_id;
|
||||
}
|
||||
|
||||
/*
|
||||
* close the connection
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
if($this->connect_id)
|
||||
{
|
||||
// Commit any remaining transactions
|
||||
if($this->in_transaction)
|
||||
{
|
||||
mysqli_commit($this->connect_id);
|
||||
}
|
||||
public function is_connected()
|
||||
{
|
||||
return ! (is_null($this->connect_id) || empty($this->connect_id));
|
||||
}
|
||||
|
||||
#loggin -> close connection
|
||||
kleeja_log('[Closing connection] : ' . kleeja_get_page());
|
||||
// close the connection
|
||||
public function close()
|
||||
{
|
||||
if ($this->connect_id)
|
||||
{
|
||||
// Commit any remaining transactions
|
||||
if ($this->in_transaction)
|
||||
{
|
||||
mysqli_commit($this->connect_id);
|
||||
}
|
||||
|
||||
return @mysqli_close($this->connect_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* encoding functions
|
||||
*/
|
||||
function set_utf8()
|
||||
{
|
||||
//loggin -> close connection
|
||||
kleeja_log('[Closing connection] : ' . kleeja_get_page());
|
||||
|
||||
return @mysqli_close($this->connect_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// encoding functions
|
||||
public function set_utf8()
|
||||
{
|
||||
$this->set_names('utf8');
|
||||
}
|
||||
|
||||
function set_names($charset)
|
||||
{
|
||||
@mysqli_set_charset($this->connect_id, $charset);
|
||||
}
|
||||
|
||||
function client_encoding()
|
||||
{
|
||||
}
|
||||
|
||||
public function set_names($charset)
|
||||
{
|
||||
@mysqli_set_charset($this->connect_id, $charset);
|
||||
}
|
||||
|
||||
public function client_encoding()
|
||||
{
|
||||
return mysqli_character_set_name($this->connect_id);
|
||||
}
|
||||
|
||||
function mysql_version()
|
||||
{
|
||||
$vr = $this->query('SELECT VERSION() AS v');
|
||||
$vs = $this->fetch_array($vr);
|
||||
$vs = $vs['v'];
|
||||
return preg_replace('/^([^-]+).*$/', '\\1', $vs);
|
||||
}
|
||||
|
||||
/*
|
||||
* the query func . its so important to do
|
||||
* the quries and give results
|
||||
*/
|
||||
function query($query, $transaction = false)
|
||||
{
|
||||
//no connection
|
||||
if(!$this->connect_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Remove any pre-existing queries
|
||||
//
|
||||
unset($this->result);
|
||||
|
||||
if(!empty($query))
|
||||
{
|
||||
//debug .. //////////////
|
||||
$srartum_sql = get_microtime();
|
||||
////////////////
|
||||
public function mysql_version()
|
||||
{
|
||||
$vr = $this->query('SELECT VERSION() AS v');
|
||||
$vs = $this->fetch_array($vr);
|
||||
$vs = $vs['v'];
|
||||
return preg_replace('/^([^-]+).*$/', '\\1', $vs);
|
||||
}
|
||||
|
||||
if($transaction == 1 && !$this->in_transaction)
|
||||
{
|
||||
if(!mysqli_autocommit($this->connect_id, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->in_transaction = TRUE;
|
||||
}
|
||||
/*
|
||||
* the query func . its so important to do
|
||||
* the quries and give results
|
||||
*/
|
||||
public function query($query, $transaction = false)
|
||||
{
|
||||
//no connection
|
||||
if (! $this->connect_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->result = mysqli_query($this->connect_id, $query);
|
||||
//
|
||||
// Remove any pre-existing queries
|
||||
//
|
||||
unset($this->result);
|
||||
|
||||
//debug .. //////////////
|
||||
$this->debugr[$this->query_num+1] = array($query, sprintf('%.5f', get_microtime() - $srartum_sql));
|
||||
////////////////
|
||||
if (! empty($query))
|
||||
{
|
||||
//debug .. //////////////
|
||||
$srartum_sql = get_microtime();
|
||||
////////////////
|
||||
|
||||
if(!$this->result)
|
||||
{
|
||||
$this->error_msg('Error In query');
|
||||
}
|
||||
else
|
||||
{
|
||||
//let's debug it
|
||||
kleeja_log('[Query] : --> ' . $query);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $transaction == 2 && $this->in_transaction )
|
||||
{
|
||||
$this->result = mysqli_commit($this->connect_id);
|
||||
}
|
||||
}
|
||||
|
||||
//is there any result
|
||||
if($this->result)
|
||||
{
|
||||
if($transaction == 2 && $this->in_transaction)
|
||||
{
|
||||
$this->in_transaction = false;
|
||||
if ($transaction == 1 && ! $this->in_transaction)
|
||||
{
|
||||
if (! mysqli_autocommit($this->connect_id, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mysqli_commit($this->connect_id))
|
||||
{
|
||||
mysqli_rollback($this->connect_id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->in_transaction = true;
|
||||
}
|
||||
|
||||
$this->query_num++;
|
||||
return $this->result;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->in_transaction)
|
||||
{
|
||||
mysqli_rollback($this->connect_id);
|
||||
$this->in_transaction = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* query build
|
||||
*/
|
||||
function build($query)
|
||||
{
|
||||
$sql = '';
|
||||
$this->result = mysqli_query($this->connect_id, $query);
|
||||
|
||||
if (isset($query['SELECT']))
|
||||
{
|
||||
$sql = 'SELECT '.$query['SELECT'].' FROM '.$query['FROM'];
|
||||
//debug .. //////////////
|
||||
$this->debugr[$this->query_num+1] = [$query, sprintf('%.5f', get_microtime() - $srartum_sql)];
|
||||
////////////////
|
||||
|
||||
if (isset($query['JOINS']))
|
||||
{
|
||||
foreach ($query['JOINS'] as $cur_join)
|
||||
$sql .= ' '.key($cur_join).' '. @current($cur_join).' ON '.$cur_join['ON'];
|
||||
}
|
||||
if (! $this->result)
|
||||
{
|
||||
$this->error_msg('Error In query');
|
||||
}
|
||||
else
|
||||
{
|
||||
//let's debug it
|
||||
kleeja_log('[Query] : --> ' . $query);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $transaction == 2 && $this->in_transaction )
|
||||
{
|
||||
$this->result = mysqli_commit($this->connect_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($query['WHERE']))
|
||||
$sql .= ' WHERE '.$query['WHERE'];
|
||||
if (!empty($query['GROUP BY']))
|
||||
$sql .= ' GROUP BY '.$query['GROUP BY'];
|
||||
if (!empty($query['HAVING']))
|
||||
$sql .= ' HAVING '.$query['HAVING'];
|
||||
if (!empty($query['ORDER BY']))
|
||||
$sql .= ' ORDER BY '.$query['ORDER BY'];
|
||||
if (!empty($query['LIMIT']))
|
||||
$sql .= ' LIMIT '.$query['LIMIT'];
|
||||
}
|
||||
else if (isset($query['INSERT']))
|
||||
{
|
||||
$sql = 'INSERT INTO '.$query['INTO'];
|
||||
//is there any result
|
||||
if ($this->result)
|
||||
{
|
||||
if ($transaction == 2 && $this->in_transaction)
|
||||
{
|
||||
$this->in_transaction = false;
|
||||
|
||||
if (!empty($query['INSERT']))
|
||||
$sql .= ' ('.$query['INSERT'].')';
|
||||
if (! mysqli_commit($this->connect_id))
|
||||
{
|
||||
mysqli_rollback($this->connect_id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= ' VALUES('.$query['VALUES'].')';
|
||||
}
|
||||
else if (isset($query['UPDATE']))
|
||||
{
|
||||
if (isset($query['PARAMS']['LOW_PRIORITY']))
|
||||
$query['UPDATE'] = 'LOW_PRIORITY '.$query['UPDATE'];
|
||||
$this->query_num++;
|
||||
return $this->result;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->in_transaction)
|
||||
{
|
||||
mysqli_rollback($this->connect_id);
|
||||
$this->in_transaction = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.$query['UPDATE'].' SET '.$query['SET'];
|
||||
// query build
|
||||
public function build($query)
|
||||
{
|
||||
$sql = '';
|
||||
|
||||
if (!empty($query['WHERE']))
|
||||
$sql .= ' WHERE '.$query['WHERE'];
|
||||
}
|
||||
else if (isset($query['DELETE']))
|
||||
{
|
||||
$sql = 'DELETE FROM '.$query['DELETE'];
|
||||
if (isset($query['SELECT']))
|
||||
{
|
||||
$sql = 'SELECT ' . $query['SELECT'] . ' FROM ' . $query['FROM'];
|
||||
|
||||
if (!empty($query['WHERE']))
|
||||
$sql .= ' WHERE '.$query['WHERE'];
|
||||
}
|
||||
else if (isset($query['REPLACE']))
|
||||
{
|
||||
$sql = 'REPLACE INTO '.$query['INTO'];
|
||||
if (isset($query['JOINS']))
|
||||
{
|
||||
foreach ($query['JOINS'] as $cur_join)
|
||||
{
|
||||
$sql .= ' ' . key($cur_join) . ' ' . @current($cur_join) . ' ON ' . $cur_join['ON'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($query['REPLACE']))
|
||||
$sql .= ' ('.$query['REPLACE'].')';
|
||||
if (! empty($query['WHERE']))
|
||||
{
|
||||
$sql .= ' WHERE ' . $query['WHERE'];
|
||||
}
|
||||
|
||||
$sql .= ' VALUES('.$query['VALUES'].')';
|
||||
}
|
||||
if (! empty($query['GROUP BY']))
|
||||
{
|
||||
$sql .= ' GROUP BY ' . $query['GROUP BY'];
|
||||
}
|
||||
|
||||
return $this->query($sql);
|
||||
}
|
||||
if (! empty($query['HAVING']))
|
||||
{
|
||||
$sql .= ' HAVING ' . $query['HAVING'];
|
||||
}
|
||||
|
||||
/*
|
||||
* free the memmory from the last results
|
||||
*/
|
||||
function free($query_id = 0)
|
||||
{
|
||||
return $this->freeresult($query_id);
|
||||
}
|
||||
|
||||
function freeresult($query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
if (! empty($query['ORDER BY']))
|
||||
{
|
||||
$sql .= ' ORDER BY ' . $query['ORDER BY'];
|
||||
}
|
||||
|
||||
if ($query_id)
|
||||
{
|
||||
mysqli_free_result($query_id);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (! empty($query['LIMIT']))
|
||||
{
|
||||
$sql .= ' LIMIT ' . $query['LIMIT'];
|
||||
}
|
||||
}
|
||||
elseif (isset($query['INSERT']))
|
||||
{
|
||||
$sql = 'INSERT INTO ' . $query['INTO'];
|
||||
|
||||
/*
|
||||
* if the result is an arry ,
|
||||
* this func is so important to order them as a array
|
||||
*/
|
||||
function fetch($query_id = 0)
|
||||
{
|
||||
return $this->fetch_array($query_id);
|
||||
}
|
||||
|
||||
function fetch_array($query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
|
||||
return $query_id ? mysqli_fetch_array($query_id, MYSQLI_ASSOC) : false;
|
||||
}
|
||||
if (! empty($query['INSERT']))
|
||||
{
|
||||
$sql .= ' (' . $query['INSERT'] . ')';
|
||||
}
|
||||
|
||||
/*
|
||||
* if we have a result and we have to know
|
||||
* the number of it , this is a func ..
|
||||
*/
|
||||
function num_rows($query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
$sql .= ' VALUES(' . $query['VALUES'] . ')';
|
||||
}
|
||||
elseif (isset($query['UPDATE']))
|
||||
{
|
||||
if (isset($query['PARAMS']['LOW_PRIORITY']))
|
||||
{
|
||||
$query['UPDATE'] = 'LOW_PRIORITY ' . $query['UPDATE'];
|
||||
}
|
||||
|
||||
return $query_id ? mysqli_num_rows($query_id) : false;
|
||||
}
|
||||
$sql = 'UPDATE ' . $query['UPDATE'] . ' SET ' . $query['SET'];
|
||||
|
||||
|
||||
/*
|
||||
* last id inserted in sql
|
||||
*/
|
||||
function insert_id()
|
||||
{
|
||||
return $this->connect_id ? mysqli_insert_id($this->connect_id) : false;
|
||||
}
|
||||
if (! empty($query['WHERE']))
|
||||
{
|
||||
$sql .= ' WHERE ' . $query['WHERE'];
|
||||
}
|
||||
}
|
||||
elseif (isset($query['DELETE']))
|
||||
{
|
||||
$sql = 'DELETE FROM ' . $query['DELETE'];
|
||||
|
||||
/*
|
||||
* clean the qurery before insert it
|
||||
*/
|
||||
function escape($msg)
|
||||
{
|
||||
$msg = htmlspecialchars($msg , ENT_QUOTES);
|
||||
#$msg = (!get_magic_quotes_gpc()) ? addslashes ($msg) : $msg;
|
||||
$msg = $this->real_escape($msg);
|
||||
return $msg;
|
||||
}
|
||||
if (! empty($query['WHERE']))
|
||||
{
|
||||
$sql .= ' WHERE ' . $query['WHERE'];
|
||||
}
|
||||
}
|
||||
elseif (isset($query['REPLACE']))
|
||||
{
|
||||
$sql = 'REPLACE INTO ' . $query['INTO'];
|
||||
|
||||
/*
|
||||
* real escape ..
|
||||
*/
|
||||
/**
|
||||
* @param string|array $msg
|
||||
* @return int|string
|
||||
*/
|
||||
function real_escape($msg)
|
||||
{
|
||||
if (is_array($msg) && !$this->connect_id)
|
||||
{
|
||||
return $msg;
|
||||
}
|
||||
if (! empty($query['REPLACE']))
|
||||
{
|
||||
$sql .= ' (' . $query['REPLACE'] . ')';
|
||||
}
|
||||
|
||||
if(!$this->connect_id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
$sql .= ' VALUES(' . $query['VALUES'] . ')';
|
||||
}
|
||||
|
||||
//escaping _ made alot of problems
|
||||
//return addcslashes(mysqli_real_escape_string($this->connect_id, $msg), '%_');
|
||||
return mysqli_real_escape_string($this->connect_id, $msg);
|
||||
}
|
||||
return $this->query($sql);
|
||||
}
|
||||
|
||||
/*
|
||||
* get affected records
|
||||
*/
|
||||
function affected()
|
||||
{
|
||||
return $this->connect_id ? mysqli_affected_rows($this->connect_id) : false;
|
||||
}
|
||||
// free the memmory from the last results
|
||||
public function free($query_id = 0)
|
||||
{
|
||||
return $this->freeresult($query_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* get the information of mysql server
|
||||
*/
|
||||
function server_info()
|
||||
{
|
||||
return 'MySQLi ' . $this->mysql_version;
|
||||
}
|
||||
public function freeresult($query_id = 0)
|
||||
{
|
||||
if (! $query_id)
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
|
||||
/*
|
||||
* error message func
|
||||
*/
|
||||
function error_msg($msg)
|
||||
{
|
||||
global $dbprefix;
|
||||
if ($query_id)
|
||||
{
|
||||
mysqli_free_result($query_id);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$this->show_errors)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* if the result is an arry ,
|
||||
* this func is so important to order them as a array
|
||||
*/
|
||||
public function fetch($query_id = 0)
|
||||
{
|
||||
return $this->fetch_array($query_id);
|
||||
}
|
||||
|
||||
$error_no = $this->connect_id ? @mysqli_errno($this->connect_id) : @mysqli_connect_errno();
|
||||
$error_msg = $this->connect_id ? @mysqli_error($this->connect_id) : @mysqli_connect_error();
|
||||
$error_sql = @current($this->debugr[$this->query_num+1]);
|
||||
public function fetch_array($query_id = 0)
|
||||
{
|
||||
if (! $query_id)
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
|
||||
//some ppl want hide their table names
|
||||
if(!defined('DEV_STAGE'))
|
||||
{
|
||||
$error_sql = preg_replace("#\s{1,3}`*{$dbprefix}([a-z0-9]+)`*\s{1,3}#e", "' <span style=\"color:blue\">' . substr('$1', 0, 1) . '</span> '", $error_sql);
|
||||
$error_msg = preg_replace("#{$this->db_name}.{$dbprefix}([a-z0-9]+)#e", "' <span style=\"color:blue\">' . substr('$1', 0, 1) . '</span> '", $error_msg);
|
||||
$error_sql = preg_replace("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#ie", "' $1 <span style=\"color:blue\">' . substr('$2', 0, 1) . '</span> '", $error_sql);
|
||||
$error_msg = preg_replace("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#ie", "' $1 <span style=\"color:blue\">' . substr('$2', 0, 1) . '</span> '", $error_msg);
|
||||
$error_msg = preg_replace("#\s'([^']+)'@'([^']+)'#ie", "' <span style=\"color:blue\">hidden</span>@$2 '", $error_msg);
|
||||
$error_sql = preg_replace("#password\s*=\s*'[^']+'#i", "password='<span style=\"color:blue\">hidden</span>'", $error_sql);
|
||||
}
|
||||
return $query_id ? mysqli_fetch_array($query_id, MYSQLI_ASSOC) : false;
|
||||
}
|
||||
|
||||
#is this error related to updating?
|
||||
$updating_related = false;
|
||||
if(strpos($error_msg, 'Unknown column') !== false)
|
||||
{
|
||||
$updating_related = true;
|
||||
}
|
||||
/*
|
||||
* if we have a result and we have to know
|
||||
* the number of it , this is a func ..
|
||||
*/
|
||||
public function num_rows($query_id = 0)
|
||||
{
|
||||
if (! $query_id)
|
||||
{
|
||||
$query_id = $this->result;
|
||||
}
|
||||
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
$error_message = "<html><head><title>ERROR IM MYSQL</title>";
|
||||
return $query_id ? mysqli_num_rows($query_id) : false;
|
||||
}
|
||||
|
||||
|
||||
// last id inserted in sql
|
||||
public function insert_id()
|
||||
{
|
||||
return $this->connect_id ? mysqli_insert_id($this->connect_id) : false;
|
||||
}
|
||||
|
||||
// clean the qurery before insert it
|
||||
public function escape($msg)
|
||||
{
|
||||
$msg = htmlspecialchars($msg, ENT_QUOTES);
|
||||
//$msg = (!get_magic_quotes_gpc()) ? addslashes ($msg) : $msg;
|
||||
$msg = $this->real_escape($msg);
|
||||
return $msg;
|
||||
}
|
||||
|
||||
// real escape ..
|
||||
/**
|
||||
* @param string|array $msg
|
||||
* @return int|string
|
||||
*/
|
||||
public function real_escape($msg)
|
||||
{
|
||||
if (is_array($msg) && ! $this->connect_id)
|
||||
{
|
||||
return $msg;
|
||||
}
|
||||
|
||||
if (! $this->connect_id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//escaping _ made alot of problems
|
||||
//return addcslashes(mysqli_real_escape_string($this->connect_id, $msg), '%_');
|
||||
return mysqli_real_escape_string($this->connect_id, $msg);
|
||||
}
|
||||
|
||||
// get affected records
|
||||
public function affected()
|
||||
{
|
||||
return $this->connect_id ? mysqli_affected_rows($this->connect_id) : false;
|
||||
}
|
||||
|
||||
// get the information of mysql server
|
||||
public function server_info()
|
||||
{
|
||||
return 'MySQLi ' . $this->mysql_version;
|
||||
}
|
||||
|
||||
// error message func
|
||||
public function error_msg($msg)
|
||||
{
|
||||
global $dbprefix;
|
||||
|
||||
if (! $this->show_errors)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$error_no = $this->connect_id ? @mysqli_errno($this->connect_id) : @mysqli_connect_errno();
|
||||
$error_msg = $this->connect_id ? @mysqli_error($this->connect_id) : @mysqli_connect_error();
|
||||
$error_sql = @current($this->debugr[$this->query_num+1]);
|
||||
|
||||
//some ppl want hide their table names
|
||||
if (! defined('DEV_STAGE'))
|
||||
{
|
||||
$error_sql = preg_replace("#\s{1,3}`*{$dbprefix}([a-z0-9]+)`*\s{1,3}#e", "' <span style=\"color:blue\">' . substr('$1', 0, 1) . '</span> '", $error_sql);
|
||||
$error_msg = preg_replace("#{$this->db_name}.{$dbprefix}([a-z0-9]+)#e", "' <span style=\"color:blue\">' . substr('$1', 0, 1) . '</span> '", $error_msg);
|
||||
$error_sql = preg_replace("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#ie", "' $1 <span style=\"color:blue\">' . substr('$2', 0, 1) . '</span> '", $error_sql);
|
||||
$error_msg = preg_replace("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#ie", "' $1 <span style=\"color:blue\">' . substr('$2', 0, 1) . '</span> '", $error_msg);
|
||||
$error_msg = preg_replace("#\s'([^']+)'@'([^']+)'#ie", "' <span style=\"color:blue\">hidden</span>@$2 '", $error_msg);
|
||||
$error_sql = preg_replace("#password\s*=\s*'[^']+'#i", "password='<span style=\"color:blue\">hidden</span>'", $error_sql);
|
||||
}
|
||||
|
||||
//is this error related to updating?
|
||||
$updating_related = false;
|
||||
|
||||
if (strpos($error_msg, 'Unknown column') !== false)
|
||||
{
|
||||
$updating_related = true;
|
||||
}
|
||||
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
$error_message = '<html><head><title>ERROR IM MYSQL</title>';
|
||||
$error_message .= "<style>BODY{font-family:'Tahoma',serif;font-size:12px;}.error {}</style></head><body>";
|
||||
$error_message .= '<br />';
|
||||
$error_message .= '<div class="error">';
|
||||
$error_message .= " <a href='#' onclick='window.location.reload( false );'>click to Refresh this page ...</a><br />";
|
||||
$error_message .= "<h2>Sorry , There is an error in mysql " . ($msg !='' ? ", error : $msg" : "") ."</h2>";
|
||||
if($error_sql != '')
|
||||
{
|
||||
$error_message .= "<br />--[query]-------------------------- <br />$error_sql<br />---------------------------------<br /><br />";
|
||||
}
|
||||
$error_message .= "[$error_no : $error_msg] <br />";
|
||||
if($updating_related)
|
||||
{
|
||||
global $config;
|
||||
$error_message .= "<br /><strong>Your Kleeja database might be old, try to update it now from: " . rtrim($config['siteurl'], '/') . "/install</strong>";
|
||||
$error_message .= '<br />';
|
||||
$error_message .= '<div class="error">';
|
||||
$error_message .= " <a href='#' onclick='window.location.reload( false );'>click to Refresh this page ...</a><br />";
|
||||
$error_message .= '<h2>Sorry , There is an error in mysql ' . ($msg !='' ? ", error : $msg" : '') . '</h2>';
|
||||
|
||||
if ($error_sql != '')
|
||||
{
|
||||
$error_message .= "<br />--[query]-------------------------- <br />$error_sql<br />---------------------------------<br /><br />";
|
||||
}
|
||||
$error_message .= "[$error_no : $error_msg] <br />";
|
||||
|
||||
if ($updating_related)
|
||||
{
|
||||
global $config;
|
||||
$error_message .= '<br /><strong>Your Kleeja database might be old, try to update it now from: ' . rtrim($config['siteurl'], '/') . '/install</strong>';
|
||||
$error_message .= "<br /><br><strong>If this error happened after installing a plugin, add <span style=\"background-color:#ccc; padding:2px\">define('STOP_PLUGINS', true);</span> to end of config.php file.</strong>";
|
||||
}
|
||||
$error_message .= "<br /><br /><strong>Script: Kleeja <br /><a href='http://www.kleeja.com'>Kleeja Website</a></strong>";
|
||||
$error_message .= '</b></div>';
|
||||
$error_message .= '</body></html>';
|
||||
}
|
||||
$error_message .= "<br /><br /><strong>Script: Kleeja <br /><a href='http://www.kleeja.com'>Kleeja Website</a></strong>";
|
||||
$error_message .= '</b></div>';
|
||||
$error_message .= '</body></html>';
|
||||
|
||||
|
||||
print $error_message;
|
||||
|
||||
|
||||
#loggin -> error
|
||||
kleeja_log('[SQL ERROR] : "' . $error_no . ' : ' . $error_msg . '" -->');
|
||||
|
||||
@$this->close();
|
||||
exit();
|
||||
}
|
||||
//loggin -> error
|
||||
kleeja_log('[SQL ERROR] : "' . $error_no . ' : ' . $error_msg . '" -->');
|
||||
|
||||
/*
|
||||
* return last error
|
||||
*/
|
||||
function get_error()
|
||||
{
|
||||
if($this->connect_id)
|
||||
{
|
||||
return array(@mysqli_errno($this->connect_id), @mysqli_error($this->connect_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(@mysqli_connect_errno(), @mysqli_connect_error());
|
||||
}
|
||||
}
|
||||
@$this->close();
|
||||
|
||||
}#end of class
|
||||
exit();
|
||||
}
|
||||
|
||||
// return last error
|
||||
public function get_error()
|
||||
{
|
||||
if ($this->connect_id)
|
||||
{
|
||||
return [@mysqli_errno($this->connect_id), @mysqli_error($this->connect_id)];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [@mysqli_connect_errno(), @mysqli_connect_error()];
|
||||
}
|
||||
}
|
||||
}//end of class
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
@@ -9,44 +9,44 @@
|
||||
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
class Pagination
|
||||
{
|
||||
protected $totalPages, $startRow , $currentPage;
|
||||
protected $totalPages, $startRow , $currentPage;
|
||||
|
||||
/**
|
||||
* @param $rowsPerPage
|
||||
* @param $numRows
|
||||
* @param int $currentPage
|
||||
*/
|
||||
public function __construct($rowsPerPage, $numRows, $currentPage = 1)
|
||||
{
|
||||
// Calculate the total number of pages
|
||||
$this->setTotalPages(ceil($numRows/$rowsPerPage));
|
||||
public function __construct($rowsPerPage, $numRows, $currentPage = 1)
|
||||
{
|
||||
// Calculate the total number of pages
|
||||
$this->setTotalPages(ceil($numRows/$rowsPerPage));
|
||||
|
||||
// Check that a valid page has been provided
|
||||
$this->currentPage = $currentPage < 1 ? 1 : ($currentPage > $this->totalPages ? $this->totalPages : $currentPage);
|
||||
// Check that a valid page has been provided
|
||||
$this->currentPage = $currentPage < 1 ? 1 : ($currentPage > $this->totalPages ? $this->totalPages : $currentPage);
|
||||
|
||||
// Calculate the row to start the select with
|
||||
$this->startRow = ($this->currentPage - 1) * $rowsPerPage;
|
||||
}
|
||||
// Calculate the row to start the select with
|
||||
$this->startRow = ($this->currentPage - 1) * $rowsPerPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total pages
|
||||
* @return float
|
||||
*/
|
||||
public function getTotalPages()
|
||||
{
|
||||
return $this->totalPages;
|
||||
}
|
||||
{
|
||||
return $this->totalPages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the total pages
|
||||
* @param int $totalPages
|
||||
* @param int $totalPages
|
||||
* @return int
|
||||
*/
|
||||
public function setTotalPages($totalPages = 0)
|
||||
@@ -76,9 +76,9 @@ class Pagination
|
||||
* @return int
|
||||
*/
|
||||
public function getStartRow()
|
||||
{
|
||||
return $this->startRow;
|
||||
}
|
||||
{
|
||||
return $this->startRow;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -92,94 +92,92 @@ class Pagination
|
||||
|
||||
/**
|
||||
* @param $link
|
||||
* @param string $link_plus
|
||||
* @param string $link_plus
|
||||
* @return string
|
||||
*/
|
||||
public function print_nums($link, $link_plus = '')
|
||||
{
|
||||
global $lang, $config;
|
||||
{
|
||||
global $lang, $config;
|
||||
|
||||
//if no page
|
||||
if($this->totalPages <= 1)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
//if no page
|
||||
if ($this->totalPages <= 1)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$link_plus .= $link_plus != '' ? ' ' : '';
|
||||
$link_plus .= $link_plus != '' ? ' ' : '';
|
||||
|
||||
$re = '<nav aria-label="Page navigation example">';
|
||||
$re = '<ul id="pagination" class="pagination">';
|
||||
$re = '<nav aria-label="Page navigation example">';
|
||||
$re = '<ul id="pagination" class="pagination">';
|
||||
|
||||
// Add a previous page link
|
||||
if ($this->totalPages > 1 && $this->currentPage > 1)
|
||||
{
|
||||
$re .= '<li class="page-item">';
|
||||
$re .= $config['mod_writer'] && !defined('IN_ADMIN')
|
||||
// Add a previous page link
|
||||
if ($this->totalPages > 1 && $this->currentPage > 1)
|
||||
{
|
||||
$re .= '<li class="page-item">';
|
||||
$re .= $config['mod_writer'] && ! defined('IN_ADMIN')
|
||||
? '<a class="paginate phover page-link" href="' . $link . '-' . ($this->currentPage-1) . '.html"' . $link_plus . '><span>' . $lang['PREV'] . '</span></a>'
|
||||
: '<a class="paginate phover page-link" href="' . $link . '&page=' . ($this->currentPage-1) . '"' . $link_plus . '><span>' . $lang['PREV'] . '</span></a>';
|
||||
$re .= '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->currentPage > 3)
|
||||
{
|
||||
if ($this->currentPage > 3)
|
||||
{
|
||||
$re .= '<li class="page-item">';
|
||||
$re .= $config['mod_writer'] && !defined('IN_ADMIN')
|
||||
$re .= $config['mod_writer'] && ! defined('IN_ADMIN')
|
||||
? '<a class="paginate page-link" href="' . $link . '-1.html"' . $link_plus . '><span>1</span></a>' . ($this->currentPage > 5 ? '<a class="paginate dots"><span>...</span></a>' : '')
|
||||
: '<a class="paginate page-link" href="' . $link . '&page=1"' . $link_plus . '><span>1</span></a>' . ($this->currentPage > 5 ? '<a class="paginate dots"><span>...</span></a>' : '');
|
||||
$re .= '</li>';
|
||||
}
|
||||
|
||||
for ($current = ($this->currentPage == 5) ? $this->currentPage - 3 : $this->currentPage - 2, $stop = ($this->currentPage + 4 == $this->totalPages) ? $this->currentPage + 4 : $this->currentPage + 3; $current < $stop; ++$current)
|
||||
{
|
||||
if ($current < 1 || $current > $this->totalPages)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if ($current != $this->currentPage)
|
||||
{
|
||||
}
|
||||
|
||||
for ($current = ($this->currentPage == 5) ? $this->currentPage - 3 : $this->currentPage - 2, $stop = ($this->currentPage + 4 == $this->totalPages) ? $this->currentPage + 4 : $this->currentPage + 3; $current < $stop; ++$current)
|
||||
{
|
||||
if ($current < 1 || $current > $this->totalPages)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
elseif ($current != $this->currentPage)
|
||||
{
|
||||
$re .= '<li class="page-item">';
|
||||
$re .= $config['mod_writer'] && !defined('IN_ADMIN')
|
||||
$re .= $config['mod_writer'] && ! defined('IN_ADMIN')
|
||||
? '<a class="paginate page-link" href="' . $link . '-' . $current . '.html"' . $link_plus . '><span>' . $current . '</span></a>'
|
||||
: '<a class="paginate page-link" href="' . $link . '&page=' . $current . '"' . $link_plus . '><span>' . $current . '</span></a>';
|
||||
$re .= '</li>';
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
$re .= '<li class="page-item">';
|
||||
$re .= '<a class="paginate page-link current"><span>' . $current . '</span></a>';
|
||||
$re .= '<a class="paginate page-link current"><span>' . $current . '</span></a>';
|
||||
$re .= '</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->currentPage <= ($this->totalPages-3))
|
||||
{
|
||||
if ($this->currentPage != ($this->totalPages-3) && $this->currentPage != ($this->totalPages-4))
|
||||
{
|
||||
$re .= '<li class="page-item"><a class="paginate page-link dots"><span>...</span></a></li>';
|
||||
}
|
||||
if ($this->currentPage <= ($this->totalPages-3))
|
||||
{
|
||||
if ($this->currentPage != ($this->totalPages-3) && $this->currentPage != ($this->totalPages-4))
|
||||
{
|
||||
$re .= '<li class="page-item"><a class="paginate page-link dots"><span>...</span></a></li>';
|
||||
}
|
||||
|
||||
$re .= '<li class="page-item">';
|
||||
$re .= $config['mod_writer'] && !defined('IN_ADMIN')
|
||||
$re .= $config['mod_writer'] && ! defined('IN_ADMIN')
|
||||
? '<a class="paginate page-link" href="' . $link . '-' . $this->totalPages . '.html"' . $link_plus . '><span>' . $this->totalPages . '</span></a>'
|
||||
: '<a class="paginate page-link" href="' . $link . '&page=' . $this->totalPages . '"' . $link_plus . '><span>' . $this->totalPages . '</span></a>';
|
||||
$re .= '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
// Add a next page link
|
||||
if ($this->totalPages > 1 && $this->currentPage < $this->totalPages)
|
||||
{
|
||||
// Add a next page link
|
||||
if ($this->totalPages > 1 && $this->currentPage < $this->totalPages)
|
||||
{
|
||||
$re .= '<li class="page-item">';
|
||||
$re .= $config['mod_writer'] && !defined('IN_ADMIN')
|
||||
$re .= $config['mod_writer'] && ! defined('IN_ADMIN')
|
||||
? '<a class="paginate page-link phover" href="' . $link . '-' . ($this->currentPage+1) . '.html"' . $link_plus . '><span>' . $lang['NEXT'] . '</span></a>'
|
||||
: '<a class="paginate phover page-link" href="' . $link . '&page=' . ($this->currentPage+1) . '"' . $link_plus . '><span>' . $lang['NEXT'] . '</span></a>';
|
||||
$re .= '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
$re .= '</ul>';
|
||||
$re .= '</nav>';
|
||||
$re .= '</ul>';
|
||||
$re .= '</nav>';
|
||||
|
||||
return $re;
|
||||
}
|
||||
return $re;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,265 +1,309 @@
|
||||
<?php
|
||||
#
|
||||
# Portable PHP password hashing framework.
|
||||
#
|
||||
# Version 0.1 / genuine.
|
||||
#
|
||||
# Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
|
||||
# the public domain.
|
||||
#
|
||||
# There's absolutely no warranty.
|
||||
#
|
||||
# The homepage URL for this framework is:
|
||||
#
|
||||
# http://www.openwall.com/phpass/
|
||||
#
|
||||
# Please be sure to update the Version line if you edit this file in any way.
|
||||
# It is suggested that you leave the main version number intact, but indicate
|
||||
# your project name (after the slash) and add your own revision information.
|
||||
#
|
||||
# Please do not change the "private" password hashing method implemented in
|
||||
# here, thereby making your hashes incompatible. However, if you must, please
|
||||
# change the hash type identifier (the "$P$") to something different.
|
||||
#
|
||||
# Obviously, since this code is in the public domain, the above are not
|
||||
# requirements (there can be none), but merely suggestions.
|
||||
#
|
||||
# @version $Id: phpass.php 1551 2010-07-25 22:09:47Z saanina $
|
||||
//
|
||||
// Portable PHP password hashing framework.
|
||||
//
|
||||
// Version 0.1 / genuine.
|
||||
//
|
||||
// Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
|
||||
// the public domain.
|
||||
//
|
||||
// There's absolutely no warranty.
|
||||
//
|
||||
// The homepage URL for this framework is:
|
||||
//
|
||||
// http://www.openwall.com/phpass/
|
||||
//
|
||||
// Please be sure to update the Version line if you edit this file in any way.
|
||||
// It is suggested that you leave the main version number intact, but indicate
|
||||
// your project name (after the slash) and add your own revision information.
|
||||
//
|
||||
// Please do not change the "private" password hashing method implemented in
|
||||
// here, thereby making your hashes incompatible. However, if you must, please
|
||||
// change the hash type identifier (the "$P$") to something different.
|
||||
//
|
||||
// Obviously, since this code is in the public domain, the above are not
|
||||
// requirements (there can be none), but merely suggestions.
|
||||
//
|
||||
// @version $Id: phpass.php 1551 2010-07-25 22:09:47Z saanina $
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
class PasswordHash
|
||||
{
|
||||
var $itoa64;
|
||||
var $iteration_count_log2;
|
||||
var $portable_hashes;
|
||||
var $random_state;
|
||||
public $itoa64;
|
||||
public $iteration_count_log2;
|
||||
public $portable_hashes;
|
||||
public $random_state;
|
||||
|
||||
function __construct($iteration_count_log2, $portable_hashes)
|
||||
{
|
||||
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
public function __construct($iteration_count_log2, $portable_hashes)
|
||||
{
|
||||
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
|
||||
$iteration_count_log2 = 8;
|
||||
$this->iteration_count_log2 = $iteration_count_log2;
|
||||
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
|
||||
{
|
||||
$iteration_count_log2 = 8;
|
||||
}
|
||||
$this->iteration_count_log2 = $iteration_count_log2;
|
||||
|
||||
$this->portable_hashes = $portable_hashes;
|
||||
$this->portable_hashes = $portable_hashes;
|
||||
|
||||
$this->random_state = microtime() . getmypid();
|
||||
}
|
||||
$this->random_state = microtime() . getmypid();
|
||||
}
|
||||
|
||||
function get_random_bytes($count)
|
||||
{
|
||||
$output = '';
|
||||
if (($fh = @fopen('/dev/urandom', 'rb')))
|
||||
{
|
||||
$output = fread($fh, $count);
|
||||
fclose($fh);
|
||||
}
|
||||
public function get_random_bytes($count)
|
||||
{
|
||||
$output = '';
|
||||
|
||||
if (strlen($output) < $count)
|
||||
{
|
||||
$output = '';
|
||||
for ($i = 0; $i < $count; $i += 16)
|
||||
{
|
||||
$this->random_state = md5(microtime() . $this->random_state);
|
||||
$output .= pack('H*', md5($this->random_state));
|
||||
}
|
||||
|
||||
$output = substr($output, 0, $count);
|
||||
}
|
||||
if (($fh = @fopen('/dev/urandom', 'rb')))
|
||||
{
|
||||
$output = fread($fh, $count);
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
if (strlen($output) < $count)
|
||||
{
|
||||
$output = '';
|
||||
|
||||
function encode64($input, $count)
|
||||
{
|
||||
$output = '';
|
||||
$i = 0;
|
||||
do
|
||||
{
|
||||
$value = ord($input[$i++]);
|
||||
$output .= $this->itoa64[$value & 0x3f];
|
||||
if ($i < $count)
|
||||
$value |= ord($input[$i]) << 8;
|
||||
$output .= $this->itoa64[($value >> 6) & 0x3f];
|
||||
if ($i++ >= $count)
|
||||
break;
|
||||
if ($i < $count)
|
||||
$value |= ord($input[$i]) << 16;
|
||||
$output .= $this->itoa64[($value >> 12) & 0x3f];
|
||||
if ($i++ >= $count)
|
||||
break;
|
||||
$output .= $this->itoa64[($value >> 18) & 0x3f];
|
||||
}
|
||||
while ($i < $count);
|
||||
for ($i = 0; $i < $count; $i += 16)
|
||||
{
|
||||
$this->random_state = md5(microtime() . $this->random_state);
|
||||
$output .= pack('H*', md5($this->random_state));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
$output = substr($output, 0, $count);
|
||||
}
|
||||
|
||||
function gensalt_private($input)
|
||||
{
|
||||
$output = '$P$';
|
||||
$output .= $this->itoa64[min($this->iteration_count_log2 + ((PHP_VERSION >= '5') ? 5 : 3), 30)];
|
||||
$output .= $this->encode64($input, 6);
|
||||
return $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
public function encode64($input, $count)
|
||||
{
|
||||
$output = '';
|
||||
$i = 0;
|
||||
do
|
||||
{
|
||||
$value = ord($input[$i++]);
|
||||
$output .= $this->itoa64[$value & 0x3f];
|
||||
|
||||
function crypt_private($password, $setting)
|
||||
{
|
||||
$output = '*0';
|
||||
if (substr($setting, 0, 2) == $output)
|
||||
$output = '*1';
|
||||
if ($i < $count)
|
||||
{
|
||||
$value |= ord($input[$i]) << 8;
|
||||
}
|
||||
$output .= $this->itoa64[($value >> 6) & 0x3f];
|
||||
|
||||
if (substr($setting, 0, 3) != '$P$')
|
||||
return $output;
|
||||
if ($i++ >= $count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
$count_log2 = strpos($this->itoa64, $setting[3]);
|
||||
if ($count_log2 < 7 || $count_log2 > 30)
|
||||
return $output;
|
||||
if ($i < $count)
|
||||
{
|
||||
$value |= ord($input[$i]) << 16;
|
||||
}
|
||||
$output .= $this->itoa64[($value >> 12) & 0x3f];
|
||||
|
||||
$count = 1 << $count_log2;
|
||||
if ($i++ >= $count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
$output .= $this->itoa64[($value >> 18) & 0x3f];
|
||||
} while ($i < $count);
|
||||
|
||||
$salt = substr($setting, 4, 8);
|
||||
if (strlen($salt) != 8)
|
||||
return $output;
|
||||
return $output;
|
||||
}
|
||||
|
||||
# We're kind of forced to use MD5 here since it's the only
|
||||
# cryptographic primitive available in all versions of PHP
|
||||
# currently in use. To implement our own low-level crypto
|
||||
# in PHP would result in much worse performance and
|
||||
# consequently in lower iteration counts and hashes that are
|
||||
# quicker to crack (by non-PHP code).
|
||||
if (PHP_VERSION >= '5')
|
||||
{
|
||||
$hash = md5($salt . $password, TRUE);
|
||||
do {
|
||||
$hash = md5($hash . $password, TRUE);
|
||||
} while (--$count);
|
||||
}
|
||||
else
|
||||
{
|
||||
$hash = pack('H*', md5($salt . $password));
|
||||
do
|
||||
{
|
||||
$hash = pack('H*', md5($hash . $password));
|
||||
}
|
||||
while (--$count);
|
||||
}
|
||||
public function gensalt_private($input)
|
||||
{
|
||||
$output = '$P$';
|
||||
$output .= $this->itoa64[min($this->iteration_count_log2 + ((PHP_VERSION >= '5') ? 5 : 3), 30)];
|
||||
$output .= $this->encode64($input, 6);
|
||||
|
||||
$output = substr($setting, 0, 12);
|
||||
$output .= $this->encode64($hash, 16);
|
||||
return $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
public function crypt_private($password, $setting)
|
||||
{
|
||||
$output = '*0';
|
||||
|
||||
function gensalt_extended($input)
|
||||
{
|
||||
$count_log2 = min($this->iteration_count_log2 + 8, 24);
|
||||
# This should be odd to not reveal weak DES keys, and the
|
||||
# maximum valid value is (2**24 - 1) which is odd anyway.
|
||||
$count = (1 << $count_log2) - 1;
|
||||
if (substr($setting, 0, 2) == $output)
|
||||
{
|
||||
$output = '*1';
|
||||
}
|
||||
|
||||
$output = '_';
|
||||
$output .= $this->itoa64[$count & 0x3f];
|
||||
$output .= $this->itoa64[($count >> 6) & 0x3f];
|
||||
$output .= $this->itoa64[($count >> 12) & 0x3f];
|
||||
$output .= $this->itoa64[($count >> 18) & 0x3f];
|
||||
if (substr($setting, 0, 3) != '$P$')
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
$output .= $this->encode64($input, 3);
|
||||
$count_log2 = strpos($this->itoa64, $setting[3]);
|
||||
|
||||
return $output;
|
||||
}
|
||||
if ($count_log2 < 7 || $count_log2 > 30)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
function gensalt_blowfish($input)
|
||||
{
|
||||
# This one needs to use a different order of characters and a
|
||||
# different encoding scheme from the one in encode64() above.
|
||||
# We care because the last character in our encoded string will
|
||||
# only represent 2 bits. While two known implementations of
|
||||
# bcrypt will happily accept and correct a salt string which
|
||||
# has the 4 unused bits set to non-zero, we do not want to take
|
||||
# chances and we also do not want to waste an additional byte
|
||||
# of entropy.
|
||||
$itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
$count = 1 << $count_log2;
|
||||
|
||||
$output = '$2a$';
|
||||
$output .= chr(ord('0') + $this->iteration_count_log2 / 10);
|
||||
$output .= chr(ord('0') + $this->iteration_count_log2 % 10);
|
||||
$output .= '$';
|
||||
$salt = substr($setting, 4, 8);
|
||||
|
||||
$i = 0;
|
||||
do
|
||||
{
|
||||
$c1 = ord($input[$i++]);
|
||||
$output .= $itoa64[$c1 >> 2];
|
||||
$c1 = ($c1 & 0x03) << 4;
|
||||
if ($i >= 16)
|
||||
{
|
||||
$output .= $itoa64[$c1];
|
||||
break;
|
||||
}
|
||||
if (strlen($salt) != 8)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
$c2 = ord($input[$i++]);
|
||||
$c1 |= $c2 >> 4;
|
||||
$output .= $itoa64[$c1];
|
||||
$c1 = ($c2 & 0x0f) << 2;
|
||||
// We're kind of forced to use MD5 here since it's the only
|
||||
// cryptographic primitive available in all versions of PHP
|
||||
// currently in use. To implement our own low-level crypto
|
||||
// in PHP would result in much worse performance and
|
||||
// consequently in lower iteration counts and hashes that are
|
||||
// quicker to crack (by non-PHP code).
|
||||
if (PHP_VERSION >= '5')
|
||||
{
|
||||
$hash = md5($salt . $password, true);
|
||||
do
|
||||
{
|
||||
$hash = md5($hash . $password, true);
|
||||
} while (--$count);
|
||||
}
|
||||
else
|
||||
{
|
||||
$hash = pack('H*', md5($salt . $password));
|
||||
do
|
||||
{
|
||||
$hash = pack('H*', md5($hash . $password));
|
||||
} while (--$count);
|
||||
}
|
||||
|
||||
$c2 = ord($input[$i++]);
|
||||
$c1 |= $c2 >> 6;
|
||||
$output .= $itoa64[$c1];
|
||||
$output .= $itoa64[$c2 & 0x3f];
|
||||
}
|
||||
while (1);
|
||||
$output = substr($setting, 0, 12);
|
||||
$output .= $this->encode64($hash, 16);
|
||||
|
||||
return $output;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function HashPassword($password)
|
||||
{
|
||||
$random = '';
|
||||
public function gensalt_extended($input)
|
||||
{
|
||||
$count_log2 = min($this->iteration_count_log2 + 8, 24);
|
||||
// This should be odd to not reveal weak DES keys, and the
|
||||
// maximum valid value is (2**24 - 1) which is odd anyway.
|
||||
$count = (1 << $count_log2) - 1;
|
||||
|
||||
if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes)
|
||||
{
|
||||
$random = $this->get_random_bytes(16);
|
||||
$hash = crypt($password, $this->gensalt_blowfish($random));
|
||||
if (strlen($hash) == 60)
|
||||
return $hash;
|
||||
}
|
||||
$output = '_';
|
||||
$output .= $this->itoa64[$count & 0x3f];
|
||||
$output .= $this->itoa64[($count >> 6) & 0x3f];
|
||||
$output .= $this->itoa64[($count >> 12) & 0x3f];
|
||||
$output .= $this->itoa64[($count >> 18) & 0x3f];
|
||||
|
||||
if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
|
||||
if (strlen($random) < 3)
|
||||
$random = $this->get_random_bytes(3);
|
||||
$hash = crypt($password, $this->gensalt_extended($random));
|
||||
if (strlen($hash) == 20)
|
||||
return $hash;
|
||||
}
|
||||
$output .= $this->encode64($input, 3);
|
||||
|
||||
if (strlen($random) < 6)
|
||||
$random = $this->get_random_bytes(6);
|
||||
$hash =
|
||||
$this->crypt_private($password,
|
||||
$this->gensalt_private($random));
|
||||
if (strlen($hash) == 34)
|
||||
return $hash;
|
||||
return $output;
|
||||
}
|
||||
|
||||
# Returning '*' on error is safe here, but would _not_ be safe
|
||||
# in a crypt(3)-like function used _both_ for generating new
|
||||
# hashes and for validating passwords against existing hashes.
|
||||
return '*';
|
||||
}
|
||||
public function gensalt_blowfish($input)
|
||||
{
|
||||
// This one needs to use a different order of characters and a
|
||||
// different encoding scheme from the one in encode64() above.
|
||||
// We care because the last character in our encoded string will
|
||||
// only represent 2 bits. While two known implementations of
|
||||
// bcrypt will happily accept and correct a salt string which
|
||||
// has the 4 unused bits set to non-zero, we do not want to take
|
||||
// chances and we also do not want to waste an additional byte
|
||||
// of entropy.
|
||||
$itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
|
||||
function CheckPassword($password, $stored_hash)
|
||||
{
|
||||
$hash = $this->crypt_private($password, $stored_hash);
|
||||
if ($hash[0] == '*')
|
||||
$hash = crypt($password, $stored_hash);
|
||||
$output = '$2a$';
|
||||
$output .= chr(ord('0') + $this->iteration_count_log2 / 10);
|
||||
$output .= chr(ord('0') + $this->iteration_count_log2 % 10);
|
||||
$output .= '$';
|
||||
|
||||
return $hash == $stored_hash;
|
||||
}
|
||||
$i = 0;
|
||||
do
|
||||
{
|
||||
$c1 = ord($input[$i++]);
|
||||
$output .= $itoa64[$c1 >> 2];
|
||||
$c1 = ($c1 & 0x03) << 4;
|
||||
|
||||
if ($i >= 16)
|
||||
{
|
||||
$output .= $itoa64[$c1];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$c2 = ord($input[$i++]);
|
||||
$c1 |= $c2 >> 4;
|
||||
$output .= $itoa64[$c1];
|
||||
$c1 = ($c2 & 0x0f) << 2;
|
||||
|
||||
$c2 = ord($input[$i++]);
|
||||
$c1 |= $c2 >> 6;
|
||||
$output .= $itoa64[$c1];
|
||||
$output .= $itoa64[$c2 & 0x3f];
|
||||
} while (1);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function HashPassword($password)
|
||||
{
|
||||
$random = '';
|
||||
|
||||
if (CRYPT_BLOWFISH == 1 && ! $this->portable_hashes)
|
||||
{
|
||||
$random = $this->get_random_bytes(16);
|
||||
$hash = crypt($password, $this->gensalt_blowfish($random));
|
||||
|
||||
if (strlen($hash) == 60)
|
||||
{
|
||||
return $hash;
|
||||
}
|
||||
}
|
||||
|
||||
if (CRYPT_EXT_DES == 1 && ! $this->portable_hashes)
|
||||
{
|
||||
if (strlen($random) < 3)
|
||||
{
|
||||
$random = $this->get_random_bytes(3);
|
||||
}
|
||||
$hash = crypt($password, $this->gensalt_extended($random));
|
||||
|
||||
if (strlen($hash) == 20)
|
||||
{
|
||||
return $hash;
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($random) < 6)
|
||||
{
|
||||
$random = $this->get_random_bytes(6);
|
||||
}
|
||||
$hash =
|
||||
$this->crypt_private($password,
|
||||
$this->gensalt_private($random));
|
||||
|
||||
if (strlen($hash) == 34)
|
||||
{
|
||||
return $hash;
|
||||
}
|
||||
|
||||
// Returning '*' on error is safe here, but would _not_ be safe
|
||||
// in a crypt(3)-like function used _both_ for generating new
|
||||
// hashes and for validating passwords against existing hashes.
|
||||
return '*';
|
||||
}
|
||||
|
||||
public function CheckPassword($password, $stored_hash)
|
||||
{
|
||||
$hash = $this->crypt_private($password, $stored_hash);
|
||||
|
||||
if ($hash[0] == '*')
|
||||
{
|
||||
$hash = crypt($password, $stored_hash);
|
||||
}
|
||||
|
||||
return $hash == $stored_hash;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
*
|
||||
*/
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
# We are in the plugin system, plugins files won't work outside here
|
||||
// We are in the plugin system, plugins files won't work outside here
|
||||
define('IN_PLUGINS_SYSTEM', true);
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@ class Plugins
|
||||
/**
|
||||
* List of loaded plugins
|
||||
*/
|
||||
private $plugins = array();
|
||||
private $plugins = [];
|
||||
|
||||
/**
|
||||
* All hooks from all plugins listed in this variable
|
||||
*/
|
||||
private $all_plugins_hooks = array();
|
||||
private $installed_plugins = array();
|
||||
private $installed_plugins_info = array();
|
||||
private $all_plugins_hooks = [];
|
||||
private $installed_plugins = [];
|
||||
private $installed_plugins_info = [];
|
||||
|
||||
|
||||
private $plugin_path = '';
|
||||
@@ -48,7 +48,7 @@ class Plugins
|
||||
{
|
||||
global $SQL, $dbprefix;
|
||||
|
||||
#if plugins system is turned off, then stop right now!
|
||||
//if plugins system is turned off, then stop right now!
|
||||
if (defined('STOP_PLUGINS'))
|
||||
{
|
||||
return;
|
||||
@@ -57,12 +57,12 @@ class Plugins
|
||||
|
||||
$this->plugin_path = PATH . KLEEJA_PLUGINS_FOLDER;
|
||||
|
||||
# Get installed plugins
|
||||
$query = array(
|
||||
'SELECT' => "plg_name, plg_ver",
|
||||
'FROM' => "{$dbprefix}plugins",
|
||||
'WHERE' => "plg_disabled = 0"
|
||||
);
|
||||
// Get installed plugins
|
||||
$query = [
|
||||
'SELECT' => 'plg_name, plg_ver',
|
||||
'FROM' => "{$dbprefix}plugins",
|
||||
'WHERE' => 'plg_disabled = 0'
|
||||
];
|
||||
|
||||
$result = $SQL->build($query);
|
||||
|
||||
@@ -88,8 +88,7 @@ class Plugins
|
||||
{
|
||||
if (is_dir($this->plugin_path . '/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
|
||||
{
|
||||
|
||||
if (!empty($this->installed_plugins[$folder_name]))
|
||||
if (! empty($this->installed_plugins[$folder_name]))
|
||||
{
|
||||
if ($this->fetch_plugin($folder_name))
|
||||
{
|
||||
@@ -99,18 +98,18 @@ class Plugins
|
||||
}
|
||||
}
|
||||
|
||||
#sort the plugins from high to low priority
|
||||
//sort the plugins from high to low priority
|
||||
krsort($this->plugins);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin information and other things
|
||||
* @param string $plugin_name
|
||||
* @param string $plugin_name
|
||||
* @return bool
|
||||
*/
|
||||
private function fetch_plugin($plugin_name)
|
||||
{
|
||||
#load the plugin
|
||||
//load the plugin
|
||||
@include_once $this->plugin_path . '/' . $plugin_name . '/init.php';
|
||||
|
||||
if (empty($kleeja_plugin))
|
||||
@@ -118,45 +117,47 @@ class Plugins
|
||||
return false;
|
||||
}
|
||||
|
||||
$priority = $kleeja_plugin[$plugin_name]['information']['plugin_priority'];
|
||||
$priority = $kleeja_plugin[$plugin_name]['information']['plugin_priority'];
|
||||
$this->installed_plugins_info[$plugin_name] = $kleeja_plugin[$plugin_name]['information'];
|
||||
|
||||
#bring the real priority of plugin and replace current one
|
||||
//bring the real priority of plugin and replace current one
|
||||
$plugin_current_priority = array_search($plugin_name, $this->plugins);
|
||||
unset($this->plugins[$plugin_current_priority]);
|
||||
$this->plugins[$priority] = $plugin_name;
|
||||
|
||||
//update plugin if current loaded version is > than installed one
|
||||
if ($this->installed_plugins[$plugin_name])
|
||||
{
|
||||
if (version_compare($this->installed_plugins[$plugin_name], $kleeja_plugin[$plugin_name]['information']['plugin_version'], '<'))
|
||||
{
|
||||
if (is_callable($kleeja_plugin[$plugin_name]['update']))
|
||||
{
|
||||
global $SQL, $dbprefix;
|
||||
|
||||
#update plugin
|
||||
//update plugin
|
||||
$kleeja_plugin[$plugin_name]['update']($this->installed_plugins[$plugin_name], $kleeja_plugin[$plugin_name]['information']['plugin_version']);
|
||||
|
||||
#update current plugin version
|
||||
$update_query = array(
|
||||
//update current plugin version
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}plugins",
|
||||
'SET' => "plg_ver='" . $SQL->escape($kleeja_plugin[$plugin_name]['information']['plugin_version']) . "'",
|
||||
'WHERE' => "plg_name='" . $SQL->escape($plugin_name) . "'"
|
||||
);
|
||||
'SET' => "plg_ver='" . $SQL->escape($kleeja_plugin[$plugin_name]['information']['plugin_version']) . "'",
|
||||
'WHERE' => "plg_name='" . $SQL->escape($plugin_name) . "'"
|
||||
];
|
||||
|
||||
|
||||
$SQL->build($update_query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#add plugin hooks to global hooks, depend on its priority
|
||||
if (!empty($kleeja_plugin[$plugin_name]['functions']))
|
||||
//add plugin hooks to global hooks, depend on its priority
|
||||
if (! empty($kleeja_plugin[$plugin_name]['functions']))
|
||||
{
|
||||
foreach ($kleeja_plugin[$plugin_name]['functions'] as $hook_name => $hook_value)
|
||||
{
|
||||
if (empty($this->all_plugins_hooks[$hook_name][$priority]))
|
||||
{
|
||||
$this->all_plugins_hooks[$hook_name][$priority] = array();
|
||||
$this->all_plugins_hooks[$hook_name][$priority] = [];
|
||||
}
|
||||
array_push($this->all_plugins_hooks[$hook_name][$priority], $hook_value);
|
||||
krsort($this->all_plugins_hooks[$hook_name]);
|
||||
@@ -169,12 +170,12 @@ class Plugins
|
||||
|
||||
/**
|
||||
* get an installed plugin information
|
||||
* @param string $plugin_name
|
||||
* @param string $plugin_name
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function installed_plugin_info($plugin_name)
|
||||
{
|
||||
if (!empty($this->installed_plugins_info[$plugin_name]))
|
||||
if (! empty($this->installed_plugins_info[$plugin_name]))
|
||||
{
|
||||
return $this->installed_plugins_info[$plugin_name];
|
||||
}
|
||||
@@ -186,15 +187,15 @@ class Plugins
|
||||
/**
|
||||
* Bring all codes of this hook
|
||||
* This function scattered all over kleeja files
|
||||
* @param string $hook_name
|
||||
* @param array $args
|
||||
* @param string $hook_name
|
||||
* @param array $args
|
||||
* @return array|null
|
||||
*/
|
||||
public function run($hook_name, $args = array())
|
||||
public function run($hook_name, $args = [])
|
||||
{
|
||||
$return_value = $to_be_returned = array();
|
||||
$return_value = $to_be_returned = [];
|
||||
|
||||
if (!empty($this->all_plugins_hooks[$hook_name]))
|
||||
if (! empty($this->all_plugins_hooks[$hook_name]))
|
||||
{
|
||||
foreach ($this->all_plugins_hooks[$hook_name] as $order => $functions)
|
||||
{
|
||||
@@ -204,9 +205,9 @@ class Plugins
|
||||
{
|
||||
$return_value = $function($args);
|
||||
|
||||
if(is_array($return_value))
|
||||
if (is_array($return_value))
|
||||
{
|
||||
$args = array_merge($args, $return_value);
|
||||
$args = array_merge($args, $return_value);
|
||||
$to_be_returned = array_merge($to_be_returned, $return_value);
|
||||
}
|
||||
}
|
||||
@@ -234,15 +235,16 @@ class Plugins
|
||||
* return debug info about plugins system
|
||||
* @return array
|
||||
*/
|
||||
public function getDebugInfo(){
|
||||
if(!defined('DEV_STAGE'))
|
||||
public function getDebugInfo()
|
||||
{
|
||||
if (! defined('DEV_STAGE'))
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'all_plugins_hooks' => $this->all_plugins_hooks,
|
||||
'installed_plugins' => $this->installed_plugins,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,25 +8,25 @@
|
||||
*/
|
||||
|
||||
|
||||
#no direct access
|
||||
if (!defined('IN_COMMON'))
|
||||
//no direct access
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class kleeja_style
|
||||
{
|
||||
protected $vars; #Reference to $GLOBALS
|
||||
protected $loop = array();
|
||||
protected $reg = array('var' => '/([{]{1,2})+([A-Z0-9_\.]+)[}]{1,2}/i');
|
||||
public $caching = true; #save templates as caches to not compiled a lot of times
|
||||
protected $vars; //Reference to $GLOBALS
|
||||
protected $loop = [];
|
||||
protected $reg = ['var' => '/([{]{1,2})+([A-Z0-9_\.]+)[}]{1,2}/i'];
|
||||
public $caching = true; //save templates as caches to not compiled a lot of times
|
||||
|
||||
/**
|
||||
* check if caching is not enabled and empty style cache files
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
if(! $this->caching)
|
||||
if (! $this->caching)
|
||||
{
|
||||
delete_cache(null, true);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class kleeja_style
|
||||
global $config, $THIS_STYLE_PATH_ABS, $STYLE_PATH_ADMIN_ABS, $DEFAULT_PATH_ADMIN_ABS;
|
||||
|
||||
|
||||
if (!($template_path = $this->template_exists($template_name, $style_path)))
|
||||
if (! ($template_path = $this->template_exists($template_name, $style_path)))
|
||||
{
|
||||
big_error('No Template !', 'Requested <b>"' . $template_name . '"</b> template doesnt exist!');
|
||||
}
|
||||
@@ -79,12 +79,12 @@ class kleeja_style
|
||||
//admin template always begin with admin_
|
||||
if (substr($template_name, 0, 6) == 'admin_')
|
||||
{
|
||||
$current_style_path = !empty($style_path) ? $style_path : $STYLE_PATH_ADMIN_ABS;
|
||||
$is_admin_template = true;
|
||||
$current_style_path = ! empty($style_path) ? $style_path : $STYLE_PATH_ADMIN_ABS;
|
||||
$is_admin_template = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$current_style_path = !empty($style_path) ? $style_path : $THIS_STYLE_PATH_ABS;
|
||||
$current_style_path = ! empty($style_path) ? $style_path : $THIS_STYLE_PATH_ABS;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,29 +95,31 @@ class kleeja_style
|
||||
$is_tpl_exist = file_exists($template_path);
|
||||
|
||||
|
||||
if (!$is_tpl_exist)
|
||||
if (! $is_tpl_exist)
|
||||
{
|
||||
if (trim($config['style_depend_on']) != '')
|
||||
{
|
||||
$template_path_alternative = str_replace('/' . $config['style'] . '/', '/' . $config['style_depend_on'] . '/', $template_path);
|
||||
|
||||
if (file_exists($template_path_alternative))
|
||||
{
|
||||
$template_path = $template_path_alternative;
|
||||
$is_tpl_exist = true;
|
||||
$is_tpl_exist = true;
|
||||
}
|
||||
}
|
||||
else if ($is_admin_template)
|
||||
elseif ($is_admin_template)
|
||||
{
|
||||
$template_path = $DEFAULT_PATH_ADMIN_ABS . $template_name . '.html';
|
||||
$is_tpl_exist = true;
|
||||
$is_tpl_exist = true;
|
||||
}
|
||||
else if ($config['style'] != 'default' && !$is_admin_template)
|
||||
elseif ($config['style'] != 'default' && ! $is_admin_template)
|
||||
{
|
||||
$template_path_alternative = str_replace('/' . $config['style'] . '/', '/default/', $template_path);
|
||||
|
||||
if (file_exists($template_path_alternative))
|
||||
{
|
||||
$template_path = $template_path_alternative;
|
||||
$is_tpl_exist = true;
|
||||
$is_tpl_exist = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,26 +134,26 @@ class kleeja_style
|
||||
{
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('style_parse_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
$html = preg_replace(array('#<([\?%])=?.*?\1>#s', '#<script\s+language\s*=\s*(["\']?)php\1\s*>.*?</script\s*>#s', '#<\?php(?:\r\n?|[ \n\t]).*?\?>#s'), '', $html);
|
||||
$html = preg_replace_callback('/\(([{A-Z0-9_\.}\s!=<>]+)\?(.*):(.*)\)/iU', array('kleeja_style', '_iif_callback'), $html);
|
||||
$html = preg_replace_callback('/<(IF|ELSEIF|UNLESS) (.+)>/iU', array('kleeja_style', '_if_callback'), $html);
|
||||
$html = preg_replace_callback('/<LOOP\s+NAME\s*=\s*(\"|)+([a-z0-9_\.]{1,})+(\"|)\s*>/i', array('kleeja_style', '_loop_callback'), $html);
|
||||
$html = preg_replace_callback(kleeja_style::reg('var'), array('kleeja_style', '_vars_callback'), $html);
|
||||
$html = preg_replace(['#<([\?%])=?.*?\1>#s', '#<script\s+language\s*=\s*(["\']?)php\1\s*>.*?</script\s*>#s', '#<\?php(?:\r\n?|[ \n\t]).*?\?>#s'], '', $html);
|
||||
$html = preg_replace_callback('/\(([{A-Z0-9_\.}\s!=<>]+)\?(.*):(.*)\)/iU', ['kleeja_style', '_iif_callback'], $html);
|
||||
$html = preg_replace_callback('/<(IF|ELSEIF|UNLESS) (.+)>/iU', ['kleeja_style', '_if_callback'], $html);
|
||||
$html = preg_replace_callback('/<LOOP\s+NAME\s*=\s*(\"|)+([a-z0-9_\.]{1,})+(\"|)\s*>/i', ['kleeja_style', '_loop_callback'], $html);
|
||||
$html = preg_replace_callback(kleeja_style::reg('var'), ['kleeja_style', '_vars_callback'], $html);
|
||||
|
||||
$rep = array
|
||||
(
|
||||
'/<\/(LOOP|IF|END|IS_BROWSER|UNLESS)>/i' => "<?php } ?>",
|
||||
'/<INCLUDE(\s+NAME|)\s*=*\s*"(.+)"\s*>/iU' => '<?php echo $this->display("\\2"); ?>',
|
||||
'/<IS_BROWSER\s*=\s*"([a-z0-9,]+)"\s*>/iU' => '<?php if(is_browser("\\1")){ ?>',
|
||||
'/<IS_BROWSER\s*\!=\s*"([a-z0-9,]+)"\s*>/iU' => '<?php if(!is_browser("\\1")){ ?>',
|
||||
'/(<ELSE>|<ELSE\s?\/>)/i' => '<?php }else{ ?>',
|
||||
'/<ODD\s*=\s*"([a-zA-Z0-9_\-\+\.\/]+)"\s*>(.*?)<\/ODD\>/is' => "<?php if(intval(\$value['\\1'])%2){?> \\2 <?php } ?>",
|
||||
$rep =
|
||||
[
|
||||
'/<\/(LOOP|IF|END|IS_BROWSER|UNLESS)>/i' => '<?php } ?>',
|
||||
'/<INCLUDE(\s+NAME|)\s*=*\s*"(.+)"\s*>/iU' => '<?php echo $this->display("\\2"); ?>',
|
||||
'/<IS_BROWSER\s*=\s*"([a-z0-9,]+)"\s*>/iU' => '<?php if(is_browser("\\1")){ ?>',
|
||||
'/<IS_BROWSER\s*\!=\s*"([a-z0-9,]+)"\s*>/iU' => '<?php if(!is_browser("\\1")){ ?>',
|
||||
'/(<ELSE>|<ELSE\s?\/>)/i' => '<?php }else{ ?>',
|
||||
'/<ODD\s*=\s*"([a-zA-Z0-9_\-\+\.\/]+)"\s*>(.*?)<\/ODD\>/is' => "<?php if(intval(\$value['\\1'])%2){?> \\2 <?php } ?>",
|
||||
'/<EVEN\s*=\s*"([a-zA-Z0-9_\-\+\.\/]+)"\s*>(.*?)<\/EVEN>/is' => "<?php if(intval(\$value['\\1'])% 2 == 0){?> \\2 <?php } ?>",
|
||||
'/<RAND\s*=\s*"(.*?)\"\s*,\s*"(.*?)"\s*>/is' => "<?php \$KLEEJA_tpl_rand_is=(!isset(\$KLEEJA_tpl_rand_is) || \$KLEEJA_tpl_rand_is==0)?1:0; print((\$KLEEJA_tpl_rand_is==1) ?'\\1':'\\2'); ?>",
|
||||
'/\{%(key|value)%\}/i' => '<?php echo $\\1; ?>',
|
||||
);
|
||||
'/<RAND\s*=\s*"(.*?)\"\s*,\s*"(.*?)"\s*>/is' => "<?php \$KLEEJA_tpl_rand_is=(!isset(\$KLEEJA_tpl_rand_is) || \$KLEEJA_tpl_rand_is==0)?1:0; print((\$KLEEJA_tpl_rand_is==1) ?'\\1':'\\2'); ?>",
|
||||
'/\{%(key|value)%\}/i' => '<?php echo $\\1; ?>',
|
||||
];
|
||||
|
||||
return preg_replace(array_keys($rep), array_values($rep), $html);
|
||||
return preg_replace(array_keys($rep), array_values($rep), $html);
|
||||
}
|
||||
|
||||
|
||||
@@ -174,13 +176,14 @@ class kleeja_style
|
||||
*/
|
||||
protected function _if_callback($matches)
|
||||
{
|
||||
$atts = call_user_func(array('kleeja_style', '_get_attributes'), $matches[0]);
|
||||
$atts = call_user_func(['kleeja_style', '_get_attributes'], $matches[0]);
|
||||
$condition = '';
|
||||
foreach(['NAME' => '', 'LOOP' => '', 'AND' => ' && ', 'OR' => ' || '] as $attribute=>$separator)
|
||||
|
||||
foreach (['NAME' => '', 'LOOP' => '', 'AND' => ' && ', 'OR' => ' || '] as $attribute=>$separator)
|
||||
{
|
||||
if(! empty($atts[$attribute]))
|
||||
if (! empty($atts[$attribute]))
|
||||
{
|
||||
$condition .= $separator . $this->parse_condition($atts[$attribute], !empty($atts['LOOP']));
|
||||
$condition .= $separator . $this->parse_condition($atts[$attribute], ! empty($atts['LOOP']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,25 +205,29 @@ class kleeja_style
|
||||
|
||||
protected function parse_condition($condition, $is_loop)
|
||||
{
|
||||
$char = array(' eq ', ' lt ', ' gt ', ' lte ', ' gte ', ' neq ', '==', '!=', '>=', '<=', '<', '>');
|
||||
$reps = array('==', '<', '>', '<=', '>=', '!=', '==', '!=', '>=', '<=', '<', '>');
|
||||
$char = [' eq ', ' lt ', ' gt ', ' lte ', ' gte ', ' neq ', '==', '!=', '>=', '<=', '<', '>'];
|
||||
$reps = ['==', '<', '>', '<=', '>=', '!=', '==', '!=', '>=', '<=', '<', '>'];
|
||||
|
||||
$con = str_replace('$this->vars', '[----this-vars----]', $condition);
|
||||
|
||||
if (preg_match('/(.*)(' . implode('|', $char) . ')(.*)/i', $con, $arr)) {
|
||||
if (preg_match('/(.*)(' . implode('|', $char) . ')(.*)/i', $con, $arr))
|
||||
{
|
||||
$arr[1] = trim($arr[1]);
|
||||
$var1 = $arr[1][0] != '$' ? call_user_func(array('kleeja_style', '_var_callback'), (! $is_loop ? '{' . $arr[1] . '}' : '{{' . $arr[1] . '}}')) : $arr[1];
|
||||
$opr = str_replace($char, $reps, $arr[2]);
|
||||
$var2 = trim($arr[3]);
|
||||
$var1 = $arr[1][0] != '$' ? call_user_func(['kleeja_style', '_var_callback'], (! $is_loop ? '{' . $arr[1] . '}' : '{{' . $arr[1] . '}}')) : $arr[1];
|
||||
$opr = str_replace($char, $reps, $arr[2]);
|
||||
$var2 = trim($arr[3]);
|
||||
|
||||
#check for type
|
||||
if ($var2[0] != '$' && !preg_match('/[0-9]/', $var2)) {
|
||||
//check for type
|
||||
if ($var2[0] != '$' && ! preg_match('/[0-9]/', $var2))
|
||||
{
|
||||
$var2 = '"' . str_replace('"', '\"', $var2) . '"';
|
||||
}
|
||||
|
||||
$con = "$var1 $opr $var2";
|
||||
} elseif ($con[0] !== '$' && strpos($con, '(') === false) {
|
||||
$con = call_user_func(array('kleeja_style', '_var_callback'), (!$is_loop ? '{' . $con . '}' : '{{' . $con . '}}'));
|
||||
}
|
||||
elseif ($con[0] !== '$' && strpos($con, '(') === false)
|
||||
{
|
||||
$con = call_user_func(['kleeja_style', '_var_callback'], (! $is_loop ? '{' . $con . '}' : '{{' . $con . '}}'));
|
||||
}
|
||||
|
||||
return str_replace('[----this-vars----]', '$this->vars', $con);
|
||||
@@ -234,9 +241,9 @@ class kleeja_style
|
||||
*/
|
||||
protected function _vars_callback($matches)
|
||||
{
|
||||
$variable = call_user_func(array('kleeja_style', '_var_callback'), $matches);
|
||||
$variable = call_user_func(['kleeja_style', '_var_callback'], $matches);
|
||||
|
||||
if(strpos($matches[0], '{lang') !== false || strpos($matches[0], '{olang') !== false)
|
||||
if (strpos($matches[0], '{lang') !== false || strpos($matches[0], '{olang') !== false)
|
||||
{
|
||||
return '<?=isset(' . $variable . ') ? ' . $variable . ' : \'' . $matches[0] . '\'?>';
|
||||
}
|
||||
@@ -252,13 +259,13 @@ class kleeja_style
|
||||
*/
|
||||
protected function _var_callback($matches)
|
||||
{
|
||||
if (!is_array($matches))
|
||||
if (! is_array($matches))
|
||||
{
|
||||
preg_match(kleeja_style::reg('var'), $matches, $matches);
|
||||
}
|
||||
|
||||
$var = !empty($matches[2]) ? str_replace('.', '\'][\'', $matches[2]) : '';
|
||||
return (!empty($matches[1]) && trim($matches[1]) == '{{') ? '$value[\'' . $var . '\']' : '$this->vars[\'' . $var . '\']';
|
||||
$var = ! empty($matches[2]) ? str_replace('.', '\'][\'', $matches[2]) : '';
|
||||
return (! empty($matches[1]) && trim($matches[1]) == '{{') ? '$value[\'' . $var . '\']' : '$this->vars[\'' . $var . '\']';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,7 +300,7 @@ class kleeja_style
|
||||
{
|
||||
preg_match_all('/([a-z]+)="(.+)"/iU', $tag, $attribute);
|
||||
|
||||
$attributes = array();
|
||||
$attributes = [];
|
||||
|
||||
for ($i = 0; $i < count($attribute[1]); $i++)
|
||||
{
|
||||
@@ -301,11 +308,11 @@ class kleeja_style
|
||||
|
||||
if (preg_match('/NAME|LOOP/', $att))
|
||||
{
|
||||
$attributes[$att] = preg_replace_callback(kleeja_style::reg('var'), array('kleeja_style', '_var_callback'), $attribute[2][$i]);
|
||||
$attributes[$att] = preg_replace_callback(kleeja_style::reg('var'), ['kleeja_style', '_var_callback'], $attribute[2][$i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes[$att] = preg_replace_callback(kleeja_style::reg('var'), array('kleeja_style', '_var_callback_att'), $attribute[2][$i]);
|
||||
$attributes[$att] = preg_replace_callback(kleeja_style::reg('var'), ['kleeja_style', '_var_callback_att'], $attribute[2][$i]);
|
||||
}
|
||||
}
|
||||
return $attributes;
|
||||
@@ -325,7 +332,7 @@ class kleeja_style
|
||||
/**
|
||||
* load parser and return page content
|
||||
* @param $template_name
|
||||
* @param null $style_path optional, good for plugins
|
||||
* @param null $style_path optional, good for plugins
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function display($template_name, $style_path = null)
|
||||
@@ -335,13 +342,13 @@ class kleeja_style
|
||||
$this->vars = &$GLOBALS;
|
||||
|
||||
//is there ?
|
||||
if (!file_exists(PATH . 'cache/tpl_' . $this->re_name_tpl($template_name, $style_path) . '.php') || !$this->caching)
|
||||
if (! file_exists(PATH . 'cache/tpl_' . $this->re_name_tpl($template_name, $style_path) . '.php') || ! $this->caching)
|
||||
{
|
||||
$this->_load_template($template_name, $style_path);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
include(PATH . 'cache/tpl_' . $this->re_name_tpl($template_name, $style_path) . '.php');
|
||||
include PATH . 'cache/tpl_' . $this->re_name_tpl($template_name, $style_path) . '.php';
|
||||
$page = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
@@ -372,7 +379,7 @@ class kleeja_style
|
||||
*/
|
||||
protected function re_name_tpl($name, $style_path = null)
|
||||
{
|
||||
return preg_replace("/[^a-z0-9-_]/", "-", strtolower($name)) .
|
||||
(!empty($style_path) ? md5($style_path) : '');
|
||||
return preg_replace('/[^a-z0-9-_]/', '-', strtolower($name)) .
|
||||
(! empty($style_path) ? md5($style_path) : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,154 +7,156 @@
|
||||
// Version: 07.02.2010
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
class BMP
|
||||
{
|
||||
public static function imagebmp(&$img, $filename = false)
|
||||
{
|
||||
return imagebmp($img, $filename);
|
||||
}
|
||||
|
||||
public static function imagecreatefrombmp($filename)
|
||||
{
|
||||
return imagecreatefrombmp($filename);
|
||||
}
|
||||
public static function imagebmp(&$img, $filename = false)
|
||||
{
|
||||
return imagebmp($img, $filename);
|
||||
}
|
||||
|
||||
public static function imagecreatefrombmp($filename)
|
||||
{
|
||||
return imagecreatefrombmp($filename);
|
||||
}
|
||||
}
|
||||
|
||||
function imagebmp(&$img, $filename = false)
|
||||
{
|
||||
$wid = imagesx($img);
|
||||
$hei = imagesy($img);
|
||||
$wid_pad = str_pad('', $wid % 4, "\0");
|
||||
|
||||
$size = 54 + ($wid + $wid_pad) * $hei;
|
||||
|
||||
//prepare & save header
|
||||
$header['identifier'] = 'BM';
|
||||
$header['file_size'] = dword($size);
|
||||
$header['reserved'] = dword(0);
|
||||
$header['bitmap_data'] = dword(54);
|
||||
$header['header_size'] = dword(40);
|
||||
$header['width'] = dword($wid);
|
||||
$header['height'] = dword($hei);
|
||||
$header['planes'] = word(1);
|
||||
$header['bits_per_pixel'] = word(24);
|
||||
$header['compression'] = dword(0);
|
||||
$header['data_size'] = dword(0);
|
||||
$header['h_resolution'] = dword(0);
|
||||
$header['v_resolution'] = dword(0);
|
||||
$header['colors'] = dword(0);
|
||||
$header['important_colors'] = dword(0);
|
||||
$wid = imagesx($img);
|
||||
$hei = imagesy($img);
|
||||
$wid_pad = str_pad('', $wid % 4, "\0");
|
||||
|
||||
if ($filename)
|
||||
{
|
||||
$f = fopen($filename, "wb");
|
||||
foreach ($header AS $h)
|
||||
{
|
||||
fwrite($f, $h);
|
||||
}
|
||||
|
||||
//save pixels
|
||||
for ($y=$hei-1; $y>=0; $y--)
|
||||
{
|
||||
for ($x=0; $x<$wid; $x++)
|
||||
{
|
||||
$rgb = imagecolorat($img, $x, $y);
|
||||
fwrite($f, byte3($rgb));
|
||||
}
|
||||
fwrite($f, $wid_pad);
|
||||
}
|
||||
fclose($f);
|
||||
$size = 54 + ($wid + $wid_pad) * $hei;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($header AS $h)
|
||||
{
|
||||
echo $h;
|
||||
}
|
||||
|
||||
//save pixels
|
||||
for ($y=$hei-1; $y>=0; $y--)
|
||||
{
|
||||
for ($x=0; $x<$wid; $x++)
|
||||
{
|
||||
$rgb = imagecolorat($img, $x, $y);
|
||||
echo byte3($rgb);
|
||||
}
|
||||
echo $wid_pad;
|
||||
}
|
||||
//prepare & save header
|
||||
$header['identifier'] = 'BM';
|
||||
$header['file_size'] = dword($size);
|
||||
$header['reserved'] = dword(0);
|
||||
$header['bitmap_data'] = dword(54);
|
||||
$header['header_size'] = dword(40);
|
||||
$header['width'] = dword($wid);
|
||||
$header['height'] = dword($hei);
|
||||
$header['planes'] = word(1);
|
||||
$header['bits_per_pixel'] = word(24);
|
||||
$header['compression'] = dword(0);
|
||||
$header['data_size'] = dword(0);
|
||||
$header['h_resolution'] = dword(0);
|
||||
$header['v_resolution'] = dword(0);
|
||||
$header['colors'] = dword(0);
|
||||
$header['important_colors'] = dword(0);
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($filename)
|
||||
{
|
||||
$f = fopen($filename, 'wb');
|
||||
|
||||
foreach ($header AS $h)
|
||||
{
|
||||
fwrite($f, $h);
|
||||
}
|
||||
|
||||
//save pixels
|
||||
for ($y=$hei-1; $y>=0; $y--)
|
||||
{
|
||||
for ($x=0; $x<$wid; $x++)
|
||||
{
|
||||
$rgb = imagecolorat($img, $x, $y);
|
||||
fwrite($f, byte3($rgb));
|
||||
}
|
||||
fwrite($f, $wid_pad);
|
||||
}
|
||||
fclose($f);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($header AS $h)
|
||||
{
|
||||
echo $h;
|
||||
}
|
||||
|
||||
//save pixels
|
||||
for ($y=$hei-1; $y>=0; $y--)
|
||||
{
|
||||
for ($x=0; $x<$wid; $x++)
|
||||
{
|
||||
$rgb = imagecolorat($img, $x, $y);
|
||||
echo byte3($rgb);
|
||||
}
|
||||
echo $wid_pad;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function imagecreatefrombmp($filename)
|
||||
{
|
||||
$f = fopen($filename, "rb");
|
||||
$f = fopen($filename, 'rb');
|
||||
|
||||
//read header
|
||||
//read header
|
||||
$header = fread($f, 54);
|
||||
$header = unpack( 'c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' .
|
||||
'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/'.
|
||||
'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header);
|
||||
'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/' .
|
||||
'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header);
|
||||
|
||||
if ($header['identifier1'] != 66 or $header['identifier2'] != 77)
|
||||
{
|
||||
//die('Not a valid bmp file');
|
||||
return false;
|
||||
//die('Not a valid bmp file');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ($header['bits_per_pixel'] != 24)
|
||||
{
|
||||
//die('Only 24bit BMP images are supported');
|
||||
return false;
|
||||
//die('Only 24bit BMP images are supported');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$wid2 = ceil((3*$header['width']) / 4) * 4;
|
||||
|
||||
|
||||
$wid = $header['width'];
|
||||
$hei = $header['height'];
|
||||
|
||||
$img = imagecreatetruecolor($header['width'], $header['height']);
|
||||
|
||||
//read pixels
|
||||
//read pixels
|
||||
for ($y=$hei-1; $y>=0; $y--)
|
||||
{
|
||||
$row = fread($f, $wid2);
|
||||
$pixels = str_split($row, 3);
|
||||
for ($x=0; $x<$wid; $x++)
|
||||
{
|
||||
imagesetpixel($img, $x, $y, dwordize($pixels[$x]));
|
||||
}
|
||||
$row = fread($f, $wid2);
|
||||
$pixels = str_split($row, 3);
|
||||
|
||||
for ($x=0; $x<$wid; $x++)
|
||||
{
|
||||
imagesetpixel($img, $x, $y, dwordize($pixels[$x]));
|
||||
}
|
||||
}
|
||||
fclose($f);
|
||||
|
||||
return $img;
|
||||
fclose($f);
|
||||
|
||||
return $img;
|
||||
}
|
||||
|
||||
function dwordize($str)
|
||||
{
|
||||
$a = ord($str[0]);
|
||||
$b = ord($str[1]);
|
||||
$c = ord($str[2]);
|
||||
return $c*256*256 + $b*256 + $a;
|
||||
$a = ord($str[0]);
|
||||
$b = ord($str[1]);
|
||||
$c = ord($str[2]);
|
||||
return $c*256*256 + $b*256 + $a;
|
||||
}
|
||||
|
||||
function byte3($n)
|
||||
{
|
||||
return chr($n & 255) . chr(($n >> 8) & 255) . chr(($n >> 16) & 255);
|
||||
return chr($n & 255) . chr(($n >> 8) & 255) . chr(($n >> 16) & 255);
|
||||
}
|
||||
function dword($n)
|
||||
{
|
||||
return pack("V", $n);
|
||||
return pack('V', $n);
|
||||
}
|
||||
function word($n)
|
||||
{
|
||||
return pack("v", $n);
|
||||
return pack('v', $n);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
*/
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,29 +21,29 @@ if (!defined('IN_COMMON'))
|
||||
*/
|
||||
function ext_check_safe($filename)
|
||||
{
|
||||
#bad files extensions
|
||||
$not_allowed = array('php', 'php3' ,'php5', 'php4', 'asp' ,'shtml' , 'html' ,'htm' ,'xhtml' ,'phtml', 'pl', 'cgi', 'htaccess', 'ini');
|
||||
|
||||
#let split the file name, suppose it filename.gif.php
|
||||
$tmp = explode(".", $filename);
|
||||
//bad files extensions
|
||||
$not_allowed = ['php', 'php3' ,'php5', 'php4', 'asp' ,'shtml' , 'html' ,'htm' ,'xhtml' ,'phtml', 'pl', 'cgi', 'htaccess', 'ini'];
|
||||
|
||||
#if it's less than 3, that its means normal
|
||||
if(sizeof($tmp) < 3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//let split the file name, suppose it filename.gif.php
|
||||
$tmp = explode('.', $filename);
|
||||
|
||||
$before_last_ext = $tmp[sizeof($tmp)-2];
|
||||
//if it's less than 3, that its means normal
|
||||
if (sizeof($tmp) < 3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#in the bad extenion, return false to tell him
|
||||
if (in_array(strtolower($before_last_ext), $not_allowed))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
$before_last_ext = $tmp[sizeof($tmp)-2];
|
||||
|
||||
//in the bad extenion, return false to tell him
|
||||
if (in_array(strtolower($before_last_ext), $not_allowed))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,35 +57,34 @@ function generate_safety_htaccess($folder)
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('generate_safety_htaccess_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
if($return)
|
||||
if ($return)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#data for the htaccess
|
||||
$htaccess_data = "<Files ~ \"^.*\.(php|php*|cgi|pl|phtml|shtml|sql|asp|aspx)\">\nOrder allow,deny\nDeny from all\n</Files>\n<IfModule mod_php4.c>\nphp_flag engine off\n</IfModule>\n<IfModule mod_php5.c>\nphp_flag engine off\n</IfModule>\nRemoveType .php .php* .phtml .pl .cgi .asp .aspx .sql";
|
||||
|
||||
#generate the htaccess
|
||||
$fi = @fopen($folder . "/.htaccess", "w");
|
||||
$fi2 = @fopen($folder . "/thumbs/.htaccess","w");
|
||||
@fwrite($fi, $htaccess_data);
|
||||
@fwrite($fi2, $htaccess_data);
|
||||
//data for the htaccess
|
||||
$htaccess_data = "<Files ~ \"^.*\.(php|php*|cgi|pl|phtml|shtml|sql|asp|aspx)\">\nOrder allow,deny\nDeny from all\n</Files>\n<IfModule mod_php4.c>\nphp_flag engine off\n</IfModule>\n<IfModule mod_php5.c>\nphp_flag engine off\n</IfModule>\nRemoveType .php .php* .phtml .pl .cgi .asp .aspx .sql";
|
||||
|
||||
//generate the htaccess
|
||||
$fi = @fopen($folder . '/.htaccess', 'w');
|
||||
$fi2 = @fopen($folder . '/thumbs/.htaccess', 'w');
|
||||
@fwrite($fi, $htaccess_data);
|
||||
@fwrite($fi2, $htaccess_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* create an uploading folder
|
||||
* @param string $folder
|
||||
* @param string $folder
|
||||
* @return bool
|
||||
*/
|
||||
function make_folder($folder)
|
||||
{
|
||||
|
||||
$return = false;
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('make_folder_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
if($return)
|
||||
if ($return)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -95,23 +94,24 @@ function make_folder($folder)
|
||||
|
||||
|
||||
$path = '';
|
||||
|
||||
foreach ($folders as $sub_folder)
|
||||
{
|
||||
#try to make a new upload folder
|
||||
//try to make a new upload folder
|
||||
@mkdir($path . $sub_folder);
|
||||
@mkdir($path . $sub_folder . '/thumbs');
|
||||
|
||||
|
||||
#then try to chmod it to 0755
|
||||
//then try to chmod it to 0755
|
||||
@chmod($path . $sub_folder, 0755);
|
||||
@chmod($path . $sub_folder . '/thumbs/', 0755);
|
||||
|
||||
#make it safe
|
||||
//make it safe
|
||||
generate_safety_htaccess($path . $sub_folder);
|
||||
|
||||
#create empty index so nobody can see the contents
|
||||
$fo = @fopen($path . $sub_folder . "/index.html", "w");
|
||||
$fo2 = @fopen($path . $sub_folder . "/thumbs/index.html", "w");
|
||||
//create empty index so nobody can see the contents
|
||||
$fo = @fopen($path . $sub_folder . '/index.html', 'w');
|
||||
$fo2 = @fopen($path . $sub_folder . '/thumbs/index.html', 'w');
|
||||
@fwrite($fo, '<a href="http://kleeja.com"><p>KLEEJA ..</p></a>');
|
||||
@fwrite($fo2, '<a href="http://kleeja.com"><p>KLEEJA ..</p></a>');
|
||||
|
||||
@@ -128,42 +128,42 @@ function change_filename_decoding($filename, $i_loop, $ext, $decoding_type = '')
|
||||
{
|
||||
global $config;
|
||||
|
||||
$return = '';
|
||||
$return = '';
|
||||
|
||||
$decoding_type = empty($decoding_type) ? $config['decode'] : $decoding_type;
|
||||
|
||||
|
||||
#change it, time..
|
||||
if($decoding_type == "time" || $decoding_type == 1)
|
||||
{
|
||||
list($usec, $sec) = explode(" ", microtime());
|
||||
$extra = str_replace('.', '', (float)$usec + (float)$sec);
|
||||
$return = $extra . $i_loop . '.' . $ext;
|
||||
}
|
||||
# md5
|
||||
elseif($decoding_type == "md5" || $decoding_type == 2)
|
||||
{
|
||||
list($usec, $sec) = explode(" ", microtime());
|
||||
$extra = md5(((float)$usec + (float)$sec) . $filename);
|
||||
$extra = substr($extra, 0, 12);
|
||||
$return = $extra . $i_loop . "." . $ext;
|
||||
}
|
||||
# exists before, change it a little
|
||||
elseif($decoding_type == 'exists')
|
||||
{
|
||||
$return = substr($filename, 0, -(strlen($ext)+1)) . '_' . substr(md5( microtime(true) . $i_loop), rand(0, 20), 5) . '.' . $ext;
|
||||
}
|
||||
#nothing
|
||||
else
|
||||
{
|
||||
$filename = substr($filename, 0, -(strlen($ext)+1));
|
||||
$return = preg_replace('/[,.?\/*&^\\\$%#@()_!|"\~\'><=+}{; ]/', '-', $filename) . '.' . $ext;
|
||||
$return = preg_replace('/-+/', '-', $return);
|
||||
}
|
||||
//change it, time..
|
||||
if ($decoding_type == 'time' || $decoding_type == 1)
|
||||
{
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
$extra = str_replace('.', '', (float) $usec + (float) $sec);
|
||||
$return = $extra . $i_loop . '.' . $ext;
|
||||
}
|
||||
// md5
|
||||
elseif ($decoding_type == 'md5' || $decoding_type == 2)
|
||||
{
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
$extra = md5(((float) $usec + (float) $sec) . $filename);
|
||||
$extra = substr($extra, 0, 12);
|
||||
$return = $extra . $i_loop . '.' . $ext;
|
||||
}
|
||||
// exists before, change it a little
|
||||
elseif ($decoding_type == 'exists')
|
||||
{
|
||||
$return = substr($filename, 0, -(strlen($ext)+1)) . '_' . substr(md5( microtime(true) . $i_loop), rand(0, 20), 5) . '.' . $ext;
|
||||
}
|
||||
//nothing
|
||||
else
|
||||
{
|
||||
$filename = substr($filename, 0, -(strlen($ext)+1));
|
||||
$return = preg_replace('/[,.?\/*&^\\\$%#@()_!|"\~\'><=+}{; ]/', '-', $filename) . '.' . $ext;
|
||||
$return = preg_replace('/-+/', '-', $return);
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('change_filename_decoding_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
return $return;
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,21 +171,21 @@ function change_filename_decoding($filename, $i_loop, $ext, $decoding_type = '')
|
||||
*/
|
||||
function change_filename_templates($filename)
|
||||
{
|
||||
#random number...
|
||||
if (preg_match("/{rand:([0-9]+)}/i", $filename, $m))
|
||||
{
|
||||
$filename = preg_replace("/{rand:([0-9]+)}/i", substr(md5(time()), 0, $m[1]), $filename);
|
||||
}
|
||||
|
||||
#current date
|
||||
if (preg_match("/{date:([a-zA-Z-_]+)}/i", $filename, $m))
|
||||
{
|
||||
$filename = preg_replace("/{date:([a-zA-Z-_]+)}/i", date($m[1]), $filename);
|
||||
}
|
||||
//random number...
|
||||
if (preg_match('/{rand:([0-9]+)}/i', $filename, $m))
|
||||
{
|
||||
$filename = preg_replace('/{rand:([0-9]+)}/i', substr(md5(time()), 0, $m[1]), $filename);
|
||||
}
|
||||
|
||||
//current date
|
||||
if (preg_match('/{date:([a-zA-Z-_]+)}/i', $filename, $m))
|
||||
{
|
||||
$filename = preg_replace('/{date:([a-zA-Z-_]+)}/i', date($m[1]), $filename);
|
||||
}
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('change_filename_templates_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
return $filename;
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,12 +194,11 @@ function change_filename_templates($filename)
|
||||
*/
|
||||
function check_mime_type($given_file_mime, $file_ext, $file_path)
|
||||
{
|
||||
|
||||
$return = '';
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('kleeja_check_mime_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
if($return !== '')
|
||||
if ($return !== '')
|
||||
{
|
||||
return $return;
|
||||
}
|
||||
@@ -207,7 +206,7 @@ function check_mime_type($given_file_mime, $file_ext, $file_path)
|
||||
|
||||
$mime = '';
|
||||
|
||||
if(function_exists('finfo_open') || function_exists('mime_content_type'))
|
||||
if (function_exists('finfo_open') || function_exists('mime_content_type'))
|
||||
{
|
||||
if (function_exists('mime_content_type'))
|
||||
{
|
||||
@@ -216,19 +215,19 @@ function check_mime_type($given_file_mime, $file_ext, $file_path)
|
||||
else
|
||||
{
|
||||
$f_info = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mime = finfo_file($f_info, $file_path);
|
||||
$mime = finfo_file($f_info, $file_path);
|
||||
finfo_close($f_info);
|
||||
}
|
||||
}
|
||||
else if(!empty($given_file_mime))
|
||||
elseif (! empty($given_file_mime))
|
||||
{
|
||||
$mime = $given_file_mime;
|
||||
}
|
||||
|
||||
|
||||
if(!empty($mime))
|
||||
if (! empty($mime))
|
||||
{
|
||||
$supposed_mime = explode("/", get_mime_for_header($file_ext), 2);
|
||||
$supposed_mime = explode('/', get_mime_for_header($file_ext), 2);
|
||||
|
||||
if (is_array($supposed_mime))
|
||||
{
|
||||
@@ -247,26 +246,26 @@ function check_mime_type($given_file_mime, $file_ext, $file_path)
|
||||
|
||||
//if normal checks failed!
|
||||
|
||||
if(@kleeja_filesize($file_path) > 6*(1000*1024))
|
||||
if (@kleeja_filesize($file_path) > 6*(1000*1024))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//check for bad things inside files ...
|
||||
//<.? i cant add it here cuz alot of files contain it
|
||||
$maybe_bad_codes_are = array('<' . 'script', 'zend', 'base64_decode', '<' . '?'. 'php', '<' . '?' . '=');
|
||||
$maybe_bad_codes_are = ['<' . 'script', 'zend', 'base64_decode', '<' . '?' . 'php', '<' . '?' . '='];
|
||||
|
||||
if(!($data = @file_get_contents($file_path)))
|
||||
if (! ($data = @file_get_contents($file_path)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
foreach($maybe_bad_codes_are as $i)
|
||||
foreach ($maybe_bad_codes_are as $i)
|
||||
{
|
||||
if(strpos(strtolower($data), $i) !== false)
|
||||
if (strpos(strtolower($data), $i) !== false)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,37 +279,37 @@ function check_mime_type($given_file_mime, $file_ext, $file_path)
|
||||
*/
|
||||
function user_is_flooding($user_id = '-1')
|
||||
{
|
||||
global $SQL, $dbprefix, $config;
|
||||
global $SQL, $dbprefix, $config;
|
||||
|
||||
$return = 'empty';
|
||||
$return = 'empty';
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('user_is_flooding_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run
|
||||
|
||||
if($return != 'empty')
|
||||
{
|
||||
return $return;
|
||||
}
|
||||
if ($return != 'empty')
|
||||
{
|
||||
return $return;
|
||||
}
|
||||
|
||||
//if the value is zero (means that the function is disabled) then return false immediately
|
||||
if(($user_id == '-1' && $config['guestsectoupload'] == 0) || $user_id != '-1' && $config['usersectoupload'] == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//if the value is zero (means that the function is disabled) then return false immediately
|
||||
if (($user_id == '-1' && $config['guestsectoupload'] == 0) || $user_id != '-1' && $config['usersectoupload'] == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//In my point of view I see 30 seconds is not bad rate to stop flooding ..
|
||||
//even though this minimum rate sometime isn't enough to protect Kleeja from flooding attacks
|
||||
$time = time() - ($user_id == '-1' ? $config['guestsectoupload'] : $config['usersectoupload']);
|
||||
//In my point of view I see 30 seconds is not bad rate to stop flooding ..
|
||||
//even though this minimum rate sometime isn't enough to protect Kleeja from flooding attacks
|
||||
$time = time() - ($user_id == '-1' ? $config['guestsectoupload'] : $config['usersectoupload']);
|
||||
|
||||
$query = array(
|
||||
'SELECT' => 'f.time',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
'WHERE' => 'f.time >= ' . $time . ' AND f.user_ip = \'' . $SQL->escape(get_ip()) . '\'',
|
||||
);
|
||||
$query = [
|
||||
'SELECT' => 'f.time',
|
||||
'FROM' => "{$dbprefix}files f",
|
||||
'WHERE' => 'f.time >= ' . $time . ' AND f.user_ip = \'' . $SQL->escape(get_ip()) . '\'',
|
||||
];
|
||||
|
||||
if ($SQL->num_rows($SQL->build($query)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ($SQL->num_rows($SQL->build($query)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,59 +8,67 @@
|
||||
*/
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
#
|
||||
# This helper is used to help in remote uploading
|
||||
#
|
||||
//
|
||||
// This helper is used to help in remote uploading
|
||||
//
|
||||
|
||||
/**
|
||||
* bring the file size from remote file; aka url
|
||||
*/
|
||||
function get_remote_file_size($url, $method = "GET", $data = "", $redirect = 10)
|
||||
function get_remote_file_size($url, $method = 'GET', $data = '', $redirect = 10)
|
||||
{
|
||||
$url = parse_url($url);
|
||||
$fp = @fsockopen ($url['host'], (!empty($url['port']) ? (int)$url['port'] : 80), $errno, $errstr, 30);
|
||||
if ($fp)
|
||||
{
|
||||
$path = (!empty($url['path']) ? $url['path'] : "/").(!empty($url['query']) ? "?" . $url['query'] : "");
|
||||
$header = "\r\nHost: ".$url['host'];
|
||||
if("post" == strtolower($method))
|
||||
{
|
||||
$header .= "\r\nContent-Length: " . strlen($data);
|
||||
}
|
||||
|
||||
fputs ($fp, $method." ".$path." HTTP/1.0" . $header . "\r\n\r\n". ("post" == strtolower($method) ? $data : ""));
|
||||
if(!feof($fp))
|
||||
{
|
||||
$scheme = fgets($fp);
|
||||
list(, $code ) = explode(" ", $scheme);
|
||||
$headers = array("Scheme" => $scheme);
|
||||
}
|
||||
$url = parse_url($url);
|
||||
$fp = @fsockopen ($url['host'], (! empty($url['port']) ? (int) $url['port'] : 80), $errno, $errstr, 30);
|
||||
|
||||
while (!feof($fp))
|
||||
{
|
||||
$h = fgets($fp);
|
||||
if($h == "\r\n" OR $h == "\n") break;
|
||||
list($key, $value) = explode(":", $h, 2);
|
||||
$headers[$key] = trim($value);
|
||||
if($code >= 300 AND $code < 400 AND strtolower($key) == "location" AND $redirect > 0)
|
||||
{
|
||||
return get_remote_file_size($headers[$key], $method, $data, --$redirect);
|
||||
}
|
||||
}
|
||||
|
||||
$body = "";
|
||||
/*while ( !feof($fp) ) $body .= fgets($fp);*/
|
||||
fclose($fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (array("error" => array("errno" => $errno, "errstr" => $errstr)));
|
||||
}
|
||||
|
||||
return (string) $headers["Content-Length"];
|
||||
if ($fp)
|
||||
{
|
||||
$path = (! empty($url['path']) ? $url['path'] : '/') . (! empty($url['query']) ? '?' . $url['query'] : '');
|
||||
$header = "\r\nHost: " . $url['host'];
|
||||
|
||||
if ('post' == strtolower($method))
|
||||
{
|
||||
$header .= "\r\nContent-Length: " . strlen($data);
|
||||
}
|
||||
|
||||
fputs ($fp, $method . ' ' . $path . ' HTTP/1.0' . $header . "\r\n\r\n" . ('post' == strtolower($method) ? $data : ''));
|
||||
|
||||
if (! feof($fp))
|
||||
{
|
||||
$scheme = fgets($fp);
|
||||
list(, $code ) = explode(' ', $scheme);
|
||||
$headers = ['Scheme' => $scheme];
|
||||
}
|
||||
|
||||
while (! feof($fp))
|
||||
{
|
||||
$h = fgets($fp);
|
||||
|
||||
if ($h == "\r\n" OR $h == "\n")
|
||||
{
|
||||
break;
|
||||
}
|
||||
list($key, $value) = explode(':', $h, 2);
|
||||
$headers[$key] = trim($value);
|
||||
|
||||
if ($code >= 300 AND $code < 400 AND strtolower($key) == 'location' AND $redirect > 0)
|
||||
{
|
||||
return get_remote_file_size($headers[$key], $method, $data, --$redirect);
|
||||
}
|
||||
}
|
||||
|
||||
$body = '';
|
||||
// while ( !feof($fp) ) $body .= fgets($fp);
|
||||
fclose($fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (['error' => ['errno' => $errno, 'errstr' => $errstr]]);
|
||||
}
|
||||
|
||||
return (string) $headers['Content-Length'];
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
*/
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,153 +18,170 @@ if (!defined('IN_COMMON'))
|
||||
/**
|
||||
* Creates a a thumbnail of an image
|
||||
* @example helper_thumb('pics/apple.jpg','thumbs/tn_apple.jpg',100,100);
|
||||
* @param string $source_path
|
||||
* @param string $ext
|
||||
* @param string $dest_image
|
||||
* @param int $dw
|
||||
* @param int $dh
|
||||
* @param string $source_path
|
||||
* @param string $ext
|
||||
* @param string $dest_image
|
||||
* @param int $dw
|
||||
* @param int $dh
|
||||
* @return bool|null
|
||||
*/
|
||||
function helper_thumb($source_path, $ext, $dest_image, $dw, $dh)
|
||||
{
|
||||
#no file, quit it
|
||||
if(!file_exists($source_path))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//no file, quit it
|
||||
if (! file_exists($source_path))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#check width, height
|
||||
if(intval($dw) == 0 || intval($dw) < 10)
|
||||
{
|
||||
$dw = 100;
|
||||
}
|
||||
//check width, height
|
||||
if (intval($dw) == 0 || intval($dw) < 10)
|
||||
{
|
||||
$dw = 100;
|
||||
}
|
||||
|
||||
if(intval($dh) == 0 || intval($dh) < 10)
|
||||
{
|
||||
$dh = $dw;
|
||||
}
|
||||
if (intval($dh) == 0 || intval($dh) < 10)
|
||||
{
|
||||
$dh = $dw;
|
||||
}
|
||||
|
||||
#if there is imagick lib, then we should use it
|
||||
if(function_exists('phpversion') && phpversion('imagick'))
|
||||
{
|
||||
helper_thumb_imagick($source_path, $ext, $dest_image, $dw, $dh);
|
||||
return null;
|
||||
}
|
||||
//if there is imagick lib, then we should use it
|
||||
if (function_exists('phpversion') && phpversion('imagick'))
|
||||
{
|
||||
helper_thumb_imagick($source_path, $ext, $dest_image, $dw, $dh);
|
||||
return null;
|
||||
}
|
||||
|
||||
//get file info
|
||||
list($source_width, $source_height, $source_type) = array(false, false, false);
|
||||
if(function_exists('getimagesize'))
|
||||
{
|
||||
list($source_width, $source_height, $source_type) = getimagesize($source_path);
|
||||
}
|
||||
|
||||
if(!function_exists('imagecreatefromjpeg'))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//get file info
|
||||
list($source_width, $source_height, $source_type) = [false, false, false];
|
||||
|
||||
if (function_exists('getimagesize'))
|
||||
{
|
||||
list($source_width, $source_height, $source_type) = getimagesize($source_path);
|
||||
}
|
||||
|
||||
if (! function_exists('imagecreatefromjpeg'))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$source_gdim = null;
|
||||
|
||||
$ext = strtolower(trim($ext));
|
||||
$ext = strtolower(trim($ext));
|
||||
|
||||
if(empty($ext))
|
||||
if (empty($ext))
|
||||
{
|
||||
$ext = strtolower(preg_replace('/^.*\./', '', $source_path));
|
||||
}
|
||||
|
||||
switch($ext)
|
||||
{
|
||||
case 'gif':
|
||||
$source_gdim = imagecreatefromgif( $source_path );
|
||||
break;
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
$source_gdim = imagecreatefromjpeg( $source_path );
|
||||
break;
|
||||
case 'png':
|
||||
$source_gdim = imagecreatefrompng( $source_path );
|
||||
break;
|
||||
case 'bmp':
|
||||
if(!defined('BMP_CLASS_INCLUDED'))
|
||||
{
|
||||
include dirname(__file__) . '/BMP.php';
|
||||
define('BMP_CLASS_INCLUDED', true);
|
||||
}
|
||||
switch ($ext)
|
||||
{
|
||||
case 'gif':
|
||||
$source_gdim = imagecreatefromgif( $source_path );
|
||||
|
||||
$source_gdim = imagecreatefrombmp( $source_path );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
$source_width = !$source_width ? ImageSX($source_gdim) : $source_width;
|
||||
$source_height = !$source_height ? ImageSY($source_gdim) : $source_height;
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
$source_gdim = imagecreatefromjpeg( $source_path );
|
||||
|
||||
$source_aspect_ratio = $source_width / $source_height;
|
||||
$desired_aspect_ratio = $dw / $dh;
|
||||
break;
|
||||
|
||||
if ($source_aspect_ratio > $desired_aspect_ratio)
|
||||
{
|
||||
// Triggered when source image is wider
|
||||
$temp_height = $dh;
|
||||
$temp_width = (int) ($dh * $source_aspect_ratio);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Triggered otherwise (i.e. source image is similar or taller)
|
||||
$temp_width = $dw;
|
||||
$temp_height = (int) ($dw / $source_aspect_ratio);
|
||||
}
|
||||
case 'png':
|
||||
$source_gdim = imagecreatefrompng( $source_path );
|
||||
|
||||
// Resize the image into a temporary GD image
|
||||
$temp_gdim = imagecreatetruecolor( $temp_width, $temp_height );
|
||||
break;
|
||||
|
||||
imagecopyresampled(
|
||||
$temp_gdim,
|
||||
$source_gdim,
|
||||
0, 0,
|
||||
0, 0,
|
||||
$temp_width, $temp_height,
|
||||
$source_width, $source_height
|
||||
);
|
||||
case 'bmp':
|
||||
if (! defined('BMP_CLASS_INCLUDED'))
|
||||
{
|
||||
include dirname(__file__) . '/BMP.php';
|
||||
define('BMP_CLASS_INCLUDED', true);
|
||||
}
|
||||
|
||||
// Copy cropped region from temporary image into the desired GD image
|
||||
$x0 = ($temp_width - $dw) / 2;
|
||||
$y0 = ($temp_height - $dh) / 2;
|
||||
$source_gdim = imagecreatefrombmp( $source_path );
|
||||
|
||||
$desired_gdim = imagecreatetruecolor($dw, $dh);
|
||||
imagecopy(
|
||||
$desired_gdim,
|
||||
$temp_gdim,
|
||||
0, 0,
|
||||
$x0, $y0,
|
||||
$dw, $dh
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
// Create thumbnail
|
||||
switch(strtolower(preg_replace('/^.*\./', '', $dest_image)))
|
||||
{
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
$return = @imagejpeg($desired_gdim, $dest_image, 90);
|
||||
break;
|
||||
case 'png':
|
||||
$return = @imagepng($desired_gdim, $dest_image);
|
||||
break;
|
||||
case 'gif':
|
||||
$return = @imagegif($desired_gdim, $dest_image);
|
||||
break;
|
||||
case 'bmp':
|
||||
$return = @imagebmp($desired_gdim, $dest_image);
|
||||
break;
|
||||
default:
|
||||
// Unsupported format
|
||||
$return = false;
|
||||
break;
|
||||
}
|
||||
$source_width = ! $source_width ? imagesx($source_gdim) : $source_width;
|
||||
$source_height = ! $source_height ? imagesy($source_gdim) : $source_height;
|
||||
|
||||
@imagedestroy($desired_gdim);
|
||||
@imagedestroy($source_gdim);
|
||||
$source_aspect_ratio = $source_width / $source_height;
|
||||
$desired_aspect_ratio = $dw / $dh;
|
||||
|
||||
return $return;
|
||||
if ($source_aspect_ratio > $desired_aspect_ratio)
|
||||
{
|
||||
// Triggered when source image is wider
|
||||
$temp_height = $dh;
|
||||
$temp_width = (int) ($dh * $source_aspect_ratio);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Triggered otherwise (i.e. source image is similar or taller)
|
||||
$temp_width = $dw;
|
||||
$temp_height = (int) ($dw / $source_aspect_ratio);
|
||||
}
|
||||
|
||||
// Resize the image into a temporary GD image
|
||||
$temp_gdim = imagecreatetruecolor( $temp_width, $temp_height );
|
||||
|
||||
imagecopyresampled(
|
||||
$temp_gdim,
|
||||
$source_gdim,
|
||||
0, 0,
|
||||
0, 0,
|
||||
$temp_width, $temp_height,
|
||||
$source_width, $source_height
|
||||
);
|
||||
|
||||
// Copy cropped region from temporary image into the desired GD image
|
||||
$x0 = ($temp_width - $dw) / 2;
|
||||
$y0 = ($temp_height - $dh) / 2;
|
||||
|
||||
$desired_gdim = imagecreatetruecolor($dw, $dh);
|
||||
imagecopy(
|
||||
$desired_gdim,
|
||||
$temp_gdim,
|
||||
0, 0,
|
||||
$x0, $y0,
|
||||
$dw, $dh
|
||||
);
|
||||
|
||||
// Create thumbnail
|
||||
switch (strtolower(preg_replace('/^.*\./', '', $dest_image)))
|
||||
{
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
$return = @imagejpeg($desired_gdim, $dest_image, 90);
|
||||
|
||||
break;
|
||||
|
||||
case 'png':
|
||||
$return = @imagepng($desired_gdim, $dest_image);
|
||||
|
||||
break;
|
||||
|
||||
case 'gif':
|
||||
$return = @imagegif($desired_gdim, $dest_image);
|
||||
|
||||
break;
|
||||
|
||||
case 'bmp':
|
||||
$return = @imagebmp($desired_gdim, $dest_image);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
// Unsupported format
|
||||
$return = false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@imagedestroy($desired_gdim);
|
||||
@imagedestroy($source_gdim);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,28 +192,28 @@ function helper_thumb($source_path, $ext, $dest_image, $dw, $dh)
|
||||
*/
|
||||
function scale_image_imagick($x, $y, $cx, $cy)
|
||||
{
|
||||
//Set the default NEW values to be the old, in case it doesn't even need scaling
|
||||
list($nx, $ny) = array($x, $y);
|
||||
//Set the default NEW values to be the old, in case it doesn't even need scaling
|
||||
list($nx, $ny) = [$x, $y];
|
||||
|
||||
//If image is generally smaller, don't even bother
|
||||
if ($x >= $cx || $y >= $cx)
|
||||
{
|
||||
//If image is generally smaller, don't even bother
|
||||
if ($x >= $cx || $y >= $cx)
|
||||
{
|
||||
$rx = $ry = 0;
|
||||
|
||||
//Work out ratios
|
||||
if ($x > 0)
|
||||
{
|
||||
$rx = $cx / $x;
|
||||
}
|
||||
|
||||
if ($y > 0)
|
||||
{
|
||||
$ry = $cy / $y;
|
||||
//Work out ratios
|
||||
if ($x > 0)
|
||||
{
|
||||
$rx = $cx / $x;
|
||||
}
|
||||
|
||||
//Use the lowest ratio, to ensure we don't go over the wanted image size
|
||||
if ($rx > $ry)
|
||||
{
|
||||
if ($y > 0)
|
||||
{
|
||||
$ry = $cy / $y;
|
||||
}
|
||||
|
||||
//Use the lowest ratio, to ensure we don't go over the wanted image size
|
||||
if ($rx > $ry)
|
||||
{
|
||||
$r = $ry;
|
||||
}
|
||||
else
|
||||
@@ -204,55 +221,52 @@ function scale_image_imagick($x, $y, $cx, $cy)
|
||||
$r = $rx;
|
||||
}
|
||||
|
||||
//Calculate the new size based on the chosen ratio
|
||||
$nx = intval($x * $r);
|
||||
$ny = intval($y * $r);
|
||||
}
|
||||
//Calculate the new size based on the chosen ratio
|
||||
$nx = intval($x * $r);
|
||||
$ny = intval($y * $r);
|
||||
}
|
||||
|
||||
//Return the results
|
||||
return array($nx, $ny);
|
||||
//Return the results
|
||||
return [$nx, $ny];
|
||||
}
|
||||
|
||||
function helper_thumb_imagick($name, $ext, $filename, $new_w, $new_h)
|
||||
{
|
||||
#intiating the Imagick lib
|
||||
$im = new Imagick($name);
|
||||
//intiating the Imagick lib
|
||||
$im = new Imagick($name);
|
||||
|
||||
#guess the right thumb height, weights
|
||||
list($thumb_w, $thumb_h) = scale_image_imagick(
|
||||
$im->getImageWidth(),
|
||||
$im->getImageHeight(),
|
||||
$new_w,
|
||||
$new_h);
|
||||
//guess the right thumb height, weights
|
||||
list($thumb_w, $thumb_h) = scale_image_imagick(
|
||||
$im->getImageWidth(),
|
||||
$im->getImageHeight(),
|
||||
$new_w,
|
||||
$new_h);
|
||||
|
||||
#an exception for gif image
|
||||
#generating thumb with 10 frames only, big gif is a devil
|
||||
if($ext == 'gif')
|
||||
{
|
||||
$i = 0;
|
||||
//$gif_new = new Imagick();
|
||||
foreach ($im as $frame)
|
||||
{
|
||||
$frame->thumbnailImage($thumb_w, $thumb_h);
|
||||
$frame->setImagePage($thumb_w, $thumb_h, 0, 0);
|
||||
// $gif_new->addImage($frame->getImage());
|
||||
if($i >= 10)
|
||||
{
|
||||
# more than 10 frames, quit it
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$im->writeImages($filename, true);
|
||||
return;
|
||||
}
|
||||
//an exception for gif image
|
||||
//generating thumb with 10 frames only, big gif is a devil
|
||||
if ($ext == 'gif')
|
||||
{
|
||||
$i = 0;
|
||||
//$gif_new = new Imagick();
|
||||
foreach ($im as $frame)
|
||||
{
|
||||
$frame->thumbnailImage($thumb_w, $thumb_h);
|
||||
$frame->setImagePage($thumb_w, $thumb_h, 0, 0);
|
||||
// $gif_new->addImage($frame->getImage());
|
||||
if ($i >= 10)
|
||||
{
|
||||
// more than 10 frames, quit it
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$im->writeImages($filename, true);
|
||||
return;
|
||||
}
|
||||
|
||||
#and other image extension use one way
|
||||
$im->thumbnailImage($thumb_w, $thumb_h);
|
||||
//and other image extension use one way
|
||||
$im->thumbnailImage($thumb_w, $thumb_h);
|
||||
|
||||
#right it
|
||||
$im->writeImages($filename, false);
|
||||
return;
|
||||
//right it
|
||||
$im->writeImages($filename, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
*/
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,167 +25,168 @@ if (!defined('IN_COMMON'))
|
||||
function helper_watermark($name, $ext)
|
||||
{
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('helper_watermark_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
#is this file really exsits ?
|
||||
if(!file_exists($name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$src_logo = $logo_path = false;
|
||||
if(file_exists(dirname(__FILE__) . '/../../images/watermark.png'))
|
||||
{
|
||||
$logo_path= dirname(__FILE__) . '/../../images/watermark.png';
|
||||
$src_logo = imagecreatefrompng($logo_path);
|
||||
}
|
||||
elseif(file_exists(dirname(__FILE__) . '/../../images/watermark.gif'))
|
||||
{
|
||||
$logo_path= dirname(__FILE__) . '/../../images/watermark.gif';
|
||||
$src_logo = imagecreatefromgif($logo_path);
|
||||
}
|
||||
//is this file really exsits ?
|
||||
if (! file_exists($name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#no watermark pic
|
||||
if(!$src_logo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
$src_logo = $logo_path = false;
|
||||
|
||||
#if there is imagick lib, then we should use it
|
||||
if(function_exists('phpversion') && phpversion('imagick'))
|
||||
{
|
||||
helper_watermark_imagick($name, $ext, $logo_path);
|
||||
return;
|
||||
}
|
||||
if (file_exists(dirname(__FILE__) . '/../../images/watermark.png'))
|
||||
{
|
||||
$logo_path= dirname(__FILE__) . '/../../images/watermark.png';
|
||||
$src_logo = imagecreatefrompng($logo_path);
|
||||
}
|
||||
elseif (file_exists(dirname(__FILE__) . '/../../images/watermark.gif'))
|
||||
{
|
||||
$logo_path= dirname(__FILE__) . '/../../images/watermark.gif';
|
||||
$src_logo = imagecreatefromgif($logo_path);
|
||||
}
|
||||
|
||||
#now, lets work and detect our image extension
|
||||
if (strpos($ext, 'jp') !== false)
|
||||
{
|
||||
$src_img = @imagecreatefromjpeg($name);
|
||||
}
|
||||
elseif (strpos($ext, 'png') !== false)
|
||||
{
|
||||
$src_img = @imagecreatefrompng($name);
|
||||
}
|
||||
elseif (strpos($ext, 'gif') !== false)
|
||||
{
|
||||
return;
|
||||
// $src_img = @imagecreatefromgif($name);
|
||||
}
|
||||
elseif(strpos($ext, 'bmp') !== false)
|
||||
{
|
||||
if(!defined('BMP_CLASS_INCLUDED'))
|
||||
{
|
||||
include dirname(__file__) . '/BMP.php';
|
||||
define('BMP_CLASS_INCLUDED', true);
|
||||
}
|
||||
//no watermark pic
|
||||
if (! $src_logo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$src_img = imagecreatefrombmp($name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
//if there is imagick lib, then we should use it
|
||||
if (function_exists('phpversion') && phpversion('imagick'))
|
||||
{
|
||||
helper_watermark_imagick($name, $ext, $logo_path);
|
||||
return;
|
||||
}
|
||||
|
||||
#detect width, height for the image
|
||||
$bwidth = @imageSX($src_img);
|
||||
$bheight = @imageSY($src_img);
|
||||
|
||||
#detect width, height for the watermark image
|
||||
$lwidth = @imageSX($src_logo);
|
||||
$lheight = @imageSY($src_logo);
|
||||
//now, lets work and detect our image extension
|
||||
if (strpos($ext, 'jp') !== false)
|
||||
{
|
||||
$src_img = @imagecreatefromjpeg($name);
|
||||
}
|
||||
elseif (strpos($ext, 'png') !== false)
|
||||
{
|
||||
$src_img = @imagecreatefrompng($name);
|
||||
}
|
||||
elseif (strpos($ext, 'gif') !== false)
|
||||
{
|
||||
return;
|
||||
// $src_img = @imagecreatefromgif($name);
|
||||
}
|
||||
elseif (strpos($ext, 'bmp') !== false)
|
||||
{
|
||||
if (! defined('BMP_CLASS_INCLUDED'))
|
||||
{
|
||||
include dirname(__file__) . '/BMP.php';
|
||||
define('BMP_CLASS_INCLUDED', true);
|
||||
}
|
||||
|
||||
$src_img = imagecreatefrombmp($name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//detect width, height for the image
|
||||
$bwidth = @imagesx($src_img);
|
||||
$bheight = @imagesy($src_img);
|
||||
|
||||
//detect width, height for the watermark image
|
||||
$lwidth = @imagesx($src_logo);
|
||||
$lheight = @imagesy($src_logo);
|
||||
|
||||
|
||||
if ($bwidth > $lwidth+5 && $bheight > $lheight+5)
|
||||
{
|
||||
#where exaxtly do we have to make the watermark ..
|
||||
$src_x = $bwidth - ($lwidth + 5);
|
||||
$src_y = $bheight - ($lheight + 5);
|
||||
|
||||
#make it now, watermark it
|
||||
@ImageAlphaBlending($src_img, true);
|
||||
@ImageCopy($src_img, $src_logo, $src_x, $src_y, 0, 0, $lwidth, $lheight);
|
||||
if ($bwidth > $lwidth+5 && $bheight > $lheight+5)
|
||||
{
|
||||
//where exaxtly do we have to make the watermark ..
|
||||
$src_x = $bwidth - ($lwidth + 5);
|
||||
$src_y = $bheight - ($lheight + 5);
|
||||
|
||||
if (strpos($ext, 'jp') !== false)
|
||||
{
|
||||
#no compression, same quality
|
||||
@imagejpeg($src_img, $name, 100);
|
||||
}
|
||||
elseif (strpos($ext, 'png') !== false)
|
||||
{
|
||||
#no compression, same quality
|
||||
@imagepng($src_img, $name, 0);
|
||||
}
|
||||
elseif (strpos($ext, 'gif') !== false)
|
||||
{
|
||||
@imagegif($src_img, $name);
|
||||
}
|
||||
elseif (strpos($ext, 'bmp') !== false)
|
||||
{
|
||||
@imagebmp($src_img, $name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#image is not big enough to watermark it
|
||||
return;
|
||||
}
|
||||
//make it now, watermark it
|
||||
@imagealphablending($src_img, true);
|
||||
@imagecopy($src_img, $src_logo, $src_x, $src_y, 0, 0, $lwidth, $lheight);
|
||||
|
||||
if (strpos($ext, 'jp') !== false)
|
||||
{
|
||||
//no compression, same quality
|
||||
@imagejpeg($src_img, $name, 100);
|
||||
}
|
||||
elseif (strpos($ext, 'png') !== false)
|
||||
{
|
||||
//no compression, same quality
|
||||
@imagepng($src_img, $name, 0);
|
||||
}
|
||||
elseif (strpos($ext, 'gif') !== false)
|
||||
{
|
||||
@imagegif($src_img, $name);
|
||||
}
|
||||
elseif (strpos($ext, 'bmp') !== false)
|
||||
{
|
||||
@imagebmp($src_img, $name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//image is not big enough to watermark it
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# generate watermarked images by imagick
|
||||
#
|
||||
//
|
||||
// generate watermarked images by imagick
|
||||
//
|
||||
function helper_watermark_imagick($name, $ext, $logo)
|
||||
{
|
||||
#Not just me babe, All the places misses you ..
|
||||
$im = new Imagick($name);
|
||||
//Not just me babe, All the places misses you ..
|
||||
$im = new Imagick($name);
|
||||
|
||||
$watermark = new Imagick($logo);
|
||||
//$watermark->readImage($);
|
||||
$watermark = new Imagick($logo);
|
||||
//$watermark->readImage($);
|
||||
|
||||
#how big are the images?
|
||||
$iWidth = $im->getImageWidth();
|
||||
$iHeight= $im->getImageHeight();
|
||||
$wWidth = $watermark->getImageWidth();
|
||||
$wHeight= $watermark->getImageHeight();
|
||||
//how big are the images?
|
||||
$iWidth = $im->getImageWidth();
|
||||
$iHeight= $im->getImageHeight();
|
||||
$wWidth = $watermark->getImageWidth();
|
||||
$wHeight= $watermark->getImageHeight();
|
||||
|
||||
if ($iHeight < $wHeight || $iWidth < $wWidth)
|
||||
{
|
||||
#resize the watermark
|
||||
$watermark->scaleImage($iWidth, $iHeight);
|
||||
if ($iHeight < $wHeight || $iWidth < $wWidth)
|
||||
{
|
||||
//resize the watermark
|
||||
$watermark->scaleImage($iWidth, $iHeight);
|
||||
|
||||
#get new size
|
||||
$wWidth = $watermark->getImageWidth();
|
||||
$wHeight = $watermark->getImageHeight();
|
||||
}
|
||||
//get new size
|
||||
$wWidth = $watermark->getImageWidth();
|
||||
$wHeight = $watermark->getImageHeight();
|
||||
}
|
||||
|
||||
#calculate the position
|
||||
$x = $iWidth - ($wWidth - 5);
|
||||
$y = $iHeight - ($wHeight - 5);
|
||||
//calculate the position
|
||||
$x = $iWidth - ($wWidth - 5);
|
||||
$y = $iHeight - ($wHeight - 5);
|
||||
|
||||
#an exception for gif image
|
||||
#generating thumb with 10 frames only, big gif is a devil
|
||||
if($ext == 'gif')
|
||||
{
|
||||
$i = 0;
|
||||
//$gif_new = new Imagick();
|
||||
foreach ($im as $frame)
|
||||
{
|
||||
$frame->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y);
|
||||
//an exception for gif image
|
||||
//generating thumb with 10 frames only, big gif is a devil
|
||||
if ($ext == 'gif')
|
||||
{
|
||||
$i = 0;
|
||||
//$gif_new = new Imagick();
|
||||
foreach ($im as $frame)
|
||||
{
|
||||
$frame->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y);
|
||||
|
||||
// $gif_new->addImage($frame->getImage());
|
||||
if($i >= 10)
|
||||
{
|
||||
# more than 10 frames, quit it
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$im->writeImages($name, true);
|
||||
return;
|
||||
}
|
||||
// $gif_new->addImage($frame->getImage());
|
||||
if ($i >= 10)
|
||||
{
|
||||
// more than 10 frames, quit it
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$im->writeImages($name, true);
|
||||
return;
|
||||
}
|
||||
|
||||
$im->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y);
|
||||
|
||||
$im->writeImages($name, false);
|
||||
$im->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y);
|
||||
|
||||
$im->writeImages($name, false);
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
#includes important functions
|
||||
//includes important functions
|
||||
include_once dirname(__file__) . '/../up_helpers/others.php';
|
||||
include_once dirname(__file__) . '/../up_helpers/thumbs.php';
|
||||
include_once dirname(__file__) . '/../up_helpers/watermark.php';
|
||||
@@ -28,19 +28,19 @@ include_once dirname(__file__) . '/../up_helpers/remote_uploading.php';
|
||||
*/
|
||||
class defaultUploader implements KleejaUploader
|
||||
{
|
||||
protected $messages = array();
|
||||
protected $messages = [];
|
||||
|
||||
protected $allowed_file_extensions = array();
|
||||
protected $allowed_file_extensions = [];
|
||||
|
||||
protected $upload_fields_limit = 0;
|
||||
protected $upload_fields_limit = 0;
|
||||
|
||||
protected $total_uploaded_files = 0;
|
||||
protected $total_uploaded_files = 0;
|
||||
|
||||
/**
|
||||
* set the allowed extensions of uploaded files
|
||||
* @param array $allowed_file_extensions an array of allowed extensions ['gif', 'png' ..]
|
||||
*/
|
||||
function setAllowedFileExtensions($allowed_file_extensions)
|
||||
public function setAllowedFileExtensions($allowed_file_extensions)
|
||||
{
|
||||
$this->allowed_file_extensions = $allowed_file_extensions;
|
||||
}
|
||||
@@ -50,9 +50,9 @@ class defaultUploader implements KleejaUploader
|
||||
* get the allowed extensions of uploaded files
|
||||
* @return array
|
||||
*/
|
||||
function getAllowedFileExtensions()
|
||||
public function getAllowedFileExtensions()
|
||||
{
|
||||
return $this->allowed_file_extensions;
|
||||
return $this->allowed_file_extensions;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class defaultUploader implements KleejaUploader
|
||||
* set the allowed limit of the uploaded files
|
||||
* @param int $limit
|
||||
*/
|
||||
function setUploadFieldsLimit($limit)
|
||||
public function setUploadFieldsLimit($limit)
|
||||
{
|
||||
$this->upload_fields_limit = $limit;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class defaultUploader implements KleejaUploader
|
||||
* get the allowed limit of the uploaded files
|
||||
* @return int
|
||||
*/
|
||||
function getUploadFieldsLimit()
|
||||
public function getUploadFieldsLimit()
|
||||
{
|
||||
return $this->upload_fields_limit;
|
||||
}
|
||||
@@ -78,23 +78,23 @@ class defaultUploader implements KleejaUploader
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
array_push($this->messages, array($message, 'info'));
|
||||
array_push($this->messages, [$message, 'info']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
array_push($this->messages, array($message, 'error'));
|
||||
array_push($this->messages, [$message, 'error']);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class defaultUploader implements KleejaUploader
|
||||
* get all the messages
|
||||
* @return array
|
||||
*/
|
||||
function getMessages()
|
||||
public function getMessages()
|
||||
{
|
||||
return $this->messages;
|
||||
}
|
||||
@@ -110,10 +110,10 @@ class defaultUploader implements KleejaUploader
|
||||
|
||||
/**
|
||||
* save the file information to the database
|
||||
* @param array $fileInfo
|
||||
* @param array $fileInfo
|
||||
* @return void
|
||||
*/
|
||||
function saveToDatabase($fileInfo)
|
||||
public function saveToDatabase($fileInfo)
|
||||
{
|
||||
global $SQL, $dbprefix, $config;
|
||||
|
||||
@@ -133,53 +133,53 @@ class defaultUploader implements KleejaUploader
|
||||
// [
|
||||
|
||||
|
||||
#sometime cant see file after uploading.. but ..
|
||||
//sometime cant see file after uploading.. but ..
|
||||
@chmod($fileInfo['saveToFolder'] . '/' . $fileInfo['generatedFileName'], 0644);
|
||||
|
||||
$fileInfo['DeleteCode'] = sha1($fileInfo['generatedFileName'] . uniqid());
|
||||
|
||||
$queryValues = array
|
||||
(
|
||||
'name' => $fileInfo['generatedFileName'],
|
||||
$queryValues =
|
||||
[
|
||||
'name' => $fileInfo['generatedFileName'],
|
||||
'real_filename' => $fileInfo['originalFileName'],
|
||||
'size' => intval($fileInfo['fileSize']),
|
||||
'time' => time(),
|
||||
'folder'=> $fileInfo['saveToFolder'],
|
||||
'type' => $fileInfo['fileExtension'],
|
||||
'user' => $fileInfo['currentUserId'],
|
||||
'code_del' => $fileInfo['DeleteCode'],
|
||||
'user_ip' => get_ip(),
|
||||
'id_form' => $config['id_form'],
|
||||
);
|
||||
'size' => intval($fileInfo['fileSize']),
|
||||
'time' => time(),
|
||||
'folder' => $fileInfo['saveToFolder'],
|
||||
'type' => $fileInfo['fileExtension'],
|
||||
'user' => $fileInfo['currentUserId'],
|
||||
'code_del' => $fileInfo['DeleteCode'],
|
||||
'user_ip' => get_ip(),
|
||||
'id_form' => $config['id_form'],
|
||||
];
|
||||
|
||||
$is_img = in_array($fileInfo['fileExtension'], array('png','gif','jpg','jpeg', 'bmp')) ? true : false;
|
||||
$is_img = in_array($fileInfo['fileExtension'], ['png','gif','jpg','jpeg', 'bmp']) ? true : false;
|
||||
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('defaultUploader_saveToDatabase_qr', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
# insertion query
|
||||
$insert_query = array(
|
||||
'INSERT' => '`' . implode('` , `' , array_keys($queryValues)) . '`',
|
||||
'INTO' => "{$dbprefix}files",
|
||||
'VALUES' => "'" . implode("', '", array_map(array($SQL, 'escape'), array_values($queryValues))) . "'"
|
||||
);
|
||||
// insertion query
|
||||
$insert_query = [
|
||||
'INSERT' => '`' . implode('` , `', array_keys($queryValues)) . '`',
|
||||
'INTO' => "{$dbprefix}files",
|
||||
'VALUES' => "'" . implode("', '", array_map([$SQL, 'escape'], array_values($queryValues))) . "'"
|
||||
];
|
||||
|
||||
|
||||
# do the query
|
||||
// do the query
|
||||
$SQL->build($insert_query);
|
||||
|
||||
|
||||
# inset id so it can be used in url like in do.php?id={id_for_url}
|
||||
// inset id so it can be used in url like in do.php?id={id_for_url}
|
||||
$fileInfo['insertId'] = $SQL->insert_id();
|
||||
|
||||
|
||||
|
||||
# update Kleeja stats
|
||||
$update_query = array(
|
||||
// update Kleeja stats
|
||||
$update_query = [
|
||||
'UPDATE' => "{$dbprefix}stats",
|
||||
'SET' => ($is_img ? "imgs=imgs+1" : "files=files+1") . ",sizes=sizes+" . intval($fileInfo['fileSize']) . ""
|
||||
);
|
||||
'SET' => ($is_img ? 'imgs=imgs+1' : 'files=files+1') . ',sizes=sizes+' . intval($fileInfo['fileSize']) . ''
|
||||
];
|
||||
|
||||
$SQL->build($update_query);
|
||||
|
||||
@@ -190,10 +190,10 @@ class defaultUploader implements KleejaUploader
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
global $config, $lang;
|
||||
|
||||
@@ -210,42 +210,44 @@ class defaultUploader implements KleejaUploader
|
||||
// [
|
||||
|
||||
|
||||
$is_img = in_array($fileInfo['fileExtension'], array('png','gif','jpg','jpeg', 'bmp')) ? true : false;
|
||||
$is_img = in_array($fileInfo['fileExtension'], ['png','gif','jpg','jpeg', 'bmp']) ? true : false;
|
||||
|
||||
|
||||
# information of file, used for generating a url boxes
|
||||
$file_info = array(
|
||||
'::ID::' => $fileInfo['insertId'],
|
||||
'::NAME::' => $fileInfo['generatedFileName'],
|
||||
'::DIR::' => $fileInfo['saveToFolder'],
|
||||
'::FNAME::' => $fileInfo['originalFileName'],
|
||||
);
|
||||
// information of file, used for generating a url boxes
|
||||
$file_info = [
|
||||
'::ID::' => $fileInfo['insertId'],
|
||||
'::NAME::' => $fileInfo['generatedFileName'],
|
||||
'::DIR::' => $fileInfo['saveToFolder'],
|
||||
'::FNAME::' => $fileInfo['originalFileName'],
|
||||
];
|
||||
|
||||
# show del code link box
|
||||
// show del code link box
|
||||
$extra_del = '';
|
||||
|
||||
if ($config['del_url_file'])
|
||||
{
|
||||
$extra_del = get_up_tpl_box('del_file_code',
|
||||
array(
|
||||
'b_title' => $lang['URL_F_DEL'],
|
||||
'b_code_link' => kleeja_get_link('del', array('::CODE::'=>$fileInfo['DeleteCode']))
|
||||
)
|
||||
[
|
||||
'b_title' => $lang['URL_F_DEL'],
|
||||
'b_code_link' => kleeja_get_link('del', ['::CODE::'=>$fileInfo['DeleteCode']])
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
//show imgs
|
||||
if($is_img)
|
||||
if ($is_img)
|
||||
{
|
||||
$img_html_result = '';
|
||||
|
||||
# get default thumb dimensions
|
||||
// get default thumb dimensions
|
||||
$thmb_dim_w = $thmb_dim_h = 150;
|
||||
if(strpos($config['thmb_dims'], '*') !== false)
|
||||
|
||||
if (strpos($config['thmb_dims'], '*') !== false)
|
||||
{
|
||||
list($thmb_dim_w, $thmb_dim_h) = array_map('trim', explode('*', $config['thmb_dims']));
|
||||
}
|
||||
|
||||
# generate a thumbnail
|
||||
// generate a thumbnail
|
||||
helper_thumb(
|
||||
$fileInfo['saveToFolder'] . '/' . $fileInfo['generatedFileName'],
|
||||
$fileInfo['fileExtension'],
|
||||
@@ -256,63 +258,63 @@ class defaultUploader implements KleejaUploader
|
||||
|
||||
|
||||
$img_html_result .= get_up_tpl_box('image_thumb',
|
||||
array(
|
||||
'b_title' => $lang['URL_F_THMB'],
|
||||
[
|
||||
'b_title' => $lang['URL_F_THMB'],
|
||||
'b_url_link'=> kleeja_get_link('image', $file_info),
|
||||
'b_img_link'=> kleeja_get_link('thumb', $file_info)
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
# watermark on image
|
||||
if($config['write_imgs'] != 0 && in_array($fileInfo['fileExtension'], array('gif', 'png', 'jpg', 'jpeg', 'bmp')))
|
||||
// watermark on image
|
||||
if ($config['write_imgs'] != 0 && in_array($fileInfo['fileExtension'], ['gif', 'png', 'jpg', 'jpeg', 'bmp']))
|
||||
{
|
||||
helper_watermark($fileInfo['saveToFolder'] . "/" . $fileInfo['generatedFileName'], $fileInfo['fileExtension']);
|
||||
helper_watermark($fileInfo['saveToFolder'] . '/' . $fileInfo['generatedFileName'], $fileInfo['fileExtension']);
|
||||
}
|
||||
|
||||
#then show, image box
|
||||
//then show, image box
|
||||
$img_html_result .= get_up_tpl_box('image',
|
||||
array(
|
||||
'b_title' => $lang['URL_F_IMG'],
|
||||
[
|
||||
'b_title' => $lang['URL_F_IMG'],
|
||||
'b_bbc_title'=> $lang['URL_F_BBC'],
|
||||
'b_url_link'=> kleeja_get_link('image', $file_info),
|
||||
)
|
||||
'b_url_link' => kleeja_get_link('image', $file_info),
|
||||
]
|
||||
);
|
||||
|
||||
#add del link box to the result if there is any
|
||||
//add del link box to the result if there is any
|
||||
$img_html_result .= $extra_del;
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('defaultUploader_generateOutputBox_image_result', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
#show success message
|
||||
//show success message
|
||||
$this->addInfoMessage(
|
||||
'<div class="up-box-title">'. $lang['IMG_DOWNLAODED'] . ': ' .
|
||||
'<div class="up-box-title">' . $lang['IMG_DOWNLAODED'] . ': ' .
|
||||
htmlspecialchars($fileInfo['originalFileName']) . '</div>' . "\n" .
|
||||
$img_html_result
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
#then show other files
|
||||
//then show other files
|
||||
$else_html_result = get_up_tpl_box('file',
|
||||
array(
|
||||
'b_title' => $lang['URL_F_FILE'],
|
||||
[
|
||||
'b_title' => $lang['URL_F_FILE'],
|
||||
'b_bbc_title'=> $lang['URL_F_BBC'],
|
||||
'b_url_link'=> kleeja_get_link('file', $file_info),
|
||||
)
|
||||
'b_url_link' => kleeja_get_link('file', $file_info),
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
#add del link box to the result if there is any
|
||||
//add del link box to the result if there is any
|
||||
$else_html_result .= $extra_del;
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('defaultUploader_generateOutputBox_file_result', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
#show success message
|
||||
//show success message
|
||||
$this->addInfoMessage(
|
||||
'<div class="up-box-title">'. $lang['FILE_DOWNLAODED']. ': '
|
||||
'<div class="up-box-title">' . $lang['FILE_DOWNLAODED'] . ': '
|
||||
. htmlspecialchars($fileInfo['originalFileName']) . '</div>' . "\n" .
|
||||
$else_html_result
|
||||
);
|
||||
@@ -326,22 +328,22 @@ class defaultUploader implements KleejaUploader
|
||||
* here happens the magic, call this on upload submit
|
||||
* @param int $uploadType upload from files input or links
|
||||
*/
|
||||
function upload($uploadType)
|
||||
public function upload($uploadType)
|
||||
{
|
||||
global $usrcp, $config, $lang;
|
||||
|
||||
# when $uploadType = 1, then we upload from _file input
|
||||
# if $uploadType = 2, then we uploading from url which is disabled by default and is buggy
|
||||
// when $uploadType = 1, then we upload from _file input
|
||||
// if $uploadType = 2, then we uploading from url which is disabled by default and is buggy
|
||||
|
||||
|
||||
#upload to this folder
|
||||
//upload to this folder
|
||||
$current_uploading_folder = $config['foldername'];
|
||||
|
||||
#current user id
|
||||
//current user id
|
||||
$current_user_id = $usrcp->name() ? $usrcp->id() : '-1';
|
||||
|
||||
|
||||
#is captcha is on?
|
||||
//is captcha is on?
|
||||
$captcha_enabled = intval($config['safe_code']);
|
||||
|
||||
$return_now = false;
|
||||
@@ -349,52 +351,52 @@ class defaultUploader implements KleejaUploader
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('defaultUploader_upload_1st', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
# check folder our real folder
|
||||
if(!file_exists($current_uploading_folder))
|
||||
// check folder our real folder
|
||||
if (! file_exists($current_uploading_folder))
|
||||
{
|
||||
if(!make_folder($current_uploading_folder))
|
||||
if (! make_folder($current_uploading_folder))
|
||||
{
|
||||
$this->addErrorMessage($lang['CANT_DIR_CRT']);
|
||||
$this->addErrorMessage($lang['CANT_DIR_CRT']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($return_now)
|
||||
if ($return_now)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#no uploading yet, or just go to index.php, so we have make a new session
|
||||
if(!$uploadType)
|
||||
//no uploading yet, or just go to index.php, so we have make a new session
|
||||
if (! $uploadType)
|
||||
{
|
||||
unset($_SESSION['FIILES_NOT_DUPLI'], $_SESSION['FIILES_NOT_DUPLI_LINKS']);
|
||||
}
|
||||
|
||||
|
||||
# is captcha on, and there is uploading going on
|
||||
if($captcha_enabled && $uploadType)
|
||||
// is captcha on, and there is uploading going on
|
||||
if ($captcha_enabled && $uploadType)
|
||||
{
|
||||
#captcha is wrong
|
||||
if(!kleeja_check_captcha())
|
||||
//captcha is wrong
|
||||
if (! kleeja_check_captcha())
|
||||
{
|
||||
$this->addErrorMessage($lang['WRONG_VERTY_CODE']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# to prevent flooding, user must wait, waiting-time is grapped from Kleeja settings, admin is exceptional
|
||||
if(! user_can('enter_acp') && user_is_flooding($current_user_id))
|
||||
// to prevent flooding, user must wait, waiting-time is grapped from Kleeja settings, admin is exceptional
|
||||
if (! user_can('enter_acp') && user_is_flooding($current_user_id))
|
||||
{
|
||||
$this->addErrorMessage(sprintf($lang['YOU_HAVE_TO_WAIT'],
|
||||
$this->addErrorMessage(sprintf($lang['YOU_HAVE_TO_WAIT'],
|
||||
$current_user_id == '-1' ? $config['guestsectoupload'] : $config['usersectoupload']));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#detect flooding, TODO fix it or remove it
|
||||
if ($uploadType == 1 && isset($_SESSION['FIILES_NOT_DUPLI']))
|
||||
//detect flooding, TODO fix it or remove it
|
||||
if ($uploadType == 1 && isset($_SESSION['FIILES_NOT_DUPLI']))
|
||||
{
|
||||
if(!empty($_SESSION['FIILES_NOT_DUPLI']) && $_SESSION['FIILES_NOT_DUPLI'] == sha1(serialize(array_column($_FILES, 'name'))))
|
||||
if (! empty($_SESSION['FIILES_NOT_DUPLI']) && $_SESSION['FIILES_NOT_DUPLI'] == sha1(serialize(array_column($_FILES, 'name'))))
|
||||
{
|
||||
unset($_SESSION['FIILES_NOT_DUPLI']);
|
||||
// if(!ip('ajax'))
|
||||
@@ -407,12 +409,13 @@ class defaultUploader implements KleejaUploader
|
||||
}
|
||||
}
|
||||
|
||||
if ($uploadType == 2 && isset($_SESSION['FIILES_NOT_DUPLI_LINKS']))
|
||||
if ($uploadType == 2 && isset($_SESSION['FIILES_NOT_DUPLI_LINKS']))
|
||||
{
|
||||
if($_SESSION['FIILES_NOT_DUPLI_LINKS'] == sha1(serialize($_POST)))
|
||||
if ($_SESSION['FIILES_NOT_DUPLI_LINKS'] == sha1(serialize($_POST)))
|
||||
{
|
||||
unset($_SESSION['FIILES_NOT_DUPLI_LINKS']);
|
||||
if(!ip('ajax'))
|
||||
|
||||
if (! ip('ajax'))
|
||||
{
|
||||
redirect('./');
|
||||
}
|
||||
@@ -423,41 +426,41 @@ class defaultUploader implements KleejaUploader
|
||||
}
|
||||
|
||||
|
||||
# flooding code, making sure every ok session is cleared
|
||||
if ($uploadType == 1 && sizeof($_FILES) > 0)
|
||||
// flooding code, making sure every ok session is cleared
|
||||
if ($uploadType == 1 && sizeof($_FILES) > 0)
|
||||
{
|
||||
$_SESSION['FIILES_NOT_DUPLI'] = sha1(serialize(array_column($_FILES, 'name')));
|
||||
}
|
||||
elseif($uploadType == 2)
|
||||
elseif ($uploadType == 2)
|
||||
{
|
||||
$_SESSION['FIILES_NOT_DUPLI_LINKS'] = sha1(serialize($_POST));
|
||||
}
|
||||
|
||||
|
||||
#now close session to let user open any other page in Kleeja
|
||||
session_write_close();
|
||||
//now close session to let user open any other page in Kleeja
|
||||
session_write_close();
|
||||
|
||||
|
||||
# do upload
|
||||
switch($uploadType)
|
||||
// do upload
|
||||
switch ($uploadType)
|
||||
{
|
||||
#uploading from a _files input
|
||||
//uploading from a _files input
|
||||
default:
|
||||
case 1:
|
||||
|
||||
if(!empty($_FILES['file']['tmp_name']))
|
||||
if (! empty($_FILES['file']['tmp_name']))
|
||||
{
|
||||
$_FILES['file'][0] = $_FILES['file'];
|
||||
}
|
||||
|
||||
|
||||
# loop the uploaded files
|
||||
for($i=0; $i<=$this->getUploadFieldsLimit(); $i++)
|
||||
// loop the uploaded files
|
||||
for ($i=0; $i<=$this->getUploadFieldsLimit(); $i++)
|
||||
{
|
||||
//no file!
|
||||
if(empty($_FILES['file_' . $i . '_']['tmp_name']) && empty($_FILES['file'][$i]['tmp_name']))
|
||||
if (empty($_FILES['file_' . $i . '_']['tmp_name']) && empty($_FILES['file'][$i]['tmp_name']))
|
||||
{
|
||||
if(is_null($_FILES['file_' . $i . '_']) && is_null($_FILES['file'][$i]))
|
||||
if (is_null($_FILES['file_' . $i . '_']) && is_null($_FILES['file'][$i]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -489,21 +492,29 @@ class defaultUploader implements KleejaUploader
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
// $message = "The uploaded file was only partially uploaded";
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
// $message = "No file was uploaded";
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
$this->addErrorMessage('Missing a temporary folder');
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
$this->addErrorMessage('Failed to write file to disk');
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
$this->addErrorMessage('File upload stopped by extension');
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->addErrorMessage(sprintf($lang['CANT_UPLAOD'], htmlspecialchars($filename)));
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -519,17 +530,17 @@ class defaultUploader implements KleejaUploader
|
||||
break;
|
||||
|
||||
|
||||
#uploading from a url text-input
|
||||
//uploading from a url text-input
|
||||
case 2:
|
||||
|
||||
#if not enabled, quit it
|
||||
if($config['www_url'] != 1)
|
||||
//if not enabled, quit it
|
||||
if ($config['www_url'] != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
#loop text inputs
|
||||
for($i=0; $i<=$this->getUploadFieldsLimit(); $i++)
|
||||
//loop text inputs
|
||||
for ($i=0; $i<=$this->getUploadFieldsLimit(); $i++)
|
||||
{
|
||||
$this->uploadTypeUrl($i, $current_uploading_folder, $current_user_id);
|
||||
}
|
||||
@@ -539,8 +550,8 @@ class defaultUploader implements KleejaUploader
|
||||
|
||||
|
||||
|
||||
# well, no file uploaded, ask user to choose a file before submit
|
||||
if($this->total_uploaded_files == 0 && sizeof($this->messages) == 0)
|
||||
// well, no file uploaded, ask user to choose a file before submit
|
||||
if ($this->total_uploaded_files == 0 && sizeof($this->messages) == 0)
|
||||
{
|
||||
$this->addErrorMessage($lang['CHOSE_F']);
|
||||
}
|
||||
@@ -553,60 +564,60 @@ class defaultUploader implements KleejaUploader
|
||||
* @param $current_uploading_folder
|
||||
* @param $current_user_id
|
||||
*/
|
||||
function uploadTypeFile($fieldNumber, $current_uploading_folder, $current_user_id)
|
||||
public function uploadTypeFile($fieldNumber, $current_uploading_folder, $current_user_id)
|
||||
{
|
||||
global $config, $lang;
|
||||
|
||||
$fileInfo = array(
|
||||
$fileInfo = [
|
||||
'saveToFolder',
|
||||
'originalFileName',
|
||||
'generatedFileName',
|
||||
'fileSize',
|
||||
'currentUserId',
|
||||
'fileExtension'
|
||||
);
|
||||
];
|
||||
|
||||
|
||||
$fileInfo['saveToFolder'] = $current_uploading_folder;
|
||||
$fileInfo['saveToFolder'] = $current_uploading_folder;
|
||||
$fileInfo['currentUserId'] = $current_user_id;
|
||||
|
||||
|
||||
if(!isset($_FILES['file_' . $fieldNumber . '_']) && isset($_FILES['file'][$fieldNumber]))
|
||||
if (! isset($_FILES['file_' . $fieldNumber . '_']) && isset($_FILES['file'][$fieldNumber]))
|
||||
{
|
||||
$_FILES['file_' . $fieldNumber . '_'] = $_FILES['file'][$fieldNumber];
|
||||
}
|
||||
|
||||
# file name
|
||||
// file name
|
||||
$fileInfo['originalFileName'] = isset($_FILES['file_' . $fieldNumber . '_']['name'])
|
||||
? urldecode(str_replace(array(';',','), '', $_FILES['file_' . $fieldNumber . '_']['name']))
|
||||
? urldecode(str_replace([';',','], '', $_FILES['file_' . $fieldNumber . '_']['name']))
|
||||
: '';
|
||||
|
||||
if(empty($fileInfo['originalFileName']))
|
||||
if (empty($fileInfo['originalFileName']))
|
||||
{
|
||||
$this->addErrorMessage(sprintf($lang['WRONG_F_NAME'], htmlspecialchars($_FILES['file_' . $fieldNumber . '_']['name'])));
|
||||
return;
|
||||
}
|
||||
|
||||
# get the extension of file
|
||||
// get the extension of file
|
||||
$fileInfo['fileExtension'] = strtolower(array_pop(explode('.', $fileInfo['originalFileName'])));
|
||||
|
||||
|
||||
# them the size
|
||||
$fileInfo['fileSize'] = !empty($_FILES['file_' . $fieldNumber . '_']['size'])
|
||||
// them the size
|
||||
$fileInfo['fileSize'] = ! empty($_FILES['file_' . $fieldNumber . '_']['size'])
|
||||
? intval($_FILES['file_' . $fieldNumber . '_']['size'])
|
||||
: 0;
|
||||
|
||||
|
||||
# get the other filename, changed depend on kleeja settings
|
||||
// get the other filename, changed depend on kleeja settings
|
||||
$fileInfo['generatedFileName'] = change_filename_decoding($fileInfo['originalFileName'], $fieldNumber, $fileInfo['fileExtension']);
|
||||
|
||||
|
||||
# filename templates {rand:..}, {date:..}
|
||||
// filename templates {rand:..}, {date:..}
|
||||
$fileInfo['generatedFileName'] = change_filename_templates(trim($config['prefixname']) . $fileInfo['generatedFileName']);
|
||||
|
||||
|
||||
# file exists before? change it a little
|
||||
if(file_exists($current_uploading_folder . '/' . $fileInfo['generatedFileName']))
|
||||
// file exists before? change it a little
|
||||
if (file_exists($current_uploading_folder . '/' . $fileInfo['generatedFileName']))
|
||||
{
|
||||
$fileInfo['generatedFileName'] = change_filename_decoding(
|
||||
$fileInfo['generatedFileName'],
|
||||
@@ -618,41 +629,41 @@ class defaultUploader implements KleejaUploader
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('defaultUploader_uploadTypeFile_1st', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
# now, let process it
|
||||
if(!in_array(strtolower($fileInfo['fileExtension']), array_keys($this->getAllowedFileExtensions())))
|
||||
// now, let process it
|
||||
if (! in_array(strtolower($fileInfo['fileExtension']), array_keys($this->getAllowedFileExtensions())))
|
||||
{
|
||||
# guest
|
||||
if($current_user_id == '-1')
|
||||
// guest
|
||||
if ($current_user_id == '-1')
|
||||
{
|
||||
$this->addErrorMessage(
|
||||
sprintf($lang['FORBID_EXT'], $fileInfo['fileExtension'])
|
||||
. '<br> <a href="' . ($config['mod_writer'] ? "register.html" : "ucp.php?go=register") .
|
||||
. '<br> <a href="' . ($config['mod_writer'] ? 'register.html' : 'ucp.php?go=register') .
|
||||
'" title="' . htmlspecialchars($lang['REGISTER']) . '">' . $lang['REGISTER'] . '</a>'
|
||||
);
|
||||
}
|
||||
# a member
|
||||
// a member
|
||||
else
|
||||
{
|
||||
$this->addErrorMessage(sprintf($lang['FORBID_EXT'], $fileInfo['fileExtension']));
|
||||
}
|
||||
}
|
||||
# bad chars in the filename
|
||||
elseif(preg_match ("#[\\\/\:\*\?\<\>\|\"]#", $fileInfo['generatedFileName']))
|
||||
// bad chars in the filename
|
||||
elseif (preg_match ("#[\\\/\:\*\?\<\>\|\"]#", $fileInfo['generatedFileName']))
|
||||
{
|
||||
$this->addErrorMessage(sprintf($lang['WRONG_F_NAME'], htmlspecialchars($_FILES['file_' . $fieldNumber . '_']['name'])));
|
||||
}
|
||||
# check file extension for bad stuff
|
||||
elseif(ext_check_safe($_FILES['file_' . $fieldNumber . '_']['name']) == false)
|
||||
// check file extension for bad stuff
|
||||
elseif (ext_check_safe($_FILES['file_' . $fieldNumber . '_']['name']) == false)
|
||||
{
|
||||
$this->addErrorMessage(sprintf($lang['WRONG_F_NAME'], htmlspecialchars($_FILES['file_' . $fieldNumber . '_']['name'])));
|
||||
}
|
||||
# check the mime-type for the file
|
||||
elseif(check_mime_type($_FILES['file_' . $fieldNumber . '_']['type'], $fileInfo['fileExtension'], $_FILES['file_' . $fieldNumber . '_']['tmp_name']) == false)
|
||||
// check the mime-type for the file
|
||||
elseif (check_mime_type($_FILES['file_' . $fieldNumber . '_']['type'], $fileInfo['fileExtension'], $_FILES['file_' . $fieldNumber . '_']['tmp_name']) == false)
|
||||
{
|
||||
$this->addErrorMessage(sprintf($lang['NOT_SAFE_FILE'], htmlspecialchars($_FILES['file_' . $fieldNumber . '_']['name'])));
|
||||
}
|
||||
# check file size
|
||||
elseif($this->getAllowedFileExtensions()[$fileInfo['fileExtension']] > 0 && $fileInfo['fileSize'] >= $this->getAllowedFileExtensions()[$fileInfo['fileExtension']])
|
||||
// check file size
|
||||
elseif ($this->getAllowedFileExtensions()[$fileInfo['fileExtension']] > 0 && $fileInfo['fileSize'] >= $this->getAllowedFileExtensions()[$fileInfo['fileExtension']])
|
||||
{
|
||||
$this->addErrorMessage(sprintf(
|
||||
$lang['SIZE_F_BIG'],
|
||||
@@ -660,13 +671,13 @@ class defaultUploader implements KleejaUploader
|
||||
readable_size($this->getAllowedFileExtensions()[$fileInfo['fileExtension']]))
|
||||
);
|
||||
}
|
||||
# no errors, so upload it
|
||||
// no errors, so upload it
|
||||
else
|
||||
{
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('defaultUploader_uploadTypeFile_2nd', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
# now, upload the file
|
||||
$file = move_uploaded_file($_FILES['file_' . $fieldNumber . '_']['tmp_name'], $current_uploading_folder . "/" . $fileInfo['generatedFileName']);
|
||||
// now, upload the file
|
||||
$file = move_uploaded_file($_FILES['file_' . $fieldNumber . '_']['tmp_name'], $current_uploading_folder . '/' . $fileInfo['generatedFileName']);
|
||||
|
||||
if ($file)
|
||||
{
|
||||
@@ -674,7 +685,7 @@ class defaultUploader implements KleejaUploader
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addErrorMessage(sprintf($lang['CANT_UPLAOD'], $fileInfo['originalFileName']));
|
||||
$this->addErrorMessage(sprintf($lang['CANT_UPLAOD'], $fileInfo['originalFileName']));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -686,43 +697,43 @@ class defaultUploader implements KleejaUploader
|
||||
* @param $current_uploading_folder
|
||||
* @param $current_user_id
|
||||
*/
|
||||
function uploadTypeUrl($fieldNumber, $current_uploading_folder, $current_user_id)
|
||||
public function uploadTypeUrl($fieldNumber, $current_uploading_folder, $current_user_id)
|
||||
{
|
||||
global $config, $lang;
|
||||
|
||||
$fileInfo = array(
|
||||
$fileInfo = [
|
||||
'saveToFolder',
|
||||
'originalFileName',
|
||||
'generatedFileName',
|
||||
'fileSize',
|
||||
'currentUserId',
|
||||
'fileExtension'
|
||||
);
|
||||
];
|
||||
|
||||
|
||||
$fileInfo['saveToFolder'] = $current_uploading_folder;
|
||||
$fileInfo['saveToFolder'] = $current_uploading_folder;
|
||||
$fileInfo['currentUserId'] = $current_user_id;
|
||||
|
||||
|
||||
if(p('file_' . $fieldNumber . '_') == '' || p('file_' . $fieldNumber . '_') == $lang['PAST_URL_HERE'])
|
||||
if (p('file_' . $fieldNumber . '_') == '' || p('file_' . $fieldNumber . '_') == $lang['PAST_URL_HERE'])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
# get file name
|
||||
// get file name
|
||||
$fileInfo['originalFileName'] = basename(p('file_' . $fieldNumber . '_'));
|
||||
|
||||
|
||||
# file extension, type
|
||||
$fileExtensions = array_map('strtolower', explode(".", $fileInfo['originalFileName']));
|
||||
// file extension, type
|
||||
$fileExtensions = array_map('strtolower', explode('.', $fileInfo['originalFileName']));
|
||||
|
||||
|
||||
if(sizeof($fileExtensions) > 1 && in_array($fileExtensions[sizeof($fileExtensions)-1], array('html', 'php', 'html')))
|
||||
if (sizeof($fileExtensions) > 1 && in_array($fileExtensions[sizeof($fileExtensions)-1], ['html', 'php', 'html']))
|
||||
{
|
||||
$fileInfo['fileExtension'] = strtolower($fileExtensions[sizeof($fileExtensions)-2]);
|
||||
}
|
||||
else if(sizeof($fileExtensions) > 0)
|
||||
elseif (sizeof($fileExtensions) > 0)
|
||||
{
|
||||
$fileInfo['fileExtension'] = strtolower($fileExtensions[sizeof($fileExtensions)-1]);
|
||||
}
|
||||
@@ -732,7 +743,7 @@ class defaultUploader implements KleejaUploader
|
||||
}
|
||||
|
||||
|
||||
# change to another filename depend on kleeja settings
|
||||
// change to another filename depend on kleeja settings
|
||||
$fileInfo['generatedFileName'] = change_filename_decoding($fileInfo['originalFileName'], $fieldNumber, $fileInfo['fileExtension']);
|
||||
$fileInfo['generatedFileName'] = change_filename_templates(trim($config['prefixname']) . $fileInfo['generatedFileName']);
|
||||
|
||||
@@ -740,45 +751,44 @@ class defaultUploader implements KleejaUploader
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('defaultUploader_uploadTypeUrl_1st', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
#forbbiden type ? quit it
|
||||
if(!in_array(strtolower($fileInfo['fileExtension']), array_keys($this->getAllowedFileExtensions())))
|
||||
//forbbiden type ? quit it
|
||||
if (! in_array(strtolower($fileInfo['fileExtension']), array_keys($this->getAllowedFileExtensions())))
|
||||
{
|
||||
if($current_user_id == '-1')
|
||||
if ($current_user_id == '-1')
|
||||
{
|
||||
$this->addErrorMessage(
|
||||
sprintf($lang['FORBID_EXT'], $fileInfo['fileExtension']) .
|
||||
'<br> <a href="' . ($config['mod_writer'] ? "register.html" : "ucp.php?go=register") . '">' .
|
||||
'<br> <a href="' . ($config['mod_writer'] ? 'register.html' : 'ucp.php?go=register') . '">' .
|
||||
$lang['REGISTER'] . '</a>'
|
||||
);
|
||||
}
|
||||
# a member
|
||||
// a member
|
||||
else
|
||||
{
|
||||
$this->addErrorMessage(sprintf($lang['FORBID_EXT'], $fileInfo['fileExtension']));
|
||||
}
|
||||
}
|
||||
# file exists before ? quit it
|
||||
elseif(file_exists($current_uploading_folder . '/' . $fileInfo['generatedFileName']))
|
||||
// file exists before ? quit it
|
||||
elseif (file_exists($current_uploading_folder . '/' . $fileInfo['generatedFileName']))
|
||||
{
|
||||
$this->addErrorMessage(sprintf($lang['SAME_FILE_EXIST'], htmlspecialchars($fileInfo['generatedFileName'])));
|
||||
}
|
||||
# no errors, ok, lets upload now
|
||||
// no errors, ok, lets upload now
|
||||
else
|
||||
{
|
||||
|
||||
is_array($plugin_run_result = Plugins::getInstance()->run('defaultUploader_uploadTypeUrl_2nd', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
|
||||
|
||||
|
||||
#no prefix ? http or even ftp, then add one
|
||||
if(!in_array(strtolower(substr(p('file_' . $fieldNumber . '_'), 0, 4)), array('http', 'ftp:')))
|
||||
//no prefix ? http or even ftp, then add one
|
||||
if (! in_array(strtolower(substr(p('file_' . $fieldNumber . '_'), 0, 4)), ['http', 'ftp:']))
|
||||
{
|
||||
$_POST['file_' . $fieldNumber . '_'] = 'http://' . p('file_' . $fieldNumber . '_');
|
||||
}
|
||||
|
||||
#get size, if big quit it
|
||||
//get size, if big quit it
|
||||
$fileInfo['fileSize'] = get_remote_file_size(p('file_' . $fieldNumber . '_'));
|
||||
|
||||
if($this->getAllowedFileExtensions()[$fileInfo['fileExtension']] > 0 && $fileInfo['fileSize'] >= $this->getAllowedFileExtensions()[$fileInfo['fileExtension']])
|
||||
if ($this->getAllowedFileExtensions()[$fileInfo['fileExtension']] > 0 && $fileInfo['fileSize'] >= $this->getAllowedFileExtensions()[$fileInfo['fileExtension']])
|
||||
{
|
||||
$this->addErrorMessage(sprintf(
|
||||
$lang['SIZE_F_BIG'],
|
||||
@@ -788,17 +798,17 @@ class defaultUploader implements KleejaUploader
|
||||
}
|
||||
else
|
||||
{
|
||||
#get remote data, if no data quit it
|
||||
//get remote data, if no data quit it
|
||||
$data = fetch_remote_file(
|
||||
p('file_' . $fieldNumber . '_'),
|
||||
$current_uploading_folder . "/" . $fileInfo['generatedFileName'],
|
||||
$current_uploading_folder . '/' . $fileInfo['generatedFileName'],
|
||||
15,
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
if($data === false)
|
||||
if ($data === false)
|
||||
{
|
||||
$this->addErrorMessage($lang['URL_CANT_GET']);
|
||||
}
|
||||
|
||||
984
includes/usr.php
984
includes/usr.php
File diff suppressed because it is too large
Load Diff
@@ -9,9 +9,9 @@
|
||||
|
||||
|
||||
//no for directly open
|
||||
if (!defined('IN_COMMON'))
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,3 @@ if (!defined('IN_COMMON'))
|
||||
define('KLEEJA_VERSION', '3.0.2');
|
||||
|
||||
define('KLEEJA_DB_VERSION', '9');
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user