PageRenderTime 55ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/wordpress/wp-content/themes/zenko/blog-result.php

http://ownerpress.googlecode.com/
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
  1. <?php
  2. require_once('/var/www/htdocs/wp-load.php');
  3. require_once('/var/www/htdocs/wp-config.php');
  4. require_once(ABSPATH . WPINC . '/functions.php');
  5. require_once(ABSPATH . WPINC . '/class-simplepie.php');
  6. require_once (ABSPATH . WPINC . '/class-feed.php');
  7. require_once(ABSPATH . '/wp-includes/class-snoopy.php');
  8. require_once (ABSPATH . WPINC . '/pluggable.php');
  9. error_reporting(0);
  10. function blogsubmit($url){
  11. global $wpdb;
  12. $feed = new SimplePie();
  13. $feed->set_feed_url($url);
  14. $feed->enable_order_by_date(false);
  15. $feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/cache');
  16. $feed->init();
  17. $feed->handle_content_type();
  18. $items = $feed->get_items();
  19. $shows = array();
  20. foreach ($items as $key=>$item):
  21. $links = $item->get_permalink();
  22. $title = $item->get_title();
  23. $shows[$key]['url'] = $links;
  24. $shows[$key]['title'] = $title;
  25. endforeach;
  26. return $shows;
  27. }
  28. function sinablogsubmitblog($url){
  29. global $wpdb;
  30. $snoopy = new Snoopy;
  31. $snoopy->fetch($url);
  32. $html = $snoopy->results;
  33. preg_match_all("/<h2 id=\"(.*)\" class=\"titName SG_txta\">(.*)<\/h2>/i",$html,$title);
  34. $title = $title[2][0];
  35. $show['url'] = $url;
  36. $show['title'] = $title;
  37. return $show;
  38. }
  39. function sinablogsubmitindex($url){
  40. $snoopy = new Snoopy;
  41. $snoopy->fetch($url);
  42. $html = $snoopy->results;
  43. preg_match_all("/<!--???start-->([\s\S]*)<!--???end-->/i",$html,$page);
  44. preg_match_all("/<div id=\"(.*)\" class=\"blog_title\">(\s)*<a href=\"(.*)\" target=\"_blank\">/i",$page[1][0],$link);
  45. $urls = $link[3];
  46. $shows = array();
  47. foreach($urls as $key => $url):
  48. $show = sinablogsubmitblog($url);
  49. $shows[$key]['url'] = $show['url'];
  50. $shows[$key]['title'] = $show['title'];
  51. endforeach;
  52. return $shows;
  53. }
  54. function sinablogsubmitarticlelist($url){
  55. $snoopy = new Snoopy;
  56. $snoopy->fetch($url);
  57. $html = $snoopy->results;
  58. preg_match_all("/<!-- ?? START -->([\s\S]*)<!-- ??END -->/i",$html,$page);
  59. preg_match_all("/<a title=\"(.*)\" target=\"_blank\" href=\"(.*)\">/i",$page[1][0],$link);
  60. $urls = $link[2];
  61. foreach($urls as $key => $url):
  62. $show = sinablogsubmitblog($url);
  63. $shows[$key]['url'] = $show['url'];
  64. $shows[$key]['title'] = $show['title'];
  65. endforeach;
  66. return $shows;
  67. }
  68. function explodeurlshow($blogurl){
  69. $url_s = explode("/",$blogurl);
  70. if (!strcmp($url_s[2],"blog.sina.com.cn")){
  71. if (!strcmp($url_s[3],"s")){
  72. $url_art = explode("_",$url_s[4]);
  73. if(!strcmp($url_art[0],"articlelist")){
  74. $shows = sinablogsubmitarticlelist($blogurl);
  75. }
  76. else
  77. {
  78. $shows = sinablogsubmitblog($blogurl);
  79. }
  80. }
  81. else
  82. {
  83. $shows = sinablogsubmitindex($blogurl);
  84. }
  85. }
  86. else
  87. {
  88. $shows = blogsubmit($blogurl);
  89. }
  90. return $shows;
  91. }
  92. if($_REQUEST['value']){
  93. $shows = explodeurlshow($_REQUEST['value']);
  94. foreach($shows as $show):
  95. echo '<br><a href="#" onclick="sendRequest('."'".$show['url']."'".');setTitle('."'".$show['title']."'".');">'.$show['title'].'</a>';
  96. endforeach;
  97. }
  98. function blogcontent($url){
  99. global $wpdb;
  100. $feed = new SimplePie();
  101. $feed->set_feed_url($url);
  102. $feed->enable_order_by_date(false);
  103. $feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/cache');
  104. $feed->init();
  105. $feed->handle_content_type();
  106. $items = $feed->get_items();
  107. $bloguserlink = $feed->get_link();
  108. for ($i=0;$i<sizeof($items);$i++){
  109. $link = $items[$i]->get_permalink();
  110. if(strcmp($link,$url) == 0)
  111. $flag = $i;
  112. }
  113. $feedinfo = $items[$flag];
  114. $content = $feedinfo->get_content();
  115. $herfpattern = '/<a HREF="([\S]*)" TARGET="_blank">/i';
  116. $content = preg_replace($herfpattern," ",$content);
  117. $content = preg_replace('/TITLE=\"([^"]*)\"/i','TITLE=""',$content);
  118. $content = preg_replace('/ALT=\"([^"]*)\"/i',' ALT=""',$content);
  119. $content = preg_replace('/<span class=\'MASS(.*)\'>([^<])*<\/span>/','',$content);
  120. $body = $content;
  121. $img_array = array();
  122. preg_match_all('/<img([^>&^<])*(src|SRC)=\"([^"]*)\" ([^<&^>])*\/>/i',$body,$img_array);
  123. $img_array = array_unique($img_array[3]);
  124. set_time_limit(0);
  125. $img_dir ='wp-content/uploads';
  126. $base_dir = ABSPATH;
  127. $imgUrl = $img_dir."/".strftime("%Y/%m",time());
  128. $imgPath = $base_dir.$imgUrl;
  129. $milliSecond = strftime("%d%H%M%S",time());
  130. if(!is_dir($imgPath)) @mkdir($imgPath,0777);
  131. foreach($img_array as $key =>$value)
  132. {
  133. $value = trim($value);
  134. $get_file = @file_get_contents($value);
  135. if (!strcmp(substr($value,-3,3),'690')){
  136. $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."jpg";
  137. $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."jpg";
  138. }
  139. if (!strcmp(substr($value,-3,3),'jpg')){
  140. $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."jpg";
  141. $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."jpg";
  142. }
  143. if (!strcmp(substr($value,-3,3),'gif')){
  144. $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."gif";
  145. $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."gif";
  146. }
  147. if($get_file)
  148. {
  149. $fp = @fopen($rndFileName,"w");
  150. @fwrite($fp,$get_file);
  151. @fclose($fp);
  152. }
  153. $body = ereg_replace($value,$fileurl,$body);
  154. }
  155. $content = $body;
  156. $content = 'from:<a href="'.$bloguserlink.'">'.$bloguserlink.'</a><br>'.$content;
  157. return $content;
  158. }
  159. function sinablogcontent($url){
  160. global $wpdb;
  161. $snoopy = new Snoopy;
  162. $snoopy->fetch($url);
  163. $html = $snoopy->results;
  164. preg_match_all("/<div id=\"bloglink\" class=\"bloglink\"><a href=\"(.)*\">([^<^>]*)<\/a>/i",$html,$bloguserlink);
  165. $bloguserlink = $bloguserlink[2][0];
  166. preg_match_all("/<!-- ???? -->([\s\S]*)<!-- ???? -->/i",$html,$contentContainer);
  167. $content = $contentContainer[1][0];
  168. $content = preg_replace("/<div id=\"sina_keyword_ad_area2\" class=\"articalContent \">/","",$content
  169. );
  170. $content = preg_replace("/<\/div>/","",$content);
  171. $pattern = '/src=\".*\" real_src /';
  172. $content = preg_replace($pattern,"SRC",$content);
  173. $herfpattern = '/<a HREF="([\S]*)" TARGET="_blank">/i';
  174. $content = preg_replace($herfpattern," ",$content);
  175. $content = preg_replace('/TITLE=\"([^"]*)\"/i','TITLE=""',$content);
  176. $content = preg_replace('/ALT=\"([^"]*)\"/i',' ALT=""',$content);
  177. $content = preg_replace('/<span class=\'MASS(.*)\'>([^<])*<\/span>/','',$content);
  178. $body = $content;
  179. $img_array = array();
  180. preg_match_all('/<img([^>&^<])*(src|SRC)=\"([^"]*)\" ([^<&^>])*\/>/i',$body,$img_array);
  181. $img_array = array_unique($img_array[3]);
  182. set_time_limit(0);
  183. $img_dir ='wp-content/uploads';
  184. $base_dir = ABSPATH;
  185. $imgUrl = $img_dir."/".strftime("%Y/%m",time());
  186. $imgPath = $base_dir.$imgUrl;
  187. $milliSecond = strftime("%d%H%M%S",time());
  188. if(!is_dir($imgPath)) @mkdir($imgPath,0777);
  189. foreach($img_array as $key =>$value)
  190. {
  191. $value = trim($value);
  192. $get_file = @file_get_contents($value);
  193. if (!strcmp(substr($value,-3,3),'690')){
  194. $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."jpg";
  195. $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."jpg";
  196. }
  197. if (!strcmp(substr($value,-3,3),'jpg')){
  198. $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."jpg";
  199. $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."jpg";
  200. }
  201. if (!strcmp(substr($value,-3,3),'gif')){
  202. $rndFileName = $imgPath."/".$userid.'-'.$milliSecond.$key."."."gif";
  203. $fileurl = "http://www.stylepress.cn/".$imgUrl."/".$userid.'-'.$milliSecond.$key."."."gif";
  204. }
  205. if($get_file)
  206. {
  207. $fp = @fopen($rndFileName,"w");
  208. @fwrite($fp,$get_file);
  209. @fclose($fp);
  210. }
  211. $body = ereg_replace($value,$fileurl,$body);
  212. }
  213. $content = $body;
  214. $content = 'from:<a href="'.$bloguserlink.'">'.$bloguserlink.'</a><br>'.$content;
  215. return $content;
  216. }
  217. function explodeurlandgetcontent($blogurl){
  218. $url_s = explode("/",$blogurl);
  219. if (!strcmp($url_s[2],"blog.sina.com.cn")){
  220. $content = sinablogcontent($blogurl);
  221. }
  222. else{
  223. $content = blogcontent($blogurl);
  224. }
  225. return $content;
  226. }
  227. if($_REQUEST['url']){
  228. $content = explodeurlandgetcontent($_REQUEST['url']);
  229. echo $content;
  230. }
  231. ?>