HTML:
<?php
/***************************************************************************
* rss.php
* -------------------
* begin : 11/09/2007 19:54
* copyright : ('C) 2007-2008 TerrorLine.de
* contact : http://flavaclown.de/contact.php
*
* $Id: rss.php, v1.05 10/06/2008 22:24 Flava Clown $
*
*
***************************************************************************/
/***************************************************************************
*
* 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 2 of the License', or
* ('at your option) any later version.
*
***************************************************************************/
define('IN_PHPATM', true);
$include_location = dirname($_SERVER['SCRIPT_FILENAME'])."/";
include($include_location.'include/conf.php');
include($include_location.'include/common.'.$phpExt);
// config part of the script
$site_title = $page_title; // your site title, the default setting will show what you have set in the conf.php
$site_link = $installurl = "http://guclusat.gu.funpic.de/"; // a link to your site, the default setting, links to your phpatm powered site (absolute url).
// $site_link = "http://guclusat.gu.funpic.de/"; // set it like this, if you don't want to use a link to your phpatm powered site.
$site_description = "A description of my phpATM powered site."; // a description of your phpATM site.
$max_last_files_rss = 10; // Max number of files listed, works like $max_last_files from the conf.php
$hide_these_dirs = ""; // here you can add the names from folder which content you don't want to appear in the feed
// an example: to hide the folders with the names 'wallpaper' and 'misc' you have to set it like this:
// $hide_these_dirs = "^wallpaper$|misc$";
// to hide a subfolder (like 'test' in the folder 'wallpaper') add only '^test$' not 'wallpaper/test$' !!!
// end config part
if (!function_exists('allhtmlentities'))
{
function allhtmlentities($string)
{
return preg_replace('/[^\x09\x0A\x0D\x20-\x7F]/e', '"&#".ord($0).";"', $string);
}
}
//
// Ricerca ricorsivamente i file contenuti nella directory indicata ed
// in ogni subdirectory in essa contenuta e ritorna un array contentente
// i dieci files pi recentri trovati fino a quel momento
//
function find_last_files($current_dir, $lastfiles = array())
{
global $max_last_files_rss,$hidden_dirs,$showhidden,$reserved_files,$hide_these_dirs;
// Leggo il contenuto della directory passata come primo argomento
$handle = opendir($current_dir);
while (false !== ($filename = readdir($handle)))
{
// Scarto i file da non visualizzare o non accettabili
if (!eregi($reserved_files, $filename) && show_hidden_files($filename))
{
// Se una dir lancio ricursivamente la funzione
if(is_dir("$current_dir/$filename"))
{
if($hide_these_dirs == "")
{
// Non controllo le dir nascoste
if (eregi($hidden_dirs, $filename) && !$showhidden)
{ continue; }
}
else
{
// Non controllo le dir nascoste
if (eregi($hidden_dirs, $filename) && !$showhidden || eregi($hide_these_dirs, $filename))
{ continue; }
}
$lastfiles = find_last_files("$current_dir/$filename", $lastfiles);
continue;
}
// Inserisco il file trovato nell'array
$file_modif_time = filemtime("$current_dir/$filename");
$lastfiles["$current_dir/$filename"] = $file_modif_time;
}
}
closedir($handle);
// Ordino l'array trovato in base alla data d'invio e
// mantengo solo i primi '$last_files_shown' valori (definito in conf.php)
arsort($lastfiles, SORT_NUMERIC);
array_splice($lastfiles, $max_last_files_rss);
return $lastfiles;
}
//
// Stampa l'elenco dei file ordinati
//
function show_files()
{
global $directory,$uploads_folder_name,$installurl,$timeoffset,$phpExt;
global $file_out_max_caracters,$comment_max_caracters;
global $grants,$user_status,$validation_enabled,$dft_language;
$lastfiles = find_last_files($uploads_folder_name);
$tab = 1;
while (list($filename, $filedate) = each($lastfiles))
{
$directory = ereg_replace($uploads_folder_name, '', dirname($filename));
if (strchr($directory, '/') == 0)
{ $directory = substr($directory, 1); }
list($upl_user, $upl_ip, $filestatus, $contents) = get_file_description($filename, $comment_max_caracters);
if (!$validation_enabled || $filestatus == VALIDATED || ($filestatus == UNVALIDATED && $grants[$user_status][VALIDATE]))
{
list($upl_user, $upl_ip, $filestatus, $contents) = get_file_description($filename, $comment_max_caracters);
$file_modif_time = filemtime($filename) - $timeoffset * 3600;
echo" <item>
<title>".date("[d My] ", $file_modif_time).substr(basename(allhtmlentities($filename)),0,$file_out_max_caracters)."</title>
<description>".allhtmlentities($contents)." Size: ".get_filesize($filename)."</description>
<link>$installurl/index.${phpExt}?directory=".rawurlencode($directory)."</link>
<guid isPermaLink=\"false\">".date("Y-m-d\TH:i:sO", $file_modif_time)."#".$tab++."</guid>
<pubDate>".date("D, d M Y H:i:s T", $file_modif_time)."</pubDate>
</item>\n";
}
} // while loop
echo " </channel>
</rss>";
}
function show_header()
{
global $dft_language,$site_title,$site_link,$site_description,$generator,$phpExt,$installurl;
$generator = "PHP Advanced Transfer Manager v".PROGRAM_VERSION;
echo "<?xml version=\"1.0\"?>
<!-- RSS generated by $generator -->
<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">
<channel>
<title>".allhtmlentities($site_title)."</title>
<link>$site_link</link>
<description>".allhtmlentities($site_description)."</description>
<language>$dft_language</language>
<pubDate>".date("D, d M Y H:i:s O")."</pubDate>
<lastBuildDate>".date("D, d M Y H:i:s O")."</lastBuildDate>
<generator>$generator</generator>
<atom:link href=\"$installurl/rss.${phpExt}\" rel=\"self\" type=\"application/rss+xml\" />
<docs>http://backend.userland.com/rss</docs>\n";
}
header("Content-type: application/rss+xml");
show_header();
show_files();
?>
Eklentiler
Son düzenleyen: Moderatör: