-
Notifications
You must be signed in to change notification settings - Fork 8
/
hooks.php
149 lines (117 loc) · 6.15 KB
/
hooks.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
<?php
/*
* *********************************************
* ** LiveHelperChat Addon Module ***
If you don't have one, please register here
https://www.zopim.com/signup/trial
More About Zopim
http://www.zopim.com
Zopim is registered by Zopim Technologies Pte Ltd
* *********************************************
*/
function LiveHelperChatJS($vars) {
$q = @mysql_query("SELECT * FROM tbladdonmodules WHERE module = 'livehelperchat'");
while ($arr = mysql_fetch_array($q)) {
$settings[$arr['setting']] = html_entity_decode($arr['value']);
}
if ( $_SESSION['uid'] == null && $settings['show_for_logged'] == 'on') {
return;
}
$url = '';
if($settings['widget_click']){
$url .= '(click)/internal/';
}
if($settings['hide_offline']) {
$url .= "(hide_offline)/true/";
}
if($settings['widget_click']) {
$url .= "(check_operator_messages)/true/";
}
if($settings['leaveamessage']) {
$url .= "(leaveamessage)/true/";
}
if($settings['disable_pro_active']) {
$url .= "(disable_pro_active)/true/";
}
if($settings['noresponse']) {
$url .= "(noresponse)/true/";
}
if($settings['position'] == 'Native placement - it will be shown where the html is embedded') {
$url .= '(position)/original/';
}elseif($settings['position'] == 'Bottom left corner of the screen') {
$url .= '(position)/bottom_left/';
}elseif($settings['position'] == 'Bottom right corner of the screen') {
$url .= '(position)/bottom_right/';
}elseif($settings['position'] == 'Middle right side of the screen') {
$url .= '(position)/middle_right/';
}elseif($settings['position'] == 'Middle left side of the screen') {
$url .= '(position)/middle_left/';
}
if($settings['enabled']) {
$script = "<script type=\"text/javascript\">
var LHCChatOptions = {};</script>";
if ($_SESSION['uid']) {
$userid = $_SESSION['uid'];
$command = "getclientsdomains";
$adminuser = "admin";
$values["clientid"] = $userid;
$results = localAPI($command,$values,$adminuser);
$command = "getclientsproducts";
$products_results = localAPI($command,$values,$adminuser);
$command = "getinvoices";
$values_unpaid["userid"] = $userid;
$values_unpaid["status"] = "Unpaid";
$unpaidinvoices = localAPI($command,$values_unpaid,$adminuser);
$firstname = $vars['clientsdetails']['firstname'];
$lastname = $vars['clientsdetails']['lastname'];
$email = $vars['clientsdetails']["email"];
$companyname = $vars['clientsdetails']['companyname'];
$credit = $vars['clientsdetails']['credit'];
$script .= "<script type=\"text/javascript\">
LHCChatOptions.attr = new Array();
LHCChatOptions.attr.push({'name':'First name','value':'$firstname','type':'hidden','size':6,'req':false});
LHCChatOptions.attr.push({'name':'Last name','value':'$lastname','type':'hidden','size':6,'req':false});
LHCChatOptions.attr.push({'name':'Email','value':'$email','type':'hidden','size':6,'req':false});
LHCChatOptions.attr.push({'name':'Company name','value':'$companyname','type':'hidden','size':6,'req':false});
LHCChatOptions.attr.push({'name':'Credit','value':'$credit','type':'hidden','size':6,'req':false});";
if(count($results['domains']['domain'])) {
foreach($results['domains']['domain'] as $domain) {
$domainname = $domain['domainname'];
$script .="LHCChatOptions.attr.push({'name':'Domain name','value':'$domainname','type':'hidden','size':6,'req':false});";
$script .="LHCChatOptions.attr.push({'name':'{$domain['domainname']} expiry date','value':'{$domain['expirydate']}','type':'hidden','size':6,'req':false});";
$script .="LHCChatOptions.attr.push({'name':'{$domain['domainname']} registrar','value':'{$domain['registrar']}','type':'hidden','size':6,'req':false});";
}
}
if(count($unpaidinvoices['invoices']['invoice'])) {
foreach($unpaidinvoices['invoices']['invoice'] as $invoice) {
$invoicenumber = $invoice['invoicenum'];
$invoiceid = $invoice['id'];
$inv = $invoicenumber.'(ID:'.$invoiceid.')';
$script .="LHCChatOptions.attr.push({'name':'Unpaid invoice','value':'$inv','type':'hidden','size':6,'req':false});";
$script .="LHCChatOptions.attr.push({'name':'{$inv} duedate','value':'{$invoice['duedate']}','type':'hidden','size':6,'req':false});";
$script .="LHCChatOptions.attr.push({'name':'{$inv} subtotal','value':'{$invoice['subtotal']}','type':'hidden','size':6,'req':false});";
}
}
if(count($products_results['products']['product'])) {
foreach($results['products']['product'] as $products) {
$script .="LHCChatOptions.attr.push({'name':'Service name','value':'{$products['name']}','type':'hidden','size':6,'req':false});";
$script .="LHCChatOptions.attr.push({'name':'{$products['name']} server ip','value':'{$products['serverip']}','type':'hidden','size':6,'req':false});";
$script .="LHCChatOptions.attr.push({'name':'{$products['name']} next due date','value':'{$products['nextduedate']}','type':'hidden','size':6,'req':false});";
}
}
$script .= "</script>";
}
$script .= "<script type=\"text/javascript\">\nLHCChatOptions.opt = {widget_height:".$settings['widget_height'].",widget_width:".$settings['widget_height'].",popup_height:".$settings['popup_height'].",popup_width:".$settings['popup_width']."};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
var refferer = (document.referrer) ? encodeURIComponent(document.referrer.substr(document.referrer.indexOf('://')+1)) : '';
var location = (document.location) ? encodeURIComponent(window.location.href.substring(window.location.protocol.length)) : '';
po.src = '{$settings['widget_domain']}/chat/getstatus/(top)/{$settings['pos_top']}/(units)/{$settings['unit']}/$url?r='+refferer+'&l='+location;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>";
return $script;
}
}
add_hook('ClientAreaFooterOutput', 1, 'LiveHelperChatJS');
?>