/** * 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); }
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']); }