1
|
<?php
|
2
|
/* --------------------------------------------------------------
|
3
|
Yoochoose GmbH
|
4
|
http://www.yoochoose.com
|
5
|
Copyright (c) 2011 Yoochoose GmbH
|
6
|
Released under the GNU General Public License (Version 2)
|
7
|
[http://www.gnu.org/licenses/gpl-2.0.html]
|
8
|
-------------------------------------------------------------- */
|
9
|
defined('_VALID_XTC') or die('Direct Access to this location is not allowed.');
|
10
|
|
11
|
///
|
12
|
/// Check frame for Yoochoose configuration module.
|
13
|
/// It is included to /admin/yoochoose.php
|
14
|
///
|
15
|
|
16
|
require_once(DIR_FS_ADMIN.'includes/modules/yoochoose/utils.php');
|
17
|
|
18
|
echo '<div style="padding: 20px 40px 30px 40px;" class="yoo-image6-large">';
|
19
|
|
20
|
define('AVAILABLE', '<span style="color:green; font-weight:bold;">available</span>');
|
21
|
define('SUCCESSFUL', '<span style="color:green; font-weight:bold;">successful</span>');
|
22
|
define('UNAVAILABLE', '<span style="color:red; font-weight:bold;">unavailable</span>');
|
23
|
define('FAILED', '<span style="color:red; font-weight:bold;">failed</span>');
|
24
|
|
25
|
echo '<h2>YOOCHOOSE SELF-TEST</h2>';
|
26
|
|
27
|
echo '<h3>PHP Configuration</h3>';
|
28
|
|
29
|
echo 'Your PHP Version (5.2 or higher recommended): <b>'.phpversion().'</b><br>';
|
30
|
|
31
|
echo 'Function json_decode: '.(function_exists('json_decode') ? AVAILABLE : UNAVAILABLE).'<br>';
|
32
|
|
33
|
echo 'Module curl: '.(in_array('curl', get_loaded_extensions()) ? AVAILABLE : UNAVAILABLE).'<br>';
|
34
|
|
35
|
echo 'Object DateTime: '.(class_exists('DateTime') ? AVAILABLE : UNAVAILABLE).'<br>';
|
36
|
|
37
|
echo '<h3>Connectivity</h3>';
|
38
|
|
39
|
$url = getMeUrl();
|
40
|
curlSomeAdress("Requesting myself as [$url]", $url);
|
41
|
|
42
|
$url = 'http://google.com';
|
43
|
curlSomeAdress("Requesting Google as [$url]", $url);
|
44
|
|
45
|
$url = 'http://config.yoochoose.net';
|
46
|
curlSomeAdress("Requesting YOOCHOOSE registration server [$url]", $url);
|
47
|
|
48
|
$url = 'https://config.yoochoose.net';
|
49
|
curlSomeAdress("Requesting YOOCHOOSE registration server over SSL [$url]", $url);
|
50
|
|
51
|
$url = 'http://reco.yoochoose.net/api/00000/landing_page.json?feedback&contextitems=1,2,3,4,5';
|
52
|
curlSomeAdress("Requesting YOOCHOOSE recommendation server [$url]", $url);
|
53
|
|
54
|
echo '<h3>Template</h3>';
|
55
|
|
56
|
$p_templates = yooProductTemplates();
|
57
|
$c_templates = yooListingTemplates();
|
58
|
|
59
|
if(gm_get_env_info('TEMPLATE_VERSION') >= 3)
|
60
|
{
|
61
|
$p_templates = '/snippets/product_info/product_lists.html';
|
62
|
}
|
63
|
|
64
|
echo "Current template: <b>" . CURRENT_TEMPLATE . "</b><br>";
|
65
|
|
66
|
yooCheckModule('MODULE_yoochoose_homepage_personalized', '/module/main_content.html');
|
67
|
yooCheckModule('MODULE_yoochoose_homepage_topsellers', '/module/main_content.html');
|
68
|
yooCheckModule('MODULE_yoochoose_category_topsellers', $c_templates);
|
69
|
yooCheckModule('MODULE_also_purchased', $p_templates);
|
70
|
yooCheckModule('MODULE_yoochoose_also_interesting', $p_templates);
|
71
|
yooCheckModule('MODULE_yoochoose_product_tracking', $p_templates);
|
72
|
yooCheckModule('MODULE_yoochoose_shopping_cart', '/module/shopping_cart.html');
|
73
|
yooCheckModule('MODULE_yoochoose_checkout_tracking', '/module/checkout_success.html');
|
74
|
|
75
|
|
76
|
function yooCheckModule($module, $template) {
|
77
|
$templates = is_array($template) ? $template : array($template);
|
78
|
|
79
|
foreach ($templates as $template) {
|
80
|
|
81
|
$tfile = DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.$template;
|
82
|
$varn = '{$'.$module.'}';
|
83
|
|
84
|
echo "Template file [$template]. Searching for placeholder $varn: ";
|
85
|
|
86
|
if (file_exists($tfile)) {
|
87
|
if (! strpos(file_get_contents($tfile), $varn) !== false) {
|
88
|
$text = sprintf(YOOCHOOSE_ERROR_TEMPLATE_NOT_PREPARED, CURRENT_TEMPLATE, $template, $varn);
|
89
|
|
90
|
echo '<br>'.FAILED." Placeholder not found.";
|
91
|
} else {
|
92
|
echo SUCCESSFUL;
|
93
|
}
|
94
|
} else {
|
95
|
echo '<br>'.FAILED." Template file not found.";
|
96
|
}
|
97
|
}
|
98
|
|
99
|
echo '<br>';
|
100
|
}
|
101
|
|
102
|
|
103
|
if (defined('YOOCHOOSE_ID')) {
|
104
|
|
105
|
echo '<h3>Authentication</h3>';
|
106
|
|
107
|
$url = 'https://config.yoochoose.net/api/'.YOOCHOOSE_ID.'/license.json';
|
108
|
curlSomeAdress("Requesting YOOCHOOSE license [$url]", $url, YOOCHOOSE_ID, YOOCHOOSE_SECRET);
|
109
|
|
110
|
$url = 'https://config.yoochoose.net/api/'.YOOCHOOSE_ID.'/counter/summary.json';
|
111
|
curlSomeAdress("Requesting YOOCHOOSE statistic [$url]", $url, YOOCHOOSE_ID, YOOCHOOSE_SECRET);
|
112
|
|
113
|
echo '<h3>Configuration</h3>';
|
114
|
|
115
|
$url = 'http://reco.yoochoose.net/api/'.YOOCHOOSE_ID.'/'.YOOCHOOSE_HOMEPAGE_PERSONALIZED_STRATEGY.'.json?feedback';
|
116
|
curlSomeAdress("Recommendation request [$url]", $url);
|
117
|
|
118
|
$url = 'http://reco.yoochoose.net/api/'.YOOCHOOSE_ID.'/'.YOOCHOOSE_HOMEPAGE_TOPSELLERS_STRATEGY.'.json';
|
119
|
curlSomeAdress("Recommendation request [$url]", $url);
|
120
|
|
121
|
$url = 'http://reco.yoochoose.net/api/'.YOOCHOOSE_ID.'/'.YOOCHOOSE_CATEGORY_TOPSELLERS_STRATEGY.'.json';
|
122
|
curlSomeAdress("Recommendation request [$url]", $url);
|
123
|
|
124
|
$url = 'http://reco.yoochoose.net/api/'.YOOCHOOSE_ID.'/'.YOOCHOOSE_PRODUCT_ALSO_PURCHASED_STRATEGY.'.json?contextitems=1';
|
125
|
curlSomeAdress("Recommendation request [$url]", $url);
|
126
|
|
127
|
$url = 'http://reco.yoochoose.net/api/'.YOOCHOOSE_ID.'/'.YOOCHOOSE_PRODUCT_ALSO_INTERESTING_STRATEGY.'.json?contextitems=1';
|
128
|
curlSomeAdress("Recommendation request [$url]", $url);
|
129
|
|
130
|
$url = 'http://reco.yoochoose.net/api/'.YOOCHOOSE_ID.'/'.YOOCHOOSE_SHOPPING_CART_STRATEGY.'.json?contextitems=1';
|
131
|
curlSomeAdress("Recommendation request [$url]", $url);
|
132
|
} else {
|
133
|
|
134
|
echo '<h3>Authentication and Configuration</h3>';
|
135
|
|
136
|
yooNoCustomerId();
|
137
|
}
|
138
|
|
139
|
echo '<p>';
|
140
|
|
141
|
echo '</div>';
|
142
|
|
143
|
|
144
|
/////////////////////////////// SOME FUNCTIONS
|
145
|
|
146
|
|
147
|
function yooNoCustomerId() {
|
148
|
$message = '<b>Customer ID not set.</b> '.
|
149
|
'Set you customer ID and the license key using the <a href="yoochoose.php?page=config">configuration tab</a>.';
|
150
|
|
151
|
printInfoDiv($message , "onebit_49.png", "warning");
|
152
|
}
|
153
|
|
154
|
|
155
|
function getMeUrl() {
|
156
|
$httpsStr = @$_SERVER['HTTPS'];
|
157
|
|
158
|
$a = (@$httpsStr && $httpsStr != 'off') ? 'https' : 'http';
|
159
|
$b = $_SERVER['SERVER_NAME'];
|
160
|
$c = $_SERVER['SERVER_PORT'];
|
161
|
return $a."://".$b.":".$c;
|
162
|
}
|
163
|
|
164
|
function curlSomeAdress($name, $url, $user='', $password='') {
|
165
|
$options = array(
|
166
|
CURLOPT_URL => $url,
|
167
|
CURLOPT_HEADER => TRUE,
|
168
|
CURLOPT_RETURNTRANSFER => TRUE,
|
169
|
CURLOPT_TIMEOUT => 4,
|
170
|
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
|
171
|
CURLOPT_SSL_VERIFYPEER => FALSE,
|
172
|
CURLOPT_FAILONERROR => TRUE
|
173
|
);
|
174
|
|
175
|
if ($user) {
|
176
|
$options[CURLOPT_USERPWD] = "$user:$password";
|
177
|
}
|
178
|
|
179
|
$ch = curl_init();
|
180
|
|
181
|
if (!$ch) {
|
182
|
echo FAILED.' Unable to initialize curl. Error code: '.$n.' Error Message: '.$m;
|
183
|
}
|
184
|
|
185
|
curl_setopt_array($ch, $options);
|
186
|
|
187
|
echo $name.': ';
|
188
|
|
189
|
$scs = curl_exec($ch);
|
190
|
$n = curl_errno($ch);
|
191
|
$m = curl_error($ch);
|
192
|
|
193
|
if ($scs) {
|
194
|
echo SUCCESSFUL;
|
195
|
} else {
|
196
|
echo '<br>'.FAILED." $n: $m";
|
197
|
}
|
198
|
|
199
|
echo '<br>';
|
200
|
|
201
|
curl_close($ch);
|
202
|
}
|
203
|
|
204
|
?>
|