root/dev/common/admin.php @ 162

Revision 162, 9.1 KB (checked in by exi, 16 years ago)

Added externalids to autoupgrade code.
Added custom headers to the http_class.
Added an option to set the socket timeout when using the http_class.
Pushed version to 1.2.2 in globals.php.
Fixed a bug in the battle parser which prevented it from parsing kills of the last day.
Added code to the synchronization module so it can handle item value updates as well.
Changed killists so they don't list kills as a kill anymore where an corp/alliance member has been killed, right, those are now pure losses. This should also resolve an issue with the battle parser going mad.

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