bookmark_edit.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. require_once ("./header.php");
  3. logged_in_only ();
  4. $bmlist = set_get_num_list ('bmlist');
  5. $post_title = set_post_title ();
  6. $post_url = set_post_url ();
  7. $post_description = set_post_description ();
  8. $post_icon = set_post_bool_var ('favicon', false);
  9. $post_childof = set_post_childof ();
  10. $post_public = set_post_bool_var ("public", false);
  11. if (count ($bmlist) > 1) {
  12. # if there is more than one bookmark to edit, we just care about the
  13. # public/private field.
  14. if ( ! isset ($_POST['public'])) {
  15. $qbmlist = implode (",", $bmlist);
  16. $query = sprintf ("SELECT title, id, public, favicon FROM bookmark WHERE id IN (%s) AND user='%s' ORDER BY title",
  17. $mysql->escape ($qbmlist),
  18. $mysql->escape ($username));
  19. if ($mysql->query ($query)) {
  20. require_once (ABSOLUTE_PATH . "bookmarks.php");
  21. $query_string = "?bmlist=" . implode ("_", $bmlist);
  22. ?>
  23. <h2 class="title">Change public state:</h2>
  24. <div style="width:100%; height:330px; overflow:auto;">
  25. <?php
  26. $bookmarks = array ();
  27. while ($row = mysqli_fetch_assoc ($mysql->result)) {
  28. array_push ($bookmarks, $row);
  29. }
  30. list_bookmarks ($bookmarks,
  31. false,
  32. false,
  33. $settings['show_bookmark_icon'],
  34. false,
  35. false,
  36. false,
  37. false,
  38. false,
  39. false,
  40. true,
  41. false);
  42. ?>
  43. </div>
  44. <br>
  45. <form action="<?php echo $_SERVER['SCRIPT_NAME'] . $query_string; ?>" method="POST" name="bmedit">
  46. <p>
  47. <select name="public">
  48. <option value="1">public</option>
  49. <option value="0">private</option>
  50. </select>
  51. </p>
  52. <input type="submit" value=" OK ">
  53. <input type="button" value=" Cancel " onClick="self.close()">
  54. </form>
  55. <?php
  56. }
  57. else {
  58. message ($mysql->error);
  59. }
  60. }
  61. else {
  62. $bmlist = implode (",", $bmlist);
  63. $query = sprintf ("UPDATE bookmark SET public='%d'
  64. WHERE id IN (%s)
  65. AND user='%s'",
  66. $mysql->escape ($post_public),
  67. $mysql->escape ($bmlist),
  68. $mysql->escape ($username));
  69. if ($mysql->query ($query)) {
  70. echo "Bookmark successfully updated<br>\n";
  71. echo '<script language="JavaScript">reloadclose();</script>';
  72. }
  73. else {
  74. message ($mysql->error);
  75. }
  76. }
  77. }
  78. else if (count ($bmlist) < 1) {
  79. message ("No Bookmark to edit.");
  80. }
  81. else if ($post_title == "" || $post_url == "" || $post_icon) {
  82. $query = sprintf ("SELECT title, url, description, childof, id, favicon, public
  83. FROM bookmark
  84. WHERE id='%d'
  85. AND user='%s'
  86. AND deleted != '1'",
  87. $mysql->escape ($bmlist[0]),
  88. $mysql->escape ($username));
  89. if ($mysql->query ($query)) {
  90. if (mysqli_num_rows ($mysql->result) != 1) {
  91. message ("No Bookmark to edit");
  92. }
  93. else {
  94. $row = mysqli_fetch_object ($mysql->result);
  95. require_once (ABSOLUTE_PATH . "folders.php");
  96. $tree = new folder;
  97. $query_string = "?expand=" . implode(",", $tree->get_path_to_root ($row->childof)) . "&amp;folderid=" . $row->childof;
  98. $path = $tree->print_path ($row->childof);
  99. if ($post_icon && $settings['show_bookmark_icon']) {
  100. if (isset ($row->favicon)) {
  101. @unlink ($row->favicon);
  102. }
  103. require_once (ABSOLUTE_PATH . "favicon.php");
  104. $favicon = new favicon ($post_url);
  105. if (isset ($favicon->favicon)) {
  106. $icon = '<img src="' . $favicon->favicon . '" width="16" height="16" alt="">';
  107. $query = sprintf ("UPDATE bookmark SET favicon='%s' WHERE user='%s' AND id='%d'",
  108. $mysql->escape ($favicon->favicon),
  109. $mysql->escape ($username),
  110. $mysql->escape ($bmlist[0]));
  111. if (!$mysql->query ($query)) {
  112. message ($mysql->error);
  113. }
  114. }
  115. else {
  116. $icon = $bookmark_image;
  117. }
  118. }
  119. else if ($row->favicon && is_file ($row->favicon)) {
  120. $icon = '<img src="' . $row->favicon . '" width="16" height="16" alt="">';
  121. }
  122. else {
  123. $icon = $bookmark_image;
  124. }
  125. }
  126. }
  127. else {
  128. message ($mysql->error);
  129. }
  130. ?>
  131. <h2 class="title">Edit Bookmark</h2>
  132. <form action="<?php echo $_SERVER['SCRIPT_NAME'] . "?bmlist=" . $row->id; ?>" id="bmedit" method="POST">
  133. <p>Title<br>
  134. <input type=text name="title" size="50" value="<?php echo $row->title; ?>"> <?php echo $settings['show_bookmark_icon'] ? $icon : ""; ?></p>
  135. <p>URL<br>
  136. <input type=text name="url" size="50" value="<?php echo $row->url; ?>">
  137. <p>Description<br>
  138. <textarea name="description" cols="50" rows="8"><?php echo $row->description; ?></textarea></p>
  139. <p><input type="button" value="Select folder" onClick="window.childof=document.forms['bmedit'].childof; window.path=document.forms['bmedit'].path; selectfolder('<?php echo $query_string; ?>')"><br>
  140. <input type="text" name="path" value="<?php echo $path; ?>" size="50" readonly>
  141. <input type="text" name="childof" value="<?php echo $row->childof; ?>" size="1" class="invisible" readonly></p>
  142. <p>Tags<br>
  143. <input type=text name="tags" size="50" value="Not yet working"></p>
  144. <input type="submit" value=" OK ">
  145. <input type="button" value=" Cancel " onClick="self.close()">
  146. <?php if ($settings['show_bookmark_icon']) : ?><input type="submit" value="Refresh Icon" name="favicon"><?php endif; ?>
  147. Public <input type="checkbox" name="public" <?php echo $row->public ? "checked" : "";?>>
  148. </form>
  149. <script>
  150. this.focus();
  151. document.getElementById('bmedit').title.focus();
  152. </script>
  153. <?php
  154. }
  155. else {
  156. $query = sprintf ("UPDATE bookmark SET title='%s', url='%s', description='%s', childof='%d', public='%d'
  157. WHERE id='%d'
  158. AND user='%s'",
  159. $mysql->escape ($post_title),
  160. $mysql->escape ($post_url),
  161. $mysql->escape ($post_description),
  162. $mysql->escape ($post_childof),
  163. $mysql->escape ($post_public),
  164. $mysql->escape ($bmlist[0]),
  165. $mysql->escape ($username));
  166. if ($mysql->query ($query)) {
  167. echo "Bookmark successfully updated<br>\n";
  168. echo '<script language="JavaScript">reloadclose();</script>';
  169. }
  170. else {
  171. message ($mysql->error);
  172. }
  173. }
  174. require_once (ABSOLUTE_PATH . "footer.php");
  175. ?>