-remove cc_access table and gunid usage

This commit is contained in:
Martin Konecny 2012-07-22 16:12:34 -04:00
parent b283b5b55e
commit 3735579378
16 changed files with 383 additions and 790 deletions

View file

@ -113,54 +113,51 @@ class ApiController extends Zend_Controller_Action
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$fileID = $this->_getParam("file");
$file_id = substr($fileID, 0, strpos($fileID, "."));
$fileId = $this->_getParam("file");
if (ctype_alnum($file_id) && strlen($file_id) == 32) {
$media = Application_Model_StoredFile::RecallByGunid($file_id);
if ($media != null) {
$media = Application_Model_StoredFile::Recall($fileId);
if ($media != null) {
$filepath = $media->getFilePath();
if (is_file($filepath)) {
$full_path = $media->getPropelOrm()->getDbFilepath();
$filepath = $media->getFilePath();
if (is_file($filepath)) {
$full_path = $media->getPropelOrm()->getDbFilepath();
$file_base_name = strrchr($full_path, '/');
/* If $full_path does not contain a '/', strrchr will return false,
* in which case we can use $full_path as the base name.
*/
if (!$file_base_name) {
$file_base_name = $full_path;
} else {
$file_base_name = substr($file_base_name, 1);
}
// possibly use fileinfo module here in the future.
// http://www.php.net/manual/en/book.fileinfo.php
$ext = pathinfo($fileID, PATHINFO_EXTENSION);
//Download user left clicks a track and selects Download.
if ("true" == $this->_getParam('download')) {
//path_info breaks up a file path into seperate pieces of informaiton.
//We just want the basename which is the file name with the path
//information stripped away. We are using Content-Disposition to specify
//to the browser what name the file should be saved as.
//
// By james.moon:
// I'm removing pathinfo() since it strips away UTF-8 characters.
// Using manualy parsing
header('Content-Disposition: attachment; filename="'.$file_base_name.'"');
} else {
//user clicks play button for track and downloads it.
header('Content-Disposition: inline; filename="'.$file_base_name.'"');
}
if (strtolower($ext) === 'mp3') {
$this->smartReadFile($filepath, 'audio/mpeg');
} else {
$this->smartReadFile($filepath, 'audio/'.$ext);
}
exit;
$file_base_name = strrchr($full_path, '/');
/* If $full_path does not contain a '/', strrchr will return false,
* in which case we can use $full_path as the base name.
*/
if (!$file_base_name) {
$file_base_name = $full_path;
} else {
header ("HTTP/1.1 404 Not Found");
$file_base_name = substr($file_base_name, 1);
}
// possibly use fileinfo module here in the future.
// http://www.php.net/manual/en/book.fileinfo.php
$ext = pathinfo($file_base_name, PATHINFO_EXTENSION);
//Download user left clicks a track and selects Download.
if ("true" == $this->_getParam('download')) {
//path_info breaks up a file path into seperate pieces of informaiton.
//We just want the basename which is the file name with the path
//information stripped away. We are using Content-Disposition to specify
//to the browser what name the file should be saved as.
//
// By james.moon:
// I'm removing pathinfo() since it strips away UTF-8 characters.
// Using manualy parsing
header('Content-Disposition: attachment; filename="'.$file_base_name.'"');
} else {
//user clicks play button for track and downloads it.
header('Content-Disposition: inline; filename="'.$file_base_name.'"');
}
if (strtolower($ext) === 'mp3') {
$this->smartReadFile($filepath, 'audio/mpeg');
} else {
$this->smartReadFile($filepath, 'audio/'.$ext);
}
exit;
} else {
header ("HTTP/1.1 404 Not Found");
}
}