=time() and strlen($q2_c['rss'])>0) or (!iam() and ($_SERVER['REMOTE_ADDR']!==my_ip())) ){ $sad_contype='text/xml'; echo '<'.'?xml version="1.0" encoding="utf-8"?'.'>'; echo $q2_c['rss']; echo ''; return; } if (!iam() and ($_SERVER['REMOTE_ADDR']!==my_ip()) and (int)sad_option('dis_booru')==1){header('http/1.0 503');return;} function numnum($img){ if (!preg_match('|https?://([0-9a-z.-]+)|',$img,$a)){return 0;} if ($a[1]=='danbooru.donmai.us'){return 11;} if ($a[1]=='kanaria.ru'){return 10;} if ($a[1]=='gelbooru.com'){return 9;} if ($a[1]=='chan.sankakucomplex.com'){return 8;} return 1; } $feed=array();set_time_limit(20*60);$debug=true; if ($debug){$fo=fopen($sad_prefix.'/debug','a'); fwrite($fo,date('Y-m-d H:i:s').': start = '.$id."\r\n");fclose($fo);} // Перебираем все дочерные фиды $q =mysql_query('select * from `'.$sad_prefix.'booru_rss` where `parent`='.$id); while ($q_c=mysql_fetch_assoc($q)){ if ($debug){ $fo=fopen($sad_prefix.'/debug','a'); fwrite($fo, date('Y-m-d H:i:s').': q_c id = '.$q_c['id'].'; url = "'. $q_c['url'].'"; time = '.date('Y-m-d H:iO',$q_c['time'])."\r\n"); fclose($fo); } //pull a feed if ($q_c['time']+6*3600$q3_c['title'], 'links'=>array('http://danbooru.donmai.us/posts/'.$q3_c['dan_id'].'/'), 'href' =>'http://danbooru.donmai.us/posts/'.$q3_c['dan_id'].'/', 'img' =>'http://danbooru.donmai.us'.$q3_c['src'], 'time' =>0 ); } continue; } //other places if ($q_c['time']+6*3600appendChild($tmp->importNode(sad_xml_getnode($ent,'content'),true)); $buf = $tmp->saveHTML(); preg_match('|([a-f0-9]{32,32})|',$buf,$a); $md5=$a[1]; if (!isset($feed[$md5])){$feed[$md5]=array('time'=>0,'links'=>array());} preg_match('|src="(.+?)"|i',$buf,$a);$img=$a[1]; if (preg_match('|^/|',$img)){$img='http://'.$domain.$img;} if (numnum($feed[$md5]['img'])2011-09-13T04:12:12Z $time=gmmktime($a[4],$a[5],$a[6], $a[2],$a[3],$a[1]); if ($feed[$md5]['time']>$time or $feed[$md5]['time']<1){$feed[$md5]['time']=$time;} if (strlen($feed[$md5]['title'])<1){$feed[$md5]['title']=sad_xml_getnode($ent,'title#'); } preg_match('|href="(.+?)"|i',$buf,$a);$href=$a[1]; if (numnum($feed[$md5]['href'])';print_r($feed); $buf='';unset($md5);$time=0; foreach ($feed as $md5 => $e){ if ($md5==''){continue;} $descr='
'; foreach (array_unique($e['links']) as $link){ if (strlen($link)>0){$descr.='
'.$link.'';} } $buf.=' '.sad_safe_xml($e['title']).' '.sad_safe_xml($e['href']).' '.sad_safe_xml($descr).' '.gmdate("D, d M Y H:i:s \G\M\T",$e['time']).' booru-'.$md5.' '; $time=max($time,$e['time']); } if ($debug){$fo=fopen($sad_prefix.'/debug','a'); fwrite($fo,date('Y-m-d H:i:s').': strlen($buf) = '.strlen($buf)."\r\n");fclose($fo);} $buf=''.sad_safe_xml($q2_c['title'].' / Meta Booru').''. gmdate("D, d M Y H:i:s \G\M\T",$time).''.round($q2_c['ttl']/60).''.$buf.''; $sad_contype='text/xml'; echo '<'.'?xml version="1.0" encoding="utf-8"?'.'>'; echo $buf; echo ''; mysql_query('update `'.$sad_prefix.'booru_feed` set `rss`="'.sad_safe_mysql($buf).'", `time`=UNIX_TIMESTAMP() where `id`='.$id); ?>