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