0, 'download_user' => fusion_get_userdata("user_id"), 'download_homepage' => '', 'download_title' => '', 'download_cat' => 0, 'download_description_short' => '', 'download_description' => '', 'download_keywords' => '', 'download_image_thumb' => '', 'download_url' => '', 'download_file' => '', 'download_license' => '', 'download_copyright' => '', 'download_os' => '', 'download_version' => '', 'download_filesize' => '', 'download_visibility' => 0, 'download_allow_comments' => 0, 'download_allow_ratings' => 0, 'download_datestamp' => '' ]; /* Delete Screenshot, Delete Files */ if ((isset($_GET['action']) && $_GET['action'] == "delete") && (isset($_GET['download_id']) && isnum($_GET['download_id']))) { $result = dbquery("SELECT download_file, download_image, download_image_thumb FROM ".DB_DOWNLOADS." WHERE download_id='".$_GET['download_id']."'"); if (dbrows($result)) { $data = dbarray($result); if (!empty($data['download_file']) && file_exists(DOWNLOADS.$data['download_file'])) { @unlink(DOWNLOADS.$data['download_file']); } if (!empty($data['download_image']) && file_exists(DOWNLOADS."images/".$data['download_image'])) { @unlink(DOWNLOADS."images/".$data['download_image']); } if (!empty($data['download_image_thumb']) && file_exists(DOWNLOADS."images/".$data['download_image_thumb'])) { @unlink(DOWNLOADS."images/".$data['download_image_thumb']); } $result = dbquery("DELETE FROM ".DB_DOWNLOADS." WHERE download_id='".$_GET['download_id']."'"); } addNotice("success", $locale['download_0102']); redirect(FUSION_SELF.$aidlink."&download_cat_id=".intval($_GET['download_cat_id'])); } /* Delete File */ if (isset($_POST['del_upload']) && isnum($_POST['del_upload'])) { $delete_query = "SELECT * FROM ".DB_DOWNLOADS." WHERE download_id='".intval($_POST['del_upload'])."'"; $result2 = dbquery($delete_query); if (dbrows($result2) > 0) { $data2 = dbarray($result2); if (!empty($data2['download_file']) && file_exists(DOWNLOADS.'files/'.$data2['download_file'])) { @unlink(DOWNLOADS.'files/'.$data2['download_file']); } $data2['download_file'] = ""; dbquery_insert(DB_DOWNLOADS, $data2, 'update'); redirect(FUSION_REQUEST); } } /* save */ if (isset($_POST['save_download'])) { $data = [ 'download_id' => form_sanitizer($_POST['download_id'], '0', 'download_id'), 'download_user' => form_sanitizer($_POST['download_user'], "", "download_user"), 'download_homepage' => form_sanitizer($_POST['download_homepage'], '', 'download_homepage'), 'download_title' => form_sanitizer($_POST['download_title'], '', 'download_title'), 'download_cat' => form_sanitizer($_POST['download_cat'], '0', 'download_cat'), 'download_description_short' => form_sanitizer($_POST['download_description_short'], '', 'download_description_short'), 'download_description' => form_sanitizer($_POST['download_description'], '', 'download_description'), 'download_keywords' => form_sanitizer($_POST['download_keywords'], '', 'download_keywords'), 'download_image' => isset($_POST['download_image']) ? form_sanitizer($_POST['download_image'], '', 'download_image') : '', 'download_image_thumb' => isset($_POST['download_image_thumb']) ? form_sanitizer($_POST['download_image_thumb'], '', 'download_image_thumb') : '', "download_url" => '', 'download_file' => isset($_POST['download_file']) ? form_sanitizer($_POST['download_file'], '', 'download_file') : '', 'download_license' => form_sanitizer($_POST['download_license'], '', 'download_license'), 'download_copyright' => form_sanitizer($_POST['download_copyright'], '', 'download_copyright'), 'download_os' => form_sanitizer($_POST['download_os'], '', 'download_os'), 'download_version' => form_sanitizer($_POST['download_version'], '', 'download_version'), 'download_filesize' => form_sanitizer($_POST['download_filesize'], '', 'download_filesize'), 'download_visibility' => form_sanitizer($_POST['download_visibility'], '0', 'download_visibility'), 'download_allow_comments' => isset($_POST['download_allow_comments']) ? 1 : 0, 'download_allow_ratings' => isset($_POST['download_allow_ratings']) ? 1 : 0, 'download_datestamp' => isset($_POST['update_datestamp']) || empty($_POST['download_datestamp']) ? TIME : $_POST['download_datestamp'], ]; /** Bugs with having Link and File together -- File will take precedence **/ if (\defender::safe() && !empty($_FILES['download_file']['name']) && is_uploaded_file($_FILES['download_file']['tmp_name'])) { $upload = form_sanitizer($_FILES['download_file'], '', 'download_file'); if (empty($upload['error'])) { $data['download_file'] = !empty($upload['target_file']) ? $upload['target_file'] : $upload['name']; if (isset($_POST['calc_upload'])) { $data['download_filesize'] = parsebytesize($_FILES['download_file']['size']); } } } else if (!empty($_POST['download_url']) && empty($data['download_file'])) { $data['download_url'] = form_sanitizer($_POST['download_url'], "", "download_url"); $data['download_file'] = ''; } else if (empty($data['download_file']) && empty($data['download_url'])) { \defender::stop(); addNotice('danger', $locale['download_0111']); } /** * Image Section */ if (\defender::safe() && isset($_POST['del_image']) && isset($_GET['download_id']) && isnum($_GET['download_id'])) { $result = dbquery("SELECT download_image, download_image_thumb FROM ".DB_DOWNLOADS." WHERE download_id='".$_GET['download_id']."'"); if (dbrows($result)) { $data += dbarray($result); if (!empty($data['download_image']) && file_exists(DOWNLOADS."images/".$data['download_image'])) { @unlink(DOWNLOADS."images/".$data['download_image']); } if (!empty($data['download_image_thumb']) && file_exists(DOWNLOADS."images/".$data['download_image_thumb'])) { @unlink(DOWNLOADS."images/".$data['download_image_thumb']); } } $data['download_image'] = ''; $data['download_image_thumb'] = ''; } else if (defender::safe() && !empty($_FILES['download_image']['name']) && is_uploaded_file($_FILES['download_image']['tmp_name'])) { $upload = form_sanitizer($_FILES['download_image'], '', 'download_image'); if (empty($upload['error'])) { $data['download_image'] = !empty($upload['image_name']) ? $upload['image_name'] : ''; $data['download_image_thumb'] = !empty($upload['thumb1_name']) ? $upload['thumb1_name'] : ''; } } if (dbcount("(download_id)", DB_DOWNLOADS, "download_id='".$data['download_id']."'")) { dbquery_insert(DB_DOWNLOADS, $data, 'update'); if (\defender::safe()) { addNotice("success", $locale['download_0101']); redirect(FUSION_SELF.$aidlink); } } else { dbquery_insert(DB_DOWNLOADS, $data, 'save'); if (\defender::safe()) { addNotice("success", $locale['download_0100']); redirect(FUSION_SELF.$aidlink); } } } if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_GET['download_id']) && isnum($_GET['download_id']))) { $result = dbquery("SELECT * FROM ".DB_DOWNLOADS." WHERE download_id='".intval($_GET['download_id'])."'"); if (dbrows($result)) { $data = dbarray($result); } else { redirect(FUSION_SELF.$aidlink); } } echo openform('inputform', 'post', FUSION_REQUEST, ['enctype' => 1]); echo "