mirror of
https://github.com/kleeja-official/kleeja.git
synced 2025-12-16 04:59:42 +01:00
fixes
This commit is contained in:
@@ -86,8 +86,7 @@ interface KleejaUploader
|
||||
|
||||
/**
|
||||
* here happens the magic, call this on upload submit
|
||||
* @param int $uploadType upload from files input or links
|
||||
* @return void
|
||||
*/
|
||||
public function upload($uploadType);
|
||||
public function upload();
|
||||
}
|
||||
|
||||
@@ -185,6 +185,7 @@ elseif ($current_smt == 'update2')
|
||||
$ex_folder = trim($zip->getNameIndex(0), '/');
|
||||
$zip->extractTo(PATH . 'cache/');
|
||||
$zip->close();
|
||||
|
||||
if (rename(
|
||||
PATH . "cache/{$ex_folder}",
|
||||
PATH . "cache/kleeja-{$new_version}"
|
||||
@@ -293,7 +294,6 @@ elseif ($current_smt == 'update3')
|
||||
file_get_contents($file->getPathname())
|
||||
) === false)
|
||||
{
|
||||
|
||||
if (copy($file->getPathname(), $file_path) === false)
|
||||
{
|
||||
$update_failed = true;
|
||||
|
||||
@@ -214,6 +214,8 @@ function kleeja_auth_username ($user_id)
|
||||
|
||||
/**
|
||||
* Check for correct password
|
||||
* @param mixed $password
|
||||
* @param mixed $hash
|
||||
*/
|
||||
function phpbb_check_hash($password, $hash)
|
||||
{
|
||||
@@ -229,6 +231,9 @@ function phpbb_check_hash($password, $hash)
|
||||
|
||||
/**
|
||||
* Generate salt for hash generation
|
||||
* @param mixed $input
|
||||
* @param mixed $itoa64
|
||||
* @param mixed $iteration_count_log2
|
||||
*/
|
||||
function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
|
||||
{
|
||||
@@ -246,6 +251,9 @@ function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
|
||||
|
||||
/**
|
||||
* Encode hash
|
||||
* @param mixed $input
|
||||
* @param mixed $count
|
||||
* @param mixed $itoa64
|
||||
*/
|
||||
function _hash_encode64($input, $count, &$itoa64)
|
||||
{
|
||||
@@ -289,6 +297,9 @@ function _hash_encode64($input, $count, &$itoa64)
|
||||
|
||||
/**
|
||||
* The crypt function/replacement
|
||||
* @param mixed $password
|
||||
* @param mixed $setting
|
||||
* @param mixed $itoa64
|
||||
*/
|
||||
function _hash_crypt_private($password, $setting, &$itoa64)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ class kleeja_style
|
||||
/**
|
||||
* Function to load a template file.
|
||||
* @param $template_name
|
||||
* @param null|mixed $style_path
|
||||
*/
|
||||
protected function _load_template($template_name, $style_path = null)
|
||||
{
|
||||
@@ -118,6 +119,8 @@ class kleeja_style
|
||||
|
||||
/**
|
||||
* Function to parse the Template Tags
|
||||
* @param mixed $html
|
||||
* @param mixed $template_name
|
||||
*/
|
||||
protected function _parse($html, $template_name = '')
|
||||
{
|
||||
@@ -380,6 +383,7 @@ class kleeja_style
|
||||
/**
|
||||
* change name of template to be valid
|
||||
* @param $name
|
||||
* @param null|mixed $style_path
|
||||
* @return mixed
|
||||
*/
|
||||
protected function re_name_tpl($name, $style_path = null)
|
||||
|
||||
@@ -18,6 +18,7 @@ if (! defined('IN_COMMON'))
|
||||
/**
|
||||
* checking the safety and validity of sub-extension of given file
|
||||
*
|
||||
* @param mixed $filename
|
||||
*/
|
||||
function ext_check_safe($filename)
|
||||
{
|
||||
@@ -49,6 +50,7 @@ function ext_check_safe($filename)
|
||||
|
||||
/**
|
||||
* create htaccess files for uploading folder
|
||||
* @param mixed $folder
|
||||
*/
|
||||
function generate_safety_htaccess($folder)
|
||||
{
|
||||
@@ -123,6 +125,10 @@ function make_folder($folder)
|
||||
|
||||
/**
|
||||
* Change the file name depend on given decoding type
|
||||
* @param mixed $filename
|
||||
* @param mixed $i_loop
|
||||
* @param mixed $ext
|
||||
* @param mixed $decoding_type
|
||||
*/
|
||||
function change_filename_decoding($filename, $i_loop, $ext, $decoding_type = '')
|
||||
{
|
||||
@@ -168,6 +174,7 @@ function change_filename_decoding($filename, $i_loop, $ext, $decoding_type = '')
|
||||
|
||||
/**
|
||||
* Change the file name depend on used templates {rand:..} {date:..}
|
||||
* @param mixed $filename
|
||||
*/
|
||||
function change_filename_templates($filename)
|
||||
{
|
||||
@@ -191,6 +198,9 @@ function change_filename_templates($filename)
|
||||
/**
|
||||
* check mime type of uploaded file
|
||||
* @return bool
|
||||
* @param mixed $given_file_mime
|
||||
* @param mixed $file_ext
|
||||
* @param mixed $file_path
|
||||
*/
|
||||
function check_mime_type($given_file_mime, $file_ext, $file_path)
|
||||
{
|
||||
@@ -276,6 +286,7 @@ function check_mime_type($given_file_mime, $file_ext, $file_path)
|
||||
|
||||
/**
|
||||
* to prevent flooding at uploading
|
||||
* @param mixed $user_id
|
||||
*/
|
||||
function user_is_flooding($user_id = '-1')
|
||||
{
|
||||
|
||||
@@ -19,6 +19,10 @@ if (! defined('IN_COMMON'))
|
||||
|
||||
/**
|
||||
* bring the file size from remote file; aka url
|
||||
* @param mixed $url
|
||||
* @param mixed $method
|
||||
* @param mixed $data
|
||||
* @param mixed $redirect
|
||||
*/
|
||||
function get_remote_file_size($url, $method = 'GET', $data = '', $redirect = 10)
|
||||
{
|
||||
|
||||
@@ -189,6 +189,10 @@ function helper_thumb($source_path, $ext, $dest_image, $dw, $dh)
|
||||
/**
|
||||
* generating thumb from image using Imagick
|
||||
*
|
||||
* @param mixed $x
|
||||
* @param mixed $y
|
||||
* @param mixed $cx
|
||||
* @param mixed $cy
|
||||
*/
|
||||
function scale_image_imagick($x, $y, $cx, $cy)
|
||||
{
|
||||
|
||||
@@ -328,14 +328,10 @@ class defaultUploader implements KleejaUploader
|
||||
* here happens the magic, call this on upload submit
|
||||
* @param int $uploadType upload from files input or links
|
||||
*/
|
||||
public function upload($uploadType)
|
||||
public function upload()
|
||||
{
|
||||
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
|
||||
|
||||
|
||||
//upload to this folder
|
||||
$current_uploading_folder = $config['foldername'];
|
||||
|
||||
@@ -366,15 +362,8 @@ class defaultUploader implements KleejaUploader
|
||||
return;
|
||||
}
|
||||
|
||||
//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)
|
||||
if ($captcha_enabled)
|
||||
{
|
||||
//captcha is wrong
|
||||
if (! kleeja_check_captcha())
|
||||
@@ -394,60 +383,27 @@ class defaultUploader implements KleejaUploader
|
||||
|
||||
|
||||
//detect flooding, TODO fix it or remove it
|
||||
if ($uploadType == 1 && isset($_SESSION['FIILES_NOT_DUPLI']))
|
||||
if (isset($_SESSION['FIILES_NOT_DUPLI']))
|
||||
{
|
||||
if (! empty($_SESSION['FIILES_NOT_DUPLI']) && $_SESSION['FIILES_NOT_DUPLI'] == sha1(serialize(array_column($_FILES, 'name'))))
|
||||
{
|
||||
unset($_SESSION['FIILES_NOT_DUPLI']);
|
||||
// if(!ip('ajax'))
|
||||
// {
|
||||
// redirect('./');
|
||||
// }
|
||||
|
||||
$this->addErrorMessage($lang['U_R_FLOODER']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($uploadType == 2 && isset($_SESSION['FIILES_NOT_DUPLI_LINKS']))
|
||||
{
|
||||
if ($_SESSION['FIILES_NOT_DUPLI_LINKS'] == sha1(serialize($_POST)))
|
||||
{
|
||||
unset($_SESSION['FIILES_NOT_DUPLI_LINKS']);
|
||||
|
||||
if (! ip('ajax'))
|
||||
{
|
||||
redirect('./');
|
||||
}
|
||||
|
||||
$this->addErrorMessage($lang['U_R_FLOODER']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// flooding code, making sure every ok session is cleared
|
||||
if ($uploadType == 1 && sizeof($_FILES) > 0)
|
||||
if (sizeof($_FILES) > 0)
|
||||
{
|
||||
$_SESSION['FIILES_NOT_DUPLI'] = sha1(serialize(array_column($_FILES, 'name')));
|
||||
}
|
||||
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();
|
||||
|
||||
|
||||
// do upload
|
||||
switch ($uploadType)
|
||||
{
|
||||
//uploading from a _files input
|
||||
default:
|
||||
case 1:
|
||||
|
||||
if (! empty($_FILES['file']['tmp_name']))
|
||||
{
|
||||
$_FILES['file'][0] = $_FILES['file'];
|
||||
@@ -527,28 +483,6 @@ class defaultUploader implements KleejaUploader
|
||||
$this->uploadTypeFile($i, $current_uploading_folder, $current_user_id);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
//uploading from a url text-input
|
||||
case 2:
|
||||
|
||||
//if not enabled, quit it
|
||||
if ($config['www_url'] != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//loop text inputs
|
||||
for ($i=0; $i<=$this->getUploadFieldsLimit(); $i++)
|
||||
{
|
||||
$this->uploadTypeUrl($i, $current_uploading_folder, $current_user_id);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// well, no file uploaded, ask user to choose a file before submit
|
||||
if ($this->total_uploaded_files == 0 && sizeof($this->messages) == 0)
|
||||
@@ -689,134 +623,4 @@ class defaultUploader implements KleejaUploader
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* upload a file from a URL
|
||||
* @param $fieldNumber
|
||||
* @param $current_uploading_folder
|
||||
* @param $current_user_id
|
||||
*/
|
||||
public function uploadTypeUrl($fieldNumber, $current_uploading_folder, $current_user_id)
|
||||
{
|
||||
global $config, $lang;
|
||||
|
||||
$fileInfo = [
|
||||
'saveToFolder',
|
||||
'originalFileName',
|
||||
'generatedFileName',
|
||||
'fileSize',
|
||||
'currentUserId',
|
||||
'fileExtension'
|
||||
];
|
||||
|
||||
|
||||
$fileInfo['saveToFolder'] = $current_uploading_folder;
|
||||
$fileInfo['currentUserId'] = $current_user_id;
|
||||
|
||||
|
||||
if (p('file_' . $fieldNumber . '_') == '' || p('file_' . $fieldNumber . '_') == $lang['PAST_URL_HERE'])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// get file name
|
||||
$fileInfo['originalFileName'] = basename(p('file_' . $fieldNumber . '_'));
|
||||
|
||||
|
||||
// file extension, type
|
||||
$fileExtensions = array_map('strtolower', explode('.', $fileInfo['originalFileName']));
|
||||
|
||||
|
||||
if (sizeof($fileExtensions) > 1 && in_array($fileExtensions[sizeof($fileExtensions)-1], ['html', 'php', 'html']))
|
||||
{
|
||||
$fileInfo['fileExtension'] = strtolower($fileExtensions[sizeof($fileExtensions)-2]);
|
||||
}
|
||||
elseif (sizeof($fileExtensions) > 0)
|
||||
{
|
||||
$fileInfo['fileExtension'] = strtolower($fileExtensions[sizeof($fileExtensions)-1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$fileInfo['fileExtension'] = ''; //what to do?
|
||||
}
|
||||
|
||||
|
||||
// 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']);
|
||||
|
||||
|
||||
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())))
|
||||
{
|
||||
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') . '">' .
|
||||
$lang['REGISTER'] . '</a>'
|
||||
);
|
||||
}
|
||||
// a member
|
||||
else
|
||||
{
|
||||
$this->addErrorMessage(sprintf($lang['FORBID_EXT'], $fileInfo['fileExtension']));
|
||||
}
|
||||
}
|
||||
// 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
|
||||
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)), ['http', 'ftp:']))
|
||||
{
|
||||
$_POST['file_' . $fieldNumber . '_'] = 'http://' . p('file_' . $fieldNumber . '_');
|
||||
}
|
||||
|
||||
//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']])
|
||||
{
|
||||
$this->addErrorMessage(sprintf(
|
||||
$lang['SIZE_F_BIG'],
|
||||
p('file_' . $fieldNumber . '_'),
|
||||
readable_size($this->getAllowedFileExtensions()[$fileInfo['fileExtension']])
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
//get remote data, if no data quit it
|
||||
$data = fetch_remote_file(
|
||||
p('file_' . $fieldNumber . '_'),
|
||||
$current_uploading_folder . '/' . $fileInfo['generatedFileName'],
|
||||
15,
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
if ($data === false)
|
||||
{
|
||||
$this->addErrorMessage($lang['URL_CANT_GET']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->saveToDatabase($fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,11 +58,11 @@ $uploader->setAllowedFileExtensions($d_groups[$userinfo['group_id']]['exts']);
|
||||
$uploader->setUploadFieldsLimit($config['filesnum']);
|
||||
|
||||
|
||||
$uploading_type = ip('submitr') ? 1 : (ip('submittxt') ? 2 : false);
|
||||
|
||||
if ($uploading_type)
|
||||
|
||||
if(ip('submitr'))
|
||||
{
|
||||
$uploader->upload($uploading_type);
|
||||
$uploader->upload();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,11 +43,6 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#fileUpload" role="tab">{lang.DOWNLOAD_F}</a>
|
||||
</li>
|
||||
<IF NAME="config.www_url == 1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#linkUpload" role="tab">{lang.DOWNLOAD_T}</a>
|
||||
</li>
|
||||
</IF>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-body tab-content">
|
||||
@@ -67,7 +62,7 @@
|
||||
</IF>
|
||||
|
||||
|
||||
<!-- files upload tab -->
|
||||
<!-- files upload -->
|
||||
<div class="tab-pane active" id="fileUpload" role="tabpanel">
|
||||
|
||||
<LOOP NAME=FILES_NUM_LOOP>
|
||||
@@ -92,25 +87,6 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<IF NAME="config.www_url == 1">
|
||||
<!-- links upload tab -->
|
||||
<div class="tab-pane" id="linkUpload" role="tabpanel">
|
||||
|
||||
<LOOP NAME=FILES_NUM_LOOP>
|
||||
<input class="url form-control mb-2" type="text" name="file_{{i}}_" style="{{show}}" size="70" placeholder="{lang.PAST_URL_HERE}">
|
||||
</LOOP>
|
||||
|
||||
<div>
|
||||
<br>
|
||||
<div class="agree text-muted"><small>{terms_msg}</small></div>
|
||||
<input type="submit" id="submittxt" name="submittxt" value="{lang.DOWNLOAD_T}" class="btn btn-outline-primary">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</IF>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -123,8 +99,6 @@
|
||||
<br>
|
||||
<img src="{STYLE_PATH}images/loading.gif" alt="{lang.LOADING}" />
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -145,7 +119,4 @@
|
||||
</IF>
|
||||
</div>
|
||||
</IF>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -32,14 +32,7 @@
|
||||
<li title="{lang.DOWNLOAD_F}">{lang.DOWNLOAD_F}</li>
|
||||
<!-- @First-Tab -->
|
||||
|
||||
<!-- Second-Tab -->
|
||||
<IF NAME="config.www_url">
|
||||
<li title="{lang.DOWNLOAD_T}">{lang.DOWNLOAD_T}</li>
|
||||
</IF>
|
||||
<!-- @Second-Tab -->
|
||||
|
||||
<!--you-can-add-another-tab-here-->
|
||||
|
||||
</ul>
|
||||
|
||||
<!-- First-Box -->
|
||||
@@ -57,23 +50,6 @@
|
||||
</div>
|
||||
<!-- @First-Box -->
|
||||
|
||||
<!-- Second-Box -->
|
||||
<IF NAME="config.www_url">
|
||||
<div class="tabcon" title="{lang.DOWNLOAD_T}">
|
||||
<div class="go_up">
|
||||
<!-- upload URL -->
|
||||
<LOOP NAME=FILES_NUM_LOOP>
|
||||
<input class="url" type="text" name="file_{{i}}_" style="{{show}}" size="70" value="{lang.PAST_URL_HERE}" />
|
||||
</LOOP>
|
||||
<div class="agree"><span>{terms_msg}</span></div>
|
||||
<div class="bn_up"><input type="submit" id="submittxt" name="submittxt" value="{lang.DOWNLOAD_T}" /> </div>
|
||||
<div class="clr"></div>
|
||||
<!-- @upload URL -->
|
||||
</div>
|
||||
</div>
|
||||
</IF>
|
||||
<!-- @Second-Box -->
|
||||
|
||||
<!--you-can-add-another-box-here-->
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user