-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransfer-profile.php
73 lines (52 loc) · 1.46 KB
/
transfer-profile.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
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $oldSecureDomain .'/api/v1/profile.json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
if(!empty($_POST['oldApi'])) {
$headers = array();
$headers[] = 'api-secret: ' . $oldHash;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$arr = json_decode($result);
$newArray = [];
if(!empty($arr->message) && $arr->message = 'Unauthorized') { ?>
<script>
window.location.href = '/?e=a';
</script>
<?php
exit();
}
$arr2 = json_decode($result, true);
foreach($arr2 as $item) {
unset($item['_id']);
array_push($newArray, $item);
}
$newJSON = json_encode($newArray);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $newSecureDomain . '/api/v1/profile');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $newJSON);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'api-secret: ' . $hashedSecret;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$arr = json_decode($result);
if(!empty($arr->message) && $arr->message = 'Unauthorized') { ?>
<script>
window.location.href = '/?e=a';
</script>
<?php
exit();
}
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);