settings.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <?php
  2. require_once ("./header.php");
  3. logged_in_only ();
  4. $message = '';
  5. if (isset ($_POST['settings_apply'])) {
  6. $settings = array (
  7. 'root_folder_name' => set_post_foldername ("settings_root_folder_name"),
  8. 'column_width_folder' => check_num_var ("settings_column_width_folder"),
  9. 'column_width_bookmark' => check_num_var ("settings_column_width_bookmark"),
  10. 'table_height' => check_num_var ("settings_table_height"),
  11. 'confirm_delete' => set_post_bool_var ("settings_confirm_delete", false),
  12. 'open_new_window' => set_post_bool_var ("settings_open_new_window", false),
  13. 'show_bookmark_description' => set_post_bool_var ("settings_show_bookmark_description", false),
  14. 'show_bookmark_icon' => set_post_bool_var ("settings_show_bookmark_icon", false),
  15. 'show_column_date' => set_post_bool_var ("settings_show_column_date", false),
  16. 'date_format' => check_date_format (),
  17. 'show_column_edit' => set_post_bool_var ("settings_show_column_edit", false),
  18. 'show_column_move' => set_post_bool_var ("settings_show_column_move", false),
  19. 'show_column_delete' => set_post_bool_var ("settings_show_column_delete", false),
  20. 'fast_folder_minus' => set_post_bool_var ("settings_fast_folder_minus", false),
  21. 'fast_folder_plus' => set_post_bool_var ("settings_fast_folder_plus", false),
  22. 'fast_symbol' => set_post_bool_var ("settings_fast_symbol", false),
  23. 'simple_tree_mode' => set_post_bool_var ("settings_simple_tree_mode", false),
  24. 'show_public' => set_post_bool_var ("settings_show_public", false),
  25. );
  26. $query = sprintf ("UPDATE user SET
  27. root_folder_name ='%s',
  28. column_width_folder ='%d',
  29. column_width_bookmark ='%d',
  30. table_height ='%d',
  31. confirm_delete ='%d',
  32. open_new_window ='%d',
  33. show_bookmark_description ='%d',
  34. show_bookmark_icon ='%d',
  35. show_column_date ='%d',
  36. date_format ='%s',
  37. show_column_edit ='%d',
  38. show_column_move ='%d',
  39. show_column_delete ='%d',
  40. fast_folder_minus ='%d',
  41. fast_folder_plus ='%d',
  42. fast_symbol ='%d',
  43. simple_tree_mode ='%d',
  44. show_public ='%d'
  45. WHERE username='%s'",
  46. $mysql->escape ($settings['root_folder_name']),
  47. $settings['column_width_folder'],
  48. $settings['column_width_bookmark'],
  49. $settings['table_height'],
  50. $settings['confirm_delete'],
  51. $settings['open_new_window'],
  52. $settings['show_bookmark_description'],
  53. $settings['show_bookmark_icon'],
  54. $settings['show_column_date'],
  55. $mysql->escape ($settings['date_format']),
  56. $settings['show_column_edit'],
  57. $settings['show_column_move'],
  58. $settings['show_column_delete'],
  59. $settings['fast_folder_minus'],
  60. $settings['fast_folder_plus'],
  61. $settings['fast_symbol'],
  62. $settings['simple_tree_mode'],
  63. $settings['show_public'],
  64. $mysql->escape ($username));
  65. if ($mysql->query ($query)) {
  66. $message = "Settings applied.";
  67. }
  68. else {
  69. message ($mysql->error);
  70. }
  71. }
  72. # I really don't feel like putting these very specific function into lib.php...
  73. function check_num_var ($varname) {
  74. if (!is_numeric ($_POST[$varname])) {
  75. return 280;
  76. }
  77. else if ($_POST[$varname] == 0 && $varname == "settings_column_width_bookmark") {
  78. return 0;
  79. }
  80. else if ($_POST[$varname] < 100) {
  81. return 100;
  82. }
  83. else if ($_POST[$varname] > 800) {
  84. return 800;
  85. }
  86. else {
  87. return $_POST[$varname];
  88. }
  89. }
  90. function check_date_format () {
  91. global $date_formats;
  92. $date_format = set_post_num_var ('settings_date_format');
  93. if ($date_format < 0 || $date_format > count ($date_formats)) {
  94. return 0;
  95. }
  96. else {
  97. return $date_format;
  98. }
  99. }
  100. ?>
  101. <h1 id="caption">My Settings</h1>
  102. <!-- Wrapper starts here. -->
  103. <div style="min-width: <?php echo 230 + $settings['column_width_folder']; ?>px;">
  104. <!-- Menu starts here. -->
  105. <div id="menu">
  106. <h2 class="nav">Bookmarks</h2>
  107. <ul class="nav">
  108. <li><a href="./index.php">My Bookmarks</a></li>
  109. <li><a href="./shared.php">Shared Bookmarks</a></li>
  110. </ul>
  111. <h2 class="nav">Tools</h2>
  112. <ul class="nav">
  113. <?php if (admin_only ()) { ?>
  114. <li><a href="./admin.php">Admin</a></li>
  115. <?php } ?>
  116. <li><a href="./import.php">Import</a></li>
  117. <li><a href="./export.php">Export</a></li>
  118. <li><a href="./sidebar.php">View as Sidebar</a></li>
  119. <li><a href="./settings.php">Settings</a></li>
  120. <li><a href="./index.php?logout=1">Logout</a></li>
  121. </ul>
  122. <!-- Menu ends here. -->
  123. </div>
  124. <!-- Main content starts here. -->
  125. <div id="main">
  126. <table>
  127. <tr>
  128. <td valign="top">
  129. <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="POST">
  130. <table>
  131. <tr>
  132. <td>Name of the root folder</td>
  133. <td>
  134. <input type="text" name="foldername" value="<?php echo $settings['root_folder_name']; ?>">
  135. </td>
  136. </tr>
  137. <tr>
  138. <td>The width in pixels of the folder column<br>100 - 800 pixel</td>
  139. <td>
  140. <input type="text" name="settings_column_width_folder" value="<?php echo $settings['column_width_folder']; ?>" size="5">
  141. </td>
  142. </tr>
  143. <tr>
  144. <td>The width in pixels of the bookmark column<br>100 - 800 pixel or 0 for 100%</td>
  145. <td>
  146. <input type="text" name="settings_column_width_bookmark" value="<?php echo $settings['column_width_bookmark']; ?>" size="5">
  147. </td>
  148. </tr>
  149. <tr>
  150. <td>The height in pixels of the main table<br>100 - 800 pixel</td>
  151. <td>
  152. <input type="text" name="settings_table_height" value="<?php echo $settings['table_height']; ?>" size="5">
  153. </td>
  154. </tr>
  155. <tr>
  156. <td>Confirm deletions of bookmarks an folders</td>
  157. <td>
  158. <input type="checkbox" name="settings_confirm_delete" <?php if ($settings['confirm_delete'] == 1) {echo "checked";}?>>
  159. </td>
  160. </tr>
  161. <tr>
  162. <td>Open a new window when clicking a bookmark</td>
  163. <td>
  164. <input type="checkbox" name="settings_open_new_window" <?php if ($settings['open_new_window'] == 1) {echo "checked";}?>>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td>Show the bookmarks description in the overview</td>
  169. <td>
  170. <input type="checkbox" name="settings_show_bookmark_description" <?php if ($settings['show_bookmark_description'] == 1) {echo "checked";}?>>
  171. </td>
  172. </tr>
  173. <tr>
  174. <td>Enable favicon support: <?php echo $bookmark_image; ?></td>
  175. <td>
  176. <input type="checkbox" name="settings_show_bookmark_icon" <?php if ($settings['show_bookmark_icon'] == 1) {echo "checked";}?>>
  177. </td>
  178. </tr>
  179. <tr>
  180. <td>Show the column with the change date: <?php echo date ($date_formats[$settings['date_format']]); ?></td>
  181. <td>
  182. <input type="checkbox" name="settings_show_column_date" <?php if ($settings['show_column_date'] == 1) {echo "checked";}?>>
  183. </td>
  184. </tr>
  185. <tr>
  186. <td>Date format:</td>
  187. <td>
  188. <select name="settings_date_format">
  189. <?php
  190. foreach ($date_formats as $format_key => $format) {
  191. echo '<option value="'.$format_key.'"';
  192. if ($settings['date_format'] == $format_key) {echo ' selected';}
  193. echo '>'.date ($format)."</option>\n";
  194. }
  195. ?>
  196. </select>
  197. </td>
  198. </tr>
  199. <tr>
  200. <td>Show the private/public column: <span class="private">private</span></td>
  201. <td>
  202. <input type="checkbox" name="settings_show_public" <?php if ($settings['show_public'] == 1) {echo "checked";}?>>
  203. </td>
  204. </tr>
  205. <tr>
  206. <td>Show the column to edit a bookmark: <?php echo $edit_image; ?></td>
  207. <td>
  208. <input type="checkbox" name="settings_show_column_edit" <?php if ($settings['show_column_edit'] == 1) {echo "checked";}?>>
  209. </td>
  210. </tr>
  211. <tr>
  212. <td>Show the column to move a bookmark: <?php echo $move_image; ?></td>
  213. <td>
  214. <input type="checkbox" name="settings_show_column_move" <?php if ($settings['show_column_move'] == 1) {echo "checked";}?>>
  215. </td>
  216. </tr>
  217. <tr>
  218. <td>Show the column to delete a bookmark: <?php echo $delete_image; ?></td>
  219. <td>
  220. <input type="checkbox" name="settings_show_column_delete" <?php if ($settings['show_column_delete'] == 1) {echo "checked";}?>>
  221. </td>
  222. </tr>
  223. <tr>
  224. <td>Collapse tree when clicking on folder icon: <?php echo $minus . $folder_opened; ?></td>
  225. <td>
  226. <input type="checkbox" name="settings_fast_folder_minus" <?php if ($settings['fast_folder_minus'] == 1) {echo "checked";}?>>
  227. </td>
  228. </tr>
  229. <tr>
  230. <td>Expand tree when clicking on folder icon: <?php echo $plus . $folder_opened; ?></td>
  231. <td>
  232. <input type="checkbox" name="settings_fast_folder_plus" <?php if ($settings['fast_folder_plus'] == 1) {echo "checked";}?>>
  233. </td>
  234. </tr>
  235. <tr>
  236. <td>Select folder when clicking on plus/minus symbol</td>
  237. <td>
  238. <input type="checkbox" name="settings_fast_symbol" <?php if ($settings['fast_symbol'] == 1) {echo "checked";}?>>
  239. </td>
  240. </tr>
  241. <tr>
  242. <td>Allways open just one tree</td>
  243. <td>
  244. <input type="checkbox" name="settings_simple_tree_mode" <?php if ($settings['simple_tree_mode'] == 1) {echo "checked";}?>>
  245. </td>
  246. </tr>
  247. <tr>
  248. <td></td>
  249. <td>
  250. <input type="submit" value="Apply" name="settings_apply"> <?php echo $message; ?>
  251. </td>
  252. </tr>
  253. </table>
  254. </form>
  255. </td>
  256. <td valign="top" style="width: 40%;">
  257. <p>
  258. <b><a href="javascript:chpw()">Change Password</a></b>
  259. </p>
  260. <hr>
  261. <?php
  262. if (isset($_SERVER['HTTPS'])) {
  263. $scheme = 'https://';
  264. }
  265. else {
  266. $scheme = 'http://';
  267. }
  268. if (dirname ($_SERVER['SCRIPT_NAME']) == '/') {
  269. $path = '';
  270. }
  271. else {
  272. $path = dirname ($_SERVER['SCRIPT_NAME']);
  273. }
  274. $js_url = $scheme . $_SERVER['SERVER_NAME'] . $path;
  275. ?>
  276. <p>
  277. You can add a button to your browsers "Link Bar" or "Hotlist" so that any homepage
  278. can be bookmarked with one click. Title and URL of the current homepage are being preset.
  279. Basically you can make Online-Bookmarks behave in two different ways showing its
  280. dialog. Either a new window pops up or it shows it in the same window.
  281. </p>
  282. <p>
  283. To show the Online-Bookmarks dialog in a new window, drag this link to the
  284. Link Bar.<br>
  285. <a href="javascript:(function(){bmadd=window.open('<?php echo $js_url; ?>/bookmark_new.php?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href),'bmadd','toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=500,height=500,left=50,top=50');setTimeout(function(){bmadd.focus();});})();" title="bookmark">
  286. <img src="./images/bookmark.gif" alt="bookmark" title="bookmark">
  287. </a><br>
  288. </p>
  289. <p>
  290. To open the Online-Bookmarks dialog in the same window, drag this link to the
  291. Link Bar.<br>
  292. <a href="javascript:location.href='<?php echo $js_url; ?>/bookmark_add.php?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href)" title="bookmark">
  293. <img src="./images/bookmark.gif" alt="bookmark" title="bookmark">
  294. </a><br>
  295. </p>
  296. <p>
  297. Note that if your browser has a Popup Blocker enabled you might experience difficulties using
  298. the upper link.
  299. </p>
  300. <hr>
  301. <p>
  302. <script type="text/javascript">
  303. <!--
  304. function addSidebar() {
  305. if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")){
  306. var sidebarname=window.location.host;
  307. if (!/bug/i.test(sidebarname))
  308. sidebarname="Online Bookmarks "+sidebarname;
  309. window.sidebar.addPanel (sidebarname, "<?php echo $js_url; ?>/sidebar.php", "");
  310. }
  311. else{
  312. var rv = window.confirm ("Your browser does not support the sidebar extension. " + "Would you like to upgrade now?");
  313. if (rv)
  314. document.location.href = "http://www.mozilla.org/";
  315. }
  316. }
  317. //-->
  318. </script>
  319. If you are using <a href="http://www.mozilla.com/firefox/">Firefox</a> as a webbrowser, you can
  320. use the link below to add a bookmark which opens Online-Bookmarks as a sidebar.<br>
  321. <b><a href="javascript:addSidebar()">Add to Sidebar</a></b>
  322. </p>
  323. <hr>
  324. </td>
  325. </tr>
  326. </table>
  327. <!-- Main content ends here. -->
  328. </div>
  329. <!-- Wrapper ends here. -->
  330. </div>
  331. <?php
  332. print_footer ();
  333. require_once (ABSOLUTE_PATH . "footer.php");
  334. ?>