CC-1713 - New storage directory structure

Changed the GUNID to a 32 hex string (MD5 value), there is no more
conversion between hex strings and bigints in the database anymore.

Added added the file extension to the file name.

Stored the complete path to the file in the database.  This means that
linking doesnt need to create any files at all. (It used to create a
symlink to the file you were importing)

The structure and file naming should be fine - there are 4096 possibilities
for the first directory level, and even will a million files this is only
244 files per sub-directory.  The GUID is fine for the file name
This commit is contained in:
paul.baranowski 2010-11-11 16:50:30 -05:00
parent 3879d1c7d4
commit 35dc3fd01f
8 changed files with 215 additions and 78 deletions

13
api/api_version.php Normal file
View file

@ -0,0 +1,13 @@
<?php
require_once('../conf.php');
$api_key = $_GET['api_key'];
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
}
print json_encode(array("version"=>CAMPCASTER_VERSION));
?>

38
api/get_media.php Normal file
View file

@ -0,0 +1,38 @@
<?php
require_once('../conf.php');
require_once('DB.php');
$api_key = $_GET['api_key'];
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
}
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
if (PEAR::isError($CC_DBC)) {
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
exit(1);
}
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
$file_id = $_GET[""]
if(!is_file($src))
{
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
//print 'Ressource in database, but not in storage. Sorry.';
exit;
}
// !! binary mode !!
$fp = fopen($src, 'rb');
header("Content-Type: audio/mpeg");
header("Content-Length: " . filesize($src));
fpassthru($fp);
exit;
?>

25
api/schedule.php Normal file
View file

@ -0,0 +1,25 @@
<?php
require_once('../conf.php');
require_once('DB.php');
require_once('../backend/Schedule.php');
$api_key = $_GET['api_key'];
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
}
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
if (PEAR::isError($CC_DBC)) {
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
exit(1);
}
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
$from = $_GET["from"];
$to = $_GET["to"];
echo Schedule::ExportRangeAsJson($from, $to);
?>