1 | <?php |
---|
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 | |
---|
8 | $killboard = new Killboard(KB_SITE); |
---|
9 | $page = new Page("Administration - Generic"); |
---|
10 | $page->setAdmin(); |
---|
11 | |
---|
12 | $config = $killboard->getConfig(); |
---|
13 | if ($_POST['submit']) |
---|
14 | { |
---|
15 | $config->setStyleBanner($_POST['style_banner']); |
---|
16 | $config->setStyleName($_POST['style_name']); |
---|
17 | if ($_POST['kill_points'] == "on") |
---|
18 | { |
---|
19 | $killpoints = 1; |
---|
20 | } |
---|
21 | else |
---|
22 | { |
---|
23 | $killpoints = 0; |
---|
24 | } |
---|
25 | if ($_POST['least_active'] == "on") |
---|
26 | { |
---|
27 | $leastactive = 1; |
---|
28 | } |
---|
29 | else |
---|
30 | { |
---|
31 | $leastactive = 0; |
---|
32 | } |
---|
33 | $config->setKillPoints($killpoints); |
---|
34 | $config->setLeastActive($leastactive); |
---|
35 | if ($_POST['comments'] == "on") |
---|
36 | { |
---|
37 | require_once('autoupgrade.php'); |
---|
38 | check_commenttable(); |
---|
39 | $config->setConfig('comments', '1'); |
---|
40 | } |
---|
41 | else |
---|
42 | { |
---|
43 | $config->setConfig('comments', '0'); |
---|
44 | } |
---|
45 | if ($_POST['comments_pw'] == "on") |
---|
46 | { |
---|
47 | $config->setConfig('comments_pw', '1'); |
---|
48 | } |
---|
49 | else |
---|
50 | { |
---|
51 | $config->setConfig('comments_pw', '0'); |
---|
52 | } |
---|
53 | $config->setPostPassword($_POST['post_password']); |
---|
54 | $config->setPostMailto($_POST['post_mailto']); |
---|
55 | |
---|
56 | if ($_POST['filter_apply'] == "on") |
---|
57 | { |
---|
58 | $config->setConfig('filter_apply', '1'); |
---|
59 | $config->setConfig('filter_date', mktime(0,0,0,$_POST['filter_month'],($_POST['filter_day'] > 31 ? 31 : $_POST['filter_day']),$_POST['filter_year'])); |
---|
60 | }else{ |
---|
61 | $config->setConfig('filter_apply', '0'); |
---|
62 | $config->setConfig('filter_date', 0); |
---|
63 | } |
---|
64 | |
---|
65 | $html .= "Changes saved."; |
---|
66 | } |
---|
67 | |
---|
68 | $html .= "<form id=options name=options method=post action=?a=admin>"; |
---|
69 | $html .= "<div class=block-header2>Look and feel</div>"; |
---|
70 | $html .= "<table class=kb-subtable>"; |
---|
71 | $html .= "<tr><td width=120><b>Banner:</b></td><td><select id=style_banner name=style_banner>"; |
---|
72 | $dir = "img/banners/"; |
---|
73 | if (is_dir($dir)) |
---|
74 | { |
---|
75 | if ($dh = opendir($dir)) |
---|
76 | { |
---|
77 | while (($file = readdir($dh)) !== false) |
---|
78 | { |
---|
79 | $file = substr($file, 0, strpos($file, ".")); |
---|
80 | if (!is_dir($dir . $file)) |
---|
81 | { |
---|
82 | $html .= "<option value=\"" . $file . "\""; |
---|
83 | if ($file == $config->getStyleBanner()) |
---|
84 | $html .= " selected=\"selected\""; |
---|
85 | $html .= ">" . $file . "</option>"; |
---|
86 | } |
---|
87 | } |
---|
88 | closedir($dh); |
---|
89 | } |
---|
90 | } |
---|
91 | $html .= "<option value=\"custom\""; |
---|
92 | if ($config->getStyleBanner() == "custom") |
---|
93 | $html .= " selected=\"selected\""; |
---|
94 | $html .= ">custom</option></select></td></tr>"; |
---|
95 | $html .= "<tr><td width=120><b>Style:</b></td><td><select id=style_name name=style_name>"; |
---|
96 | $dir = "style/"; |
---|
97 | if (is_dir($dir)) |
---|
98 | { |
---|
99 | if ($dh = opendir($dir)) |
---|
100 | { |
---|
101 | while (($file = readdir($dh)) !== false) |
---|
102 | { |
---|
103 | if (is_dir($dir . $file)) |
---|
104 | { |
---|
105 | if ($file == "." || $file == ".." || $file == ".svn") |
---|
106 | continue; |
---|
107 | $html .= "<option value=\"" . $file . "\""; |
---|
108 | if ($file == $config->getStyleName()) |
---|
109 | $html .= " selected=\"selected\""; |
---|
110 | $html .= ">" . $file . "</option>"; |
---|
111 | } |
---|
112 | } |
---|
113 | closedir($dh); |
---|
114 | } |
---|
115 | } |
---|
116 | $html .= "</select></td></tr>"; |
---|
117 | $html .= "<tr><td></td></tr></table>"; |
---|
118 | |
---|
119 | $html .= "<div class=block-header2>Global options</div>"; |
---|
120 | $html .= "<table class=kb-subtable>"; |
---|
121 | $html .= "<tr><td width=120><b>Display killpoints:</b></td><td><input type=checkbox name=kill_points id=kill_points"; |
---|
122 | if ($config->getConfig('kill_points')) |
---|
123 | $html .= " checked=\"checked\""; |
---|
124 | $html .= "></td></tr>"; |
---|
125 | $html .= "<tr><td width=120><b>Enable Comments:</b></td><td><input type=checkbox name=comments id=comments"; |
---|
126 | if ($config->getConfig('comments')) |
---|
127 | $html .= " checked=\"checked\""; |
---|
128 | $html .= "></td></tr>"; |
---|
129 | $html .= "<tr><td width=120><b>Require password for Comments:</b></td><td><input type=checkbox name=comments_pw id=comments_pw"; |
---|
130 | if ($config->getConfig('comments_pw')) |
---|
131 | $html .= " checked=\"checked\""; |
---|
132 | $html .= "></td></tr>"; |
---|
133 | |
---|
134 | // $html .= "<tr><td width=120><b>Display least active:</b></td><td><input type=checkbox name=least_active id=least_active"; |
---|
135 | // if ( $config->getLeastActive() ) |
---|
136 | // $html .= " checked=\"checked\""; |
---|
137 | // $html .= "></td></tr>"; |
---|
138 | $html .= "<tr><td></td></tr></table>"; |
---|
139 | |
---|
140 | $html .= "<div class=block-header2>Posting</div>"; |
---|
141 | $html .= "<table class=kb-subtable>"; |
---|
142 | |
---|
143 | $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>"; |
---|
144 | $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>"; |
---|
145 | $html .= "<tr><td width=120><b>Disallow any killmails before:</b></td><td>" . dateSelector($config->getConfig('filter_apply'),$config->getConfig('filter_date')) . "</td></tr>"; |
---|
146 | $html .= "</table>"; |
---|
147 | |
---|
148 | $html .= "<div class=block-header2>Save changes</div>"; |
---|
149 | $html .= "<table class=kb-subtable>"; |
---|
150 | |
---|
151 | $html .= "<tr><td width=120></td><td><input type=submit name=submit value=\"Save\"></td></tr>"; |
---|
152 | $html .= "</table>"; |
---|
153 | |
---|
154 | $html .= "</form>"; |
---|
155 | |
---|
156 | $page->setContent($html); |
---|
157 | $page->addContext($menubox->generate()); |
---|
158 | $page->generate(); |
---|
159 | |
---|
160 | function dateSelector($apply,$date){ |
---|
161 | if($date > 0){ |
---|
162 | $date = getdate($date); |
---|
163 | }else{ |
---|
164 | $date = getdate(); |
---|
165 | } |
---|
166 | $html = "<input type=\"text\" name=\"filter_day\" id=\"filter_day\" style=\"width:20px\" value=\"{$date['mday']}\"/> "; |
---|
167 | $html .= "<select name=\"filter_month\" id=\"filter_month\">"; |
---|
168 | for($i=1;$i<=12;$i++){ |
---|
169 | $t = mktime(0,0,0,$i,1,1980); |
---|
170 | $month = date("M",$t); |
---|
171 | if($date['mon'] == $i) $selected = " selected=\"selected\""; else $selected = ""; |
---|
172 | $html .= "<option value=\"$i\"$selected>$month</option>"; |
---|
173 | } |
---|
174 | $html .= "</select> "; |
---|
175 | |
---|
176 | $html .= "<select name=\"filter_year\" id=\"filter_year\">"; |
---|
177 | for($i=date("Y")-7;$i<=date("Y");$i++){ |
---|
178 | if($date['year'] == $i) $selected = " selected=\"selected\""; else $selected = ""; |
---|
179 | $html .= "<option value=\"$i\"$selected>$i</option>"; |
---|
180 | } |
---|
181 | $html .= "</select> "; |
---|
182 | $html .= "<input type=checkbox name=filter_apply id=filter_apply"; |
---|
183 | if($apply=="1") $html .= " checked=\"checked\""; |
---|
184 | $html .= "/>Apply "; |
---|
185 | return $html; |
---|
186 | } |
---|
187 | ?> |
---|