/*
**********************************************************************
Copyright 2008 Joe Terranova
joeterranova@gmail.com
http://www.joeterranova.net
Released under GPL Version 3.
http://www.gnu.org/licenses/gpl.txt
To request any other license, please contact the author.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
**********************************************************************
*/
$usecurl=1;
$url = 'http://www.joeterranova.net/code/deviantart.php';
$webmaster='joeterranova@gmail.com (Joe Terranova)';
$artist = $_REQUEST['artist'];
if(!$artist) return;
if($_REQUEST['count']) $count= $_REQUEST['count'];
else $count = 24;
$url .= "?artist={$artist}";
$results = get_gal($artist,$count);
if($_REQUEST['export'])
{
var_export($results);
exit;
}
header("Content-Type: application/rss+xml");
date_default_timezone_set('GMT');
$date = date("D, d M Y H:i:s T",$results[0]['time']);
echo
"
{$artist}'s latest artwork
http://{$artist}.deviantart.com/gallery/
{$artist}'s latest artworken-us{$date}{$date}http://blogs.law.harvard.edu/tech/rssJoe Terranova's DeviantArt RSS Generatorjoeterranova@gmail.com (Joe Terranova)$webmaster
";
foreach($results as $result)
{
$date = date("D, d M Y H:i:s T",$result['time']);
if($_REQUEST['nolink'])$desc = "";
else $desc = "";
$desc = '';
echo
"{$result[title]}
{$result[url]}
$desc$date{$result[url]}
";
}
echo
" ";
function get_gal($artist, $count = 24)
{
global $usecurl;
$results = Array();
$start =0;
$resultcount=0;
while(!$end)
{
if($count - $resultcount < 24) $request = $count - $resultcount;
else $request = 24;
$url="http://$artist.deviantart.com/global/difi/?c%5B%5D=Resources;htmlFromQuery;gallery%3A$artist%20sort%3Atime,$start,$request,thumb150,artist%3A0&t=json";
if($usecurl)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$dump = curl_exec($ch);
}
else
$dump = file_get_contents($url);
if(!$dump) return;
$dump = stripslashes($dump);
preg_match_all('{