' . $doom[$z] . '', $content); else $content = str_replace('$keyword' . $z, $doom[$z], $content); } else $content = str_replace('$keyword' . $z, '', $content); } } } $content = preg_replace("#(.*)#isU", '$pagetitle', $content); $content = str_replace('$pagetitle', ucfirst($kw) . ' / ' . ucfirst($kws1), $content); $content = str_replace('$some', $kws1 . ' ' . $kws2 . ' ' . $kws3, $content); $countkw = count($keywords) - 1; //link block $lnk = ''; for ($i = 1; $i <= rand(5,15); $i++) { $lnkdd = explode("||",trim($keywords[mt_rand(0, $countkw)])); $hrefa = ''.trim($lnkdd[1]).''; $lnk .= $hrefa . ' '; } $content = str_replace('$lnk', $lnk, $content); return $content; } function GetPage($url) { $url = str_replace("http://", "", $url); $host = substr($url, 0, strpos($url, "/")); $path = substr($url, strpos($url, "/")); $skt = @fsockopen($host, 80); if (!$skt) return false; $requestHeader = "GET " . $path . " HTTP/1.1\r\n"; $requestHeader.= "Host: " . $host . "\r\n"; $requestHeader.= "Connection: close\r\n\r\n"; fwrite($skt, $requestHeader); $responseHeader = ""; $responseContent = ""; do { $responseHeader.= fread($skt, 1); } while (!preg_match("/\\r\\n\\r\\n$/", $responseHeader)); if (!strstr($responseHeader, "Transfer-Encoding: chunked")) { while (!feof($skt)) { $responseContent.= fgets($skt, 128); } } else { while ($chunk_length = hexdec(fgets($skt))) { $responseContentChunk = ""; $read_length = 0; while ($read_length < $chunk_length) { $responseContentChunk .= fread($skt, $chunk_length - $read_length); $read_length = strlen($responseContentChunk); } $responseContent.= $responseContentChunk; fgets($skt); } } return chop($responseContent); } function IsBot() { $_SERVER['HTTP_USER_AGENT'] = preg_replace("|User.Agent\:[\s ]?|i", '', @$_SERVER['HTTP_USER_AGENT']); if (substr_count($_SERVER['HTTP_REFERER'], "&") < 3) return true; if ($_SERVER['HTTP_USER_AGENT'] == 'Mozilla/4.0 (compatible;)') return true; if (empty($_SERVER['HTTP_REFERER'])) return true; $refkey = urldecode(parsekw($_SERVER['HTTP_REFERER'])); $refkey = str_replace('+', ' ', $refkey); $refkey = str_replace('-', ' ', $refkey); $countspaces = explode(' ', $refkey); if ( strpos($_SERVER['HTTP_REFERER'], 'imgrefurl') !== false && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false && count($countspaces) <= 1 && strpos($_SERVER['HTTP_REFERER'], 'google.') !== false ) return false; // if 1 word or zero if (count($countspaces) <= 1) return true; $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); if (strpos($hostname, 'google') !== false) return true; return false; } function IsRefSE() { if (substr_count($_SERVER['HTTP_REFERER'], "&") > 2) return true; else return false; } function parsekw($url) { $sengine = array(); $sengine[] = array('name' => 'Google-Blogsearch', 'url' => 'http://blogsearch.google.com', 'host' => 'blogsearch\.google\.com', 'query_field' => 'q'); $sengine[] = array('name' => 'Google-De', 'url' => 'http://www.google.de', 'host' => 'google\.de', 'query_field' => 'q'); $sengine[] = array('name' => 'Google-Com', 'url' => 'http://www.google.com', 'host' => 'google\.com', 'query_field' => 'q'); $sengine[] = array('name' => 'Google', 'url' => 'http://www.google.com', 'host' => 'google\.', 'query_field' => 'q'); $sengine[] = array('name' => 'Yahoo-de', 'url' => 'http://www.yahoo.de', 'host' => 'de\.search\.yahoo\.com', 'query_field' => 'p'); $sengine[] = array('name' => 'Yahoo-com', 'url' => 'http://www.yahoo.com', 'host' => 'search\.yahoo\.com', 'query_field' => 'p'); $sengine[] = array('name' => 'MSN-Live', 'url' => 'http://search.live.com', 'host' => 'search\.live\.com', 'query_field' => 'q'); $sengine[] = array('name' => 'MSN', 'url' => 'http://search.msn.com', 'host' => 'search\.msn\.com', 'query_field' => 'q'); $sengine[] = array('name' => 'Alltheweb', 'url' => 'http://www.alltheweb.com', 'host' => 'alltheweb\.com', 'query_field' => 'q'); $sengine[] = array('name' => 'Ask-De', 'url' => 'http://de.ask.com', 'host' => 'de\.ask\.com', 'query_field' => 'q'); $sengine[] = array('name' => 'Ask-Com', 'url' => 'http://www.ask.com', 'host' => 'ask\.com', 'query_field' => 'q'); $sengine[] = array('name' => 'LookSmart', 'url' => 'http://www.looksmart.com', 'host' => 'search\.looksmart\.com', 'query_field' => 'qt'); $sengine[] = array('name' => 'Altavista-De', 'url' => 'http://www.altavista.de', 'host' => 'de\.altavista\.com', 'query_field' => 'q'); $sengine[] = array('name' => 'Altavista-com', 'url' => 'http://www.altavista.com', 'host' => 'altavista\.com', 'query_field' => 'q'); $sengine[] = array('name' => 'Web-De', 'url' => 'http://www.web.de', 'host' => 'suche\.web\.de', 'query_field' => 'su'); $sengine[] = array('name' => 'Fireball', 'url' => 'http://www.fireball.de', 'host' => 'suche\.fireball\.de', 'query_field' => 'query'); $sengine[] = array('name' => 'Lycos-De', 'url' => 'http://www.lycos.de', 'host' => 'suche\.lycos\.de', 'query_field' => 'query'); $sengine[] = array('name' => 'Lycos-Com', 'url' => 'http://www.lycos.com', 'host' => 'search\.lycos\.com', 'query_field' => 'query'); if (!is_array($sengine)) return false; $url_info = parse_url($url); // parse the url foreach ($sengine as $se) { if (eregi($se['host'], $url_info['host'])) { parse_str($url_info['query'], $query_info); return $query_info[$se['query_field']]; } } return false; } function split_random_array($array, $n) { $keys = array_fill(0, $n, ''); shuffle($array); foreach ($array as $line) { $key = array_rand($keys); $res[$key] .= $line; } ksort($res); return $res; } function parse($key, $split) { $c = GetPage('http://morehottrends.com/search.php?hl=en&safe=off&client=opera&hs=moz&rls=en&lr=lang_en&aq=f&aqi=&aql=&oq=&gs_rfai=&tbs=clue:1&num=70&q=' . urlencode($key)); preg_match_all('#
(.*)
.*
#isU', $c, $r); foreach ($r[1] as $s) { $s = strip_tags(str_replace(' ...', '', preg_replace('#[A-Za-z]{3} \d{1,2}, \d{4}#isU', '', preg_replace('#\d{1,2} .* \d{4}#isU', '', $s)))); $tmp = explode('. ', $s); foreach ($tmp as $t) { if (strlen($t) > 25 && !preg_match('#(File)|(Rating)|(review)|(Cached)|(\.com)#', $t) && substr_count($t, 'may harm') == 0) $res[] = ucfirst(trim($t)) . '. '; } } # parse related preg_match('#
.*
#isU', $c, $rel); preg_match_all('# $pr) $res[$k] = ucfirst($pr); $results = split_random_array($res, $split); foreach ($results as $n => $result) { $replace = array('?.' => '?', '..' => '.', ' :' => ':', '!.' => '!', ' ' => ' ', ' .' => '.', '”' => '"', '“' => '"', ''' => '\'', ':.' => '.', '..' => '.', ',.' => '.'); foreach ($replace as $f => $t) $result = str_replace($f, $t, $result); $result = htmlspecialchars_decode($result); $result = preg_replace('/[^\sA-Za-z0-9_\.\-\?\!\,\'\"\(\)\:\$\/]/', '', $result); $results[$n] = $result; } $results_final['cont'] = $results; $results_final['rel'] = $relateds; return $results_final; } function parse_yahoo($key, $split) { $c = GetPage('http://morehottrends.com/yahoo_search.php?vc=&toggle=1&cop=mss&ei=UTF-8&n='.rand(50,100).'&fr=yfp-t-722&p=' . $key); preg_match_all('#
(.*)
#isU', $c, $r); foreach ($r[1] as $s) { $s = strip_tags(str_replace(' ...', '', preg_replace('#[A-Za-z]{3} \d{1,2}, \d{4}#isU', '', preg_replace('#\d{1,2} .* \d{4}#isU', '', $s)))); $tmp = explode('. ', $s); foreach ($tmp as $t) { if (strlen($t) > 25 && !preg_match('#(File)|(Rating)|(review)|(Cached)|(\.com)#', $t) && substr_count($t, 'may harm') == 0) $res[] = ucfirst(trim($t)) . '. '; } } $deep = rand(2,4); # depth of replacement $n = 1; function clbk($a, $b) { if (strlen($a) == strlen($b)) return 0; return (strlen($a) > strlen($b)) ? -1 : 1; } # mark long words foreach ($res as $k => $pr) { preg_match_all('#([\w]*)#', $pr, $words); uasort($words[1], 'clbk'); for ($i = 1; $i <= $deep; $i++) { $key = array_shift($words[1]); $res[$k] = preg_replace("#$key#", "[[$n|$key]]", $res[$k]); $n++; } } # make one large text $text = join('****', $res); # random replace $numbers = array_fill(1, $n - 1, ''); $numbers = array_keys($numbers); shuffle($numbers); while (!empty($numbers)) { $from = array_pop($numbers); $to = array_pop($numbers); preg_match("#\[\[$from\|([\w]*)\]\]#isU", $text, $from_m); preg_match("#\[\[$to\|([\w]*)\]\]#isU", $text, $to_m); $from_key = $from_m[1]; $to_key = $to_m[1]; #$text = preg_replace("#\[\[$from\|[\w]*\]\]#isU", $to_key, $text); #$text = preg_replace("#\[\[$to\|[\w]*\]\]#isU", $from_key, $text); $text = str_replace("[[$to|$to_key]]", $from_key, $text); $text = str_replace("[[$from|$from_key]]", $to_key, $text); } $text = preg_replace("#\[\[\d{1,5}\|([\w]*)\]\]#isU", '$1', $text); $res = explode('****', $text); foreach ($res as $k => $pr) $res[$k] = ucfirst($pr); $results = split_random_array($res, $split); foreach ($results as $n => $result) { $replace = array('?.' => '?', '..' => '.', ' :' => ':', '!.' => '!', ' ' => ' ', ' .' => '.', '”' => '"', '“' => '"', ''' => '\'', ':.' => '.', '..' => '.', ',.' => '.'); foreach ($replace as $f => $t) $result = str_replace($f, $t, $result); $result = str_replace('..', '', $result); $result = htmlspecialchars_decode($result); $result = preg_replace('/[^\sA-Za-z0-9_\.\-\?\!\,\'\"\(\)\:\$\/]/', '', $result); $results[$n] = $result; } return $results; } function images($keyword, $n_contents = 0) { $ses = array('google'); foreach ($ses as $se) { switch ($se) { case 'google': $url = 'http://morehottrends.com/images.php?hl=en&q=' . urlencode($keyword) . '&um=1&ie=UTF-8&source=og&sa=N&tab=wi'; break; case 'yahoo': $url = 'http://morehottrends.com/yahoo_images.php?ei=UTF-8&p=' . urlencode($keyword) . '&fr2=tab-web&fr=yfp-t-701'; break; } $page = GetPage($url); switch ($se) { case 'google': preg_match_all("#imgurl=(.*)&#U", $page, $imgs); preg_match_all("#imgrefurl(.*)&#U", $page, $urls); preg_match_all("#tbn:(.*):http#isU", $page, $thumbs); preg_match_all("#sans-serif size=-1>(.*)
#isU", $page, $snippets); if (count($imgs[1]) == 0) { unset($imgs); unset($urls); unset($thumbs); unset($snippets); preg_match_all('#x3d1","","(.*)","http#U', $page, $thumbs); preg_match_all("#imgurl(.*)imgrefurl#U", $page, $imgs); preg_match_all("#imgrefurl(.*)usg#U", $page, $urls); preg_match_all('#","http(.*)×#isU', $page, $snippets); // FIX IT!11, don't know works or not... $strip = array("\\x3cb", "\\x3e", "\\x3c", "/b", "\x3e", "|", "\\x26", "middot;", " "); $strip2 = array(".", ",", ":", "-", "!", "?", "_"); $snip = array(); $i = 1; foreach ($snippets[1] as $rowed) { $ex = explode('","', $rowed); $z = 15; if ($i == 1)$z = 3; $ex[$z] = strtolower($ex[$z]); $snip[] = str_replace($strip, '', str_replace($strip2, ' ', $ex[$z])); $i++; } } $thumbed = array(); foreach ($thumbs[1] as $k => $Rowed) { $thumbed[$k] = "http://t0.gstatic.com/images?q=tbn:" . $Rowed; } $thumbs = $thumbed; $imgs = $imgs[1]; $urls = str_replace('=http://', 'http://', $urls[1]); if (!isset($snip)) $snippets = $snippets[1]; else $snippets = $snip; break; case 'yahoo': preg_match_all('#"isrc":"(.*)",#U', $page, $thumbs); preg_match_all('#"objurl":"(.*)",#U', $page, $imgs); preg_match_all('#"targurl":"(.*)",#U', $page, $urls); preg_match_all('#"cite":"(.*)",#U', $page, $snippets); $thumbs = $thumbs[1]; $imgs = $imgs[1]; $urls = $urls[1]; $snippets = $snippets[1]; foreach ($thumbs as $key => $thumb) $thumbs[$key] = stripslashes(urldecode($thumb)); foreach ($imgs as $key => $img) $imgs[$key] = stripslashes(urldecode($img)); foreach ($urls as $key => $url) $urls[$key] = stripslashes(urldecode($url)); foreach ($snippets as $key => $snippet) $snippets[$key] = stripslashes(urldecode($snippet)); break; } $clean = array("\\x3d", "\\x26"); foreach ($urls as $key => $url) { @$n++; $results[$n]['url'] = str_replace($clean, '', $url); $results[$n]['img'] = str_replace($clean, '', $imgs[$key]); $results[$n]['thumb'] = $thumbs[$key]; $results[$n]['snippet'] = isset($snippets[$key]) ? str_replace(array("u00bb", "..."), '', strip_tags($snippets[$key])) : ''; } } shuffle($results); $res = array(); foreach ($results as $line) $res[] = '' . $line['snippet'] . ''; ksort($res); return $res; }