本文整理汇总了PHP中wpr_translate_partial函数的典型用法代码示例。如果您正苦于以下问题:PHP wpr_translate_partial函数的具体用法?PHP wpr_translate_partial怎么用?PHP wpr_translate_partial使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpr_translate_partial函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpr_bigcontentsearchpost
function wpr_bigcontentsearchpost($keyword,$num,$start) {
if(empty($keyword)) {
$return["error"]["module"] = "Big Content Search";
$return["error"]["reason"] = "No keyword";
$return["error"]["message"] = __("No keyword specified.","wprobot");
return $return;
}
$options = unserialize(get_option("wpr_options"));
$template = "{article}";
$x = 0;
$bcontent = array();$uniques = array();
for ($i = 1; $i <= $num; $i++) {
$pxml = wpr_bigcontentsearchrequest($keyword,$uniques);
if(!empty($pxml->error_msg)) {
$bcontent["error"]["module"] = "Big Content Search";
$bcontent["error"]["reason"] = "Request fail";
$bcontent["error"]["message"] = $pxml->error_msg;
return $bcontent;
} elseif ($pxml === False) {
$bcontent["error"]["module"] = "Big Content Search";
$bcontent["error"]["reason"] = "Request fail";
$bcontent["error"]["message"] = __("API request could not be sent.","wprobot");
return $bcontent;
} elseif (is_array($pxml) && !empty($pxml["error"]["message"])) {
return $pxml;
} elseif (isset($pxml->response->text)) {
$title = $pxml->response->title;
$text = $pxml->response->text;
$unique = $pxml->response->uid;
$content = $template;
$content = wpr_random_tags($content);
$content = str_replace("{article}", $text, $content);
$content = str_replace("{title}", $title, $content);
if(function_exists("wpr_translate_partial")) {
$content = wpr_translate_partial($content);
}
if(function_exists("wpr_rewrite_partial")) {
$content = wpr_rewrite_partial($content,$options);
}
$bcontent[$x]["unique"] = $unique;
$bcontent[$x]["title"] = $title;
$bcontent[$x]["content"] = $content;
$uniques[] = $unique;
$x++;
}
}
if(empty($bcontent)) {
$bcontent["error"]["module"] = "Big Content Search";
$bcontent["error"]["reason"] = "No content";
$bcontent["error"]["message"] = __("No (more) Big Content Search items found.","wprobot");
return $bcontent;
} else {
return $bcontent;
}
}
示例2: wpr_twitterpost
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);
if (function_exists("wpr_translate_partial")) {
$content = wpr_translate_partial($content);
}
if (function_exists("wpr_rewrite_partial")) {
$content = wpr_rewrite_partial($content, $options);
}
$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;
}
}
}
}
示例3: wpr_yahooanswerspost
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;
//.........这里部分代码省略.........
示例4: wpr_commissionjunctionpost
function wpr_commissionjunctionpost($keyword, $num, $start, $optional = "", $comments = "")
{
global $wpdb, $wpr_table_templates;
$buyUrl = "buy-url";
$imageUrl = "image-url";
$rPrice = "retail-price";
$sPrice = "sale-price";
$advertiserName = "advertiser-name";
$inStock = "in-stock";
$errormessage = "error-message";
if ($keyword == "") {
// If keyword is empty return error
$return["error"]["module"] = "Commission Junction";
$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 = 'commissionjunction'");
if ($template == false || empty($template)) {
// If module template is empty return error
$return["error"]["module"] = "Commission Junction";
$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_commissionjunctionrequest($keyword, $num, $start);
// Send API request
//print_r($pxml);
if (!empty($pxml["error"])) {
return $pxml;
}
if ($pxml === False) {
$itemcontent["error"]["module"] = "Commission Junction";
$itemcontent["error"]["reason"] = "Request fail";
$itemcontent["error"]["message"] = __("API request could not be sent.", "wprobot");
return $itemcontent;
} else {
if (isset($pxml->products->product)) {
foreach ($pxml->products->product as $item) {
$title = $item->name;
$summary = $item->description;
$url = $item->{$buyUrl};
$price = number_format($item->price, 2, '.', '');
$currency = $item->currency;
$listprice = $item->{$rPrice};
if ($listprice == "0.0") {
$listprice = "";
}
$saleprice = $item->{$sPrice};
if ($saleprice == "0.0") {
$saleprice = "";
}
$img = $item->{$imageUrl};
$advert = $item->{$advertiserName};
$isinstock = $item->{$inStock};
$skipit = 0;
$skip = $options["wpr_commissionjunction_skip"];
if ($skip == "noimg" || $skip == "nox") {
if (empty($img)) {
$skipit = 1;
}
}
if ($skip == "nodesc" || $skip == "nox") {
if (empty($summary)) {
$skipit = 1;
}
}
if (!empty($img)) {
$thumbnail = '<a alt="' . $title . '" href="' . $url . '" rel="nofollow"><img style="float:left;width:150px;margin: 0 20px 10px 0;" src="' . $img . '" /></a>';
} else {
$thumbnail = '';
}
if ($skipit == 0) {
$content = $template;
$content = wpr_random_tags($content);
$content = str_replace("{thumbnail}", $thumbnail, $content);
$content = str_replace("{imageurl}", $img, $content);
$content = str_replace("{title}", $title, $content);
$content = str_replace("{description}", $summary, $content);
$content = str_replace("{price}", $price, $content);
$content = str_replace("{currency}", $currency, $content);
$content = str_replace("{saleprice}", $saleprice, $content);
$content = str_replace("{listprice}", $listprice, $content);
$content = str_replace("{url}", $url, $content);
$noqkeyword = str_replace('"', '', $keyword);
$content = str_replace("{keyword}", $noqkeyword, $content);
$content = str_replace("{Keyword}", ucwords($noqkeyword), $content);
$content = str_replace("{advertiser}", $advert, $content);
$content = str_replace("{instock}", $isinstock, $content);
if (function_exists("wpr_translate_partial")) {
$content = wpr_translate_partial($content);
}
if (function_exists("wpr_rewrite_partial")) {
$content = wpr_rewrite_partial($content, $options);
}
if (!empty($item->upc) && $item->upc != "") {
$unique = $item->upc;
} elseif (!empty($item->sku)) {
//.........这里部分代码省略.........
示例5: wpr_yahoonewspost
function wpr_yahoonewspost($keyword, $num, $start, $optional = "", $comments = "")
{
global $wpdb, $wpr_table_templates;
if ($keyword == "") {
$return["error"]["module"] = "Yahoo News";
$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 = 'yahoonews'");
if ($template == false || empty($template)) {
$return["error"]["module"] = "Yahoo News";
$return["error"]["reason"] = "No template";
$return["error"]["message"] = __("Module Template does not exist or could not be loaded.", "wprobot");
return $return;
}
$x = 0;
$newscontent = array();
$pxml = wpr_yahoonewsrequest($keyword, $num, $start);
if (!empty($pxml["error"])) {
return $pxml;
}
if ($pxml === False) {
$newscontent["error"]["module"] = "Yahoonews";
$newscontent["error"]["reason"] = "Request fail";
$newscontent["error"]["message"] = __("API request could not be sent.", "wprobot");
return $newscontent;
} else {
if (isset($pxml->results->results)) {
foreach ($pxml->results->results as $news) {
// abstract, title, date, clickurl, source, language, ...
$title = $news->title;
$summary = $news->content;
$url = $news->unescapedUrl;
$source = $news->publisher;
$sourceurl = $news->sourceurl;
$language = $news->language;
$date = $news->publishedDate;
$thumb = $news->image->url;
$source = "Read more on <a rel=\"nofollow\" href=\"{$url}\">{$source}</a><br/><br/>";
if ($thumb != "") {
$thumbnail = '<a href="' . $url . '" rel="nofollow"><img style="width:150px;float:left;margin: 0 20px 10px 0;" src="' . $thumb . '" /></a>';
} else {
$thumbnail = '';
}
$content = $template;
$content = wpr_random_tags($content);
$content = str_replace("{thumbnail}", $thumbnail, $content);
$content = str_replace("{title}", $title, $content);
$summary = strip_tags($summary);
$summary = str_replace("\$", "\$ ", $summary);
$content = str_replace("{summary}", $summary, $content);
$content = str_replace("{source}", $source, $content);
$content = str_replace("{url}", $url, $content);
$content = str_replace("{date}", $date, $content);
$content = str_replace("{sourceurl}", $sourceurl, $content);
$content = str_replace("{language}", $language, $content);
$noqkeyword = str_replace('"', '', $keyword);
$content = str_replace("{keyword}", $noqkeyword, $content);
$content = str_replace("{Keyword}", ucwords($noqkeyword), $content);
if (function_exists("wpr_translate_partial")) {
$content = wpr_translate_partial($content);
}
if (function_exists("wpr_rewrite_partial")) {
$content = wpr_rewrite_partial($content, $options);
}
$newscontent[$x]["unique"] = $url;
$newscontent[$x]["title"] = $title;
$newscontent[$x]["content"] = $content;
$x++;
}
if (isset($pxml->description)) {
$message = __('There was a problem with your API request. This is the error Yahoo returned:', "wprobot") . ' <b>' . $pxml->description . '</b>';
$newscontent["error"]["module"] = "Yahoonews";
$newscontent["error"]["reason"] = "API fail";
$newscontent["error"]["message"] = $message;
return $newscontent;
} elseif (empty($newscontent)) {
$newscontent["error"]["module"] = "Yahoonews";
$newscontent["error"]["reason"] = "No content";
$newscontent["error"]["message"] = __("No (more) Yahoo news items found.", "wprobot");
return $newscontent;
} else {
return $newscontent;
}
} else {
if (isset($pxml->description)) {
$message = __('There was a problem with your API request. This is the error Yahoo returned:', "wprobot") . ' <b>' . $pxml->description . '</b>';
$newscontent["error"]["module"] = "Yahoonews";
$newscontent["error"]["reason"] = "API fail";
$newscontent["error"]["message"] = $message;
return $newscontent;
} else {
$newscontent["error"]["module"] = "Yahoonews";
$newscontent["error"]["reason"] = "No content";
$newscontent["error"]["message"] = __("No (more) Yahoo news items found.", "wprobot");
return $newscontent;
}
}
}
//.........这里部分代码省略.........
示例6: wpr_plrpost
function wpr_plrpost($keyword, $num, $start, $optional = "", $comments = "")
{
global $wpdb, $wpr_table_templates, $wpr_cache;
/*if($keyword == "") {
$return["error"]["module"] = "Yahoo News";
$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 = 'plr'");
if ($template == false || empty($template)) {
$template = "{article}";
}
$wpr_saveurl = WPR_URLPATH . "plr";
$folder = $wpr_cache . "/";
$plrcontent = array();
for ($i = 0; $i < $num; $i++) {
$filename = wpr_plr_randomfile($folder, 'txt|pdf');
//echo $filename . "<br>";
$output = "";
$title = "";
$file = fopen($filename, "r");
if (empty($file) || $file == false) {
$plrcontent["error"]["module"] = "PLR";
$plrcontent["error"]["reason"] = "No content";
$plrcontent["error"]["message"] = __("No (more) PLR items found.", "wprobot");
return $plrcontent;
}
while (!feof($file)) {
if (empty($title)) {
$title = fgets($file, 4096);
}
$output = $output . fgets($file, 4096);
//read file line by line into variable
}
fclose($file);
//$output = utf8_encode($output);
if (function_exists('iconv')) {
$output = iconv('UTF-8', 'ISO-8859-1//IGNORE', $output);
}
//echo $title . "<br>";
//echo $output . "<br>";
if (!empty($output) && !empty($title)) {
// Keyword filter
$kw = $keyword;
if ($kw != "" && $options['wpr_plr_filter'] == 'yes') {
$kw = str_replace('"', '', $kw);
$kws = explode(" AND ", $kw);
//print_r($kws);
foreach ($kws as $kwx) {
$kw2 = " " . $kwx . " ";
//echo $kw2."<br>";
$c1 = stripos($output, $kw2);
$c2 = stripos($title, $kw2);
if ($c1 != false || $c2 != false) {
//echo "keyword was found<br>";
$abort = 0;
} else {
//echo "keyword was not found<br>";
$plrcontent["error"]["module"] = "PLR";
$plrcontent["error"]["reason"] = "IncNum";
$plrcontent["error"]["message"] = __("File skipped because filter keyword was not found.", "wprobot");
return $plrcontent;
}
}
}
$content = $template;
$content = wpr_random_tags($content);
$content = str_replace("{article}", $output, $content);
$content = str_replace("{title}", $title, $content);
$noqkeyword = str_replace('"', '', $keyword);
$content = str_replace("{keyword}", $noqkeyword, $content);
$content = str_replace("{Keyword}", ucwords($noqkeyword), $content);
if (function_exists("wpr_translate_partial")) {
$content = wpr_translate_partial($content);
}
if (function_exists("wpr_rewrite_partial")) {
$content = wpr_rewrite_partial($content, $options);
}
$ren = rename($filename, $filename . "2");
if ($ren == true) {
} else {
}
$plrcontent[$i]["unique"] = rand(1, 10000);
$plrcontent[$i]["title"] = $title;
$plrcontent[$i]["content"] = $content;
}
}
if (empty($plrcontent)) {
$plrcontent["error"]["module"] = "PLR";
$plrcontent["error"]["reason"] = "No content";
$plrcontent["error"]["message"] = __("No (more) PLR items found.", "wprobot");
return $plrcontent;
} else {
return $plrcontent;
}
}
示例7: wpr_youtubepost
//.........这里部分代码省略.........
//$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;
}
}
}
示例8: wpr_clickbankpost
//.........这里部分代码省略.........
$paras1 = $xpath1->query("//a[@class='a18 dblue']");
$end = $numb + $num;
$x = 0;
if ($paras1->length == 0) {
$posts["error"]["module"] = "Clickbank";
$posts["error"]["reason"] = "No content";
$posts["error"]["message"] = __("No (more) Clickbank products found.", "wprobot");
return $posts;
}
if ($end > $paras1->length) {
$end = $paras1->length;
}
for ($i = $numb; $i < $end; $i++) {
//for ($i = $numb; $i < $paras1->length; $i++ ) { //$paras->length
/*if($i < $num) {
$para1 = $paras1->item($i);
$urlt = $para1->textContent;
if($urlt == '' | $urlt == null) {
$posts["error"]["module"] = "Clickbank";
$posts["error"]["reason"] = "No content";
$posts["error"]["message"] = __("No (more) Clickbank products found.","wprobot");
return $posts;
} else {*/
$xpath2 = new DOMXPath($dom);
$paras2 = $xpath2->query("//span[@class='v13']");
$para2 = $paras2->item($i);
$description = $para2->textContent;
$xpath3 = new DOMXPath($dom);
$paras3 = $xpath3->query("//a[@class='a18 dblue']");
$para3 = $paras3->item($i);
$title = $para3->textContent;
$url = $para3->getAttribute('href');
$url = explode("/id/", $url);
$url = "http://" . $affid . "." . $url[1] . ".hop.clickbank.net";
$xpath4 = new DOMXPath($dom);
$paras4 = $xpath4->query("//div[@class='screenshot']/a/img");
$para4 = $paras4->item($i);
$thumbnail = $para4->getAttribute('src');
$link = '<a rel="nofollow" href="' . $url . '">' . $title . '</a>';
$image = '<a href="' . $url . '" rel="nofollow"><img style="float:left;margin: 0 20px 10px 0;" src="' . $thumbnail . '" alt="' . $title . '" /></a>';
$ff = $options['wpr_cb_filter'];
$stop = 0;
if ($ff == "yes") {
$pos = strpos($description, "Commission");
if ($pos !== false) {
$stop = 1;
}
$pos = strpos($description, "commission");
if ($pos !== false) {
$stop = 1;
}
$pos = strpos($description, "affiliate");
if ($pos !== false) {
$stop = 1;
}
$pos = strpos($description, "Affiliate");
if ($pos !== false) {
$stop = 1;
}
$pos = strpos($description, "affiliates");
if ($pos !== false) {
$stop = 1;
}
}
if ($stop == 0) {
$post = $template;
$post = wpr_random_tags($post);
$post = str_replace("{thumbnail}", $image, $post);
$post = str_replace("{imageurl}", $thumbnail, $post);
$post = str_replace("{link}", $link, $post);
$post = str_replace("{description}", $description, $post);
$post = str_replace("{url}", $url, $post);
$noqkeyword = str_replace('"', '', $keyword);
$post = str_replace("{keyword}", $noqkeyword, $post);
$post = str_replace("{Keyword}", ucwords($noqkeyword), $post);
$post = str_replace("{title}", $title, $post);
if (function_exists("wpr_translate_partial")) {
$post = wpr_translate_partial($post);
}
if (function_exists("wpr_rewrite_partial")) {
$post = wpr_rewrite_partial($post, $options);
}
$posts[$x]["unique"] = $title;
$posts[$x]["title"] = $title;
$posts[$x]["content"] = $post;
$x++;
}
//}
//}
}
if (empty($posts)) {
$posts["error"]["module"] = "Clickbank";
$posts["error"]["reason"] = "No content";
$posts["error"]["message"] = __("No (more) Clickbank ads found.", "wprobot");
return $posts;
} else {
return $posts;
}
}
示例9: wpr_flickrpost
function wpr_flickrpost($keyword,$num,$start,$optional="",$getcomments) {
global $wpdb,$wpr_table_templates;
if($keyword == "") {
$return["error"]["module"] = "Flickr";
$return["error"]["reason"] = "No keyword";
$return["error"]["message"] = __("No keyword specified.","wprobot");
return $return;
}
$options = unserialize(get_option("wpr_options"));
$width = $options["wpr_fl_width"];
$apikey = trim($options["wpr_fl_apikey"]);
$cont = $options["wpr_fl_content"];
$sort = $options["wpr_fl_sort"];
$license = $options["wpr_fl_license"];
$template = $wpdb->get_var("SELECT content FROM " . $wpr_table_templates . " WHERE type = 'flickr' AND name = 'standard'");
if($template == false || empty($template)) {
$return["error"]["module"] = "Flickr";
$return["error"]["reason"] = "No template";
$return["error"]["message"] = __("Module Template does not exist or could not be loaded.","wprobot");
return $return;
}
$pxml = wpr_flickrrequest($keyword,$apikey,$cont,$sort,$license,$start,$num);
if(!empty($pxml["error"])) {return $pxml;}
//echo "<br/>---FLICKR---<br/>";print_r($pxml);echo "<br/>---FLICKR---<br/>";
$end = $start + $num;
//$i = 0;
$x = 0;
$photos = array();
if ($pxml === False) {
$photos["error"]["module"] = "Flickr";
$photos["error"]["reason"] = "API fail";
$photos["error"]["message"] = __("Flickr API request did not work.","wprobot");
return $photos;
} else {
if (isset($pxml->err)) {
$message = '<p>'.__("There was a problem with your Flickr API request. This is the error Flickr returned:","wprobot").'</p>
<p><i><b>'.$pxml->err['code'].':</b> '.$pxml->err['msg'].'</i></p>';
$photos["error"]["module"] = "Flickr";
$photos["error"]["reason"] = "API fail";
$photos["error"]["message"] = $message;
return $photos;
}
if (isset($pxml->photos->photo)) {
foreach($pxml->photos->photo as $photo) {
//if($i >= $start && $i <= $end) { // PROBLEM HERE ???!!!
$title = $photo['title'];
$date = $photo['datetaken'];
$owner = $photo['ownername'];
$urlt = $photo['url_t'];
$urls = $photo['url_s'];
$urlm = $photo['url_m'];
$urlo = $photo['url_o'];
//$description = $photo['description'];
$description = $photo->description;
$ownerid = $photo['owner'];
$photoid = $photo['id'];
if($options["wpr_fl_size"] == "small") {
$img = '<img alt="'.$keyword.'" src="'.$urls.'" width="'.$width.'"/><br/>';
} elseif($options["wpr_fl_size"] == "med") {
$img = '<img alt="'.$keyword.'" src="'.$urlm.'" width="'.$width.'"/><br/>';
} else {
$img = '<img alt="'.$keyword.'" src="'.$urlo.'" width="'.$width.'"/><br/>';
}
$link = 'http://www.flickr.com/photos/'.$ownerid.'/'.$photoid;
$photo = $template;
$photo = wpr_random_tags($photo);
// Comments
$commentspost = "";
preg_match('#\{comments(.*)\}#iU', $photo, $rmatches);
if ($rmatches[0] != false || $getcomments == 1) {
$comments = wpr_fl_getcomments($photoid,$apikey);
}
if ($rmatches[0] != false && !empty($comments)) {
$cnum = substr($rmatches[1], 1);
for ($i = 0; $i < count($comments); $i++) {
if($i == $cnum) {break;} else {
$commentspost .= "<p><b>Comment by ".$comments[$i]["author"]."</b><br/>".$comments[$i]["content"]."</p>";
}
}
$photo = str_replace($rmatches[0], $commentspost, $photo);
}
$photo = str_replace("{image}", $img, $photo);
$photo = str_replace("{date}", $date, $photo);
$photo = str_replace("{owner}", $owner, $photo);
$photo = str_replace("{url}", $link, $photo);
$photo = str_replace("{keyword}", $keyword, $photo);
$photo = str_replace("{description}", $description, $photo);
$photo = str_replace("{title}", $title, $photo);
if(function_exists("wpr_translate_partial")) {
$photo = wpr_translate_partial($photo);
//.........这里部分代码省略.........
示例10: wpr_shareasalepost
function wpr_shareasalepost($keyword, $num, $start, $optional = "", $comments = "")
{
global $wpdb, $wpr_table_templates;
$options = unserialize(get_option("wpr_options"));
// Load WP Robot Options Array
$affid = $options['wpr_shareasale_aff'];
// If necessary retreive the API key from the options...
if (empty($affid)) {
$affid = "435192";
}
if ($keyword == "") {
// If keyword is empty return error
$return["error"]["module"] = "Shareasale";
$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 = 'shareasale'");
if ($template == false || empty($template)) {
// If module template is empty return error
$return["error"]["module"] = "Shareasale";
$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();
if (empty($start)) {
$start = 1;
}
if (empty($num)) {
$num = 1;
}
$total = $num + $start;
if (($handle = fopen(WPR_URLPATH . "datafeed.csv", "r")) !== FALSE) {
for ($i = 1; $i < $total; $i++) {
if ($i >= $start && $x != $num) {
$data = fgetcsv($handle, 0, "|");
$xxx = count($data);
//echo "<p> $xxx fields in line $i: <br /></p>\n";
//print_r($data);
$pid = $data[0];
$title = $data[1];
$url = str_replace("YOURUSERID", $affid, $data[4]);
$thumb = $data[5];
$bigimage = $data[6];
$description = $data[11];
$merchant = $data[3];
$custom1 = $data[12];
$custom2 = $data[13];
$custom3 = $data[14];
$category = $data[9];
$manufacturer = $data[19];
$isbn = $data[24];
$status = $data[18];
$price = "\$ " . $data[7];
$listprice = "\$ " . $data[8];
if ($thumb != "") {
$thumbnail = '<a href="' . $url . '" rel="nofollow"><img style="float:left;margin: 0 20px 10px 0;" src="' . $thumb . '" /></a>';
} else {
$thumbnail = '';
}
$abort = 0;
if ($keyword != "" && $options['wpr_shareasale_filter'] == 'yes') {
$keyword = str_replace('"', '', $keyword);
$keywords = explode(" AND ", $keyword);
foreach ($keywords as $kwx) {
$kw2 = " " . $kwx . " ";
//echo $kw2."<br/>";
$c2 = stripos($description, $kw2);
$c3 = stripos($title, $kw2);
if ($c2 != false || $c3 != false) {
// echo "keyword was found $c2 $c3<br/>";
$abort = 0;
} else {
//echo "keyword was not found<br/>";
$abort = 1;
}
}
}
$content = $template;
$content = wpr_random_tags($content);
$content = str_replace("{thumbnail}", $thumbnail, $content);
$content = str_replace("{title}", $title, $content);
$content = str_replace("{bigimage}", $bigimage, $content);
$content = str_replace("{description}", $description, $content);
$content = str_replace("{url}", $url, $content);
$content = str_replace("{keyword}", $keyword, $content);
$content = str_replace("{merchant}", $merchant, $content);
$content = str_replace("{custom1}", $custom1, $content);
$content = str_replace("{custom2}", $custom2, $content);
$content = str_replace("{custom3}", $custom3, $content);
$content = str_replace("{category}", $category, $content);
$content = str_replace("{manufacturer}", $manufacturer, $content);
$content = str_replace("{isbn}", $isbn, $content);
$content = str_replace("{status}", $status, $content);
$content = str_replace("{price}", $price, $content);
$content = str_replace("{listprice}", $listprice, $content);
if (function_exists("wpr_translate_partial")) {
$content = wpr_translate_partial($content);
//.........这里部分代码省略.........
示例11: wpr_itunespost
function wpr_itunespost($keyword, $num, $start, $optional = "", $comments = "")
{
global $wpdb, $wpr_table_templates;
$options = unserialize(get_option("wpr_options"));
$uid = $options['wpr_itunes_unique'];
if ($keyword == "") {
// If keyword is empty return error
$return["error"]["module"] = "iTunes";
$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 = 'itunes'");
if ($template == false || empty($template)) {
// If module template is empty return error
$return["error"]["module"] = "iTunes";
$return["error"]["reason"] = "No template";
$return["error"]["message"] = __("Module Template does not exist or could not be loaded.", "wprobot");
return $return;
}
$x = 0;
$r = 0;
$itemcontent = array();
$pxml = wpr_itunesrequest($keyword, $num, $start, $options);
// Send API request
if (is_array($pxml) && isset($pxml["error"])) {
return $pxml;
}
if ($pxml === False) {
$itemcontent["error"]["module"] = "iTunes";
$itemcontent["error"]["reason"] = "Request fail";
$itemcontent["error"]["message"] = __("API request could not be sent.", "wprobot");
return $itemcontent;
} else {
if (isset($pxml->results)) {
foreach ($pxml->results as $item) {
if ($r >= $start) {
$artistName = $item->artistName;
$collectionName = $item->collectionName;
$trackId = $item->trackId;
$collectionId = $item->collectionId;
$trackName = $item->trackName;
$artistViewUrl = $item->artistViewUrl;
$collectionViewUrl = $item->collectionViewUrl;
$trackViewUrl = $item->trackViewUrl;
$previewUrl = $item->previewUrl;
$artworkUrl30 = $item->artworkUrl30;
$artworkUrl60 = $item->artworkUrl60;
$artworkUrl100 = $item->artworkUrl100;
$collectionPrice = $item->collectionPrice;
$trackPrice = $item->trackPrice;
$currency = $item->currency;
$primaryGenreName = $item->primaryGenreName;
if ($artworkUrl60 != "") {
$thumbnail = '<a href="' . $collectionViewUrl . '" rel="nofollow"><img style="float:left;margin: 0 20px 10px 0;" src="' . $artworkUrl60 . '" /></a>';
} else {
$thumbnail = '';
}
$content = $template;
$content = wpr_random_tags($content);
$content = str_replace("{thumbnail}", $thumbnail, $content);
$content = str_replace("{keyword}", $keyword, $content);
$content = str_replace("{trackname}", $trackName, $content);
$content = str_replace("{collectionname}", $collectionName, $content);
$content = str_replace("{artistname}", $artistName, $content);
$content = str_replace("{artworkUrl30}", $artworkUrl30, $content);
$content = str_replace("{artworkUrl60}", $artworkUrl60, $content);
$content = str_replace("{artworkUrl100}", $artworkUrl100, $content);
$content = str_replace("{collectionPrice}", $collectionPrice, $content);
$content = str_replace("{trackPrice}", $trackPrice, $content);
$content = str_replace("{currency}", $currency, $content);
$content = str_replace("{genre}", $primaryGenreName, $content);
$content = str_replace("{artisturl}", $artistViewUrl, $content);
$content = str_replace("{collectionurl}", $collectionViewUrl, $content);
$content = str_replace("{trackurl}", $trackViewUrl, $content);
$content = str_replace("{previewurl}", $previewUrl, $content);
if (function_exists("wpr_translate_partial")) {
$content = wpr_translate_partial($content);
}
if (function_exists("wpr_rewrite_partial")) {
$content = wpr_rewrite_partial($content, $options);
}
if ($uid == "track") {
$uid2 = $trackId;
} else {
$uid2 = $collectionId;
}
$itemcontent[$x]["unique"] = $uid2;
$itemcontent[$x]["title"] = $artistName . " - " . $trackName;
$itemcontent[$x]["content"] = $content;
$x++;
}
$r++;
}
if (empty($itemcontent)) {
// Return error if no content has been found.
$itemcontent["error"]["module"] = "iTunes";
$itemcontent["error"]["reason"] = "No content";
$itemcontent["error"]["message"] = __("No (more) Yahoo news items found.", "wprobot");
return $itemcontent;
//.........这里部分代码省略.........
示例12: wpr_yelppost
//.........这里部分代码省略.........
if ($yy >= $start && $yy < $end) {
$title = $item->name;
$url = $item->url;
$address1 = $item->address1;
$address2 = $item->address2;
$address3 = $item->address3;
$address = $address1 . "<br/>" . $address2 . "<br/>" . $address3 . "<br/>";
$city = $item->city;
$phone = $item->phone;
$photo_url = $item->photo_url;
$avg_rating = $item->avg_rating;
$review_count = $item->review_count;
$reviews = array();
if (isset($item->reviews)) {
$r = 0;
foreach ($item->reviews as $review) {
$reviews[$r]["author"] = $review->user_name;
$reviews[$r]["rating"] = $review->rating;
$rtemplate = "<i>Review by {author}</i><br/>{content}<br/><b>Rating: {rating}</b><br/><br/>";
$rtemplate = str_replace("{content}", strip_tags($review->text_excerpt, '<br><strong>'), $rtemplate);
$rtemplate = str_replace("{rating}", $review->rating, $rtemplate);
$rtemplate = str_replace("{author}", $review->user_name, $rtemplate);
$reviews[$r]["content"] = $rtemplate;
$r++;
}
}
$source = "Read more on <a rel=\"nofollow\" href=\"{$url}\">{$source}</a><br/><br/>";
if ($photo_url != "") {
$thumbnail = '<a href="' . $url . '" rel="nofollow"><img style="float:left;margin: 0 20px 10px 0;" src="' . $photo_url . '" /></a>';
} else {
$thumbnail = '';
}
$content = $template;
$content = wpr_random_tags($content);
$content = str_replace("{thumbnail}", $thumbnail, $content);
$content = str_replace("{title}", $title, $content);
$content = str_replace("{rating}", $avg_rating, $content);
$content = str_replace("{reviewscount}", $review_count, $content);
$content = str_replace("{url}", $url, $content);
$content = str_replace("{keyword}", $keyword, $content);
$content = str_replace("{address}", $address1, $content);
$content = str_replace("{city}", $city, $content);
// reviews
$reviewspost = "";
$reviewsnum = $review_count;
preg_match('#\\{reviews(.*)\\}#iU', $content, $rmatches);
if ($rmatches[0] == false) {
} elseif (empty($reviews)) {
$content = str_replace($rmatches[0], $reviewspost, $content);
} else {
$reviewnum = substr($rmatches[1], 1);
for ($i = 0; $i < $reviewnum; $i++) {
if ($i == $reviewsnum || $i == 3) {
break;
} else {
$reviewspost .= $reviews[$i]["content"];
}
}
$content = str_replace($rmatches[0], $reviewspost, $content);
}
if (function_exists("wpr_translate_partial")) {
$content = wpr_translate_partial($content);
}
if (function_exists("wpr_rewrite_partial")) {
$content = wpr_rewrite_partial($content, $options);
}
$itemcontent[$x]["unique"] = $item->id;
$itemcontent[$x]["title"] = $title;
$itemcontent[$x]["content"] = $content;
$x++;
}
$yy++;
}
if (empty($itemcontent)) {
// Return error if no content has been found.
$itemcontent["error"]["module"] = "Yelp";
$itemcontent["error"]["reason"] = "No content";
$itemcontent["error"]["message"] = __("No (more) Yelp items found.", "wprobot");
return $itemcontent;
} else {
return $itemcontent;
}
} else {
if (isset($pxml->message->text) && $pxml->message->code != 0) {
// 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 by Yelp:', "wprobot") . ' <b>' . $pxml->message->code . ': ' . $pxml->message->text . '</b>';
$itemcontent["error"]["module"] = "Yelp";
$itemcontent["error"]["reason"] = "API fail";
$itemcontent["error"]["message"] = $message;
return $itemcontent;
} else {
// Return error if no content has been found.
$itemcontent["error"]["module"] = "Yelp";
$itemcontent["error"]["reason"] = "No content";
$itemcontent["error"]["message"] = __("No (more) Yelp items found.", "wprobot");
return $itemcontent;
}
}
}
}
示例13: wpr_eventfulpost
function wpr_eventfulpost($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"] = "Eventful";
$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 = 'eventful'");
if ($template == false || empty($template)) {
// If module template is empty return error
$return["error"]["module"] = "Eventful";
$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_eventfulrequest($keyword, $num, $start, $options);
// Send API request
if (!empty($pxml["error"])) {
return $pxml;
}
if ($pxml === False) {
$itemcontent["error"]["module"] = "Eventful";
$itemcontent["error"]["reason"] = "Request fail";
$itemcontent["error"]["message"] = __("API request could not be sent.", "wprobot");
return $itemcontent;
} else {
if (isset($pxml->events)) {
foreach ($pxml->events->event as $item) {
$attrs = $item->attributes();
$uid = $attrs['id'];
$title = $item->title;
$description = trim($item->description);
$url = $item->url;
$start_time = $item->start_time;
$stop_time = $item->stop_time;
$venue_name = $item->venue_name;
$venue_url = $item->venue_url;
$venue_address = $item->venue_address;
$city_name = $item->city_name;
$country_name = $item->country_name;
$content = $template;
$content = wpr_random_tags($content);
$content = str_replace("{title}", $title, $content);
$content = str_replace("{description}", $description, $content);
$content = str_replace("{url}", $url, $content);
$content = str_replace("{keyword}", $keyword, $content);
$content = str_replace("{begin}", $start_time, $content);
$content = str_replace("{end}", $stop_time, $content);
$content = str_replace("{venuename}", $venue_name, $content);
$content = str_replace("{venueurl}", $venue_url, $content);
$content = str_replace("{venueaddress}", $venue_address, $content);
$content = str_replace("{city}", $city_name, $content);
$content = str_replace("{country}", $country_name, $content);
if (function_exists("wpr_translate_partial")) {
$content = wpr_translate_partial($content);
}
if (function_exists("wpr_rewrite_partial")) {
$content = wpr_rewrite_partial($content, $options);
}
if ("yes" == $options['wpr_eventful_skip'] && empty($description) && $num == 1) {
$itemcontent["error"]["module"] = "Eventful";
$itemcontent["error"]["reason"] = "No content";
$itemcontent["error"]["message"] = __("Event skipped because of empty description.", "wprobot");
return $itemcontent;
}
$itemcontent[$x]["unique"] = $uid;
$itemcontent[$x]["title"] = $title;
$itemcontent[$x]["content"] = $content;
$x++;
}
if (empty($itemcontent)) {
// Return error if no content has been found.
$itemcontent["error"]["module"] = "Eventful";
$itemcontent["error"]["reason"] = "No content";
$itemcontent["error"]["message"] = __("No (more) Yahoo news items found.", "wprobot");
return $itemcontent;
} else {
return $itemcontent;
}
} else {
if (isset($pxml->description)) {
// 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->description . '</b>';
$itemcontent["error"]["module"] = "Eventful";
$itemcontent["error"]["reason"] = "API fail";
$itemcontent["error"]["message"] = $message;
return $itemcontent;
} else {
// Return error if no content has been found.
$itemcontent["error"]["module"] = "Eventful";
$itemcontent["error"]["reason"] = "No content";
$itemcontent["error"]["message"] = __("No (more) Eventful items found.", "wprobot");
return $itemcontent;
}
//.........这里部分代码省略.........
示例14: wpr_articlepost
//.........这里部分代码省略.........
$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;
}
示例15: wpr_oodlepost
function wpr_oodlepost($keyword, $num, $start, $optional = "", $comments = "")
{
global $wpdb, $wpr_table_templates;
if ($keyword == "") {
// If keyword is empty return error
$return["error"]["module"] = "oodle";
$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 = 'oodle'");
if ($template == false || empty($template)) {
// If module template is empty return error
$return["error"]["module"] = "oodle";
$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_oodlerequest($keyword, $num, $start);
// Send API request
if (!empty($pxml["error"])) {
return $pxml;
}
if ($pxml === False) {
$itemcontent["error"]["module"] = "oodle";
$itemcontent["error"]["reason"] = "Request fail";
$itemcontent["error"]["message"] = __("API request could not be sent.", "wprobot");
return $itemcontent;
} else {
if (isset($pxml->listings->element)) {
foreach ($pxml->listings->element as $item) {
$title = $item->title;
$listing = $item->body;
$url = $item->url;
$img = $item->images->element[0]->src;
$address = $item->location->address;
$city = $item->location->zip . " " . $item->location->name . ", " . $item->location->country;
$lat = $item->location->latitude;
$long = $item->location->longitude;
$price = $item->attributes->price_display;
$price = str_replace("\$", "\$ ", $price);
$condition = $item->attributes->condition;
$features = $item->attributes->features;
$seller_type = $item->attributes->seller_type;
$delivery = $item->attributes->delivery;
if ($img != "") {
$thumbnail = '<a href="' . $url . '" rel="nofollow"><img style="float:left;margin: 0 20px 10px 0;" src="' . $img . '" /></a>';
} else {
$thumbnail = '';
}
$content = $template;
$content = wpr_random_tags($content);
$content = str_replace("{thumbnail}", $thumbnail, $content);
$content = str_replace("{title}", $title, $content);
$content = str_replace("{content}", $listing, $content);
$content = str_replace("{url}", $url, $content);
$content = str_replace("{city}", $city, $content);
$content = str_replace("{address}", $address, $content);
$content = str_replace("{latitude}", $latitude, $content);
$content = str_replace("{longitude}", $longitude, $content);
$content = str_replace("{price}", $price, $content);
$content = str_replace("{condition}", $condition, $content);
$content = str_replace("{features}", $features, $content);
$content = str_replace("{seller_type}", $seller_type, $content);
$content = str_replace("{delivery}", $delivery, $content);
$noqkeyword = str_replace('"', '', $keyword);
$content = str_replace("{keyword}", $noqkeyword, $content);
$content = str_replace("{Keyword}", ucwords($noqkeyword), $content);
if (function_exists("wpr_translate_partial")) {
$content = wpr_translate_partial($content);
}
if (function_exists("wpr_rewrite_partial")) {
$content = wpr_rewrite_partial($content, $options);
}
$customfield = array();
$customfield["oodletitle"] = $title;
$customfield["oodleprice"] = $price;
$customfield["oodlethumbnail"] = $img;
if (!empty($listing)) {
$itemcontent[$x]["unique"] = $item->id;
$itemcontent[$x]["title"] = $title;
$itemcontent[$x]["content"] = $content;
$itemcontent[$x]["customfield"] = $customfield;
}
$x++;
}
if (empty($itemcontent)) {
// Return error if no content has been found.
$itemcontent["error"]["module"] = "oodle";
$itemcontent["error"]["reason"] = "No content";
$itemcontent["error"]["message"] = __("No (more) oodle 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.
//.........这里部分代码省略.........