public function mediainfo($paths)
 {
     $filename = $this->getWorkDir($paths->target);
     if (!Fs::get()->isFile($filename)) {
         throw new Exception("Error Processing Request", 6);
     }
     $commands = array();
     $flags = '';
     $st = mediainfoSettings::load();
     $task = new rTask(array('arg' => call_user_func('end', explode('/', $filename)), 'requester' => 'mediainfo', 'name' => 'mediainfo', 'no' => 0));
     if ($st && !empty($st->data["mediainfousetemplate"])) {
         $randName = $task->makeDirectory() . "/opts";
         file_put_contents($randName, $st->data["mediainfotemplate"]);
         $flags = "--Inform=file://" . escapeshellarg($randName);
     }
     $commands[] = getExternal("mediainfo") . " " . $flags . " " . Helper::mb_escapeshellarg($filename);
     $ret = $task->start($commands, rTask::FLG_WAIT);
     return $ret;
 }
예제 #2
0
파일: action.php 프로젝트: Snusel/ruTorrent
$ret = array("status" => 255, "errors" => array("Can't retrieve information"));
if (isset($_REQUEST['hash']) && isset($_REQUEST['no']) && isset($_REQUEST['cmd'])) {
    switch ($_REQUEST['cmd']) {
        case "mediainfo":
            $req = new rXMLRPCRequest(new rXMLRPCCommand("f.get_frozen_path", array($_REQUEST['hash'], intval($_REQUEST['no']))));
            if ($req->success()) {
                $filename = $req->val[0];
                if ($filename == '') {
                    $req = new rXMLRPCRequest(array(new rXMLRPCCommand("d.open", $_REQUEST['hash']), new rXMLRPCCommand("f.get_frozen_path", array($_REQUEST['hash'], intval($_REQUEST['no']))), new rXMLRPCCommand("d.close", $_REQUEST['hash'])));
                    if ($req->success()) {
                        $filename = $req->val[1];
                    }
                }
                if ($filename !== '') {
                    $commands = array();
                    $flags = '';
                    $st = mediainfoSettings::load();
                    $task = new rTask(array('arg' => call_user_func('end', explode('/', $filename)), 'requester' => 'mediainfo', 'name' => 'mediainfo', 'hash' => $_REQUEST['hash'], 'no' => $_REQUEST['no']));
                    if ($st && !empty($st->data["mediainfousetemplate"])) {
                        $randName = $task->makeDirectory() . "/opts";
                        file_put_contents($randName, $st->data["mediainfotemplate"]);
                        $flags = "--Inform=file://" . escapeshellarg($randName);
                    }
                    $commands[] = getExternal("mediainfo") . " " . $flags . " " . escapeshellarg($filename);
                    $ret = $task->start($commands, rTask::FLG_WAIT);
                }
            }
            break;
    }
}
cachedEcho(json_encode($ret), "application/json");