function wpr_articlepost($keyword,$num,$start,$optional="",$comments="") { global $wpdb,$wpr_table_templates; if($keyword == "") { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "No keyword"; $return["error"]["message"] = __("No keyword specified.","wprobot"); return $return; } $template = $wpdb->get_var("SELECT content FROM " . $wpr_table_templates . " WHERE type = 'article'"); if($template == false || empty($template)) { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "No template"; $return["error"]["message"] = __("Module Template does not exist or could not be loaded.","wprobot"); return $return; } $options = unserialize(get_option("wpr_options")); $posts = array(); $keyword2 = $keyword; $keyword = str_replace( " ","+",$keyword ); $keyword = urlencode($keyword); $blist[] = "Mozilla/5.0 (compatible; Konqueror/4.0; Microsoft Windows) KHTML/4.0.80 (like Gecko)"; $blist[] = "Mozilla/5.0 (compatible; Konqueror/3.92; Microsoft Windows) KHTML/3.92.0 (like Gecko)"; $blist[] = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0; .NET CLR 1.1.4322; Windows-Media-Player/10.00.00.3990; InfoPath.2"; $blist[] = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; Dealio Deskball 3.0)"; $blist[] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; NeosBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; $ua = $blist[array_rand($blist)]; $page = $start / 15; $page = (string) $page; $page = explode(".", $page); $page=(int)$page[0]; $page++; if($page == 0) {$page = 1;} $prep = floor($start / 15); $numb = $start - $prep * 15; $lang = $options['wpr_eza_lang']; if($lang == "en") { $search_url = "http://www.articlesbase.com/find-articles.php?q=$keyword&page=$page"; } elseif($lang == "fr") { $search_url = "http://fr.articlesbase.com/find-articles.php?q=$keyword&page=$page"; } elseif($lang == "es") { $search_url = "http://www.articuloz.com/find-articles.php?q=$keyword&page=$page"; } elseif($lang == "pg") { $search_url = "http://www.artigonal.com/find-articles.php?q=$keyword&page=$page"; } elseif($lang == "ru") { $search_url = "http://www.rusarticles.com/find-articles.php?q=$keyword&page=$page"; } // make the cURL request to $search_url if ( function_exists('curl_init') ) { $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, 'Firefox (WindowsXP) - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6'); curl_setopt($ch, CURLOPT_URL,$search_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 45); $html = curl_exec($ch); if (!$html) { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "cURL Error"; $return["error"]["message"] = __("cURL Error Number ","wprobot").curl_errno($ch).": ".curl_error($ch); return $return; } curl_close($ch); } else { $html = @file_get_contents($search_url); if (!$html) { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "cURL Error"; $return["error"]["message"] = __("cURL is not installed on this server!","wprobot"); return $return; } } // parse the html into a DOMDocument $dom = new DOMDocument(); @$dom->loadHTML($html); // Grab Product Links $xpath = new DOMXPath($dom); $paras = $xpath->query("//div//h3/a"); $x = 0; $end = $numb + $num; if($paras->length == 0) { $posts["error"]["module"] = "Article"; $posts["error"]["reason"] = "No content"; $posts["error"]["message"] = __("No (more) articles found.","wprobot"); return $posts; } if($end > $paras->length) { $end = $paras->length;} for ($i = $numb; $i < $end; $i++ ) { $para = $paras->item($i); if(empty($para)) { $posts["error"]["module"] = "Article"; $posts["error"]["reason"] = "No content"; $posts["error"]["message"] = __("No (more) articles found.","wprobot"); //print_r($posts); return $posts; } else { $target_url = $para->getAttribute('href'); // $target_url = "http://www.articlesbase.com" . $para->getAttribute('href'); // make the cURL request to $search_url if ( function_exists('curl_init') ) { $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, 'Firefox (WindowsXP) - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6'); curl_setopt($ch, CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 45); $html = curl_exec($ch); if (!$html) { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "cURL Error"; $return["error"]["message"] = __("cURL Error Number ","wprobot").curl_errno($ch).": ".curl_error($ch); return $return; } curl_close($ch); } else { $html = @file_get_contents($target_url); if (!$html) { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "cURL Error"; $return["error"]["message"] = __("cURL is not installed on this server!","wprobot"); return $return; } } // parse the html into a DOMDocument $dom = new DOMDocument(); @$dom->loadHTML($html); // Grab Article Title $xpath1 = new DOMXPath($dom); $paras1 = $xpath1->query("//div/h1"); $para1 = $paras1->item(0); $title = $para1->textContent; // Grab Article Syndicate Box //$xpath2 = new DOMXPath($dom); //$paras2 = $xpath2->query("//textarea[@id='texttocopy']"); //$para2 = $paras2->item(0); //echo strip_tags($dom->saveXml($para2),'<p><strong><b><a><br>'); // Grab Article $xpath2 = new DOMXPath($dom); //$paras2 = $xpath2->query("//div[@class='KonaBody']"); $paras2 = $xpath2->query("//div[@class='article_cnt']/div[@class='KonaBody']"); $para2 = $paras2->item(0); $string = $dom->saveXml($para2); $string = strip_tags($string,'<p><strong><b><a><br>'); $string = str_replace('<div class="KonaBody">', "", $string); $string = str_replace("</div>", "", $string); $string = str_replace(" ", "", $string); if ($options['wpr_eza_striplinks']=='yes') {$string = wpr_strip_selected_tags($string, array('a','iframe','script'));} //if($lang == "es") {$string = utf8_decode ( $string ); } $articlebody .= $string . ' '; // Grab Ressource Box $xpath3 = new DOMXPath($dom); $paras3 = $xpath3->query("//div[@class='author_details']/p"); //$para = $paras->item(0); $ressourcetext = ""; for ($y = 0; $y < $paras3->length; $y++ ) { //$paras->length $para3 = $paras3->item($y); $ressourcetext .= $dom->saveXml($para3); } $ressourcetext .= '<br/>Article from <a href="'.$target_url.'">articlesbase.com</a>'; $title = utf8_decode($title); // Split into Pages if($options['wpr_eza_split'] == "yes") { $articlebody = wordwrap($articlebody, $options['wpr_eza_splitlength'], "<!--nextpage-->"); } $post = $template; $post = wpr_random_tags($post); $post = str_replace("{article}", $articlebody, $post); $post = str_replace("{authortext}", $ressourcetext, $post); $noqkeyword = str_replace('"', '', $keyword2); $post = str_replace("{keyword}", $noqkeyword, $post); $post = str_replace("{Keyword}", ucwords($noqkeyword), $post); $post = str_replace("{title}", $title, $post); $post = str_replace("{url}", $target_url, $post); if(function_exists("wpr_translate_partial")) { $post = wpr_translate_partial($post); } $posts[$x]["unique"] = $target_url; $posts[$x]["title"] = $title; $posts[$x]["content"] = $post; $x++; } } return $posts; }
function wpr_youtubepost($keyword, $num, $start, $optional = "", $getcomments) { global $wpdb, $wpr_table_templates; if ($keyword == "") { $return["error"]["module"] = "Youtube"; $return["error"]["reason"] = "No keyword"; $return["error"]["message"] = __("No keyword specified.", "wprobot"); return $return; } $template = $wpdb->get_var("SELECT content FROM " . $wpr_table_templates . " WHERE type = 'youtube'"); if ($template == false || empty($template)) { $return["error"]["module"] = "Youtube"; $return["error"]["reason"] = "No template"; $return["error"]["message"] = __("Module Template does not exist or could not be loaded.", "wprobot"); return $return; } $options = unserialize(get_option("wpr_options")); $pxml = wpr_youtuberequest($keyword, $num, $start); if (!empty($pxml["error"])) { return $pxml; } $videos = array(); $x = 0; if ($pxml === False) { $videos["error"]["module"] = "Youtube"; $videos["error"]["reason"] = "API fail"; $videos["error"]["message"] = __("Youtube API request did not work.", "wprobot"); return $videos; } else { if (isset($pxml->entry)) { foreach ($pxml->entry as $entry) { $media = $entry->children('http://search.yahoo.com/mrss/'); $title = $media->group->title; $description = $media->group->description; $attrs = $media->group->thumbnail[0]->attributes(); $thumbnail = '<img alt="' . $title . '" src="' . $attrs['url'] . '" />'; $thumbnailurl = $attrs['url']; //$yt = $entry->children('http://gdata.youtube.com/schemas/2007'); //$attrs = $yt->statistics->attributes(); //$viewCount = $attrs['viewCount']; $yt = $media->children('http://gdata.youtube.com/schemas/2007'); $videoid = $yt->videoid; $gd = $entry->children('http://schemas.google.com/g/2005'); if ($gd->rating) { $attrs = $gd->rating->attributes(); $rating = round($attrs['average'], 2); } else { $rating = 0; } $attrs = $media->group->player->attributes(); $playerUrl = $attrs['url']; $gd = $entry->children('http://schemas.google.com/g/2005'); if ($gd->comments->feedLink) { $attrs = $gd->comments->feedLink->attributes(); $commentsUrl = $attrs['href']; $commentsCount = $attrs['countHint']; } if (empty($options['wpr_yt_width'])) { $options['wpr_yt_width'] = "425"; } if (empty($options['wpr_yt_height'])) { $options['wpr_yt_height'] = "355"; } // 425 // 355 $video = ' <object width="' . $options['wpr_yt_width'] . '" height="' . $options['wpr_yt_height'] . '"> <param name="movie" value="http://www.youtube.com/v/' . $videoid . '?fs=1"></param> <param name="allowFullScreen" value="true"></param> <embed src="http://www.youtube.com/v/' . $videoid . '?fs=1&rel=0" type="application/x-shockwave-flash" width="' . $options['wpr_yt_width'] . '" height="' . $options['wpr_yt_height'] . '" allowfullscreen="true"></embed> </object>'; //$video ='<object type="application/x-shockwave-flash" style="width:'.$options['wpr_yt_width'].'px;height:'.$options['wpr_yt_height'].'px;" data="http://www.youtube.com/v/'.$videoid.'"> //<param name="movie" value="http://www.youtube.com/v/'.$videoid.'" /> //</object>'; if ($options['wpr_yt_striplinks_desc'] == 'yes') { $description = wpr_strip_selected_tags($description, array('a', 'iframe', 'script')); } $vid = $template; $vid = wpr_random_tags($vid); // Comments $commentspost = ""; preg_match('#\\{comments(.*)\\}#iU', $vid, $rmatches); if ($rmatches[0] != false || $getcomments == 1) { $comments = wpr_yt_getcomments($commentsUrl, $commentsCount); } if ($rmatches[0] != false && !empty($comments)) { $cnum = substr($rmatches[1], 1); for ($i = 0; $i < $commentsCount; $i++) { if ($i == $cnum) { break; } else { $commentspost .= "<p><b>Comment by " . $comments[$i]["author"] . "</b><br/>" . $comments[$i]["content"] . "</p>"; } } $vid = str_replace($rmatches[0], $commentspost, $vid); } $vid = str_replace("{description}", $description, $vid); $vid = str_replace("{thumbnail}", $thumbnail, $vid); //$vid = str_replace("{viewcount}", $viewCount, $vid); $vid = str_replace("{rating}", $rating, $vid); $noqkeyword = str_replace('"', '', $keyword); $vid = str_replace("{keyword}", $noqkeyword, $vid); $vid = str_replace("{Keyword}", ucwords($noqkeyword), $vid); $vid = str_replace("{video}", $video, $vid); $vid = str_replace("{title}", $title, $vid); $vid = str_replace("{url}", "http://www.youtube.com/watch?v=" . $videoid, $vid); if (function_exists("wpr_translate_partial")) { $vid = wpr_translate_partial($vid); } if (function_exists("wpr_rewrite_partial")) { $vid = wpr_rewrite_partial($vid, $options); } $customfield = array(); $customfield["youtubetitle"] = $title; $customfield["video"] = $videoid; $customfield["youtubethumbnail"] = $thumbnailurl; $customfield["youtuberating"] = $rating; $videos[$x]["unique"] = $videoid; $videos[$x]["title"] = $title; $videos[$x]["content"] = $vid; $videos[$x]["comments"] = $comments; $videos[$x]["customfield"] = $customfield; $x++; } if (empty($videos)) { $videos["error"]["module"] = "Youtube"; $videos["error"]["reason"] = "No content"; $videos["error"]["message"] = __("No (more) Youtube videos found.", "wprobot"); return $videos; } else { return $videos; } } else { $videos["error"]["module"] = "Youtube"; $videos["error"]["reason"] = "No content"; $videos["error"]["message"] = __("No (more) Youtube videos found.", "wprobot"); return $videos; } } }
function wpr_yahooanswerspost($keyword,$num,$start,$yapcat,$getcomments) { global $wpdb,$wpr_table_templates; if($keyword == "") { $return["error"]["module"] = "Yahoo Answers"; $return["error"]["reason"] = "No keyword"; $return["error"]["message"] = __("No keyword specified.","wprobot"); return $return; } $options = unserialize(get_option("wpr_options")); $template = $wpdb->get_var("SELECT content FROM " . $wpr_table_templates . " WHERE type = 'yahooanswers'"); if($template == false || empty($template)) { $return["error"]["module"] = "Yahoo Answers"; $return["error"]["reason"] = "No template"; $return["error"]["message"] = __("Module Template does not exist or could not be loaded.","wprobot"); return $return; } $pxml = wpr_yahooanswersrequest($keyword,$num,$start,$yapcat); if(!empty($pxml["error"])) {return $pxml;} $x = 0; $posts = array(); if ($pxml === False) { $posts["error"]["module"] = "Yahooanswers"; $posts["error"]["reason"] = "Request fail"; $posts["error"]["message"] = __("API request could not be sent.","wprobot"); return $posts; } else { if (isset($pxml->Question)) { foreach($pxml->Question as $question) { $attrs = $question->attributes(); $qid = $question['id']; $title = $question->Subject; $content = $question->Content; $url = $question->Link; $user = $question->UserNick; $answercount = $question->NumAnswers; if ($options['wpr_ya_striplinks_q']=='yes') {$content = wpr_strip_selected_tags($content, array('a','iframe','script'));} $post = $template; $post = wpr_random_tags($post); // Answers $answerpost = ""; preg_match('#\{answers(.*)\}#iU', $post, $rmatches); if ($rmatches[0] != false || $getcomments == 1) { $answers = wpr_yap_getanswers($qid,$answercount); } if ($rmatches[0] != false && !empty($answers)) { $answernum = substr($rmatches[1], 1); for ($i = 0; $i < $answercount; $i++) { if($i == $answernum) {break;} else { $answerpost .= "<p><i>Answer by ".$answers[$i]["author"]."</i><br/>".$answers[$i]["content"]."</p>"; // Remove posted answer from comments array unset($answers[$i]); } } $answers = array_values($answers); $post = str_replace($rmatches[0], $answerpost, $post); } else { $post = str_replace($rmatches[0], "", $post); } $content = str_replace("$", "$ ", $content); $post = str_replace("{question}", $content, $post); $noqkeyword = str_replace('"', '', $keyword); $post = str_replace("{keyword}", $noqkeyword, $post); $post = str_replace("{Keyword}", ucwords($noqkeyword), $post); $post = str_replace("{url}", $url, $post); $post = str_replace("{user}", $user, $post); $post = str_replace("{title}", $title, $post); if(function_exists("wpr_translate_partial")) { $post = wpr_translate_partial($post); } $posts[$x]["unique"] = $qid; $posts[$x]["title"] = $title; $posts[$x]["content"] = $post; $posts[$x]["comments"] = $answers; $x++; } if(empty($posts)) { $posts["error"]["module"] = "Yahooanswers"; $posts["error"]["reason"] = "No content"; $posts["error"]["message"] = __("No (more) Yahoo Answers content found.","wprobot"); return $posts; } else { return $posts; } } else { if (isset($pxml->Message)) { $message = __('There was a problem with your API request. This is the error Yahoo returned:',"wprobot").' <b>'.$pxml->Message.'</b>'; $posts["error"]["module"] = "Yahooanswers"; $posts["error"]["reason"] = "API fail"; $posts["error"]["message"] = $message; return $posts; } else { $posts["error"]["module"] = "Yahooanswers"; $posts["error"]["reason"] = "No content"; $posts["error"]["message"] = __("No (more) Yahoo Answers content found.","wprobot"); return $posts; } } } }
function wpr_rsspost($keyword="",$num,$start,$url,$comments="") { global $wpdb, $wpr_table_templates; $template = $wpdb->get_var("SELECT content FROM " . $wpr_table_templates . " WHERE type = 'rss'"); if($template == false || empty($template)) { $return["error"]["module"] = "RSS"; $return["error"]["reason"] = "No template"; $return["error"]["message"] = __("Module Template does not exist or could not be loaded.","wprobot"); return $return; } $options = unserialize(get_option("wpr_options")); $kw = $keyword; $url = trim($url); $url2 = urldecode($url); $start = 0; $found = 0; if ( function_exists('curl_init') ) { $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Konqueror/4.0; Microsoft Windows) KHTML/4.0.80 (like Gecko)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url2); curl_setopt($ch, CURLOPT_TIMEOUT, 60); $response = curl_exec($ch); if (!$response) { $return["error"]["module"] = "RSS"; $return["error"]["reason"] = "cURL Error"; $return["error"]["message"] = __("cURL Error Number ","wprobot").curl_errno($ch).": ".curl_error($ch); return $return; } curl_close($ch); } else { $response = @file_get_contents($url2); if (!$response) { $return["error"]["module"] = "RSS"; $return["error"]["reason"] = "cURL Error"; $return["error"]["message"] = __("cURL is not installed on this server!","wprobot"); return $return; } } $therss = @simplexml_load_string($response); if (!$therss){ $therss = @simplexml_load_file($url); } //echo "<pre>".print_r($therss)."</pre>"; if (empty($therss)) { $return["error"]["module"] = "RSS"; $return["error"]["reason"] = "RSS Error"; $return["error"]["message"] = __("RSS Feed could not be loaded or is empty!","wprobot"); return $return; } $posts = array(); if(isset($therss->entry)) {$fee = $therss->entry;$ffr="blogger";} elseif(isset($therss->channel->item)) {$fee = $therss->channel->item;} elseif(isset($therss->item)) {$fee = $therss->item;} else {$fee = "stop";} if($ffr=="blogger") { $ctitle = $therss->title; } else { $ctitle = $therss->channel->title; $clink = $therss->channel->link; $cdesc = $therss->channel->description; } if($fee == "stop") { $return["error"]["module"] = "RSS"; $return["error"]["reason"] = "Invalid Feed"; $return["error"]["message"] = __("Invalid Feed","wprobot"); return $return; } else { foreach ($fee as $item) { $allabort = 0; $abort = 0; //print_r($item); $title = $item->title; $title = preg_replace('/[\r\n\s]+/xms', ' ', trim($title)); $title = strip_tags($title); $guid = $item->guid; $gattr = $guid->attributes(); if($gattr['isPermaLink'] != "false" && !empty($guid)) {$unguid = $guid;} else {$unguid = "";} if($ffr=="blogger") { $link = $item->link; $descr = $item->summary; $fullcontent = $item->content; $date = $item->published; if($kw != "" && $options['wpr_rss_filter']=='yes') { $kw = str_replace('"', '', $kw); $kws = explode(" AND ", $kw); //print_r($kws); foreach($kws as $kwx) { $kw2 = " ".$kwx." "; //echo $kw2."<br>"; $c1 = stripos($fullcontent, $kw2); $c2 = stripos($descr, $kw2); $c3 = stripos($title, $kw2); if($c1 != false || $c2 != false || $c3 != false) { //echo "keyword was found<br>"; $abort = 0; } else { //echo "keyword was not found<br>"; $abort = 1; $allabort = 1; } } } foreach ($item->link as $link) { $attr = $link->attributes(); if($link['rel'] == "replies" && $link['type'] == "application/atom+xml") {$commentRss = $link['href'];} if($link['rel'] == "alternate") {$sourcelink = $link['href']; } //echo $sourcelink . "<br><br>"; print_r($link); } } else { $sourcelink = $item->link; $descr = $item->description; $date = $item->pubDate; $dc = $item->children("http://purl.org/dc/elements/1.1/"); $creator = (string) $dc->creator; $ccc = $item->children("http://purl.org/rss/1.0/modules/content/"); $fullcontent = (string)trim($ccc->encoded); if($kw != "" && $options['wpr_rss_filter']=='yes') { $kw = str_replace('"', '', $kw); $kws = explode(" AND ", $kw); //print_r($kws); foreach($kws as $kwx) { $kw2 = " ".$kwx." "; //echo $kw2."<br>"; $c1 = stripos($fullcontent, $kw2); $c2 = stripos($descr, $kw2); $c3 = stripos($title, $kw2); if($c1 != false || $c2 != false || $c3 != false) { //echo "keyword was found<br>"; $abort = 0; } else { //echo "keyword was not found<br>"; $abort = 1; $allabort = 1; } } } $wfw = $item->children("http://wellformedweb.org/CommentAPI/"); $commentRss = $wfw->commentRss; $enclosure = $item->enclosure["url"]; $media = $item->children('http://search.yahoo.com/mrss/'); if($media->player) { $attrs = $media->player->attributes(); $mediaplayer = $attrs['url']; } if($media->content) { $attrs = $media->content->attributes(); $mediacontent = $attrs['url']; $mediatype = $attrs['type']; $mediaheight = $attrs['height']; $mediawidth = $attrs['width']; $video =' <object width="'.$mediawidth.'" height="'.$mediaheight.'"> <param name="movie" value="'.$mediacontent.'"></param> <embed src="'.$mediacontent.'" type="'.$mediatype.'" width="'.$mediawidth.'" height="'.$mediaheight.'"></embed> </object>'; } if($media->thumbnail) { $attrs = $media->thumbnail[0]->attributes(); $mediathumbnail = $attrs['url']; } } if(!empty($unguid)) {$uid = $unguid;} else {$uid = $sourcelink;} if($abort == 0 && $allabort == 0 && !wpr_check_unique($uid)) { $source = '<a rel="nofollow" href="'.$sourcelink.'">'.$ctitle.'</a>'; if($fullcontent != "" && $options['wpr_rss_content']=='full') {$content = $fullcontent;} else {$content = $descr;} if ($options['wpr_rss_striplinks']=='yes') {$content = wpr_strip_selected_tags($content, array('a','iframe','script'));} if($options['wpr_rss_content']=='trunc') {$content = substr($content,0,350). "...";} $post = $template; $post = wpr_random_tags($post); $content = str_replace("$", "$ ", $content); $content = str_replace("\n\r", " ", $content); $content = str_replace("\n", " ", $content); $post = str_replace("{content}", $content, $post); $post = str_replace("{source}", $source, $post); $post = str_replace("{author}", $creator, $post); $noqkeyword = str_replace('"', '', $keyword); $post = str_replace("{keyword}", $noqkeyword, $post); $post = str_replace("{Keyword}", ucwords($noqkeyword), $post); $post = str_replace("{url}", $sourcelink, $post); $post = str_replace("{title}", $title, $post); $post = str_replace("{mediacontent}", $video, $post); $post = str_replace("{mediathumbnail}", $mediathumbnail, $post); $post = str_replace("{enclosure}", $enclosure, $post); if(function_exists("wpr_translate_partial")) { $post = wpr_translate_partial($post); } if(function_exists("wpr_rewrite_partial")) { $post = wpr_rewrite_partial($post,$options); } if(!empty($mediathumbnail)) {$customfield = $mediathumbnail;} elseif(!empty($enclosure)) {$customfield = $enclosure;} else {$customfield = "";} $customfield2 = array(); $customfield2["rsstitle"] = $title; $customfield2["rssmediacontent"] = $video; $customfield2["rssenclosure"] = $enclosure; $customfield2["rsssource"] = $sourcelink; $customfield2["rssimage"] = $customfield; $posts[$found]["unique"] = $uid; $posts[$found]["title"] = $title; $posts[$found]["content"] = $post; $posts[$found]["customfield"] = $customfield2; $found++; } if ($found==$num){break;} } } //print_r($posts); if($found > 0) { return $posts; } elseif($abort == 1) { // error: no posts found for keywords $posts["error"]["module"] = "RSS"; $posts["error"]["reason"] = "No content"; $posts["error"]["message"] = __("No post found in RSS feed for keyword $kw","wprobot"); return $posts; } elseif($found == 0) { // error: no posts found $posts["error"]["module"] = "RSS"; $posts["error"]["reason"] = "No content"; $posts["error"]["message"] = __("No unposted RSS items found!","wprobot"); return $posts; } elseif(empty($posts)) { // error: no posts found $posts["error"]["module"] = "RSS"; $posts["error"]["reason"] = "No content"; $posts["error"]["message"] = __("No items found in this feed!","wprobot"); return $posts; } else { // error: no posts found $posts["error"]["module"] = "RSS"; $posts["error"]["reason"] = "No content"; $posts["error"]["message"] = __("No items found in this feed!","wprobot"); return $posts; } }
function wpr_twitterpost($keyword,$num,$start,$optional="",$comments="") { global $wpdb,$wpr_table_templates; $options = unserialize(get_option("wpr_options")); if($keyword == "") { // If keyword is empty return error $return["error"]["module"] = "Twitter"; $return["error"]["reason"] = "No keyword"; $return["error"]["message"] = __("No keyword specified.","wprobot"); return $return; } $template = $wpdb->get_var("SELECT content FROM " . $wpr_table_templates . " WHERE type = 'twitter'"); if($template == false || empty($template)) { // If module template is empty return error $return["error"]["module"] = "Twitter"; $return["error"]["reason"] = "No template"; $return["error"]["message"] = __("Module Template does not exist or could not be loaded.","wprobot"); return $return; } $x = 0; $itemcontent = array(); $pxml = wpr_twitterrequest($keyword,$num,$start); // Send API request if(!empty($pxml["error"])) {return $pxml;} if ($pxml === False) { $itemcontent["error"]["module"] = "Twitter"; $itemcontent["error"]["reason"] = "Request fail"; $itemcontent["error"]["message"] = __("API request could not be sent.","wprobot"); return $itemcontent; } else { if (isset($pxml->entry)) { foreach($pxml->entry as $news) { $title = $news->title; $summary = $news->content; if ($options['wpr_twitter_striplinks']=='yes') {$summary = wpr_strip_selected_tags($summary, array('a','iframe','script'));} $authorurl = $news->author->uri; $authorname = $news->author->name; $date = $news->published; $author = "<a rel=\"nofollow\" href=\"$authorurl\">$authorname</a><br/><br/>"; $content = $template; $content = wpr_random_tags($content); $content = str_replace("{title}", $title, $content); $content = str_replace("{tweet}", $summary, $content); $content = str_replace("{author}", $author, $content); $content = str_replace("{authorname}", $authorname, $content); $content = str_replace("{authorurl}", $authorurl, $content); $content = str_replace("{date}", $date, $content); $noqkeyword = str_replace('"', '', $keyword); $content = str_replace("{keyword}", $noqkeyword, $content); $content = str_replace("{Keyword}", ucwords($noqkeyword), $content); $itemcontent[$x]["unique"] = $news->id; $itemcontent[$x]["title"] = $title; $itemcontent[$x]["content"] = $content; $x++; } if(empty($itemcontent)) { // Return error if no content has been found. $itemcontent["error"]["module"] = "Twitter"; $itemcontent["error"]["reason"] = "No content"; $itemcontent["error"]["message"] = __("No (more) Twitter items found.","wprobot"); return $itemcontent; } else { return $itemcontent; } } else { if (isset($pxml->Message)) { // Check for API error messages in results and if found return them. $message = __('There was a problem with your API request. This is the error returned:',"wprobot").' <b>'.$pxml->Message.'</b>'; $itemcontent["error"]["module"] = "Twitter"; $itemcontent["error"]["reason"] = "API fail"; $itemcontent["error"]["message"] = $message; return $itemcontent; } else { // Return error if no content has been found. $itemcontent["error"]["module"] = "Twitter"; $itemcontent["error"]["reason"] = "No content"; $itemcontent["error"]["message"] = __("No (more) Twitter items found.","wprobot"); return $itemcontent; } } } }
function wpr_articlepost($keyword, $num, $start, $optional = "", $comments = "") { global $wpdb, $wpr_table_templates; if ($keyword == "") { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "No keyword"; $return["error"]["message"] = __("No keyword specified.", "wprobot"); return $return; } $template = $wpdb->get_var("SELECT content FROM " . $wpr_table_templates . " WHERE type = 'article'"); if ($template == false || empty($template)) { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "No template"; $return["error"]["message"] = __("Module Template does not exist or could not be loaded.", "wprobot"); return $return; } $posts = array(); $options = unserialize(get_option("wpr_options")); $proxy == ""; if ($options["wpr_trans_use_proxies"] == "yes") { $proxies = str_replace("\r", "", $options["wpr_trans_proxies"]); $proxies = explode("\n", $proxies); $rand = array_rand($proxies); list($proxy, $proxytype, $proxyuser) = explode("|", $proxies[$rand]); } $keyword2 = $keyword; $keyword = str_replace(" ", "+", $keyword); $keyword = urlencode($keyword); $blist[] = "Mozilla/5.0 (compatible; Konqueror/4.0; Microsoft Windows) KHTML/4.0.80 (like Gecko)"; $blist[] = "Mozilla/5.0 (compatible; Konqueror/3.92; Microsoft Windows) KHTML/3.92.0 (like Gecko)"; $blist[] = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0; .NET CLR 1.1.4322; Windows-Media-Player/10.00.00.3990; InfoPath.2"; $blist[] = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; Dealio Deskball 3.0)"; $blist[] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; NeosBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; $ua = $blist[array_rand($blist)]; // SOURCE $source = array(); if ($options['wpr_eza_source_ab'] == 1 || $options['wpr_eza_source'] == "ab" || $options['wpr_eza_source'] == "rand") { $source[] = "ab"; } if ($options['wpr_eza_source_goa'] == 1 || $options['wpr_eza_source'] == "goa" || $options['wpr_eza_source'] == "rand") { $source[] = "goa"; } if ($options['wpr_eza_source_buk'] == 1 || $options['wpr_eza_source'] == "buk" || $options['wpr_eza_source'] == "rand") { $source[] = "buk"; } if ($options['wpr_eza_source_ezm'] == 1 || $options['wpr_eza_source'] == "ezm" || $options['wpr_eza_source'] == "rand") { $source[] = "ezm"; } $rand_key = array_rand($source); if ($source[$rand_key] == "ab") { $options['wpr_eza_source'] = "ab"; } elseif ($source[$rand_key] == "goa") { $options['wpr_eza_source'] = "goa"; } elseif ($source[$rand_key] == "buk") { $options['wpr_eza_source'] = "buk"; } elseif ($source[$rand_key] == "ezm") { $options['wpr_eza_source'] = "ezm"; } //print_r($source);echo "source: ".$rand_key . " ". $options['wpr_eza_source'] . "\n"; /*if($options["wpr_eza_source"] == "rand") { $rand = rand(0,3); if($rand == 0) {$options["wpr_eza_source"] = "buk"; } elseif($rand == 1) {$options["wpr_eza_source"] = "goa"; } elseif($rand == 2) {$options["wpr_eza_source"] = "ezm"; } else {$options["wpr_eza_source"] = "ab";} }*/ if ($options["wpr_eza_source"] == "buk") { return wpr_bukisapost($keyword, $num, $start, $optional, $comments, $options, $template, $ua, $proxy, $proxytype, $proxyuser); } elseif ($options["wpr_eza_source"] == "goa") { return wpr_goarticlepost($keyword, $num, $start, $optional, $comments, $options, $template, $ua, $proxy, $proxytype, $proxyuser); } elseif ($options["wpr_eza_source"] == "ezm") { return wpr_ezinemarkpost($keyword, $num, $start, $optional, $comments, $options, $template, $ua, $proxy, $proxytype, $proxyuser); } if (empty($start)) { $start = 0; } $search_url = "http://ezinearticles.com/search/?q={$keyword}&index={$start}"; // // make the cURL request to $search_url if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $ua); if ($proxy != "") { //curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch, CURLOPT_PROXY, $proxy); if ($proxyuser) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyuser); } if ($proxytype == "socks") { curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); } } curl_setopt($ch, CURLOPT_URL, $search_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 45); $html = curl_exec($ch); if (!$html) { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "cURL Error"; $return["error"]["message"] = __("cURL Error Number ", "wprobot") . curl_errno($ch) . ": " . curl_error($ch); return $return; } curl_close($ch); } else { $html = @file_get_contents($search_url); if (!$html) { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "cURL Error"; $return["error"]["message"] = __("cURL is not installed on this server!", "wprobot"); return $return; } } // parse the html into a DOMDocument $dom = new DOMDocument(); @$dom->loadHTML($html); // Grab Product Links $xpath = new DOMXPath($dom); $paras = $xpath->query("//div/h3/a"); $x = 0; $end = $num; if ($paras->length == 0) { $posts["error"]["module"] = "Article"; $posts["error"]["reason"] = "No content"; $posts["error"]["message"] = __("No (more) articles found.", "wprobot"); return $posts; } if ($end > $paras->length) { $end = $paras->length; } for ($i = 0; $i <= $end; $i++) { $para = $paras->item($i); if (empty($para)) { $posts["error"]["module"] = "Article"; $posts["error"]["reason"] = "No content"; $posts["error"]["message"] = __("No (more) articles found.", "wprobot"); return $posts; } else { $target_url = "http://ezinearticles.com" . $para->getAttribute('href'); // $target_url = "http://www.articlesbase.com" . $para->getAttribute('href'); // make the cURL request to $search_url if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $ua); if ($proxy != "") { //curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch, CURLOPT_PROXY, $proxy); if ($proxyuser) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyuser); } if ($proxytype == "socks") { curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); } } curl_setopt($ch, CURLOPT_URL, $target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 45); $html = curl_exec($ch); if (!$html) { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "cURL Error"; $return["error"]["message"] = __("cURL Error Number ", "wprobot") . curl_errno($ch) . ": " . curl_error($ch); return $return; } curl_close($ch); } else { $html = @file_get_contents($target_url); if (!$html) { $return["error"]["module"] = "Article"; $return["error"]["reason"] = "cURL Error"; $return["error"]["message"] = __("cURL is not installed on this server!", "wprobot"); return $return; } } // parse the html into a DOMDocument $dom = new DOMDocument(); @$dom->loadHTML($html); // Grab Article Title $xpath1 = new DOMXPath($dom); $paras1 = $xpath1->query("//div/h1"); $para1 = $paras1->item(0); $title = $para1->textContent; // Grab Article $xpath2 = new DOMXPath($dom); $paras2 = $xpath2->query("//div[@id='article-content']"); $para2 = $paras2->item(0); $string = $dom->saveXml($para2); //$string = preg_replace('#<div class="articles">(.*)</div>#smiU', '', $string); //$string = preg_replace('#<a title="(.*)" href="/authors/(.*)</a>#smiU', '', $string); //$string = preg_replace('#<strong>(.*)</strong>#smiU', '', $string); $string = strip_tags($string, '<p><strong><b><a><br>'); $string = str_replace(" ", "", $string); $string = str_replace("]]>", "", $string); $string = str_replace("\$", "\$ ", $string); if ($options['wpr_eza_striplinks'] == 'yes') { $string = wpr_strip_selected_tags($string, array('a', 'iframe', 'script')); } $articlebody .= $string . ' '; // Grab Ressource Box $xpath3 = new DOMXPath($dom); $paras3 = $xpath3->query("//div[@id='article-resource']"); //$para = $paras->item(0); $ressourcetext = ""; for ($y = 0; $y < $paras3->length; $y++) { //$paras->length $para3 = $paras3->item($y); $ressourcetext .= $dom->saveXml($para3); } $xpath2 = new DOMXPath($dom); $paras2 = $xpath2->query("//div[@id='article-body']/p"); $para2 = $paras2->item(0); $ressourcetext .= str_replace('href="', 'href="http://ezinearticles.com', $dom->saveXml($para2)); $title = utf8_decode($title); // Split into Pages if ($options['wpr_eza_split'] == "yes") { $articlebody = wordwrap($articlebody, $options['wpr_eza_splitlength'], "<!--nextpage-->"); } $post = $template; $post = wpr_random_tags($post); $post = str_replace("{article}", $articlebody, $post); $post = str_replace("{authortext}", $ressourcetext, $post); $noqkeyword = str_replace('"', '', $keyword2); $post = str_replace("{keyword}", $noqkeyword, $post); $post = str_replace("{Keyword}", ucwords($noqkeyword), $post); $post = str_replace("{title}", $title, $post); $post = str_replace("{url}", $target_url, $post); if (function_exists("wpr_rewrite_partial")) { $post = wpr_rewrite_partial($post, $options); } if (function_exists("wpr_translate_partial")) { $post = wpr_translate_partial($post); } $posts[$x]["unique"] = $target_url; $posts[$x]["title"] = $title; $posts[$x]["content"] = $post; $x++; } } return $posts; }