function make_images($file_data, $module, $image_sizes, $create_path, $delete_files) { make_folder($create_path); if ($delete_files) { delete_files($create_path); } $raw_path = config_item('uploads_folder') . $file_data['file_name']; // Loop through sizes... foreach ($image_sizes as $size) { // If upload width / heights differ from config if ($file_data['image_width'] != config_item($module . '_images_' . $size . '_width') || $file_data['image_height'] != config_item($module . '_images_' . $size . '_height')) { $this->make_cropped($file_data, $module, $create_path, $size); } } return true; }
/** * initiating uploading class * @return void */ public function __construct() { global $config; #local folder to upload to $this->uploading_folder = trim($config['foldername']); if ($this->uploading_folder == '') { $this->uploading_folder = 'uploads'; } #if local, check for current folder is it exists? if ($this->uploading_type == 'local' && !file_exists($this->uploading_folder)) { make_folder($this->uploading_folder); } # check the live-exts-folder, live exts plugin codes if (!empty($config['imagefolderexts']) && !file_exists($config['imagefolder'])) { make_folder($config['imagefolder']); } # get default thumb dimensions if (strpos($config['thmb_dims'], '*') !== false) { list($this->thumb_dimensions['width'], $this->thumb_dimensions['height']) = array_map('intval', explode('*', $config['thmb_dims'])); } }
function upload_profile_picture_post() { if ($upload = $this->social_tools->get_upload($this->input->post('upload_id'))) { // If File Exists if ($upload->file_hash == $this->input->post('file_hash')) { // Delete Expectation $this->social_tools->delete_upload($this->input->post('upload_id')); // Upload Settings $create_path = config_item('users_images_folder') . $this->get('id') . '/'; $config['upload_path'] = $create_path; $config['allowed_types'] = config_item('users_images_formats'); $config['overwrite'] = true; $config['max_size'] = config_item('users_images_max_size'); $config['max_width'] = config_item('users_images_max_dimensions'); $config['max_height'] = config_item('users_images_max_dimensions'); $this->load->helper('file'); $this->load->library('upload', $config); // Delete / Make Folder delete_files($create_path); make_folder($create_path); // Upload if (!$this->upload->do_upload('file')) { $message = array('status' => 'error', 'message' => $this->upload->display_errors('', ''), 'upload_info' => $this->upload->data()); } else { // Image Model $this->load->model('image_model'); // Upload Data $file_data = $this->upload->data(); // Update DB & Userdata Image $this->social_auth->update_user($this->get('id'), array('image' => $file_data['file_name'])); $this->session->set_userdata('image', $file_data['file_name']); // Make Thumb $this->image_model->make_thumbnail($create_path, $file_data['file_name'], 'users', 'medium'); $this->image_model->make_thumbnail($create_path, $file_data['file_name'], 'users', 'small'); $message = array('status' => 'success', 'message' => 'Profile picture updated', 'upload_info' => $file_data); } } else { $message = array('status' => 'error', 'message' => 'No image file was sent or the hash was bad'); } } else { $message = array('status' => 'error', 'message' => 'No matching upload token was found'); } $this->response($message, 200); }
/** * Create Widgets * @return bool Always returns true * @todo Make this return more meaningful data * @todo document properly */ function create_widgets($widgets) { if ($widgets == 'TRUE') { // Widgets Config $config_template = $this->template_path . 'config/widgets.php'; $config_data = $this->replace_tags($config_template); file_put_contents($this->install_path . 'config/widgets.php', $config_data); // Widget Template make_folder($this->install_path . 'views/widgets/'); $widget_template = $this->template_path . 'views/widgets/recent_data.php'; $widget_data = $this->replace_tags($widget_template); file_put_contents($this->install_path . 'views/widgets/recent_data.php', $widget_data); } return TRUE; }
function create_folders($app_folders) { foreach ($app_folders as $folder) { make_folder(config_item('uploads_folder') . $folder); } return TRUE; }
} else { if (in_array($ext, $img_ext)) { $isimage = true; } else { $isimage = false; } if ($savedirectorytype_attachment == 'onedir') { $savepath = ""; } elseif ($savedirectorytype_attachment == 'monthdir') { $savepath = date("Ym") . "/"; } elseif ($savedirectorytype_attachment == 'daydir') { $savepath = date("Ymd") . "/"; } $filemd5 = md5_file($file['tmp_name']); $filename = date("YmdHis") . $filemd5; $file_location = make_folder($savedirectory_attachment . "/", $savepath) . $filename; $db_file_location = $savepath . $filename; $abandonorig = false; $hasthumb = false; $width = 0; if ($isimage) { $maycreatethumb = false; $stop = false; $imagesize = getimagesize($file['tmp_name']); if ($imagesize) { $height = $imagesize[1]; $width = $imagesize[0]; $it = $imagesize[2]; if ($it != 1 || !$Attach->is_gif_ani($file['tmp_name'])) { //if it is an animation GIF, stop creating thumbnail and adding watermark if ($thumbnailtype_attachment != 'no') {
$anon = $CURUSER["username"]; } //$file["name"] = str_replace("", "_", htmlspecialchars("$file[name]")); //$file["name"] = preg_replace('/[^a-z0-9_\-\.]/i', '_', $file[name]); //make_folder($SUBSPATH."/",$detail_torrent_id); //stderr("",$file["name"]); $r = sql_query("SELECT lang_name from language WHERE sub_lang=1 AND id = " . sqlesc($lang_id)) or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($r); $filename = $file["name"]; $added = date("Y-m-d H:i:s"); $uppedby = $CURUSER["id"]; $size = $file["size"]; sql_query("INSERT INTO subs (torrent_id, lang_id, title, filename, added, uppedby, anonymous, size, ext) VALUES (" . implode(",", array_map("sqlesc", array($torrent_id, $lang_id, $title, $filename, $added, $uppedby, $anonymous, $size, $ext))) . ")") or sqlerr(); $id = mysql_insert_id(); //stderr("",make_folder($SUBSPATH."/",$torrent_id). "/" . $id . "." .$ext); if (!move_uploaded_file($file["tmp_name"], make_folder($SUBSPATH . "/", $torrent_id) . "/" . $id . "." . $ext)) { echo $lang_subtitles['std_failed_moving_file']; } KPS("+", $uploadsubtitle_bonus, $uppedby); //subtitle uploader gets bonus write_log("{$arr['lang_name']} Subtitle {$id} ({$title}) was uploaded by {$anon}"); $msg_bt = "{$arr['lang_name']} Subtitle {$id} ({$title}) was uploaded by {$anon}, Download: " . get_protocol_prefix() . "{$BASEURL}/downloadsubs.php/" . $file["name"] . ""; } if (get_user_class() >= $delownsub_class) { $delete = $_GET["delete"]; if (is_valid_id($delete)) { $r = sql_query("SELECT id,torrent_id,ext,lang_id,title,filename,uppedby,anonymous FROM subs WHERE id=" . sqlesc($delete)) or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($r) == 1) { $a = mysql_fetch_assoc($r); if (get_user_class() >= $submanage_class || $a["uppedby"] == $CURUSER["id"]) { $sure = $_GET["sure"];
/** * Processing current upload, aka 'after user click upload button to upload his files' */ function process() { global $SQL, $dbprefix, $config, $lang; ($hook = kleeja_run_hook('kljuploader_process_func')) ? eval($hook) : null; //run hook # check folder our real folder if (!file_exists($this->folder)) { if (!make_folder($this->folder)) { $this->messages[] = array($lang['CANT_DIR_CRT'], 'index_err'); } } # check the live-exts-folder, live exts plugin codes if (!empty($config['imagefolderexts']) && !file_exists($config['imagefolder'])) { if (!make_folder($config['imagefolder'])) { $this->messages[] = array($lang['CANT_DIR_CRT'], 'index_err'); } } # when uploading_type = 1, then we upload from _file input # if uploading_type = 2, then we uploading from url which is disabled by default and is buggy $uploading_type = isset($_POST['submitr']) ? 1 : (isset($_POST['submittxt']) ? 2 : false); # add your uploading_type through the hook ($hook = kleeja_run_hook('kljuploader_process_func_uploading_type')) ? eval($hook) : null; //run hook #no uploading yet, or just go to index.php, so we have make a new session if (!$uploading_type) { unset($_SESSION['FIILES_NOT_DUPLI'], $_SESSION['FIILES_NOT_DUPLI_LINKS']); } # is captcha on, and there is uploading going on if ($this->safe_code && $uploading_type) { #captcha is wrong if (!kleeja_check_captcha()) { return $this->messages[] = array($lang['WRONG_VERTY_CODE'], 'index_err'); } } # to prevent flooding, user must wait, waiting-time is grapped from Kleeja settings, admin is exceptional if (!$this->user_is_adm && user_is_flooding($this->id_user)) { return $this->messages[] = array(sprintf($lang['YOU_HAVE_TO_WAIT'], $this->id_user == '-1' ? $config['guestsectoupload'] : $config['usersectoupload']), 'index_err'); } # flooading .. if ($uploading_type == 1 && isset($_SESSION['FIILES_NOT_DUPLI'])) { for ($i = 0; $i <= $this->filesnum; $i++) { if (!empty($_SESSION['FIILES_NOT_DUPLI']['file_' . $i . '_']['name']) && !empty($_FILES['file_' . $i . '_']['name']) && $_SESSION['FIILES_NOT_DUPLI']['file_' . $i . '_']['name'] == $_FILES['file_' . $i . '_']['name']) { redirect('./'); } } } if ($uploading_type == 2 && isset($_SESSION['FIILES_NOT_DUPLI_LINKS'])) { for ($i = 0; $i <= $this->filesnum; $i++) { if (!empty($_SESSION['FIILES_NOT_DUPLI_LINKS']['file_' . $i . '_']) && !empty($_POST['file_' . $i . '_']) && trim($_POST['file_' . $i . '_']) != $lang['PAST_URL_HERE'] && trim($_SESSION['FIILES_NOT_DUPLI_LINKS']['file_' . $i . '_']) != $lang['PAST_URL_HERE'] && $_SESSION['FIILES_NOT_DUPLI_LINKS']['file_' . $i . '_'] == $_POST['file_' . $i . '_']) { redirect('./'); } } } # flooding code, making sure every ok session is cleared 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; } #now close session to let user open any other page in Kleeja @session_write_close(); # uploading process, empty check-list for now $check = false; # add your uploading_type through the hook ($hook = kleeja_run_hook('kljuploader_process_func_uploading_type_later')) ? eval($hook) : null; //run hook # do upload switch ($uploading_type) { #uploading from a _files input case 1: ($hook = kleeja_run_hook('kljuploader_process_func_uploading_type_1')) ? eval($hook) : null; //run hook # loop the uploaded files for ($i = 0; $i <= $this->filesnum; $i++) { //no file! if (empty($_FILES['file_' . $i . '_']['tmp_name'])) { continue; } # file name $this->filename = isset($_FILES['file_' . $i . '_']['name']) ? htmlspecialchars(str_replace(array(';', ','), '', $_FILES['file_' . $i . '_']['name'])) : ''; # add the file to the check-list $check .= isset($_FILES['file_' . $i . '_']['name']) ? $_FILES['file_' . $i . '_']['name'] : ''; # get the extension of file $this->typet = strtolower(array_pop(explode('.', $this->filename))); # them the size $this->sizet = !empty($_FILES['file_' . $i . '_']['size']) ? intval($_FILES['file_' . $i . '_']['size']) : null; # get the other filename, changed depend on kleeja settings $this->filename2 = change_filename_decoding($this->filename, $i, $this->typet, $this->decode); # filename templates {rand:..}, {date:..} $this->filename2 = change_filename_templates(trim($this->prefix) . $this->filename2); ($hook = kleeja_run_hook('kljuploader_process_func_uploading_type_1_loop')) ? eval($hook) : null; //run hook # file exists before? change it a little if (file_exists($this->folder . '/' . $this->filename2)) { $this->filename2 = change_filename_decoding($this->filename2, $i, $this->typet, 'exists'); } # now, let process it if (!in_array(strtolower($this->typet), array_keys($this->types))) { # guest if ($this->id_user == '-1') { $this->messages[] = array(sprintf($lang['FORBID_EXT'], $this->typet) . '<br /> <a href="' . ($config['mod_writer'] ? "register.html" : "ucp.php?go=register") . '" title="' . htmlspecialchars($lang['REGISTER']) . '">' . $lang['REGISTER'] . '</a>', 'index_err'); } else { $this->messages[] = array(sprintf($lang['FORBID_EXT'], $this->typet), 'index_err'); } } elseif (preg_match("#[\\\\/\\:\\*\\?\\<\\>\\|\"]#", $this->filename2)) { $this->messages[] = array(sprintf($lang['WRONG_F_NAME'], htmlspecialchars($_FILES['file_' . $i . '_']['name'])), 'index_err'); } elseif (ext_check_safe($_FILES['file_' . $i . '_']['name']) == false) { $this->messages[] = array(sprintf($lang['WRONG_F_NAME'], htmlspecialchars($_FILES['file_' . $i . '_']['name'])), 'index_err'); } elseif (check_mime_type($_FILES['file_' . $i . '_']['type'], in_array(strtolower($this->typet), array('gif', 'png', 'jpg', 'jpeg', 'bmp')), $_FILES['file_' . $i . '_']['tmp_name']) == false) { $this->messages[] = array(sprintf($lang['NOT_SAFE_FILE'], htmlspecialchars($_FILES['file_' . $i . '_']['name'])), 'index_err'); } elseif ($this->types[strtolower($this->typet)] > 0 && $this->sizet >= $this->types[strtolower($this->typet)]) { $this->messages[] = array(sprintf($lang['SIZE_F_BIG'], htmlspecialchars($_FILES['file_' . $i . '_']['name']), Customfile_size($this->types[strtolower($this->typet)])), 'index_err'); } else { ($hook = kleeja_run_hook('kljuploader_process_func_uploading_type_1_loop_upload')) ? 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->folder; if (in_array(strtolower($this->typet), $live_exts)) { # live-exts folder, if empty use default folder $folder_to_upload = trim($config['imagefolder']) == '' ? trim($config['foldername']) : trim($config['imagefolder']); # change to time decoding for filename if ((int) $config['imagefoldere']) { //$this->filename2 = change_filename_decoding($this->filename2, $i, $this->typet, 'time'); } } # now, upload the file $file = move_uploaded_file($_FILES['file_' . $i . '_']['tmp_name'], $folder_to_upload . "/" . $this->filename2); if ($file) { $this->saveit($this->filename2, $folder_to_upload, $this->sizet, $this->typet, $this->filename); } else { $this->messages[] = array(sprintf($lang['CANT_UPLAOD'], $this->filename2), 'index_err'); } } } #loop # well, there is no file uploaded if (!isset($check) || empty($check)) { $this->messages[] = array($lang['CHOSE_F'], 'index_err'); } break; #uploading from a url text-input #uploading from a url text-input case 2: #if not enabled, quit it if ((int) $config['www_url'] != '1') { break; } ($hook = kleeja_run_hook('kljuploader_process_func_uploading_type_2')) ? eval($hook) : null; //run hook #loop text inputs for ($i = 0; $i <= $this->filesnum; $i++) { # get file name $this->filename = isset($_POST['file_' . $i . '_']) ? basename(htmlspecialchars($_POST['file_' . $i . '_'])) : ''; //print $this->filename; # add it to the check-list $check .= isset($_POST['file_' . $i . '_']) && trim($_POST['file_' . $i . '_']) != $lang['PAST_URL_HERE'] ? $_POST['file_' . $i . '_'] : ''; # file extension, type $this->typet = explode(".", $this->filename); if (in_array($this->typet[count($this->typet) - 1], array('html', 'php', 'html'))) { $this->typet = strtolower($this->typet[count($this->typet) - 2]); } else { $this->typet = strtolower($this->typet[count($this->typet) - 1]); } # change to another filename depend on kleeja settings $this->filename2 = change_filename_decoding($this->filename, $i, $this->typet, $this->decode); $this->filename2 = change_filename_templates(trim($this->prefix) . $this->filename2); ($hook = kleeja_run_hook('kljuploader_process_func_uploading_type_2_loop')) ? eval($hook) : null; //run hook # process is begun if (empty($_POST['file_' . $i . '_']) || trim($_POST['file_' . $i . '_']) == $lang['PAST_URL_HERE']) { #if empty is not big deal, it's a multi-text-input, remember? } elseif (!in_array(strtolower($this->typet), array_keys($this->types))) { $this->messages[] = array(sprintf($lang['FORBID_EXT'], htmlspecialchars($_POST['file_' . $i . '_']), $this->typet), 'index_err'); } elseif (file_exists($this->folder . '/' . $this->filename2)) { $this->messages[] = array(sprintf($lang['SAME_FILE_EXIST'], htmlspecialchars($this->filename2)), 'index_err'); } else { ($hook = kleeja_run_hook('kljuploader_process_func_uploading_type_2_loop_upload')) ? eval($hook) : null; //run hook #if this is listed as live-ext from Kleeja settings $live_exts = explode(',', $config['imagefolderexts']); $folder_to_upload = $this->folder; if (in_array(strtolower($this->typet), $live_exts)) { # live-exts folder, if empty use default folder $folder_to_upload = trim($config['imagefolder']) == '' ? trim($config['foldername']) : trim($config['imagefolder']); # change to time decoding for filename if ((int) $config['imagefoldere']) { //$this->filename2 = change_filename_decoding($this->filename2, $i, $this->typet, 'time'); } } #no prefix ? http or even ftp, then add one if (!in_array(substr($_POST['file_' . $i . '_'], 0, 4), array('http', 'ftp:'))) { $_POST['file_' . $i . '_'] = 'http://' . $_POST['file_' . $i . '_']; } #get size, if big quit it $this->sizet = get_remote_file_size($_POST['file_' . $i . '_']); if ($this->types[strtolower($this->typet)] > 0 && $this->sizet >= $this->types[strtolower($this->typet)]) { $this->messages[] = array(sprintf($lang['SIZE_F_BIG'], htmlspecialchars($_POST['file_' . $i . '_']), Customfile_size($this->types[strtolower($this->typet)])), 'index_err'); } else { #get remote data, if no data quit it $data = fetch_remote_file($_POST['file_' . $i . '_'], $folder_to_upload . "/" . $this->filename2, 6, false, 2, true); if ($data === false) { $this->messages[] = array($lang['URL_CANT_GET'], 'index_err'); } else { $this->saveit($this->filename2, $folder_to_upload, $this->sizet, $this->typet); } } } #else } #end loop # if not file uploaded as the check-list said, then show error if (!isset($check) || empty($check)) { $this->messages[] = array($lang['CHOSE_F'], 'index_err'); } break; default: ($hook = kleeja_run_hook('kljuploader_process_switch_default_func')) ? eval($hook) : null; //run hook } #end switch }
function picture_upload_post() { if ($upload = $this->social_tools->get_upload($this->input->post('upload_id'))) { // If File Exists if ($upload->file_hash == $this->input->post('file_hash')) { // Delete Expectation $this->social_tools->delete_upload($this->input->post('upload_id')); // Upload Settings $create_path = config_item('categories_images_folder') . $this->get('id') . '/'; $config['upload_path'] = $create_path; $config['allowed_types'] = config_item('categories_images_formats'); $config['overwrite'] = true; $config['max_size'] = config_item('categories_images_max_size'); $config['max_width'] = config_item('categories_images_max_dimensions'); $config['max_height'] = config_item('categories_images_max_dimensions'); $this->load->helper('file'); $this->load->library('upload', $config); // Delete / Make Folder delete_files($create_path); make_folder($create_path); // Upload if (!$this->upload->do_upload('file')) { $message = array('status' => 'error', 'message' => $this->upload->display_errors('', '')); } else { // Load Image Model $this->load->model('image_model'); // Upload Data $file_data = $this->upload->data(); // Make Sizes $this->image_model->make_thumbnail($create_path, $file_data['file_name'], 'site', 'small'); $category = $this->social_tools->get_category($this->get('id')); $details = json_decode($category->details); $details->thumb = $file_data['file_name']; // Update if ($update = $this->social_tools->update_category($this->get('id'), array('details' => json_encode($details)), $this->oauth_user_id)) { $message = array('status' => 'success', 'message' => 'Awesome we uploaded your category image', 'thumb' => $details->thumb); } else { $message = array('status' => 'error', 'message' => 'Oops, uploaded but unable to add image to site'); } } } else { $message = array('status' => 'error', 'message' => 'No image file was sent or the hash was bad'); } } else { $message = array('status' => 'error', 'message' => 'No matching upload token was found'); } $this->response($message, 200); }
function upload_site_picture_post() { if ($upload = $this->social_tools->get_upload($this->input->post('upload_id'))) { // If File Exists if ($upload->file_hash == $this->input->post('file_hash')) { // Delete Expectation $this->social_tools->delete_upload($this->input->post('upload_id')); // Upload Settings $create_path = config_item('site_images_folder') . config_item('site_id') . '/'; $config['upload_path'] = $create_path; $config['allowed_types'] = config_item('default_images_formats'); $config['overwrite'] = true; $config['max_size'] = config_item('default_images_max_size'); $config['max_width'] = config_item('default_image_dimensions'); $config['max_height'] = config_item('default_image_dimensions'); $this->load->helper('file'); $this->load->library('upload', $config); // Make Folder if (!file_exists($create_path)) { make_folder($create_path); } // Upload if (!$this->upload->do_upload('file')) { $message = array('status' => 'error', 'message' => $this->upload->display_errors('', ''), 'upload_info' => $this->upload->data()); } else { // Image Model $this->load->model('image_model'); // Upload Data $file_data = $this->upload->data(); $this->social_igniter->update_settings('design', array($this->get('type') => $file_data['file_name'])); // Update Settings & Make Sizes for Type $this->image_model->make_thumbnail($create_path, $file_data['file_name'], 'default', 'small'); $message = array('status' => 'success', 'message' => 'Profile picture updated', 'upload_info' => $file_data); } } else { $message = array('status' => 'error', 'message' => 'No image file was sent or the hash was bad. Add some ketchup?'); } } else { $message = array('status' => 'error', 'message' => 'No matching upload token was found'); } $this->response($message, 200); }