Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach ( $xml->content as $content ) {
- if( $rss['text_type'] ) {
- $xml->content[$i]['title'] = $parse->decodeBBCodes( strip_tags($xml->content[$i]['title']), false );
- $xml->content[$i]['description'] = $parse->decodeBBCodes( $xml->content[$i]['description'], false );
- $xml->content[$i]['date'] = date( "Y-m-d H:i:s", $xml->content[$i]['date'] );
- } else {
- $xml->content[$i]['title'] = $parse->decodeBBCodes( strip_tags($xml->content[$i]['title']), false );
- $xml->content[$i]['description'] = $parse->decodeBBCodes( $xml->content[$i]['description'], true, "yes" );
- $xml->content[$i]['date'] = date( "Y-m-d H:i:s", $xml->content[$i]['date'] );
- }
- //knight
- if (trim($rss["search_knight"])!=""){
- $content = $xml->content[$i]['title'] . $xml->content[$i]['description'];
- $filters = preg_split ("/[,;]/", $rss["search_knight"]);
- $filter_found = FALSE;
- foreach ($filters as $filter) {
- if (stripos($content, trim($filter) )!==FALSE) {
- $filter_found = TRUE;
- break;
- }
- }
- if ($filter_found == FALSE) {
- unset($xml->content[$i]);
- $xml->content[$i]['skip'] = true;
- //continue;
- }
- }
- //price, author, address
- $content = preg_replace("/(\n|\r|\t)/im", ' ', html_entity_decode($xml->content[$i]['description']));
- $content = preg_replace("/<.*?br.*?>/im", ' ', $content);
- $matches = array();
- preg_match_all("/<p>(.*?)<strong>(.*?)<\/strong>(.*?)<\/p>/im", $content, $matches);
- if ($matches != NULL) {
- $xml->content[$i]['price'] = preg_replace("/(Цена|цена|руб\.|руб|[ ]{2,})/im",'', $matches[2][0]);
- $xml->content[$i]['author_avito'] = preg_replace("/(контактное лицо|[ ]{2,})/im",' ', $matches[2][1] . $matches[3][1]);
- }
- preg_match("/(Московская область.*?|Москва.*?)<\/p>/im", $content, $matches);
- if ($matches != NULL) {
- $xml->content[$i]['address'] = $matches[1];
- }
- preg_match_all("/<p>(.*?)<\/p>/im", $content, $matches);
- if ($matches != NULL) {
- $index = 1;
- if (preg_match("/Московская/im", $matches[0][2])==0){
- $index = 2;
- }
- $xml->content[$i]['title'] = $matches[0][$index];
- $xml->content[$i]['title'] = preg_replace("/(<p|\/p>|<|>)/imu", '', $xml->content[$i]['title']);
- $xml->content[$i]['title'] = preg_replace("/(.*?[^г]\.)( .+)/imu", '$1', $xml->content[$i]['title']);
- }
- $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";
- $short = html_entity_decode($xml->content[$i]['description']);
- $short = preg_replace($exp, '', $short);
- //цена
- $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";
- if (preg_match($exp, $short, $matches)!==NULL) {
- $xml->content[$i]['price'] = trim($matches[1]);
- }
- $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";
- $short = preg_replace($exp, '', $short);
- //цена/
- $exp = "/img.*?src\=[\'\"](.*?)[\'\"]/im";
- preg_match($exp, $short, $matches);
- if ($matches!==NULL) {
- $xml->content[$i]['image'] = $matches[1];
- }
- $exp = "(<img.*?>)";
- $short = preg_replace($exp, '<br/>', $short);
- $exp = "/[\r\t\n]{2,}/im";
- $short = preg_replace($exp, '<br/>', $short);
- $exp = "/^[\r\t\n\x20]*?/im";
- $short = preg_replace($exp, '', $short);
- $short = strip_tags($short);
- $exp = "/>$/im";
- $short = preg_replace($exp, '', $short);
- $xml->content[$i]['description'] = $short;
- //knight/
- $i ++;
- }
Advertisement
Add Comment
Please, Sign In to add comment