-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
125 lines (106 loc) · 4.08 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
<?php
include dirname(__FILE__) . "/app/app.php";
include dirname(__FILE__) . "/app/app.login.php";
$search = isset($_POST['search']) ? $_POST['search'] : "";
$filter_active = isset($_POST['filter_active']) ? true : false;
$filter_inactive = isset($_POST['filter_inactive']) ? true : false;
$folder = isset($_POST['folder']) ? intval($_POST['folder']) : 0;
if(!isset($_POST['filter_send'])) {
$filter_active = true;
$filter_inactive = false;
}
if(isset($_GET['deactivate'])) {
$deactivate = intval($_GET['deactivate']);
$db->website[$deactivate]->update(array('status' => 'inactive'));
header("Location: ./");
}
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebChangesTracker</title>
<link rel="stylesheet" href="./style.css?v=7">
</head>
<body>
<h1>WebChangesTracker</h1>
<a href="./editor/index.php?username=<?php echo urlencode(EMAIL_ADDRESS); ?>">Editor</a> |
<a href="./editor/index.php?username=<?php echo urlencode(EMAIL_ADDRESS); ?>&edit=website">Add new website</a> |
<a href="./?logout">Logout</a> |
<?php if(isset($_GET['run'])) { ?>
<a href="./">Close tracker</a>
<hr />
<iframe src="./cron.php"></iframe>
<?php } else { ?>
<a href="./?run">Run tracker manualy</a>
<?php } ?>
<hr />
<form action="./" method="post">
<p>
<input type="text" name="search" placeholder="🔎︎" value="<?php echo $search; ?>" />
<select name="folder" id="folder">
<option value="0"<?php echo ($folder==0 ? ' selected="selected"' : ''); ?>>(all folders)</option>
<?php
foreach($db->folder()->order("name ASC") as $item) {
echo '<option value="'.$item['id'].'"'.($folder == $item['id'] ? ' selected="selected"' : '').'>'.$item['name'].'</option>';
}
?>
</select>
<label for="filter_active"><input type="checkbox" name="filter_active" id="filter_active"<?php echo ($filter_active ? ' checked="checked"' : ''); ?> /> active</label>
<label for="filter_inactive"><input type="checkbox" name="filter_inactive" id="filter_inactive"<?php echo ($filter_inactive ? ' checked="checked"' : ''); ?> /> inactive</label>
<input type="submit" value="Filter" />
<input type="hidden" name="filter_send" value="1" />
</p>
</form>
<form action="./records.php">
<table>
<thead>
<tr>
<th>Label</th>
<th>Folder</th>
<th>Status</th>
<th>Interval</th>
<th>Last tracking</th>
<th>URL</th>
<th>Preview</th>
<th><input type="checkbox" id="select_all" /> Records</th>
<th>Edit</th>
</tr>
</thead>
<tbody>
<?php
$websites = $db->website();
if($search!="") $websites->where("LOWER(label) REGEXP ?", mb_strtolower($search));
if(!$filter_active) $websites->where("status", "inactive");
if(!$filter_inactive) $websites->where("status", "active");
if($folder>0) $websites->where("folder_id", $folder);
foreach($websites as $website) {
echo '<tr>';
echo ' <td><b>'.$website['label'].'</b></td>';
echo ' <td>'.$website->folder["name"].'</td>';
echo ' <td>'.$website['status'].'</td>';
echo ' <td>'.$website['tracking_interval'].'</td>';
echo ' <td>'.$website['tracking_last'].'</td>';
echo ' <td><a href="'.$website['url'].'">URL</a></td>';
echo ' <td><a href="./view.php?id='.$website['id'].'">Preview</a></td>';
echo ' <td><input name="website[]" type="checkbox" value="'.$website['id'].'"/> <a href="./records.php?'.urlencode('website[]').'='.$website['id'].'">Records</a></td>';
echo ' <td><a href="./editor/index.php?username='.urlencode(EMAIL_ADDRESS).'&edit=website&'.urlencode('where[id]').'='.$website['id'].'">Edit</a></td>';
echo '</tr>';
}
?>
</tbody>
</table>
<p>
<input type="submit" value="Show records" />
</p>
</form>
<script src="./jquery-3.6.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#select_all").change(function (e) {
$('input[name^="website"]').prop("checked", $(this).is(":checked"));
});
});
</script>
</body>
</html>