find_all_galleries(); if ( count($galleries) == 0 ) { header('content-type:text/plain;charset=utf-8'); echo sprintf(__("No galleries have been yet created.","nggallery"), $gid); exit; } // Get additional parameters $gid = (int) $_GET['gid']; //if no gid is present, take the first gallery if (!isset($gid) || $gid == '' || $gid == 0) { $first = current($galleries); $gid = $first->gid; } // Set the main gallery object $gallery = $galleries[$gid]; if (!isset($gallery) || $gallery==null) { header('content-type:text/plain;charset=utf-8'); echo sprintf(__("The gallery ID=%s does not exist.","nggallery"), $gid); exit; } // show other galleries if needed $prev_next = ( $_GET['prev_next'] == 'true' ) ? true : false; $prev_gallery = $next_gallery = null; // Get previous and next galleries if required if ($prev_next) { reset($galleries); while( current($galleries) ){ if( key($galleries) == $gid ) break; next($galleries); } // one step back $prev_gallery = prev( $galleries); // two step forward... Could be easier ? How ? next($galleries); $next_gallery = next($galleries); } $rss = nggMediaRss::get_gallery_mrss($gallery, $prev_gallery, $next_gallery); } else if ($mode=='album') { // Get additional parameters $aid = (int) $_GET["aid"]; if (!isset($aid) || $aid=='' || $aid==0) { header('content-type:text/plain;charset=utf-8'); _e("No album ID has been provided as parameter","nggallery"); exit; } // Get the album object $album = nggdb::find_album($aid); if (!isset($album) || $album==null ) { header('content-type:text/plain;charset=utf-8'); echo sprintf(__("The album ID=%s does not exist.","nggallery"), $aid); exit; } $rss = nggMediaRss::get_album_mrss($album); } else { header('content-type:text/plain;charset=utf-8'); echo sprintf(__("Invalid MediaRSS command (%s).","nggallery"), $mode); exit; } // Output header for media RSS header("content-type:text/xml;charset=utf-8"); echo "\n"; echo $rss; ?>