SO 1-final
[specialops1.git] / theme.php
blob2a5894a189842317c694a25417cf1c8eaba63411
1 <?php
2 require 'config.php';
3 $level_restriction = INACTIVE_USER;
4 $require_login = true;
6 if ( isset($_POST['submit'], $_POST['themetype']) ) {
8 if ( !function_exists('file_put_contents') ) {
9 function file_put_contents($filename, $data) {
10 $a = fopen($filename, 'w');
11 fwrite($a, $data);
12 fclose($a);
16 $theme = 0;
18 if ( $_POST['themetype'] == 'premade' && isset($_POST['theme']) ) {
19 $theme = isset($_POST['theme']) ? intval($_POST['theme']) : 1;
20 if ( isset($_POST['importpre']) ) {
21 $theme = 0;
22 $_POST['csstext'] = file_get_contents('csslib/system/'.mysql_result(
23 mysql_unbuffered_query('SELECT `file` FROM `styles` WHERE `style` = '.$theme), 0));
26 elseif ( $_POST['themetype'] == 'import' && isset($_POST['import']) ) {
27 $theme = 0;
28 $_POST['csstext'] = file_get_contents('csslib/user/'.intval($_POST['import']).'.css');
31 mysql_query ('UPDATE `users` SET `theme` = '.$theme.' WHERE `user` = '.$userinfo['user']);
32 file_put_contents('csslib/user/'.$userinfo['user'].'.css', $_POST['csstext']);
34 $userinfo = mysql_fetch_assoc(mysql_unbuffered_query('SELECT * FROM `users` WHERE `user` = '.$userinfo['user']));
37 $page_name = 'Theme Settings';
38 require 'top.inc.php';
40 if ( isset($_POST['submit']) || isset($_POST['import']) )
41 echo '<p class="alert">Theme Updated.</p>';
43 echo '<form method="post" action="',$_SERVER['PHP_SELF'],URL_STRING,'">
45 <fieldset style="float:left; width:25%">
46 <legend>Settings</legend>
47 <ul class="plain-list">
48 <li><label><input type="radio" id="theme_pre" name="themetype" value="premade"',
49 ( $userinfo['theme'] > 0 ? ' checked="checked"' : '' ),' onclick="showstuff();"/>
50 Premade (',mysql_result(mysql_query('SELECT COUNT(*) FROM `users` WHERE `theme` > 0'), 0),' user[s])</label></li>
51 <li><label><input type="radio" id="theme_adv" name="themetype" value="advanced"',
52 ( $userinfo['theme'] == 0 ? ' checked="checked"' : '' ),' onclick="showstuff();"/>
53 Advanced</label></li>
54 <li><label><input type="radio" id="theme_usr" name="themetype" value="import" onclick="showstuff();"/>
55 Import (',mysql_result(mysql_query('SELECT COUNT(*) FROM `users` WHERE `theme` = 0'), 0),' user[s])</label></li>
56 </ul>
57 <hr/>
59 Header: <select name="header">',"\n";
60 asort($cfg['headers']);
61 $i = 0;
62 foreach ( $cfg['headers'] as $desc => $image )
63 echo '<option value="',++$i,'"',( $userinfo['header'] == $i ? ' selected="selected"' : '' ),'>',$desc,"</option>\n";
64 echo '</select>
66 <input type="submit" name="submit" accesskey="s" value="Save Settings (S)"/></fieldset>
68 <fieldset style="float:left; clear:left; width:25%">
69 <legend>Preview</legend>
70 <h2>Tables</h2>
71 <table style="width:100%">
72 <tr><th>tr th | <a href="#">Link</a></th></tr>',"\n";
73 for ( $row = 3; $row > 0; $row-- )
74 echo '<tr class="c',$row,'"><td>tr.c',$row,' td | <a href="#">Link</a></td></tr>',"\n";
75 echo '</table>
76 <h3>Divs</h3>
77 <div class="alert">div.alert | <a href="#">Link</a></div>';
78 for ( $row = 3; $row > 0; $row-- )
79 echo '<div class="c',$row,'">div.c',$row,' | <a href="#">Link</a></div>',"\n";
81 echo '<a href="csslib">CSS directory</a>
82 </fieldset>
84 <fieldset style="vertical-align:top" id="premadebox">
85 <legend>Premade Themes</legend>',"\n";
87 $themes = mysql_query('SELECT `style`, `title` FROM `styles` ORDER BY `title` ASC');
88 echo '<select name="theme" id="premade_list" size="',( ($i=mysql_num_rows($themes)) > 6 ? 6 : $i ),"\">\n";
89 while ( $style = mysql_fetch_row($themes) )
90 echo '<option value="',$style[0],'"',( $userinfo['theme'] == $style[0] ? ' selected="selected"' : '' ),'>',$style[1],
91 ' (',mysql_result(mysql_query('SELECT COUNT(*) FROM `users` WHERE `theme` = '.$style[0]), 0)," users)</option>\n";
93 echo '</select>
94 <p>Choose from one of the default themes.</p>
96 <label><input type="checkbox" name="importpre"/> Import to advanced</label>
97 </fieldset>
99 <fieldset style="vertical-align:top" id="importbox">
100 <legend>Import User Theme</legend>',"\n";
102 $themes = mysql_query('SELECT `user`, `name`, `theme` FROM `users` WHERE `theme` = 0 ORDER BY `name` ASC');
103 echo '<select name="import" id="import_list" size="',( ($i=mysql_num_rows($themes)) > 6 ? 6 : $i ),"\">\n";
104 while ( $user = mysql_fetch_row($themes) )
105 echo '<option value="',$user[0],'">',$user[1],"</option>\n";
106 echo '</select>
108 <p>Import another user\'s theme.</p>
109 </fieldset>
111 <fieldset style="vertical-align:top" id="advancedbox">
112 <legend>Advanced Custom Theme</legend>
113 <textarea name="csstext" rows="30" cols="80" style="height:25em; width:95%">';
114 if ( file_exists('csslib/user/'.$userinfo['user'].'.css') )
115 echo htmlentities(file_get_contents('csslib/user/'.$userinfo['user'].'.css'));
116 echo '</textarea>
117 <p>Write your own CSS theme or modify an imported one.</p>
118 </fieldset>
120 </form>';
122 require 'foot.php';