shared.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. require_once ('./header.php');
  3. if ($_SESSION['logged_in']) {
  4. $user = set_get_string_var ('user', $username);
  5. }
  6. else {
  7. $user = set_get_string_var ('user');
  8. }
  9. $display_shared = false;
  10. if (isset ($_GET['user']) && check_username ($user)) {
  11. $title = $user . "&#039;s Online Bookmarks";
  12. }
  13. else {
  14. $title = "Shared Online-Bookmarks";
  15. }
  16. $order = set_get_order ();
  17. ?>
  18. <h1 id="caption"><?php echo $title; ?></h1>
  19. <!-- Wrapper starts here. -->
  20. <div style="min-width: <?php echo 230 + $settings['column_width_folder']; ?>px;">
  21. <!-- Menu starts here. -->
  22. <div id="menu">
  23. <h2 class="nav">Bookmarks</h2>
  24. <ul class="nav">
  25. <li><a href="./index.php">My Bookmarks</a></li>
  26. <li><a href="./shared.php">Shared Bookmarks</a></li>
  27. </ul>
  28. <h2 class="nav">Tools</h2>
  29. <ul class="nav">
  30. <?php if (isset ($_SESSION['logged_in']) && $_SESSION['logged_in']) { ?>
  31. <?php if (admin_only ()) { ?>
  32. <li><a href="./admin.php">Admin</a></li>
  33. <?php } ?>
  34. <li><a href="./import.php">Import</a></li>
  35. <li><a href="./export.php">Export</a></li>
  36. <li><a href="./sidebar.php">View as Sidebar</a></li>
  37. <li><a href="./settings.php">Settings</a></li>
  38. <li><a href="./index.php?logout=1">Logout</a></li>
  39. <?php } else { ?>
  40. <li><a href="./index.php">Login</a></li>
  41. <?php } ?>
  42. </ul>
  43. <!-- Menu ends here. -->
  44. </div>
  45. <!-- Main content starts here. -->
  46. <div id="main">
  47. <?php
  48. if (isset ($_GET['user']) && check_username ($user)) {
  49. ?>
  50. <!-- Folders starts here. -->
  51. <div class="folders" style="width: <?php echo $column_width_folder; ?>; height: <?php echo $table_height; ?>;">
  52. <?php
  53. require_once (ABSOLUTE_PATH . "folders.php");
  54. $tree = new folder ($user);
  55. $tree->make_tree (0);
  56. $tree->print_tree ();
  57. ?>
  58. <!-- Folders ends here. -->
  59. </div>
  60. <!-- Bookmarks starts here. -->
  61. <div class="bookmarks" style="height: <?php echo $table_height; ?>;">
  62. <?php
  63. require_once (ABSOLUTE_PATH . "bookmarks.php");
  64. $query = sprintf ("SELECT title, url, description, UNIX_TIMESTAMP(date) AS timestamp, id, favicon
  65. FROM bookmark
  66. WHERE user='%s'
  67. AND childof='%d'
  68. AND deleted!='1'
  69. AND public='1'
  70. ORDER BY $order[1]",
  71. $mysql->escape ($user),
  72. $mysql->escape ($folderid));
  73. if ($mysql->query ($query)) {
  74. $bookmarks = array ();
  75. while ($row = mysqli_fetch_assoc ($mysql->result)) {
  76. array_push ($bookmarks, $row);
  77. }
  78. list_bookmarks ($bookmarks,
  79. false,
  80. false,
  81. $settings['show_bookmark_icon'],
  82. true,
  83. $settings['show_bookmark_description'],
  84. $settings['show_column_date'],
  85. false,
  86. false,
  87. false,
  88. false,
  89. true,
  90. $user);
  91. }
  92. else {
  93. message ($mysql->error);
  94. }
  95. ?>
  96. <!-- Bookmarks ends here. -->
  97. </div>
  98. <?php
  99. }
  100. else {
  101. echo '<div id="content" style="height:' . $table_height . ';">' . "\n";
  102. $query = "SELECT user, SUM(bookmarks) AS bookmarks, SUM(folders) AS folders FROM (
  103. SELECT user, 1 AS bookmarks, 0 AS folders FROM bookmark WHERE public='1' AND deleted!='1'
  104. UNION ALL
  105. SELECT user, 0 AS bookmarks , 1 AS folders FROM folder WHERE public='1' AND deleted!='1'
  106. ) AS tmp GROUP BY user";
  107. if ($mysql->query ($query)) {
  108. while ($row = mysqli_fetch_object ($mysql->result)) {
  109. echo '<p class="shared"><a href="' . $_SERVER['SCRIPT_NAME'] . '?user=' . $row->user . '&folderid=0"><b>' . $row->user . "</b><br>\n";
  110. echo "Shares $row->folders Folders and $row->bookmarks Bookmarks</a></p>\n";
  111. }
  112. }
  113. else {
  114. message ($mysql->error);
  115. }
  116. echo "</div>";
  117. }
  118. ?>
  119. <!-- Main content ends here. -->
  120. </div>
  121. <!-- Wrapper ends here. -->
  122. </div>
  123. <?php
  124. print_footer ();
  125. require_once (ABSOLUTE_PATH . "footer.php");
  126. ?>