-
Notifications
You must be signed in to change notification settings - Fork 0
/
shared.php
159 lines (137 loc) · 4.21 KB
/
shared.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
require_once(realpath(__DIR__ . '/header.php'));
if ($_SESSION['logged_in']) {
$user = set_get_string_var('user', $username);
}
else {
$user = set_get_string_var('user');
}
$display_shared = false;
if (isset ($_GET['user']) && check_username($user)) {
$title = $user . ''s Online Bookmarks';
}
else {
$title = 'Shared OpenBookmark';
}
$order = set_get_order();
?>
<h1 id="caption"><?php echo $title; ?></h1>
<!-- Wrapper starts here. -->
<div style="min-width: <?php echo 230 + $settings['column_width_folder']; ?>px;">
<!-- Menu starts here. -->
<div id="menu">
<h2 class="nav">Bookmarks</h2>
<ul class="nav">
<li><a href="<?= $cfg['sub_dir'] ?>/index.php">My Bookmarks</a></li>
<li><a href="<?= $cfg['sub_dir'] ?>/shared.php">Shared Bookmarks</a></li>
</ul>
<h2 class="nav">Tools</h2>
<ul class="nav">
<?php if (isset ($_SESSION['logged_in']) && $_SESSION['logged_in']) : ?>
<?php if (admin_only()) : ?>
<li><a href="<?= $cfg['sub_dir'] ?>/admin.php">Admin</a></li>
<?php endif ?>
<li><a href="<?= $cfg['sub_dir'] ?>/import.php">Import</a></li>
<li><a href="<?= $cfg['sub_dir'] ?>/export.php">Export</a></li>
<li><a href="<?= $cfg['sub_dir'] ?>/sidebar.php">View as Sidebar</a></li>
<li><a href="<?= $cfg['sub_dir'] ?>/settings.php">Settings</a></li>
<li><a href="<?= $cfg['sub_dir'] ?>/index.php?logout=1">Logout</a></li>
<?php else : ?>
<li><a href="<?= $cfg['sub_dir'] ?>/index.php">Login</a></li>
<?php endif ?>
</ul>
<!-- Menu ends here. -->
</div>
<!-- Main content starts here. -->
<div id="main">
<?php
if (isset($_GET['user']) && check_username($user)) {
?>
<!-- Folders starts here. -->
<div class="folders" style="width: <?php echo (($column_width_folder == 0) ? "auto" : $column_width_folder); ?>; height: <?php echo (($table_height == 0) ? "auto" : $table_height); ?>;">
<?php
require_once(realpath(DOC_ROOT . '/folders/folder.php'));
$tree = new Folder($user);
$tree->make_tree(0);
$tree->print_tree();
?>
<!-- Folders ends here. -->
</div>
<!-- Bookmarks starts here. -->
<div class="bookmarks" style="height: <?php echo (($table_height == 0) ? "auto" : $table_height); ?>;">
<?php
require_once(realpath(DOC_ROOT . '/bookmarks/bookmark.php'));
$query = sprintf("
SELECT `title`, `url`, `description`, UNIX_TIMESTAMP(`date_created`) AS timestamp, `id`, `favicon`
FROM `obm_bookmarks`
WHERE `user` = '%s'
AND `childof` = '%d'
AND `deleted` != '1'
AND `public` = '1'
ORDER BY $order[1]",
$mysql->escape($user),
$mysql->escape($folderid)
);
if ($mysql->query($query)) {
$bookmarks = [];
while ($row = mysqli_fetch_assoc($mysql->result)) {
array_push($bookmarks, $row);
}
list_bookmarks(
bookmarks: $bookmarks,
show_checkbox: false,
show_folder: false,
show_icon: $settings['show_bookmark_icon'],
show_link: true,
show_desc: $settings['show_bookmark_description'],
show_date: $settings['show_column_date'],
show_edit: false,
show_move: false,
show_delete: false,
show_share: false,
show_header: true,
user: $user
);
}
else {
message($mysql->error);
}
?>
<!-- Bookmarks ends here. -->
</div>
<?php
}
else {
echo '<div id="content" style="height:' . (($table_height == 0) ? "auto" : $table_height) . ';">' . PHP_EOL;
$query = "
SELECT `user`, SUM(`bookmarks`) AS bookmarks, SUM(`folders`) AS folders
FROM (
SELECT `user`, 1 AS bookmarks, 0 AS folders
FROM `obm_bookmarks`
WHERE `public` = '1' AND `deleted` != '1'
UNION ALL
SELECT `user`, 0 AS bookmarks , 1 AS folders
FROM `obm_folders`
WHERE `public` = '1' AND `deleted` != '1'
) AS tmp
GROUP BY `user`";
if ($mysql->query ($query)) {
while ($row = mysqli_fetch_object ($mysql->result)) {
echo '<p class="shared"><a href="' . $_SERVER['SCRIPT_NAME'] . '?user=' . $row->user . '&folderid=0"><b>' . $row->user . "</b><br>\n";
echo "Shares {$row->folders} Folders and {$row->bookmarks} Bookmarks</a></p>\n";
}
}
else {
message($mysql->error);
}
echo '</div>';
}
?>
<!-- Main content ends here. -->
</div>
<!-- Wrapper ends here. -->
</div>
<?php
print_footer();
require_once(realpath(DOC_ROOT . '/footer.inc.php'));
?>