/** * Insert the file data to database, also make other things like, * thumb, watermark and etc.. */ function saveit($filname, $folderee, $sizeee, $typeee, $real_filename = '') { global $SQL, $dbprefix, $config, $lang; #sometime cant see file after uploading.. but .. @chmod($folderee . '/' . $filname, 0644); #file data, filter them $name = (string) $SQL->escape($filname); $size = (int) $sizeee; $type = (string) strtolower($SQL->escape($typeee)); $folder = (string) $SQL->escape($folderee); $timeww = (int) time(); $user = (int) $this->id_user; $code_del = (string) md5($name . uniqid()); $ip = (string) $SQL->escape(get_ip()); $realf = (string) $SQL->escape($real_filename); $id_form = (string) $SQL->escape($config['id_form']); $is_img = in_array($type, array('png', 'gif', 'jpg', 'jpeg', 'bmp')) ? true : false; # insertion query $insert_query = array('INSERT' => 'name ,size ,time ,folder ,type,user,code_del,user_ip, real_filename, id_form', 'INTO' => "{$dbprefix}files", 'VALUES' => "'{$name}', '{$size}', '{$timeww}', '{$folder}','{$type}', '{$user}', '{$code_del}', '{$ip}', '{$realf}', '{$id_form}'"); ($hook = kleeja_run_hook('qr_insert_new_file_kljuploader')) ? eval($hook) : null; //run hook # do the query $SQL->build($insert_query); # orginal name of file to use it in the file url $this->name_for_url = $name; # inset id so it can be used in url like in do.php?id={id_for_url} $this->id_for_url = $SQL->insert_id(); # update Kleeja stats $update_query = array('UPDATE' => "{$dbprefix}stats", 'SET' => ($is_img ? "imgs=imgs+1" : "files=files+1") . ",sizes=sizes+" . $size . ""); ($hook = kleeja_run_hook('qr_update_no_files_kljuploader')) ? eval($hook) : null; //run hook $SQL->build($update_query); # inforamation of file, used for generating a url boxes $file_info = array('::ID::' => $this->id_for_url, '::NAME::' => $this->name_for_url, '::DIR::' => $folderee, '::FNAME::' => $realf); # 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::' => $code_del)))); } //show imgs if ($is_img) { $img_html_result = ''; # get default thumb dimensions $thmb_dim_w = $thmb_dim_h = 150; if (strpos($config['thmb_dims'], '*') !== false) { list($thmb_dim_w, $thmb_dim_h) = array_map('trim', explode('*', $config['thmb_dims'])); } # generate thumb now helper_thumb($folderee . '/' . $filname, strtolower($this->typet), $folderee . '/thumbs/' . $filname, $thmb_dim_w, $thmb_dim_h); if ($config['thumbs_imgs'] != 0 && in_array(strtolower($this->typet), array('png', 'jpg', 'jpeg', 'gif', 'bmp'))) { $img_html_result .= get_up_tpl_box('image_thumb', array('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(strtolower($this->typet), array('gif', 'png', 'jpg', 'jpeg', 'bmp'))) { helper_watermark($folderee . "/" . $filname, strtolower($this->typet)); } #then show, image box $img_html_result .= get_up_tpl_box('image', array('b_title' => $lang['URL_F_IMG'], 'b_bbc_title' => $lang['URL_F_BBC'], 'b_url_link' => kleeja_get_link('image', $file_info))); #add del link box to the result if there is any $img_html_result .= $extra_del; ($hook = kleeja_run_hook('saveit_func_img_res_kljuploader')) ? eval($hook) : null; //run hook $this->total++; #show success message $this->messages[] = array($lang['IMG_DOWNLAODED'] . '<br />' . $img_html_result, 'index_info'); } else { #then show other files $else_html_result = get_up_tpl_box('file', array('b_title' => $lang['URL_F_FILE'], 'b_bbc_title' => $lang['URL_F_BBC'], 'b_url_link' => kleeja_get_link('file', $file_info))); #add del link box to the result if there is any $else_html_result .= $extra_del; ($hook = kleeja_run_hook('saveit_func_else_res_kljuploader')) ? eval($hook) : null; //run hook $this->total++; #show success message $this->messages[] = array($lang['FILE_DOWNLAODED'] . '<br />' . $else_html_result, 'index_info'); } ($hook = kleeja_run_hook('saveit_func_kljuploader')) ? eval($hook) : null; //run hook # clear some variables from memory unset($filename, $folderee, $sizeee, $typeee); }
/** * Processing current upload, aka 'after user click upload button to upload his files' * * @param bool $just_check If enabled, no uploading will occur, just checking process */ public function process($just_check = false) { global $SQL, $dbprefix, $config, $lang; ($hook = kleeja_run_hook('process_func_uploading_cls')) ? eval($hook) : null; //run hook #To prevent flooding, user must wait, waiting-time is grapped from Kleeja settings, admin is exceptional if (!user_can('enter_acp') && user_is_flooding()) { return $this->errors[] = sprintf($lang['YOU_HAVE_TO_WAIT'], $config['usersectoupload']); } #if captcha enabled if ($config['safe_code']) { #captcha is wrong if (!kleeja_check_captcha()) { return $this->errors[] = $lang['WRONG_VERTY_CODE']; } } #files uploading $files = rearrange_files_input($_FILES['file']); if (empty($files)) { $this->errors[] = $lang['CHOSE_F']; } foreach ($files as $file) { #if total uploaded files reached the limit if ($this->total >= $config['filesnum']) { break; } #no file content if (empty($file['tmp_name'])) { continue; } #filename without extension? if (strpos($file['name'], '.') === false) { #TODO: try to figure out the extension for popular files $this->errors[] = sprintf($lang['WRONG_F_NAME'], htmlspecialchars($file['name'])); continue; } #clean filename, what about other language? $filename = strtr($file['name'], 'ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'); $filename = preg_replace(array('/\\s/', '/\\.[\\.]+/', '/[^\\w_\\.\\-]/'), array('_', '.', ''), strtolower($filename)); #get the extension and the right filename $file_extension = strtolower(substr($filename, strrpos($filename, '.') + 1)); $filename = str_replace('.', '_', substr($filename, 0, strrpos($filename, '.'))); #if file extension is not allowed? if (!in_array($file_extension, array_keys($this->allowed_extensions))) { $this->errors[] = sprintf($lang['FORBID_EXT'], $file_extension); continue; } #file check for first 265 content if (check_file_content($file['tmp_name']) == false && !$just_check) { $this->errors[] = sprintf($lang['NOT_SAFE_FILE'], $filename); continue; } #file size exceed allowed one if ($this->allowed_extensions[$file_extension] > 0 && $file['size'] >= $this->allowed_extensions[$file_extension]) { $this->errors[] = sprintf($lang['SIZE_F_BIG'], htmlspecialchars($file_extension['name']), readable_size($this->allowed_extensions[$file_extension])); continue; } #modify filename to apply Admin changes $filename = change_filename($file['name'], $file_extension); ($hook = kleeja_run_hook('uploading_process_func_loop_files')) ? eval($hook) : null; //run hook #if this is listed as live-ext from Kleeja settings $live_exts = array_map('trim', explode(',', $config['imagefolderexts'])); $folder_to_upload = $this->uploading_folder; if (in_array($file_extension, $live_exts)) { # live-exts folder, if empty use default folder $folder_to_upload = trim($config['imagefolder']) == '' ? trim($config['foldername']) : $this->uploading_folder; } #is this file an image? $is_img = in_array($file_extension, array('png', 'gif', 'jpg', 'jpeg')) ? true : false; #now upload $upload_result = move_uploaded_file($file['tmp_name'], $folder_to_upload . '/' . $filename); #if uploading went ok if ($upload_result && !$just_check) { #sometime can nott see the file after uploading without this fix @chmod($folder . '/' . $filename, 0644); #generate delete code $delete_code = md5($filename . uniqid()); #insert to the DB $insert_id = $this->add_to_database($filename, $folder_to_upload, $file['size'], $file_extension, $file['name'], $delete_code); #if insertion goes bad, rollback, delete the file and show error if (!$insert_id) { @unlink($folder . '/' . $filname); $this->errors[] = sprintf($lang['CANT_UPLAOD'], $filename); continue; } # inforamation of file, used for generating a url boxes $file_info = array('::ID::' => $insert_id, '::NAME::' => $filename, '::DIR::' => $folder_to_upload, '::FNAME::' => $file['name'], '::EXT::' => $file_extension, '::CODE::' => $delete_code); #if image if ($is_img) { # generate thumb always create_thumb($folder_to_upload . '/' . $filename, $file_extension, $folder_to_upload . '/thumbs/' . $filename, $this->thumb_dimensions['width'], $this->thumb_dimensions['height']); #show thumb if enabled if ($config['thumbs_imgs']) { $this->results[$insert_id]['thumb'] = kleeja_get_link('thumb', $file_info); } #if watermark enabled if ($config['write_imgs']) { create_watermark($folder_to_upload . '/' . $filename, $file_extension); } $this->results[$insert_id]['image'] = kleeja_get_link('image', $file_info); } else { $this->results[$insert_id]['file'] = kleeja_get_link('file', $file_info); } #if delete code is enabled to be displayed if ($config['del_url_file']) { $this->results[$insert_id]['delete_code'] = kleeja_get_link('del', $file_info); } #uploaded files increment++ $this->total++; } else { $this->errors[] = sprintf($lang['CANT_UPLAOD'], $filename); } } #end-foreach #total files equal zero, then show a message to tell user to select files if ($this->total == 0 && !sizeof($this->errors)) { $this->errors[] = $lang['CHOSE_F']; } }
function saveit($filname, $folderee, $sizeee, $typeee, $real_filename = '') { global $SQL, $dbprefix, $config, $lang; // sometime cant see file after uploading.. but .. @chmod($folderee . '/' . $filname, 0644); //0644 $name = (string) $SQL->escape($filname); $size = (int) $sizeee; $type = (string) strtolower($SQL->escape($typeee)); $folder = (string) $SQL->escape($folderee); $timeww = (int) time(); $user = (int) $this->id_user; $code_del = (string) md5(time()); $ip = get_ip(); $realf = (string) $SQL->escape($real_filename); $insert_query = array('INSERT' => '`name` ,`size` ,`time` ,`folder` ,`type`,`user`,`code_del`,`user_ip`, `real_filename`', 'INTO' => "`{$dbprefix}files`", 'VALUES' => "'{$name}', '{$size}', '{$timeww}', '{$folder}','{$type}', '{$user}', '{$code_del}', '{$ip}', '{$realf}'"); ($hook = kleeja_run_hook('qr_insert_new_file_kljuploader')) ? eval($hook) : null; //run hook $SQL->build($insert_query); $this->name_for_url = $name; $this->id_for_url = $SQL->insert_id(); //calculate stats ..s $update_query = array('UPDATE' => "{$dbprefix}stats", 'SET' => "`files`=files+1,`sizes`=sizes+" . $size . ",`last_file`='" . $folder . "/" . $name . "'"); ($hook = kleeja_run_hook('qr_update_no_files_kljuploader')) ? eval($hook) : null; //run hook $SQL->build($update_query); //delete cache of stats ! delete_cache('data_stats'); //inforantion of file $file_info = array('::ID::' => $this->id_for_url, '::NAME::' => $this->name_for_url, '::DIR::' => $folderee, '::FNAME::' => $realf); //show del code link $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::' => $code_del)))); } //show imgs if (in_array(strtolower($this->typet), array('png', 'gif', 'jpg', 'jpeg', 'tif', 'tiff'))) { //make thumbs $img_html_result = ''; if ($config['thumbs_imgs'] != 0 && in_array(strtolower($this->typet), array('png', 'jpg', 'jpeg', 'gif'))) { list($thmb_dim_w, $thmb_dim_h) = @explode('*', $config['thmb_dims']); $this->createthumb($folderee . '/' . $filname, strtolower($this->typet), $folderee . '/thumbs/' . $filname, $thmb_dim_w, $thmb_dim_h); $img_html_result .= get_up_tpl_box('image_thumb', array('b_title' => $lang['URL_F_THMB'], 'b_url_link' => kleeja_get_link('image', $file_info), 'b_img_link' => kleeja_get_link('thumb', $file_info))); } //write on image if ($config['write_imgs'] != 0 && in_array(strtolower($this->typet), array('gif', 'png', 'jpg', 'jpeg'))) { $this->watermark($folderee . "/" . $filname, strtolower($this->typet)); } //then show $img_html_result .= get_up_tpl_box('image', array('b_title' => $lang['URL_F_IMG'], 'b_bbc_title' => $lang['URL_F_BBC'], 'b_url_link' => kleeja_get_link('image', $file_info))); $img_html_result .= $extra_del; ($hook = kleeja_run_hook('saveit_func_img_res_kljuploader')) ? eval($hook) : null; //run hook $this->total++; $this->errs[] = array($lang['IMG_DOWNLAODED'] . '<br />' . $img_html_result, 'index_info'); } else { //then show other files $else_html_result = get_up_tpl_box('file', array('b_title' => $lang['URL_F_FILE'], 'b_bbc_title' => $lang['URL_F_BBC'], 'b_url_link' => kleeja_get_link('file', $file_info))); $else_html_result .= $extra_del; ($hook = kleeja_run_hook('saveit_func_else_res_kljuploader')) ? eval($hook) : null; //run hook $this->total++; $this->errs[] = array($lang['FILE_DOWNLAODED'] . '<br />' . $else_html_result, 'index_info'); } ($hook = kleeja_run_hook('saveit_func_kljuploader')) ? eval($hook) : null; //run hook if (isset($_POST['submitr'])) { if (isset($_SESSION['FIILES_NOT_DUPLI'])) { unset($_SESSION['FIILES_NOT_DUPLI']); } $_SESSION['FIILES_NOT_DUPLI'] = $_FILES; } elseif (isset($_POST['submittxt'])) { if (isset($_SESSION['FIILES_NOT_DUPLI_LINKS'])) { unset($_SESSION['FIILES_NOT_DUPLI_LINKS']); } $_SESSION['FIILES_NOT_DUPLI_LINKS'] = $_POST; } unset($filename, $folderee, $sizeee, $typeee); //unset ($_SESSION['NO_UPLOADING_YET']); }
: <?php echo kleeja_date($file['time']); ?> "> <img src="<?php echo kleeja_get_link('thumb', $file); ?> " /> </a> <?php } else { ?> <div class="filebox" style="background-image:url(images/filetypes/file.png)"> <div class="this_file"> <a href="<?php echo kleeja_get_link('file', $file); ?> " target="_blank"><?php echo shorten_text($file['real_filename']); ?> </a> <div class="fileinfo"> <span><?php echo $lang['FILEUPS']; ?> : <?php echo $file['uploads']; ?> </span> <span><?php
$action = "ucp.php?go=filecp&page={$currentPage}"; $total_pages = $Pager->getTotalPages(); //now, there is no result $no_results = false; if ($nums_rows != 0) { $query['LIMIT'] = "{$start}, {$perpage}"; ($hook = kleeja_run_hook('qr_select_files_in_filecp')) ? eval($hook) : null; //run hook $result = $SQL->build($query); $sizes = $num = 0; $i = $currentPage * $perpage - $perpage; while ($row = $SQL->fetch_array($result)) { $del[$row['id']] = isset($_POST['del_' . $row['id']]) ? $_POST['del_' . $row['id']] : ''; $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', 'tiff', 'tif')) ? true : false; $url = $is_image ? kleeja_get_link('image', $file_info) : kleeja_get_link('file', $file_info); ++$i; //make new lovely arrays !! $arr[] = array('id' => $row['id'], 'name' => '<a title="' . ($row['real_filename'] == '' ? $row['name'] : $row['real_filename']) . '" href="' . $url . '" onclick="window.open(this.href,\'_blank\');return false;">' . ($row['real_filename'] == '' ? strlen($row['name']) > 40 ? substr($row['name'], 0, 40) . '...' : $row['name'] : (strlen($row['real_filename']) > 40 ? substr($row['real_filename'], 0, 40) . '...' : $row['real_filename'])) . '</a>', 'i' => $i, 'icon_link' => file_exists('images/filetypes/' . $row['type'] . '.png') ? 'images/filetypes/' . $row['type'] . '.png' : 'images/filetypes/file.png', 'file_type' => $row['type']); //when submit !! if (isset($_POST['submit_files'])) { ($hook = kleeja_run_hook('submit_in_filecp')) ? eval($hook) : null; //run hook //check for form key if (!kleeja_check_form_key('filecp', 1800)) { kleeja_info($lang['INVALID_FORM_KEY']); } if ($del[$row['id']]) { //delete from folder .. @kleeja_unlink($row['folder'] . '/' . $row['name']); //delete thumb
$titlee = $lang['FILEUSER'] . ': ' . $user_name; #there is result ? show them if ($nums_rows != 0) { $no_results = false; $query['LIMIT'] = "{$start}, {$perpage}"; ($hook = kleeja_run_hook('qr_select_files_in_fileuser')) ? eval($hook) : null; //run hook $result = $SQL->build($query); $i = $currentPage * $perpage - $perpage; $tdnumi = $num = $files_num = $imgs_num = 0; while ($row = $SQL->fetch_array($result)) { ++$i; $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 = $is_image ? kleeja_get_link('image', $file_info) : kleeja_get_link('file', $file_info); $url_thumb = $is_image ? kleeja_get_link('thumb', $file_info) : kleeja_get_link('thumb', $file_info); $url_fileuser = $is_image ? $url : (file_exists("images/filetypes/" . $row['type'] . ".png") ? "images/filetypes/" . $row['type'] . ".png" : 'images/filetypes/file.png'); //make new lovely arrays !! $arr[] = array('id' => $row['id'], 'name_img' => $row['real_filename'] == '' ? strlen($row['name']) > 40 ? substr($row['name'], 0, 40) . '...' : $row['name'] : (strlen($row['real_filename']) > 40 ? substr($row['real_filename'], 0, 40) . '...' : $row['real_filename']), 'url_thumb_img' => '<a title="' . ($row['real_filename'] == '' ? $row['name'] : $row['real_filename']) . '" href="' . $url . '" onclick="window.open(this.href,\'_blank\');return false;"><img src="' . $url_fileuser . '" alt="' . $row['type'] . '" /></a>', 'name_file' => '<a title="' . ($row['real_filename'] == '' ? $row['name'] : $row['real_filename']) . '" href="' . $url . '" onclick="window.open(this.href,\'_blank\');return false;">' . ($row['real_filename'] == '' ? strlen($row['name']) > 40 ? substr($row['name'], 0, 40) . '...' : $row['name'] : (strlen($row['real_filename']) > 40 ? substr($row['real_filename'], 0, 40) . '...' : $row['real_filename'])) . '</a>', 'url_thumb_file' => '<a title="' . ($row['real_filename'] == '' ? $row['name'] : $row['real_filename']) . '" href="' . $url . '" onclick="window.open(this.href,\'_blank\');return false;"><img src="' . $url_fileuser . '" alt="' . $row['type'] . '" /></a>', 'file_type' => $row['type'], 'uploads' => $row['uploads'], 'tdnum' => $tdnumi == 0 ? '<ul>' : '', 'tdnum2' => $tdnumi == 4 ? '</ul>' : '', 'href' => $url, 'size' => Customfile_size($row['size']), 'time' => !empty($row['time']) ? kleeja_date($row['time']) : '...', 'thumb_link' => $is_image ? $url_thumb : $url_fileuser, 'is_image' => $is_image); $tdnumi = $tdnumi == 2 ? 0 : $tdnumi + 1; if (isset($_POST['submit_files']) && $user_himself) { ($hook = kleeja_run_hook('submit_in_fileuser')) ? eval($hook) : null; //run hook //check for form key if (!kleeja_check_form_key('fileuser', 1800)) { kleeja_info($lang['INVALID_FORM_KEY']); } if ($_POST['del_' . $row['id']]) { //delete from folder .. @kleeja_unlink($row['folder'] . '/' . $row['name']); //delete thumb