PHP Advanced Transfer Manager rss.php Ayarları nasıl yapılır görsel anlatım

guclusat

Tanınmış Üye
Süper Moderatör
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:
What it does:
It creates an RSS Feed * with the latest files added to your phpATM page.

* Feeds are specially formatted documents which summarize the content of web sites. For example, a feed might summarize the latest news headlines from a news site or the latest posts on a blog. You can view the content of feeds in Firefox, create Live Bookmarks for them, or add them to a feed reader on your computer or on the Web.

How to install:
  1. Unpack the rss.php to a temporary folder.

  2. Open the rss.php with your favorite PHP editor (such as Notepad++) and change the variables from the part marked as "config part of the script" (line 28 - line 40), to fit your needs.
    1. $site_title: the title of your site (default $page_title which is the title as set in the conf.php)

    2. $site_link: link to your site (default $installurl which links to your phpATM page)

    3. $site_description: add there a description of your phpATM page

    4. $max_last_files_rss: this is the maximal number of files listed (default 10)

    5. $hide_these_dirs: hidden directories (regular expression) which latest files won't be listed (default "")
  3. Upload the rss.php to your phpATM folder. If necessary change the extension.

  4. Open the include/functions.php with your favorite PHP editor and search for function page_header($title)and find there the following line:

    HTML:
    echo "<link rel=\"stylesheet\" href=\"styles.css\" type=\"text/css\">";
    add under it the following code:

    HTML:
    echo "<link rel=\"alternate\" href=\"rss.php\" type=\"application/rss+xml\" title=\"RSS 2.0\">";
  5. You could add a link to the rss.php, a good place would be in the row where the [Last uploads] - [Top downloads] links are placed. To add it there open the index.php and search for function list_dir($directory) find there the following lines:

    HTML:
    <td align=\"center\" bgColor=\"$tablecolor\">
    <font size=\"2\" face=\"$font\" color=\"$normalfontcolor\">
    [<a href=\"showrecent.$phpExt?".SID."\">$mess[199]</a>]
    -
    [<a href=\"showtophits.$phpExt?".SID."\">$mess[200]</a>]
    </font>
    </td>
    replace these lines with the following code:

    HTML:
    <td align=\"center\" bgColor=\"$tablecolor\"><font size=\"2\" face=\"$font\" color=\"$normalfontcolor\">
    [<a href=\"showrecent.$phpExt?".SID."\">$mess[199]</a>]&nbsp;-&nbsp;<a href=\"RSS.$phpExt?".SID."\" title=\"Click here to subscribe to my feed.\"><img src=\"images/RSS.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"RSS feed\" align=\"top\"></a>&nbsp;-&nbsp;[<a href=\"showtophits.$phpExt?".SID."\">$mess[200]</a>]
    </font></td>
 
Geri
Yukarı