Changeset 1885 in ExiteCMS for trunk/administration/downloads.php
- Timestamp:
- 10/20/08 00:59:18 (4 years ago)
- File:
-
- 1 edited
-
trunk/administration/downloads.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/administration/downloads.php
r1530 r1885 118 118 } 119 119 120 $result = dbquery("SELECT * FROM ".$db_prefix."download_cats LIMIT 1"); 121 if (dbrows($result) != 0) { 122 $variables['cats_found'] = true; 123 if ($step == "delete") { 124 $result = dbquery("DELETE FROM ".$db_prefix."downloads WHERE download_id='$download_id'"); 125 if (dbcount("(*)", "downloads", "download_cat=$download_cat_id") == 0) { 126 redirect(FUSION_SELF.$aidlink."&cat_locale=$cat_locale"); 127 } else { 128 redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat_id&cat_locale=$cat_locale"); 129 } 130 } 131 if (isset($_POST['save_download'])) { 132 $download_title = stripinput($_POST['download_title']); 133 $download_description = addslash($_POST['download_description']); 134 $download_url = stripinput($_POST['download_url']); 135 $download_external = (isset($_POST['download_external']) && isNum($_POST['download_external'])) ? $_POST['download_external'] : 0; 136 $download_license = stripinput($_POST['download_license']); 137 $download_os = stripinput($_POST['download_os']); 138 $download_version = stripinput($_POST['download_version']); 139 $download_filesize = stripinput($_POST['download_filesize']); 140 if ($step == "edit") { 141 $download_datestamp = isset($_POST['update_datestamp']) ? ", download_datestamp='".time()."'" : ""; 142 $result = dbquery("UPDATE ".$db_prefix."downloads SET download_title='$download_title', download_description='$download_description', download_url='$download_url', download_cat='$download_cat', download_license='$download_license', download_os='$download_os', download_version='$download_version', download_filesize='$download_filesize'".$download_datestamp.",download_external='".$download_external."' WHERE download_id='$download_id'"); 143 redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat&cat_locale=$cat_locale"); 144 } else { 145 $result = dbquery("INSERT INTO ".$db_prefix."downloads (download_title, download_description, download_url, download_cat, download_license, download_os, download_version, download_filesize, download_datestamp, download_count, download_external) VALUES ('$download_title', '$download_description', '$download_url', '$download_cat', '$download_license', '$download_os', '$download_version', '$download_filesize', '".time()."', '0', '$download_external')"); 146 redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat&cat_locale=$cat_locale"); 147 } 148 } 120 $variables['cats_found'] = true; 121 if ($step == "delete") { 122 $result = dbquery("DELETE FROM ".$db_prefix."downloads WHERE download_id='$download_id'"); 123 if (dbcount("(*)", "downloads", "download_cat=$download_cat_id") == 0) { 124 redirect(FUSION_SELF.$aidlink."&cat_locale=$cat_locale"); 125 } else { 126 redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat_id&cat_locale=$cat_locale"); 127 } 128 } 129 if (isset($_POST['save_download'])) { 130 $download_title = stripinput($_POST['download_title']); 131 $download_description = addslash($_POST['download_description']); 132 $download_url = stripinput($_POST['download_url']); 133 $download_external = (isset($_POST['download_external']) && isNum($_POST['download_external'])) ? $_POST['download_external'] : 0; 134 $download_license = stripinput($_POST['download_license']); 135 $download_os = stripinput($_POST['download_os']); 136 $download_version = stripinput($_POST['download_version']); 137 $download_filesize = stripinput($_POST['download_filesize']); 149 138 if ($step == "edit") { 150 $result = dbquery("SELECT * FROM ".$db_prefix."downloads WHERE download_id='$download_id'"); 151 $data = dbarray($result); 152 $download_title = $data['download_title']; 153 $download_description = stripslashes($data['download_description']); 154 $download_url = $data['download_url']; 155 $download_license = $data['download_license']; 156 $download_os = $data['download_os']; 157 $download_version = $data['download_version']; 158 $download_filesize = $data['download_filesize']; 159 $download_external = $data['download_external']; 160 $formaction = FUSION_SELF.$aidlink."&step=edit&download_cat_id=$download_cat_id&download_id=$download_id"; 161 $title = $locale['470']; 139 $download_datestamp = isset($_POST['update_datestamp']) ? ", download_datestamp='".time()."'" : ""; 140 $result = dbquery("UPDATE ".$db_prefix."downloads SET download_title='$download_title', download_description='$download_description', download_url='$download_url', download_cat='$download_cat', download_license='$download_license', download_os='$download_os', download_version='$download_version', download_filesize='$download_filesize'".$download_datestamp.",download_external='".$download_external."' WHERE download_id='$download_id'"); 141 redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat&cat_locale=$cat_locale"); 162 142 } else { 163 $download_title = ""; 164 $download_description = ""; 165 $download_url = ""; 166 $download_license = ""; 167 $download_os = ""; 168 $download_version = ""; 169 $download_filesize = ""; 170 $download_external = 0; 171 $formaction = FUSION_SELF.$aidlink; 172 $title = $locale['471']; 173 } 174 $variables['cats'] = array(); 175 $variables['download_cats'] = array(); 176 $result2 = dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id > 0 ".($where==""?"":("AND ".$where))." ORDER BY download_cat_id*10000+download_parent"); 177 while ($data2 = dbarray($result2)) { 178 $variables['download_cats'][$data2['download_cat_id']] = $data2['download_cat_name']; 179 $data2['selected'] = ($step == "edit" && $data['download_cat'] == $data2['download_cat_id']); 180 $variables['cats'][] = $data2; 181 } 182 183 // build the download tree 184 $variables['tree'] = array(); 185 $variables['tree'][] = array('node' => 'P', 'nestlevel' => -1, 'name' => $locale['455'], 'id' => 0); 186 // Download root first 187 $result = dbquery("SELECT * FROM ".$db_prefix."downloads WHERE download_cat = '0' ORDER BY download_id DESC"); 188 if ($rows = dbrows($result)) { 189 $row = 1; 190 while ($data = dbarray($result)) { 191 $variables['tree'][] = array('node' => 'D', 'first' => ($row == 1), 'last' => ($row == $rows), 'cat_id' => 0, 'url' => $data['download_url'], 'name' => $data['download_title'], 'id' => $data['download_id']); 192 } 143 $result = dbquery("INSERT INTO ".$db_prefix."downloads (download_title, download_description, download_url, download_cat, download_license, download_os, download_version, download_filesize, download_datestamp, download_count, download_external) VALUES ('$download_title', '$download_description', '$download_url', '$download_cat', '$download_license', '$download_os', '$download_version', '$download_filesize', '".time()."', '0', '$download_external')"); 144 redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat&cat_locale=$cat_locale"); 145 } 146 } 147 if ($step == "edit") { 148 $result = dbquery("SELECT * FROM ".$db_prefix."downloads WHERE download_id='$download_id'"); 149 $data = dbarray($result); 150 $download_title = $data['download_title']; 151 $download_description = stripslashes($data['download_description']); 152 $download_url = $data['download_url']; 153 $download_license = $data['download_license']; 154 $download_os = $data['download_os']; 155 $download_version = $data['download_version']; 156 $download_filesize = $data['download_filesize']; 157 $download_external = $data['download_external']; 158 $formaction = FUSION_SELF.$aidlink."&step=edit&download_cat_id=$download_cat_id&download_id=$download_id"; 159 $title = $locale['470']; 160 } else { 161 $download_title = ""; 162 $download_description = ""; 163 $download_url = ""; 164 $download_license = ""; 165 $download_os = ""; 166 $download_version = ""; 167 $download_filesize = ""; 168 $download_external = 0; 169 $formaction = FUSION_SELF.$aidlink; 170 $title = $locale['471']; 171 } 172 $variables['cats'] = array(); 173 $variables['download_cats'] = array(); 174 $result2 = dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id > 0 ".($where==""?"":("AND ".$where))." ORDER BY download_cat_id*10000+download_parent"); 175 while ($data2 = dbarray($result2)) { 176 $variables['download_cats'][$data2['download_cat_id']] = $data2['download_cat_name']; 177 $data2['selected'] = ($step == "edit" && $data['download_cat'] == $data2['download_cat_id']); 178 $variables['cats'][] = $data2; 179 } 180 181 // build the download tree 182 $variables['tree'] = array(); 183 $variables['tree'][] = array('node' => 'P', 'nestlevel' => -1, 'name' => $locale['455'], 'id' => 0); 184 185 // Download root first 186 $result = dbquery("SELECT * FROM ".$db_prefix."downloads WHERE download_cat = '0' ORDER BY download_id DESC"); 187 if ($rows = dbrows($result)) { 188 $row = 1; 189 while ($data = dbarray($result)) { 190 $variables['tree'][] = array('node' => 'D', 'first' => ($row == 1), 'last' => ($row == $rows), 'cat_id' => 0, 'url' => $data['download_url'], 'name' => $data['download_title'], 'id' => $data['download_id']); 191 } 192 } else { 193 // no downloads in this category 194 $variables['tree'][] = array('node' => 'E', 'name' => $locale['505'], 'id' => 0); 195 } 196 // Then recurse through the download categories 197 $result = dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id > 0 ".($where==""?"":("AND ".$where))." AND download_parent = 0 ORDER BY download_datestamp DESC"); 198 while($data = dbarray($result)) { 199 recurse_dc($data['download_cat_id'], 0); 200 } 201 202 // get all downloads from the database 203 $variables['barfiles'] = array(); 204 $result = dbquery("SELECT * FROM ".$db_prefix."downloads ORDER BY download_id DESC"); 205 while($data = dbarray($result)) { 206 // skip all downloads from filtered categories 207 if (!isset($variables['download_cats'][$data['download_cat']])) continue; 208 if ($data['download_cat']) { 209 $data['download_cat_name'] = $variables['download_cats'][$data['download_cat']]; 193 210 } else { 194 // no downloads in this category 195 $variables['tree'][] = array('node' => 'E', 'name' => $locale['505'], 'id' => 0); 196 } 197 // Then recurse through the download categories 198 $result = dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id > 0 ".($where==""?"":("AND ".$where))." AND download_parent = 0 ORDER BY download_datestamp DESC"); 199 while($data = dbarray($result)) { 200 recurse_dc($data['download_cat_id'], 0); 201 } 202 203 // get all downloads from the database 204 $variables['barfiles'] = array(); 205 $result = dbquery("SELECT * FROM ".$db_prefix."downloads ORDER BY download_id DESC"); 206 while($data = dbarray($result)) { 207 // skip all downloads from filtered categories 208 if (!isset($variables['download_cats'][$data['download_cat']])) continue; 209 if ($data['download_cat']) { 210 $data['download_cat_name'] = $variables['download_cats'][$data['download_cat']]; 211 } else { 212 $data['download_cat_name'] = $locale['455']; 213 } 214 $variables['barfiles'][] = $data; 215 } 216 217 // template variables 218 $variables['step'] = $step; 219 $variables['formaction'] = $formaction.($cat_locale==""?"":("&cat_locale=".$cat_locale)); 220 $variables['download_cat_id'] = $download_cat_id; 221 $variables['download_title'] = $download_title; 222 $variables['download_description'] = $download_description; 223 $variables['download_url'] = $download_url; 224 $variables['download_license'] = $download_license; 225 $variables['download_os'] = $download_os; 226 $variables['download_version'] = $download_version; 227 $variables['download_filesize'] = $download_filesize; 228 $variables['download_external'] = $download_external; 229 230 } else { 231 $title = $locale['500']; 232 $variables['cats_found'] = false; 233 } 211 $data['download_cat_name'] = $locale['455']; 212 } 213 $variables['barfiles'][] = $data; 214 } 215 216 // template variables 217 $variables['step'] = $step; 218 $variables['formaction'] = $formaction.($cat_locale==""?"":("&cat_locale=".$cat_locale)); 219 $variables['download_cat_id'] = $download_cat_id; 220 $variables['download_title'] = $download_title; 221 $variables['download_description'] = $download_description; 222 $variables['download_url'] = $download_url; 223 $variables['download_license'] = $download_license; 224 $variables['download_os'] = $download_os; 225 $variables['download_version'] = $download_version; 226 $variables['download_filesize'] = $download_filesize; 227 $variables['download_external'] = $download_external; 234 228 235 229 // panel definitions
Note: See TracChangeset
for help on using the changeset viewer.
