-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcookie_script.php
More file actions
executable file
·58 lines (52 loc) · 1.65 KB
/
Copy pathcookie_script.php
File metadata and controls
executable file
·58 lines (52 loc) · 1.65 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
<?php
header('Content-Type: text/javascript');
if(!isset($_COOKIE['stats_user_id'])) {
$bytes = random_bytes(8);
$user_id = bin2hex($bytes);
setcookie('stats_user_id', $user_id, time() + 365 * 86400 * 10);
//echo "cookies";
} else {
$user_id = $_COOKIE['stats_user_id'];
}
echo "var host = '" . $_SERVER['HTTP_REFERER'] . "'; ";
$config = "{
cart_item_name_selector: '.cart .item .name',
page_item_name_selector: '.item-name',
page_item_category_selector: '.item-category',
paste_container_selector: '.paste-container',
}";
if(isset($_SERVER['HTTP_REFERER']))
{
$url = parse_url($_SERVER['HTTP_REFERER']);
if(isset($url['host'])) $config = config_create($url['host']);
}
$js = str_replace('%%user_id%%', $user_id, file_get_contents('script.js'));
$js = str_replace('%%config%%', $config, $js);
echo $js;
function config_create($host_name)
{
switch($host_name) {
case 'abc.ru' :
return "{
cart_item_name_selector: '.cart .item .nameeeee',
page_item_name_selector: '.item-name',
page_item_category_selector: '.item-category',
paste_container_selector: '.paste-containter',
}";
case 'staging.realytics.ru' :
return "{
cart_item_name_selector: '.cart .item .name',
page_item_name_selector: '.sel-product-title',
page_item_category_selector: '.c-breadcrumbs__item-text',
paste_container_selector: '.review-container',
}";
default :
return "{
cart_item_name_selector: '.cart .item .name',
page_item_name_selector: '.item-name',
page_item_category_selector: '.item-category',
paste_container_selector: '.paste-containter',
}";
}
}
?>