5 $page->title
= 'Theme Settings';
7 if ( ! ($user instanceof authuser
) )
8 $page->errorfooter('login');
10 $premade_themes = new form_select('premade_theme', 2, $user->theme
);
11 $user_themes = new form_select('user_theme', 2);
13 $premade_themes->db_fill($DB->query('SELECT `themeid`, `theme_name` FROM `themes` ORDER BY `theme_name` ASC', MYSQLI_USE_RESULT
));
14 $user_themes->db_fill($DB->query('SELECT `userid`, `alias` FROM `users` WHERE `theme` = 0 ORDER BY `alias` ASC', MYSQLI_USE_RESULT
));
16 if ( isset($_POST['submit']) ) {
18 switch ( $_POST['themetype'] ) {
20 $premade_themes->check_value($_POST['premade_theme']);
21 $premade_themes->default = $user->theme
= intval($_POST['premade_theme']);
23 if ( isset($_POST['importpre']) ) {
24 list($f) = $DB->query('SELECT `css_file` FROM `themes`
25 WHERE `themeid` = '.intval($_POST['premade_theme']))->fetch_row();
26 file_put_contents('css/u'.$user->userid
.'.css',
27 file_get_contents('css/'.$f.'.css'));
32 $user_themes->check_value($_POST['user_theme']);
33 file_put_contents('css/u'.$user->userid
.'.css',
34 file_get_contents('css/u'.intval($_POST['user_theme']).'.css'));
40 file_put_contents('css/u'.$user->userid
.'.css',
41 str_replace("\r\n", "\n", $_POST['user_css']));
45 echo '<p class="notice">Settings have been saved.</p>';
46 } catch ( Exception
$e ) {
48 echo '<p class="error">',$e->getMessage(),'</p>';
53 if ( file_exists('css/u'.$user->userid
.'.css') )
54 $css_textbox = htmlspecialchars(file_get_contents('css/u'.$user->userid
.'.css'));
59 <form id
="theme" method
="post" action
="<?php echo $_SERVER['PHP_SELF'] ?>">
60 <fieldset
class="content">
61 <legend
><label
><input type
="radio" name
="themetype" value
="premade"<?php
62 echo $user->theme
> 0 ?
' checked="checked"' : '' ?
>/> Premade Theme
</label
></legend
>
63 <p
><label
>Select theme
: <?php
echo $premade_themes->display() ?
></label
></p
>
64 <p
><label
><input type
="checkbox" name
="importpre"/> Set your custom theme to this
</label
></p
>
66 <fieldset
class="content">
67 <legend
><label
><input type
="radio" name
="themetype" value
="import"/> Import from user
</label
></legend
>
68 <p
><label
>User name
: <?php
echo $user_themes->display() ?
></label
></p
>
70 <fieldset
class="content">
71 <legend
><label
><input type
="radio" name
="themetype" value
="custom"<?php
72 echo $user->theme
== 0 ?
' checked="checked"' : '' ?
>/> Custom CSS
</label
></legend
>
73 <textarea rows
="20" cols
="60" name
="user_css" id
="user_css"><?php
echo $css_textbox ?
></textarea
>
76 <button type
="submit" name
="submit" value
="save" accesskey
="s">Save
Settings (S
)</button
>