-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.php
157 lines (136 loc) · 5.79 KB
/
get.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
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
156
157
<?php
// ModernCount Copyright Studio 384 2013-2014
ob_start();
if (!file_exists("config.php")) {
header("Location: installer");
exit;
}
require_once("config.php");
//Connect to database
@$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$con) {
die("Error: Could not connect to database (" . mysql_error() . "). Check your database settings are correct.");
}
mysql_select_db(DB_NAME, $con);
//Get the ID from $_GET OR $_POST
if (isset($_GET["id"])) {
$id = mysql_real_escape_string($_GET["id"]);
} elseif (isset($_POST["id"])) {
$id = mysql_real_escape_string($_POST["id"]);
} else {
die("Error: ID cannot be blank.");
}
//Check if ID exists
$getinfo = mysql_query("SELECT `name`, `url` FROM `Data` WHERE `id` = \"$id\"");
$getinforesult = mysql_fetch_assoc($getinfo);
if (mysql_num_rows($getinfo) == 0) {
die("Error: ID does not exist.");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ModernCount</title>
<meta name="robots" content="noindex, nofollow">
<link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 30px;
padding-bottom: 30px;
}
</style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">ModernCount</a>
</div>
</div>
</div>
<div class="container">
<div class="page-header">
<h1><?php echo $getinforesult["name"]; ?></h1>
</div>
<?php
//Cookies don't like dots
$idclean = str_replace(".", "_", $id);
//Ignore admin counts if setting has been enabled
session_start();
if (IGNORE_ADMIN_STATE == "Enabled" && isset($_SESSION["luna_user"])) {
echo "<div class=\"alert alert-info\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button><b>Info:</b> You are currently logged in, downloads will not be counted.</div>";
} else {
if (COUNT_UNIQUE_ONLY_STATE == "Enabled") {
if (!isset($_COOKIE["lunahasdownloaded_$idclean"])) {
mysql_query("UPDATE `Data` SET `count` = `count`+1 WHERE `id` = \"$id\"");
setcookie("lunahasdownloaded_$idclean", time(), time()+3600*COUNT_UNIQUE_ONLY_TIME);
}
} else {
mysql_query("UPDATE `Data` SET `count` = `count`+1 WHERE `id` = \"$id\"");
}
}
//Check if download is password protected
$checkifprotected = mysql_query("SELECT `protect`, `password` FROM `Data` WHERE `id` = \"$id\"");
$checkifprotectedresult = mysql_fetch_assoc($checkifprotected);
if ($checkifprotectedresult["protect"] == "1") {
$case = "passwordprotected";
}
//Check if we should show ads
$checkifadsshow = mysql_query("SELECT `showads` FROM `Data` WHERE `id` = \"$id\"");
$checkifadsshowresult = mysql_fetch_assoc($checkifadsshow);
if ($checkifadsshowresult["showads"] == "1") {
$case = "showads";
}
if ($checkifprotectedresult["protect"] == "1" && $checkifadsshowresult["showads"] == "1") {
$case = "passwordprotectedandshowads";
}
if ($checkifprotectedresult["protect"] != "1" && $checkifadsshowresult["showads"] != "1") {
$case = "normal";
}
if (isset($_POST["password"])) {
if (hash("sha256", SALT . hash("sha256", $_POST["password"])) == $checkifprotectedresult["password"]) {
$case = "passwordcorrect";
} else {
$case = "passwordincorrect";
}
}
switch ($case) {
case "showads":
$adcode = htmlspecialchars_decode(AD_CODE);
echo "<p>$adcode</p><a class=\"btn btn-default\" href=\"javascript:history.go(-1)\">Go Back</a><a class=\"btn btn-default pull-right\" href=\"" . $getinforesult["url"] . "\">Get Download</a>";
break;
case "passwordprotected":
echo "<form role=\"form\" method=\"post\"><div class=\"form-group\"><label for=\"password\">Password</label><input type=\"password\" class=\"form-control\" id=\"password\" name=\"password\" placeholder=\"Password...\"><div class=\"help-block\">This download is password protected, please enter the password you were given.</div></div><a class=\"btn btn-default\" href=\"javascript:history.go(-1)\">Go Back</a><button type=\"submit\" class=\"btn btn-default pull-right\">Get Download</button></form>";
break;
case "normal":
header("Location: " . $getinforesult["url"] . "");
exit;
break;
case "passwordprotectedandshowads":
$adcode = htmlspecialchars_decode(AD_CODE);
echo "<p>$adcode</p><form role=\"form\" method=\"post\"><div class=\"form-group\"><label for=\"password\">Password</label><input type=\"password\" class=\"form-control\" id=\"password\" name=\"password\" placeholder=\"Password...\"><div class=\"help-block\">This download is password protected, please enter the password you were given.</div></div><a class=\"btn btn-default\" href=\"javascript:history.go(-1)\">Go Back</a><button type=\"submit\" class=\"btn btn-default pull-right\">Get Download</button></form>";
break;
case "passwordcorrect":
header("Location: " . $getinforesult["url"] . "");
exit;
break;
case "passwordincorrect":
echo "<div class=\"alert alert-danger\"><h4 class=\"alert-heading\">Error</h4><p>Incorrect password.</p><p><a class=\"btn btn-danger\" href=\"javascript:history.go(-1)\">Go Back</a></p></div>";
break;
}
ob_end_flush();
mysql_close($con);
?>
</div>
<script src="assets/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>