-
Notifications
You must be signed in to change notification settings - Fork 0
/
adrotate-admin-portability.php
52 lines (48 loc) · 1.91 KB
/
adrotate-admin-portability.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
<?php
/* ------------------------------------------------------------------------------------
* COPYRIGHT AND TRADEMARK NOTICE
* Copyright 2008-2024 Arnan de Gans. All Rights Reserved.
* ADROTATE is a registered trademark of Arnan de Gans.
* COPYRIGHT NOTICES AND ALL THE COMMENTS SHOULD REMAIN INTACT.
* By using this code you agree to indemnify Arnan de Gans from any
* liability that might arise from its use.
------------------------------------------------------------------------------------ */
/*-------------------------------------------------------------
Name: adrotate_portable_hash
Purpose: Export/import adverts via a portable hash
Since: 5.8.3
-------------------------------------------------------------*/
function adrotate_portable_hash($action, $data, $what = 'advert') {
$source = get_option('siteurl');
if(in_array("aes-128-cbc", openssl_get_cipher_methods())) {
if($action == 'export') {
$portable['meta'] = array('type' => $what, 'source' => $source, 'exported' => current_time('timestamp'));
foreach($data as $key => $value) {
if(empty($value)) $value = '';
$advert[$key] = $value;
}
$portable['data'] = $advert;
$portable = serialize($portable);
return openssl_encrypt($portable, 'aes-128-cbc', '983jdnn3idjk02id', false, 'oi1u23kj123hj7jd');
}
if($action == 'import') {
$data = openssl_decrypt($data, 'aes-128-cbc', '983jdnn3idjk02id', false, 'oi1u23kj123hj7jd');
$data = unserialize($data);
if(is_array($data)) {
if(array_key_exists('meta', $data) AND array_key_exists('data', $data)) {
if($data['meta']['type'] == 'advert' AND $source != $data['meta']['source']) {
return $data['data'];
} else if($data['meta']['type'] == 'group') {
// maybe
} else if($data['meta']['type'] == 'schedule') {
// maybe
} else {
adrotate_return('adrotate', 514);
}
}
}
adrotate_return('adrotate', 513);
}
}
}
?>