$rightBotClass = "td_br_right"; } ?> <tr class="<?php echo $class; ?> "> <td class="<?php echo $leftBotClass; ?> "><?php echo $listInfo['id']; ?> </td> <td class="td_br_right left"><a target="_blank" href="<?php echo addHttpToUrl($listInfo['directory_name']); ?> "><?php echo $listInfo['directory_name']; ?> </a></td> <td class="td_br_right"><img src="<?php echo SP_IMGPATH; ?> /pr/pr<?php echo $listInfo['google_pagerank']; ?> .gif"></td> <!-- <td class="td_br_right" style="color: red;"><?php echo $listInfo['coupon_code'];
function rankCheckerCron($websiteId) { include_once SP_CTRLPATH . "/rank.ctrl.php"; $this->debugMsg("Starting Rank Checker cron for website: {$this->websiteInfo['name']}....<br>\n"); $rankCtrler = new RankController(); $websiteInfo = $this->websiteInfo; if (SP_MULTIPLE_CRON_EXEC && $rankCtrler->isReportsExists($websiteInfo['id'], $this->timeStamp)) { return; } $websiteUrl = addHttpToUrl($websiteInfo['url']); $websiteInfo['googlePagerank'] = $rankCtrler->__getGooglePageRank($websiteUrl); $websiteInfo['alexaRank'] = $rankCtrler->__getAlexaRank($websiteUrl); $rankCtrler->saveRankResults($websiteInfo, true); $this->debugMsg("Saved rank results of <b>{$websiteUrl}</b>.....<br>\n"); }
function generateReports($searchInfo = '') { $userId = isLoggedIn(); $websiteId = empty($searchInfo['website_id']) ? '' : $searchInfo['website_id']; $sql = "select id,url from websites where status=1"; if (!empty($userId) && !isAdmin()) { $sql .= " and user_id={$userId}"; } if (!empty($websiteId)) { $sql .= " and id={$websiteId}"; } $sql .= " order by name"; $websiteList = $this->db->select($sql); if (count($websiteList) <= 0) { echo "<p class='note'>No Websites found!!!</p>"; exit; } # loop through each websites foreach ($websiteList as $websiteInfo) { $websiteUrl = addHttpToUrl($websiteInfo['url']); $websiteInfo['googlePagerank'] = $this->__getGooglePageRank($websiteUrl); $websiteInfo['alexaRank'] = $this->__getAlexaRank($websiteUrl); $this->saveRankResults($websiteInfo, true); echo "<p class='note notesuccess'>Saved rank results of <b>{$websiteUrl}</b>.....</p>"; } }
function generateReports($searchInfo = '') { $userId = isLoggedIn(); $websiteId = empty($searchInfo['website_id']) ? '' : intval($searchInfo['website_id']); $sql = "select id,url from websites where status=1"; if (!empty($userId) && !isAdmin()) { $sql .= " and user_id={$userId}"; } if (!empty($websiteId)) { $sql .= " and id={$websiteId}"; } $sql .= " order by name"; $websiteList = $this->db->select($sql); if (count($websiteList) <= 0) { echo "<p class='note'>" . $_SESSION['text']['common']['nowebsites'] . "!</p>"; exit; } # loop through each websites foreach ($websiteList as $websiteInfo) { $this->url = $websiteUrl = addHttpToUrl($websiteInfo['url']); foreach ($this->colList as $col => $dbCol) { $websiteInfo[$col] = $this->__getBacklinks($col); } $this->saveRankResults($websiteInfo, true); echo "<p class='note notesuccess'>" . $this->spTextBack['Saved backlink results of'] . " <b>{$websiteUrl}</b>.....</p>"; } }
function updateWebsite($listInfo, $apiCall = false) { // check whether admin or api calll if (isAdmin() || $apiCall) { $userId = empty($listInfo['user_id']) ? isLoggedIn() : $listInfo['user_id']; } else { $userId = isLoggedIn(); } $listInfo['id'] = intval($listInfo['id']); $this->set('post', $listInfo); $errMsg['name'] = formatErrorMsg($this->validate->checkBlank($listInfo['name'])); $errMsg['url'] = formatErrorMsg($this->validate->checkBlank($listInfo['url'])); $listInfo['url'] = addHttpToUrl($listInfo['url']); $statusVal = isset($listInfo['status']) ? "status = " . intval($listInfo['status']) . "," : ""; // verify the form if (!$this->validate->flagErr) { if ($listInfo['name'] != $listInfo['oldName']) { if ($this->__checkName($listInfo['name'], $userId)) { $errMsg['name'] = formatErrorMsg($this->spTextWeb['Website already exist']); $this->validate->flagErr = true; } } if ($this->__checkWebsiteUrl($listInfo['url'], $listInfo['id'])) { $errMsg['url'] = formatErrorMsg($this->spTextWeb['Website already exist']); $this->validate->flagErr = true; } if (!$this->validate->flagErr) { $sql = "update websites set\n\t\t\t\t\t\tname = '" . addslashes($listInfo['name']) . "',\n\t\t\t\t\t\turl = '" . addslashes($listInfo['url']) . "',\n\t\t\t\t\t\tuser_id = {$userId},\n\t\t\t\t\t\ttitle = '" . addslashes($listInfo['title']) . "',\n\t\t\t\t\t\tdescription = '" . addslashes($listInfo['description']) . "',\n\t\t\t\t\t\t{$statusVal}\n\t\t\t\t\t\tkeywords = '" . addslashes($listInfo['keywords']) . "'\n\t\t\t\t\t\twhere id={$listInfo['id']}"; $this->db->query($sql); // if api call if ($apiCall) { return array('success', 'Successfully updated website'); } else { $this->listWebsites(); exit; } } } // if api call if ($apiCall) { return array('error', $errMsg); } else { $this->set('errMsg', $errMsg); $this->editWebsite($listInfo['id'], $listInfo); } }
function updateWebsite($listInfo) { if (isAdmin()) { $userId = empty($listInfo['user_id']) ? isLoggedIn() : $listInfo['user_id']; } else { $userId = isLoggedIn(); } $listInfo['id'] = intval($listInfo['id']); $this->set('post', $listInfo); $errMsg['name'] = formatErrorMsg($this->validate->checkBlank($listInfo['name'])); $errMsg['url'] = formatErrorMsg($this->validate->checkBlank($listInfo['url'])); $listInfo['url'] = addHttpToUrl($listInfo['url']); if (!$this->validate->flagErr) { if ($listInfo['name'] != $listInfo['oldName']) { if ($this->__checkName($listInfo['name'], $userId)) { $errMsg['name'] = formatErrorMsg($this->spTextWeb['Website already exist']); $this->validate->flagErr = true; } } if ($this->__checkWebsiteUrl($listInfo['url'], $listInfo['id'])) { $errMsg['url'] = formatErrorMsg($this->spTextWeb['Website already exist']); $this->validate->flagErr = true; } if (!$this->validate->flagErr) { $sql = "update websites set\n\t\t\t\t\t\tname = '" . addslashes($listInfo['name']) . "',\n\t\t\t\t\t\turl = '" . addslashes($listInfo['url']) . "',\n\t\t\t\t\t\tuser_id = {$userId},\n\t\t\t\t\t\ttitle = '" . addslashes($listInfo['title']) . "',\n\t\t\t\t\t\tdescription = '" . addslashes($listInfo['description']) . "',\n\t\t\t\t\t\tkeywords = '" . addslashes($listInfo['keywords']) . "'\n\t\t\t\t\t\twhere id={$listInfo['id']}"; $this->db->query($sql); $this->listWebsites(); exit; } } $this->set('errMsg', $errMsg); $this->editWebsite($listInfo['id'], $listInfo); }
function crawlKeyword($keywordInfo, $seId = '', $cron = false, $removeDuplicate = true) { $crawlResult = array(); $websiteUrl = formatUrl($keywordInfo['url'], false); if (empty($websiteUrl)) { return $crawlResult; } if (empty($keywordInfo['name'])) { return $crawlResult; } $time = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $seList = explode(':', $keywordInfo['searchengines']); foreach ($seList as $seInfoId) { if (!empty($seId) && $seInfoId != $seId) { continue; } $this->seFound = 1; // if execution from cron check whether cron already executed /*if ($cron) { if (SP_MULTIPLE_CRON_EXEC && $this->isCronExecuted($keywordInfo['id'], $seInfoId, $time)) continue; }*/ $searchUrl = str_replace('[--keyword--]', urlencode(stripslashes($keywordInfo['name'])), $this->seList[$seInfoId]['url']); $searchUrl = str_replace('[--lang--]', $keywordInfo['lang_code'], $searchUrl); $searchUrl = str_replace('[--country--]', $keywordInfo['country_code'], $searchUrl); if (empty($keywordInfo['country_code']) && stristr($searchUrl, '&cr=country&')) { $searchUrl = str_replace('&cr=country&', '&cr=&', $searchUrl); } $seUrl = str_replace('[--start--]', $this->seList[$seInfoId]['start'], $searchUrl); // if google add special parameters $isGoogle = false; if (stristr($this->seList[$seInfoId]['url'], 'google')) { $isGoogle = true; $seUrl .= "&ie=utf-8&pws=0&gl=" . $keywordInfo['country_code']; } if (!empty($this->seList[$seInfoId]['cookie_send'])) { $this->seList[$seInfoId]['cookie_send'] = str_replace('[--lang--]', $keywordInfo['lang_code'], $this->seList[$seInfoId]['cookie_send']); $this->spider->_CURLOPT_COOKIE = $this->seList[$seInfoId]['cookie_send']; } $result = $this->spider->getContent($seUrl); $pageContent = $this->formatPageContent($seInfoId, $result['page']); $crawlLogCtrl = new CrawlLogController(); $crawlInfo['crawl_type'] = 'keyword'; $crawlInfo['ref_id'] = empty($keywordInfo['id']) ? $keywordInfo['name'] : $keywordInfo['id']; $crawlInfo['subject'] = $seInfoId; $seStart = $this->seList[$seInfoId]['start'] + $this->seList[$seInfoId]['start_offset']; while (empty($result['error']) && $seStart < $this->seList[$seInfoId]['max_results']) { $logId = $result['log_id']; $crawlLogCtrl->updateCrawlLog($logId, $crawlInfo); sleep(SP_CRAWL_DELAY); $seUrl = str_replace('[--start--]', $seStart, $searchUrl); $result = $this->spider->getContent($seUrl); $pageContent .= $this->formatPageContent($seInfoId, $result['page']); $seStart += $this->seList[$seInfoId]['start_offset']; } # to check whether utf8 conversion needed if (!empty($this->seList[$seInfoId]['encoding'])) { $pageContent = mb_convert_encoding($pageContent, "UTF-8", $this->seList[$seInfoId]['encoding']); } $crawlStatus = 0; if (empty($result['error'])) { // to update cron that report executed for akeyword on a search engine if (SP_MULTIPLE_CRON_EXEC && $cron) { $this->saveCronTrackInfo($keywordInfo['id'], $seInfoId, $time); } if (preg_match_all($this->seList[$seInfoId]['regex'], $pageContent, $matches)) { $urlList = $matches[$this->seList[$seInfoId]['url_index']]; $crawlResult[$seInfoId]['matched'] = array(); $rank = 1; $previousDomain = ""; foreach ($urlList as $i => $url) { $url = urldecode(strip_tags($url)); // add special condition for baidu if (stristr($this->seList[$seInfoId]['domain'], "baidu")) { $url = addHttpToUrl($url); $url = str_replace("...", "", $url); } if (!preg_match('/^http:\\/\\/|^https:\\/\\//i', $url)) { continue; } // check for to remove msn ad links in page if (stristr($url, 'r.msn.com')) { continue; } // check to remove duplicates from same domain if google is the search engine if ($removeDuplicate && $isGoogle) { $currentDomain = parse_url($url, PHP_URL_HOST); if ($previousDomain == $currentDomain) { continue; } $previousDomain = $currentDomain; } if ($this->showAll || stristr($url, $websiteUrl)) { if ($this->showAll && stristr($url, $websiteUrl)) { $matchInfo['found'] = 1; } else { $matchInfo['found'] = 0; } $matchInfo['url'] = $url; $matchInfo['title'] = strip_tags($matches[$this->seList[$seInfoId]['title_index']][$i]); $matchInfo['description'] = strip_tags($matches[$this->seList[$seInfoId]['description_index']][$i]); $matchInfo['rank'] = $rank; $crawlResult[$seInfoId]['matched'][] = $matchInfo; } $rank++; } $crawlStatus = 1; } else { // set crawl log info $crawlInfo['crawl_status'] = 0; $crawlInfo['log_message'] = SearchEngineController::isCaptchInSearchResults($pageContent) ? "<font class=error>Captcha found</font> in search result page" : "Regex not matched error occured while parsing search results!"; if (SP_DEBUG) { echo "<p class='note' style='text-align:left;'>Error occured while parsing {$seUrl} " . formatErrorMsg("Regex not matched <br>\n") . "</p>"; } } } else { if (SP_DEBUG) { echo "<p class='note' style='text-align:left;'>Error occured while crawling {$seUrl} " . formatErrorMsg($result['errmsg'] . "<br>\n") . "</p>"; } } $crawlResult[$seInfoId]['status'] = $crawlStatus; sleep(SP_CRAWL_DELAY); // update crawl log $logId = $result['log_id']; $crawlLogCtrl->updateCrawlLog($logId, $crawlInfo); } return $crawlResult; }
function checkDirectoryStatus($dirId, $nodebug = 0) { $dirId = intval($dirId); $dirInfo = $this->getDirectoryInfo($dirId); $active = 0; $captcha = 0; $spider = new Spider(); $ret = $spider->getContent(addHttpToUrl($dirInfo['submit_url'])); $prUpdate = ''; $searchUpdate = ''; $extraValUpdate = ''; if (empty($ret['error']) && !empty($ret['page'])) { $page = $ret['page']; $matches = $this->isCategoryExists($page, $dirInfo['category_col']); $active = empty($matches[0]) ? 0 : 1; $captcha = stristr($page, $dirInfo['captcha_script']) ? 1 : 0; // to check search script if (stristr($page, 'name="search"')) { $searchUpdate = ",search_script='index.php?search=[--keyword--]'"; } // to check the value of the LINK_TYPE if phpld directory if ($dirInfo['script_type_id'] == 1 && preg_match('/name="LINK_TYPE" value="(\\d)"/s', $page)) { $subject = array('LINK_TYPE=reciprocal', 'LINK_TYPE=normal', 'LINK_TYPE=free'); $replace = array('reciprocal=1&LINK_TYPE=1', 'LINK_TYPE=2', 'LINK_TYPE=3'); $dirInfo['extra_val'] = str_replace($subject, $replace, $dirInfo['extra_val']); $extraValUpdate = ",extra_val='{$dirInfo['extra_val']}'"; } if ($this->checkPR) { include_once SP_CTRLPATH . "/rank.ctrl.php"; $rankCtrler = new RankController(); $pagerank = $rankCtrler->__getGooglePageRank($dirInfo['domain']); $prUpdate = ",google_pagerank={$pagerank}"; } } $sql = "update directories set working={$active},is_captcha={$captcha},checked=1 {$prUpdate} {$searchUpdate} {$extraValUpdate} where id={$dirId}"; $this->db->query($sql); if ($nodebug) { $captchaLabel = $captcha ? $_SESSION['text']['common']['Yes'] : $_SESSION['text']['common']['No']; ?> <script type="text/javascript"> document.getElementById('captcha_<?php echo $dirId; ?> ').innerHTML = '<?php echo $captchaLabel; ?> '; </script> <?php if ($this->checkPR) { ?> <script type="text/javascript"> document.getElementById('pr_<?php echo $dirId; ?> ').innerHTML = '<?php echo $pagerank; ?> '; </script> <?php } echo $this->getStatusLink($dirId, $active); } else { echo "<p class='note notesuccess'>Saved status of directory <b>{$dirInfo['domain']}</b>.....</p>"; } }
function checkDirectoryStatus($dirId, $nodebug = 0) { $dirId = intval($dirId); $dirInfo = $this->getDirectoryInfo($dirId); $active = 0; $captcha = 0; $spider = new Spider(); $ret = $spider->getContent(addHttpToUrl($dirInfo['submit_url'])); $prUpdate = ''; if (empty($ret['error']) && !empty($ret['page'])) { $page = $ret['page']; $matches = $this->isCategoryExists($page, $dirInfo['category_col']); $active = empty($matches[0]) ? 0 : 1; $captcha = stristr($page, $dirInfo['captcha_script']) ? 1 : 0; if ($this->checkPR) { include_once SP_CTRLPATH . "/rank.ctrl.php"; $rankCtrler = new RankController(); $pagerank = $rankCtrler->__getGooglePageRank($dirInfo['domain']); $prUpdate = ",google_pagerank={$pagerank}"; } } $sql = "update directories set working={$active},is_captcha={$captcha},checked=1 {$prUpdate} where id={$dirId}"; $this->db->query($sql); if ($nodebug) { $captchaLabel = $captcha ? $_SESSION['text']['common']['Yes'] : $_SESSION['text']['common']['No']; ?> <script type="text/javascript"> document.getElementById('captcha_<?php echo $dirId; ?> ').innerHTML = '<?php echo $captchaLabel; ?> '; </script> <?php if ($this->checkPR) { ?> <script type="text/javascript"> document.getElementById('pr_<?php echo $dirId; ?> ').innerHTML = '<?php echo $pagerank; ?> '; </script> <?php } echo $this->getStatusLink($dirId, $active); } else { echo "<p class='note notesuccess'>Saved status of directory <b>{$dirInfo['domain']}</b>.....</p>"; } }
function checkDirectoryStatus($dirId, $nodebug = 0) { $dirInfo = $this->getDirectoryInfo($dirId); $active = 0; $captcha = 0; $spider = new Spider(); $ret = $spider->getContent(addHttpToUrl($dirInfo['submit_url'])); if (empty($ret['error']) && !empty($ret['page'])) { $page = $ret['page']; $matches = $this->isCategoryExists($page, $dirInfo['category_col']); $active = empty($matches[0]) ? 0 : 1; $captcha = stristr($page, $dirInfo['captcha_script']) ? 1 : 0; } $sql = "update directories set working={$active},is_captcha={$captcha} where id={$dirId}"; $this->db->query($sql); if ($nodebug) { $captchaLabel = $captcha ? "Yes" : "No"; ?> <script type="text/javascript"> document.getElementById('captcha_<?php echo $dirId; ?> ').innerHTML = '<?php echo $captchaLabel; ?> '; </script> <?php echo $this->getStatusLink($dirId, $active); } else { echo "<p class='note notesuccess'>Saved status of directory <b>{$dirInfo['domain']}</b>.....</p>"; } }
function rankCheckerCron($websiteId) { include_once SP_CTRLPATH . "/rank.ctrl.php"; $this->debugMsg("Starting Rank Checker cron for website: {$this->websiteInfo['name']}....<br>\n"); $rankCtrler = new RankController(); $websiteInfo = $this->websiteInfo; $websiteUrl = addHttpToUrl($websiteInfo['url']); $websiteInfo['googlePagerank'] = $rankCtrler->__getGooglePageRank($websiteUrl); $websiteInfo['alexaRank'] = $rankCtrler->__getAlexaRank($websiteUrl); $rankCtrler->saveRankResults($websiteInfo, true); $this->debugMsg("Saved rank results of <b>{$websiteUrl}</b>.....<br>\n"); }