root/dev/common/admin.php @ 165

Revision 165, 9.6 KB (checked in by exi, 16 years ago)

Added options to show loss and totalpoints in pilot details.
Tidied up class.box.php.
class.kill.php now checks better for item location ids.
Added victimalliancename to the killlisttable.
The signature generator now paints error messages if he doesnt like stuff.

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