-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
121 lines (111 loc) · 4.71 KB
/
Copy pathindex.php
File metadata and controls
121 lines (111 loc) · 4.71 KB
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
<?php
require "db.inc.php";
if ($loggedin && $_SESSION['last'] == $username &&
$_SESSION['cat'] == true &&
$_SESSION['links'] == true) {
// If the username is the same, allow caching
cache();
} else {
diable_cache();
if ($username !== false) {
$_SESSION['last'] = $username;
}
$_SESSION['cat'] = true;
$_SESSION['links'] = true;
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<base target="_top">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="language" content="english">
<title>Home Page</title>
<link rel="apple-touch-icon" sizes="57x57" href="/favicons/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/favicons/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/favicons/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/favicons/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/favicons/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/favicons/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/favicons/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/favicons/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/favicons/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicons/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicons/favicon-16x16.png">
<link rel="manifest" href="/favicons/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/favicons/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<style>
ul { list-style-type: none; line-height: 40px; margin-right: 40px;}
ul li { display: inline; }
</style>
</head>
<body style="background: linear-gradient(135deg, #a9dfbf, #dcdcdc, #a9dfbf);">
<div style="text-align: center;"><font face="Times New Roman, Times, serif"><b><font color="#cc0000" face="Courier New, Courier, mono" size="+1"><?= (! empty($username)) ? ucfirst($username) . ", " : "" ?>Welcome to your Home Page.</font></b></font></div>
<center>
<form action="https://www.duckduckgo.com/" method="get"><font face="Times New Roman, Times, serif"><b><font color="#cc0000" face="Courier New, Courier, mono" size="+1">
<input name="sourceid" value="chrome" type="hidden">
<input name="ie" value="UTF-8" type="hidden">
<input size="90" name="q"><input name="hl" value="en" type="hidden"><input name="source" value="hp" type="hidden"><input name="site" value="" type="hidden"><input value="Search" name="submit" type="submit"></font></b></font></form>
</center>
<?php
/**
* @author Bob S. <Tips@TechnoWizardBob.com>
* @copyright Copyright (c) 2022, Bob S.
* @license MIT
*/
if ($loggedin) {
echo '<a href="insert.php">Add new Link</a> | <a href="index.php'.bust().'&edit=true">Edit Links</a> | ';
echo '<a href="update_cat.php?edit=true">Edit categories</a> | ';
echo '<a href="change_pwd.php?name='.$username.'">Change Password</a> | ';
echo '<a href="logout.php">Log out</a>';
} else {
echo '<a href="login.php?name='.$username.'">Log In</a>';
}
?>
<ul>
<?php
$hide = ($loggedin) ? "" : " WHERE private=\"false\" ";
function get_cat(int $id): string {
try {
$sql = "SELECT category FROM cats WHERE id=:id LIMIT 1";
$pdostmt = $GLOBALS['pdo']->prepare($sql);
$pdostmt->execute(["id"=>$id]);
$r = $pdostmt->fetch(\PDO::FETCH_ASSOC);
if (empty($r['category'])) {
return "Misc.";
}
return (string) $r['category'];
} catch (\PDOException $e) {
echo $e->getMessage();
}
}
try {
$sql = "SELECT cat_id, link_id, link_name, link_href, `description` FROM links {$hide} ORDER BY link_name ASC";
$pdostmt = $pdo->prepare($sql);
$pdostmt->execute();
$a = [];
while($r = $pdostmt->fetch(\PDO::FETCH_ASSOC)) {
$cid = $r['cat_id'];
unset($r['cat_id']);
$a[$cid][] = $r;
}
} catch (\PDOException $e) {
echo $e->getMessage();
}
$edit = $_GET['edit'] ?? false;
foreach($a as $id=>$data) {
echo "<h4>" . get_cat($id) . "</h4>";
foreach($data as $row) {
$edit_row = ($edit === false) ? "</li>": "<a href=\"update.php".bust()."&id={$row['link_id']}\">(Edit)</a></li>";
echo "<li>| <a href=\"{$row['link_href']}\" title=\"{$row['description']}\" target=\"_blank\">{$row['link_name']}</a> {$edit_row} ";
}
}
?>
</ul>
</body>
</html>