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 setStorageDirAction() { global $CC_CONFIG; $request = $this->getRequest(); $api_key = $request->getParam('api_key'); $path = base64_decode($request->getParam('path')); if (!in_array($api_key, $CC_CONFIG["apiKey"])) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; exit; } $this->view->msg = MusicDir::setStorDir($path); }
public function removeWatchDirectoryAction() { $chosen = $this->getRequest()->getParam("dir"); $dir = MusicDir::removeWatchedDir($chosen); $watched_dirs_form = new Application_Form_WatchedDirPreferences(); $this->view->subform = $watched_dirs_form->render(); }
public static function removeWatchedDir($p_dir) { $p_dir = realpath($p_dir) . "/"; $dir = MusicDir::getDirByPath($p_dir); if ($dir == NULL) { return array("code" => 1, "error" => "'{$p_dir}' doesn't exist in the watched list."); } else { $dir->remove(); $data = array(); $data["directory"] = $p_dir; RabbitMq::SendMessageToMediaMonitor("remove_watch", $data); return array("code" => 0); } }