Net_CDDB
[ class tree: Net_CDDB ] [ index: Net_CDDB ] [ all elements ]

Class: Net_CDDB_Protocol_Filesystem

Source Location: /Net_CDDB-0.3.0/CDDB/Protocol/Filesystem.php

Class Overview

Net_CDDB_Protocol
   |
   --Net_CDDB_Protocol_Filesystem

Connection protocol for querying local filesystem in FreeDB database dump format


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: Net_CDDB_Protocol

Net_CDDB_Protocol::remote()
Tell whether or not a protocol acts on a remote resource

Class Details

[line 79]
Connection protocol for querying local filesystem in FreeDB database dump format

The FreeDB.org project provides database dumps of the entire CDDB/FreeDB database. The database downloads are usually provided in the following formats:

  • .tar.bz2 (tarred and bzipped)
  • .tar.7z (tarred and 7-zipped)
  • .torrent (Bittorrent download)
In order to use the database dumps (and thus this protocol) you need to download and extract one of the database dumps. The DSN provided to the Net_CDDB_Client should point to the directory of the database dumps:
  1.      $proto 'filesystem:///usr/home/keith/FreeDB Database/';
  2.      $client = new Net_CDDB_Client($proto'cddiscid:///dev/acd0');

You probably don't want to use this protocol unless you have a very specific need for it. This protocol doesn't support a large chunk of the CDDB protocol and chances are your local CDDB data won't be as up-to-date as the FreeDB.org database servers. On the other hand, if you're without a network connection or need faster access to CDDB data than slow socket connections can provide, this protocol might work well for you.

One thing you should watch out for: The 'stat' command Net_CDDB_Client::statistics() can be extremelly slow if you set the 'use_stat_file' option to 'false' or don't provide a valid 'stat.db' file to the 'stat_file' option. This is because it needs to count the number of files in each of the CDDB category directories (i.e.: count about 1.8 to 2-million files). These two parameters default to:

  • use_stat_file = true
  • stat_file = 'stat.db'
When you first start using this protocol, you should create a 'stat.db' file in the CDDB database dump directory and chmod it so that its read/write by whatever user will be using the Net_CDDB_Client class. Run the 'stat' command immediately to build the 'stat.db' file so that the next 'stat' request doesn't need to count all of the files next time (it just reads the 'stat.db' file instead counters instead).

  • Todo: Finish implementing all of the CDDB commands
  • Todo: Sites file
  • Todo: Support more than one protocol level (and the proto command...?)


[ Top ]


Class Variables

$_buffer =

[line 148]

String buffer containing protocol data
  • Access: protected

Type:   string


[ Top ]

$_dir =

[line 87]

The directory the FreeDB database dump is stored in
  • Access: protected

Type:   string


[ Top ]

$_motd_file =

[line 103]

The filename of the message of the day message (i.e.: motd.txt, which should be located in the FreeDB database dump directory)
  • Access: protected

Type:   string


[ Top ]

$_sites_file =

[line 140]

The filename of a file containing mirror site entries (i.e.: sites.txt)
  • Access: protected

Type:   string


[ Top ]

$_status_buffer =

[line 156]

Integer buffer containing protocol status information
  • Access: protected

Type:   integer


[ Top ]

$_stat_file =

[line 124]

The name of the statistics file (defaults to 'stat.db' in the CDDB database directory)
  • Access: protected

Type:   string


[ Top ]

$_use_motd_file =

[line 95]

Whether or not to use a 'Message of the Day' file for the 'motd' command
  • Access: protected

Type:   boolean


[ Top ]

$_use_sites_file =

[line 132]

  • Todo: Implement...
  • Access: protected

Type:   boolean


[ Top ]

$_use_stat_file =

[line 116]

Whether or not to use a cached statistics file for the 'stat' command

If you don't use a the cached statistics file, then the number of files in each of the CDDB category directories needs to be counted each time you issue a 'stat' command. For a full dump of the database, this can take 10 or 20 *minutes*.

  • Access: protected

Type:   boolean


[ Top ]



Method Detail

__construct (Constructor)   [line 178]

Net_CDDB_Protocol_Filesystem __construct( [string $dsn = 'filesystem:///FreeDB'], array $options)

Constructor (PHP v5.x)
  • Access: public

Parameters:

string   $dsn   — 
array   $options   — 

[ Top ]

Net_CDDB_Protocol_Filesystem (Constructor)   [line 165]

Net_CDDB_Protocol_Filesystem Net_CDDB_Protocol_Filesystem( [ $dsn = 'filesystem:///FreeDB'], $options)

Constructor (PHP v4.x)

Parameters:

   $dsn   — 
   $options   — 

[ Top ]

connect   [line 221]

boolean connect( )

Pretend to connect to a remote server while we actually just check if the database directory is readable

Function will return false if either the filesystem directory does not exist or if the directory is not readable.

  • Access: public

[ Top ]

connected   [line 237]

boolean connected( )

Pretend to check if we are connected to a server
  • Access: public

[ Top ]

disconnect   [line 661]

void disconnect( )

Pretend to disconnect (doesn't actually do anything because you don't need to disconnect from the local filesystem)
  • Access: public

[ Top ]

recieve   [line 637]

string recieve( )

Read data from the protocol buffer
  • Access: public

[ Top ]

remote   [line 674]

boolean remote( )

Report this class as *not* accessing remote resources for protocol output

Overrides Net_CDDB_Protocol::remote() (Tell whether or not a protocol acts on a remote resource)
[ Top ]

send   [line 258]

void send( string $query)

Send a query to the Net_CDDB_Protocol_Filesystem object, the query will be parsed and the buffers will be filled with the response

Not all CDDB commands are implemented for this protocol, some don't make sense in the context of a filesystem protocol and some just havn't been implemented yet.

This method basically parses and dispatches the query to other protected methods of the class for further processing.


Parameters:

string   $query   — 

[ Top ]

status   [line 649]

int status( )

Read the status of the last executed command from the protocol buffer
  • Access: public

[ Top ]

_cddbLscat   [line 381]

void _cddbLscat( string $cmd, string $query)

Handle a 'cddb lscat' (Display disc categories) query and fill the buffer with a response
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 

[ Top ]

_cddbQuery   [line 329]

void _cddbQuery( string $cmd, string $query)

Handle a 'cddb query' (Find possible disc matches by disc id) and fill the buffer with a response
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 

[ Top ]

_cddbRead   [line 409]

void _cddbRead( string $cmd, string $query)

Handle a 'cddb read ...' (read a complete disc entry) query and fill the buffer with a response
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 

[ Top ]

_countDatabaseEntries   [line 482]

integer _countDatabaseEntries( string $category)

Count the number of database entries in a given category (directory)

Parameters:

string   $category   — 

[ Top ]

_discid   [line 310]

void _discid( string $cmd, string $query)

Handle a CDDB 'discid' (Calculate a Disc ID) query and fill the buffer with a response
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 

[ Top ]

_motd   [line 443]

void _motd( string $cmd, string $query)

Handle a 'motd' (Message Of The Day) query and fill the buffers with the repsonse
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 

[ Top ]

_readStatFile   [line 525]

array _readStatFile( )

Read the 'stat' file to determine how many database entries are in each CDDB category

This method performs a check to make sure every CDDB category has a corresponding, valid entry in the 'stat' file. If you want to clear the 'stat' file, just truncate it to 0 characters at the command prompt.


[ Top ]

_stat   [line 575]

void _stat( string $cmd, string $query)

Handle a cddb 'stat' (get server statistics) and fill the buffers with the response

Parameters:

string   $cmd   — 
string   $query   — 

[ Top ]

_ver   [line 468]

void _ver( string $cmd, string $query)

Handle a 'ver' (get CDDB server version) command and fill the buffers with a response
  • Access: protected

Parameters:

string   $cmd   — 
string   $query   — 

[ Top ]

_writeStatFile   [line 503]

boolean _writeStatFile( array $arr)

Write the 'stat' file

Parameters:

array   $arr   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:56:54 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.