-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsidebar.php
171 lines (141 loc) · 5.11 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
160
161
162
163
164
165
166
167
168
169
170
<?php
require_once(realpath(__DIR__ . '/config/config.php'));
require_once(realpath(DOC_ROOT . '/lib/mysql.php'));
$mysql = new Mysql();
require_once(realpath(DOC_ROOT .'/lib/auth.php'));
$auth = new Auth();
require_once(realpath(DOC_ROOT .'/lib/lib.php'));
require_once(realpath(DOC_ROOT .'/lib/login.php'));
class sidebar
{
public $tree;
public $counter;
public $bookmarks;
function __construct() {
global $username, $mysql;
// Collect the folder data.
require_once(realpath(DOC_ROOT .'/folders/folder.php'));
$this->tree = new Folder();
$this->tree->folders[0] = ['id' => 0, 'childof' => null, 'name' => $GLOBALS['settings']['root_folder_name']];
$this->counter = 0;
// Collect the bookmark data.
$query = sprintf("
SELECT `title`, `url`, `description`, `childof`, `id`, `favicon`
FROM `obm_bookmarks`
WHERE `user`='%s'
AND `deleted`!='1' ORDER BY `title`",
$mysql->escape($username));
if ($mysql->query($query)) {
while ($row = mysqli_fetch_assoc($mysql->result)) {
if (!isset($this->bookmarks[$row['childof']])) {
$this->bookmarks[$row['childof']] = [];
}
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) {
global $cfg;
echo str_repeat(' ', $this->counter) . '<li class="closed"><img src="'. $cfg['sub_dir'] .'/includes/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>'. PHP_EOL;
}
}
function print_folder_close($folderid) {
if (isset($this->tree->children[$folderid]) || isset($this->bookmarks[$folderid])) {
echo str_repeat(' ', $this->counter + 1) . '</ul>'. PHP_EOL;
}
echo str_repeat(' ', $this->counter) . '</li>'. PHP_EOL;
}
function print_bookmarks($folderid) {
global $cfg;
$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="'. $cfg['sub_dir'] .'?>/includes/jquery/images/file.gif" alt="">';
}
echo $spacer .' <li><a href="'. $value['url'] .'" target="_blank">'. $icon .' '. $value['title'] ."</a></li>\n";
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex,nofollow,noarchive" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title> OpenBookmark </title>
<link rel="stylesheet" type="text/css" href="<?= $cfg['sub_dir'] ?>/includes/css/style.css">
<script src="<?= $cfg['sub_dir'] ?>/includes/jquery/jquery.js"></script>
<script src="<?= $cfg['sub_dir'] ?>/includes/jquery/jquery.treeview.js"></script>
<script>
$(document).ready(function() {
$("#browser").Treeview();
});
</script>
<style>
html, body {height:100%; margin: 0; padding: 0; }
html>body {
font-size: 1em;
/* 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(<?= $cfg['sub_dir'] ?>/includes/jquery/images/tv-item.gif) 0 0 no-repeat; }
.treeview .collapsable { background-image: url(<?= $cfg['sub_dir'] ?>/includes/jquery/images/tv-collapsable.gif); }
.treeview .expandable { background-image: url(<?= $cfg['sub_dir'] ?>/includes/jquery/images/tv-expandable.gif); }
.treeview .last { background-image: url(<?= $cfg['sub_dir'] ?>/includes/jquery/images/tv-item-last.gif); }
.treeview .lastCollapsable { background-image: url(<?= $cfg['sub_dir'] ?>/includes/jquery/images/tv-collapsable-last.gif); }
.treeview .lastExpandable { background-image: url(<?= $cfg['sub_dir'] ?>/includes/jquery/images/tv-expandable-last.gif); }
</style>
<?php echo ($settings['theme'] != '') ? '<link rel="stylesheet" type="text/css" href="'. $cfg['sub_dir'] .'/includes/css/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">' . PHP_EOL;
$sidebar->make_tree(0);
echo '</ul>'. PHP_EOL;
require_once(realpath(DOC_ROOT .'/footer.inc.php'));
?>