Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
103 - 1
<?php
2
 
3
/***************************************************************************
4
 *   Copyright (C) 2009-2011 by Geo Varghese(www.seopanel.in)  	   *
5
 *   sendtogeo@gmail.com   												   *
6
 *                                                                         *
7
 *   This program is free software; you can redistribute it and/or modify  *
8
 *   it under the terms of the GNU General Public License as published by  *
9
 *   the Free Software Foundation; either version 2 of the License, or     *
10
 *   (at your option) any later version.                                   *
11
 *                                                                         *
12
 *   This program is distributed in the hope that it will be useful,       *
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
15
 *   GNU General Public License for more details.                          *
16
 *                                                                         *
17
 *   You should have received a copy of the GNU General Public License     *
18
 *   along with this program; if not, write to the                         *
19
 *   Free Software Foundation, Inc.,                                       *
20
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
21
 ***************************************************************************/
22
 
23
# class defines all rank controller functions
24
class RankController extends Controller{
25
 
26
	var $colList = array('moz' => 'moz_rank', 'alexa' => 'alexa_rank', 'domain_authority' => 'domain_authority', 'page_authority' => 'page_authority');
27
 
28
	# func to show quick rank checker
29
	function showQuickRankChecker() {
30
 
31
		$this->render('rank/showquickrank');
32
	}
33
 
34
	function findQuickRank($searchInfo) {
35
		$urlList = explode("\n", $searchInfo['website_urls']);
36
		$list = array();
37
		$i = 1;
38
		foreach ($urlList as $url) {
39
		    $url = sanitizeData($url);
40
			if(!preg_match('/\w+/', $url)) continue;
41
			if (SP_DEMO) {
42
			    if ($i++ > 10) break;
43
			}
44
 
45
			$url = addHttpToUrl($url);
46
			$list[] = str_replace(array("\n", "\r", "\r\n", "\n\r"), "", trim($url));
47
		}
48
 
49
		$mozCtrler = new MozController();
50
		$mozRankList = $mozCtrler->__getMozRankInfo($list);
51
		/*mozRankList = $this->__getMozRank($list);*/
52
		$this->set('mozRankList', $mozRankList);
53
 
54
		$this->set('list', $list);
55
		$this->render('rank/findquickrank');
56
	}
57
 
58
	function printGooglePageRank($url){
59
		$pageRank = $this->__getGooglePageRank($url);
60
		if($pageRank >= 0){
61
			$imageUrl = SP_IMGPATH."/pr/pr".$pageRank.".gif";
62
		}else{
63
			$imageUrl = SP_IMGPATH."/pr/pr.gif";
64
		}
65
 
66
		print "<img src='$imageUrl'>";
67
	}
68
 
69
	function printMOZRank($url){
70
		$pageRank = $this->__getMozRank($url);
71
		if($pageRank >= 0){
72
			$imageUrl = SP_IMGPATH."/pr/pr".$pageRank.".gif";
73
		}else{
74
			$imageUrl = SP_IMGPATH."/pr/pr.gif";
75
		}
76
 
77
		print "<img src='$imageUrl'>";
78
	}
79
 
80
	function __getGooglePageRank ($url) {
81
 
82
		return 0;
83
 
84
		// commented due to gooogle stops this service
85
		/*
86
	    if (SP_DEMO && !empty($_SERVER['REQUEST_METHOD'])) return 0;
87
	    $websiteUrl =  $url;
88
		$url = "http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=".$this->CheckHash($this->hashURL($url))."&features=Rank&q=info:".$url."&num=100&filter=0";
89
		$ret = $this->spider->getContent($url);
90
		$rank = 0;
91
 
92
		// parse rank from the page
93
		if (!empty($ret['page'])) {
94
			if (preg_match('/Rank_([0-9]+):([0-9]+):([0-9]+)/si', $ret['page'], $matches) ) {
95
				$rank = empty($matches[3]) ? 0 : $matches[3];
96
			} else {
97
				$crawlInfo['crawl_status'] = 0;
98
				$crawlInfo['log_message'] = SearchEngineController::isCaptchInSearchResults($ret['page']) ? "<font class=error>Captcha found</font> in search result page" : "Regex not matched error occured while parsing search results!";
99
			}
100
		}
101
 
102
		// update crawl log
103
		$crawlLogCtrl = new CrawlLogController();
104
		$crawlInfo['crawl_type'] = 'rank';
105
		$crawlInfo['ref_id'] = $websiteUrl;
106
		$crawlInfo['subject'] = "google";
107
		$crawlLogCtrl->updateCrawlLog($ret['log_id'], $crawlInfo);
108
 
109
		return $rank;
110
		*/
111
	}
112
 
113
	function printAlexaRank($url){
114
		$alexaRank = $this->__getAlexaRank($url);
115
		$imageUrl = SP_WEBPATH."/rank.php?sec=alexaimg&rank=$alexaRank";
116
 
117
		print "<img src='$imageUrl'>";
118
	}
119
 
120
	function printAlexaRankImg($alexaRank) {
121
		$rankImage = SP_IMGPATH."/alexa-rank.jpeg";
122
 
123
		$im = imagecreatefromjpeg ($rankImage);
124
		$textColor = imagecolorallocate($im, 0, 0, 255);
125
		$width = imagesx($im);
126
		$height = imagesy($im);
127
		$leftTextPos = ( $width - (7 * strlen($alexaRank)) )/2;
128
		imagestring($im, 3, $leftTextPos, 35, $alexaRank, $textColor);
129
 
130
		ob_end_clean();
131
		Header('Content-type: image/jpeg');
132
		imagejpeg($im);
133
		exit;
134
	}
135
 
136
	# alexa_rank
137
	function __getAlexaRank ($url) {
138
	    if (SP_DEMO && !empty($_SERVER['REQUEST_METHOD'])) return 0;
139
	    $websiteUrl =  $url;
140
		$url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url=' . urlencode($url);
141
		$ret = $this->spider->getContent($url);
142
		$rank = 0;
143
 
144
		// parse rank from teh page
145
		if(!empty($ret['page'])){
146
			if (preg_match('/\<popularity url\="(.*?)" TEXT\="([0-9]+)"/si', $ret['page'], $matches) ) {
147
				$rank = empty($matches[2]) ? 0 : $matches[2];
148
			} else {
149
				$crawlInfo['crawl_status'] = 0;
150
				$crawlInfo['log_message'] = SearchEngineController::isCaptchInSearchResults($ret['page']) ? "<font class=error>Captcha found</font> in search result page" : "Regex not matched error occured while parsing search results!";
151
			}
152
 
153
		}
154
 
155
		// update crawl log
156
		$crawlLogCtrl = new CrawlLogController();
157
		$crawlInfo['crawl_type'] = 'rank';
158
		$crawlInfo['ref_id'] = $websiteUrl;
159
		$crawlInfo['subject'] = "alexa";
160
		$crawlLogCtrl->updateCrawlLog($ret['log_id'], $crawlInfo);
161
 
162
		return $rank;
163
	}
164
 
165
	// function to get moz rank
166
	function __getMozRank ($urlList = array(), $accessID = "", $secretKey = "", $returnLog = false) {
167
		$mozRankList = array();
168
 
169
		if (SP_DEMO && !empty($_SERVER['REQUEST_METHOD'])) return $mozRankList;
170
 
171
		if (empty($urlList)) return $mozRankList;
172
 
173
		// Get your access id and secret key here: https://moz.com/products/api/keys
174
		$accessID = !empty($accessID) ? $accessID : SP_MOZ_API_ACCESS_ID;
175
		$secretKey = !empty($secretKey) ? $secretKey : SP_MOZ_API_SECRET;
176
 
177
		// if empty no need to crawl
178
		if (empty($accessID) || empty($secretKey)) return $mozRankList;
179
 
180
		// Set your expires times for several minutes into the future.
181
		// An expires time excessively far in the future will not be honored by the Mozscape API.
182
		$expires = time() + 300;
183
 
184
		// Put each parameter on a new line.
185
		$stringToSign = $accessID."\n".$expires;
186
 
187
		// Get the "raw" or binary output of the hmac hash.
188
		$binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);
189
 
190
		// Base64-encode it and then url-encode that.
191
		$urlSafeSignature = urlencode(base64_encode($binarySignature));
192
 
193
		// Add up all the bit flags you want returned.
194
		// Learn more here: https://moz.com/help/guides/moz-api/mozscape/api-reference/url-metrics
195
		$cols = "16384";
196
 
197
		// Put it all together and you get your request URL.
198
		$requestUrl = SP_MOZ_API_LINK . "/url-metrics/?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
199
 
200
		// Put your URLS into an array and json_encode them.
201
		$encodedDomains = json_encode($urlList);
202
 
203
		$spider = new Spider();
204
		$spider->_CURLOPT_POSTFIELDS = $encodedDomains;
205
		$ret = $spider->getContent($requestUrl);
206
 
207
		// parse rank from the page
208
		if (!empty($ret['page'])) {
209
			$rankList = json_decode($ret['page']);
210
 
211
			// if no errors occured
212
			if (empty($rankList->error_message)) {
213
 
214
				// loop through rank list
215
				foreach ($rankList as $rankInfo) {
216
					$mozRankList[] = round($rankInfo->umrp, 2);
217
				}
218
 
219
			} else {
220
				$crawlInfo['crawl_status'] = 0;
221
				$crawlInfo['log_message'] = $rankList->error_message;
222
			}
223
 
224
		} else {
225
			$crawlInfo['crawl_status'] = 0;
226
			$crawlInfo['log_message'] = $ret['errmsg'];
227
		}
228
 
229
		// update crawl log
230
		$crawlLogCtrl = new CrawlLogController();
231
		$crawlInfo['crawl_type'] = 'rank';
232
		$crawlInfo['ref_id'] = $encodedDomains;
233
		$crawlInfo['subject'] = "moz";
234
		$crawlLogCtrl->updateCrawlLog($ret['log_id'], $crawlInfo);
235
 
236
		return $returnLog ? array($mozRankList, $crawlInfo) : $mozRankList;
237
	}
238
 
239
 
240
	function strToNum($Str, $Check, $Magic) {
241
		$Int32Unit = 4294967296;
242
		$length = strlen($Str);
243
		for ($i = 0; $i < $length; $i++) {
244
			$Check *= $Magic;
245
			if ($Check >= $Int32Unit) {
246
				$Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
247
				$Check = ($Check < -2147483648)? ($Check + $Int32Unit) : $Check;
248
			}
249
			$Check += ord($Str{$i});
250
		}
251
		return $Check;
252
	}
253
 
254
	function hashURL($String) {
255
		$Check1 = $this->strToNum($String, 0x1505, 0x21);
256
		$Check2 = $this->strToNum($String, 0, 0x1003F);
257
 
258
		$Check1 >>= 2;
259
		$Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
260
		$Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
261
		$Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);
262
 
263
		$T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F );
264
		$T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );
265
 
266
		return ($T1 | $T2);
267
	}
268
 
269
	function checkHash($Hashnum) {
270
		$CheckByte = 0;
271
		$Flag = 0;
272
 
273
		$HashStr = sprintf('%u', $Hashnum) ;
274
		$length = strlen($HashStr);
275
 
276
		for ($i = $length - 1; $i >= 0; $i --) {
277
			$Re = $HashStr{$i};
278
			if (1 === ($Flag % 2)) {
279
				$Re += $Re;
280
				$Re = (int)($Re / 10) + ($Re % 10);
281
			}
282
			$CheckByte += $Re;
283
			$Flag ++;
284
		}
285
 
286
		$CheckByte %= 10;
287
		if (0!== $CheckByte) {
288
			$CheckByte = 10 - $CheckByte;
289
			if (1 === ($Flag % 2) ) {
290
				if (1 === ($CheckByte % 2)) {$CheckByte += 9;}
291
				$CheckByte >>= 1;
292
			}
293
		}
294
 
295
		return '7'.$CheckByte.$HashStr;
296
	}
297
 
298
	# func to show genearte reports interface
299
	function showGenerateReports($searchInfo = '') {
300
 
301
		$userId = isLoggedIn();
302
		$websiteController = New WebsiteController();
303
		$websiteList = $websiteController->__getAllWebsites($userId, true);
304
		$this->set('websiteList', $websiteList);
305
 
306
		$this->render('rank/generatereport');
307
	}
308
 
309
	# func to generate reports
310
	function generateReports( $searchInfo='' ) {
311
 
312
		$userId = isLoggedIn();
313
		$websiteId = empty ($searchInfo['website_id']) ? '' : intval($searchInfo['website_id']);
314
 
315
		$sql = "select id,url from websites where status=1";
316
		if(!empty($userId) && !isAdmin()) $sql .= " and user_id=$userId";
317
		if(!empty($websiteId)) $sql .= " and id=$websiteId";
318
		$sql .= " order by name";
319
		$websiteList = $this->db->select($sql);
320
 
321
		if(count($websiteList) <= 0){
322
			echo "<p class='note'>".$_SESSION['text']['common']['nowebsites']."!</p>";
323
			exit;
324
		}
325
 
326
		$urlList = array();
327
		foreach ($websiteList as $websiteInfo) {
328
			$urlList[] = addHttpToUrl($websiteInfo['url']);
329
		}
330
 
331
		// get moz ranks
332
		/*$mozRankList = $this->__getMozRank($urlList);*/
333
 
334
		$mozCtrler = new MozController();
335
		$mozRankList = $mozCtrler->__getMozRankInfo($urlList);
336
 
337
		// loop through each websites
338
		foreach ( $websiteList as $i => $websiteInfo ) {
339
			$websiteUrl = addHttpToUrl($websiteInfo['url']);
340
			$websiteInfo['alexaRank'] = $this->__getAlexaRank($websiteUrl);
341
			$websiteInfo['moz_rank'] = !empty($mozRankList[$i]['moz_rank']) ? $mozRankList[$i]['moz_rank'] : 0;
342
			$websiteInfo['domain_authority'] = !empty($mozRankList[$i]['domain_authority']) ? $mozRankList[$i]['domain_authority'] : 0;
343
			$websiteInfo['page_authority'] = !empty($mozRankList[$i]['page_authority']) ? $mozRankList[$i]['page_authority'] : 0;
344
 
345
			$this->saveRankResults($websiteInfo, true);
346
			echo "<p class='note notesuccess'>".$this->spTextRank['Saved rank results of']." <b>$websiteUrl</b>.....</p>";
347
		}
348
	}
349
 
350
	# function to save rank details
351
	function saveRankResults($matchInfo, $remove=false) {
352
		$resultDate = date('Y-m-d');
353
 
354
		if($remove){
355
			$sql = "delete from rankresults where website_id={$matchInfo['id']} and result_date='$resultDate'";
356
			$this->db->query($sql);
357
		}
358
 
359
		$mozRank = floatval($matchInfo['moz_rank']);
360
		$domainAuthority = floatval($matchInfo['domain_authority']);
361
		$pageAuthority = floatval($matchInfo['page_authority']);
362
		$sql = "insert into rankresults(website_id, moz_rank, alexa_rank, domain_authority, page_authority, result_date)
363
			values({$matchInfo['id']}, $mozRank, {$matchInfo['alexaRank']},	$domainAuthority, $pageAuthority, '$resultDate')";
364
		$this->db->query($sql);
365
	}
366
 
367
	# function check whether reports already saved
368
	function isReportsExists($websiteId, $time) {
369
		$resultDate = date('Y-m-d', $time);
370
	    $sql = "select website_id from rankresults where website_id=$websiteId and result_date='$resultDate'";
371
	    $info = $this->db->select($sql, true);
372
	    return empty($info['website_id']) ? false : true;
373
	}
374
 
375
	# func to show reports
376
	function showReports($searchInfo = '') {
377
 
378
		$userId = isLoggedIn();
379
		if (!empty ($searchInfo['from_time'])) {
380
			$fromTime = $searchInfo['from_time'];
381
		} else {
382
			$fromTime = date('Y-m-d', strtotime('-30 days'));
383
		}
384
 
385
		if (!empty ($searchInfo['to_time'])) {
386
			$toTime = $searchInfo['to_time'];
387
		} else {
388
			$toTime = date('Y-m-d');
389
		}
390
 
391
		$fromTime = addslashes($fromTime);
392
		$toTime = addslashes($toTime);
393
		$this->set('fromTime', $fromTime);
394
		$this->set('toTime', $toTime);
395
 
396
		$websiteController = New WebsiteController();
397
		$websiteList = $websiteController->__getAllWebsites($userId, true);
398
		$this->set('websiteList', $websiteList);
399
		$websiteId = empty ($searchInfo['website_id']) ? $websiteList[0]['id'] : intval($searchInfo['website_id']);
400
		$this->set('websiteId', $websiteId);
401
 
402
		$conditions = empty ($websiteId) ? "" : " and s.website_id=$websiteId";
403
		$sql = "select s.* ,w.name from rankresults s,websites w  where s.website_id=w.id
404
		and result_date >= '$fromTime' and result_date <= '$toTime' $conditions order by result_date";
405
		$reportList = $this->db->select($sql);
406
 
407
		$i = 0;
408
		$colList = $this->colList;
409
		foreach ($colList as $col => $dbCol) {
410
			$prevRank[$col] = 0;
411
		}
412
 
413
		# loop throgh rank
414
		foreach ($reportList as $key => $repInfo) {
415
			foreach ($colList as $col => $dbCol) {
416
				$rankDiff[$col] = '';
417
			}
418
 
419
			foreach ($colList as $col => $dbCol) {
420
				if ($i > 0) {
421
					$signVal = -1;
422
					$greaterClass = 'green';
423
					$lessClass = 'red';
424
					if($col == 'alexa'){
425
						$signVal = 1;
426
						$greaterClass = 'green';
427
						$lessClass = 'red';
428
					}
429
					$rankDiff[$col] = ($prevRank[$col] - $repInfo[$dbCol]) * $signVal;
430
					if ($rankDiff[$col] > 0) {
431
						$rankDiff[$col] = "<font class='$greaterClass'>($rankDiff[$col])</font>";
432
					}elseif ($rankDiff[$col] < 0) {
433
						$rankDiff[$col] = "<font class='$lessClass'>($rankDiff[$col])</font>";
434
					}
435
				}
436
				$reportList[$key]['rank_diff_'.$col] = empty ($rankDiff[$col]) ? '' : $rankDiff[$col];
437
			}
438
 
439
			foreach ($colList as $col => $dbCol) {
440
				$prevRank[$col] = $repInfo[$dbCol];
441
			}
442
 
443
			$i++;
444
		}
445
 
446
		$this->set('list', array_reverse($reportList, true));
447
		$this->render('rank/rankreport');
448
	}
449
 
450
 
451
	# func to show reports for a particular website
452
	function __getWebsiteRankReport($websiteId, $fromTime, $toTime) {
453
 
454
		$fromTimeLabel = date('Y-m-d', $fromTime);
455
		$toTimeLabel = date('Y-m-d', $toTime);
456
		$sql = "select s.* ,w.name
457
				from rankresults s,websites w
458
				where s.website_id=w.id
459
				and s.website_id=$websiteId
460
				and (result_date='$fromTimeLabel' or result_date='$toTimeLabel')
461
				order by result_date DESC
462
				Limit 0, 2";
463
		$reportList = $this->db->select($sql);
464
		$reportList = array_reverse($reportList);
465
 
466
		$i = 0;
467
		$colList = $this->colList;
468
		foreach ($colList as $col => $dbCol) {
469
			$prevRank[$col] = 0;
470
		}
471
 
472
		# loop throgh rank
473
		foreach ($reportList as $key => $repInfo) {
474
 
475
			foreach ($colList as $col => $dbCol) {
476
				$rankDiff[$col] = '';
477
			}
478
 
479
			foreach ($colList as $col => $dbCol) {
480
 
481
				if ($i > 0) {
482
					$signVal = -1;
483
					$greaterClass = 'green';
484
					$lessClass = 'red';
485
					if($col == 'alexa'){
486
						$signVal = 1;
487
						$greaterClass = 'green';
488
						$lessClass = 'red';
489
					}
490
 
491
					$rankDiff[$col] = ($prevRank[$col] - $repInfo[$dbCol]) * $signVal;
492
 
493
					if ($rankDiff[$col] > 0) {
494
						$rankDiff[$col] = "<font class='$greaterClass'>($rankDiff[$col])</font>";
495
					} elseif ($rankDiff[$col] < 0) {
496
						$rankDiff[$col] = "<font class='$lessClass'>($rankDiff[$col])</font>";
497
					}
498
				}
499
 
500
				$reportList[$key]['rank_diff_'.$col] = empty ($rankDiff[$col]) ? '' : $rankDiff[$col];
501
			}
502
 
503
			foreach ($colList as $col => $dbCol) {
504
				$prevRank[$col] = $repInfo[$dbCol];
505
			}
506
 
507
			$i++;
508
		}
509
 
510
		$reportList = array_reverse(array_slice($reportList, count($reportList) - 1));
511
		return $reportList;
512
	}
513
 
514
	# func to show graphical reports
515
	function showGraphicalReports($searchInfo = '') {
516
 
517
		$userId = isLoggedIn();
518
		$fromTime = !empty($searchInfo['from_time']) ? $searchInfo['from_time'] : date('Y-m-d', strtotime('-30 days'));
519
		$toTime = !empty ($searchInfo['to_time']) ? $searchInfo['to_time'] : date("Y-m-d");
520
		$this->set('fromTime', $fromTime);
521
		$this->set('toTime', $toTime);
522
 
523
        $websiteController = New WebsiteController();
524
        $websiteList = $websiteController->__getAllWebsites($userId, true);
525
        $this->set('websiteList', $websiteList);
526
        $websiteId = empty ($searchInfo['website_id']) ? $websiteList[0]['id'] : intval($searchInfo['website_id']);
527
        $this->set('websiteId', $websiteId);
528
 
529
        $searchEngine = !empty($searchInfo['search_engine']) ? $searchInfo['search_engine'] : "moz";
530
        $this->set('searchEngine', $searchEngine);
531
 
532
        $conditions = empty($websiteId) ? "" : " and s.website_id=$websiteId";
533
        $sql = "select s.* ,w.name from rankresults s,websites w  where s.website_id=w.id
534
        and result_date >= '$fromTime' and result_date <= '$toTime' $conditions order by result_date";
535
        $reportList = $this->db->select($sql);
536
 
537
        $colLabelList = array(
538
        	'moz_rank' => $_SESSION['text']['common']['MOZ Rank'],
539
        	'alexa_rank' => $_SESSION['text']['common']['Alexa Rank'],
540
        	'domain_authority' => $_SESSION['text']['common']['Domain Authority'],
541
        	'page_authority' => $_SESSION['text']['common']['Page Authority'],
542
        );
543
 
544
        // loop through col list
545
        $colList = array();
546
        foreach ($this->colList as $seId => $seVal) {
547
 
548
        	// if slected i search engine
549
        	if ($searchEngine == 'alexa') {
550
 
551
        		if ($seId == 'alexa') {
552
        			$colList[$seVal] = $colLabelList[$seVal];
553
        		}
554
 
555
        	} else {
556
 
557
        		if ($seId != 'alexa') {
558
        			$colList[$seVal] = $colLabelList[$seVal];
559
        		}
560
 
561
        	}
562
 
563
        }
564
 
565
		// if reports not empty
566
		if (!empty($reportList)) {
567
 
568
			$dataArr = "['Date', '" . implode("', '", array_values($colList)) . "']";
569
 
570
	        // loop through data list
571
	        foreach ($reportList as $dataInfo) {
572
 
573
	            $valStr = "";
574
	            foreach ($colList as $seId => $seVal) {
575
	                $valStr .= ", ";
576
	                $valStr .= !empty($dataInfo[$seId])    ? $dataInfo[$seId] : 0;
577
	            }
578
 
579
	            $dataArr .= ", ['{$dataInfo['result_date']}' $valStr]";
580
	        }
581
 
582
	        // if alexa, use reverse ranking
583
	        if ($searchEngine == 'alexa') {
584
	        	$this->set('reverseDir', true);
585
	        }
586
 
587
	        $this->set('dataArr', $dataArr);
588
	        $this->set('graphTitle', $this->spTextTools['Rank Reports']);
589
	        $graphContent = $this->getViewContent('report/graph');
590
 
591
		} else {
592
			$graphContent = showErrorMsg($_SESSION['text']['common']['No Records Found'], false, true);
593
		}
594
 
595
		// get graph content
596
		$this->set('graphContent', $graphContent);
597
		$this->render('rank/graphicalreport');
598
	}
599
 
600
}
601
?>