-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathupdate.php
More file actions
60 lines (53 loc) · 2.02 KB
/
update.php
File metadata and controls
60 lines (53 loc) · 2.02 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
<?php
define("IN_SITE", true);
require_once(__DIR__.'/libs/db.php');
require_once(__DIR__.'/config.php');
require_once(__DIR__.'/libs/helper.php');
//require_once(__DIR__.'/models/is_admin.php');
$CMSNT = new DB();
$whitelist = array(
'127.0.0.1',
'::1'
);
if (in_array($_SERVER['REMOTE_ADDR'], $whitelist)) {
die('Localhost không thể sử dụng chức năng này');
}
if ($CMSNT->site('status_update') == 1) {
if ($config['version'] != file_get_contents('http://api.cmsnt.co/version.php?version=DVMXH2')) {
//CONFIG THÔNG SỐ
define('filename', 'update_'.random('ABC123456789', 6).'.zip');
define('serverfile', 'http://api.cmsnt.co/DVMXH2xz35f71fgb6x8g9s.zip');
// TIẾN HÀNH TẢI BẢN CẬP NHẬT TỪ SERVER VỀ
file_put_contents(filename, file_get_contents(serverfile));
// TIẾN HÀNH GIẢI NÉN BẢN CẬP NHẬT VÀ GHI ĐÈ VÀO HỆ THỐNG
$file = filename;
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
$zip = new ZipArchive();
$res = $zip->open($file);
if ($res === true) {
$zip->extractTo($path);
$zip->close();
// XÓA FILE ZIP CẬP NHẬT TRÁNH TỤI KHÔNG MUA ĐÒI XÀI FREE
unlink(filename);
// TIẾN HÀNH INSTALL DATABASE MỚI
$query = curl_get(BASE_URL('install.php'));
// XÓA FILE INSTALL DATABASE
if ($query) {
unlink('install.php');
}
// GHI LOG
$file = @fopen('Update.txt', 'a');
if ($file) {
$data = "[UPDATE] Phiên cập nhật phiên bản gần nhất vào lúc ".gettime().PHP_EOL;
fwrite($file, $data);
fclose($file);
}
die('Cập nhật thành công!');
} else {
die('Cập nhật thất bại!');
}
}
die('Không có phiên bản mới nhất');
} else {
die('Chức năng cập nhật tự động đang được tắt');
}