function submitRequest($code, $subject, $body, $id = null) { require_once dirname(__FILE__) . "/../lib/Snoopy.class.php"; $SnoopySeoBoss = new SnoopySeoBoss(); $vars = array("option" => "com_seobossupdater", "task" => "helpdesk_submit", "format" => "raw", "code" => $code, "subject" => $subject, "body" => $body); if ($id) { $vars["id"] = $id; } $SnoopySeoBoss->httpmethod = "POST"; $SnoopySeoBoss->submit("http://{$this->UPDATE_SITE}/index.php", $vars); return $SnoopySeoBoss->results; }
/** * Retrieves the position of specified site in the google result list by specified keyword. * @param String $keyword * @param String $site * @param String $google_url cron * @param String $lang * @return Int position of the specified site in search result list. * value between 1 and 100 if the site is in the first top 100 sites. * 1000 if site is not in the first top 100 sites. */ function getGoogleKeywordRank($keyword, $site, $google_url = "google.by", $lang = "be") { $SnoopySeoBoss = new SnoopySeoBoss(); if (strpos($site, "http://") === 0) { $site = substr($site, strlen("http://")); } if (strpos($site, "www.") === 0) { $site = substr($site, strlen("www.")); } $keyword = urlencode($keyword); $SnoopySeoBoss->fetch("http://www.{$google_url}/search?as_q={$keyword}&num=100&site=&source=hp"); preg_match_all("/<h3[\\s]+class=\\\"r\\\">[\\s]*<a[\\s]+href=\\\"([^\\\"]*)\\\"/i", $SnoopySeoBoss->results, $results); $rank = 1; foreach ($results[1] as $result) { if (strpos($result, "http://{$site}") !== false || strpos($result, "http://www.{$site}") !== false || strpos($result, "http%3A%2F%2Fwww.{$site}%2F") > 0 || strpos($result, "http%3A%2F%2F{$site}%2F") > 0) { return $rank; } $rank++; } return 1000; }
public static function Redirect($data) { require_once JPATH_ADMINISTRATOR . "/components/com_seoboss/lib/Snoopy.class.php"; $db =& JFactory::getDBO(); $obj = new SnoopySeoBoss(); $obj->fetchLinksForRedirect($data); $url = $_SERVER['HTTP_HOST']; //rectal replacement if ($obj->results) { $linksInText = array_flip($obj->results); $linksInText = array_flip($linksInText); foreach ($linksInText as $linkInText) { if (preg_match("~^[^=]+://~", $linkInText) && !preg_match("~^[^://]+://(www\\.)?" . $url . "~i", $linkInText)) { $extLink[] = '|' . $linkInText . '|'; } } $query = "SELECT * FROM #__seoboss_redirects WHERE 1"; $db->setQuery($query); $r_links = $db->loadObjectList(); foreach ($r_links as $r_link) { for ($i = 0; $i < count($extLink); $i++) { $target = $r_link->target == '1' ? "_blank" : "_self"; if (substr($r_link->url, -1) == '*' && stripos($extLink[$i], substr($r_link->url, 0, -1))) { $extLink[$i] = str_replace("|", "", $extLink[$i]); $data = str_replace($extLink[$i] . '"', '/index.php?option=com_seoboss&url=' . $extLink[$i] . '" target="' . $target . '"', $data); } else { if (stripos($extLink[$i], $r_link->url . "|")) { $extLink[$i] = str_replace("|", "", $extLink[$i]); $data = str_replace($extLink[$i] . '"', '/index.php?option=com_seoboss&url=' . $extLink[$i] . '" target="' . $target . '"', $data); } } } } } return $data; }