Guest User

Untitled

a guest
Nov 2nd, 2018
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.08 KB | None | 0 0
  1. foreach ( $xml->content as $content ) {
  2.         if( $rss['text_type'] ) {
  3.             $xml->content[$i]['title'] = $parse->decodeBBCodes( strip_tags($xml->content[$i]['title']), false );
  4.             $xml->content[$i]['description'] = $parse->decodeBBCodes( $xml->content[$i]['description'], false );
  5.             $xml->content[$i]['date'] = date( "Y-m-d H:i:s", $xml->content[$i]['date'] );
  6.        
  7.         } else {
  8.             $xml->content[$i]['title'] = $parse->decodeBBCodes( strip_tags($xml->content[$i]['title']), false );
  9.             $xml->content[$i]['description'] = $parse->decodeBBCodes( $xml->content[$i]['description'], true, "yes" );
  10.             $xml->content[$i]['date'] = date( "Y-m-d H:i:s", $xml->content[$i]['date'] );
  11.         }
  12.                 //knight
  13.                
  14.                
  15.                
  16.                 if (trim($rss["search_knight"])!=""){
  17.                     $content = $xml->content[$i]['title'] . $xml->content[$i]['description'];
  18.                     $filters = preg_split ("/[,;]/", $rss["search_knight"]);
  19.                     $filter_found = FALSE;
  20.                     foreach ($filters as $filter) {
  21.                         if (stripos($content, trim($filter) )!==FALSE) {
  22.                             $filter_found = TRUE;
  23.                             break;
  24.                         }                        
  25.                     }
  26.                     if ($filter_found == FALSE) {
  27.                         unset($xml->content[$i]);
  28.                         $xml->content[$i]['skip'] = true;
  29.                         //continue;
  30.                     }
  31.                 }
  32.                
  33.                 //price, author, address
  34.                 $content = preg_replace("/(\n|\r|\t)/im", ' ', html_entity_decode($xml->content[$i]['description']));
  35.                
  36.                 $content = preg_replace("/<.*?br.*?>/im", ' ', $content);
  37.                
  38.                
  39.                 $matches = array();
  40.                 preg_match_all("/<p>(.*?)<strong>(.*?)<\/strong>(.*?)<\/p>/im", $content, $matches);
  41.                
  42.                 if ($matches != NULL) {
  43.                     $xml->content[$i]['price'] = preg_replace("/(Цена|цена|руб\.|руб|[ ]{2,})/im",'', $matches[2][0]);
  44.  
  45.                     $xml->content[$i]['author_avito'] = preg_replace("/(контактное лицо|[ ]{2,})/im",' ', $matches[2][1] . $matches[3][1]);
  46.                 }
  47.  
  48.                
  49.                
  50.                 preg_match("/(Московская область.*?|Москва.*?)<\/p>/im", $content, $matches);
  51.                 if ($matches != NULL) {
  52.                     $xml->content[$i]['address'] = $matches[1];                
  53.                 }
  54.  
  55.                
  56.                
  57.                 preg_match_all("/<p>(.*?)<\/p>/im", $content, $matches);
  58.                
  59.                 if ($matches != NULL) {
  60.                     $index = 1;
  61.                     if (preg_match("/Московская/im", $matches[0][2])==0){
  62.                         $index = 2;
  63.                     }
  64.                     $xml->content[$i]['title'] = $matches[0][$index];
  65.                     $xml->content[$i]['title'] = preg_replace("/(<p|\/p>|<|>)/imu", '', $xml->content[$i]['title']);
  66.                     $xml->content[$i]['title'] = preg_replace("/(.*?[^г]\.)( .+)/imu", '$1', $xml->content[$i]['title']);
  67.                
  68.                 }
  69.                
  70.                 $exp   = "/(<p>[\r\t\n\+\d \-]+<strong>[\r\t\n\s\S\w\W]*?<\/strong>[\r\t\n\s\S\w\W]*?<\/p>)[\r\t\n\s\S\w\W]*?\]\]/im";
  71.                 $short = html_entity_decode($xml->content[$i]['description']);
  72.                 $short = preg_replace($exp, '', $short);
  73.  
  74.                
  75.                 //цена
  76.  
  77.                 $exp   = "/<p><strong>[\r\t\n\s\S\w\W]*?Цена[\r\t\n\s\S\w\W]*?([\d \.]+)[\r\t\n\s\S\w\W]*?<\/strong>[\r\t\n\s\S\w\W]*?<\/p>/im";
  78.                 if (preg_match($exp, $short, $matches)!==NULL) {
  79.                     $xml->content[$i]['price'] = trim($matches[1]);
  80.                 }
  81.                
  82.                 $exp   = "/(<p><strong>[\r\t\n\s\S\w\W]*?Цена[\r\t\n\s\S\w\W]*?<\/strong>[\r\t\n\s\S\w\W\dруб\.]*?<\/p>)/im";
  83.                 $short = preg_replace($exp, '', $short);
  84.                
  85.                 //цена/
  86.  
  87.                
  88.                
  89.                
  90.                 $exp = "/img.*?src\=[\'\"](.*?)[\'\"]/im";
  91.                 preg_match($exp, $short, $matches);
  92.                 if ($matches!==NULL) {
  93.                     $xml->content[$i]['image']  =  $matches[1];
  94.                 }
  95.                
  96.                 $exp = "(<img.*?>)";
  97.                 $short = preg_replace($exp, '<br/>', $short);
  98.                
  99.                 $exp   = "/[\r\t\n]{2,}/im";
  100.                 $short = preg_replace($exp, '<br/>', $short);
  101.                
  102.                 $exp   = "/^[\r\t\n\x20]*?/im";
  103.                 $short = preg_replace($exp, '', $short);
  104.                
  105.  
  106.                
  107.                 $short = strip_tags($short);
  108.                
  109.                 $exp   = "/>$/im";
  110.                 $short = preg_replace($exp, '', $short);
  111.  
  112.                
  113.                 $xml->content[$i]['description'] = $short;
  114.                
  115.                 //knight/
  116.         $i ++;
  117.     }
Advertisement
Add Comment
Please, Sign In to add comment