| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | if (!defined('FORUM_ROOT'))
|
|---|
| 4 | define('FORUM_ROOT', '../../');
|
|---|
| 5 | require FORUM_ROOT.'include/common.php';
|
|---|
| 6 |
|
|---|
| 7 | ($hook = get_hook('vt_start')) ? eval($hook) : null;
|
|---|
| 8 |
|
|---|
| 9 | if ($forum_user['g_read_board'] == '0' || $forum_user['is_guest'])
|
|---|
| 10 | message($lang_common['No view']);
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | if (!defined('DOWNLOAD'))
|
|---|
| 14 | define('DOWNLOAD', FORUM_ROOT.'extensions/download/');
|
|---|
| 15 |
|
|---|
| 16 | $cat = isset($_GET['cat']) ? intval($_GET['cat']) : null;
|
|---|
| 17 |
|
|---|
| 18 | if (file_exists(DOWNLOAD.'lang/'.$forum_user['language'].'/download.php'))
|
|---|
| 19 | require_once DOWNLOAD.'lang/'.$forum_user['language'].'/download.php';
|
|---|
| 20 | else
|
|---|
| 21 | require_once DOWNLOAD.'lang/English/download.php';
|
|---|
| 22 |
|
|---|
| 23 | if (file_exists(DOWNLOAD.'lang/'.$forum_user['language'].'/admin_download.php'))
|
|---|
| 24 | require_once DOWNLOAD.'lang/'.$forum_user['language'].'/admin_download.php';
|
|---|
| 25 | else
|
|---|
| 26 | require_once DOWNLOAD.'lang/English/admin_download.php';
|
|---|
| 27 |
|
|---|
| 28 | if (isset($_POST['submit']))
|
|---|
| 29 | {
|
|---|
| 30 | // Start with the forum details
|
|---|
| 31 | $name = forum_trim($_POST['name']);
|
|---|
| 32 | $description = forum_trim($_POST['description']);
|
|---|
| 33 | $cat = intval($_POST['cat']);
|
|---|
| 34 | $version = forum_trim($_POST['version']);
|
|---|
| 35 | $author = forum_trim($_POST['author']);
|
|---|
| 36 |
|
|---|
| 37 | if ($name == '')
|
|---|
| 38 | message($lang_admin_download['Must enter download message']);
|
|---|
| 39 |
|
|---|
| 40 | if (!is_uploaded_file($_FILES['file_upload']['tmp_name']))
|
|---|
| 41 | message($lang_admin_download['File upload error']);
|
|---|
| 42 |
|
|---|
| 43 | $file_upload = $_FILES['file_upload']['name'];
|
|---|
| 44 | $file_ext = substr($file_upload, strrpos($file_upload, '.')+1);
|
|---|
| 45 |
|
|---|
| 46 | $allowed_ext = array('zip', 'rar');
|
|---|
| 47 | if (!in_array($file_ext, $allowed_ext))
|
|---|
| 48 | message($lang_admin_download['Invalid extension']);
|
|---|
| 49 |
|
|---|
| 50 | if (file_exists(DOWNLOAD.'files/'.$file_upload))
|
|---|
| 51 | {
|
|---|
| 52 | // Get new name for file
|
|---|
| 53 | $filename = substr($file_upload, 0, strrpos($file_upload, '.'));
|
|---|
| 54 | $ext = substr($file_upload, strrpos($file_upload, '.'));
|
|---|
| 55 | $i = 1;
|
|---|
| 56 | while (file_exists(DOWNLOAD.'files/'.$filename.'_'.$i.$ext))
|
|---|
| 57 | $i++;
|
|---|
| 58 | $file = $filename.'_'.$i.$ext;
|
|---|
| 59 | }
|
|---|
| 60 | else
|
|---|
| 61 | $file = $_FILES['file_upload']['name'];
|
|---|
| 62 |
|
|---|
| 63 | $file = str_replace(' ', '_', strtolower($file));
|
|---|
| 64 | $file = preg_replace('/[^0-9a-z\._]/', '', $file);
|
|---|
| 65 |
|
|---|
| 66 | move_uploaded_file($_FILES['file_upload']['tmp_name'], DOWNLOAD.'files/'.$file);
|
|---|
| 67 |
|
|---|
| 68 | $query = array(
|
|---|
| 69 | 'INSERT' => 'name, description, cat, author, version, user_id, added, file',
|
|---|
| 70 | 'INTO' => 'downloads',
|
|---|
| 71 | 'VALUES' => '\''.$forum_db->escape($name).'\', \''.$forum_db->escape($description).'\', '.$cat.', \''.$forum_db->escape($author).'\', \''.$forum_db->escape($version).'\', \''.$forum_db->escape($forum_user['id']).'\', '.time().', \''.$forum_db->escape($file).'\'',
|
|---|
| 72 | );
|
|---|
| 73 |
|
|---|
| 74 | if ($forum_user['g_id'] == FORUM_ADMIN)
|
|---|
| 75 | {
|
|---|
| 76 | $query['INSERT'] .= ', approved';
|
|---|
| 77 | $query['VALUES'] .= ', 1';
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | ($hook = get_hook('afo_save_forum_qr_update_forum')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
|
|---|
| 81 | $forum_db->query_build($query) or error(__FILE__, __LINE__);
|
|---|
| 82 |
|
|---|
| 83 | ($hook = get_hook('afo_save_forum_pre_redirect')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
|
|---|
| 84 |
|
|---|
| 85 | redirect(forum_link($forum_url['download']), $lang_admin_download['Download submited redirect']);
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | // Setup breadcrumbs
|
|---|
| 89 | $forum_page['crumbs'] = array(
|
|---|
| 90 | array($forum_config['o_board_title'], forum_link($forum_url['index'])),
|
|---|
| 91 | array($lang_download['Downloads'], forum_link($forum_url['download'])),
|
|---|
| 92 | array($lang_admin_download['Submit download'], forum_link($forum_url['download'])),
|
|---|
| 93 | );
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | // define('FORUM_PAGE_SECTION', 'management');
|
|---|
| 97 | define('FORUM_PAGE', 'download');
|
|---|
| 98 | define('FORUM_PAGE_TYPE', 'sectioned');
|
|---|
| 99 | require FORUM_ROOT.'header.php';
|
|---|
| 100 |
|
|---|
| 101 | ob_start();
|
|---|
| 102 | ?>
|
|---|
| 103 | <div class="main-head">
|
|---|
| 104 | <h2 class="hn"><span><?php echo $lang_admin_download['Submit download'] ?></span></h2>
|
|---|
| 105 | </div>
|
|---|
| 106 |
|
|---|
| 107 | <div class="main-subhead">
|
|---|
| 108 | <h2 class="hn"><span><?php echo $lang_admin_download['Submit download head'] ?></span></h2>
|
|---|
| 109 | </div>
|
|---|
| 110 |
|
|---|
| 111 | <div class="main-content main-frm">
|
|---|
| 112 | <form method="post" class="frm-form" accept-charset="utf-8" enctype="multipart/form-data" action="<?php echo forum_link($forum_url['submit_download']) ?>">
|
|---|
| 113 | <div class="hidden">
|
|---|
| 114 | <input type="hidden" name="csrf_token" value="<?php echo generate_form_token(forum_link($forum_url['submit_download'])) ?>" />
|
|---|
| 115 | </div>
|
|---|
| 116 |
|
|---|
| 117 | <?php if ($forum_user['g_id'] != FORUM_ADMIN) : ?>
|
|---|
| 118 | <div class="ct-box info-box">
|
|---|
| 119 | <p><?php echo $lang_admin_download['Submit download info'] ?></p>
|
|---|
| 120 | </div>
|
|---|
| 121 | <?php endif; ?>
|
|---|
| 122 |
|
|---|
| 123 | <?php ($hook = get_hook('afo_edit_forum_pre_details_fieldset')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?>
|
|---|
| 124 | <fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
|
|---|
| 125 | <legend class="group-legend"><strong><?php echo $lang_admin_download['Edit forum details legend'] ?></strong></legend>
|
|---|
| 126 | <?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?>
|
|---|
| 127 | <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
|
|---|
| 128 | <div class="sf-box text">
|
|---|
| 129 | <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_download['Download name'] ?></span></label><br />
|
|---|
| 130 | <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="name" size="35" maxlength="80" /></span>
|
|---|
| 131 | </div>
|
|---|
| 132 | </div>
|
|---|
| 133 | <?php ($hook = get_hook('afo_edit_forum_pre_forum_descrip')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?>
|
|---|
| 134 | <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
|
|---|
| 135 | <div class="sf-box select">
|
|---|
| 136 | <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_download['Category'] ?></span></label><br />
|
|---|
| 137 | <span class="fld-input"><select id="fld<?php echo $forum_page['fld_count'] ?>" name="cat">
|
|---|
| 138 | <?php
|
|---|
| 139 |
|
|---|
| 140 | $query = array(
|
|---|
| 141 | 'SELECT' => 'c.id, c.name',
|
|---|
| 142 | 'FROM' => 'downloads_cats AS c',
|
|---|
| 143 | 'ORDER BY' => 'c.name'
|
|---|
| 144 | );
|
|---|
| 145 |
|
|---|
| 146 | ($hook = get_hook('afo_edit_forum_qr_get_categories')) ? eval($hook) : null;
|
|---|
| 147 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
|
|---|
| 148 | while ($cur_cat = $forum_db->fetch_assoc($result))
|
|---|
| 149 | {
|
|---|
| 150 | echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'"'.($cur_cat['id'] == $cat ? ' selected="selected"' : '').'>'.forum_htmlencode($cur_cat['name']).'</option>'."\n";
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | ?>
|
|---|
| 154 | </select></span>
|
|---|
| 155 | </div>
|
|---|
| 156 | </div>
|
|---|
| 157 | <?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?>
|
|---|
| 158 | <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
|
|---|
| 159 | <div class="sf-box text">
|
|---|
| 160 | <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_download['Upload file'] ?></span></label><br />
|
|---|
| 161 | <span class="fld-input"><input type="file" id="fld<?php echo $forum_page['fld_count'] ?>" name="file_upload" size="35" /></span>
|
|---|
| 162 | </div>
|
|---|
| 163 | </div>
|
|---|
| 164 | <?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?>
|
|---|
| 165 | <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
|
|---|
| 166 | <div class="sf-box text">
|
|---|
| 167 | <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_download['Download author'] ?></span></label><br />
|
|---|
| 168 | <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="author" size="20" maxlength="80" value="<?php echo forum_htmlencode($forum_user['username']) ?>" /></span>
|
|---|
| 169 | </div>
|
|---|
| 170 | </div>
|
|---|
| 171 | <?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?>
|
|---|
| 172 |
|
|---|
| 173 | <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
|
|---|
| 174 | <div class="sf-box text">
|
|---|
| 175 | <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_download['Download version'] ?></span><small><?php echo $lang_admin_download['Download version help'] ?></small></label><br />
|
|---|
| 176 | <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="version" size="20" maxlength="80" /></span>
|
|---|
| 177 | </div>
|
|---|
| 178 | </div>
|
|---|
| 179 | <?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?>
|
|---|
| 180 | <div class="txt-set set<?php echo ++$forum_page['item_count'] ?>">
|
|---|
| 181 | <div class="txt-box textarea">
|
|---|
| 182 | <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_download['Download description'] ?></span> <small><?php echo $lang_admin_download['Download description help'] ?></small></label><br />
|
|---|
| 183 | <div class="txt-input"><span class="fld-input"><textarea id="fld<?php echo $forum_page['fld_count'] ?>" name="description" rows="10" cols="50"></textarea></span></div>
|
|---|
| 184 | </div>
|
|---|
| 185 | </div>
|
|---|
| 186 |
|
|---|
| 187 | </fieldset>
|
|---|
| 188 | <div class="frm-buttons">
|
|---|
| 189 | <span class="submit"><input type="submit" name="submit" value="<?php echo $lang_admin_download['Submit download'] ?>" /></span>
|
|---|
| 190 | </div>
|
|---|
| 191 | </form>
|
|---|
| 192 | </div>
|
|---|
| 193 |
|
|---|
| 194 | <?php
|
|---|
| 195 |
|
|---|
| 196 | $tpl_temp = trim(ob_get_contents());
|
|---|
| 197 | $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
|
|---|
| 198 | ob_end_clean();
|
|---|
| 199 | // END SUBST - <!-- forum_main -->
|
|---|
| 200 |
|
|---|
| 201 | require FORUM_ROOT.'footer.php';
|
|---|
| 202 |
|
|---|