From a1d90f6bbcebcbf334a0582efa60e3c361f2c2f6 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 15 Jan 2007 23:12:54 +0000 Subject: [PATCH] Fix to prevent double-import in the Web interface. Part of #1805 --- .../modules/htmlUI/var/html/ui_handler.php | 10 ++++---- campcaster/src/modules/htmlUI/var/ui_conf.php | 2 +- .../modules/htmlUI/var/ui_handler.class.php | 24 +++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/campcaster/src/modules/htmlUI/var/html/ui_handler.php b/campcaster/src/modules/htmlUI/var/html/ui_handler.php index 5f3af0251..b37b14c60 100644 --- a/campcaster/src/modules/htmlUI/var/html/ui_handler.php +++ b/campcaster/src/modules/htmlUI/var/html/ui_handler.php @@ -25,7 +25,7 @@ switch ($_REQUEST['act']) { $uiHandler->logout(TRUE); break; - ## file/webstream handling + // file/webstream handling case "addFileData": if (($ui_tmpid = $uiHandler->uploadFile(array_merge($_REQUEST, $_FILES), $ui_fmask["file"])) !== FALSE) { $uiHandler->SCRATCHPAD->addItem($ui_tmpid); @@ -260,9 +260,11 @@ switch ($_REQUEST['act']) { break; case "PL.addItem": - if ($uiHandler->PLAYLIST->addItem($_REQUEST['id'], $_REQUEST['playlength']) !== FALSE) { - $uiHandler->SCRATCHPAD->addItem($_REQUEST['id']); - } + if (isset($_REQUEST['id']) && isset($_REQUEST['playlength'])) { + if ($uiHandler->PLAYLIST->addItem($_REQUEST['id'], $_REQUEST['playlength']) !== FALSE) { + $uiHandler->SCRATCHPAD->addItem($_REQUEST['id']); + } + } $uiHandler->PLAYLIST->setReload(); break; diff --git a/campcaster/src/modules/htmlUI/var/ui_conf.php b/campcaster/src/modules/htmlUI/var/ui_conf.php index 149f9b459..4576619cf 100644 --- a/campcaster/src/modules/htmlUI/var/ui_conf.php +++ b/campcaster/src/modules/htmlUI/var/ui_conf.php @@ -2,7 +2,7 @@ ini_set('memory_limit', '64M'); // Warning/Error level -define('UI_DEBUG', TRUE); +define('UI_DEBUG', FALSE); define('UI_VERBOSE', FALSE); define('UI_WARNING', TRUE); define('UI_ERROR', TRUE); diff --git a/campcaster/src/modules/htmlUI/var/ui_handler.class.php b/campcaster/src/modules/htmlUI/var/ui_handler.class.php index ae1d5e3fe..a2fa14b8a 100644 --- a/campcaster/src/modules/htmlUI/var/ui_handler.class.php +++ b/campcaster/src/modules/htmlUI/var/ui_handler.class.php @@ -136,6 +136,14 @@ class uiHandler extends uiBase { return FALSE; } + $md5 = md5_file($formdata['mediafile']['tmp_name']); + $duplicate = StoredFile::RecallByMd5($md5); + if ($duplicate) { + $this->_retMsg('The file "'.basename($formdata['mediafile']['name']).'" already exists in the database.'); + $this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId']; + return FALSE; + } + $metadata = camp_get_audio_metadata($formdata['mediafile']['tmp_name']); if (PEAR::isError($metadata)) { $this->_retMsg($metadata->getMessage()); @@ -162,12 +170,12 @@ class uiHandler extends uiBase { } $this->setMetadataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name']); - $this->transMData($r); + $this->translateMetadata($r); // set records in default language too if (UI_UPLOAD_LANGID !== UI_DEFAULT_LANGID) { $this->setMetadataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name'], UI_UPLOAD_LANGID); - $this->transMData($r, UI_UPLOAD_LANGID); + $this->translateMetadata($r, UI_UPLOAD_LANGID); } $this->redirUrl = UI_BROWSER."?act=addFileMData&id=$r"; @@ -191,12 +199,11 @@ class uiHandler extends uiBase { /** - * @todo Rename this function. * @param unknown_type $id * @param unknown_type $langid * @return void */ - function transMData($id, $langid=UI_DEFAULT_LANGID) + function translateMetadata($id, $langid=UI_DEFAULT_LANGID) { include(dirname(__FILE__).'/formmask/metadata.inc.php'); @@ -431,15 +438,6 @@ class uiHandler extends uiBase { { $this->redirUrl = UI_BROWSER."?popup[]=_reload_parent&popup[]=_close"; - /* no folder support yet - if (!($delOverride==$id) && (count(BasicStor::GetObjType($id)=='Folder'? - $this->gb->listFolder($id, $this->sessid):NULL))) { - $this->_retMsg("Folder is not empty. You can override this protection by clicking DEL again"); - $this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid."&delOverride=$id"; - return FALSE; - } - */ - if (is_array($id)) { $ids = $id; } else {