public function addFile($file, $duration, $password) { $torrentfile = explode('|', $file); if (count($torrentfile) > 1) { $file = array($torrentfile[1], $torrentfile[0]); } if (is_array($file)) { $file = \Flm\Helper::getTorrentHashFilepath($file[0], $file[1]); } else { $file = fullpath(trim($file, DIRECTORY_SEPARATOR), $this->userdir); } $this->validDuration($duration); $share = Storage::load(); if ($this->islimited('links', $share->size())) { throw new Exception("File limit reached " . $share->size(), 2); } if (($stat = LFS::stat($file)) === FALSE) { throw new Exception("Invalid file " . $file, 2); } $data = array('path' => $file, 'size' => $stat['size'], 'expire' => time() + 3600 * $duration, 'password' => $password); return $share->add($data); }
public function sfvCreate($paths) { $sfvfile = $this->getUserDir($paths->target); $files = array_map(array($this, 'getWorkDir'), (array) $paths->fls); if (Fs::get()->isFile($sfvfile)) { throw new Exception("File already exists", 16); } $temp = Helper::getTempDir(); $args = array('action' => 'sfvCreate', 'params' => array('files' => $files, 'target' => $sfvfile), 'temp' => $temp); $task = $temp['dir'] . 'task'; file_put_contents($task, json_encode($args)); $task_opts = array('requester' => 'filemanager', 'name' => 'SFV create'); $rtask = new \rTask($task_opts); $commands = array(Helper::getTaskCmd() . " " . escapeshellarg($task)); $ret = $rtask->start($commands, 0); //var_dump($ret); return $temp; }
public function readLog($lpos = 0) { var_dump('readdding log....'); return is_file($this->log) ? Helper::readTaskLog($this->log, $lpos) : false; }
public function viewNfo($params) { if (!isset($params->mode)) { $params->mode = 0; } if (!isset($params->target)) { Helper::jsonError(2); } try { $contents = $this->flm->nfo_get($params->target, $params->mode); } catch (\Exception $err) { Helper::jsonError($err->getCode()); return false; } Helper::jsonOut(array('error' => 0, 'nfo' => $contents)); }
public function _run() { if (!isset($_POST['action'])) { die; } try { $this->fs = new FSHARE(); } catch (\Exception $err) { var_dump($err); Helper::jsonError($err->getCode()); } $action = $_POST['action']; $call = json_decode($action); if ($call) { $this->_processCall($call); } else { Helper::jsonError(3); } }
public function extract($to) { $formatBin = self::getFormatBinary($this->file); if (!$formatBin) { throw new Exception("Error Processing Request", 18); } $temp = Helper::getTempDir(); $args = array('action' => 'extract', 'params' => array('file' => $this->file, 'to' => $to, 'binary' => getExternal($formatBin)), 'temp' => $temp); $task = $temp['dir'] . 'task'; file_put_contents($task, json_encode($args)); $task_opts = array('requester' => 'filemanager', 'name' => 'unpack'); $rtask = new \rTask($task_opts); $commands = array(Helper::getTaskCmd() . " " . escapeshellarg($task)); $ret = $rtask->start($commands, 0); return $temp; }