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
|
<?php
namespace Database;
use PDO;
class Webpage extends Table {
public $WID;
public $Path;
public $URL;
public $Date;
public $Visits;
public $RequesterUID;
public $FaviconPath;
public $Title;
static function create(string $Path, string $URL, int $RequesterUID, ?string $FaviconPath, ?string $Title) : int {
return Table::_create(
'Webpages',
'(Path, URL, Date, Visits, RequesterUID, FaviconPath, Title)',
"(\"$Path\", \"$URL\", (NOW() + INTERVAL 2 HOUR), 0, \"$RequesterUID\", \"$FaviconPath\", \"$Title\")"
);
}
static function fromDB(string $URL) : Webpage {
return Table::_fromDB(
"SELECT * FROM Webpages WHERE URL = \"$URL\" ORDER BY Date DESC LIMIT 1",
"Database\Webpage"
);
}
static function getPagesCount() : int {
return Table::_get_entries_count("Webpages");
}
static function mostVisited(int $count) : array {
return Table::_get_all(
'Webpages',
'Database\Webpage',
"GROUP BY URL ORDER BY Visits DESC, Date DESC LIMIT $count",
'WID,Path,URL,Date,MAX(Visits) as Visits,RequesterUID,FaviconPath,Title'
);
}
static function allArchives(string $URL) : array {
return Table::_get_all(
'Webpages',
'Database\Webpage',
"WHERE URL = \"$URL\" ORDER BY Date DESC"
);
}
static function getArchivePathsByPattern(string $URLPattern) : array {
return Table::_get_all(
'Webpages',
'Database\Webpage',
"WHERE URL LIKE \"$URLPattern\" ORDER BY Date DESC",
"Path, WID"
);
}
function incrementVisits() {
Table::_update(
'Webpages',
"Visits = \"" . ($this->Visits + 1) . "\"",
"WID = \"{$this->WID}\""
);
}
}
|