-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
133 lines (97 loc) · 4.11 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
126
127
128
129
130
131
132
133
<?php
require_once ("sql.php");
?>
<!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">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="/assets/images/favicon.ico">
<title>CloudFlare WebPanel</title>
<!-- Bootstrap core CSS -->
<link href="/assets/css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="/assets/css/engine.css" rel="stylesheet">
<link rel="stylesheet" href="/assets/css/font-awesome.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Fixed navbar -->
<?php include("nav.php"); ?>
<!-- Begin page content -->
<div class="container">
<?php
require_once ("functions.php");
require_once ("sql.php");
$data = $mysqli->query("SELECT * FROM users");
?>
<div class="page-header">
<h1>Добро пожаловать в CloudFlare WebPanel</h1>
</div>
<?php
if(!$data->num_rows) { ?>
<!-- Показывается только если конфиг пустой -->
<p class="lead">Похоже, у вас еще не добавлено ни одного аккаунта <code>CloudFlare</code>.</p>
<p>Зайдите в <a href="/settings/">настройки</a> для продолжения работы.</p>
<?php }
$flag = false;
$str = "";
while($row = $data->fetch_array()) {
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, "https://api.cloudflare.com/client/v4/user");
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$headers = [
'X-Auth-Email: ' . $row["email"],
'X-Auth-Key: ' . $row["api"],
'Content-Type: application/json'
];
curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($connection);
curl_close($connection);
$result = json_decode($result);
if(!isset($result->result->id)) {
$flag = true;
$str = $str.", ".$row["name"];
}
}
if($flag) {
$str = ltrim($str, ", ");
print <<< HTML
<!-- Показывается только если какой-то из токенов протух -->
<p class="lead">Похоже, некоторые токены ({$str}) <code>CloudFlare</code> неверны.</p>
<p>Зайдите в <a href="/settings/">настройки</a> для продолжения работы.</p>
HTML;
}else{
print <<< HTML
<p class="lead">Похоже, что сейчас все отлично!</p>
<p>Можете продолжить работу, выбрав в меню соответсвующий аккаунт <code>CloudFlare</code>.</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=0" frameborder="0" allowfullscreen></iframe>
HTML;
}
$mysqli->close();
?>
</div>
<footer class="footer navbar-default">
<div class="container">
<p class="text-muted pull-right">Version 0.1-git-asdADqsdf</p>
<p class="text-muted pull-left">EpicMorg <i class="fa fa-copyright" aria-hidden="true"></i> 2017</p>
</div>
</footer>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script>window.jQuery || document.write('<script src="/assets/js/jquery-3.1.1.min.js"><\/script>')</script>
<script src="/assets/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="/assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>