function formatUrl($url) { $scheme = ""; if (stristr($url, 'http://')) { $scheme = "http://"; } elseif (stristr($url, 'https://')) { $scheme = "https://"; } $url = str_replace(array('http://', 'https://', '"', '"'), '', $url); $url = preg_replace('/\\/{2,}/', '/', $url); $url = preg_replace('/&{2,}/', '&', $url); $url = preg_replace('/#{2,}/', '#', $url); $url = Spider::removeTrailingSlash($url); return $scheme . $url; }
function showReports($searchInfo = '') { $userId = isLoggedIn(); if (!empty($searchInfo['from_time'])) { $fromTime = strtotime($searchInfo['from_time'] . ' 00:00:00'); } else { $fromTime = @mktime(0, 0, 0, date('m'), date('d') - 30, date('Y')); } if (!empty($searchInfo['to_time'])) { $toTime = strtotime($searchInfo['to_time'] . ' 23:59:59'); } else { $toTime = @mktime(); } $this->set('fromTime', date('Y-m-d', $fromTime)); $this->set('toTime', date('Y-m-d', $toTime)); $websiteController = new WebsiteController(); $websiteList = $websiteController->__getAllWebsites($userId, true); $this->set('websiteList', $websiteList); $websiteId = empty($searchInfo['website_id']) ? $websiteList[0]['id'] : intval($searchInfo['website_id']); $this->set('websiteId', $websiteId); $conditions = empty($websiteId) ? "" : " and s.website_id={$websiteId}"; $sql = "select s.* ,w.name\r\n\t\t\t\t\t\t\t\tfrom backlinkresults s,websites w \r\n\t\t\t\t\t\t\t\twhere s.website_id=w.id \r\n\t\t\t\t\t\t\t\tand result_time>= {$fromTime} and result_time<={$toTime} {$conditions} \r\n\t\t\t\t\t\t\t\torder by result_time"; $reportList = $this->db->select($sql); $i = 0; $colList = $this->colList; foreach ($colList as $col => $dbCol) { $prevRank[$col] = 0; } # loop throgh rank foreach ($reportList as $key => $repInfo) { foreach ($colList as $col => $dbCol) { $rankDiff[$col] = ''; } foreach ($colList as $col => $dbCol) { if ($i > 0) { $rankDiff[$col] = ($prevRank[$col] - $repInfo[$dbCol]) * -1; if ($rankDiff[$col] > 0) { $rankDiff[$col] = "<font class='green'>({$rankDiff[$col]})</font>"; } elseif ($rankDiff[$col] < 0) { $rankDiff[$col] = "<font class='red'>({$rankDiff[$col]})</font>"; } } $reportList[$key]['rank_diff_' . $col] = empty($rankDiff[$col]) ? '' : $rankDiff[$col]; } foreach ($colList as $col => $dbCol) { $prevRank[$col] = $repInfo[$dbCol]; } $i++; } $websiteInfo = $websiteController->__getWebsiteInfo($websiteId); $websiteUrl = @Spider::removeTrailingSlash(formatUrl($websiteInfo['url'])); $websiteUrl = urldecode($websiteUrl); $this->set('directLinkList', array('google' => $this->backUrlList['google'] . $websiteUrl, 'msn' => $this->backUrlList['msn'] . $websiteUrl, 'alexa' => $this->backUrlList['alexa'] . $websiteUrl)); $this->set('list', array_reverse($reportList, true)); $this->render('backlink/backlinkreport'); }
function __getProjectInfo($projectId) { $sql = "select p.*,w.url,w.name from auditorprojects p,websites w where p.website_id=w.id and p.id={$projectId}"; $info = $this->db->select($sql, true); $info['url'] = Spider::removeTrailingSlash($info['url']); return $info; }