Overview   Package   Tree   Index 
HistView Api Doc
PREV  NEXT Frames  No Frame 
SUMMARY:  FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Api
Class download

- hvconfig
-

class download
extends hvconfig

Scanning a directory and checking for download files

Authors:
Izzy (devel AT izzysoft DOT de)
Version:
$Revision: 64 $ $Date: 2009-10-12 19:46:32 +0200 (Mo, 12. Okt 2009) $
Copyright:
(c) 2007-2009 by Itzchak Rehberg and IzzySoft

Constructor Summary
void download([string $basedir], [string $icondir])
Initial setup of default filetypes and date format

Method Summary
protected void add_bot(mixed $bot, string $cat)
Setup bots to be ignored/rejected
void add_details([string $descdir], [boolean $descreplace])
Add details to the filelist (fields "size" and "date")
protected void ar_sort_by(array $arr, string $orderby, [boolean $rev], [integer $method])
Sort array by given key
void blacklistCheck()
Handle IP blacklist
void crawler_net(mixed $name)
Add name to crawler list
protected object& db_init()
Initialize DB and hand-out a handle to it
void db_setup(string $host, string $database, string $user, string $passwd, string $table, string $limitTable)
Setup database connection
void dbcounter(string $filename)
Increase download counter in the database (if statisticsmode is enabled and the Remote UA is not in the ignore list)
array get_filelist()
Get full (interpreted) filelist
array get_filenames()
Get the list of files
protected string getProgName(string $file)
Get the prog name from the file name
void ignore_bot(mixed $bot)
Add bots to ignore list
protected void interprete_filelist([integer $dirnum])
Generate list of all files incl.
boolean is_crawler_net()
Network check (where does the request come from)
void limit_check(string $file)
Check for download limits and reject the request if they are exceeded
void limit_purge()
Purge the limits table
void refererCheck()
Handle request w/o referer
void reject()
Reject a client and quit
void reject_bot(mixed $bot)
Add bots to reject list
void scan_dir(string $dir, [integer $dirnum])
Scan another directory Switches to another directory.
boolean send_latest(string $prog, string $type, [string $directory])
Send latest version
boolean sendfile(string $filename, [string $directory])
Download a file (if the remote UA is not in the reject list)
void set_argsep(string $separator)
Set the argument separator This is how to separate arguments in the URL.
void set_bots(string $type, string $filename)
Setup bots to ignore / reject
void set_dateformat(string $format)
Set the date format to use
void set_dllinktype(string $type)
Set download linktype
void set_excludes(array $excludes, [boolean $replace])
Setup exclude list
void set_filetype(string $type, string $mask, string $extension, [string $icon])
Setup file types
void set_icondir(string $dir)
Set the directory (URL) where your icons reside
boolean set_statisticsmode(integer $mode)
Set the statisticsmode Use this to turn on (1)/Off (0) statistic functions (database related stuff like download counters) at runtime
void sort_by_filename([boolean $rev])
Sort by filename
void sort_by_version([boolean $rev])
Sort filelist by version
array whois(string $host, [boolean $raw], [string $server], [integer $port])
Query the whois database

Constructor Detail

download()

void download([string $basedir], [string $icondir])

Initial setup of default filetypes and date format

Parameters:
basedir - What to cut off to generate a download link. This is usually your web servers document root. This parameter is not needed when using the internal download method (default).
icondir - URL of the directory where the icons reside

Method Detail

add_bot()

protected void add_bot(mixed $bot, string $cat)

Setup bots to be ignored/rejected

Parameters:
bot - string or array of strings (substr of botnames)
cat - category to add the bot to (ignore,reject)

add_details()

void add_details([string $descdir], [boolean $descreplace])

Add details to the filelist (fields "size" and "date")

Parameters:
descdir - Directory where the description files reside. Name of a description file must be either <name>.desc (for a general, version independent description) or <name>_<version>.desc (description bound to a specific version). The latter one is used (if found), the first one otherwise (if found). Descriptions will be preceded by "<name> v<version>". If a description file is found, it then will be added after an additional line break (<BR>).
descreplace - Replace the short desc (TRUE, default) or append to it (FALSE)

ar_sort_by()

protected void ar_sort_by(array $arr, string $orderby, [boolean $rev], [integer $method])

Sort array by given key

Parameters:
arr - Array to sort
orderby - Field to order by
rev - Reverse order (default:false)
method - One of the constants SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_LOCALE_STRING

blacklistCheck()

void blacklistCheck()

Handle IP blacklist


crawler_net()

void crawler_net(mixed $name)

Add name to crawler list

Parameters:
name - string or array of strings (substr of botnames)

db_init()

protected object& db_init()

Initialize DB and hand-out a handle to it

Returns:
object db handle to the database class

db_setup()

void db_setup(string $host, string $database, string $user, string $passwd, string $table, string $limitTable)

Setup database connection

Parameters:
host - hostname the DB is running on
database - Name of the database to use
user - DB User to connect with
passwd - Password to use
table - Name of the download table
limitTable - Name of the download limits table

dbcounter()

void dbcounter(string $filename)

Increase download counter in the database (if statisticsmode is enabled and the Remote UA is not in the ignore list)

Parameters:
filename - Filename to process

get_filelist()

array get_filelist()

Get full (interpreted) filelist

Returns:
Array[0..n] of file arrays. File array has the properties dir,name,version,sortver,file, icon, ilink (link with icon) and flink (link with filename). If add_details was run before, size, date and desc are also available.

get_filenames()

array get_filenames()

Get the list of files

Returns:
Array[0..n] of filenames

getProgName()

protected string getProgName(string $file)

Get the prog name from the file name

Parameters:
file - name of the file
Returns:
prog name of the prog

ignore_bot()

void ignore_bot(mixed $bot)

Add bots to ignore list

Parameters:
bot - string or array of strings (substr of botnames)

interprete_filelist()

protected void interprete_filelist([integer $dirnum])

Generate list of all files incl. basic information Is called from method scan_dir

Parameters:
dirnum - If you run multiple directories via an array, you can store the index here. Will be added to the DL URL, when internal DL method is used.

is_crawler_net()

boolean is_crawler_net()

Network check (where does the request come from)

Returns:

limit_check()

void limit_check(string $file)

Check for download limits and reject the request if they are exceeded

Parameters:
file - name of the downloaded file

limit_purge()

void limit_purge()

Purge the limits table


refererCheck()

void refererCheck()

Handle request w/o referer


reject()

void reject()

Reject a client and quit


reject_bot()

void reject_bot(mixed $bot)

Add bots to reject list

Parameters:
bot - string or array of strings (substr of botnames)

scan_dir()

void scan_dir(string $dir, [integer $dirnum])

Scan another directory Switches to another directory. This resets the internal file array and starts over. The filelist array will not be reset, so entries are added to it.

Parameters:
dir - Directory to scan
dirnum - If you run multiple directories via an array, you can store the index here. Will be added to the DL URL, when internal DL method is used.

send_latest()

boolean send_latest(string $prog, string $type, [string $directory])

Send latest version

Parameters:
prog - Which program is requested
type - What type of archive (first parameter of set_filetype)
directory - Directory where the file resides (if it was not scanned yet)
Returns:
file_send Whether we found something to send.

sendfile()

boolean sendfile(string $filename, [string $directory])

Download a file (if the remote UA is not in the reject list)

Parameters:
filename - File to download
directory - Directory where the file resides (if other than the recent one)
Returns:
file_sent TRUE if file found, FALSE otherwise

set_argsep()

void set_argsep(string $separator)

Set the argument separator This is how to separate arguments in the URL. Default is ";" - you may want to set this to "&"

Parameters:
separator -

set_bots()

void set_bots(string $type, string $filename)

Setup bots to ignore / reject

Parameters:
type - "ignore" or "reject"
filename - file to read the bots from

set_dateformat()

void set_dateformat(string $format)

Set the date format to use

Parameters:
format - Date format to use (refer to the PHP manual of date)

set_dllinktype()

void set_dllinktype(string $type)

Set download linktype

Parameters:
type - type of the link

set_excludes()

void set_excludes(array $excludes, [boolean $replace])

Setup exclude list

Parameters:
excludes - Array of files to exclude from listings
replace - Replace the preset list (TRUE) or append to it (FALSE)? Default is to append.

set_filetype()

void set_filetype(string $type, string $mask, string $extension, [string $icon])

Setup file types

Parameters:
type - Short name for the type, e.g. "rpm", "deb", "tar"
mask - Corresponding regexp mask. The back references should be set such that
  • \1 is the name of the software
  • \2.\3.\4 make up the version
  • optional \5 sets the release number (required for *.deb and *.rpm)

extension - File extension to identify this type - e.g. "deb" or "tar.gz"
icon - Complete img tag to display for this type

set_icondir()

void set_icondir(string $dir)

Set the directory (URL) where your icons reside

Parameters:
dir - URL of the directory where the icons reside

set_statisticsmode()

boolean set_statisticsmode(integer $mode)

Set the statisticsmode Use this to turn on (1)/Off (0) statistic functions (database related stuff like download counters) at runtime

Parameters:
mode - 0 (to turn off stats) or 1 (to turn them on)
Returns:
success

sort_by_filename()

void sort_by_filename([boolean $rev])

Sort by filename

Parameters:
rev - Reverse order? Default: False

sort_by_version()

void sort_by_version([boolean $rev])

Sort filelist by version

Parameters:
rev - Reverse order? Default: False

whois()

array whois(string $host, [boolean $raw], [string $server], [integer $port])

Query the whois database

Parameters:
host - IP/hostname
raw - whether to include the raw whois information (default: FALSE)
server - whois server to use (default: "whois.arin.net")
port - (default: 43)
Returns:
whois

 Overview   Package   Tree   Index 
HistView Api Doc
PREV  NEXT Frames  No Frame 
SUMMARY:  FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Submit a bug

This document was generated by phpdocgen 0.17-rc3.
Copyright © 2002-03 Stéphane GALLAND (under the GNU General Public License)