'; exit; } function partial_in_array($key,$array) { foreach($array AS $element) { if (is_numeric(strpos($element,$key))) { return $element; } } return; } // Function to convert the XML into an array function xml_to_result($dom) { global $totalResultsReturned; $root = $dom->document_element(); $res['totalResultsReturned'] = $root->get_attribute('totalResultsReturned'); $i = 0; $node = $root->first_child(); while($node) { switch($node->tagname) { case 'Result': $subnode = $node->first_child(); while($subnode) { $subnodes = $subnode->child_nodes(); if(!empty($subnodes)) foreach($subnodes as $k=>$n) { if(empty($n->tagname)) $res[$i][$subnode->tagname] = trim($n->get_content()); else $res[$i][$subnode->tagname][$n->tagname]=trim($n->get_content()); } $subnode = $subnode->next_sibling(); } break; default: $res[$node->tagname] = trim($node->get_content()); $i--; break; } $i++; $node = $node->next_sibling(); } return $res; } // Function to display links with all options and information function show_links ($final_output) { global $all_sites, $min_match; echo "
Hub Finder is a free link analysis tool created by www.SeoBook.com. Hub Finder looks for sites which have co occuring links to related authoritative websites on a particular topic.
\n"; // If they haven't submitted a query, end the page. if (!isset($query)) done(); // Break up the sites entered by the user into an array $manual_sites = explode("\n",$manual_filter); $searched_sites = array(); if ($whichengine != 'google') { // Construct the query for the Yahoo api making sure to remove results from sites already entered manually $query = str_replace(' ','%20',$query); $q='http://api.search.yahoo.com/WebSearchService/V1/webSearch?query=' . $query; foreach ($manual_sites AS $site) { $q .= '%20-site:' . trim($site); } $q .= '&results=' . $search_num . '&appid=' . $appid; // Perform the Yahoo query to get the top x sites for the topic entered $site_results = file_get_contents($q); $dom = domxml_open_mem($site_results,DOMXML_LOAD_PARSING,$error); if ($dom) $res = xml_to_result($dom); // Get the Yahoo results in an array for ($x = 0; $x < $res[totalResultsReturned]; $x++) { $url = $res[$x][Url]; $url_array = parse_url($url); $url = $url_array['host']; if (!in_array($url,$searched_sites)) array_push($searched_sites,$url); } } $maxresults = intval($search_num); if ($whichengine != 'yahoo') { // Get the top search results from google. $parameters = array( "key" => $googlekey, "q" => $query, "start" => 0, "maxResults" => $maxresults, "filter" => true, "restrict" => "", "safeSearch" => false, "lr" => "lang_en", "ie" => "", "oe" => "" ); $soapclient = new soapclient("http://api.google.com/search/beta2"); // [1] $result = $soapclient->call("doGoogleSearch", $parameters, "urn:GoogleSearch"); for ($i = 0; $i < $result["endIndex"]; $i++) { $element = $result[resultElements][$i]; $url = $element["URL"]; $url_array = parse_url($url); $url = $url_array['host']; if (!in_array($url,$searched_sites)) array_push($searched_sites,$url); } } $all_results = array(); $site_count = 0; $all_sites = array(); if ($individual != '') array_push($all_sites,$individual); foreach ($manual_sites AS $site) { if ($site != '') array_push($all_sites,$site); } foreach ($searched_sites AS $site) { if ($site != '') array_push($all_sites,$site); } foreach ($all_sites AS $site) { $site_results_array = array(); $site = trim($site); if (strlen($site) > 1) { $query = str_replace('http://','',$site); $domain = parse_url("http://" . $query); for ($i = 0; $i < $depth; $i++) { $start = 50 * $i; if (($site_count == 0) && ($individual != '') && ($linktype == 'link')) { $q='http://api.search.yahoo.com/WebSearchService/V1/webSearch?query=link:http://' . str_replace('http://','',$individual) . "%20-site:" . $domain[host]; } else { $q='http://api.search.yahoo.com/WebSearchService/V1/webSearch?query=linkdomain:' . $domain[host] . "%20-site:" . $domain[host]; } if ($start == 0) { $site_results = file_get_contents($q.'&results=50&appid=' . $appid); } else { $site_results = file_get_contents($q.'&results=50&appid=' . $appid . '&start=' . $start); } $dom = domxml_open_mem($site_results,DOMXML_LOAD_PARSING,$error); if ($dom) $res = xml_to_result($dom); for ($x = 0; $x < $res[totalResultsReturned]; $x++) { $full_url = $res[$x][Url]; $url_array = parse_url($full_url); $url = $url_array['host']; array_push($site_results_array,$full_url); if (!in_array($url,$all_results)) { array_push($all_results,$url); } } } $sites[$site_count] = $site_results_array; $site_count++; } } $final_output = array(); for ($y = 0; $y < count($all_results); $y++) { $final_output[$y]['name'] = $all_results[$y]; for ($x = 0; $x < count($all_sites); $x++) { $this_link = partial_in_array($all_results[$y],$sites[$x]); if ($this_link != '') { if (($x == 0) || ($apply != 'mustlink') || ($individual == '') || ($final_output[$y][0] != '')) { $final_output[$y][$x] = $this_link; $final_output[$y]['total']++; } } else { $final_output[$y][$x] = ''; } } } foreach($final_output as $result) { $row_sorting[] = $result['total']; } array_multisort($row_sorting, SORT_DESC, $final_output); if (($individual != '') && ($apply == 'sortby')) { foreach($final_output as $result) { $row_sorting2[] = $result[0]; } array_multisort($row_sorting2, SORT_DESC, $final_output); } ?> Querying the following " . count($all_sites) . " sites\n"; for ($y = 1; $y <= count($all_sites); $y++) { echo "$y: " . $all_sites[$y-1] . "