[17] | 1 | <?php |
---|
[89] | 2 | require_once('db.php'); |
---|
| 3 | require_once('class.killboard.php'); |
---|
| 4 | require_once('class.page.php'); |
---|
| 5 | require_once('class.tabbedform.php'); |
---|
| 6 | require_once('admin_menu.php'); |
---|
| 7 | require_once('autoupgrade.php'); |
---|
[17] | 8 | |
---|
| 9 | $killboard = new Killboard(KB_SITE); |
---|
[89] | 10 | $page = new Page('Administration - Generic (Current version: '.KB_VERSION.' Build '.SVN_REV.')'); |
---|
[17] | 11 | $page->setAdmin(); |
---|
[89] | 12 | |
---|
| 13 | // check tables for validity and fields |
---|
| 14 | // todo: tidy this mess up!!!!! |
---|
| 15 | check_pilots(); |
---|
[71] | 16 | check_invdetail(); |
---|
[89] | 17 | check_contracts(); |
---|
| 18 | check_index(); |
---|
| 19 | check_tblstrct1(); |
---|
| 20 | check_tblstrct2(); |
---|
| 21 | check_tblstrct3(); |
---|
| 22 | check_tblstrct4(); |
---|
[135] | 23 | check_tblstrct5(); |
---|
[17] | 24 | |
---|
| 25 | if ($_POST['submit']) |
---|
| 26 | { |
---|
| 27 | $config->setStyleBanner($_POST['style_banner']); |
---|
| 28 | $config->setStyleName($_POST['style_name']); |
---|
[47] | 29 | |
---|
| 30 | // new function checkCheckbox, checks $_POST[arg] and inserts 0 if != 'on' |
---|
| 31 | $config->checkCheckbox('kill_points'); |
---|
| 32 | $config->checkCheckbox('ship_values'); |
---|
| 33 | $config->checkCheckbox('least_active'); |
---|
[89] | 34 | $config->checkCheckbox('adapt_items'); |
---|
[134] | 35 | $config->checkCheckbox('show_standing'); |
---|
[47] | 36 | |
---|
| 37 | if ($config->checkCheckbox('comments')) |
---|
[17] | 38 | { |
---|
| 39 | check_commenttable(); |
---|
| 40 | } |
---|
[47] | 41 | $config->checkCheckbox('comments_pw'); |
---|
| 42 | $config->checkCheckbox('comments_count'); |
---|
[112] | 43 | $config->checkCheckbox('item_values'); |
---|
[17] | 44 | $config->setPostPassword($_POST['post_password']); |
---|
| 45 | $config->setPostMailto($_POST['post_mailto']); |
---|
[59] | 46 | $config->setConfig('mail_host', $_POST['post_mailhost']); |
---|
[30] | 47 | |
---|
[17] | 48 | if ($_POST['filter_apply'] == "on") |
---|
[30] | 49 | { |
---|
[17] | 50 | $config->setConfig('filter_apply', '1'); |
---|
[30] | 51 | $config->setConfig('filter_date', mktime(0, 0, 0, $_POST['filter_month'], ($_POST['filter_day'] > 31 ? 31 : $_POST['filter_day']), $_POST['filter_year'])); |
---|
| 52 | } |
---|
| 53 | else |
---|
| 54 | { |
---|
[17] | 55 | $config->setConfig('filter_apply', '0'); |
---|
| 56 | $config->setConfig('filter_date', 0); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | $html .= "Changes saved."; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | $html .= "<form id=options name=options method=post action=?a=admin>"; |
---|
| 63 | $html .= "<div class=block-header2>Look and feel</div>"; |
---|
| 64 | $html .= "<table class=kb-subtable>"; |
---|
| 65 | $html .= "<tr><td width=120><b>Banner:</b></td><td><select id=style_banner name=style_banner>"; |
---|
[30] | 66 | |
---|
[89] | 67 | $dir = "img/logo/"; |
---|
[17] | 68 | if (is_dir($dir)) |
---|
| 69 | { |
---|
| 70 | if ($dh = opendir($dir)) |
---|
| 71 | { |
---|
| 72 | while (($file = readdir($dh)) !== false) |
---|
| 73 | { |
---|
| 74 | $file = substr($file, 0, strpos($file, ".")); |
---|
[89] | 75 | if (!is_dir($dir.$file)) |
---|
[17] | 76 | { |
---|
[89] | 77 | $html .= "<option value=\"".$file."\""; |
---|
| 78 | if ($file == $config->getConfig('style_banner')) |
---|
[30] | 79 | { |
---|
[17] | 80 | $html .= " selected=\"selected\""; |
---|
[30] | 81 | } |
---|
[89] | 82 | $html .= ">".$file."</option>"; |
---|
[17] | 83 | } |
---|
| 84 | } |
---|
| 85 | closedir($dh); |
---|
| 86 | } |
---|
| 87 | } |
---|
[89] | 88 | $html .= "</td></tr>"; |
---|
[17] | 89 | $html .= "<tr><td width=120><b>Style:</b></td><td><select id=style_name name=style_name>"; |
---|
[30] | 90 | |
---|
[17] | 91 | $dir = "style/"; |
---|
| 92 | if (is_dir($dir)) |
---|
| 93 | { |
---|
| 94 | if ($dh = opendir($dir)) |
---|
| 95 | { |
---|
| 96 | while (($file = readdir($dh)) !== false) |
---|
| 97 | { |
---|
[89] | 98 | if (is_dir($dir.$file)) |
---|
[17] | 99 | { |
---|
| 100 | if ($file == "." || $file == ".." || $file == ".svn") |
---|
[30] | 101 | { |
---|
[17] | 102 | continue; |
---|
[30] | 103 | } |
---|
[89] | 104 | $html .= "<option value=\"".$file."\""; |
---|
| 105 | if ($file == $config->getConfig('style_name')) |
---|
[30] | 106 | { |
---|
[17] | 107 | $html .= " selected=\"selected\""; |
---|
[30] | 108 | } |
---|
[89] | 109 | $html .= ">".$file."</option>"; |
---|
[17] | 110 | } |
---|
| 111 | } |
---|
| 112 | closedir($dh); |
---|
| 113 | } |
---|
| 114 | } |
---|
| 115 | $html .= "</select></td></tr>"; |
---|
| 116 | $html .= "<tr><td></td></tr></table>"; |
---|
| 117 | |
---|
| 118 | $html .= "<div class=block-header2>Global options</div>"; |
---|
| 119 | $html .= "<table class=kb-subtable>"; |
---|
| 120 | $html .= "<tr><td width=120><b>Display killpoints:</b></td><td><input type=checkbox name=kill_points id=kill_points"; |
---|
| 121 | if ($config->getConfig('kill_points')) |
---|
[30] | 122 | { |
---|
[17] | 123 | $html .= " checked=\"checked\""; |
---|
[30] | 124 | } |
---|
[17] | 125 | $html .= "></td></tr>"; |
---|
[116] | 126 | |
---|
[17] | 127 | $html .= "<tr><td width=120><b>Enable Comments:</b></td><td><input type=checkbox name=comments id=comments"; |
---|
| 128 | if ($config->getConfig('comments')) |
---|
[30] | 129 | { |
---|
[17] | 130 | $html .= " checked=\"checked\""; |
---|
[30] | 131 | } |
---|
[17] | 132 | $html .= "></td></tr>"; |
---|
| 133 | $html .= "<tr><td width=120><b>Require password for Comments:</b></td><td><input type=checkbox name=comments_pw id=comments_pw"; |
---|
| 134 | if ($config->getConfig('comments_pw')) |
---|
[30] | 135 | { |
---|
[17] | 136 | $html .= " checked=\"checked\""; |
---|
[30] | 137 | } |
---|
[17] | 138 | $html .= "></td></tr>"; |
---|
[33] | 139 | $html .= "<tr><td width=120><b>Display Comment Count on Killlists:</b></td><td><input type=checkbox name=comments_count id=comments_count"; |
---|
| 140 | if ($config->getConfig('comments_count')) |
---|
| 141 | { |
---|
| 142 | $html .= " checked=\"checked\""; |
---|
| 143 | } |
---|
| 144 | $html .= "></td></tr>"; |
---|
[134] | 145 | $html .= "<tr><td width=120><b>Display Standings:</b></td><td><input type=checkbox name=show_standing id=show_standing"; |
---|
| 146 | if ($config->getConfig('show_standing')) |
---|
| 147 | { |
---|
| 148 | $html .= " checked=\"checked\""; |
---|
| 149 | } |
---|
| 150 | $html .= "></td></tr>"; |
---|
[17] | 151 | |
---|
[112] | 152 | $html .= "<tr><td width=120><b>Enable Lost Item Values</b></td><td><input type=checkbox name=item_values id=item_values"; |
---|
| 153 | if ($config->getConfig('item_values')) |
---|
| 154 | { |
---|
| 155 | $html .= " checked=\"checked\""; |
---|
| 156 | } |
---|
| 157 | $html .= "></td></tr>"; |
---|
| 158 | $html .= "<tr><td width=120><b>Use custom shipvalues:</b></td><td><input type=checkbox name=ship_values id=ship_values"; |
---|
| 159 | if ($config->getConfig('ship_values')) |
---|
| 160 | { |
---|
| 161 | $html .= " checked=\"checked\""; |
---|
| 162 | } |
---|
| 163 | $html .= "></td></tr>"; |
---|
[17] | 164 | // $html .= "<tr><td width=120><b>Display least active:</b></td><td><input type=checkbox name=least_active id=least_active"; |
---|
| 165 | // if ( $config->getLeastActive() ) |
---|
| 166 | // $html .= " checked=\"checked\""; |
---|
| 167 | // $html .= "></td></tr>"; |
---|
| 168 | $html .= "<tr><td></td></tr></table>"; |
---|
| 169 | |
---|
| 170 | $html .= "<div class=block-header2>Posting</div>"; |
---|
| 171 | $html .= "<table class=kb-subtable>"; |
---|
| 172 | |
---|
[89] | 173 | $html .= "<tr><td width=120><b>Post password:</b></td><td><input type=text name=post_password id=post_password size=20 maxlength=20 value=\"".$config->getPostPassword()."\"></td></tr>"; |
---|
| 174 | $html .= "<tr><td width=120><b>Killmail CC:</b></td><td><input type=text name=post_mailto id=post_mailto size=20 maxlength=80 value=\"".$config->getPostMailto()."\"> (e-mail address)</td></tr>"; |
---|
[59] | 175 | $html .= "<tr><td width=120><b>Mailhost:</b></td><td><input type=text name=post_mailhost id=post_mailhost size=20 maxlength=80 value=\"".$config->getConfig('mail_host')."\"></td></tr>"; |
---|
[89] | 176 | $html .= "<tr><td width=120><b>Disallow any killmails before:</b></td><td>".dateSelector($config->getConfig('filter_apply'), $config->getConfig('filter_date'))."</td></tr>"; |
---|
| 177 | $html .= "<tr><td width=120><b>Enable auto-addition of unknown Items:</b></td><td><input type=checkbox name=adapt_items id=adapt_items"; |
---|
| 178 | if ($config->getConfig('adapt_items')) |
---|
| 179 | { |
---|
| 180 | $html .= " checked=\"checked\""; |
---|
| 181 | } |
---|
| 182 | $html .= "> (This is in case we can't supply a dump with the new items when Kali goes live)</td></tr>"; |
---|
[17] | 183 | $html .= "</table>"; |
---|
| 184 | |
---|
| 185 | $html .= "<div class=block-header2>Save changes</div>"; |
---|
| 186 | $html .= "<table class=kb-subtable>"; |
---|
| 187 | |
---|
| 188 | $html .= "<tr><td width=120></td><td><input type=submit name=submit value=\"Save\"></td></tr>"; |
---|
| 189 | $html .= "</table>"; |
---|
| 190 | |
---|
| 191 | $html .= "</form>"; |
---|
| 192 | |
---|
| 193 | $page->setContent($html); |
---|
| 194 | $page->addContext($menubox->generate()); |
---|
| 195 | $page->generate(); |
---|
| 196 | |
---|
[30] | 197 | function dateSelector($apply, $date) |
---|
| 198 | { |
---|
| 199 | if ($date > 0) |
---|
| 200 | { |
---|
| 201 | $date = getdate($date); |
---|
| 202 | } |
---|
| 203 | else |
---|
| 204 | { |
---|
[17] | 205 | $date = getdate(); |
---|
[30] | 206 | } |
---|
[17] | 207 | $html = "<input type=\"text\" name=\"filter_day\" id=\"filter_day\" style=\"width:20px\" value=\"{$date['mday']}\"/> "; |
---|
| 208 | $html .= "<select name=\"filter_month\" id=\"filter_month\">"; |
---|
[30] | 209 | for ($i = 1; $i <= 12; $i++) |
---|
| 210 | { |
---|
| 211 | $t = mktime(0, 0, 0, $i, 1, 1980); |
---|
| 212 | $month = date("M", $t); |
---|
| 213 | if($date['mon'] == $i) |
---|
| 214 | { |
---|
| 215 | $selected = " selected=\"selected\""; |
---|
| 216 | } |
---|
| 217 | else |
---|
| 218 | { |
---|
| 219 | $selected = ""; |
---|
| 220 | } |
---|
| 221 | |
---|
[17] | 222 | $html .= "<option value=\"$i\"$selected>$month</option>"; |
---|
| 223 | } |
---|
| 224 | $html .= "</select> "; |
---|
[30] | 225 | |
---|
[17] | 226 | $html .= "<select name=\"filter_year\" id=\"filter_year\">"; |
---|
[30] | 227 | for ($i = date("Y")-7; $i <= date("Y"); $i++) |
---|
| 228 | { |
---|
| 229 | if ($date['year'] == $i) |
---|
| 230 | { |
---|
| 231 | $selected = " selected=\"selected\""; |
---|
| 232 | } |
---|
| 233 | else |
---|
| 234 | { |
---|
| 235 | $selected = ""; |
---|
| 236 | } |
---|
[17] | 237 | $html .= "<option value=\"$i\"$selected>$i</option>"; |
---|
| 238 | } |
---|
| 239 | $html .= "</select> "; |
---|
| 240 | $html .= "<input type=checkbox name=filter_apply id=filter_apply"; |
---|
[30] | 241 | if ($apply) |
---|
| 242 | { |
---|
| 243 | $html .= " checked=\"checked\""; |
---|
| 244 | } |
---|
| 245 | $html .= "/>Apply "; |
---|
[17] | 246 | return $html; |
---|
| 247 | } |
---|
[10] | 248 | ?> |
---|