· 6 years ago · Oct 27, 2019, 09:52 AM
1<?php
2/*
3 *
4 * @ This file is created by http://DeZender.Net
5 * @ deZender (PHP5 Decoder for ionCube Encoder)
6 *
7 * @ Version : 3.5.0.0
8 * @ Author : DeZender
9 * @ Release on : 22.06.2018
10 * @ Official site : http://DeZender.Net
11 *
12 */
13
14include_once 'core/protection.php';
15
16class auth
17{
18 public $db = null;
19 public $Config = null;
20
21 public function analysisAll()
22 {
23 $str = '';
24 $q = "\n\t\t\t\tSELECT\n\t\t\t\t\t(SELECT id FROM campaigns ORDER BY id DESC LIMIT 1) AS cnt_campaigns,\n\t\t\t\t\t(SELECT id FROM clicks ORDER BY id DESC LIMIT 1) AS cnt_clicks,\n\t\t\t\t\t(SELECT id FROM `domains` ORDER BY id DESC LIMIT 1) AS cnt_domains,\n\t\t\t\t\t(SELECT id FROM clicks_events ORDER BY id DESC LIMIT 1) AS cnt_events,\n\t\t\t\t\t(SELECT id FROM filters ORDER BY id DESC LIMIT 1) AS cnt_filters,\n\t\t\t\t\t(SELECT id FROM `groups` ORDER BY id DESC LIMIT 1) AS cnt_groups,\n\t\t\t\t\t(SELECT id FROM landing_pages ORDER BY id DESC LIMIT 1) AS cnt_landers,\n\t\t\t\t\t(SELECT id FROM networks ORDER BY id DESC LIMIT 1) AS cnt_networks,\n\t\t\t\t\t(SELECT id FROM offers ORDER BY id DESC LIMIT 1) AS cnt_offers,\n\t\t\t\t\t(SELECT COUNT(*) FROM interface_page_log WHERE date>(UNIX_TIMESTAMP()-3*24*3600)) AS cnt_pages,\n\t\t\t\t\t(SELECT id FROM report_templates WHERE preset_type=1 ORDER BY id DESC LIMIT 1) AS cnt_report_templates,\n\t\t\t\t\t(SELECT COUNT(*) FROM rotations WHERE `type`=1) AS cnt_rotations,\n\t\t\t\t\t(SELECT id FROM traffic_sources ORDER BY id DESC LIMIT 1) AS cnt_sources,\n\t\t\t\t\t(SELECT id FROM users ORDER BY id DESC LIMIT 1) AS cnt_users\n\t\t\t";
25 $row = $this->db->select($q);
26
27 foreach ($row as $element) {
28 $str = $str . $this->encodeStr($element) . 'X' . rand(0, 99) . 'O';
29 }
30
31 return $str;
32 }
33
34 public function analysisTS()
35 {
36 $str = '';
37 $key = $this->create_key(5);
38 $data_url = 'https://cloud.binom.org/trk_controller.php?type=cloud_load_traffic_sources&key=' . $key['key'];
39 $response = file_get_contents($data_url, false, $headers);
40
41 if ($response == 'err:304') {
42 $TSTemplates = 'false';
43 } else {
44 $TSTemplates = json_decode($response, true);
45 }
46
47 if (is_array($TSTemplates)) {
48 $q = 'SELECT el_id, SUM(clicks) AS clicks FROM showcase_sources WHERE date_type=3 GROUP BY el_id';
49 $res = $this->db->select_res($q);
50
51 while ($row = $res->fetch()) {
52 $ArrTSClicks[$row['el_id']] = $row['clicks'];
53 }
54 $q = 'SELECT id, name FROM traffic_sources WHERE status = 1';
55 $res = $this->db->select_res($q);
56
57 while ($row = $res->fetch()) {
58 if (!empty($TSTemplates)) {
59 foreach ($TSTemplates as $Template) {
60 if (($Template['name'] == $row['name'] || strpos($row['name'], $Template['name']) !== false || strpos($Template['name'], $row['name']) !== false) && !in_array($TSResult, $Template['id'])) {
61 $TSResult[] = $Template['id'];
62
63 if (isset($ArrTSClicks[$row['id']])) {
64 $TSClicks[$Template['id']] = $ArrTSClicks[$row['id']];
65 } else {
66 $TSClicks[$Template['id']] = 0;
67 }
68
69 $str = $str . $this->encodeStr($Template['id']) . 'CB' . rand(0, 9) . 'BC' . $this->encodeStr($TSClicks[$Template['id']]) . 'X' . rand(0, 99) . 'O';
70 }
71 }
72 }
73 }
74 }
75
76 return $str;
77 }
78
79 public function analysisNet()
80 {
81 $str = '';
82 $q = "\n\t\t\t\tSELECT \n\t\t\t\t\tIF(SUM(showcase_networks.clicks) IS NULL, 0, SUM(showcase_networks.clicks)) AS clicks,\n\t\t\t\t\tnetworks.name AS name\n\t\t\t\tFROM \n\t\t\t\t\tnetworks LEFT JOIN\n\t\t\t\t\t\tshowcase_networks ON showcase_networks.el_id = networks.id AND showcase_networks.date_type=3\n\t\t\t\tWHERE \n\t\t\t\t\tnetworks.status=1\n\t\t\t\tGROUP BY networks.id\n\t\t\t";
83 $res = $this->db->select_res($q);
84
85 while ($row = $res->fetch()) {
86 $row['name'] = substr($row['name'], 0, 15);
87 $row['name'] = $this->encodeNameToInt($row['name']);
88 $row['clicks'] = $this->encodeStr($row['clicks']);
89 $str = $str . $row['name'] . 'CB' . rand(0, 9) . 'BC' . $row['clicks'] . 'X' . rand(0, 99) . 'O';
90 }
91
92 return $str;
93 }
94
95 public function analysis()
96 {
97 $str = $this->analysisAll() . 'ByM' . rand(0, 999) . 'On' . $this->analysisTS() . 'ByM' . rand(0, 999) . 'On' . $this->analysisNet();
98
99 return base64_encode($str);
100 }
101
102 public function encodeNameToInt($str)
103 {
104 for ($i = 0; $i < strlen($str); $i++) {
105 if (isset($newStr)) {
106 $newStr = $newStr . 'S' . $this->encodeStr(ord($str[$i]));
107 } else {
108 $newStr = $this->encodeStr(ord($str[$i]));
109 }
110 }
111
112 return $newStr;
113 }
114
115 public function encodeStr($element)
116 {
117 $qc = 'ckfei4vrwj8nbldz6o3y2tgx17h9q5pmusxsfnbz8r7vheoj16ci52qdgmlpu3y94ktwwfntb4irgh8pxok27sqe5myd1zvc6j9lft3zb7e21nho9rg58wscmyuqxidvj6zwhqd51m46p2tlc8ejsyx937bgrnikfvuo3vm7ibxrfyktwh4pocj2159zsldug6e8qnqq';
118 $qc = str_split($qc, 2);
119 $element = str_split($element, 2);
120 $code_id = '';
121
122 foreach ($element as $val) {
123 if (substr($val, 0, 1) == '0') {
124 if (strlen($val) == 1) {
125 $code_id = $code_id . '0';
126 } else {
127 $code_id = $code_id . 'a' . (int) $val;
128 }
129 } else {
130 $code_id = $code_id . $qc[(int) $val];
131 }
132 }
133 $str = $str . $code_id;
134
135 return $str;
136 }
137
138 public function generate_password($number)
139 {
140 $arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
141 $pass = '';
142
143 for ($i = 0; $i < $number; $i++) {
144 $index = rand(0, count($arr) - 1);
145 $pass .= $arr[$index];
146 }
147
148 return $pass;
149 }
150
151 public function setLog($Status = 'Unknown', $Type = 'interface', $UserId = 'Unknown')
152 {
153 global $db;
154 global $Config;
155 include_once 'core/file_manager.php';
156 $LogStatus = 0;
157
158 if (isset($Config->auth_logs) && ($Config->auth_logs == 1 || $Config->auth_logs == 2 && $Type == 'interface')) {
159 if ($UserId !== 'Unknown' && $Status == 'true') {
160 $q = 'SELECT last_log FROM users WHERE id = :UserId';
161
162 if (($row = $db->select($q, array('UserId' => $UserId))) && $row['last_log'] < time() - 12 * 3600) {
163 $LogStatus = 1;
164 $q = 'UPDATE users SET last_log = ' . time() . ' WHERE id = :UserId';
165 $this->db->i_d($q, array('UserId' => $UserId));
166 }
167 } else {
168 $LogStatus = 1;
169 }
170
171 if ($LogStatus == 1) {
172 $Log['datetime'] = date('Y-m-d H:i:s');
173 $Log['type'] = $Type;
174 $Log['user_id'] = $UserId;
175 $Log['status'] = $Status;
176
177 if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
178 $IPTemp = explode(', ', $_SERVER['HTTP_X_FORWARDED_FOR']);
179
180 if (count($IPTemp) <= 1) {
181 $IPTemp = explode(',', $IPTemp[0]);
182 }
183
184 $Log['ip'] = $IPTemp[0];
185 }
186
187 if (!isset($Log['ip']) || empty($Log['ip'])) {
188 $Log['ip'] = $_SERVER['REMOTE_ADDR'];
189 }
190
191 $Log['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
192
193 foreach ($Log as $key => $val) {
194 $val = str_replace('\\', '', $val);
195 $val = str_replace("'", "\\'", $val);
196 $val = str_replace(';', '_', $val);
197 $Log[$key] = $val;
198 }
199 $StrLog = implode(';', $Log) . PHP_EOL;
200 $file_name = 'authLogs' . date('Ymd') . '_' . md5(date('Y-m-d') . $_SERVER['SERVER_NAME']) . '.log';
201 $fm = new fm();
202 $fm->dir = $Config->general_dir;
203 $fm->fm_dir('auth_logs');
204
205 if (!file_exists('auth_logs/index.php')) {
206 $fm->new_file('auth_logs/index.php', '');
207 }
208
209 if (!file_exists('auth_logs/' . $file_name)) {
210 $fm->new_file('auth_logs/' . $file_name, implode(';', array_keys($Log)) . PHP_EOL);
211 }
212
213 $fp = fopen($Config->general_dir . 'auth_logs/' . $file_name, 'a');
214 $test = fwrite($fp, $StrLog);
215 fclose($fp);
216 }
217 }
218 }
219
220 public function auth_logs($status = 'error: unknown', $login = 'unknown', $type = 'interface')
221 {
222 global $db;
223 global $Config;
224
225 if (!empty($Config->auth_logs) && $Config->auth_logs == 1) {
226 $log['date'] = date('Y-m-d H:i:s');
227 $log['type'] = $type;
228 $log['status'] = $status;
229 $log['login'] = $login;
230 $log['agent'] = $_SERVER['HTTP_USER_AGENT'];
231 $log['agent'] = str_replace('\\', '', $log['agent']);
232 $log['agent'] = str_replace("'", "\\'", $log['agent']);
233
234 if (protection::get('api_key') || protection::post('api_key')) {
235 $log['device'] = 'API Mode';
236 } else {
237 include_once 'core/detect/detect_device.php';
238 $detect = new detect_device($log['agent']);
239 $log['device'] = $detect->arr['name'] . ' (' . $detect->arr['os'] . ' ' . $detect->arr['os_version'] . ')';
240 }
241
242 $log['ip'] = $_SERVER['REMOTE_ADDR'];
243 $log['domain'] = $_SERVER['SERVER_NAME'];
244 include_once 'core/detect.php';
245 $geo = new detect();
246 $geo->db = $db;
247 $geo->config = $Config;
248 $arr = $geo->operator_detect($log['ip'], 1);
249 $log['geo'] = $arr['name'] . ' ' . $arr['city'] . ' (' . $arr['isp'] . ')';
250...............................................................................
251..............................................
252................