This repository was archived by the owner on Feb 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathindex.php
More file actions
120 lines (97 loc) · 2.85 KB
/
index.php
File metadata and controls
120 lines (97 loc) · 2.85 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
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
<?php
if(file_exists("install.php"))
{
die("please rename or run install.php");
}
include("Db.class.php");
include("smarty/libs/Smarty.class.php");
$smarty = new Smarty;
$smarty->setCaching(false);
$smarty->setTemplateDir("smarty/templates/default/");
if($_GET['page']) $page = filter_var($_GET['page'], FILTER_SANITIZE_STRING);
switch($page)
{
default:
$db = new Db();
$doxList =$db->getDoxList();
$smarty->assign("doxCount", count($doxList));
$smarty->assign("doxList", $doxList);
$smarty->display("header.tpl");
$smarty->display("nav.tpl");
$smarty->display("index.tpl");
$smarty->display("footer.tpl");
break;
case "add":
$config = json_decode(file_get_contents("config"));
if($config->cap_site_key != "" && $config->cap_sec_key != "")
{
$smarty->assign("cap_sec_key", $config->cap_sec_key);
$smarty->assign("cap_site_key", $config->cap_site_key);
}
$smarty->assign("page", "add");
$smarty->display("header.tpl");
$smarty->display("nav.tpl");
$smarty->display("add.tpl");
$smarty->display("footer.tpl");
break;
case "tos":
$smarty->display("header.tpl");
$smarty->display("nav.tpl");
$smarty->display("tos.tpl");
$smarty->display("footer.tpl");
break;
case "upload":
$id = filter_var($_GET['id'], FILTER_SANITIZE_STRING);
$db = new Db();
$dox = $db->getDox($id);
$db->addView($id);
$smarty->assign("dox", $dox);
$smarty->assign("page", "upload");
$smarty->display("header.tpl");
$smarty->display("nav.tpl");
$smarty->display("upload.tpl");
$smarty->display("footer.tpl");
break;
case "raw":
$id = filter_var($_GET['id'], FILTER_SANITIZE_STRING);
$db = new Db();
$dox = $db->getDox($id);
$db->addView($id);
$smarty->assign("dox", $dox);
$smarty->display("raw.tpl");
break;
case "submit":
//check captcha
$config = json_decode(file_get_contents("config"));
$cap_url = "https://www.google.com/recaptcha/api/siteverify";
$fields = array(
'secret' => $config->cap_sec_key,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
);
//url-ify the data for the POST
foreach($fields as $key=>$value)
{
$fields_string .= $key.'='.$value.'&';
}
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $cap_url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$res = curl_exec($ch);
//close connection
curl_close($ch);
if($res)
{
$db = new Db();
$title = filter_var($_POST['doxTitle'], FILTER_SANITIZE_STRING);
$dox = $_POST['dox'];
$db->addDox($title, $dox, $_SERVER['REMOTE_ADDR']);
}
break;
}
?>