Version Description
Download this release
Release Info
Developer | bencxr |
Plugin | Zendesk Chat |
Version | 0.7 |
Comparing to | |
See all releases |
Version 0.7
- JSON.php +807 -0
- ZeroClipboard.js +302 -0
- ZeroClipboard.swf +0 -0
- accountconfig.php +296 -0
- customizewidget.php +415 -0
- imintegration.php +140 -0
- readme.txt +101 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- zopim.php +261 -0
JSON.php
ADDED
@@ -0,0 +1,807 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Converts to and from JSON format.
|
6 |
+
*
|
7 |
+
* JSON (JavaScript Object Notation) is a lightweight data-interchange
|
8 |
+
* format. It is easy for humans to read and write. It is easy for machines
|
9 |
+
* to parse and generate. It is based on a subset of the JavaScript
|
10 |
+
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
|
11 |
+
* This feature can also be found in Python. JSON is a text format that is
|
12 |
+
* completely language independent but uses conventions that are familiar
|
13 |
+
* to programmers of the C-family of languages, including C, C++, C#, Java,
|
14 |
+
* JavaScript, Perl, TCL, and many others. These properties make JSON an
|
15 |
+
* ideal data-interchange language.
|
16 |
+
*
|
17 |
+
* This package provides a simple encoder and decoder for JSON notation. It
|
18 |
+
* is intended for use with client-side Javascript applications that make
|
19 |
+
* use of HTTPRequest to perform server communication functions - data can
|
20 |
+
* be encoded into JSON notation for use in a client-side javascript, or
|
21 |
+
* decoded from incoming Javascript requests. JSON format is native to
|
22 |
+
* Javascript, and can be directly eval()'ed with no further parsing
|
23 |
+
* overhead
|
24 |
+
*
|
25 |
+
* All strings should be in ASCII or UTF-8 format!
|
26 |
+
*
|
27 |
+
* LICENSE: Redistribution and use in source and binary forms, with or
|
28 |
+
* without modification, are permitted provided that the following
|
29 |
+
* conditions are met: Redistributions of source code must retain the
|
30 |
+
* above copyright notice, this list of conditions and the following
|
31 |
+
* disclaimer. Redistributions in binary form must reproduce the above
|
32 |
+
* copyright notice, this list of conditions and the following disclaimer
|
33 |
+
* in the documentation and/or other materials provided with the
|
34 |
+
* distribution.
|
35 |
+
*
|
36 |
+
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
37 |
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
38 |
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
39 |
+
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
40 |
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
41 |
+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
42 |
+
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
43 |
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
44 |
+
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
45 |
+
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
46 |
+
* DAMAGE.
|
47 |
+
*
|
48 |
+
* @category
|
49 |
+
* @package Services_JSON
|
50 |
+
* @author Michal Migurski <mike-json@teczno.com>
|
51 |
+
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
|
52 |
+
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
|
53 |
+
* @copyright 2005 Michal Migurski
|
54 |
+
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
|
55 |
+
* @license http://www.opensource.org/licenses/bsd-license.php
|
56 |
+
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
|
57 |
+
*/
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Marker constant for Services_JSON::decode(), used to flag stack state
|
61 |
+
*/
|
62 |
+
define('SERVICES_JSON_SLICE', 1);
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Marker constant for Services_JSON::decode(), used to flag stack state
|
66 |
+
*/
|
67 |
+
define('SERVICES_JSON_IN_STR', 2);
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Marker constant for Services_JSON::decode(), used to flag stack state
|
71 |
+
*/
|
72 |
+
define('SERVICES_JSON_IN_ARR', 3);
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Marker constant for Services_JSON::decode(), used to flag stack state
|
76 |
+
*/
|
77 |
+
define('SERVICES_JSON_IN_OBJ', 4);
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Marker constant for Services_JSON::decode(), used to flag stack state
|
81 |
+
*/
|
82 |
+
define('SERVICES_JSON_IN_CMT', 5);
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Behavior switch for Services_JSON::decode()
|
86 |
+
*/
|
87 |
+
define('SERVICES_JSON_LOOSE_TYPE', 16);
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Behavior switch for Services_JSON::decode()
|
91 |
+
*/
|
92 |
+
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Converts to and from JSON format.
|
96 |
+
*
|
97 |
+
* Brief example of use:
|
98 |
+
*
|
99 |
+
* <code>
|
100 |
+
* // create a new instance of Services_JSON
|
101 |
+
* $json = new Services_JSON();
|
102 |
+
*
|
103 |
+
* // convert a complexe value to JSON notation, and send it to the browser
|
104 |
+
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
|
105 |
+
* $output = $json->encode($value);
|
106 |
+
*
|
107 |
+
* print($output);
|
108 |
+
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
|
109 |
+
*
|
110 |
+
* // accept incoming POST data, assumed to be in JSON notation
|
111 |
+
* $input = file_get_contents('php://input', 1000000);
|
112 |
+
* $value = $json->decode($input);
|
113 |
+
* </code>
|
114 |
+
*/
|
115 |
+
class Services_JSON
|
116 |
+
{
|
117 |
+
/**
|
118 |
+
* constructs a new JSON instance
|
119 |
+
*
|
120 |
+
* @param int $use object behavior flags; combine with boolean-OR
|
121 |
+
*
|
122 |
+
* possible values:
|
123 |
+
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
|
124 |
+
* "{...}" syntax creates associative arrays
|
125 |
+
* instead of objects in decode().
|
126 |
+
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
|
127 |
+
* Values which can't be encoded (e.g. resources)
|
128 |
+
* appear as NULL instead of throwing errors.
|
129 |
+
* By default, a deeply-nested resource will
|
130 |
+
* bubble up with an error, so all return values
|
131 |
+
* from encode() should be checked with isError()
|
132 |
+
*/
|
133 |
+
function Services_JSON($use = 0)
|
134 |
+
{
|
135 |
+
$this->use = $use;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* convert a string from one UTF-16 char to one UTF-8 char
|
140 |
+
*
|
141 |
+
* Normally should be handled by mb_convert_encoding, but
|
142 |
+
* provides a slower PHP-only method for installations
|
143 |
+
* that lack the multibye string extension.
|
144 |
+
*
|
145 |
+
* @param string $utf16 UTF-16 character
|
146 |
+
* @return string UTF-8 character
|
147 |
+
* @access private
|
148 |
+
*/
|
149 |
+
function utf162utf8($utf16)
|
150 |
+
{
|
151 |
+
// oh please oh please oh please oh please oh please
|
152 |
+
if(function_exists('mb_convert_encoding')) {
|
153 |
+
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
|
154 |
+
}
|
155 |
+
|
156 |
+
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
|
157 |
+
|
158 |
+
switch(true) {
|
159 |
+
case ((0x7F & $bytes) == $bytes):
|
160 |
+
// this case should never be reached, because we are in ASCII range
|
161 |
+
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
162 |
+
return chr(0x7F & $bytes);
|
163 |
+
|
164 |
+
case (0x07FF & $bytes) == $bytes:
|
165 |
+
// return a 2-byte UTF-8 character
|
166 |
+
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
167 |
+
return chr(0xC0 | (($bytes >> 6) & 0x1F))
|
168 |
+
. chr(0x80 | ($bytes & 0x3F));
|
169 |
+
|
170 |
+
case (0xFFFF & $bytes) == $bytes:
|
171 |
+
// return a 3-byte UTF-8 character
|
172 |
+
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
173 |
+
return chr(0xE0 | (($bytes >> 12) & 0x0F))
|
174 |
+
. chr(0x80 | (($bytes >> 6) & 0x3F))
|
175 |
+
. chr(0x80 | ($bytes & 0x3F));
|
176 |
+
}
|
177 |
+
|
178 |
+
// ignoring UTF-32 for now, sorry
|
179 |
+
return '';
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* convert a string from one UTF-8 char to one UTF-16 char
|
184 |
+
*
|
185 |
+
* Normally should be handled by mb_convert_encoding, but
|
186 |
+
* provides a slower PHP-only method for installations
|
187 |
+
* that lack the multibye string extension.
|
188 |
+
*
|
189 |
+
* @param string $utf8 UTF-8 character
|
190 |
+
* @return string UTF-16 character
|
191 |
+
* @access private
|
192 |
+
*/
|
193 |
+
function utf82utf16($utf8)
|
194 |
+
{
|
195 |
+
// oh please oh please oh please oh please oh please
|
196 |
+
if(function_exists('mb_convert_encoding')) {
|
197 |
+
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
198 |
+
}
|
199 |
+
|
200 |
+
switch(strlen($utf8)) {
|
201 |
+
case 1:
|
202 |
+
// this case should never be reached, because we are in ASCII range
|
203 |
+
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
204 |
+
return $utf8;
|
205 |
+
|
206 |
+
case 2:
|
207 |
+
// return a UTF-16 character from a 2-byte UTF-8 char
|
208 |
+
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
209 |
+
return chr(0x07 & (ord($utf8{0}) >> 2))
|
210 |
+
. chr((0xC0 & (ord($utf8{0}) << 6))
|
211 |
+
| (0x3F & ord($utf8{1})));
|
212 |
+
|
213 |
+
case 3:
|
214 |
+
// return a UTF-16 character from a 3-byte UTF-8 char
|
215 |
+
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
216 |
+
return chr((0xF0 & (ord($utf8{0}) << 4))
|
217 |
+
| (0x0F & (ord($utf8{1}) >> 2)))
|
218 |
+
. chr((0xC0 & (ord($utf8{1}) << 6))
|
219 |
+
| (0x7F & ord($utf8{2})));
|
220 |
+
}
|
221 |
+
|
222 |
+
// ignoring UTF-32 for now, sorry
|
223 |
+
return '';
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* encodes an arbitrary variable into JSON format
|
228 |
+
*
|
229 |
+
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
230 |
+
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
231 |
+
* if var is a strng, note that encode() always expects it
|
232 |
+
* to be in ASCII or UTF-8 format!
|
233 |
+
*
|
234 |
+
* @return mixed JSON string representation of input var or an error if a problem occurs
|
235 |
+
* @access public
|
236 |
+
*/
|
237 |
+
function encode($var)
|
238 |
+
{
|
239 |
+
switch (gettype($var)) {
|
240 |
+
case 'boolean':
|
241 |
+
return $var ? 'true' : 'false';
|
242 |
+
|
243 |
+
case 'NULL':
|
244 |
+
return 'null';
|
245 |
+
|
246 |
+
case 'integer':
|
247 |
+
return (int) $var;
|
248 |
+
|
249 |
+
case 'double':
|
250 |
+
case 'float':
|
251 |
+
return (float) $var;
|
252 |
+
|
253 |
+
case 'string':
|
254 |
+
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
|
255 |
+
$ascii = '';
|
256 |
+
$strlen_var = strlen($var);
|
257 |
+
|
258 |
+
/*
|
259 |
+
* Iterate over every character in the string,
|
260 |
+
* escaping with a slash or encoding to UTF-8 where necessary
|
261 |
+
*/
|
262 |
+
for ($c = 0; $c < $strlen_var; ++$c) {
|
263 |
+
|
264 |
+
$ord_var_c = ord($var{$c});
|
265 |
+
|
266 |
+
switch (true) {
|
267 |
+
case $ord_var_c == 0x08:
|
268 |
+
$ascii .= '\b';
|
269 |
+
break;
|
270 |
+
case $ord_var_c == 0x09:
|
271 |
+
$ascii .= '\t';
|
272 |
+
break;
|
273 |
+
case $ord_var_c == 0x0A:
|
274 |
+
$ascii .= '\n';
|
275 |
+
break;
|
276 |
+
case $ord_var_c == 0x0C:
|
277 |
+
$ascii .= '\f';
|
278 |
+
break;
|
279 |
+
case $ord_var_c == 0x0D:
|
280 |
+
$ascii .= '\r';
|
281 |
+
break;
|
282 |
+
|
283 |
+
case $ord_var_c == 0x22:
|
284 |
+
case $ord_var_c == 0x2F:
|
285 |
+
case $ord_var_c == 0x5C:
|
286 |
+
// double quote, slash, slosh
|
287 |
+
$ascii .= '\\'.$var{$c};
|
288 |
+
break;
|
289 |
+
|
290 |
+
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
|
291 |
+
// characters U-00000000 - U-0000007F (same as ASCII)
|
292 |
+
$ascii .= $var{$c};
|
293 |
+
break;
|
294 |
+
|
295 |
+
case (($ord_var_c & 0xE0) == 0xC0):
|
296 |
+
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
297 |
+
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
298 |
+
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
|
299 |
+
$c += 1;
|
300 |
+
$utf16 = $this->utf82utf16($char);
|
301 |
+
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
302 |
+
break;
|
303 |
+
|
304 |
+
case (($ord_var_c & 0xF0) == 0xE0):
|
305 |
+
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
306 |
+
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
307 |
+
$char = pack('C*', $ord_var_c,
|
308 |
+
ord($var{$c + 1}),
|
309 |
+
ord($var{$c + 2}));
|
310 |
+
$c += 2;
|
311 |
+
$utf16 = $this->utf82utf16($char);
|
312 |
+
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
313 |
+
break;
|
314 |
+
|
315 |
+
case (($ord_var_c & 0xF8) == 0xF0):
|
316 |
+
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
317 |
+
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
318 |
+
$char = pack('C*', $ord_var_c,
|
319 |
+
ord($var{$c + 1}),
|
320 |
+
ord($var{$c + 2}),
|
321 |
+
ord($var{$c + 3}));
|
322 |
+
$c += 3;
|
323 |
+
$utf16 = $this->utf82utf16($char);
|
324 |
+
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
325 |
+
break;
|
326 |
+
|
327 |
+
case (($ord_var_c & 0xFC) == 0xF8):
|
328 |
+
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
329 |
+
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
330 |
+
$char = pack('C*', $ord_var_c,
|
331 |
+
ord($var{$c + 1}),
|
332 |
+
ord($var{$c + 2}),
|
333 |
+
ord($var{$c + 3}),
|
334 |
+
ord($var{$c + 4}));
|
335 |
+
$c += 4;
|
336 |
+
$utf16 = $this->utf82utf16($char);
|
337 |
+
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
338 |
+
break;
|
339 |
+
|
340 |
+
case (($ord_var_c & 0xFE) == 0xFC):
|
341 |
+
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
342 |
+
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
343 |
+
$char = pack('C*', $ord_var_c,
|
344 |
+
ord($var{$c + 1}),
|
345 |
+
ord($var{$c + 2}),
|
346 |
+
ord($var{$c + 3}),
|
347 |
+
ord($var{$c + 4}),
|
348 |
+
ord($var{$c + 5}));
|
349 |
+
$c += 5;
|
350 |
+
$utf16 = $this->utf82utf16($char);
|
351 |
+
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
352 |
+
break;
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
return '"'.$ascii.'"';
|
357 |
+
|
358 |
+
case 'array':
|
359 |
+
/*
|
360 |
+
* As per JSON spec if any array key is not an integer
|
361 |
+
* we must treat the the whole array as an object. We
|
362 |
+
* also try to catch a sparsely populated associative
|
363 |
+
* array with numeric keys here because some JS engines
|
364 |
+
* will create an array with empty indexes up to
|
365 |
+
* max_index which can cause memory issues and because
|
366 |
+
* the keys, which may be relevant, will be remapped
|
367 |
+
* otherwise.
|
368 |
+
*
|
369 |
+
* As per the ECMA and JSON specification an object may
|
370 |
+
* have any string as a property. Unfortunately due to
|
371 |
+
* a hole in the ECMA specification if the key is a
|
372 |
+
* ECMA reserved word or starts with a digit the
|
373 |
+
* parameter is only accessible using ECMAScript's
|
374 |
+
* bracket notation.
|
375 |
+
*/
|
376 |
+
|
377 |
+
// treat as a JSON object
|
378 |
+
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
|
379 |
+
$properties = array_map(array($this, 'name_value'),
|
380 |
+
array_keys($var),
|
381 |
+
array_values($var));
|
382 |
+
|
383 |
+
foreach($properties as $property) {
|
384 |
+
if(Services_JSON::isError($property)) {
|
385 |
+
return $property;
|
386 |
+
}
|
387 |
+
}
|
388 |
+
|
389 |
+
return '{' . join(',', $properties) . '}';
|
390 |
+
}
|
391 |
+
|
392 |
+
// treat it like a regular array
|
393 |
+
$elements = array_map(array($this, 'encode'), $var);
|
394 |
+
|
395 |
+
foreach($elements as $element) {
|
396 |
+
if(Services_JSON::isError($element)) {
|
397 |
+
return $element;
|
398 |
+
}
|
399 |
+
}
|
400 |
+
|
401 |
+
return '[' . join(',', $elements) . ']';
|
402 |
+
|
403 |
+
case 'object':
|
404 |
+
$vars = get_object_vars($var);
|
405 |
+
|
406 |
+
$properties = array_map(array($this, 'name_value'),
|
407 |
+
array_keys($vars),
|
408 |
+
array_values($vars));
|
409 |
+
|
410 |
+
foreach($properties as $property) {
|
411 |
+
if(Services_JSON::isError($property)) {
|
412 |
+
return $property;
|
413 |
+
}
|
414 |
+
}
|
415 |
+
|
416 |
+
return '{' . join(',', $properties) . '}';
|
417 |
+
|
418 |
+
default:
|
419 |
+
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
|
420 |
+
? 'null'
|
421 |
+
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
|
422 |
+
}
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* array-walking function for use in generating JSON-formatted name-value pairs
|
427 |
+
*
|
428 |
+
* @param string $name name of key to use
|
429 |
+
* @param mixed $value reference to an array element to be encoded
|
430 |
+
*
|
431 |
+
* @return string JSON-formatted name-value pair, like '"name":value'
|
432 |
+
* @access private
|
433 |
+
*/
|
434 |
+
function name_value($name, $value)
|
435 |
+
{
|
436 |
+
$encoded_value = $this->encode($value);
|
437 |
+
|
438 |
+
if(Services_JSON::isError($encoded_value)) {
|
439 |
+
return $encoded_value;
|
440 |
+
}
|
441 |
+
|
442 |
+
return $this->encode(strval($name)) . ':' . $encoded_value;
|
443 |
+
}
|
444 |
+
|
445 |
+
/**
|
446 |
+
* reduce a string by removing leading and trailing comments and whitespace
|
447 |
+
*
|
448 |
+
* @param $str string string value to strip of comments and whitespace
|
449 |
+
*
|
450 |
+
* @return string string value stripped of comments and whitespace
|
451 |
+
* @access private
|
452 |
+
*/
|
453 |
+
function reduce_string($str)
|
454 |
+
{
|
455 |
+
$str = preg_replace(array(
|
456 |
+
|
457 |
+
// eliminate single line comments in '// ...' form
|
458 |
+
'#^\s*//(.+)$#m',
|
459 |
+
|
460 |
+
// eliminate multi-line comments in '/* ... */' form, at start of string
|
461 |
+
'#^\s*/\*(.+)\*/#Us',
|
462 |
+
|
463 |
+
// eliminate multi-line comments in '/* ... */' form, at end of string
|
464 |
+
'#/\*(.+)\*/\s*$#Us'
|
465 |
+
|
466 |
+
), '', $str);
|
467 |
+
|
468 |
+
// eliminate extraneous space
|
469 |
+
return trim($str);
|
470 |
+
}
|
471 |
+
|
472 |
+
/**
|
473 |
+
* decodes a JSON string into appropriate variable
|
474 |
+
*
|
475 |
+
* @param string $str JSON-formatted string
|
476 |
+
*
|
477 |
+
* @return mixed number, boolean, string, array, or object
|
478 |
+
* corresponding to given JSON input string.
|
479 |
+
* See argument 1 to Services_JSON() above for object-output behavior.
|
480 |
+
* Note that decode() always returns strings
|
481 |
+
* in ASCII or UTF-8 format!
|
482 |
+
* @access public
|
483 |
+
*/
|
484 |
+
function decode($str)
|
485 |
+
{
|
486 |
+
$str = $this->reduce_string($str);
|
487 |
+
|
488 |
+
switch (strtolower($str)) {
|
489 |
+
case 'true':
|
490 |
+
return true;
|
491 |
+
|
492 |
+
case 'false':
|
493 |
+
return false;
|
494 |
+
|
495 |
+
case 'null':
|
496 |
+
return null;
|
497 |
+
|
498 |
+
default:
|
499 |
+
$m = array();
|
500 |
+
|
501 |
+
if (is_numeric($str)) {
|
502 |
+
// Lookie-loo, it's a number
|
503 |
+
|
504 |
+
// This would work on its own, but I'm trying to be
|
505 |
+
// good about returning integers where appropriate:
|
506 |
+
// return (float)$str;
|
507 |
+
|
508 |
+
// Return float or int, as appropriate
|
509 |
+
return ((float)$str == (integer)$str)
|
510 |
+
? (integer)$str
|
511 |
+
: (float)$str;
|
512 |
+
|
513 |
+
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
|
514 |
+
// STRINGS RETURNED IN UTF-8 FORMAT
|
515 |
+
$delim = substr($str, 0, 1);
|
516 |
+
$chrs = substr($str, 1, -1);
|
517 |
+
$utf8 = '';
|
518 |
+
$strlen_chrs = strlen($chrs);
|
519 |
+
|
520 |
+
for ($c = 0; $c < $strlen_chrs; ++$c) {
|
521 |
+
|
522 |
+
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
523 |
+
$ord_chrs_c = ord($chrs{$c});
|
524 |
+
|
525 |
+
switch (true) {
|
526 |
+
case $substr_chrs_c_2 == '\b':
|
527 |
+
$utf8 .= chr(0x08);
|
528 |
+
++$c;
|
529 |
+
break;
|
530 |
+
case $substr_chrs_c_2 == '\t':
|
531 |
+
$utf8 .= chr(0x09);
|
532 |
+
++$c;
|
533 |
+
break;
|
534 |
+
case $substr_chrs_c_2 == '\n':
|
535 |
+
$utf8 .= chr(0x0A);
|
536 |
+
++$c;
|
537 |
+
break;
|
538 |
+
case $substr_chrs_c_2 == '\f':
|
539 |
+
$utf8 .= chr(0x0C);
|
540 |
+
++$c;
|
541 |
+
break;
|
542 |
+
case $substr_chrs_c_2 == '\r':
|
543 |
+
$utf8 .= chr(0x0D);
|
544 |
+
++$c;
|
545 |
+
break;
|
546 |
+
|
547 |
+
case $substr_chrs_c_2 == '\\"':
|
548 |
+
case $substr_chrs_c_2 == '\\\'':
|
549 |
+
case $substr_chrs_c_2 == '\\\\':
|
550 |
+
case $substr_chrs_c_2 == '\\/':
|
551 |
+
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
|
552 |
+
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
|
553 |
+
$utf8 .= $chrs{++$c};
|
554 |
+
}
|
555 |
+
break;
|
556 |
+
|
557 |
+
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
|
558 |
+
// single, escaped unicode character
|
559 |
+
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
|
560 |
+
. chr(hexdec(substr($chrs, ($c + 4), 2)));
|
561 |
+
$utf8 .= $this->utf162utf8($utf16);
|
562 |
+
$c += 5;
|
563 |
+
break;
|
564 |
+
|
565 |
+
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
|
566 |
+
$utf8 .= $chrs{$c};
|
567 |
+
break;
|
568 |
+
|
569 |
+
case ($ord_chrs_c & 0xE0) == 0xC0:
|
570 |
+
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
571 |
+
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
572 |
+
$utf8 .= substr($chrs, $c, 2);
|
573 |
+
++$c;
|
574 |
+
break;
|
575 |
+
|
576 |
+
case ($ord_chrs_c & 0xF0) == 0xE0:
|
577 |
+
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
578 |
+
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
579 |
+
$utf8 .= substr($chrs, $c, 3);
|
580 |
+
$c += 2;
|
581 |
+
break;
|
582 |
+
|
583 |
+
case ($ord_chrs_c & 0xF8) == 0xF0:
|
584 |
+
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
585 |
+
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
586 |
+
$utf8 .= substr($chrs, $c, 4);
|
587 |
+
$c += 3;
|
588 |
+
break;
|
589 |
+
|
590 |
+
case ($ord_chrs_c & 0xFC) == 0xF8:
|
591 |
+
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
592 |
+
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
593 |
+
$utf8 .= substr($chrs, $c, 5);
|
594 |
+
$c += 4;
|
595 |
+
break;
|
596 |
+
|
597 |
+
case ($ord_chrs_c & 0xFE) == 0xFC:
|
598 |
+
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
599 |
+
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
600 |
+
$utf8 .= substr($chrs, $c, 6);
|
601 |
+
$c += 5;
|
602 |
+
break;
|
603 |
+
|
604 |
+
}
|
605 |
+
|
606 |
+
}
|
607 |
+
|
608 |
+
return $utf8;
|
609 |
+
|
610 |
+
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
|
611 |
+
// array, or object notation
|
612 |
+
|
613 |
+
if ($str{0} == '[') {
|
614 |
+
$stk = array(SERVICES_JSON_IN_ARR);
|
615 |
+
$arr = array();
|
616 |
+
} else {
|
617 |
+
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
618 |
+
$stk = array(SERVICES_JSON_IN_OBJ);
|
619 |
+
$obj = array();
|
620 |
+
} else {
|
621 |
+
$stk = array(SERVICES_JSON_IN_OBJ);
|
622 |
+
$obj = new stdClass();
|
623 |
+
}
|
624 |
+
}
|
625 |
+
|
626 |
+
array_push($stk, array('what' => SERVICES_JSON_SLICE,
|
627 |
+
'where' => 0,
|
628 |
+
'delim' => false));
|
629 |
+
|
630 |
+
$chrs = substr($str, 1, -1);
|
631 |
+
$chrs = $this->reduce_string($chrs);
|
632 |
+
|
633 |
+
if ($chrs == '') {
|
634 |
+
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
635 |
+
return $arr;
|
636 |
+
|
637 |
+
} else {
|
638 |
+
return $obj;
|
639 |
+
|
640 |
+
}
|
641 |
+
}
|
642 |
+
|
643 |
+
//print("\nparsing {$chrs}\n");
|
644 |
+
|
645 |
+
$strlen_chrs = strlen($chrs);
|
646 |
+
|
647 |
+
for ($c = 0; $c <= $strlen_chrs; ++$c) {
|
648 |
+
|
649 |
+
$top = end($stk);
|
650 |
+
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
651 |
+
|
652 |
+
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
|
653 |
+
// found a comma that is not inside a string, array, etc.,
|
654 |
+
// OR we've reached the end of the character list
|
655 |
+
$slice = substr($chrs, $top['where'], ($c - $top['where']));
|
656 |
+
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
|
657 |
+
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
658 |
+
|
659 |
+
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
660 |
+
// we are in an array, so just push an element onto the stack
|
661 |
+
array_push($arr, $this->decode($slice));
|
662 |
+
|
663 |
+
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
664 |
+
// we are in an object, so figure
|
665 |
+
// out the property name and set an
|
666 |
+
// element in an associative array,
|
667 |
+
// for now
|
668 |
+
$parts = array();
|
669 |
+
|
670 |
+
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
|
671 |
+
// "name":value pair
|
672 |
+
$key = $this->decode($parts[1]);
|
673 |
+
$val = $this->decode($parts[2]);
|
674 |
+
|
675 |
+
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
676 |
+
$obj[$key] = $val;
|
677 |
+
} else {
|
678 |
+
$obj->$key = $val;
|
679 |
+
}
|
680 |
+
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
|
681 |
+
// name:value pair, where name is unquoted
|
682 |
+
$key = $parts[1];
|
683 |
+
$val = $this->decode($parts[2]);
|
684 |
+
|
685 |
+
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
686 |
+
$obj[$key] = $val;
|
687 |
+
} else {
|
688 |
+
$obj->$key = $val;
|
689 |
+
}
|
690 |
+
}
|
691 |
+
|
692 |
+
}
|
693 |
+
|
694 |
+
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
|
695 |
+
// found a quote, and we are not inside a string
|
696 |
+
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
|
697 |
+
//print("Found start of string at {$c}\n");
|
698 |
+
|
699 |
+
} elseif (($chrs{$c} == $top['delim']) &&
|
700 |
+
($top['what'] == SERVICES_JSON_IN_STR) &&
|
701 |
+
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
|
702 |
+
// found a quote, we're in a string, and it's not escaped
|
703 |
+
// we know that it's not escaped becase there is _not_ an
|
704 |
+
// odd number of backslashes at the end of the string so far
|
705 |
+
array_pop($stk);
|
706 |
+
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
|
707 |
+
|
708 |
+
} elseif (($chrs{$c} == '[') &&
|
709 |
+
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
710 |
+
// found a left-bracket, and we are in an array, object, or slice
|
711 |
+
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
|
712 |
+
//print("Found start of array at {$c}\n");
|
713 |
+
|
714 |
+
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
|
715 |
+
// found a right-bracket, and we're in an array
|
716 |
+
array_pop($stk);
|
717 |
+
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
718 |
+
|
719 |
+
} elseif (($chrs{$c} == '{') &&
|
720 |
+
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
721 |
+
// found a left-brace, and we are in an array, object, or slice
|
722 |
+
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
|
723 |
+
//print("Found start of object at {$c}\n");
|
724 |
+
|
725 |
+
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
|
726 |
+
// found a right-brace, and we're in an object
|
727 |
+
array_pop($stk);
|
728 |
+
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
729 |
+
|
730 |
+
} elseif (($substr_chrs_c_2 == '/*') &&
|
731 |
+
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
732 |
+
// found a comment start, and we are in an array, object, or slice
|
733 |
+
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
|
734 |
+
$c++;
|
735 |
+
//print("Found start of comment at {$c}\n");
|
736 |
+
|
737 |
+
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
|
738 |
+
// found a comment end, and we're in one now
|
739 |
+
array_pop($stk);
|
740 |
+
$c++;
|
741 |
+
|
742 |
+
for ($i = $top['where']; $i <= $c; ++$i)
|
743 |
+
$chrs = substr_replace($chrs, ' ', $i, 1);
|
744 |
+
|
745 |
+
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
746 |
+
|
747 |
+
}
|
748 |
+
|
749 |
+
}
|
750 |
+
|
751 |
+
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
752 |
+
return $arr;
|
753 |
+
|
754 |
+
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
755 |
+
return $obj;
|
756 |
+
|
757 |
+
}
|
758 |
+
|
759 |
+
}
|
760 |
+
}
|
761 |
+
}
|
762 |
+
|
763 |
+
/**
|
764 |
+
* @todo Ultimately, this should just call PEAR::isError()
|
765 |
+
*/
|
766 |
+
function isError($data, $code = null)
|
767 |
+
{
|
768 |
+
if (class_exists('pear')) {
|
769 |
+
return PEAR::isError($data, $code);
|
770 |
+
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
|
771 |
+
is_subclass_of($data, 'services_json_error'))) {
|
772 |
+
return true;
|
773 |
+
}
|
774 |
+
|
775 |
+
return false;
|
776 |
+
}
|
777 |
+
}
|
778 |
+
|
779 |
+
if (class_exists('PEAR_Error')) {
|
780 |
+
|
781 |
+
class Services_JSON_Error extends PEAR_Error
|
782 |
+
{
|
783 |
+
function Services_JSON_Error($message = 'unknown error', $code = null,
|
784 |
+
$mode = null, $options = null, $userinfo = null)
|
785 |
+
{
|
786 |
+
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
|
787 |
+
}
|
788 |
+
}
|
789 |
+
|
790 |
+
} else {
|
791 |
+
|
792 |
+
/**
|
793 |
+
* @todo Ultimately, this class shall be descended from PEAR_Error
|
794 |
+
*/
|
795 |
+
class Services_JSON_Error
|
796 |
+
{
|
797 |
+
function Services_JSON_Error($message = 'unknown error', $code = null,
|
798 |
+
$mode = null, $options = null, $userinfo = null)
|
799 |
+
{
|
800 |
+
|
801 |
+
}
|
802 |
+
}
|
803 |
+
|
804 |
+
}
|
805 |
+
|
806 |
+
?>
|
807 |
+
|
ZeroClipboard.js
ADDED
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Simple Set Clipboard System
|
2 |
+
// Author: Joseph Huckaby
|
3 |
+
|
4 |
+
var ZeroClipboard = {
|
5 |
+
|
6 |
+
version: "1.0.5",
|
7 |
+
clients: {}, // registered upload clients on page, indexed by id
|
8 |
+
moviePath: 'ZeroClipboard.swf', // URL to movie
|
9 |
+
nextId: 1, // ID of next movie
|
10 |
+
|
11 |
+
$: function(thingy) {
|
12 |
+
// simple DOM lookup utility function
|
13 |
+
if (typeof(thingy) == 'string') thingy = document.getElementById(thingy);
|
14 |
+
if (!thingy.addClass) {
|
15 |
+
// extend element with a few useful methods
|
16 |
+
thingy.hide = function() { this.style.display = 'none'; };
|
17 |
+
thingy.show = function() { this.style.display = ''; };
|
18 |
+
thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
|
19 |
+
thingy.removeClass = function(name) {
|
20 |
+
this.className = this.className.replace( new RegExp("(^|\\s+)" + name + "(\\s+|$)"), "").replace(/^\s+|\s+$/g, '');
|
21 |
+
};
|
22 |
+
thingy.hasClass = function(name) {
|
23 |
+
return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
|
24 |
+
};
|
25 |
+
}
|
26 |
+
return thingy;
|
27 |
+
},
|
28 |
+
|
29 |
+
setMoviePath: function(path) {
|
30 |
+
// set path to ZeroClipboard.swf
|
31 |
+
this.moviePath = path;
|
32 |
+
},
|
33 |
+
|
34 |
+
dispatch: function(id, eventName, args) {
|
35 |
+
// receive event from flash movie, send to client
|
36 |
+
var client = this.clients[id];
|
37 |
+
if (client) {
|
38 |
+
client.receiveEvent(eventName, args);
|
39 |
+
}
|
40 |
+
},
|
41 |
+
|
42 |
+
register: function(id, client) {
|
43 |
+
// register new client to receive events
|
44 |
+
this.clients[id] = client;
|
45 |
+
},
|
46 |
+
|
47 |
+
getDOMObjectPosition: function(obj, stopObj) {
|
48 |
+
// get absolute coordinates for dom element
|
49 |
+
var info = {
|
50 |
+
left: 0,
|
51 |
+
top: 0,
|
52 |
+
width: obj.width ? obj.width : obj.offsetWidth,
|
53 |
+
height: obj.height ? obj.height : obj.offsetHeight
|
54 |
+
};
|
55 |
+
|
56 |
+
while (obj && (obj != stopObj)) {
|
57 |
+
info.left += obj.offsetLeft;
|
58 |
+
info.top += obj.offsetTop;
|
59 |
+
obj = obj.offsetParent;
|
60 |
+
}
|
61 |
+
|
62 |
+
return info;
|
63 |
+
},
|
64 |
+
|
65 |
+
Client: function(elem) {
|
66 |
+
// constructor for new simple upload client
|
67 |
+
this.handlers = {};
|
68 |
+
|
69 |
+
// unique ID
|
70 |
+
this.id = ZeroClipboard.nextId++;
|
71 |
+
this.movieId = 'ZeroClipboardMovie_' + this.id;
|
72 |
+
|
73 |
+
// register client with singleton to receive flash events
|
74 |
+
ZeroClipboard.register(this.id, this);
|
75 |
+
|
76 |
+
// create movie
|
77 |
+
if (elem) this.glue(elem);
|
78 |
+
}
|
79 |
+
};
|
80 |
+
|
81 |
+
ZeroClipboard.Client.prototype = {
|
82 |
+
|
83 |
+
id: 0, // unique ID for us
|
84 |
+
ready: false, // whether movie is ready to receive events or not
|
85 |
+
movie: null, // reference to movie object
|
86 |
+
clipText: '', // text to copy to clipboard
|
87 |
+
handCursorEnabled: true, // whether to show hand cursor, or default pointer cursor
|
88 |
+
cssEffects: true, // enable CSS mouse effects on dom container
|
89 |
+
handlers: null, // user event handlers
|
90 |
+
|
91 |
+
glue: function(elem, appendElem, stylesToAdd) {
|
92 |
+
// glue to DOM element
|
93 |
+
// elem can be ID or actual DOM element object
|
94 |
+
this.domElement = ZeroClipboard.$(elem);
|
95 |
+
|
96 |
+
// float just above object, or zIndex 99 if dom element isn't set
|
97 |
+
var zIndex = 99;
|
98 |
+
if (this.domElement.style.zIndex) {
|
99 |
+
zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
|
100 |
+
}
|
101 |
+
|
102 |
+
if (typeof(appendElem) == 'string') {
|
103 |
+
appendElem = ZeroClipboard.$(appendElem);
|
104 |
+
}
|
105 |
+
else if (typeof(appendElem) == 'undefined') {
|
106 |
+
appendElem = document.getElementsByTagName('body')[0];
|
107 |
+
}
|
108 |
+
|
109 |
+
// find X/Y position of domElement
|
110 |
+
var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem);
|
111 |
+
|
112 |
+
// create floating DIV above element
|
113 |
+
this.div = document.createElement('div');
|
114 |
+
var style = this.div.style;
|
115 |
+
style.position = 'absolute';
|
116 |
+
style.left = '' + box.left + 'px';
|
117 |
+
style.top = '' + box.top + 'px';
|
118 |
+
style.width = '' + box.width + 'px';
|
119 |
+
style.height = '' + box.height + 'px';
|
120 |
+
style.zIndex = zIndex;
|
121 |
+
|
122 |
+
if (typeof(stylesToAdd) == 'object') {
|
123 |
+
for (addedStyle in stylesToAdd) {
|
124 |
+
style[addedStyle] = stylesToAdd[addedStyle];
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
// style.backgroundColor = '#f00'; // debug
|
129 |
+
|
130 |
+
appendElem.appendChild(this.div);
|
131 |
+
|
132 |
+
this.div.innerHTML = this.getHTML( box.width, box.height );
|
133 |
+
},
|
134 |
+
|
135 |
+
getHTML: function(width, height) {
|
136 |
+
// return HTML for movie
|
137 |
+
var html = '';
|
138 |
+
var flashvars = 'id=' + this.id +
|
139 |
+
'&width=' + width +
|
140 |
+
'&height=' + height;
|
141 |
+
|
142 |
+
if (navigator.userAgent.match(/MSIE/)) {
|
143 |
+
// IE gets an OBJECT tag
|
144 |
+
var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
|
145 |
+
html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+protocol+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><param name="wmode" value="transparent"/></object>';
|
146 |
+
}
|
147 |
+
else {
|
148 |
+
// all other browsers get an EMBED tag
|
149 |
+
html += '<embed id="'+this.movieId+'" src="'+ZeroClipboard.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" wmode="transparent" />';
|
150 |
+
}
|
151 |
+
return html;
|
152 |
+
},
|
153 |
+
|
154 |
+
hide: function() {
|
155 |
+
// temporarily hide floater offscreen
|
156 |
+
if (this.div) {
|
157 |
+
this.div.style.left = '-2000px';
|
158 |
+
}
|
159 |
+
},
|
160 |
+
|
161 |
+
show: function() {
|
162 |
+
// show ourselves after a call to hide()
|
163 |
+
this.reposition();
|
164 |
+
},
|
165 |
+
|
166 |
+
destroy: function() {
|
167 |
+
// destroy control and floater
|
168 |
+
if (this.domElement && this.div) {
|
169 |
+
this.hide();
|
170 |
+
this.div.innerHTML = '';
|
171 |
+
|
172 |
+
var body = document.getElementsByTagName('body')[0];
|
173 |
+
try { body.removeChild( this.div ); } catch(e) {;}
|
174 |
+
|
175 |
+
this.domElement = null;
|
176 |
+
this.div = null;
|
177 |
+
}
|
178 |
+
},
|
179 |
+
|
180 |
+
reposition: function(elem) {
|
181 |
+
// reposition our floating div, optionally to new container
|
182 |
+
// warning: container CANNOT change size, only position
|
183 |
+
if (elem) {
|
184 |
+
this.domElement = ZeroClipboard.$(elem);
|
185 |
+
if (!this.domElement) this.hide();
|
186 |
+
}
|
187 |
+
|
188 |
+
if (this.domElement && this.div) {
|
189 |
+
var box = ZeroClipboard.getDOMObjectPosition(this.domElement);
|
190 |
+
var style = this.div.style;
|
191 |
+
style.left = '' + box.left + 'px';
|
192 |
+
style.top = '' + box.top + 'px';
|
193 |
+
}
|
194 |
+
},
|
195 |
+
|
196 |
+
setText: function(newText) {
|
197 |
+
// set text to be copied to clipboard
|
198 |
+
this.clipText = newText;
|
199 |
+
if (this.ready) this.movie.setText(newText);
|
200 |
+
},
|
201 |
+
|
202 |
+
addEventListener: function(eventName, func) {
|
203 |
+
// add user event listener for event
|
204 |
+
// event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel
|
205 |
+
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
|
206 |
+
if (!this.handlers[eventName]) this.handlers[eventName] = [];
|
207 |
+
this.handlers[eventName].push(func);
|
208 |
+
},
|
209 |
+
|
210 |
+
setHandCursor: function(enabled) {
|
211 |
+
// enable hand cursor (true), or default arrow cursor (false)
|
212 |
+
this.handCursorEnabled = enabled;
|
213 |
+
if (this.ready) this.movie.setHandCursor(enabled);
|
214 |
+
},
|
215 |
+
|
216 |
+
setCSSEffects: function(enabled) {
|
217 |
+
// enable or disable CSS effects on DOM container
|
218 |
+
this.cssEffects = !!enabled;
|
219 |
+
},
|
220 |
+
|
221 |
+
receiveEvent: function(eventName, args) {
|
222 |
+
// receive event from flash
|
223 |
+
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
|
224 |
+
|
225 |
+
// special behavior for certain events
|
226 |
+
switch (eventName) {
|
227 |
+
case 'load':
|
228 |
+
// movie claims it is ready, but in IE this isn't always the case...
|
229 |
+
// bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function
|
230 |
+
this.movie = document.getElementById(this.movieId);
|
231 |
+
if (!this.movie) {
|
232 |
+
var self = this;
|
233 |
+
setTimeout( function() { self.receiveEvent('load', null); }, 1 );
|
234 |
+
return;
|
235 |
+
}
|
236 |
+
|
237 |
+
// firefox on pc needs a "kick" in order to set these in certain cases
|
238 |
+
if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
|
239 |
+
var self = this;
|
240 |
+
setTimeout( function() { self.receiveEvent('load', null); }, 100 );
|
241 |
+
this.ready = true;
|
242 |
+
return;
|
243 |
+
}
|
244 |
+
|
245 |
+
this.ready = true;
|
246 |
+
this.movie.setText( this.clipText );
|
247 |
+
this.movie.setHandCursor( this.handCursorEnabled );
|
248 |
+
break;
|
249 |
+
|
250 |
+
case 'mouseover':
|
251 |
+
if (this.domElement && this.cssEffects) {
|
252 |
+
this.domElement.addClass('hover');
|
253 |
+
if (this.recoverActive) this.domElement.addClass('active');
|
254 |
+
}
|
255 |
+
break;
|
256 |
+
|
257 |
+
case 'mouseout':
|
258 |
+
if (this.domElement && this.cssEffects) {
|
259 |
+
this.recoverActive = false;
|
260 |
+
if (this.domElement.hasClass('active')) {
|
261 |
+
this.domElement.removeClass('active');
|
262 |
+
this.recoverActive = true;
|
263 |
+
}
|
264 |
+
this.domElement.removeClass('hover');
|
265 |
+
}
|
266 |
+
break;
|
267 |
+
|
268 |
+
case 'mousedown':
|
269 |
+
if (this.domElement && this.cssEffects) {
|
270 |
+
this.domElement.addClass('active');
|
271 |
+
}
|
272 |
+
break;
|
273 |
+
|
274 |
+
case 'mouseup':
|
275 |
+
if (this.domElement && this.cssEffects) {
|
276 |
+
this.domElement.removeClass('active');
|
277 |
+
this.recoverActive = false;
|
278 |
+
}
|
279 |
+
break;
|
280 |
+
} // switch eventName
|
281 |
+
|
282 |
+
if (this.handlers[eventName]) {
|
283 |
+
for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
|
284 |
+
var func = this.handlers[eventName][idx];
|
285 |
+
|
286 |
+
if (typeof(func) == 'function') {
|
287 |
+
// actual function reference
|
288 |
+
func(this, args);
|
289 |
+
}
|
290 |
+
else if ((typeof(func) == 'object') && (func.length == 2)) {
|
291 |
+
// PHP style object + method, i.e. [myObject, 'myMethod']
|
292 |
+
func[0][ func[1] ](this, args);
|
293 |
+
}
|
294 |
+
else if (typeof(func) == 'string') {
|
295 |
+
// name of function
|
296 |
+
window[func](this, args);
|
297 |
+
}
|
298 |
+
} // foreach event handler defined
|
299 |
+
} // user defined handler for event
|
300 |
+
}
|
301 |
+
|
302 |
+
};
|
ZeroClipboard.swf
ADDED
Binary file
|
accountconfig.php
ADDED
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Settings page in the admin panel
|
4 |
+
function zopim_account_config() {
|
5 |
+
global $usernameToCodeURL, $languagesURL, $current_user;
|
6 |
+
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="wrap">
|
10 |
+
|
11 |
+
<?php
|
12 |
+
|
13 |
+
if ($_GET["action"]=="deactivate") {
|
14 |
+
update_option('zopimSalt', "");
|
15 |
+
update_option('zopimCode', "zopim");
|
16 |
+
}
|
17 |
+
|
18 |
+
$message = "";
|
19 |
+
if ($_POST["action"]=="login") {
|
20 |
+
if ($_POST["zopimUseSSL"] == "") {
|
21 |
+
$_POST["zopimUseSSL"] = "nossl";
|
22 |
+
}
|
23 |
+
update_option('zopimUseSSL', $_POST["zopimUseSSL"]);
|
24 |
+
|
25 |
+
if ($_POST["zopimPassword"] != "password") {
|
26 |
+
|
27 |
+
$logindata = array("email" => $_POST["zopimUsername"], "password" => $_POST["zopimPassword"]);
|
28 |
+
$loginresult = json_to_array(do_post_request(ZOPIM_LOGIN_URL, $logindata));
|
29 |
+
|
30 |
+
if (isset($loginresult->error)) {
|
31 |
+
$error["login"] = "<b>Could not log in to Zopim. Please check your login details. If problem persists, try connecting without SSL enabled.</b>";
|
32 |
+
$gotologin = 1;
|
33 |
+
update_option('zopimSalt', "wronglogin");
|
34 |
+
} else {
|
35 |
+
update_option('zopimUsername', $_POST["zopimUsername"]);
|
36 |
+
if (isset($loginresult->salt)) {
|
37 |
+
update_option('zopimSalt', $loginresult->salt);
|
38 |
+
} else {
|
39 |
+
update_option('zopimSalt', "");
|
40 |
+
}
|
41 |
+
$account = getAccountDetails(get_option('zopimSalt'));
|
42 |
+
|
43 |
+
if (isset($account)) {
|
44 |
+
update_option('zopimCode', $account->account_key);
|
45 |
+
|
46 |
+
if (get_option('zopimGreetings') == "") {
|
47 |
+
$jsongreetings = to_json($account->settings->greetings);
|
48 |
+
update_option('zopimGreetings', $jsongreetings);
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
} else if ($_POST["action"]=="signup") {
|
54 |
+
|
55 |
+
if ($_POST["zopimUseSSL"] == "") {
|
56 |
+
$_POST["zopimUseSSL"] = "nossl";
|
57 |
+
}
|
58 |
+
update_option('zopimUseSSL', $_POST["zopimUseSSL"]);
|
59 |
+
|
60 |
+
$createdata = array(
|
61 |
+
"email" => $_POST["zopimnewemail"],
|
62 |
+
"first_name" => $_POST["zopimfirstname"],
|
63 |
+
"last_name" => $_POST["zopimlastname"],
|
64 |
+
"display_name" => $_POST["zopimfirstname"]." ".$_POST["zopimlastname"],
|
65 |
+
"eref" => $_POST["zopimeref"],
|
66 |
+
"source" => "wordpress",
|
67 |
+
"recaptcha_challenge_field" => $_POST["recaptcha_challenge_field"],
|
68 |
+
"recaptcha_response_field" => $_POST["recaptcha_response_field"]
|
69 |
+
);
|
70 |
+
|
71 |
+
$signupresult = json_to_array(do_post_request(ZOPIM_SIGNUP_URL, $createdata));
|
72 |
+
if (isset($signupresult->error)) {
|
73 |
+
$message = "<div style='color:#c33;'>Error during activation: <b>".$signupresult->error."</b>. Please try again.</div>";
|
74 |
+
} else {
|
75 |
+
$message = "<b>Thank you for signing up. Please check your mail for your password to complete the process. </b>";
|
76 |
+
$gotologin = 1;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
if (get_option('zopimCode') != "" && get_option('zopimCode') != "zopim") {
|
81 |
+
|
82 |
+
$accountDetails = getAccountDetails(get_option('zopimSalt'));
|
83 |
+
|
84 |
+
if (!isset($accountDetails) || isset($accountDetails->error)) {
|
85 |
+
$gotologin = 1;
|
86 |
+
$error["auth"] = '
|
87 |
+
<div class="metabox-holder">
|
88 |
+
<div class="postbox">
|
89 |
+
<h3 class="hndle"><span>Account no longer linked!</span></h3>
|
90 |
+
<div style="padding:10px;line-height:17px;">
|
91 |
+
We could not verify your Zopim account. Please check your password and try again.
|
92 |
+
</div>
|
93 |
+
</div>
|
94 |
+
</div>'
|
95 |
+
;
|
96 |
+
} else {
|
97 |
+
$authenticated = "ok";
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
if ($authenticated == "ok") {
|
102 |
+
if ($accountDetails->package_id=="trial") {
|
103 |
+
$accountDetails->package_id = "Free Lite Package + 14 Days Full-features";
|
104 |
+
} else {
|
105 |
+
$accountDetails->package_id .= " Package";
|
106 |
+
}
|
107 |
+
?>
|
108 |
+
<div id="icon-options-general" class="icon32"><br/></div><h2>Set up your Zopim Account</h2>
|
109 |
+
<br/>
|
110 |
+
<div style="background:#FFFEEB;padding:25px;border:1px solid #eee;">
|
111 |
+
<span style="float:right;"><a href="admin.php?page=zopim_account_config&action=deactivate">Deactivate</a></span>
|
112 |
+
Currently Activated Account → <b><?php echo get_option('zopimUsername'); ?></b> <div style="display:inline-block;background:#444;color:#fff;font-size:10px;text-transform:uppercase;padding:3px 8px;-moz-border-radius:5px;-webkit-border-radius:5px;"><?php echo ucwords($accountDetails->package_id); ?></div>
|
113 |
+
<br><p><br>You can <a href="admin.php?page=zopim_customize_widget">customize</a> the chat widget, <a href="admin.php?page=zopim_instant_messaging">relay messages</a> to your favourite IM client, or <a href="admin.php?page=zopim_dashboard">launch the dashboard</a> for advanced features.
|
114 |
+
</div>
|
115 |
+
|
116 |
+
<?php } else { ?>
|
117 |
+
<div id="icon-options-general" class="icon32"><br/></div><h2>Set up your Zopim Account</h2>
|
118 |
+
<?php if ($error && $error["auth"]) {
|
119 |
+
echo $error["auth"];
|
120 |
+
} else if ($message == "") { ?>
|
121 |
+
Congratulations on successfully installing the Zopim WordPress plugin! Activate an account to start using Zopim Live Chat.<br>
|
122 |
+
<br>
|
123 |
+
<?php } else { echo $message; } ?>
|
124 |
+
|
125 |
+
<script type="text/javascript">
|
126 |
+
|
127 |
+
function showSignup(whichform) {
|
128 |
+
if (whichform == '1') {
|
129 |
+
document.getElementById('existingform').style.display = "none";
|
130 |
+
document.getElementById('signupform').style.display = "block";
|
131 |
+
document.getElementById('formtoshow_signup').checked = 'true';
|
132 |
+
} else {
|
133 |
+
document.getElementById('signupform').style.display = "none";
|
134 |
+
document.getElementById('existingform').style.display = "block";
|
135 |
+
document.getElementById('formtoshow_existing').checked = 'true';
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
|
140 |
+
</script>
|
141 |
+
<div class="metabox-holder">
|
142 |
+
<div class="postbox">
|
143 |
+
<h3 class="hndle"><span>Select a Setup</span></h3>
|
144 |
+
<div style="padding:10px;">
|
145 |
+
<div onclick="javascript: showSignup(1)"><input type="radio" name="formtoshow" id="formtoshow_signup" value="yes" onchange="javascript: showSignup(1)"/> Give me a new account — <i>absolutely free!</i></div>
|
146 |
+
<br/>
|
147 |
+
<div onclick="javascript: showSignup(0)"><input type="radio" name="formtoshow" id="formtoshow_existing" value="no" onchange="javascript: showSignup(0)"/> I already have a Zopim account</div>
|
148 |
+
</div>
|
149 |
+
</div>
|
150 |
+
</div>
|
151 |
+
|
152 |
+
|
153 |
+
<div id="existingform" style="display: none">
|
154 |
+
<div class="metabox-holder">
|
155 |
+
<div class="postbox">
|
156 |
+
<h3 class="hndle"><span>Link up to your Zopim account</span></h3>
|
157 |
+
<div style="padding:10px;">
|
158 |
+
<?php if (isset($error) && isset($error["login"])) { echo $error["login"]; } ?>
|
159 |
+
<form method="post" action="admin.php?page=zopim_account_config">
|
160 |
+
<input type="hidden" name="action" value="login">
|
161 |
+
<table class="form-table">
|
162 |
+
|
163 |
+
<tr valign="top">
|
164 |
+
<th scope="row">Zopim Username (E-mail)</th>
|
165 |
+
<td><input type="text" name="zopimUsername" value="<?php echo get_option('zopimUsername'); ?>" /></td>
|
166 |
+
</tr>
|
167 |
+
|
168 |
+
<tr valign="top">
|
169 |
+
<th scope="row">Zopim Pasword</th>
|
170 |
+
<td><input type="password" name="zopimPassword" value="<?php if (get_option('zopimSalt') != "") { echo "password"; }; ?>" /></td>
|
171 |
+
</tr>
|
172 |
+
|
173 |
+
<tr valign="center">
|
174 |
+
<th scope="row">Use SSL</th>
|
175 |
+
<td><input type="checkbox" name="zopimUseSSL" value="zopimUseSSL" <?php if (get_option('zopimUseSSL') == "zopimUseSSL") { echo "checked='checked'"; } ?> /> uncheck this if you are unable to login</td>
|
176 |
+
</tr>
|
177 |
+
</table>
|
178 |
+
<br/>
|
179 |
+
The Zopim chat bar will displayed on your blog once your account is linked up.
|
180 |
+
<br/><br/>
|
181 |
+
<p class="submit">
|
182 |
+
<input type="submit" class="button-primary" value="<?php _e('Link Up') ?>" />
|
183 |
+
</p>
|
184 |
+
|
185 |
+
</form>
|
186 |
+
|
187 |
+
</div>
|
188 |
+
</div>
|
189 |
+
</div>
|
190 |
+
</div>
|
191 |
+
|
192 |
+
<div id="signupform" style="display: none">
|
193 |
+
<div class="metabox-holder">
|
194 |
+
<div class="postbox">
|
195 |
+
<h3 class="hndle"><span>Activate your free Zopim Account</span></h3>
|
196 |
+
<div style="padding:10px;">
|
197 |
+
<form method="post" action="admin.php?page=zopim_account_config" onSubmit="return checkSignUp();">
|
198 |
+
<input type="hidden" name="action" value="signup">
|
199 |
+
<div id="signuperror"></div>
|
200 |
+
<table class="form-table">
|
201 |
+
|
202 |
+
<tr valign="top">
|
203 |
+
<th scope="row">First Name</th>
|
204 |
+
<td><input id="zopimfirstname" type="text" name="zopimfirstname" value="<?php if (isset($_POST["zopimfirstname"])) { echo $_POST["zopimfirstname"]; } else { echo $current_user->data->first_name; } ?>"></td>
|
205 |
+
</tr>
|
206 |
+
|
207 |
+
<tr valign="top">
|
208 |
+
<th scope="row">Last Name</th>
|
209 |
+
<td><input id="zopimlastname" type="text" name="zopimlastname" value="<?php if (isset($_POST["zopimlastname"])) { echo $_POST["zopimnlastname"]; } else { echo $current_user->data->last_name; } ?>"></td>
|
210 |
+
</tr>
|
211 |
+
|
212 |
+
<tr valign="top">
|
213 |
+
<th scope="row">E-mail</th>
|
214 |
+
<td><input id="zopimnewemail" type="text" name="zopimnewemail" value="<?php if (isset($_POST["zopimnewemail"])) { echo $_POST["zopimnewemail"]; } else { echo $current_user->data->user_email; } ?>"></td>
|
215 |
+
</tr>
|
216 |
+
|
217 |
+
<tr valign="top">
|
218 |
+
<th scope="row">Use SSL</th>
|
219 |
+
<td><input type="checkbox" name="zopimUseSSL" value="zopimUseSSL" checked="checked" } ?> uncheck this if you are unable to login</td>
|
220 |
+
</tr>
|
221 |
+
|
222 |
+
<tr valign="top">
|
223 |
+
<th scope="row">Verification</th>
|
224 |
+
<td>
|
225 |
+
<script type="text/javascript" src="https://api-secure.recaptcha.net/challenge?k=6Lfr8AQAAAAAAC7MpRXM2hgLfyss_KKjvcJ_JFIk">
|
226 |
+
</script>
|
227 |
+
<noscript>
|
228 |
+
<iframe src="https://api-secure.recaptcha.net/noscript?k=6Lfr8AQAAAAAAC7MpRXM2hgLfyss_KKjvcJ_JFIk"
|
229 |
+
height="300" width="500" frameborder="0"></iframe><br>
|
230 |
+
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
|
231 |
+
</textarea>
|
232 |
+
<input type="hidden" name="recaptcha_response_field"
|
233 |
+
value="manual_challenge">
|
234 |
+
</noscript>
|
235 |
+
|
236 |
+
</td>
|
237 |
+
</tr>
|
238 |
+
<!--
|
239 |
+
<tr valign="top">
|
240 |
+
<th scope="row">Referral E-mail or ID</th>
|
241 |
+
<td><input id="zopimeref" type="text" name="zopimeref" value="<?php if (isset($_POST)) { echo $_POST["zopimeref"]; } ?>"></td>
|
242 |
+
</tr>
|
243 |
+
-->
|
244 |
+
</table>
|
245 |
+
<br/>
|
246 |
+
The Zopim chat bar will displayed on your blog once your account is activated.<br/><br/>
|
247 |
+
<input id="zopimagree" type="checkbox" name="zopimagree" value=""> I agree to Zopim's <a href="http://www.zopim.com/termsnconditions" target="_blank">Terms of Service</a> & <a href="http://www.zopim.com/privacypolicy" target="_blank">Privacy Policy</a>.
|
248 |
+
<br/><br/>
|
249 |
+
<p class="submit">
|
250 |
+
<input type="submit" class="button-primary" value="<?php _e('Activate Now') ?>" />
|
251 |
+
</p>
|
252 |
+
</form>
|
253 |
+
</div>
|
254 |
+
</div>
|
255 |
+
</div>
|
256 |
+
|
257 |
+
</div>
|
258 |
+
</div>
|
259 |
+
|
260 |
+
<script type="text/javascript">
|
261 |
+
<?php
|
262 |
+
if ($authenticated != "ok" && !isset($gotologin) && get_option("zopimCode")=="zopim") {
|
263 |
+
echo "showSignup(1); ";
|
264 |
+
} else {
|
265 |
+
echo "showSignup(0); ";
|
266 |
+
}
|
267 |
+
|
268 |
+
?>
|
269 |
+
|
270 |
+
function checkSignUp() {
|
271 |
+
|
272 |
+
var message = 'Oops! ';
|
273 |
+
if (document.getElementById('zopimfirstname').value == '') {
|
274 |
+
|
275 |
+
message = message + 'First name is required. ';
|
276 |
+
}
|
277 |
+
if (document.getElementById('zopimlastname').value == '') {
|
278 |
+
|
279 |
+
message = message + 'Last name is required. ';
|
280 |
+
}
|
281 |
+
if (document.getElementById('zopimagree').checked == '') {
|
282 |
+
|
283 |
+
message = message + 'You must agree to our Terms of Service to continue. ';
|
284 |
+
}
|
285 |
+
|
286 |
+
if (message != 'Oops! ') {
|
287 |
+
|
288 |
+
document.getElementById('signuperror').innerHTML = message;
|
289 |
+
return false;
|
290 |
+
}
|
291 |
+
|
292 |
+
return true;
|
293 |
+
}
|
294 |
+
</script>
|
295 |
+
|
296 |
+
<?php } } ?>
|
customizewidget.php
ADDED
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Zopim Customize Widget Page
|
4 |
+
|
5 |
+
function zopim_customize_widget() {
|
6 |
+
global $current_user;
|
7 |
+
$ul = $current_user->data->first_name;
|
8 |
+
$useremail = $current_user->data->user_email;
|
9 |
+
$greetings = json_to_array(get_option('zopimGreetings'));
|
10 |
+
|
11 |
+
$message = "";
|
12 |
+
|
13 |
+
|
14 |
+
if (count($_POST) > 0) {
|
15 |
+
update_option('zopimLang', $_POST["zopimLang"]);
|
16 |
+
update_option('zopimPosition', $_POST["zopimPosition"]);
|
17 |
+
|
18 |
+
update_checkbox("zopimGetVisitorInfo");
|
19 |
+
update_checkbox("zopimHideOnOffline");
|
20 |
+
update_checkbox("zopimBubbleEnable");
|
21 |
+
|
22 |
+
$greetings->online->window = stripslashes($_POST["zopimOnlineLong"]);
|
23 |
+
$greetings->online->bar = stripslashes($_POST["zopimOnlineShort"]);
|
24 |
+
$greetings->away->window = stripslashes($_POST["zopimAwayLong"]);
|
25 |
+
$greetings->away->bar = stripslashes($_POST["zopimAwayShort"]);
|
26 |
+
$greetings->offline->window = stripslashes($_POST["zopimOfflineLong"]);
|
27 |
+
$greetings->offline->bar = stripslashes($_POST["zopimOfflineShort"]);
|
28 |
+
|
29 |
+
update_option('zopimGreetings', to_json($greetings));
|
30 |
+
update_option('zopimColor', $_POST["zopimColor"]);
|
31 |
+
update_option('zopimTheme', $_POST["zopimTheme"]);
|
32 |
+
update_option('zopimBubbleTitle', stripslashes($_POST["zopimBubbleTitle"]));
|
33 |
+
update_option('zopimBubbleText', stripslashes($_POST["zopimBubbleText"]));
|
34 |
+
$message = "<b>Changes saved!</b><br>";
|
35 |
+
}
|
36 |
+
|
37 |
+
zopimme();
|
38 |
+
|
39 |
+
|
40 |
+
$accountDetails = getAccountDetails(get_option('zopimSalt'));
|
41 |
+
|
42 |
+
if (get_option('zopimCode')=="zopim") {
|
43 |
+
|
44 |
+
$message = '<div class="metabox-holder">
|
45 |
+
<div class="postbox">
|
46 |
+
<h3 class="hndle"><span>Customizing in Demo Mode</span></h3>
|
47 |
+
<div style="padding:10px;line-height:17px;">
|
48 |
+
Currently customizing in demo mode. Messages in this widget will go to Zopim staff. The chat widget will not appear on your site until you <a href="admin.php?page=zopim_account_config">activate / link up an account</a>. <br>
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
</div>';
|
52 |
+
$accountDetails->widget_customization_enabled = 1;
|
53 |
+
$accountDetails->color_customization_enabled = 1;
|
54 |
+
} else if (isset($accountDetails->error)) {
|
55 |
+
$message = '
|
56 |
+
<div class="metabox-holder">
|
57 |
+
<div class="postbox">
|
58 |
+
<h3 class="hndle"><span>Account no longer linked!</span></h3>
|
59 |
+
<div style="padding:10px;line-height:17px;">
|
60 |
+
We could not connect to your Zopim account. As a result, this customization page is running in demo mode.<br> Please <a href="admin.php?page=zopim_account_config">check your password in account setup</a> and try again.
|
61 |
+
</div>
|
62 |
+
</div>
|
63 |
+
</div>';
|
64 |
+
} else {
|
65 |
+
$message .= "Click 'Save Changes' when you're done. Happy customizing!";
|
66 |
+
}
|
67 |
+
|
68 |
+
// unset($accountDetails->widget_customization_enabled);
|
69 |
+
// unset($accountDetails->color_customization_enabled);
|
70 |
+
?>
|
71 |
+
|
72 |
+
<script type="text/javascript">
|
73 |
+
|
74 |
+
function updateWidget() {
|
75 |
+
|
76 |
+
var lang = document.getElementById('zopimLang').options[ document.getElementById('zopimLang').options.selectedIndex ].value;
|
77 |
+
$zopim.livechat.setLanguage(lang);
|
78 |
+
|
79 |
+
if (document.getElementById("zopimGetVisitorInfo").checked) {
|
80 |
+
$zopim.livechat.setName('<?php echo $ul; ?>');
|
81 |
+
$zopim.livechat.setEmail('<?php echo $useremail; ?>');
|
82 |
+
} else {
|
83 |
+
$zopim.livechat.setName('Visitor');
|
84 |
+
$zopim.livechat.setEmail('');
|
85 |
+
}
|
86 |
+
|
87 |
+
if (document.getElementById("zopimHideOnOffline").checked) {
|
88 |
+
$zopim.livechat.button.setHideWhenOffline(true);
|
89 |
+
} else {
|
90 |
+
$zopim.livechat.button.setHideWhenOffline(false);
|
91 |
+
}
|
92 |
+
|
93 |
+
$zopim.livechat.window.setColor(document.getElementById("zopimColor").value);
|
94 |
+
$zopim.livechat.window.setTheme(document.getElementById("zopimTheme").value);
|
95 |
+
|
96 |
+
$zopim.livechat.bubble.setTitle(document.getElementById("zopimBubbleTitle").value);
|
97 |
+
$zopim.livechat.bubble.setText(document.getElementById("zopimBubbleText").value);
|
98 |
+
|
99 |
+
$zopim.livechat.setGreetings({
|
100 |
+
'online': [document.getElementById("zopimOnlineShort").value, document.getElementById("zopimOnlineLong").value],
|
101 |
+
'offline': [document.getElementById("zopimOfflineShort").value, document.getElementById("zopimOfflineLong").value],
|
102 |
+
'away': [document.getElementById("zopimAwayShort").value, document.getElementById("zopimAwayLong").value]
|
103 |
+
});
|
104 |
+
}
|
105 |
+
|
106 |
+
function updatePosition() {
|
107 |
+
|
108 |
+
var position = document.getElementById('zopimPosition').options[ document.getElementById('zopimPosition').options.selectedIndex ].value;
|
109 |
+
$zopim.livechat.button.setPosition(position);
|
110 |
+
}
|
111 |
+
|
112 |
+
function updateBubbleStatus() {
|
113 |
+
if (document.getElementById("zopimBubbleEnable").checked) {
|
114 |
+
$zopim.livechat.bubble.show();
|
115 |
+
$zopim.livechat.bubble.reset();
|
116 |
+
} else {
|
117 |
+
$zopim.livechat.bubble.hide();
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
var timer;
|
122 |
+
function updateSoon() {
|
123 |
+
|
124 |
+
clearTimeout(timer);
|
125 |
+
timer = setTimeout("updateWidget()", 300);
|
126 |
+
}
|
127 |
+
</script>
|
128 |
+
|
129 |
+
<style type="text/css">
|
130 |
+
.smallExplanation {
|
131 |
+
background:#FAFAFA;
|
132 |
+
color:#667788;
|
133 |
+
font-size:8pt;
|
134 |
+
line-height:13px;
|
135 |
+
margin:4px 0 0 0;
|
136 |
+
padding:8px;
|
137 |
+
display: inline-block;
|
138 |
+
}
|
139 |
+
.inputtextshort {
|
140 |
+
width:200px;
|
141 |
+
}
|
142 |
+
.inputtext {
|
143 |
+
width:450px;
|
144 |
+
}
|
145 |
+
.secthead {
|
146 |
+
border-bottom:1px solid #EEEEEE;
|
147 |
+
color:#8899AA;
|
148 |
+
font-size:13px;
|
149 |
+
line-height:21px;
|
150 |
+
}
|
151 |
+
.sethead {
|
152 |
+
width:200px;
|
153 |
+
}
|
154 |
+
.swatch {
|
155 |
+
float: left;
|
156 |
+
width: 15px
|
157 |
+
}
|
158 |
+
.swatch:hover {
|
159 |
+
background-image:url(http://www.zopim.com/static/images/colorselectbg.gif);
|
160 |
+
cursor:pointer;
|
161 |
+
}
|
162 |
+
.sorry {
|
163 |
+
color:#c33;
|
164 |
+
}
|
165 |
+
</style>
|
166 |
+
|
167 |
+
<div class="wrap">
|
168 |
+
<div id="icon-themes" class="icon32"><br/></div><h2>Customize your widget</h2>
|
169 |
+
|
170 |
+
<?php echo $message; ?>
|
171 |
+
<form method="post" action="admin.php?page=zopim_customize_widget">
|
172 |
+
<div class="metabox-holder">
|
173 |
+
<div class="postbox">
|
174 |
+
<h3 class="hndle"><span>General Settings</span></h3>
|
175 |
+
<div style="padding:10px;">
|
176 |
+
<table class="form-table">
|
177 |
+
<tr valign="top">
|
178 |
+
<th scope="row" class="sethead">Language</th>
|
179 |
+
<td>
|
180 |
+
|
181 |
+
<select name="zopimLang" id="zopimLang" onchange="updateWidget()">
|
182 |
+
<?php
|
183 |
+
|
184 |
+
$languages = get_languages();
|
185 |
+
echo generate_options($languages, get_option('zopimLang'));
|
186 |
+
?>
|
187 |
+
</select>
|
188 |
+
</td>
|
189 |
+
</tr>
|
190 |
+
<tr valign="top" style="display:none;">
|
191 |
+
<th scope="row">Use Logged in Username / Email</th>
|
192 |
+
<td><input onchange="updateWidget()" type="checkbox" id="zopimGetVisitorInfo" name="zopimGetVisitorInfo" value="zopimGetVisitorInfo" <?php if (get_option('zopimGetVisitorInfo')!="disabled") { echo "checked='checked'"; } ?> /></td>
|
193 |
+
</tr>
|
194 |
+
<tr valign="top">
|
195 |
+
<th scope="row" class="sethead">Position</th>
|
196 |
+
<td>
|
197 |
+
|
198 |
+
<select name="zopimPosition" id="zopimPosition" onchange="updatePosition()">
|
199 |
+
<?php
|
200 |
+
$positions = array("br" => "Bottom Right", "bl" => "Bottom Left", "mr" => "Right", "ml" => "Left");
|
201 |
+
echo generate_options($positions, get_option('zopimPosition'));
|
202 |
+
?>
|
203 |
+
</select>
|
204 |
+
</td>
|
205 |
+
</tr>
|
206 |
+
|
207 |
+
<tr valign="top">
|
208 |
+
<th scope="row">Hide chat bar when offline<br>
|
209 |
+
<!-- <div class="smallExplanation">Hide the chat bar when no agents are available to answer questions. This prevents visitors from sending you offline messages. </div> -->
|
210 |
+
</th>
|
211 |
+
<td><input onchange="updateWidget()" type="checkbox" id="zopimHideOnOffline" name="zopimHideOnOffline" value="zopimHideOnOffline" <?php if (get_option('zopimHideOnOffline') && get_option('zopimHideOnOffline')!="disabled") { echo "checked='checked'"; } ?> /> This prevents visitors from sending you offline messages</td>
|
212 |
+
</tr>
|
213 |
+
</table>
|
214 |
+
</div>
|
215 |
+
</div>
|
216 |
+
</div>
|
217 |
+
<div class="metabox-holder">
|
218 |
+
<div class="postbox">
|
219 |
+
<h3 class="hndle"><span>Color & Theme Settings</span></h3>
|
220 |
+
<div style="padding:10px;">
|
221 |
+
Settings reflect instantly on your preview widget. Try it out!<br/>
|
222 |
+
<table class="form-table" style="width: 700px">
|
223 |
+
<tr valign="top">
|
224 |
+
<td colspan="2">
|
225 |
+
<input type="hidden" id="zopimColor" name="zopimColor" value="<?php echo get_option('zopimColor'); ?>">
|
226 |
+
<?php
|
227 |
+
|
228 |
+
if ($accountDetails->color_customization_enabled == 1) {
|
229 |
+
echo "<div style='display:inline-block;border:11px solid #888;background:#888;color:#fee;'>";
|
230 |
+
$colors = file_get_contents(ZOPIM_COLORS_LIST);
|
231 |
+
$colors = explode("\n", $colors);
|
232 |
+
|
233 |
+
$i=0;
|
234 |
+
foreach ($colors as $color) {
|
235 |
+
echo "<div class='swatch' style='background-color: $color;' onclick=\"document.getElementById('zopimColor').value='$color'; updateWidget();\"> </div>";
|
236 |
+
if (++$i%40==0) {
|
237 |
+
echo "<br>";
|
238 |
+
}
|
239 |
+
}
|
240 |
+
echo "<br><a href=# style='color:#ff8' onclick=\"document.getElementById('zopimColor').value=''; updateWidget();\">Restore default color</a></div>";
|
241 |
+
} else {
|
242 |
+
echo "<div class='sorry'>Sorry, your plan does not allow for color customization. Please upgrade to enjoy choice of color!</div>";
|
243 |
+
}
|
244 |
+
?>
|
245 |
+
</td>
|
246 |
+
</tr>
|
247 |
+
<tr valign="top">
|
248 |
+
<th scope="row" class="sethead">Select A Theme</th>
|
249 |
+
<td style="width: 400px"><div align="left">
|
250 |
+
<?php
|
251 |
+
|
252 |
+
if ($accountDetails->widget_customization_enabled == 1) {
|
253 |
+
echo '<select name="zopimTheme" id="zopimTheme" onchange="updateWidget()">';
|
254 |
+
$themes = file_get_contents(ZOPIM_THEMES_LIST);
|
255 |
+
$themes = valuekeys(explode("\n", $themes));
|
256 |
+
ksort($themes);
|
257 |
+
|
258 |
+
echo generate_options($themes, get_option('zopimTheme'));
|
259 |
+
echo "</select> <a href='#' onclick='\$zopim.livechat.window.toggle();return false;'>View the Chat Panel</a> for changes";
|
260 |
+
} else {
|
261 |
+
echo "<div class='sorry'>Sorry, your plan does not allow for theme customization. Please upgrade to enjoy choice of themes!</div>";
|
262 |
+
echo '<input type=hidden value="" name="zopimTheme" id="zopimTheme">';
|
263 |
+
}
|
264 |
+
?>
|
265 |
+
</td>
|
266 |
+
</tr>
|
267 |
+
</table>
|
268 |
+
</div>
|
269 |
+
</div>
|
270 |
+
</div>
|
271 |
+
|
272 |
+
<div class="metabox-holder">
|
273 |
+
<div class="postbox">
|
274 |
+
<h3 class="hndle"><span>Help Bubble Settings</span></h3>
|
275 |
+
<div style="padding:10px;">
|
276 |
+
<table class="form-table">
|
277 |
+
|
278 |
+
<tr valign="top">
|
279 |
+
<th scope="row">Display Help Bubble<br>
|
280 |
+
</th>
|
281 |
+
<td><input onchange="updateBubbleStatus()" type="checkbox" id="zopimBubbleEnable" name="zopimBubbleEnable" value="zopimBubbleEnable" <?php if (get_option('zopimBubbleEnable')!="disabled") { echo "checked='checked'"; } ?> /> Use this pretty chat bubble to grab attention!</td>
|
282 |
+
</tr>
|
283 |
+
<tr valign="top">
|
284 |
+
<th scope="row" class="sethead">Help Bubble Title
|
285 |
+
<!--<div class="smallExplanation">Entice your visitors with this friendly chat bubble title!</div>--></th>
|
286 |
+
<td>
|
287 |
+
|
288 |
+
<input class="inputtextshort" name="zopimBubbleTitle" id="zopimBubbleTitle" onKeyup="updateSoon()" value="<?php echo get_option('zopimBubbleTitle'); ?>"> <a href="#" onclick="updateBubbleStatus();">Refresh</a>
|
289 |
+
</td>
|
290 |
+
</tr>
|
291 |
+
|
292 |
+
<tr valign="top">
|
293 |
+
<th scope="row" class="sethead">Help Bubble Message
|
294 |
+
<!--<div class="smallExplanation">Welcome your visitors and encourage them to talk with you</div>--></th>
|
295 |
+
<td>
|
296 |
+
|
297 |
+
<input class="inputtext" name="zopimBubbleText" id="zopimBubbleText" onKeyup="updateSoon()" value="<?php echo get_option('zopimBubbleText'); ?>">
|
298 |
+
</td>
|
299 |
+
</tr>
|
300 |
+
|
301 |
+
|
302 |
+
</table>
|
303 |
+
</div>
|
304 |
+
</div>
|
305 |
+
</div>
|
306 |
+
|
307 |
+
<div class="metabox-holder">
|
308 |
+
<div class="postbox">
|
309 |
+
<h3 class="hndle"><span>Greeting Message Settings</span></h3>
|
310 |
+
<div style="padding:10px;">
|
311 |
+
<table class="form-table">
|
312 |
+
<tr><td colspan="2"><div class="secthead">Message Shown on Chat Bar</div></td></tr>
|
313 |
+
<tr valign="top">
|
314 |
+
<th scope="row" class="sethead">Online</th>
|
315 |
+
<td>
|
316 |
+
<input class="inputtextshort" name="zopimOnlineShort" id="zopimOnlineShort" onKeyup="updateSoon)" value="<?php echo $greetings->online->bar; ?>">
|
317 |
+
</td>
|
318 |
+
</tr>
|
319 |
+
|
320 |
+
<tr valign="top">
|
321 |
+
<th scope="row" class="sethead">Away</th>
|
322 |
+
<td>
|
323 |
+
<input class="inputtextshort" name="zopimAwayShort" id="zopimAwayShort" onKeyup="updateSoon()" value="<?php echo $greetings->away->bar; ?>">
|
324 |
+
</td>
|
325 |
+
</tr>
|
326 |
+
|
327 |
+
<tr valign="top">
|
328 |
+
<th scope="row" class="sethead">Offline</th>
|
329 |
+
<td>
|
330 |
+
<input class="inputtextshort" name="zopimOfflineShort" id="zopimOfflineShort" onKeyup="updateSoon()" value="<?php echo $greetings->offline->bar; ?>">
|
331 |
+
</td>
|
332 |
+
</tr>
|
333 |
+
|
334 |
+
|
335 |
+
<tr><td colspan="2"><div class="secthead">Message Shown on Chat Panel</div></td></tr>
|
336 |
+
<tr valign="top">
|
337 |
+
<th scope="row" class="sethead">Online</th>
|
338 |
+
<td>
|
339 |
+
<textarea class="inputtext" name="zopimOnlineLong" id="zopimOnlineLong" onKeyup="updateSoon()"><?php echo $greetings->online->window; ?></textarea>
|
340 |
+
</td>
|
341 |
+
</tr>
|
342 |
+
|
343 |
+
<tr valign="top">
|
344 |
+
<th scope="row" class="sethead">Away</th>
|
345 |
+
<td>
|
346 |
+
<textarea class="inputtext" name="zopimAwayLong" id="zopimAwayLong" onKeyup="updateSoon()"><?php echo $greetings->away->window; ?></textarea>
|
347 |
+
</td>
|
348 |
+
</tr>
|
349 |
+
|
350 |
+
<tr valign="top">
|
351 |
+
<th scope="row" class="sethead">Offline</th>
|
352 |
+
<td>
|
353 |
+
<textarea class="inputtext" name="zopimOfflineLong" id="zopimOfflineLong" onKeyup="updateSoon()"><?php echo $greetings->offline->window; ?></textarea>
|
354 |
+
</td>
|
355 |
+
</tr>
|
356 |
+
</table>
|
357 |
+
|
358 |
+
</div>
|
359 |
+
</div>
|
360 |
+
</div>
|
361 |
+
|
362 |
+
|
363 |
+
|
364 |
+
<p class="submit">
|
365 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
366 |
+
</p>
|
367 |
+
|
368 |
+
</form>
|
369 |
+
</div>
|
370 |
+
|
371 |
+
<?php }
|
372 |
+
|
373 |
+
function valuekeys($array) {
|
374 |
+
|
375 |
+
$newarray = array();
|
376 |
+
foreach ($array as $s) {
|
377 |
+
$newarray[$s] = $s;
|
378 |
+
}
|
379 |
+
|
380 |
+
return $newarray;
|
381 |
+
}
|
382 |
+
|
383 |
+
function generate_options($options, $current) {
|
384 |
+
|
385 |
+
$out = "";
|
386 |
+
foreach ($options as $key => $value) {
|
387 |
+
|
388 |
+
if ($value != "") {
|
389 |
+
$isselected = "";
|
390 |
+
if ($current == $key) {
|
391 |
+
$isselected = "selected";
|
392 |
+
}
|
393 |
+
$out .= '<option value="'.$key.'" '.$isselected.'>'.$value.'</option>';
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
return $out;
|
398 |
+
}
|
399 |
+
|
400 |
+
function get_languages() {
|
401 |
+
|
402 |
+
$langjson = '{"--":" - Auto Detect - ","ar":"Arabic","bg":"Bulgarian","cs":"Czech","da":"Danish","de":"German","en":"English","es":"Spanish; Castilian","fa":"Persian","fo":"Faroese","fr":"French","he":"Hebrew","hr":"Croatian","id":"Indonesian","it":"Italian","ja":"Japanese","ko":"Korean","ms":"Malay","nb":"Norwegian Bokmal","nl":"Dutch; Flemish","pl":"Polish","pt":"Portuguese","ru":"Russian","sk":"Slovak","sl":"Slovenian","sv":"Swedish","th":"Thai","tr":"Turkish","ur":"Urdu","vi":"Vietnamese","zh_CN":"Chinese (China)"}hihi{"--":" - Auto Detect - ","ar":"Arabic","bg":"Bulgarian","cs":"Czech","da":"Danish","de":"German","en":"English","es":"Spanish; Castilian","fa":"Persian","fo":"Faroese","fr":"French","he":"Hebrew","hr":"Croatian","id":"Indonesian","it":"Italian","ja":"Japanese","ko":"Korean","ms":"Malay","nb":"Norwegian Bokmal","nl":"Dutch; Flemish","pl":"Polish","pt":"Portuguese","ru":"Russian","sk":"Slovak","sl":"Slovenian","sv":"Swedish","th":"Thai","tr":"Turkish","ur":"Urdu","vi":"Vietnamese","zh_CN":"Chinese (China)"}';
|
403 |
+
|
404 |
+
return json_to_array($langjson);
|
405 |
+
}
|
406 |
+
|
407 |
+
function update_checkbox($fieldname) {
|
408 |
+
if (isset($_POST["$fieldname"]) && $_POST["$fieldname"] != "") {
|
409 |
+
update_option($fieldname, $_POST["$fieldname"]);
|
410 |
+
} else {
|
411 |
+
update_option($fieldname, "disabled");
|
412 |
+
}
|
413 |
+
}
|
414 |
+
|
415 |
+
?>
|
imintegration.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function zopim_instant_messaging() { ?>
|
4 |
+
|
5 |
+
<div class="wrap">
|
6 |
+
<div id="icon-users" class="icon32"></div>
|
7 |
+
<h2>Relay your messages</h2>
|
8 |
+
Use your favourite Instant Messaging (IM) client to chat with your website visitors!<p>
|
9 |
+
|
10 |
+
|
11 |
+
<?php
|
12 |
+
|
13 |
+
$salt = array('salt' => get_option('zopimSalt'));
|
14 |
+
|
15 |
+
if (isset($_GET["remove"]) && $_GET["remove"] == 1) {
|
16 |
+
echo "Removed IM Set Up. <br><br>";
|
17 |
+
|
18 |
+
json_to_array(do_post_request(ZOPIM_IMREMOVE_URL, $salt));
|
19 |
+
}
|
20 |
+
$iminfo = json_to_array(do_post_request(ZOPIM_IMINFO_URL, $salt));
|
21 |
+
|
22 |
+
if (isset($iminfo->bots)) { // Can set up IM ?>
|
23 |
+
|
24 |
+
<style>
|
25 |
+
td {}
|
26 |
+
.clients td.first {border:none;background:#888;color:#fff;}
|
27 |
+
.steps {width:100%}
|
28 |
+
.steps td {background:#f9f9f9;padding:15px;}
|
29 |
+
.clients td {padding:8px;border-top:1px solid #dfdfdf;background:#fff;}
|
30 |
+
.clients {border:1px solid #dfdfdf;background:#fff}
|
31 |
+
.explain {
|
32 |
+
background:#FAFAFA;
|
33 |
+
color:#667788;
|
34 |
+
font-size:8pt;
|
35 |
+
line-height:13px;
|
36 |
+
margin:4px 0 0 0;
|
37 |
+
padding:8px 3px;
|
38 |
+
display: inline-block;
|
39 |
+
}
|
40 |
+
</style>
|
41 |
+
|
42 |
+
<div class="metabox-holder">
|
43 |
+
<div class="postbox">
|
44 |
+
<h3 class="hndle"><span>Setting up your Chat Bots</span></h3>
|
45 |
+
<div style="padding:10px 0px;line-height:17px;">
|
46 |
+
|
47 |
+
<table class="steps" cellspacing="0" cellpadding="0">
|
48 |
+
<tr valign="top">
|
49 |
+
<td style="border-right:5px solid #fff;width:394px;">
|
50 |
+
1. Add the Control Bot to the IM Client of your choice.<br/><br/>
|
51 |
+
|
52 |
+
<table class="clients" cellpadding="0" cellspacing="0">
|
53 |
+
<tr><td align="center" width="160" class="first"><b>IM Cient</b></td><td class="first" width="200"><b>Chat Bot's Name</b></td></tr>
|
54 |
+
<tr><td valign="center" align="center"><img src="<?php echo ZOPIM_IM_LOGOS ?>big/gtalk.png"></td><td><?php echo $iminfo->bots->gtalk; ?></td></tr>
|
55 |
+
<tr><td valign="center" align="center"><img src="<?php echo ZOPIM_IM_LOGOS ?>big/msn.png"></td><td><?php echo $iminfo->bots->msn; ?></td></tr>
|
56 |
+
<tr><td valign="center" align="center"><img src="<?php echo ZOPIM_IM_LOGOS ?>big/yahoo.png"></td><td><?php echo $iminfo->bots->yahoo; ?></td></tr>
|
57 |
+
<tr><td valign="center" align="center"><img src="<?php echo ZOPIM_IM_LOGOS ?>big/aim.png"></td><td><?php echo $iminfo->bots->aim; ?></td></tr>
|
58 |
+
</table>
|
59 |
+
<div class="explain">For example, to use <b>MSN Live Messenger</b> to chat,<br/>add <b>zdctrlbot01@hotmail.com</b> to your MSN contact list.</div>
|
60 |
+
</td>
|
61 |
+
<td>
|
62 |
+
2. Send the Control Bot this message:<br/><br/><input style="font-size:31px;color:#555;margin:0 0 5px;width:380px;" type="text" value="#setup <?php echo $iminfo->auth_key; ?>" id="box-content" readonly></input><br/>
|
63 |
+
<input id="copy" value="Copy to Clipboard" type="button"></input>
|
64 |
+
|
65 |
+
<br/><br/>
|
66 |
+
3. Accept the invitations to add the Chat Bots.<br>
|
67 |
+
<div class="explain">Depending on the number of Chat Bots available in your Package,<br/>you may need to accept up to 8 invitations</div>
|
68 |
+
<br/><br/>That's all!<br/><br/>
|
69 |
+
The Chat Bot will now relay all messages sent from<br/>your website to your IM Client.
|
70 |
+
<br/><br/>
|
71 |
+
Chat away!
|
72 |
+
</td>
|
73 |
+
</tr>
|
74 |
+
</table>
|
75 |
+
|
76 |
+
</div>
|
77 |
+
</div>
|
78 |
+
</div>
|
79 |
+
<script type="text/javascript" src="http://www.zopim.com/static/ZeroClipboard.js"></script>
|
80 |
+
<script language="javascript">
|
81 |
+
|
82 |
+
//create client
|
83 |
+
ZeroClipboard.setMoviePath('http://www.zopim.com/static/ZeroClipboard.swf');
|
84 |
+
var clip = new ZeroClipboard.Client();
|
85 |
+
|
86 |
+
//event
|
87 |
+
function $(id) { return document.getElementById(id); }
|
88 |
+
|
89 |
+
clip.addEventListener('mousedown',function() {
|
90 |
+
clip.setText(document.getElementById('box-content').value);
|
91 |
+
});
|
92 |
+
clip.addEventListener('complete',function(client,text) {
|
93 |
+
window.status = 'copied: ' + text;
|
94 |
+
});
|
95 |
+
//glue it to the button
|
96 |
+
clip.glue('copy');
|
97 |
+
</script>
|
98 |
+
|
99 |
+
<?php } else if (isset($iminfo->status)) { // integration already set up ?>
|
100 |
+
|
101 |
+
<h3><img src="<?php echo ZOPIM_IM_LOGOS.$iminfo->protocol; ?>.png"> Your <?php echo strtoupper($iminfo->protocol); ?> account is now linked with Zopim.</h3>
|
102 |
+
|
103 |
+
You are connected using the account: <?php echo $iminfo->username; ?>. <br>
|
104 |
+
Your status is now <b><?php echo $iminfo->status; ?></b>.<br><br>
|
105 |
+
|
106 |
+
<H3>Disable IM Integration</h3>
|
107 |
+
You can <a href="admin.php?page=zopim_instant_messaging&remove=1">disable IM integration by clicking here</a>.
|
108 |
+
|
109 |
+
<?php } else { // could not contact zopim to get the IM status
|
110 |
+
|
111 |
+
if (get_option('zopimCode') != "zopim") {
|
112 |
+
|
113 |
+
?>
|
114 |
+
|
115 |
+
<div class="metabox-holder">
|
116 |
+
<div class="postbox">
|
117 |
+
<h3 class="hndle"><span>Account not linked</span></h3>
|
118 |
+
<div style="padding:10px;line-height:17px;">
|
119 |
+
Please <a href="admin.php?page=zopim_account_config">link your account / check your password</a> before setting up Chat Bots.
|
120 |
+
|
121 |
+
</div>
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
|
125 |
+
<?php } else { ?>
|
126 |
+
|
127 |
+
<div class="metabox-holder">
|
128 |
+
<div class="postbox">
|
129 |
+
<h3 class="hndle"><span>Account not activated</span></h3>
|
130 |
+
<div style="padding:10px;line-height:17px;">
|
131 |
+
Please <a href="admin.php?page=zopim_account_config">activate your account</a> before setting up Chat Bots.
|
132 |
+
|
133 |
+
</div>
|
134 |
+
</div>
|
135 |
+
</div>
|
136 |
+
|
137 |
+
<?php } }
|
138 |
+
|
139 |
+
}
|
140 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Zopim Live Chat ===
|
2 |
+
Contributors: bencxr
|
3 |
+
Tags: widget, plugin, sidebar, page, admin, enhancement, livechat, chat, widget
|
4 |
+
Requires at least: 2.7
|
5 |
+
Tested up to: 2.8.2
|
6 |
+
Stable tag: 0.7
|
7 |
+
|
8 |
+
Visitors can chat with you directly by clicking on the Zopim Chat Bar.
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
|
12 |
+
What if your website could talk? Zopim increases engagement between you and your visitors, by allowing them to chat with you!
|
13 |
+
Great for improving interaction with your users and increasing the time they spend on your site.
|
14 |
+
|
15 |
+
**Why use Zopim?**
|
16 |
+
|
17 |
+
* Installation happens in a flash - 60 seconds setup!
|
18 |
+
|
19 |
+
* Choose to reply to visitors via your favorite IM client or the high productivity Dashboard
|
20 |
+
|
21 |
+
* Know exactly who enters your site! The name and email is automatically detected if he is a Wordpress user.
|
22 |
+
|
23 |
+
* Monitor visitors live as they surf, including their entry, location, history, current URL, repeat visitors etc
|
24 |
+
|
25 |
+
* Customize widget look and feel: themes, colours, positions, greeting message.
|
26 |
+
|
27 |
+
* Localise the widget to the language you want: English, Hebrew, Persian, Polish, Indonesian, Swedish, Bulgarian, Czech, Slovenian, Russian, Danish, Chinese, Croation, Thai, French, Dutch, Turkish, German, Faroese, Korean, Japanese.
|
28 |
+
|
29 |
+
* Access a high productivity Dashboard: with saved chat history, templated messages, visitor prioritization, Q & A, smart responder
|
30 |
+
|
31 |
+
== Changelog ==
|
32 |
+
|
33 |
+
= 0.6.1 =
|
34 |
+
* Update: Launched with improved signup process and minor cosmetic fixes.
|
35 |
+
|
36 |
+
= 0.6.0 =
|
37 |
+
* UI fix: Improved account management page.
|
38 |
+
|
39 |
+
= 0.5.0 =
|
40 |
+
|
41 |
+
* Feature: Push surveys and questions to the visitor.
|
42 |
+
* Bugfix: In-plugin dashboard will be hidden in full screen mode.
|
43 |
+
|
44 |
+
= 0.4.0 =
|
45 |
+
|
46 |
+
* Feature: Provide customer service through your favourite IM client (MSN, GTalk, Yahoo, AIM)
|
47 |
+
* Feature: You can access the dashboard in full screen!
|
48 |
+
|
49 |
+
= 0.3.0 =
|
50 |
+
|
51 |
+
* Feature: Connect to Zopim servers using 256-bit industry standard SSL for increased security!
|
52 |
+
* Feature: You can experiment with customizing the widget even without an account.
|
53 |
+
* Feature: Change the automatic messages displayed on the widget when it first loads, and depending on your online status.
|
54 |
+
* Feature: Customize the language of the widget.
|
55 |
+
* Bugfix: Positioning customization now works properly.
|
56 |
+
|
57 |
+
= 0.2.0 =
|
58 |
+
|
59 |
+
* Feature: Live Visitor Analytics (page your users are on, webpaths, length of stay, repeat visits and much more!)
|
60 |
+
* Feature: Create an account directly in the plugin.
|
61 |
+
* Feature: Rank Visitors by priority of importance.
|
62 |
+
|
63 |
+
= 0.1.0 =
|
64 |
+
|
65 |
+
* Feature: Add the Zopim live chat widget to your site!
|
66 |
+
* Feature: Customize look and feel of the widget, including themes and color!
|
67 |
+
* Feature: Use wordpress user information to populate visitor data in the plugin.
|
68 |
+
|
69 |
+
== Screenshots ==
|
70 |
+
|
71 |
+
1. Chat window on your website
|
72 |
+
2. Typical usage session in the dashboard
|
73 |
+
3. Account Configuration
|
74 |
+
4. Styling and customiation
|
75 |
+
|
76 |
+
== Frequently Asked Questions ==
|
77 |
+
|
78 |
+
= Do I have to install any software on my server to get this working? =
|
79 |
+
|
80 |
+
Not at all! Zopim is a hosted livechat service. Simply configure the plugin and you're done!
|
81 |
+
|
82 |
+
= Which web browsers work best with this plugin =
|
83 |
+
|
84 |
+
Though designed to work on most browsers, Zopim works best in the following environment: IE 6 or later (PC), Firefox 2 or later (Mac, PC, or Linux), Safari 2 or later (Mac), Google Chrome (PC, Mac).
|
85 |
+
|
86 |
+
= Is it free to use? =
|
87 |
+
|
88 |
+
The plugin comes with a free plan specially tailored for Wordpress users. Power users can purchase upgrade options anytime.
|
89 |
+
|
90 |
+
= Its just not working for me! HELP! =
|
91 |
+
|
92 |
+
Dont worry!! We are happy to assist! Just come on down to our site at http://www.zopim.com and we will help you with installation.
|
93 |
+
|
94 |
+
== Usage ==
|
95 |
+
|
96 |
+
After enabling the plug in, head on to the widget customization page to change settings and integrate it's look and feel with your site. When done, enable it by visiting the account configuration page and completing the instant signup process.
|
97 |
+
|
98 |
+
== Installation ==
|
99 |
+
|
100 |
+
*Server Requirements:* PHP4 or PHP5.
|
101 |
+
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
screenshot-3.png
ADDED
Binary file
|
screenshot-4.png
ADDED
Binary file
|
zopim.php
ADDED
@@ -0,0 +1,261 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
Plugin Name: Zopim Widget
|
5 |
+
Plugin URI: http://www.zopim.org
|
6 |
+
Description: Zopim embeds a chatbar on your website, so that any visitor can chat with you directly by clicking on the chatbar.
|
7 |
+
Author: Isidore
|
8 |
+
Version: 0.7.1
|
9 |
+
Author URI: http://www.isidorechan.com/
|
10 |
+
*/
|
11 |
+
|
12 |
+
define('ZOPIM_SCRIPT_DOMAIN', "zopim.com");
|
13 |
+
define('ZOPIM_BASE_URL', "https://www.zopim.com/");
|
14 |
+
define('ZOPIM_GETACCOUNTDETAILS_URL', ZOPIM_BASE_URL."plugins/getAccountDetails");
|
15 |
+
define('ZOPIM_SETDISPLAYNAME_URL', ZOPIM_BASE_URL."plugins/setDisplayName");
|
16 |
+
define('ZOPIM_IMINFO_URL', ZOPIM_BASE_URL."plugins/getImSetupInfo");
|
17 |
+
define('ZOPIM_IMREMOVE_URL', ZOPIM_BASE_URL."plugins/removeImSetup");
|
18 |
+
define('ZOPIM_LOGIN_URL', ZOPIM_BASE_URL."plugins/login");
|
19 |
+
define('ZOPIM_SIGNUP_URL', ZOPIM_BASE_URL."plugins/createTrialAccount");
|
20 |
+
define('ZOPIM_THEMES_LIST', "http://zopim.com/assets/dashboard/themes/window/plugins-themes.txt");
|
21 |
+
define('ZOPIM_COLORS_LIST', "http://zopim.com/assets/dashboard/themes/window/plugins-colors.txt");
|
22 |
+
define('ZOPIM_LANGUAGES_URL', "http://translate.zopim.com/projects/zopim/");
|
23 |
+
define('ZOPIM_DASHBOARD_URL', "http://dashboard.zopim.com/");
|
24 |
+
define('ZOPIM_SMALL_LOGO', "http://zopim.com/assets/branding/zopim.com/chatman/online.png");
|
25 |
+
define('ZOPIM_IM_LOGOS', "http://www.zopim.com/static/images/im/");
|
26 |
+
define('ZOPIM_THEMES_URL', "http://");
|
27 |
+
define('ZOPIM_COLOURS_URL', "http://");
|
28 |
+
|
29 |
+
require_once dirname( __FILE__ ) . '/accountconfig.php';
|
30 |
+
require_once dirname( __FILE__ ) . '/customizewidget.php';
|
31 |
+
require_once dirname( __FILE__ ) . '/imintegration.php';
|
32 |
+
|
33 |
+
// We need some CSS to position the paragraph
|
34 |
+
function zopimme() {
|
35 |
+
global $current_user;
|
36 |
+
|
37 |
+
$code = get_option('zopimCode');
|
38 |
+
|
39 |
+
if (($code == "" || $code=="zopim") && (!ereg("zopim", $_GET["page"]))&& (!ereg("zopim", $_SERVER["SERVER_NAME"]))) { return; }
|
40 |
+
|
41 |
+
// Use zopim's code...
|
42 |
+
echo "
|
43 |
+
<script type=\"text/javascript\">
|
44 |
+
document.write(unescape(\"%3Cscript src='\" + document.location.protocol + \"//".ZOPIM_SCRIPT_DOMAIN."/?".$code."' charset='utf-8' type='text/javascript'%3E%3C/script%3E\"));
|
45 |
+
</script>";
|
46 |
+
|
47 |
+
$theoptions = array();
|
48 |
+
if (get_option('zopimLang') != "" && get_option('zopimLang') != "--") {
|
49 |
+
$theoptions[] = " language: '".get_option('zopimLang')."'";
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
if ( isset($current_user) && get_option("zopimGetVisitorInfo") == "checked" )
|
54 |
+
{
|
55 |
+
$ul = $current_user->data->first_name;
|
56 |
+
$useremail = $current_user->data->user_email;
|
57 |
+
|
58 |
+
if ($ul!="" && $useremail != "") {
|
59 |
+
$theoptions[] = "
|
60 |
+
name: '$ul',
|
61 |
+
email: '$useremail'
|
62 |
+
";
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
echo '<script type="text/javascript">';
|
67 |
+
if (count($theoptions) > 0) {
|
68 |
+
echo '$zopim.livechat.set({';
|
69 |
+
echo implode(", ", $theoptions);
|
70 |
+
echo " });";
|
71 |
+
}
|
72 |
+
if (get_option('zopimPosition') != "") {
|
73 |
+
echo "\n\$zopim.livechat.button.setPosition('".get_option('zopimPosition')."');";
|
74 |
+
}
|
75 |
+
if (get_option('zopimTheme') != "") {
|
76 |
+
echo "\n\$zopim.livechat.window.setTheme('".get_option('zopimTheme')."');";
|
77 |
+
}
|
78 |
+
if (get_option('zopimColor') != "") {
|
79 |
+
echo "\n\$zopim.livechat.window.setColor('".get_option('zopimColor')."');";
|
80 |
+
}
|
81 |
+
if (get_option('zopimBubbleTitle') != "") {
|
82 |
+
echo "\n\$zopim.livechat.bubble.setTitle('".addslashes(get_option('zopimBubbleTitle'))."');";
|
83 |
+
}
|
84 |
+
if (get_option('zopimBubbleText') != "") {
|
85 |
+
echo "\n\$zopim.livechat.bubble.setText('".addslashes(get_option('zopimBubbleText'))."');";
|
86 |
+
}
|
87 |
+
if (get_option('zopimHideOnOffline') == "checked") {
|
88 |
+
echo "\n\$zopim.livechat.button.setHideWhenOffline(true);";
|
89 |
+
}
|
90 |
+
if (get_option('zopimBubbleEnable') == "checked") {
|
91 |
+
echo "\n\$zopim.livechat.bubble.show(true);";
|
92 |
+
}
|
93 |
+
if (get_option('zopimGreetings') != "") {
|
94 |
+
$greetings = json_to_array(get_option('zopimGreetings'));
|
95 |
+
echo "\n\$zopim.livechat.setGreetings({
|
96 |
+
'online': ['".addslashes($greetings->online->bar)."', '".addslashes($greetings->online->window)."'],
|
97 |
+
'offline': ['".addslashes($greetings->offline->bar)."', '".addslashes($greetings->offline->window)."'],
|
98 |
+
'away': ['".addslashes($greetings->away->bar)."', '".addslashes($greetings->away->window)."'] });
|
99 |
+
";
|
100 |
+
}
|
101 |
+
echo "</script>";
|
102 |
+
}
|
103 |
+
|
104 |
+
function zopim_create_menu() {
|
105 |
+
|
106 |
+
//create new top-level menu
|
107 |
+
add_menu_page('Account Configuration', 'Zopim Chat', 'administrator', 'zopim_account_config', 'zopim_account_config', ZOPIM_SMALL_LOGO);
|
108 |
+
// add_submenu_page('zopim_about', "About", "About", "administrator", 'zopim_about', 'zopim_about');
|
109 |
+
add_submenu_page('zopim_account_config', 'Account Configuration', 'Account Setup', 'administrator', 'zopim_account_config', 'zopim_account_config');
|
110 |
+
add_submenu_page('zopim_account_config', 'Customize Widget', 'Customize', 'administrator', 'zopim_customize_widget', 'zopim_customize_widget');
|
111 |
+
add_submenu_page('zopim_account_config', 'IM Integration', 'IM Chat Bots', 'administrator', 'zopim_instant_messaging', 'zopim_instant_messaging');
|
112 |
+
add_submenu_page('zopim_account_config', 'Dashboard', 'Dashboard', 'administrator', 'zopim_dashboard', 'zopim_dashboard');
|
113 |
+
|
114 |
+
//call register settings function
|
115 |
+
add_action( 'admin_init', 'register_mysettings' );
|
116 |
+
}
|
117 |
+
|
118 |
+
function check_zopimCode() {
|
119 |
+
/*
|
120 |
+
// if (get_option('zopimCode') == '' && ($_GET["page"] != "zopim_account_config")) {
|
121 |
+
if (ereg("zopim", $_GET["page"] )) {
|
122 |
+
//add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>" . sprintf( "Please <a href=\"%s\">input your Zopim account details</a>.", "admin.php?page=zopim_account_config" ) . "</p></div>";' ) );
|
123 |
+
add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>This Zopim plugin is a work in progress. We will launch on the 25th of January. Thank you for your interest.</p></div>";' ) );
|
124 |
+
}
|
125 |
+
*/
|
126 |
+
return false;
|
127 |
+
}
|
128 |
+
|
129 |
+
function zopim_loader() {
|
130 |
+
|
131 |
+
add_action( 'admin_menu', 'check_zopimCode' );
|
132 |
+
}
|
133 |
+
|
134 |
+
add_action( 'init', 'zopim_loader' );
|
135 |
+
|
136 |
+
function zopim_about() {
|
137 |
+
|
138 |
+
echo "about";
|
139 |
+
}
|
140 |
+
|
141 |
+
function zopim_dashboard() {
|
142 |
+
|
143 |
+
echo '<div id="dashboarddiv"><iframe id="dashboardiframe" src="'.ZOPIM_DASHBOARD_URL.'" height=700 width=98% scrolling="no"></iframe></div> You may also <a href="'.ZOPIM_DASHBOARD_URL.'" target="_newWindow" onClick="javascript:document.getElementById(\'dashboarddiv\').innerHTML=\'\'; ">access the dashboard in a new window</a>.
|
144 |
+
';
|
145 |
+
}
|
146 |
+
|
147 |
+
// Register the option settings we will be using
|
148 |
+
function register_mysettings() {
|
149 |
+
|
150 |
+
// Authentication and codes
|
151 |
+
register_setting( 'zopim-settings-group', 'zopimCode' );
|
152 |
+
register_setting( 'zopim-settings-group', 'zopimUsername' );
|
153 |
+
register_setting( 'zopim-settings-group', 'zopimSalt' );
|
154 |
+
register_setting( 'zopim-settings-group', 'zopimUseSSL' );
|
155 |
+
|
156 |
+
// General Widget settings
|
157 |
+
register_setting( 'zopim-settings-group', 'zopimGetVisitorInfo' );
|
158 |
+
register_setting( 'zopim-settings-group', 'zopimLang' );
|
159 |
+
|
160 |
+
// Chat button settings
|
161 |
+
register_setting( 'zopim-settings-group', 'zopimPosition' );
|
162 |
+
register_setting( 'zopim-settings-group', 'zopimHideOnOffline' );
|
163 |
+
register_setting( 'zopim-settings-group', 'zopimBubbleTitle' );
|
164 |
+
register_setting( 'zopim-settings-group', 'zopimBubbleText' );
|
165 |
+
register_setting( 'zopim-settings-group', 'zopimBubbleEnable' );
|
166 |
+
|
167 |
+
// Themes / Color
|
168 |
+
register_setting( 'zopim-settings-group', 'zopimColor' );
|
169 |
+
register_setting( 'zopim-settings-group', 'zopimTheme' );
|
170 |
+
|
171 |
+
// Message Settings
|
172 |
+
register_setting( 'zopim-settings-group', 'zopimGreetings' );
|
173 |
+
|
174 |
+
if (get_option('zopimCode') == "") {
|
175 |
+
update_option('zopimCode', "zopim");
|
176 |
+
}
|
177 |
+
|
178 |
+
if (get_option('zopimBubbleTitle') == "") {
|
179 |
+
update_option('zopimBubbleTitle', "Questions?");
|
180 |
+
}
|
181 |
+
if (get_option('zopimBubbleText') == "") {
|
182 |
+
update_option('zopimBubbleText', "Click here to chat with us!");
|
183 |
+
}
|
184 |
+
if (get_option('zopimBubbleEnable') == "") {
|
185 |
+
update_option('zopimBubbleEnable', "checked");
|
186 |
+
}
|
187 |
+
|
188 |
+
if (get_option('zopimGreetings') == "") {
|
189 |
+
update_option('zopimGreetings', '{"away":{"window":"If you leave a question or comment, our agents will be notified and will try to attend to you shortly =)","bar":"Click here to chat"},"offline":{"window":"We are offline, but if you leave your message and contact details, we will try to get back to you =)","bar":"Leave a message"},"online":{"window":"Leave a question or comment and our agents will try to attend to you shortly =)","bar":"Click here to chat"}}');
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
add_action('get_footer', 'zopimme');
|
194 |
+
// create custom plugin settings menu
|
195 |
+
add_action('admin_menu', 'zopim_create_menu');
|
196 |
+
|
197 |
+
function do_post_request($url, $_data, $optional_headers = null)
|
198 |
+
{
|
199 |
+
$gadURL = ZOPIM_GETACCOUNTDETAILS_URL;
|
200 |
+
if (get_option('zopimUseSSL') != "zopimUseSSL") {
|
201 |
+
$gadURL = str_replace("https", "http", $gadURL);
|
202 |
+
}
|
203 |
+
|
204 |
+
$data = array();
|
205 |
+
|
206 |
+
while(list($n,$v) = each($_data)){
|
207 |
+
$data[] = urlencode($n)."=".urlencode($v);
|
208 |
+
}
|
209 |
+
|
210 |
+
$data = implode('&', $data);
|
211 |
+
$params = array('http' => array(
|
212 |
+
'method' => 'POST',
|
213 |
+
'content' => $data
|
214 |
+
));
|
215 |
+
if ($optional_headers !== null) {
|
216 |
+
$params['http']['header'] = $optional_headers;
|
217 |
+
}
|
218 |
+
$ctx = stream_context_create($params);
|
219 |
+
$fp = @fopen($url, 'rb', false, $ctx);
|
220 |
+
|
221 |
+
if (!$fp) {
|
222 |
+
// echo ("Problem with $url, $php_errormsg");
|
223 |
+
}
|
224 |
+
$response = @stream_get_contents($fp);
|
225 |
+
if ($response === false) {
|
226 |
+
// echo("Problem reading data from $url, $php_errormsg");
|
227 |
+
}
|
228 |
+
|
229 |
+
return $response;
|
230 |
+
}
|
231 |
+
|
232 |
+
function json_to_array($json) {
|
233 |
+
|
234 |
+
// json_decode does exist but only in php > 5.2.0
|
235 |
+
require_once('JSON.php');
|
236 |
+
|
237 |
+
$jsonparser = new Services_JSON();
|
238 |
+
|
239 |
+
return ($jsonparser->decode($json));
|
240 |
+
}
|
241 |
+
|
242 |
+
function to_json($variable) {
|
243 |
+
|
244 |
+
// json_decode does exist but only in php > 5.2.0
|
245 |
+
require_once('JSON.php');
|
246 |
+
|
247 |
+
$jsonparser = new Services_JSON();
|
248 |
+
|
249 |
+
return ($jsonparser->encode($variable));
|
250 |
+
}
|
251 |
+
|
252 |
+
function getAccountDetails($salt) {
|
253 |
+
|
254 |
+
$salty = array(
|
255 |
+
"salt" => get_option('zopimSalt')
|
256 |
+
);
|
257 |
+
|
258 |
+
return json_to_array(do_post_request(ZOPIM_GETACCOUNTDETAILS_URL, $salty));
|
259 |
+
}
|
260 |
+
|
261 |
+
?>
|