forked from sendtogeo/Seo-Panel
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathtest_review_details.php
More file actions
296 lines (279 loc) · 11.8 KB
/
test_review_details.php
File metadata and controls
296 lines (279 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?php
/**
* Test page to verify getReviewDetails function
* with active entries from review_links table
*/
// Load SEO Panel environment
include_once("includes/sp-load.php");
include_once(SP_CTRLPATH."/review_manager.ctrl.php");
// Create controller instance
$rmController = new ReviewManagerController();
// Get active review links from database
$sql = "SELECT id, name, type, url, status FROM review_links WHERE status = 1 LIMIT 10";
$linkList = $rmController->db->select($sql);
?>
<!DOCTYPE html>
<html>
<head>
<title>Test Review Details Fetcher</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f5f5f5;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
h1 {
color: #333;
border-bottom: 2px solid #28a745;
padding-bottom: 10px;
}
.test-item {
border: 1px solid #ddd;
margin: 15px 0;
padding: 15px;
border-radius: 5px;
background: #fafafa;
}
.test-header {
background: #28a745;
color: white;
padding: 10px;
margin: -15px -15px 15px -15px;
border-radius: 5px 5px 0 0;
}
.test-header h3 {
margin: 0;
}
.result {
margin-top: 10px;
padding: 10px;
border-left: 4px solid #28a745;
background: white;
}
.result.error {
border-left-color: #dc3545;
}
.label {
font-weight: bold;
color: #555;
}
.value {
color: #333;
margin-left: 10px;
}
.status-success {
color: #28a745;
font-weight: bold;
}
.status-error {
color: #dc3545;
font-weight: bold;
}
.info-row {
padding: 5px 0;
}
.rating-display {
display: inline-block;
background: #ffc107;
color: white;
padding: 3px 8px;
border-radius: 4px;
font-weight: bold;
}
.reviews-display {
display: inline-block;
background: #17a2b8;
color: white;
padding: 3px 8px;
border-radius: 4px;
font-weight: bold;
}
.loading {
color: #ffc107;
font-style: italic;
}
.icon {
margin-right: 5px;
}
.platform-badge {
display: inline-block;
padding: 4px 10px;
border-radius: 4px;
font-size: 0.9em;
font-weight: bold;
color: white;
}
.platform-google { background: #4285f4; }
.platform-yelp { background: #d32323; }
.platform-trustpilot { background: #00b67a; }
.platform-tripadvisor { background: #00aa6c; }
</style>
</head>
<body>
<div class="container">
<h1>⭐ Review Details Fetcher - Test Page</h1>
<p>Testing <code>getReviewDetails()</code> function with active entries from <code>review_links</code> table</p>
<?php if (empty($linkList)): ?>
<div class="test-item">
<p class="status-error">❌ No active review links found in the database.</p>
</div>
<?php else: ?>
<p><strong>Found <?php echo count($linkList); ?> active review link(s)</strong></p>
<?php foreach ($linkList as $index => $link): ?>
<div class="test-item">
<div class="test-header">
<h3>
<span class="icon">
<?php
$icons = [
'google' => '🔍',
'yelp' => '📍',
'trustpilot' => '⭐',
'tripadvisor' => '✈️'
];
echo isset($icons[$link['type']]) ? $icons[$link['type']] : '🔗';
?>
</span>
Test #<?php echo ($index + 1); ?>: <?php echo htmlspecialchars($link['name']); ?>
</h3>
</div>
<div class="info-row">
<span class="label">ID:</span>
<span class="value"><?php echo $link['id']; ?></span>
</div>
<div class="info-row">
<span class="label">Platform:</span>
<span class="platform-badge platform-<?php echo $link['type']; ?>">
<?php echo ucfirst($link['type']); ?>
</span>
</div>
<div class="info-row">
<span class="label">URL:</span>
<span class="value"><?php echo htmlspecialchars($link['url']); ?></span>
</div>
<?php
// Test the getReviewDetails function
echo "<div class='info-row'><span class='loading'>⏳ Fetching review details...</span></div>";
flush();
$startTime = microtime(true);
$result = $rmController->getReviewDetails($link['type'], $link['url']);
$endTime = microtime(true);
$executionTime = round(($endTime - $startTime), 2);
?>
<div class="result <?php echo $result['status'] ? '' : 'error'; ?>">
<div class="info-row">
<span class="label">Status:</span>
<span class="<?php echo $result['status'] ? 'status-success' : 'status-error'; ?>">
<?php echo $result['status'] ? '✅ Success' : '❌ Failed'; ?>
</span>
</div>
<div class="info-row">
<span class="label">Message:</span>
<span class="value"><?php echo htmlspecialchars($result['msg']); ?></span>
</div>
<div class="info-row">
<span class="label">Reviews Count:</span>
<span class="reviews-display"><?php echo number_format($result['reviews']); ?> reviews</span>
</div>
<div class="info-row">
<span class="label">Rating:</span>
<span class="rating-display">
<?php
$rating = $result['rating'];
echo number_format($rating, 1);
if ($rating > 0) {
echo ' / 5.0 ';
// Display stars
$fullStars = floor($rating);
$halfStar = ($rating - $fullStars) >= 0.5 ? 1 : 0;
for ($i = 0; $i < $fullStars; $i++) {
echo '★';
}
if ($halfStar) {
echo '☆';
}
for ($i = $fullStars + $halfStar; $i < 5; $i++) {
echo '☆';
}
}
?>
</span>
</div>
<div class="info-row">
<span class="label">Execution Time:</span>
<span class="value"><?php echo $executionTime; ?> seconds</span>
</div>
<?php if ($result['status']): ?>
<div class="info-row" style="margin-top: 10px; padding-top: 10px; border-top: 1px solid #ddd;">
<span class="label">✓ Review data fetched successfully!</span>
</div>
<?php else: ?>
<div class="info-row" style="margin-top: 10px; padding-top: 10px; border-top: 1px solid #ddd; color: #dc3545;">
<span class="label">⚠️ Check if the URL is accessible and the regex patterns are correct.</span>
</div>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
<div style="margin-top: 30px; padding: 15px; background: #e8f5e9; border-left: 4px solid #28a745; border-radius: 4px;">
<h4 style="margin-top: 0;">📊 Summary</h4>
<?php
$successCount = 0;
$failCount = 0;
$totalReviews = 0;
$totalRating = 0;
$ratingCount = 0;
foreach ($linkList as $link) {
$result = $rmController->getReviewDetails($link['type'], $link['url']);
if ($result['status']) {
$successCount++;
$totalReviews += $result['reviews'];
if ($result['rating'] > 0) {
$totalRating += $result['rating'];
$ratingCount++;
}
} else {
$failCount++;
}
}
$avgRating = $ratingCount > 0 ? round($totalRating / $ratingCount, 2) : 0;
?>
<p>
<strong>Total Tests:</strong> <?php echo count($linkList); ?><br>
<strong style="color: #28a745;">Successful:</strong> <?php echo $successCount; ?><br>
<strong style="color: #dc3545;">Failed:</strong> <?php echo $failCount; ?><br>
<strong>Total Reviews Found:</strong> <?php echo number_format($totalReviews); ?><br>
<strong>Average Rating:</strong> <?php echo $avgRating; ?> / 5.0
</p>
</div>
<?php endif; ?>
<div style="margin-top: 20px; padding: 15px; background: #fff3cd; border: 1px solid #ffc107; border-radius: 4px;">
<strong>ℹ️ Note:</strong> This test page calls the <code>getReviewDetails()</code> method from
<code>ReviewManagerController</code> which fetches live data from review platforms.
Results may vary depending on:
<ul>
<li>Network connectivity and firewall settings</li>
<li>Review platform availability and anti-scraping measures</li>
<li>Correctness of regex patterns in the crawl_engine_category table</li>
<li>Rate limiting by review platforms</li>
<li>Changes in page structure by the platforms</li>
</ul>
<p><strong>Supported Platforms:</strong></p>
<ul>
<li>🔍 <strong>Google My Business</strong> - Business reviews and ratings</li>
<li>📍 <strong>Yelp</strong> - Local business reviews</li>
<li>⭐ <strong>Trustpilot</strong> - Company reviews and trust scores</li>
<li>✈️ <strong>TripAdvisor</strong> - Travel and hospitality reviews</li>
</ul>
</div>
</div>
</body>
</html>