Advertisement
NokitaKaze

Качалка Deviantart

Jul 5th, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.44 KB | None | 0 0
  1. <?php
  2.  if ((int)sad_option('dis_deviant')==1){
  3.   header('http/1.0 503');
  4.   $sad_contype='text/html; charset=utf-8';
  5.   return;
  6.  }
  7.  
  8.  $qf_c=mysql_fetch_assoc(mysql_query('select * from `'.$sad_prefix.'da_feed` where `id`='.sad_safe_mysql($_GET['id'])));
  9.  if ((int)$qf_c['id']==0){
  10.   header('http/1.0 404');
  11.   $sad_contype='text/html; charset=utf-8';
  12.   return;
  13.  }
  14.  
  15.  if ($qf_c['time']<time()-6*3600 and ($_SERVER['REMOTE_ADDR']==my_ip() or iam() ) ){
  16.   $allfeed=array();
  17.   $q=mysql_query('select `id`, `sname`, `time`, `data` from `'.$sad_prefix.'da_item` where `parent`='.sad_safe_mysql($_GET['id']));
  18.   while ($q_c=mysql_fetch_assoc($q)){
  19.    $fd.='; '.$q_c['title'];
  20.    if ($q_c['time']>=time()-5*3600){
  21.     $buf=$q_c['data'];
  22.    }else{
  23.     $ch=curl_init('http://backend.deviantart.com/rss.xml?q=boost%3Anewest%20'.urlencode($q_c['sname']));
  24.     curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  25.     $buf=curl_exec($ch);
  26.     mysql_query('update `'.$sad_prefix.'da_item` set `data`="'.sad_safe_mysql($buf).'", `time`=UNIX_TIMESTAMP() where `id`='.$q_c['id']);
  27.    }
  28.    
  29.    $feed=sad_xml_rawtext($buf);
  30.    for ($i=1;true;$i++){
  31.     if (strlen(sad_xml_getnode($feed,'channel/item|'.$i.'/title#'))<1){break;}
  32.    
  33.    
  34.     preg_match('|([0-9]+)$|',sad_xml_getnode($feed,'channel/item|'.$i.'/link#'),$a);
  35.     preg_match('|/([^/]+?)" alt="thumbnail"|',sad_xml_getnode($feed,'channel/item|'.$i.'/description#'),$b);
  36.     $ff =' <title>'.sad_safe_html(sad_xml_getnode($feed,'channel/item|'.$i.'/title#')).'</title>
  37. <link>'.sad_xml_getnode($feed,'channel/item|'.$i.'/link#').'</link>
  38. <guid isPermaLink="true">'.sad_xml_getnode($feed,'channel/item|'.$i.'/guid#').'</guid>
  39. <pubDate>'.sad_xml_getnode($feed,'channel/item|'.$i.'/pubDate#').'</pubDate>
  40. <description>'.sad_safe_xml(sad_xml_getnode($feed,'channel/item|'.$i.'/description#'));
  41.     if (strlen(sad_xml_getnode($feed,'channel/item|'.$i.'/description#'))>0){
  42.      if (preg_match('_\\.(jpe?g|png|gif|bmp)_i',sad_xml_getnode($feed,'channel/item|'.$i.'/description#'))){
  43.       $t='Full image';
  44.      }else{$t='Read text';}
  45.      $ff.=sad_safe_xml('<br><a target="_blank" href="http://www.deviantart.com/download/'.$a[1].'/'.$b[1].'">'.$t.'</a>');
  46.     }
  47.     $ff.='</description>';
  48.     $allfeed[sad_xml_getnode($feed,'channel/item|'.$i.'/guid#')]=$ff;
  49.    }
  50.  
  51.   }
  52.  
  53.   $buf=''; foreach ($allfeed as $guid => $item){
  54.    $buf.="<item>\r\n".$item."\r\n</item>\r\n\r\n";
  55.   }
  56.   mysql_query('update `'.$sad_prefix.'da_feed` set `data`="'.sad_safe_mysql($buf).'", `time`=UNIX_TIMESTAMP() where `id`='.$qf_c['id']);
  57.   $dd=time();
  58.  }else{
  59.   $buf=$qf_c['data'];
  60.   $dd =$qf_c['time'];
  61.  }
  62.  
  63. // print_r($allfeed);exit;
  64.  $sad_contype='application/rss+xml; charset=UTF-8';
  65.  $sad_hide=true;
  66.  echo '<'.'?xml version="1.0" encoding="utf-8"?'.'>';
  67. ?><rss version="2.0"
  68.  xmlns:media="http://search.yahoo.com/mrss/"
  69.  xmlns:atom="http://www.w3.org/2005/Atom">
  70. <channel>
  71.         <title>{#php:$qf_c['title']#} / DeviantArt</title>
  72.         <link>http://kanaria.ru/deviantart/</link>
  73.         <description>deviantART RSS for sort:time boost:{#php:substr($fd,2)#}</description>
  74.         <language>en-us</language>
  75.         <copyright>Copyright 2011, deviantART.com con KanariaRu</copyright>
  76.         <pubDate>{#php:gmdate("D, d M Y H:i:s \G\M\T",$dd)#}</pubDate>
  77.         <generator>KanariaRu</generator>
  78.         <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  79.  
  80. {#php:$buf#}
  81. </channel></rss><!-- {#php:gmdate("d.m.Y H:i:sO",$dd)#} -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement