root/dev/common/admin.php @ 134

Revision 134, 8.1 KB (checked in by exi, 14 years ago)

Added standings-management.
Changed installer step 3 to only use POST data now.
Character portraits should now look a bit better.
Changed all smarty template requests to use a wrapper function.
Modified standard page for IGB.
Added php compat file to reduce minimal needed version to 4.0.9.

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