-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade.php
72 lines (59 loc) · 2.28 KB
/
upgrade.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
<?php
include("config/encrypt.php");
include("config/functions.php");
include("config/database.php");
include("api/pblast/config.php");
$Request = $_GET['req'];
if($Request != ""){
$Request = OtarDecrypt($key,$Request);
$ExternalFile = $Request['file'];
$ReqId = $Request['id'];
$Date = date("M-d-Y");
$UpdateFile = "CwUpdate-$Date";
$FileLocation = "./uploads/upgrade/$UpdateFile.zip";
$myfile = fopen("$FileLocation", "w");
// VALIDATE THE UPDATE REQUEST WITH PROMOTERBLAST \\
$body ="?appid=$Pblast_Api&reqid=$ReqId&req=validate&status=null";
$url = 'http://www.pblast.in/cwupgrade.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
$content = trim(curl_exec($ch));
curl_close($ch);
$content = OtarDecrypt($key,$content);
if($content['valid'] == "1"){
// SAVE THE EXTERNAL FILE TO THE SERVER \\
$ch = curl_init("$ExternalFile");
$fp = fopen("$FileLocation", 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
// EXTRACT THE EXTERNAL FILE'S CONTENTS \\
$CwZip = new ZipArchive;
if ($CwZip->open("$FileLocation") === TRUE){
$CwZip->extractTo('./');
$CwZip->close();
$body ="?appid=$Website_App_Id&reqid=$ReqId&req=update&status=1";
$url = 'http://www.pblast.in/cwupgrade.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
$content = trim(curl_exec($ch));
curl_close($ch);
}else{
$body ="?appid=$Website_App_Id&reqid=$ReqId&req=update&status=0";
$url = 'http://www.pblast.in/cwupgrade.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
$content = trim(curl_exec($ch));
curl_close($ch);
}
}
}
?>