function saveSubmissiondata($submitInfo) { if (empty($submitInfo['website_id'])) { showErrorMsg("Please select a website to proceed!"); } $_SESSION['skipped'][$submitInfo['website_id']] = array(); if (!SP_DEMO) { $errMsg['url'] = formatErrorMsg($this->validate->checkBlank($submitInfo['url'])); $errMsg['owner_name'] = formatErrorMsg($this->validate->checkBlank($submitInfo['owner_name'])); $errMsg['category'] = formatErrorMsg($this->validate->checkBlank($submitInfo['category'])); $errMsg['title'] = formatErrorMsg($this->validate->checkBlank($submitInfo['title'])); $errMsg['description'] = formatErrorMsg($this->validate->checkBlank($submitInfo['description'])); $errMsg['keywords'] = formatErrorMsg($this->validate->checkBlank($submitInfo['keywords'])); $errMsg['owner_email'] = formatErrorMsg($this->validate->checkEmail($submitInfo['owner_email'])); # error occurs if ($this->validate->flagErr) { $this->set('errMsg', $errMsg); $submitInfo['sec'] = ''; $this->showWebsiteSubmissionPage($submitInfo, true); return; } if (!stristr($submitInfo['url'], 'http://')) { $submitInfo['url'] = "http://" . $submitInfo['url']; } $sql = "update websites set " . "url='{$submitInfo['url']}'," . "owner_name='" . addslashes($submitInfo['owner_name']) . "'," . "owner_email='" . addslashes($submitInfo['owner_email']) . "'," . "category='" . addslashes($submitInfo['category']) . "'," . "title='" . addslashes($submitInfo['title']) . "'," . "description='" . addslashes($submitInfo['description']) . "',"; for ($i = 2; $i <= $this->noTitles; $i++) { $sql .= "title{$i}='" . addslashes($submitInfo['title' . $i]) . "'," . "description{$i}='" . addslashes($submitInfo['description' . $i]) . "',"; } $sql .= "keywords='" . addslashes($submitInfo['keywords']) . "' " . "where id={$submitInfo['website_id']}"; $this->db->query($sql); } $this->startSubmission($submitInfo['website_id']); }
function createmetatag($info) { $errMsg['title'] = formatErrorMsg($this->validate->checkBlank($info['title'])); $errMsg['description'] = formatErrorMsg($this->validate->checkBlank($info['description'])); $errMsg['keywords'] = formatErrorMsg($this->validate->checkBlank($info['keywords'])); # error occurs if ($this->validate->flagErr) { $this->set('errMsg', $errMsg); $this->show($info, true); return; } print "<p><b>Meta Tags</b><br><br>"; $this->highLight('<head>', false); $this->highLight('<title>' . $info['title'] . '</title>'); $this->highLight('<meta name="description" content="' . $info['description'] . '">'); $this->highLight('<meta name="keywords" content="' . $info['keywords'] . '">'); if (!empty($info['owner_name'])) { $this->highLight('<meta name="author" content="' . $info['owner_name'] . '">'); } if (!empty($info['copyright'])) { $this->highLight('<meta name="copyright" content="' . $info['copyright'] . '">'); } if (!empty($info['owner_email'])) { $this->highLight('<meta name="email" content="' . $info['owner_email'] . '">'); } if (!empty($info['lang_code'])) { $this->highLight('<meta http-equiv="Content-Language" content="' . $info['lang_code'] . '">'); } if (!empty($info['charset'])) { $this->highLight('<meta name="Charset" content="' . $info['charset'] . '">'); } if (!empty($info['rating'])) { $this->highLight('<meta name="Rating" content="' . $info['rating'] . '">'); } if (!empty($info['distribution'])) { $this->highLight('<meta name="Distribution" content="' . $info['distribution'] . '">'); } if (!empty($info['robots'])) { $this->highLight('<meta name="Robots" content="' . $info['robots'] . '">'); } if (!empty($info['revisit-after'])) { $this->highLight('<meta name="Revisit-after" content="' . $info['revisit-after'] . '">'); } if (!empty($info['expires'])) { $this->highLight('<meta name="expires" content="' . $info['expires'] . '">'); } $this->highLight('</head>', false); print "<textarea style='width:600px;' rows='15'>{$this->metaTags}</textarea>"; print "</p>"; }
function requestPassword($userEmail) { $errMsg['email'] = formatErrorMsg($this->validate->checkEmail($userEmail)); $errMsg['code'] = formatErrorMsg($this->validate->checkCaptcha($userInfo['code'])); $this->set('post', $_POST); if (!$this->validate->flagErr) { $userId = $this->__checkEmail($userEmail); if (!empty($userId)) { $userInfo = $this->__getUserInfo($userId); $rand = str_shuffle(rand() . $userInfo['username']); // get admin details $adminInfo = $this->__getUserInfo(1); # send password to user $error = 0; $this->set('rand', $rand); $name = $userInfo['first_name'] . " " . $userInfo['last_name']; $this->set('name', $name); $content = $this->getViewContent('email/passwordreset'); $subject = "Seo panel password reset"; if (!sendMail($adminInfo["email"], $name, $userEmail, $subject, $content)) { $error = $_SESSION['text']['login']['internal_error_mail_send']; } else { // update password in DB $sql = "update users set password=md5('{$rand}') where id={$userInfo['id']}"; $this->db->query($sql); } $this->set('error', $error); $this->render('common/forgotconfirm'); exit; } else { $errMsg['email'] = formatErrorMsg($_SESSION['text']['login']['user_email_not_exist']); } } $this->set('errMsg', $errMsg); $this->forgotPasswordForm(); }
function updateSeoPlugin($listInfo) { $listInfo['id'] = intval($listInfo['id']); $this->set('post', $listInfo); $errMsg['plugin_name'] = formatErrorMsg($this->validate->checkBlank($listInfo['plugin_name'])); if (!$this->validate->flagErr) { $sql = "update seoplugins set\r\n\t\t\t\t\t\tlabel='" . addslashes($listInfo['plugin_name']) . "'\r\n\t\t\t\t\t\twhere id={$listInfo['id']}"; $this->db->query($sql); $this->listSeoPlugins(); } else { $this->set('errMsg', $errMsg); $this->editSeoPlugin($listInfo, true); } }
function updateKeyword($listInfo) { $userId = isLoggedIn(); $this->set('post', $listInfo); $errMsg['name'] = formatErrorMsg($this->validate->checkBlank($listInfo['name'])); $errMsg['searchengines'] = formatErrorMsg($this->validate->checkBlank(implode('', $listInfo['searchengines']))); if (!$this->validate->flagErr) { $listInfo['website_id'] = intval($listInfo['website_id']); $listInfo['id'] = intval($listInfo['id']); $keyword = addslashes(trim($listInfo['name'])); if ($listInfo['name'] != $listInfo['oldName']) { if ($this->__checkName($keyword, $listInfo['website_id'])) { $errMsg['name'] = formatErrorMsg($this->spTextKeyword['Keyword already exist']); $this->validate->flagErr = true; } } if (!$this->validate->flagErr) { $listInfo['searchengines'] = is_array($listInfo['searchengines']) ? $listInfo['searchengines'] : array(); $sql = "update keywords set\r\n\t\t\t\t\t\tname = '{$keyword}',\r\n\t\t\t\t\t\tlang_code = '" . addslashes($listInfo['lang_code']) . "',\r\n\t\t\t\t\t\tcountry_code = '" . addslashes($listInfo['country_code']) . "',\r\n\t\t\t\t\t\twebsite_id = {$listInfo['website_id']},\r\n\t\t\t\t\t\tsearchengines = '" . implode(':', $listInfo['searchengines']) . "'\r\n\t\t\t\t\t\twhere id={$listInfo['id']}"; $this->db->query($sql); $this->listKeywords(); exit; } } $this->set('errMsg', $errMsg); $this->editKeyword($listInfo['id'], $listInfo); }
function updateMyProfile($userInfo) { $this->set('post', $userInfo); $errMsg['userName'] = formatErrorMsg($this->validate->checkUname($userInfo['userName'])); if (!empty($userInfo['password'])) { $errMsg['password'] = formatErrorMsg($this->validate->checkPasswords($userInfo['password'], $userInfo['confirmPassword'])); $passStr = "password = '******'password']) . "',"; } $errMsg['firstName'] = formatErrorMsg($this->validate->checkBlank($userInfo['firstName'])); $errMsg['lastName'] = formatErrorMsg($this->validate->checkBlank($userInfo['lastName'])); $errMsg['email'] = formatErrorMsg($this->validate->checkEmail($userInfo['email'])); if (!$this->validate->flagErr) { if ($userInfo['userName'] != $userInfo['oldName']) { if ($this->__checkUserName($userInfo['userName'])) { $errMsg['userName'] = formatErrorMsg('Username already exist!'); $this->validate->flagErr = true; } } if ($userInfo['email'] != $userInfo['oldEmail']) { if ($this->__checkEmail($userInfo['email'])) { $errMsg['email'] = formatErrorMsg('Email already exist!'); $this->validate->flagErr = true; } } if (!$this->validate->flagErr) { $sql = "update users set\r\n\t\t\t\t\t\tusername = '******'userName']}',\r\n\t\t\t\t\t\tfirst_name = '{$userInfo['firstName']}',\r\n\t\t\t\t\t\tlast_name = '{$userInfo['lastName']}',\r\n\t\t\t\t\t\t{$passStr}\r\n\t\t\t\t\t\temail = '{$userInfo['email']}'\r\n\t\t\t\t\t\twhere id={$userInfo['id']}"; $this->db->query($sql); $this->set('msg', 'Saved My Profile Details!'); $this->showMyProfile(); exit; } } $this->set('errMsg', $errMsg); $this->showMyProfile($userInfo); }
function updateKeyword($listInfo, $apiCall = false) { $userId = isLoggedIn(); $this->set('post', $listInfo); $errMsg['name'] = formatErrorMsg($this->validate->checkBlank($listInfo['name'])); $errMsg['searchengines'] = formatErrorMsg($this->validate->checkBlank(implode('', $listInfo['searchengines']))); $seStr = is_array($listInfo['searchengines']) ? implode(':', $listInfo['searchengines']) : $listInfo['searchengines']; $statusVal = isset($listInfo['status']) ? "status = " . intval($listInfo['status']) . "," : ""; //validate form if (!$this->validate->flagErr) { $listInfo['website_id'] = intval($listInfo['website_id']); $listInfo['id'] = intval($listInfo['id']); $keyword = addslashes(trim($listInfo['name'])); if ($listInfo['name'] != $listInfo['oldName']) { if ($this->__checkName($keyword, $listInfo['website_id'])) { $errMsg['name'] = formatErrorMsg($this->spTextKeyword['Keyword already exist']); $this->validate->flagErr = true; } } if (!$this->validate->flagErr) { $listInfo['searchengines'] = is_array($listInfo['searchengines']) ? $listInfo['searchengines'] : array(); $sql = "update keywords set\r\n\t\t\t\t\t\tname = '{$keyword}',\r\n\t\t\t\t\t\tlang_code = '" . addslashes($listInfo['lang_code']) . "',\r\n\t\t\t\t\t\tcountry_code = '" . addslashes($listInfo['country_code']) . "',\r\n\t\t\t\t\t\twebsite_id = {$listInfo['website_id']},\r\n\t\t\t\t\t\t{$statusVal}\r\n\t\t\t\t\t\tsearchengines = '" . addslashes($seStr) . "'\r\n\t\t\t\t\t\twhere id={$listInfo['id']}"; $this->db->query($sql); // if api call if ($apiCall) { return array('success', 'Successfully updated keyword'); } else { $this->listKeywords(); exit; } } } // if api call if ($apiCall) { return array('error', $errMsg); } else { $this->set('errMsg', $errMsg); $this->editKeyword($listInfo['id'], $listInfo); } }
function importLinks($listInfo) { $userId = isLoggedIn(); $listInfo['project_id'] = intval($listInfo['project_id']); $this->set('post', $listInfo); $errMsg['links'] = formatErrorMsg($this->validate->checkBlank($listInfo['links'])); if (!$this->validate->flagErr) { $totalLinks = $this->getCountcrawledLinks($listInfo['project_id']); $projectInfo = $this->__getProjectInfo($listInfo['project_id']); // if total links greater than max links of a project if ($totalLinks >= $projectInfo['max_links']) { $errMsg['links'] = formatErrorMsg($this->spTextSA['totallinksgreaterallowed'] . " - {$projectInfo['max_links']}"); } else { // check whether links are pages of website $linkInfo = $this->checkExcludeLinks($listInfo['links'], $projectInfo['url'], false); if (!empty($linkInfo['err_msg'])) { $errMsg['links'] = formatErrorMsg($linkInfo['err_msg']); } else { $auditorComp = $this->createComponent('AuditorComponent'); $links = explode(",", $listInfo['links']); $error = false; $linkList = array(); foreach ($links as $i => $link) { $link = Spider::formatUrl(trim($link)); if (empty($link)) { continue; } if ($auditorComp->isExcludeLink($link, $projectInfo['exclude_links'])) { continue; } // check whether url exists or not if ($auditorComp->getReportInfo(" and project_id={$projectInfo['id']} and page_url='" . addslashes($link) . "'")) { $errMsg['links'] = formatErrorMsg($this->spTextSA['Page Link'] . " '<b>{$link}</b>' " . $_SESSION['text']['label']['already exist']); $error = true; break; } else { $totalLinks++; // if total links greater than max links of a project if ($totalLinks > $projectInfo['max_links']) { $error = true; $errMsg['links'] = formatErrorMsg($this->spTextSA['totallinksgreaterallowed'] . " - {$projectInfo['max_links']}"); break; } } $linkList[$link] = 1; } // to save the page if no error occurs if (!$error) { foreach ($linkList as $link => $val) { $reportInfo['page_url'] = $link; $reportInfo['project_id'] = $projectInfo['id']; $auditorComp->saveReportInfo($reportInfo); } $this->showAuditorProjects(); exit; } } } } $this->set('errMsg', $errMsg); $this->showImportProjectLinks(); }
function countReportPageScore($reportInfo) { $scoreInfo = array(); $this->commentInfo = array(); $spTextSA = $this->getLanguageTexts('siteauditor', $_SESSION['lang_code']); // check page title length $lengTitle = strlen($reportInfo['page_title']); if ($lengTitle <= SA_TITLE_MAX_LENGTH && $lengTitle >= SA_TITLE_MIN_LENGTH) { $scoreInfo['page_title'] = 1; } else { $scoreInfo['page_title'] = -1; $msg = $spTextSA["The page title length is not between"] . " " . SA_TITLE_MIN_LENGTH . " & " . SA_TITLE_MAX_LENGTH; $this->commentInfo['page_title'] = formatErrorMsg($msg, 'error', ''); } // check meta description length $lengDes = strlen($reportInfo['page_description']); if ($lengDes <= SA_DES_MAX_LENGTH && $lengDes >= SA_DES_MIN_LENGTH) { $scoreInfo['page_description'] = 1; } else { $scoreInfo['page_description'] = -1; $msg = $spTextSA["The page description length is not between"] . " " . SA_DES_MIN_LENGTH . " and " . SA_DES_MAX_LENGTH; $this->commentInfo['page_description'] = formatErrorMsg($msg, 'error', ''); } // check meta keywords length $lengKey = strlen($reportInfo['page_keywords']); if ($lengKey <= SA_KEY_MAX_LENGTH && $lengKey >= SA_KEY_MIN_LENGTH) { $scoreInfo['page_keywords'] = 1; } else { $scoreInfo['page_keywords'] = -1; $msg = $spTextSA["The page keywords length is not between"] . " " . SA_KEY_MIN_LENGTH . " and " . SA_KEY_MAX_LENGTH; $this->commentInfo['page_keywords'] = formatErrorMsg($msg, 'error', ''); } // if link brocken if ($reportInfo['brocken']) { $scoreInfo['brocken'] = -1; $msg = $spTextSA["The page is brocken"]; $this->commentInfo['brocken'] = formatErrorMsg($msg, 'error', ''); } // if total links of a page if ($reportInfo['total_links'] >= SA_TOTAL_LINKS_MAX) { $scoreInfo['total_links'] = -1; $msg = $spTextSA["The total number of links in page is greater than"] . " " . SA_TOTAL_LINKS_MAX; $this->commentInfo['page_keywords'] = formatErrorMsg($msg, 'error', ''); } // check google pagerank if ($reportInfo['pagerank'] >= SA_PR_CHECK_LEVEL_SECOND) { $scoreInfo['pagerank'] = 3; $msg = $spTextSA["The page is having exellent pagerank"]; $this->commentInfo['pagerank'] = formatSuccessMsg($msg); } else { if ($reportInfo['pagerank'] >= SA_PR_CHECK_LEVEL_FIRST) { $scoreInfo['pagerank'] = 2; $msg = $spTextSA["The page is having very good pagerank"]; $this->commentInfo['pagerank'] = formatSuccessMsg($msg); } else { if ($reportInfo['pagerank']) { $scoreInfo['pagerank'] = 1; $msg = $spTextSA["The page is having good pagerank"]; $this->commentInfo['pagerank'] = formatSuccessMsg($msg); } else { $scoreInfo['pagerank'] = 0; $msg = $spTextSA["The page is having poor pagerank"]; $this->commentInfo['pagerank'] = formatErrorMsg($msg, 'error', ''); } } } // check backlinks $seArr = array('google', 'bing'); foreach ($seArr as $se) { $label = $se . '_backlinks'; if ($reportInfo[$label] >= SA_BL_CHECK_LEVEL) { $scoreInfo[$label] = 2; $msg = $spTextSA["The page is having exellent number of backlinks in"] . " " . $se; $this->commentInfo[$label] = formatSuccessMsg($msg); } elseif ($reportInfo[$label]) { $scoreInfo[$label] = 1; $msg = $spTextSA["The page is having good number of backlinks in"] . " " . $se; $this->commentInfo[$label] = formatSuccessMsg($msg); } else { $scoreInfo[$label] = 0; $msg = $spTextSA["The page is not having backlinks in"] . " " . $se; $this->commentInfo[$label] = formatErrorMsg($msg, 'error', ''); } } // check whether indexed or not foreach ($seArr as $se) { $label = $se . '_indexed'; if ($reportInfo[$label]) { $scoreInfo[$label] = 1; } else { $scoreInfo[$label] = -1; $msg = $spTextSA["The page is not indexed in"] . " " . $se; $this->commentInfo[$label] = formatErrorMsg($msg, 'error', ''); } } return $scoreInfo; }
function crawlKeyword($keywordInfo, $seId = '', $cron = false) { $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--]', strtolower($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 (!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']); $seStart = $this->seList[$seInfoId]['start'] + $this->seList[$seInfoId]['start_offset']; while (empty($result['error']) && $seStart < $this->seList[$seInfoId]['max_results']) { 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; foreach ($urlList as $i => $url) { $url = urldecode(strip_tags($url)); if (!preg_match('/^http:\\/\\/|^https:\\/\\//i', $url)) { continue; } 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 { 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); } return $crawlResult; }
function updateProxy($listInfo) { $this->set('post', $listInfo); $errMsg['proxy'] = formatErrorMsg($this->validate->checkBlank($listInfo['proxy'])); $errMsg['port'] = formatErrorMsg($this->validate->checkNumber($listInfo['port'])); if (!empty($listInfo['proxy_auth'])) { $errMsg['proxy_username'] = formatErrorMsg($this->validate->checkBlank($listInfo['proxy_username'])); $errMsg['proxy_password'] = formatErrorMsg($this->validate->checkBlank($listInfo['proxy_password'])); } if (!$this->validate->flagErr) { if ($listInfo['proxy'] != $listInfo['oldProxy']) { if ($this->__checkProxy($listInfo['proxy'], $listInfo['port'])) { $errMsg['proxy'] = formatErrorMsg($this->spTextProxy['Proxyalreadyexist']); $this->validate->flagErr = true; } } if (!$this->validate->flagErr) { $proxyAuth = empty($listInfo['proxy_auth']) ? 0 : 1; $sql = "update proxylist set\r\n\t\t\t\t\t\tproxy = '" . addslashes($listInfo['proxy']) . "',\r\n\t\t\t\t\t\tport = '" . intval($listInfo['port']) . "',\r\n\t\t\t\t\t\tproxy_auth = {$proxyAuth},\r\n\t\t\t\t\t\tproxy_username = '******'proxy_username']) . "',\r\n\t\t\t\t\t\tproxy_password = '******'proxy_password']) . "'\r\n\t\t\t\t\t\twhere id={$listInfo['id']}"; $this->db->query($sql); $this->listProxy(); exit; } } $this->set('errMsg', $errMsg); $this->editProxy($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 requestPassword($userEmail) { $errMsg['email'] = formatErrorMsg($this->validate->checkEmail($userEmail)); $this->set('post', $_POST); if (!$this->validate->flagErr) { $userId = $this->__checkEmail($userEmail); if (!empty($userId)) { $userInfo = $this->__getUserInfo($userId); $rand = str_shuffle(rand() . $userInfo['username']); $sql = "update users set password=md5('{$rand}') where id={$userInfo['id']}"; $this->db->query($sql); # send password to user $error = 0; $this->set('rand', $rand); $this->set('name', $userInfo['first_name'] . " " . $userInfo['last_name']); $content = $this->getViewContent('email/passwordreset'); $subject = "Seo panel password reset"; if (!sendMail(SP_SUPPORT_EMAIL, SP_ADMIN_NAME, $userEmail, $subject, $content)) { $error = showErrorMsg('An internal error occured while sending password reset mail!', false); } $this->set('error', $error); $this->render('common/forgotconfirm'); exit; } else { $errMsg['email'] = formatErrorMsg($_SESSION['text']['login']['user_email_not_exist']); } } $this->set('errMsg', $errMsg); $this->forgotPasswordForm(); }
function crawlKeyword($keywordInfo, $seId = '') { $crawlResult = array(); $websiteUrl = formatUrl($keywordInfo['url']); if (empty($websiteUrl)) { return $crawlResult; } if (empty($keywordInfo['name'])) { return $crawlResult; } $seList = explode(':', $keywordInfo['searchengines']); foreach ($seList as $seInfoId) { if (!empty($seId) && $seInfoId != $seId) { continue; } $this->seFound = 1; $searchUrl = str_replace('[--keyword--]', urlencode($keywordInfo['name']), $this->seList[$seInfoId]['url']); $searchUrl = str_replace('[--lang--]', $keywordInfo['lang_code'], $searchUrl); $searchUrl = str_replace('[--country--]', $keywordInfo['country_code'], $searchUrl); $seUrl = str_replace('[--start--]', $this->seList[$seInfoId]['start'], $searchUrl); 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 = $result['page']; $seStart = $this->seList[$seInfoId]['start'] + $this->seList[$seInfoId]['no_of_results_page']; while (empty($result['error']) && $seStart < $this->seList[$seInfoId]['max_results']) { $seUrl = str_replace('[--start--]', $seStart, $searchUrl); $result = $this->spider->getContent($seUrl); $pageContent .= $result['page']; $seStart += $this->seList[$seInfoId]['no_of_results_page']; sleep(SP_CRAWL_DELAY); } $crawlStatus = 0; if (empty($result['error'])) { if (preg_match_all($this->seList[$seInfoId]['regex'], $pageContent, $matches)) { $urlList = $matches[$this->seList[$seInfoId]['url_index']]; $crawlResult[$seInfoId]['matched'] = array(); foreach ($urlList as $i => $url) { $url = strip_tags($url); 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'] = $i + 1; $crawlResult[$seInfoId]['matched'][] = $matchInfo; } } $crawlStatus = 1; } else { 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; } return $crawlResult; }
function updateMyProfile($userInfo) { $userInfo = sanitizeData($userInfo); $userId = isLoggedIn(); $this->set('post', $userInfo); $errMsg['userName'] = formatErrorMsg($this->validate->checkUname($userInfo['userName'])); if (!empty($userInfo['password'])) { $errMsg['password'] = formatErrorMsg($this->validate->checkPasswords($userInfo['password'], $userInfo['confirmPassword'])); $passStr = "password = '******'password']) . "',"; } $errMsg['firstName'] = formatErrorMsg($this->validate->checkBlank($userInfo['firstName'])); $errMsg['lastName'] = formatErrorMsg($this->validate->checkBlank($userInfo['lastName'])); $errMsg['email'] = formatErrorMsg($this->validate->checkEmail($userInfo['email'])); if (!$this->validate->flagErr) { if ($userInfo['userName'] != $userInfo['oldName']) { if ($this->__checkUserName($userInfo['userName'])) { $errMsg['userName'] = formatErrorMsg($_SESSION['text']['login']['usernameexist']); $this->validate->flagErr = true; } } if ($userInfo['email'] != $userInfo['oldEmail']) { if ($this->__checkEmail($userInfo['email'])) { $errMsg['email'] = formatErrorMsg($_SESSION['text']['login']['emailexist']); $this->validate->flagErr = true; } } if (!$this->validate->flagErr) { $sql = "update users set\r\n\t\t\t\t\t\tusername = '******'userName']) . "',\r\n\t\t\t\t\t\tfirst_name = '" . addslashes($userInfo['firstName']) . "',\r\n\t\t\t\t\t\tlast_name = '" . addslashes($userInfo['lastName']) . "',\r\n\t\t\t\t\t\t{$passStr}\r\n\t\t\t\t\t\temail = '" . addslashes($userInfo['email']) . "'\r\n\t\t\t\t\t\twhere id={$userId}"; $this->db->query($sql); $this->set('msg', $this->spTextUser['Saved My Profile Details']); $this->showMyProfile(); exit; } } $this->set('errMsg', $errMsg); $this->showMyProfile($userInfo); }
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'])); 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->validate->flagErr) { $sql = "update websites set\r\n\t\t\t\t\t\tname = '{$listInfo['name']}',\r\n\t\t\t\t\t\turl = '{$listInfo['url']}',\r\n\t\t\t\t\t\tuser_id = {$userId},\r\n\t\t\t\t\t\ttitle = '" . addslashes($listInfo['title']) . "',\r\n\t\t\t\t\t\tdescription = '" . addslashes($listInfo['description']) . "',\r\n\t\t\t\t\t\tkeywords = '" . addslashes($listInfo['keywords']) . "'\r\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 to create a new user type * @params : $listInfo - post values * @return : returns the data */ function createUserType($listInfo) { $this->set('post', $listInfo); $errMsg['user_type'] = formatErrorMsg($this->validate->checkBlank(trim($listInfo['user_type']))); $errMsg['num_websites'] = formatErrorMsg($this->validate->checkNumber(trim($listInfo['num_websites']))); $errMsg['num_keywords'] = formatErrorMsg($this->validate->checkNumber(trim($listInfo['num_keywords']))); $errMsg['price'] = formatErrorMsg($this->validate->checkNumber(trim($listInfo['price']))); if (!$this->validate->flagErr) { if (!$this->__checkUserType($listInfo['user_type'])) { $sql = "insert into usertypes(user_type,description,num_websites,num_keywords,price,status)\n \t\t\t\tvalues('" . addslashes($listInfo['user_type']) . "','" . addslashes($listInfo['description']) . "',\n \t\t\t\t'" . intval($listInfo['num_websites']) . "','" . intval($listInfo['num_keywords']) . "',\n \t\t\t\t'" . floatval($listInfo['price']) . "'," . intval($listInfo['user_type_status']) . ")"; $this->db->query($sql); $this->listUserTypes(); exit; } else { $errMsg['user_type'] = formatErrorMsg($this->spTextWeb['User Type already exist']); } } $this->set('errMsg', $errMsg); $this->newUserType($listInfo); }