Repository navigation
Expand file tree
/
Copy pathsave.php
More file actions
66 lines (59 loc) · 2.25 KB
/
Copy pathsave.php
File metadata and controls
66 lines (59 loc) · 2.25 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
<?php
require_once 'functions.php';
if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
die("
<div style='font-family: sans-serif; text-align: center; padding: 20px;'>
<h3 style='color: #dc3545;'>❌ Unauthorized</h3>
<p>Please log in to your main Visual Bookmarks app first.</p>
<script>setTimeout(() => window.close(), 3000);</script>
</div>
");
}
$url = filter_var($_GET['url'] ?? '', FILTER_SANITIZE_URL);
$category = '';
$folder = 'Uncategorized';
$status = 'saving';
$message = '';
if (filter_var($url, FILTER_VALIDATE_URL)) {
$stmt = $pdo->prepare("SELECT id FROM bookmarks WHERE url = ?");
$stmt->execute([$url]);
if ($stmt->fetch()) {
$status = 'warning';
$message = 'Already in your bookmarks!';
} else {
$imagePath = takeScreenshot($url);
$title = getWebpageTitle($url);
$stmt = $pdo->prepare("INSERT INTO bookmarks (title, url, image, category, folder) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$title, $url, $imagePath, $category, $folder]);
$status = 'success';
$message = 'Saved successfully!';
}
} else {
$status = 'error';
$message = 'Invalid URL.';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Saving Bookmark...</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="d-flex align-items-center justify-content-center vh-100 bg-light text-center">
<div>
<?php if ($status === 'success'): ?>
<h3 class="text-success mb-3">✅ <?php echo $message; ?></h3>
<p class="text-muted small">Closing window...</p>
<script>setTimeout(() => window.close(), 1500);</script>
<?php elseif ($status === 'warning'): ?>
<h3 class="text-warning mb-3">⚠️ <?php echo $message; ?></h3>
<p class="text-muted small">Closing window...</p>
<script>setTimeout(() => window.close(), 1500);</script>
<?php else: ?>
<h3 class="text-danger mb-3">❌ <?php echo $message; ?></h3>
<p class="text-muted small">You can close this window.</p>
<?php endif; ?>
</div>
</body>
</html>