public static function copyFileToStor($p_targetDir, $fileName) { $audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $fileName; $md5 = md5_file($audio_file); $duplicate = StoredFile::RecallByMd5($md5); if ($duplicate) { if (PEAR::isError($duplicate)) { die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() . '}}'); } if (file_exists($duplicate->getFilePath())) { $duplicateName = $duplicate->getMetadataValue('MDATA_KEY_TITLE'); die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named ' . $duplicateName . ' already exists in the storage server."}}'); } } $storDir = MusicDir::getStorDir(); $stor = $storDir->getDirectory(); $stor .= "/organize"; $audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName; $r = @copy($audio_file, $audio_stor); }
public function listAllWatchedDirsAction() { global $CC_CONFIG; $request = $this->getRequest(); $api_key = $request->getParam('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; } $result = array(); $arrWatchedDirs = MusicDir::getWatchedDirs(); $storDir = MusicDir::getStorDir(); $result[$storDir->getId()] = $storDir->getDirectory(); foreach ($arrWatchedDirs as $watchedDir) { $result[$watchedDir->getId()] = $watchedDir->getDirectory(); } $this->view->dirs = $result; }