Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Roy Tam http://scrappedblog.blogspot.com/

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

PHPアップローダー RSS機能

PHPアップローダー RSS機能

   1  
   2  <?php
   3  /**** PHPアップローダー RSS機能 ***
   4   * by ◆RTphpfqies
   5   ****/
   6  
   7    $title	= 'PHPアップローダー';
   8    $logfile	= "./log/upup.log";	//ログファイル名(変更する事)
   9    $updir 	= "./log/";	//アップ用ディレクトリ(変更する場合は、35.48.50行も変更)
  10    $prefix	= '';		//接頭語(up001.txt,up002.jpgならup)
  11    $page_def	= 20;		//RSSの表示行数
  12  
  13  
  14  function FormatByte($size){//バイトのフォーマット(B→kB)
  15    if($size == 0)			$format = "";
  16    else if($size <= 1024)		$format = $size."B";
  17    else if($size <= (1024*1024))		$format = sprintf ("%dKB",($size/1024));
  18    else if($size <= (10*1024*1024))	$format = sprintf ("%.2fMB",($size/(1024*1024)));
  19    else					$format = $size."B";
  20  
  21    return $format;
  22  }
  23  
  24  error_reporting(0);
  25  $base_dir = 'http://'.$_SERVER['HTTP_HOST'].str_replace('\\','/', dirname($_SERVER['SCRIPT_NAME'])); if(substr($base_dir,-1) != '/') $base_dir .= '/'; // URL
  26  	header('Content-Type: text/xml;charset=shift-jis');
  27  echo'<?xml version="1.0" encoding="shift-jis"?>
  28  <rss version="2.0">
  29  <channel>
  30  <title>'.$title.'</title>
  31  <link>'.$base_dir.'</link>
  32  <description>'.$title.'</description>
  33  <language>ja</language>
  34  <generator>PHPアップローダー RSS機能</generator>';
  35  
  36  $lines = file($logfile);
  37  for($i = 0; $i < $page_def; $i++){
  38    if($lines[$i]=="") continue;
  39    list($id,$ext,$com,$host,$now,$size,$mtype,$pas,$orig,)=explode("\t",$lines[$i]);
  40    $fsize = FormatByte($size);
  41  
  42    $filename = $prefix.$id.".$ext";
  43    $target = $updir.$filename;
  44  
  45    echo '<item>
  46  	<title>'.$filename.' - '.$orig.' ('.$fsize.')</title>
  47  	<link>'.$base_dir.$target.'</link>
  48  	<description>
  49  	<![CDATA[
  50  '.$com.'
  51  	]]>
  52  	</description>
  53  	<pubDate>'.$now.'</pubDate>
  54  </item>
  55  ';
  56    }
  57  echo '</channel>
  58  </rss>';
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS