/wordpress/wp-content/themes/zenko/blog-result.php
PHP | 244 lines | 231 code | 13 blank | 0 comment | 22 complexity | 556336e3eb5e7337674e7414a090042b MD5 | raw file
Possible License(s): Apache-2.0, AGPL-1.0, GPL-2.0, GPL-3.0, LGPL-2.1
- <?php
- require_once('/var/www/htdocs/wp-load.php');
- require_once('/var/www/htdocs/wp-config.php');
- require_once(ABSPATH . WPINC . '/functions.php');
- require_once(ABSPATH . WPINC . '/class-simplepie.php');
- require_once (ABSPATH . WPINC . '/class-feed.php');
- require_once(ABSPATH . '/wp-includes/class-snoopy.php');
- require_once (ABSPATH . WPINC . '/pluggable.php');
-
- error_reporting(0);
-
- function blogsubmit($url){
- global $wpdb;
- $feed = new SimplePie();
- $feed->set_feed_url($url);
- $feed->enable_order_by_date(false);
- $feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/cache');
- $feed->init();
- $feed->handle_content_type();
- $items = $feed->get_items();
- $shows = array();
- foreach ($items as $key=>$item):
- $links = $item->get_permalink();
- $title = $item->get_title();
- $shows[$key]['url'] = $links;
- $shows[$key]['title'] = $title;
- endforeach;
- return $shows;
- }
-
- function sinablogsubmitblog($url){
- global $wpdb;
- $snoopy = new Snoopy;
- $snoopy->fetch($url);
- $html = $snoopy->results;
- preg_match_all("/<h2 id=\"(.*)\" class=\"titName SG_txta\">(.*)<\/h2>/i",$html,$title);
- $title = $title[2][0];
- $show['url'] = $url;
- $show['title'] = $title;
- return $show;
- }
-
- function sinablogsubmitindex($url){
- $snoopy = new Snoopy;
- $snoopy->fetch($url);
- $html = $snoopy->results;
- preg_match_all("/<!--???start-->([\s\S]*)<!--???end-->/i",$html,$page);
- preg_match_all("/<div id=\"(.*)\" class=\"blog_title\">(\s)*<a href=\"(.*)\" target=\"_blank\">/i",$page[1][0],$link);
- $urls = $link[3];
- $shows = array();
- foreach($urls as $key => $url):
- $show = sinablogsubmitblog($url);
- $shows[$key]['url'] = $show['url'];
- $shows[$key]['title'] = $show['title'];
- endforeach;
- return $shows;
- }
-
- function sinablogsubmitarticlelist($url){
- $snoopy = new Snoopy;
- $snoopy->fetch($url);
- $html = $snoopy->results;
- preg_match_all("/<!-- ?? START -->([\s\S]*)<!-- ??END -->/i",$html,$page);
- preg_match_all("/<a title=\"(.*)\" target=\"_blank\" href=\"(.*)\">/i",$page[1][0],$link);
- $urls = $link[2];
- foreach($urls as $key => $url):
- $show = sinablogsubmitblog($url);
- $shows[$key]['url'] = $show['url'];
- $shows[$key]['title'] = $show['title'];
- endforeach;
- return $shows;
- }
-
- function explodeurlshow($blogurl){
- $url_s = explode("/",$blogurl);
- if (!strcmp($url_s[2],"blog.sina.com.cn")){
- if (!strcmp($url_s[3],"s")){
- $url_art = explode("_",$url_s[4]);
- if(!strcmp($url_art[0],"articlelist")){
- $shows = sinablogsubmitarticlelist($blogurl);
- }
- else
- {
- $shows = sinablogsubmitblog($blogurl);
- }
- }
- else
- {
- $shows = sinablogsubmitindex($blogurl);
- }
- }
- else
- {
- $shows = blogsubmit($blogurl);
- }
- return $shows;
- }
-
-
- if($_REQUEST['value']){
- $shows = explodeurlshow($_REQUEST['value']);
- foreach($shows as $show):
- echo '<br><a href="#" onclick="sendRequest('."'".$show['url']."'".');setTitle('."'".$show['title']."'".');">'.$show['title'].'</a>';
- endforeach;
- }
-
- function blogcontent($url){
- global $wpdb;
- $feed = new SimplePie();
- $feed->set_feed_url($url);
- $feed->enable_order_by_date(false);
- $feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/cache');
- $feed->init();
- $feed->handle_content_type();
- $items = $feed->get_items();
- $bloguserlink = $feed->get_link();
- for ($i=0;$i<sizeof($items);$i++){
- $link = $items[$i]->get_permalink();
- if(strcmp($link,$url) == 0)
- $flag = $i;
- }
- $feedinfo = $items[$flag];
- $content = $feedinfo->get_content();
- $herfpattern = '/<a HREF="([\S]*)" TARGET="_blank">/i';
- $content = preg_replace($herfpattern," ",$content);
- $content = preg_replace('/TITLE=\"([^"]*)\"/i','TITLE=""',$content);
- $content = preg_replace('/ALT=\"([^"]*)\"/i',' ALT=""',$content);
- $content = preg_replace('/<span class=\'MASS(.*)\'>([^<])*<\/span>/','',$content);
- $body = $content;
- $img_array = array();
- preg_match_all('/<img([^>&^<])*(src|SRC)=\"([^"]*)\" ([^<&^>])*\/>/i',$body,$img_array);
- $img_array = array_unique($img_array[3]);
- set_time_limit(0);
- $img_dir ='wp-content/uploads';
- $base_dir = ABSPATH;
- $imgUrl = $img_dir."/".strftime("%Y/%m",time());
- $imgPath = $base_dir.$imgUrl;
- $milliSecond = strftime("%d%H%M%S",time());
- if(!is_dir($imgPath)) @mkdir($imgPath,0777);
- foreach($img_array as $key =>$value)
- {
- $value = trim($value);
- $get_file = @file_get_contents($value);
- if (!strcmp(substr($value,-3,3),'690')){
- $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."jpg";
- $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."jpg";
- }
- if (!strcmp(substr($value,-3,3),'jpg')){
- $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."jpg";
- $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."jpg";
- }
- if (!strcmp(substr($value,-3,3),'gif')){
- $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."gif";
- $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."gif";
- }
- if($get_file)
- {
- $fp = @fopen($rndFileName,"w");
- @fwrite($fp,$get_file);
- @fclose($fp);
- }
- $body = ereg_replace($value,$fileurl,$body);
- }
- $content = $body;
- $content = 'from:<a href="'.$bloguserlink.'">'.$bloguserlink.'</a><br>'.$content;
- return $content;
- }
-
-
- function sinablogcontent($url){
- global $wpdb;
- $snoopy = new Snoopy;
- $snoopy->fetch($url);
- $html = $snoopy->results;
- preg_match_all("/<div id=\"bloglink\" class=\"bloglink\"><a href=\"(.)*\">([^<^>]*)<\/a>/i",$html,$bloguserlink);
- $bloguserlink = $bloguserlink[2][0];
- preg_match_all("/<!-- ???? -->([\s\S]*)<!-- ???? -->/i",$html,$contentContainer);
- $content = $contentContainer[1][0];
- $content = preg_replace("/<div id=\"sina_keyword_ad_area2\" class=\"articalContent \">/","",$content
- );
- $content = preg_replace("/<\/div>/","",$content);
- $pattern = '/src=\".*\" real_src /';
- $content = preg_replace($pattern,"SRC",$content);
- $herfpattern = '/<a HREF="([\S]*)" TARGET="_blank">/i';
- $content = preg_replace($herfpattern," ",$content);
- $content = preg_replace('/TITLE=\"([^"]*)\"/i','TITLE=""',$content);
- $content = preg_replace('/ALT=\"([^"]*)\"/i',' ALT=""',$content);
- $content = preg_replace('/<span class=\'MASS(.*)\'>([^<])*<\/span>/','',$content);
- $body = $content;
- $img_array = array();
- preg_match_all('/<img([^>&^<])*(src|SRC)=\"([^"]*)\" ([^<&^>])*\/>/i',$body,$img_array);
- $img_array = array_unique($img_array[3]);
- set_time_limit(0);
- $img_dir ='wp-content/uploads';
- $base_dir = ABSPATH;
- $imgUrl = $img_dir."/".strftime("%Y/%m",time());
- $imgPath = $base_dir.$imgUrl;
- $milliSecond = strftime("%d%H%M%S",time());
- if(!is_dir($imgPath)) @mkdir($imgPath,0777);
- foreach($img_array as $key =>$value)
- {
- $value = trim($value);
- $get_file = @file_get_contents($value);
- if (!strcmp(substr($value,-3,3),'690')){
- $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."jpg";
- $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."jpg";
- }
- if (!strcmp(substr($value,-3,3),'jpg')){
- $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."jpg";
- $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."jpg";
- }
- if (!strcmp(substr($value,-3,3),'gif')){
- $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."gif";
- $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."gif";
- }
- if($get_file)
- {
- $fp = @fopen($rndFileName,"w");
- @fwrite($fp,$get_file);
- @fclose($fp);
- }
- $body = ereg_replace($value,$fileurl,$body);
- }
- $content = $body;
- $content = 'from:<a href="'.$bloguserlink.'">'.$bloguserlink.'</a><br>'.$content;
- return $content;
- }
-
- function explodeurlandgetcontent($blogurl){
- $url_s = explode("/",$blogurl);
- if (!strcmp($url_s[2],"blog.sina.com.cn")){
- $content = sinablogcontent($blogurl);
- }
- else{
- $content = blogcontent($blogurl);
- }
- return $content;
- }
-
- if($_REQUEST['url']){
- $content = explodeurlandgetcontent($_REQUEST['url']);
- echo $content;
- }
- ?>