MDB (Media DataBase) is just a little php webapp I wrote to keep track of the copious amounts of anime I have stored on my fileserver. It’s designed for easy browsing – as opposed to having a big conglomeration of files and folders that people have to sort through, it’ll index all the files and categorize them and sort the titles alphabetically. There’s other features such as searching. In addition to indexing the filenames, it also indexes filesizes, so it can calculate the size of your entire collection on the fly as well as print the size of each file and title (as long as your database is updated). Mine as of right now is 1.95 TB ;-)

There are user roles too – anonymous users can only browse the list of files. Normal (level 0) users can download the files too. Privileged (level 1) users can download as well as maintain the database – telling it to update its file list, perform integrity checks to make sure all the files are mapped, etc.

Other nifty features include search string highlighting, and an AJAX updater page – it will query the server once a second to see if the updatedb script is running – while it’s going, it’ll show an animated “…” ellipses, and will print “Database update completed” when the update is done. If the browser doesn’t support AJAX it’ll just print “Database updating” and stay that way. Fortunately it has checks to ensure database atomicity; that is, it won’t let you run more than one instance of the database update script to protect against commit collisions.

It uses ADOdb for the database connections, Smarty for the template display, and Mootools for the sidebar menu effects.

After installing those things, it’s easy to install mdb, just extract the tarball and create the database structure using the included SQL file. You’ll need to set up config/mdb.conf.php with your database connection options as well as file paths. It might be a little hard to grasp, so I’ll explain it here.

My anime filesystem structure looks kind of like this:

/storage
/storage/anime1
/storage/anime1/cowboy bebop/*.{avi,mkv,mp4}
/storage/anime1/full metal panic/01 – original/*.mkv
/storage/anime1/full metal panic/02 – fumoffu/*.mkv
/storage/anime1/full metal panic/03 – the second raid/*.mkv
/storage/anime2
/storage/anime2/love hina/tv/*.{avi,mkv,mp4}
/storage/anime2/love hina/manga/*.zip
/storage/anime3
/storage/anime3/suzumiya haruhi no yuutsu/afk/*.avi
/storage/anime3/suzumiya haruhi no yuutsu/animanda/*.avi
/storage/non-anime/*
/storage/incoming/*

You get the idea.
anime1, anime2, and anime3 are three raids. These are the ones that I want to index. “non-anime” is obviously non-anime stuff and “incoming” is the folder where I put incoming downloads. I want to index the 3 anime raids but I don’t want to index the incoming/non-anime directories (this is purely an anime list).
The root directory is specified as “/storage/”:

$mdb_conf['root'] = "/storage/";

The files I want to exclude are “incoming” and “non-anime”:

$mdb_conf['excludes'] = array(
"non-anime",
"incoming",
);

The title base is the list of files in which titles are. So on my filesystem, all the titles are under anime1, anime2, and anime3. Everything deeper than that is just a file stored under its respective directory. So in these examples, “full metal panic” would be recognized as a title since it’s right under anime1, but its subdirectories “01 – original”, “02 – fumoffu”, and “03 – the second raid” just have their contents categorized under the “full metal panic” title listing. Therefore, the titlebase set is:

$mdb_conf['titlebase'] = array(
"anime1",
"anime2",
"anime3",
);

I hope that’s enough of an explanation. If not, ask me.
You’ll find those configuration options in the mdb.conf.php as well as the database connection, smarty paths, adodb caching, etc. After doing that, you need to update the database as a privileged user that can do it through the web interface.

Changelog

  • 20080821 – 0.0.8
    • Make sure to turn off output buffering when downloading a file (or else files larger than the output buffer size will be truncated)
  • 20080714 – 0.0.7: 
    • Strip out non-alphanumeric characters when adding tags – preventing tags such as “genderbending” and “gender bending” being treated as two different tags
    • Exclude ext3′s “lost+found” directory by default
    • The dbcheck page now scans for files that are in the database but no longer exist on disk
    • Persistent connections disabled by default
    • Debugging no longer interferes with file downloads
    • When loading a title’s page, list of titles on the right will automatically open to the correct letter
    • Apply smarty’s trimwritespace filter to all templates
    • Organizational cleanup
    • Cache framework, including cache stats on the dbstats page, cache info in the footer (type/hits/misses), and an option on the db management page to flush cache
    • Memcached cache type
    • Eaccelerator cache type
    • File cache type
  • 20080619 – 0.0.6: 
    • Database update times are logged in a table
    • The updatedb page shows the output of the status test if something goes wrong
    • PHP commandline binary used in db updates is configurable
    • Allow setting a cooloff time between database updates (for example, if last update was less than X seconds ago, skip update)
    • Fixed the shell hack mutex test in some places
    • Allow using the database to store update status (rather than just testing with ps and grep) – please read the notes in the config file before enabling this!
    • Add debug option to dump a bunch of info during execution
    • Fix OPTIMIZE TABLE calls that weren’t working
    • The optimize configure option now applies to updatedb (so optimizing after updating can be optional too)
    • Updatedb status test reports when cooloff time hasn’t been met
    • Mapping sanity check has been moved to a more generic db check page that will also check consistency of dbmutex
    • Optimizing is done on dbcheck page instead of during db stats
    • Use php’s builtin uname for dbstats page instead of running external uname
    • Clean up uptime output on dbstats page
    • Avoid caching password hash in session key
    • Add user management page so admins can add and delete users, and change user privileges (from/to admin)
    • Add preferences page for users to change passwords
    • Metadata links for titles have been moved to a generic links table, rather than an AnimeNFO-specific table
    • Title list no longer depends on images that I couldn’t include – colored by CSS now
    • Use newer mootools rather than old moo.fx for javascript effects (scripts included now)
    • CSS split into themes – formatting is in a core css file and colors/styles are in separate theme files. Comes with three themes – Dark Aqua, Dark Lime, and Light
    • Users can set their preferred css theme on their preferences page
    • Some PHP warnings are cleaned up
    • Chooses an optimal title listing method (SQL queries or iteration) by the number of titles in the system
    • Title listing using SQL uses prepared statements for speedup
    • A footer now shows db status (size, titles, files, etc), the number of queries executed, and the execution time of the page
    • Footer and main page show a warning when database is upgrading
    • ADOdb caching now works (it didn’t before) – please read the notes in the config file about adodb caching’s performance hit before enabling!
    • Remove limit statements to be more portable with other databases
    • Remove file_title association table and embed the title id in the file database instead – files can only have one title
    • Fix bug with tag substring collisions (e.g. “girls” and “girls with guns” being treated as the same tag)
    • Change delete links to submit buttons that use POST – safer to avoid accidental triggering by spiders (although I don’t know why you’d spider this in the first place)
    • Database operations (updatedb, dbstats, dbcheck) are now all triggered from one admin-only database page
    • Minor optimizations of SQL queries
    • Only count directories as titles
    • Filelist on title page is now shown hierarchically indented by directory
    • Directories on title page are now collapsible by javascript. All files are shown by default, so will degrade gracefully if javascript is off – directories just won’t collapse
  • 20080610 – 0.0.5: 
    • Prevent SQL injections in searches
    • Move config to its own directory
    • Break up function library into a file for each function that’s loaded on demand
    • Made ADOdb prefix configurable
    • Rewrite SQL/PHP in functions unmapped, taglist, prunetags, userhistory, titlelist
    • Fixed file download function which broke in some browsers
    • Use a transaction during database update to avoid users seeing corrupt data during update
  • 20070714 – 0.0.4: 
    • Support for tracking a user’s download history (can be disabled). Regular users see their own history, privileged users can see all other users’ histories. Shows files downloaded, size, total downloaded by user, and whois lookups for user ips
    • Fix a bug with titles having the same prefix crossfeeding into each other (Air and Airmaster, for example)
  • 20060815 – 0.0.3: 
    • Support for migrating tags/links when titles are moved across titlebases (in my case, between RAIDs)
    • Support for AnimeNFO link(s) for titles
    • My weak attempt at a nicer site design ;)
    • Support for excluding certain file extensions
    • Configurable AJAX updatedb query interval
    • Untagging (removing a single tag from a single title) support
    • Config option to allow/disallow file downloads entirely
    • Several bugfixes
  • 20060612 – 0.0.2: 
    • Tagging / tag cloud support – any user can view tags for a series, series under a tag, and the tag cloud. Normal users can also add new tags and apply existing tags to titles. Administrators can also delete tags.
    • Fixed a bug in the title updatedb function
  • 20060606 – 0.0.1: 
    • Initial release
    • TODO: need easier way to add users

Download

Older versions