Moved all file-related functions from BasicStor into StoredFile class.
Got rid of all the stuff related to GUNID hex-to-int conversion. Commented out lots of functions that are either not in use or will no longer work. Pypo: made things more generic and pluggable, added documentation. Added the PHP scripts to serve the right info back to pypo.
This commit is contained in:
parent
35dc3fd01f
commit
8a58df3093
32 changed files with 2233 additions and 2000 deletions
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
require_once('../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../backend/StoredFile.php');
|
||||
|
||||
$api_key = $_GET['api_key'];
|
||||
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
|
@ -19,20 +20,35 @@ if (PEAR::isError($CC_DBC)) {
|
|||
}
|
||||
$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;
|
||||
$file_id = $_GET["file_id"];
|
||||
if (ctype_alnum($file_id) && strlen($file_id) == 32) {
|
||||
$media = StoredFile::RecallByGunid($file_id);
|
||||
if ($media != null && !PEAR::isError($media)) {
|
||||
//var_dump($media);
|
||||
$filepath = $media->getRealFileName();
|
||||
if(!is_file($filepath))
|
||||
{
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
//print 'Ressource in database, but not in storage. Sorry.';
|
||||
exit;
|
||||
}
|
||||
|
||||
// !! binary mode !!
|
||||
$fp = fopen($filepath, 'rb');
|
||||
|
||||
header("Content-Type: audio/mpeg");
|
||||
header("Content-Length: " . filesize($filepath));
|
||||
|
||||
fpassthru($fp);
|
||||
}
|
||||
else {
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
|
||||
// !! binary mode !!
|
||||
$fp = fopen($src, 'rb');
|
||||
|
||||
header("Content-Type: audio/mpeg");
|
||||
header("Content-Length: " . filesize($src));
|
||||
|
||||
fpassthru($fp);
|
||||
exit;
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue