root/dev/common/admin.php @ 157

Revision 157, 9.1 KB (checked in by exi, 14 years ago)

Added option to show a link to the pod killmail instead of a pod picture on the battle summary.
Battle summaries will now be sorted by shippoints, shipname, pilotname.
Added option to disable mailposting without having to change the password.
Fixed a typo on the standingslist.

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