5 $page->title
= 'Theme Settings';
7 if ( ! ($user instanceof authuser
) ) {
8 $page->errorfooter('login');
11 $premade_themes = new form_select('premade_theme', 2, $user->theme
);
12 $user_themes = new form_select('user_theme', 2);
14 $premade_themes->db_fill($DB->query('SELECT `themeid`, `theme_name` FROM `themes` ORDER BY `theme_name` ASC',
16 $user_themes->db_fill($DB->query('SELECT `userid`, `alias` FROM `users` WHERE `theme` = 0 ORDER BY `alias` ASC',
19 if ( isset($_POST['submit']) ) {
21 switch ( $_POST['themetype'] ) {
23 $premade_themes->check_value($_POST['premade_theme']);
24 $premade_themes->default = $user->theme
= intval($_POST['premade_theme']);
26 if ( isset($_POST['importpre']) ) {
27 list($f) = $DB->query('SELECT `css_file` FROM `themes`
28 WHERE `themeid` = '.intval($_POST['premade_theme']))->fetch_row();
29 file_put_contents('css/u'.$user->userid
.'.css',
30 file_get_contents('css/'.$f));
35 $user_themes->check_value($_POST['user_theme']);
36 file_put_contents('css/u'.$user->userid
.'.css',
37 file_get_contents('css/u'.intval($_POST['user_theme']).'.css'));
43 file_put_contents('css/u'.$user->userid
.'.css',
48 echo '<p class="notice">Settings have been saved.</p>';
49 } catch ( Exception
$e ) {
51 echo '<p class="error">',$e->getMessage(),'</p>';
56 if ( file_exists('css/u'.$user->userid
.'.css') )
57 $css_textbox = htmlspecialchars(file_get_contents('css/u'.$user->userid
.'.css'));
64 '<form method="post" action="',$_SERVER['PHP_SELF'],'">
68 <th scope="col">Theme Type</th>
69 <th scope="col">Detailed Settings</th>
74 <tr class="content c',(++
$a&1),'">
75 <td><label><input type="radio" name="themetype" value="premade"',
76 ( $user->theme
> 0 ?
' checked="checked"' : '' ),'/> Premade</label></td>
77 <td><label>Select theme: ',$premade_themes->display(),
79 <label><input type="checkbox" name="importpre"/> Set your custom theme to this</label></td>
81 <tr class="content c',(++
$a&1),'">
82 <td><label><input type="radio" name="themetype" value="import"/> Import user theme</label></td>
83 <td><label>User name: ',$user_themes->display(),
86 <tr class="content c',(++
$a&1),'">
87 <td><label><input type="radio" name="themetype" value="custom"',
88 ( $user->theme
== 0 ?
' checked="checked"' : '' ),'/> Custom CSS</label></td>
89 <td><label>CSS:<br/><textarea rows="20" cols="60" name="user_css">',$css_textbox,'</textarea></label></td>
94 <button type="submit" name="submit" value="save" accesskey="s">Save Settings (S)</button>