Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
155 lines (132 loc) · 4.79 KB
/
Copy pathindex.php
File metadata and controls
155 lines (132 loc) · 4.79 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
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
<?php declare(strict_types=1);
require_once './inc/settings.inc.php';
require_once './inc/utils.inc.php';
if (array_key_exists('code', $_GET)) {
$select = \Persist\DB\Database::getConnection()->prepare('select get_url(:code)');
try {
if ($select->execute(['code' => $_GET['code']]) && ($url = $select->fetchColumn())) {
$select = null;
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Location: $url");
exit();
} else {
header("HTTP/1.1 404 Not Found");
exit('<h1>404 Not Found');
}
} catch (PDOException $e) {
header("HTTP/1.1 500 Internal Server Error");
exit('<h1>500 Internal Server Error');
}
}
define( 'BASE_URL',
($_SERVER['HTTPS']? 'https://': 'http://') .
$_SERVER['HTTP_HOST'] .
'/'
);
define('DEFAULT_URL', $settings['default_url']);
require_once './inc/session.inc.php';
if (!array_key_exists('user_id', $_SESSION)) {
header('Location:./logon');
exit(0);
}
// test for url but ignore our own
if( array_key_exists('url', $_GET) and (false === strpos($_GET['url'], BASE_URL)) ) {
$url = trim($_GET['url']);
if (strlen($url) < strlen(BASE_URL) + 8) {
// don't make longer urls
$full_url = $url;
} else {
// save full_url for name of the svg file
$full_url = $url;
$select = \Persist\DB\Database::getConnection()->prepare('select set_url(:user_id, :url)');
$select->execute(['url' => $full_url, 'user_id' => $_SESSION['user_id']]);
//echo $select-> errorInfo()[2];
if ($code = $select->fetchColumn()) {
$url = BASE_URL . $code;
} else {
$url = DEFAULT_URL;
}
}
} else {
// nothing to do get the default
$url = $full_url = DEFAULT_URL;
}
//var_dump($_GET);
?>
<!DOCTYPE html>
<html lang="de">
<head>
<title>go321</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./lib/qrcode.js" defer></script>
<link rel="stylesheet" href="./assets/main.css">
</head>
<body>
<main>
<h1>go321</h1>
<a href="/logon">Abmelden</a>
<h2>Von dir registrierten Codes</h2>
<p>Auf URL klicken um zu ändern, zum Bestätigen Eingabe-Taste, Esc. für Abbbrechen</p>
<table id="code-table">
<tr>
<th>Code
<th>URL
</tr>
<?php
foreach (\Link\Code::findAll(where: ['user_id' => $_SESSION['user_id']]) as $code) {
echo '<tr>';
echo wrap_tag(
'td',
"<a target=\"_blank\" href=\"/$code->code\">$code->code</a>"
);
echo wrap_tag('td', $code->url);
}
?>
</table>
<h2>Erstellen</h2>
<p>URL eingeben und Farben/Grösse einstellen
<p>Klick auf QR Code für Download.
<p>Kürzen mit Enter-Taste. Gekürzt werden nur längere URLs.
<form id="form-container" method="get">
<label for="url">URL</label>
<textarea id="url" name="url"><?= $url ?></textarea>
<span></span>
<div>
<input type=submit value="Kürzen" id="shorten" data-full-url="<?= $full_url ?>"><br />
</div>
<label for="bg-color">Hintergrundfarbe</label>
<input type="color" id="bg-color" value="#8cbf35">
<label for="color">Farbe</label>
<input type="color" id="color" value="#000000">
<label for="size">Grösse</label>
<input type="range" id="size" min="50" max="500" value="100">
<span></span>
<button id="do-qr">OK</button>
<span>QR-Code</span>
<div id="container"></div>
<input id="base-url" type="hidden" value="<?= BASE_URL ?>">
</form>
<p><a href="./impressum.html">IMPRESSUM</a></p>
<script src="./assets/main.js"></script>
</main>
</body>
<link rel="apple-touch-icon" sizes="57x57" href="/assets/icons/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/assets/icons/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/assets/icons/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/assets/icons/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/assets/icons/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/assets/icons/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/assets/icons/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/assets/icons/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/assets/icons/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/assets/icons/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png">
<link rel="manifest" href="/assets/icons/manifest.json">
<meta name="msapplication-TileColor" content="#49a09d">
<meta name="msapplication-TileImage" content="/assets/icons/ms-icon-144x144.png">
<meta name="theme-color" content="#49a09d">
</html>