-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
38 lines (27 loc) · 959 Bytes
/
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
<?php
if(isset($_GET['path'])){
$path = $_GET['path'];
}
else{
die("No id");
}
$m = new MongoClient();
$db = $m->achievecraft;
if($path == "stats" || $path == "stats.png"){
$stats = $db->currentcount;
$countsofar = $stats->findOne(array("id" => "count"));
$countsofar = number_format($countsofar['count']);
//Always go to latest stats image
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: http://achievecraft.net/i/19.1/".rawurlencode($countsofar)."%20images%20generated/achievecraft.net.png");
die();
}
$shorturls = $db->shorturls;
$id = trim($path, ".png");
$imagepath = $shorturls->findOne(array("id" => $id));
$protocol = json_decode($_SERVER['HTTP_CF_VISITOR'], true)['scheme'].":";
header("Location: $protocol//achievecraft.net/".$imagepath['url']);
die();
?>