OSDN Git Service

rabr
[embrj/master.git] / setting.php
1 <?php\r
2         include ('lib/twitese.php');\r
3         $title = "Settings";\r
4         include ('inc/header.php');     \r
5         if (!loginStatus()) header('location: login.php');      \r
6 ?>\r
7 <script type="text/javascript" src="js/colorpicker.js"></script>\r
8 <script type="text/javascript" src="js/setting.js?ver=20100206"></script>\r
9 <link rel="stylesheet" href="css/colorpicker.css" type="text/css" />\r
10 <div id="statuses" class="column round-left">\r
11         <div id="setting">\r
12 <?php \r
13         if (isset($_POST['name'])) {\r
14                 $t = getTwitter();\r
15                 $args = array();\r
16                 $args['name'] = $_POST['name'];\r
17                 $args['url'] = $_POST['url'];\r
18                 $args['location'] = $_POST['location'];\r
19                 $args['description'] = $_POST['description'];\r
20                 $result = $t->updateProfile($args);\r
21                 if ($result) echo "<div id=\"otherTip\">Your profile has been updated!</div>";\r
22                 else echo "<div id=\"otherTip\">Update failed. Please try again.</div>";\r
23         }\r
24 \r
25         if (isset($_GET['t'])){\r
26                 $settingType = $_GET['t'];\r
27         }\r
28 ?>\r
29 <div id="setting_nav">\r
30 <?php\r
31         switch($settingType){\r
32                 case 'profile':\r
33 ?>\r
34                         <span class="subnavLink"><a href="setting.php">Customize</a></span><span class="subnavNormal">Edit Profile</span><span class="subnavLink"><a href="setting.php?t=advanced">Advanced</a></span>\r
35 <?php                   \r
36                         break;\r
37                 case 'advanced':\r
38 ?>\r
39                         <span class="subnavLink"><a href="setting.php">Customize</a></span><span class="subnavLink"><a href="setting.php?t=profile">Edit Profile</a></span><span class="subnavNormal">Advanced</span>\r
40 <?php           \r
41                         break;\r
42                 default:\r
43 ?>\r
44                         <span class="subnavNormal">Customize</span><span class="subnavLink"><a href="setting.php?t=profile">Edit Profile</a></span><span class="subnavLink"><a href="setting.php?t=advanced">Advanced</a></span>\r
45 <?php   \r
46         } // end switch\r
47 ?>\r
48 </div>\r
49 <?php\r
50         switch($settingType){\r
51                 case 'profile':\r
52                         $user = getTwitter()->veverify();\r
53 ?>\r
54                         <form id="setting_form" action="setting.php?t=profile" method="post">\r
55                                 <table id="setting_table">\r
56                                 <tr>\r
57                                 <td class="setting_title">Name:</td>\r
58                                 <td><input class="setting_input" type="text" name="name" value="<?php echo isset($user->name) ? $user->name : ''?>" /></td>\r
59                                 </tr>\r
60                                 <tr>\r
61                                 <td class="setting_title">URL:</td>\r
62                                 <td><input class="setting_input" type="text" name="url" value="<?php echo isset($user->url) ? $user->url : '' ?>" /></td>\r
63                                 </tr>\r
64                                 <tr>\r
65                                 <td class="setting_title">Location:</td>\r
66                                 <td><input class="setting_input" type="text" name="location" value="<?php echo isset($user->location) ? $user->location : '' ?>" /></td>\r
67                                 </tr>\r
68                                 <tr>\r
69                                 <td class="setting_title">Bio:</td>\r
70                                 <td><textarea id="setting_text" name="description"><?php echo isset($user->description) ? $user->description : '' ?></textarea><small style="margin-left:5px;vertical-align: top;">*Max 160 chars</small></td>\r
71                                 </tr>\r
72                                 <tr>\r
73                                 <td colspan="2"><input type="submit" class="btn" style="margin-left:62px !important" id="save_button" value="Save"></input></td>\r
74                                 </tr>\r
75                                 </table>\r
76                                 </form>\r
77 <?php\r
78                         break;\r
79                 case 'advanced':\r
80 ?>\r
81                 <div id="otherTip">More features coming soon!</div>\r
82 <?php\r
83                         break;\r
84                 default:\r
85                         if ( isset($_POST['myCSS']) ) {\r
86                                 try {\r
87                                         saveStyle($_POST['myCSS'], $_POST['fontsize'], $_POST['ad_display'], $_POST['bodyBg']);\r
88                                         echo "<div id=\"otherTip\">Your style has been updated!</div>";\r
89                                         $arr;\r
90                                         preg_match('/\(([\w\/\.\-_\&\#\$\%\:]+)\)/i', $_POST['myCSS'], $arr);\r
91                                         echo '<script>var styles = "/'.$arr[1].'";\r
92                                         var newSS=document.createElement("link");\r
93                                         newSS.rel="stylesheet";\r
94                                         newSS.type="text/css";\r
95                                         newSS.href=escape(styles);\r
96                                         document.getElementsByTagName("head")[0].appendChild(newSS);</script>';\r
97                                 } catch (Exception $e) {\r
98                                         echo "<div id=\"otherTip\">Update failed. Please try again.</div>";\r
99                                 }\r
100                         }\r
101                         if ( isset($_GET['reset']) ) {\r
102                                 resetStyle();\r
103                                 echo "<div id=\"otherTip\">Styles have been reseted!</div>";\r
104                         }\r
105                         if(isset($_POST['updatesInterval'])){\r
106                                 setcookie('updatesInterval', $_POST['updatesInterval'], time()+3600*24*365, '/');\r
107                                 setcookie('intervalChanged', 'true', time()+3600*24*365, '/');\r
108                         }\r
109                         if(isset($_POST['homeInterval'])){\r
110                                 setcookie('homeInterval', $_POST['updatesInterval'], time()+3600*24*365, '/');\r
111                                 setcookie('intervalChanged', 'true', time()+3600*24*365, '/');\r
112                         }\r
113 ?>\r
114                 <form id="style_form" action="setting.php" method="post">\r
115 \r
116                         <fieldset class="settings">\r
117 \r
118                         <legend>Enhancements</legend>\r
119 \r
120                         <input id="show_pic" type="checkbox" checked="checked" />\r
121                         <label>Enable Auto Images Preview</label>\r
122                         <small>(Supports mainstream image hostings)</small>\r
123 \r
124                         <br /><br />\r
125 \r
126                         <input id="mediaPreSelect" type="checkbox" />\r
127                         <label>Enable Auto Medias Preview</label>\r
128                         <small>(Supports Xiami and Tudou)</small><br />\r
129 \r
130                         </fieldset>\r
131 \r
132                         <fieldset class="settings">\r
133 \r
134                         <legend>Auto Refresh Interval</legend>\r
135 \r
136                         <label>Home Page</label>\r
137                         <select id="homeInterval" name="homeInterval" value="<?php echo getCookie('homeInterval')?>">\r
138                                 <option value="0.5">30 sec</option>\r
139                                 <option value="1" selected="selected">1 min(Default)</option>\r
140                                 <option value="3">3 min</option>\r
141                                 <option value="5">5 min</option>\r
142                                 <option value="10">10 min</option>\r
143                                 <option value="0">Never</option>\r
144                         </select>\r
145                         <small>(https://rabr.in/index.php)</small>\r
146 \r
147                         <br /><br />\r
148 \r
149                         <label>Updates Page</label>\r
150                         <select id="updatesInterval" name="updatesInterval" value="<?php echo getCookie('updatesInterval')?>">\r
151                                 <option value="0.5">30 sec</option>\r
152                                 <option value="1">1 min</option>\r
153                                 <option value="3" selected="selected">3 min(Default)</option>\r
154                                 <option value="5">5 min</option>\r
155                                 <option value="10">10 min</option>\r
156                                 <option value="0">Never</option>\r
157                         </select>\r
158                         <small>(https://rabr.in/all.php)</small>\r
159 \r
160                         </fieldset>\r
161 \r
162                         <fieldset class="settings">\r
163 \r
164                         <legend>UI Preferences</legend>\r
165 \r
166                         <label>Custom Themes</label>\r
167                         <select id="styleSelect"><option value="n/a">Choose one...</option></select>\r
168                         <small>(We have awesome themes for you!)</small>\r
169 \r
170                         <br /><br />\r
171 \r
172                         <label>Background Color</label>\r
173                         <input class="bg_input" type="text" id="bodyBg" name="bodyBg" value="<?php echo getColor("bodyBg","") ?>" />\r
174                         <small>(Choose your favorite color here)</small>\r
175 \r
176                         <br /><br />\r
177 \r
178                         <label>Font Size</label>\r
179                         <select id="fontsize" name="fontsize" value="<?php echo getCookie('fontsize')?>">\r
180                                 <option value="12px">Small</option>\r
181                                 <option value="13px" selected="selected">Middle(Default)</option>\r
182                                 <option value="14px">Large</option>\r
183                                 <option value="15px">Extra Large</option>\r
184                         </select>\r
185                         <small>(Set the font size)</small>\r
186 \r
187                         <br /><br />\r
188                         \r
189                         <label>Support Rabr</label>\r
190                         <select id="ad_display" name="ad_display" value="<?php echo getCookie('ad_display')?>">\r
191                                 <option value="block" selected="selected">Count me in!</option>\r
192                                 <option value="none">Nah, not me...</option>\r
193                         </select>\r
194                         <small>(Sidebar AD display management)</small>\r
195 \r
196                         <br /><br />                    \r
197 \r
198                         <label>Customize CSS</label>\r
199                         <small>(You can put your own CSS hack here, or your Twitter style code)</small>\r
200                         <br />\r
201                         <textarea type="text" id="myCSS" name="myCSS" value="" /><?php echo getColor("myCSS","") ?></textarea>\r
202 \r
203                         </fieldset>\r
204 \r
205                         <table>\r
206                         <tr>\r
207                         <td colspan="2">\r
208                         <input type="submit" class="btn" id="save_button" value="Save" />\r
209                         <a id="reset_link" href="setting.php?reset=true" title="You will lose all customized settings!">Reset to default</a>\r
210                         </td>\r
211                         </tr>\r
212                         </table>\r
213 \r
214                 </form>\r
215 <?php\r
216         } // end switch\r
217 ?>\r
218 \r
219         </div>\r
220 </div>\r
221 \r
222 <?php \r
223         include ('inc/sidebar.php');\r
224 ?>\r
225 \r
226 <?php \r
227         include ('inc/footer.php');\r
228 ?>\r