forked from ZE3kr/Cloudflare-CNAME-Setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·152 lines (146 loc) · 5.49 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/**
* The main file
*
* @file $Source: /README.md $
* @package core
* @author ZE3kr <ze3kr@icloud.com>
*
*/
$starttime = microtime(true);
include "settings.php";
$tlo_id = false;
if ( !isset($_COOKIE['user_key']) || !isset($_COOKIE['cloudflare_email']) || !isset($_COOKIE['user_api_key']) ) { require_once "login.php"; exit(); }
$key = new \Cloudflare\API\Auth\APIKey($_COOKIE['cloudflare_email'], $_COOKIE['user_api_key']);
$adapter = new Cloudflare\API\Adapter\Guzzle($key);
$tlo_id = md5($_COOKIE['cloudflare_email'].$_COOKIE['user_api_key']);
?><!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="TlOxygen Cloudflare Partners">
<meta name="keywords" content="TlOxygen, Cloudflare">
<meta name="viewport" content="width=800">
<title><?php if(isset($_GET['action']) && $_GET['action'] == 'analytics'){ echo 'Analytics: '.$_GET['domain']; } elseif(isset($_GET['domain'])){ echo 'DNS: '.$_GET['domain']; } else { echo 'Console'; } ?> | <?php echo _('Cloudflare CNAME/IP Advanced Setup'); ?> – <?php echo $page_title; ?></title>
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/tlo.css">
</head>
<body>
<div class="am-container">
<div class="am-cf am-padding am-padding-bottom-0 data-am-sticky">
<div class="am-fl am-cf">
<strong class="am-text-primary am-text-lg"><a href="?"><?php echo $page_title; ?></a></strong> /
<small><?php echo _('Console'); ?></small> /
<small><a href="?action=logout"><?php echo _('Logout'); ?></a></small>
</div>
</div></div><hr>
<div class="am-container" style=" max-width: 960px"><?php
require_once 'cloudflare.class.php';
$cloudflare = new CloudFlare;
if(isset($_GET['action'])){
$action = $_GET['action'];
} else {
$action = false;
}
switch ($action) {
case 'logout':
require_once 'actions/logout.php';
break;
case 'dnssec':
require_once 'actions/dnssec.php';
break;
case 'add_record':
require_once 'actions/add_record.php';
break;
case 'edit_record':
require_once 'actions/edit_record.php';
break;
case 'delete_record':
require_once 'actions/delete_record.php';
break;
case 'analytics':
require_once 'actions/analytics.php';
break;
case 'add':
require_once 'actions/add.php';
break;
case 'zones':
require_once 'actions/zones.php';
break;
case 'ssl':
require_once 'actions/ssl.php';
break;
default:
if(!isset($_GET['page'])){
$_GET['page'] = 1;
}
?>
<a href="?action=add" class="am-btn am-btn-success am-round"><?php echo _('Add Domain'); ?></a>
<table class="am-table am-table-striped am-table-hover">
<thead>
<tr>
<th><?php echo _('Domain'); ?></th>
<th><?php echo _('Status'); ?></th>
<th><?php echo _('Mode'); ?></th>
<th><?php echo _('Operation'); ?></th>
</tr>
</thead>
<tbody>
<?php
$zones = new \Cloudflare\API\Endpoints\Zones($adapter);
$zones_data = $zones->listZones(false,false,intval($_GET['page']));
foreach ($zones_data->result as $zone) {
if( property_exists($zone, 'name_servers') ){
$manage_data = '<a href="https://dash.cloudflare.com/" target="_blank">';
$manage_ssl = '';
$cname_method = '<span style="color:orange;">'._('Official Setup').'</span>';
} else {
$manage_data = '<a href="?action=zones&domain='.$zone->name.'&zoneid='.$zone->id.'">';
$manage_ssl = ' | <a href="?action=ssl&domain='.$zone->name.'&zoneid='.$zone->id.'">'._('Security').'</a>';
$cname_method = '<span style="color:green;">'._('Universal Setup').'</span>';
}
echo '<tr>
<td>'.$manage_data.$zone->name.'</a></td>
<td>'.$status_translate[$zone->status].'</td>
<td>'.$cname_method.'</td>
<td>'.$manage_data._('Manage').'</a>'.' | <a href="?action=analytics&domain='.$zone->name.'&zoneid='.$zone->id.'">'._('Advanced Analytics').'</a>'.$manage_ssl.'</td>';
}
?>
</tbody>
</table><?php
if(isset($zones_data->result_info->total_pages)){
$previous_page = '';
$next_page = '';
if($zones_data->result_info->page < $zones_data->result_info->total_pages){
$page_link = $zones_data->result_info->page + 1;
$next_page = ' | <a href="?page='.$page_link.'">'._('Next').'</a>';
}
if($zones_data->result_info->page > 1){
$page_link = $zones_data->result_info->page - 1;
$previous_page = '<a href="?page='.$page_link.'">'._('Previous').'</a> | ';
}
echo '<p>'.$previous_page._('Page').' '.$zones_data->result_info->page.'/'.$zones_data->result_info->total_pages.$next_page.'</p>';
}
break;
}
?>
</div>
<hr>
<div class="am-container">
<p><?php echo _('<a href="https://support.cloudflare.com/hc" target="_blank">Any questions or problems about Cloudflare, please contact official support</a></p><p>Any question or problem about this service, please <a href="https://github.com/ZE3kr/Cloudflare-CNAME-Setup/issues/new" target="_blank">create a issue on GitHub</a>'); ?></p><?php
if($is_beta){
$time = round(microtime(true) - $starttime,3);
echo '<small><p>Beta Version / Load time: '.$time.'s </p>';
}
?>
</div>
<hr>
<div class="am-container">
<p><?php echo _('Last Update: ').date('Y-m-d H:i:s e', filemtime(__FILE__)); ?></p>
<p><a href="https://github.com/ZE3kr/Cloudflare-CNAME-Setup" target="_blank"><?php echo _('This open source project is powered by ZE3kr.');?></a></p>
</div>
</body>
</html>