sidebar.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. define ("ABSOLUTE_PATH", dirname (__FILE__) . "/");
  3. require_once (ABSOLUTE_PATH . "lib/webstart.php");
  4. require_once (ABSOLUTE_PATH . "config/config.php");
  5. require_once (ABSOLUTE_PATH . "lib/mysql.php");
  6. $mysql = new mysql;
  7. require_once (ABSOLUTE_PATH . "lib/auth.php");
  8. $auth = new Auth;
  9. require_once (ABSOLUTE_PATH . "lib/lib.php");
  10. require_once (ABSOLUTE_PATH . "lib/login.php");
  11. class sidebar {
  12. function sidebar () {
  13. # collect the folder data
  14. require_once (ABSOLUTE_PATH . "folders.php");
  15. $this->tree = new folder;
  16. $this->tree->folders[0] = array ('id' => 0, 'childof' => null, 'name' => $GLOBALS['settings']['root_folder_name']);
  17. global $username, $mysql;
  18. $this->counter = 0;
  19. # collect the bookmark data
  20. $query = sprintf ("SELECT title, url, description, childof, id, favicon
  21. FROM bookmark
  22. WHERE user='%s'
  23. AND deleted!='1' ORDER BY title",
  24. $mysql->escape ($username));
  25. if ($mysql->query ($query)) {
  26. while ($row = mysqli_fetch_assoc ($mysql->result)) {
  27. if (!isset ($this->bookmarks[$row['childof']])) {
  28. $this->bookmarks[$row['childof']] = array ();
  29. }
  30. array_push ($this->bookmarks[$row['childof']], $row);
  31. }
  32. }
  33. else {
  34. message ($mysql->error);
  35. }
  36. }
  37. function make_tree ($folderid) {
  38. if (isset ($this->tree->children[$folderid])) {
  39. $this->counter++;
  40. foreach ($this->tree->children[$folderid] as $value) {
  41. $this->print_folder ($value);
  42. $this->make_tree ($value);
  43. $this->print_folder_close ($value);
  44. }
  45. $this->counter--;
  46. }
  47. $this->print_bookmarks ($folderid);
  48. }
  49. function print_folder ($folderid) {
  50. echo str_repeat (" ", $this->counter) . '<li class="closed"><img src="./jquery/images/folder.gif" alt=""> ' . $this->tree->folders[$folderid]['name'] . "\n";
  51. if (isset ($this->tree->children[$folderid]) || isset ($this->bookmarks[$folderid])) {
  52. echo str_repeat (" ", $this->counter + 1) . "<ul>\n";
  53. }
  54. }
  55. function print_folder_close ($folderid) {
  56. if (isset ($this->tree->children[$folderid]) || isset ($this->bookmarks[$folderid])) {
  57. echo str_repeat (" ", $this->counter + 1) . "</ul>\n";
  58. }
  59. echo str_repeat (" ", $this->counter) . "</li>\n";
  60. }
  61. function print_bookmarks ($folderid) {
  62. $spacer = str_repeat (" ", $this->counter);
  63. if (isset ($this->bookmarks[$folderid])) {
  64. foreach ($this->bookmarks[$folderid] as $value) {
  65. if ($value['favicon'] && is_file ($value['favicon'])) {
  66. $icon = '<img src="' . $value['favicon'] . '" width="16" height="16" border="0" alt="">';
  67. }
  68. else {
  69. $icon = '<img src="./jquery/images/file.gif" alt="">';
  70. }
  71. echo $spacer . ' <li><a href="' . $value['url'] . '" target="_blank">' . $icon . " " . $value['title'] . "</a></li>\n";
  72. }
  73. }
  74. }
  75. }
  76. ?>
  77. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  78. <html>
  79. <head>
  80. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  81. <title>Online-Bookmarks</title>
  82. <link rel="stylesheet" type="text/css" href="./style.css">
  83. <script src="./jquery/jquery.js" type="text/javascript"></script>
  84. <script src="./jquery/jquery.treeview.js" type="text/javascript"></script>
  85. <script type="text/javascript">
  86. $(document).ready(function(){
  87. $("#browser").Treeview();
  88. });
  89. </script>
  90. <style type="text/css">
  91. html, body {height:100%; margin: 0; padding: 0; }
  92. html>body {
  93. font-size: 16px;
  94. font-size: 68.75%;
  95. } /* Reset Base Font Size */
  96. body {
  97. font-family: Verdana, helvetica, arial, sans-serif;
  98. font-size: 68.75%;
  99. background: #fff;
  100. color: #333;
  101. padding-left: 20px;
  102. } /* Reset Font Size */
  103. .treeview, .treeview ul {
  104. padding: 0;
  105. margin: 0;
  106. list-style: none;
  107. }
  108. .treeview li {
  109. margin: 0;
  110. padding: 3px 0pt 3px 16px;
  111. }
  112. ul.dir li { padding: 2px 0 0 16px; }
  113. .treeview li { background: url(./jquery/images/tv-item.gif) 0 0 no-repeat; }
  114. .treeview .collapsable { background-image: url(./jquery/images/tv-collapsable.gif); }
  115. .treeview .expandable { background-image: url(./jquery/images/tv-expandable.gif); }
  116. .treeview .last { background-image: url(./jquery/images/tv-item-last.gif); }
  117. .treeview .lastCollapsable { background-image: url(./jquery/images/tv-collapsable-last.gif); }
  118. .treeview .lastExpandable { background-image: url(./jquery/images/tv-expandable-last.gif); }
  119. </style>
  120. </head>
  121. <body>
  122. <p><a href="./">Back to Online-Bookmarks</a></p>
  123. <?php
  124. logged_in_only ();
  125. $sidebar = new sidebar;
  126. echo '<ul id="browser" class="dir">' . "\n";
  127. $sidebar->make_tree (0);
  128. echo "</ul>\n";
  129. require_once (ABSOLUTE_PATH . "footer.php");
  130. ?>