-
Notifications
You must be signed in to change notification settings - Fork 0
/
updater.php
164 lines (162 loc) · 7.23 KB
/
updater.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
153
154
155
156
157
158
159
160
161
162
163
164
<?php
// +------------------------------------------------------------------------+
// | @author Deen Doughouz (DoughouzForest)
// | @author_url 1: http://www.wowonder.com
// | @author_url 2: http://codecanyon.net/user/doughouzforest
// | @author_email: wowondersocial@gmail.com
// +------------------------------------------------------------------------+
// | WoWonder - The Ultimate Social Networking Platform
// | Copyright (c) 2017 WoWonder. All rights reserved.
// +------------------------------------------------------------------------+
require_once('config.php');
require_once('assets/includes/tabels.php');
$f = '';
$data = array();
$s = '';
if (isset($_GET['f'])) {
$f = Wo_Secure($_GET['f'], 0);
}
if (isset($_GET['s'])) {
$s = Wo_Secure($_GET['s'], 0);
}
$hash_id = '';
if (!empty($_POST['hash_id'])) {
$hash_id = $_POST['hash_id'];
} else if (!empty($_GET['hash_id'])) {
$hash_id = $_GET['hash_id'];
} else if (!empty($_GET['hash'])) {
$hash_id = $_GET['hash'];
} else if (!empty($_POST['hash'])) {
$hash_id = $_POST['hash'];
}
function Wo_CheckMainSession($hash = '') {
if (!isset($_SESSION['main_hash_id']) || empty($_SESSION['main_hash_id'])) {
return false;
}
if (empty($hash)) {
return false;
}
if ($hash == $_SESSION['main_hash_id']) {
return true;
}
return false;
}
$wo = array();
// Connect to SQL Server
$sqlConnect = mysqli_connect($sql_db_host, $sql_db_user, $sql_db_pass, $sql_db_name, 3306);
function Wo_Secure($string, $censored_words = 1) {
global $sqlConnect;
$string = trim($string);
$string = htmlspecialchars($string, ENT_QUOTES);
$string = str_replace('\\n', " <br>", $string);
$string = str_replace('\\r', " <br>", $string);
$string = str_replace('\\r\\n', " <br>", $string);
$string = str_replace('\\n\\r', " <br>", $string);
$string = str_replace('&#', '&#', $string);
if ($censored_words == 1) {
global $config;
$censored_words = @explode(",", $config['censored_words']);
foreach ($censored_words as $censored_word) {
$censored_word = trim($censored_word);
$string = str_replace($censored_word, '****', $string);
}
}
return $string;
}
function unzip_file($file, $destination) {
// create object
$zip = new ZipArchive() ;
// open archive
if ($zip->open($file) !== TRUE) {
return false;
}
// extract contents to destination directory
$zip->extractTo($destination);
// close archive
$zip->close();
return true;
}
$theme_name = 'wowonder';
$query = mysqli_query($sqlConnect, "SELECT `value` FROM " . T_CONFIG . " WHERE `name` = 'theme'");
$mysqli_fetch = mysqli_fetch_assoc($query);
if (!empty($mysqli_fetch['value'])) {
$theme_name = $mysqli_fetch['value'];
}
$version = '';
$query = mysqli_query($sqlConnect, "SELECT `value` FROM " . T_CONFIG . " WHERE `name` = 'script_version'");
$mysqli_fetch = mysqli_fetch_assoc($query);
if (!empty($mysqli_fetch['value'])) {
$version = Wo_Secure($mysqli_fetch['value']);
}
if ($f == 'run_updater') {
$arrContextOptions = array(
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false
)
);
if (!empty($_GET['purchase_code'])) {
$purchase_code = Wo_Secure($_GET['purchase_code']);
if (empty($version)) {
$version = Wo_Secure($_GET['script_version']);
}
$siteurl = urlencode($_SERVER['SERVER_NAME']);
$file = file_get_contents("http://www.wowonder.com/check_for_updates.php?code={$purchase_code}&version=$version&url=$siteurl&check_for=true", false, stream_context_create($arrContextOptions));
$check = json_decode($file, true);
if (!empty($check['status'])) {
if ($check['status'] == 'SUCCESS') {
if (!empty($check['versions'])) {
foreach ($check['versions'] as $key => $version) {
$updater = file_put_contents('script.zip', file_get_contents("https://www.wowonder.com/get_update.php?code={$purchase_code}&version=$version&url=$siteurl", false, stream_context_create($arrContextOptions)));
if ($updater && file_exists('script.zip')) {
$updater = file_put_contents('theme.zip', file_get_contents("https://www.wowonder.com/get_update.php?code={$purchase_code}&version=$version&theme=true&url=$siteurl", false, stream_context_create($arrContextOptions)));
$updater = file_put_contents('wonderful.zip', file_get_contents("https://www.wowonder.com/get_update.php?code={$purchase_code}&version=$version&wonderful=true&url=$siteurl", false, stream_context_create($arrContextOptions)));
if ($updater) {
$unzip_file = unzip_file('script.zip', './');
if ($unzip_file) {
if (file_exists('theme.zip') && file_exists('./themes/wowonder')) {
$unzip_file = unzip_file('theme.zip', './themes/wowonder/');
}
if (file_exists('wonderful.zip') && file_exists('./themes/wonderful')) {
$unzip_file = unzip_file('wonderful.zip', './themes/wonderful/');
}
if (file_exists('update.php')) {
$file = file_get_contents($site_url . "/update.php", false, stream_context_create($arrContextOptions));
}
if (file_exists('theme.zip')) {
unlink('theme.zip');
}
if (file_exists('script.zip')) {
unlink('script.zip');
}
if (file_exists('wonderful.zip')) {
unlink('wonderful.zip');
}
$data['status'] = 200;
} else {
$data['status'] = 400;
$data['ERROR_NAME'] = 'Error found while updating, please update your site manually.';
}
}
} else {
$data['status'] = 400;
$data['ERROR_NAME'] = 'Error found while updating, please update your site manually.';
}
}
} else {
$data['status'] = 400;
$data['ERROR_NAME'] = 'Error found while updating, please update your site manually.';
}
} else {
$data['status'] = 400;
$data['ERROR_NAME'] = $check['ERROR_NAME'];
}
} else {
$data['status'] = 400;
$data['ERROR_NAME'] = 'Error found while updating, please update your site manually.';
}
}
header("Content-type: application/json");
echo json_encode($data);
exit();
}