-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
143 lines (125 loc) · 4.58 KB
/
index.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
<?php
if (!file_exists('bookd.sqlite')) {
header('Location: setup.php');
}
require_once('inc/files.php');
require_once('inc/functions.php');
require_once('vendor/autoload.php');
require_once('inc/document.php');
if(logged_in() && isset($_GET['del'])) {
db_delete_document(intval($_GET['del']));
header('Location: index.php');
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>BookMark'd</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/search.css" rel="stylesheet" media="screen">
<style>
body {
padding-top: 60px;
}
</style>
<link href="css/responsive.css" rel="stylesheet" media="screen">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="index.php">BookMark'd</a>
<div class="nav-collapse collapse">
<form method="get" action="search.php" class="navbar-search pull-right">
<input type="text" class="search-query" name="q" placeholder="Search">
</form>
</div>
</div>
</div>
</div>
<div class="container">
<?php
$how_many = 15;
$page = isset($_GET['p']) ? intval($_GET['p']) : 0;
$results = db_list_documents($how_many, $page);
$pagination = db_paginate_documents($how_many, $page, 6);
$num_res = count($results);
if ($num_res == 0) {
echo '<p>No bookmarks.</p>';
} else {
echo '<ol start="' . ($page * $how_many + 1) . '">';
for($r = 0; $r < $num_res; $r++) {
$res = $results[$r];
$doc_content = db_get_content($res['id']);
$parts = parse_query(ascii_only($res['title']));
$terms = $parts['terms'];
?>
<li>
<a href="view.php?doc=<?=$res['id']?>" rel="tooltip" title="<?=$res['path']?>"><img src="https://plus.google.com/_/favicon?domain=<?php
$parsed_url = parse_url($res['path']);
if (isset($parsed_url['host'])) {
echo $parsed_url['host'];
} else {
echo urlencode($res['path']);
}
?>" style="margin-top: -4px"> <?=strip_tags_and_javascript($res['title'])?></a><?php
if(logged_in()) {
?>
<a href="?del=<?=$res['id']?>" rel="tooltip" title="Delete" class="delete">×</a>
<?php
}
?>
<p><?=($r<15)?get_syop($doc_content, $terms) : ''?></p>
</li>
<?php
}
echo '</ol>';
}
?>
<div class="pagination text-center">
<ul>
<?php
if ($page == 0) {
echo '<li class="disabled"><a href="#">«</a></li>';
} else {
echo '<li><a href="?p=' . ($page - 1) . '">«</a></li>';
}
foreach($pagination as $paginator) {
if ($paginator == -1) {
echo '<li class="disabled"><a href="#">…</a></li>';
} else {
echo '<li' . (($page == $paginator) ? ' class="active"':'') . '>';
echo '<a href="?p=' . $paginator . '">' . ($paginator + 1) . '</a></li>';
}
}
if ($page < $pagination[count($pagination) - 1]) {
echo '<li><a href="?p=' . ($page + 1) . '">»</a></li>';
} else {
echo '<li class="disabled"><a href="#">»</a></li>';
}
?>
</ul>
</div>
</div>
<footer id="footer">
<div class="container">
<p class="text-center"><a href="index.php">Home</a> <a href="search.php?q=search">Search</a> <a href="admin.php">Admin</a><br>Powered by <a href="http://kmwallio.github.io/BookMarkd">BookMark'd</a>.</p>
</div>
</footer>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$(document).ready(function () {
$("[rel=tooltip]").tooltip({'placement':'right'});
$('.navbar').scrollspy();
});
</script>
</body>
</html>