Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('BASEPATH') || exit('No direct script access allowed');
- /**
- * videos controller
- */
- class Videos extends Front_Controller
- {
- protected $permissionCreate = 'Videos.Create';
- protected $permissionDelete = 'Videos.Delete';
- protected $permissionEdit = 'Videos.Edit';
- protected $permissionView = 'Videos.View';
- protected $permissionManage = 'Videos.Manage';
- public $fields = array();
- protected $mbConverterHost = '192.168.200.190';
- protected $mbConverterUsername = 'mediabox-converter';
- protected $mbConverterPassword = 'dawd!@#$';
- protected $mbHost = '192.168.200.171';
- protected $mbUsername = 'mediabox';
- protected $mbPassword = 'dawd!@#$';
- protected $mbTrackerHost = '192.168.200.178';
- protected $mbTrackerUsername = 'mediabox-tracker';
- protected $mbTrackerPassword = 'dawd!@#$';
- protected $trackerFilePath = "/home/mediabox-tracker/encodes";
- protected $trackerTorrentPath = "/home/mediabox-tracker/torrents";
- /**
- * Constructor
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- $this->auth->restrict($this->permissionView);
- $this->load->model('videos/videos_model');
- $this->lang->load('videos/main', '', false, true, '', '', false);
- $this->lang->load('datatable');
- $this->load->helper('color_helper');
- $this->load->library('functions');
- load_color('videos/main');
- ini_set('max_execution_time', 600);
- //Load sshseclib for SSH commands.
- include(realpath(APPPATH) . '/libraries/phpseclib/Net/SSH2.php');
- }
- /**
- * Display a list of Videos data.
- *
- * @return void
- */
- public function index()
- {
- $this->auth->restrict($this->permissionView);
- $breadcrumb = array('nomenclator' => lang('nomenclator'), 'videos' => lang('videos'));
- breadcrumb($breadcrumb, true, false);
- $this->load->model('datatable/datatable_model');
- $dataTable['id'] = 'videos_table';
- $dataTable['url'] = 'videos';
- $dataTable['module'] = 'videos';
- $dataTable['fields'] = $this->videos_model->get_fields();
- $this->datatable_model->add_js($dataTable);
- $videos = $this->videos_model->getAllVideos();
- foreach ($videos as $k => $video) {
- $videos[$k]['duration_readable'] = $this->timable($video['duration_seconds']);
- }
- Template::set('clientId', $this->parent());
- Template::set('videos', $videos);
- Assets::clear_cache();
- Assets::add_module_js('grupuri', 'bootbox.min.js');
- Assets::add_js('resumable.js');
- Template::set_view('videos/front/index');
- Template::render();
- }
- private function timable($seconds)
- {
- $t = round($seconds);
- return sprintf('%02d:%02d:%02d', ($t / 3600), ($t / 60 % 60), $t % 60);
- }
- /**
- * Form for videos module
- *
- * @param int $id -> id_record
- *
- * @return void
- */
- public function form($id = NULL)
- {
- if (empty($id)) {
- $this->auth->restrict($this->permissionCreate);
- $mode = 'create';
- $breadcrumb = array('nomenclator' => lang('nomenclator'), 'videos' => lang('videos'), 'form' => lang('add_label'));
- } elseif (is_numeric($id)) {
- $this->auth->restrict($this->permissionEdit);
- $mode = 'edit';
- $breadcrumb = array('nomenclator' => lang('nomenclator'), 'videos' => lang('videos'), 'form' => lang('edit_label'));
- }
- breadcrumb($breadcrumb, true, false);
- if (isset($_POST['save'])) {
- if ($id_i = $this->form_videos($mode, $id)) {
- if ($mode == 'create') {
- if (is_numeric($id_i)) {
- Template::set_message(lang('videos_create_success'), 'success');
- } else {
- Template::set_message(lang('videos_create_failure'), 'success');
- }
- } else {
- Template::set_message(lang('videos_edit_success'), 'success');
- }
- redirect('nomenclator/videos');
- }
- // Not validation error
- if (!empty($this->videos_model->error)) {
- Template::set_message(lang('videos_edit_failure') . $this->videos_model->error, 'error');
- }
- } elseif (isset($_POST['delete'])) {
- $this->auth->restrict($this->permissionDelete);
- $result = true;
- $deleted = $this->videos_model->delete($id);
- if ($deleted == false) {
- $result = false;
- }
- if ($result) {
- Template::set_message(lang('videos_delete_success'), 'success');
- redirect('nomenclator/videos');
- } else {
- Template::set_message(lang('videos_delete_failure') . $this->videos_model->error, 'error');
- }
- }
- $data = array();
- if ($mode == 'edit') {
- $data = $this->videos_model->find($id);
- }
- Template::set('data', $data);
- Template::set_view('videos/front/form');
- Template::render();
- }
- /**
- * Process form for videos module
- * Check for validation if validations are ok go to insert/update
- *
- * @param string $mode -> create|edit
- * @param int $id -> record id for update
- *
- * @return int|bool
- */
- private function form_videos($mode, $id = NULL)
- {
- // Validate the data
- $this->load->model('validari/get_validari_model');
- $banned = $this->videos_model->get_banned_labels();
- $this->form_validation->set_rules($this->get_validari_model->get_validation_rules(9, $banned));
- if ($this->form_validation->run() === false) {
- return false;
- }
- // Make sure we only pass in the fields we want
- $data = $this->videos_model->prep_data($this->input->post());
- $return = false;
- if ($mode == 'create') {
- $id = $this->videos_model->update($data);
- if (is_numeric($id)) {
- $return = $id;
- }
- } elseif ($mode == 'edit') {
- $return = $this->videos_model->update($data, $id);
- }
- return $return;
- }
- /**
- * Autovehicule datatable
- *
- *
- * @return void
- */
- public function datatable()
- {
- $this->load->model('datatable/datatable_model');
- $fields = array(
- 'id' => '',
- 'videos_name' => '',
- );
- $this->datatable_model->generate_output($fields, 'videos');
- }
- //Uploading Spaghetti
- public function run()
- {
- $this->output->enable_profiler(FALSE); /* Disable Profiler */
- //Set paths
- $realPath = realpath('./uploads') . '/client_' . $this->parent();
- $tempPath = $realPath . '/temp/';
- $originalPath = $realPath . '/original/';
- $encodesPath = $realPath . '/encodes/';
- $torrentsPath = $realPath . '/torrents/';
- $logsPath = $realPath . '/logs/';
- //Create Folders if missing
- $this->createFolders($tempPath, $originalPath, $encodesPath, $torrentsPath, $logsPath);
- if ($_SERVER['REQUEST_METHOD'] === 'GET') {
- if (!(isset($_GET['resumableIdentifier']) && trim($_GET['resumableIdentifier']) != '')) {
- $_GET['resumableIdentifier'] = '';
- }
- $temp_dir = $tempPath . $_GET['resumableIdentifier'];
- if (!(isset($_GET['resumableFilename']) && trim($_GET['resumableFilename']) != '')) {
- $_GET['resumableFilename'] = '';
- }
- if (!(isset($_GET['resumableChunkNumber']) && trim($_GET['resumableChunkNumber']) != '')) {
- $_GET['resumableChunkNumber'] = '';
- }
- $chunk_file = $temp_dir . $_GET['resumableFilename'] . '.part' . $_GET['resumableChunkNumber'];
- if (file_exists($chunk_file)) {
- header("HTTP/1.0 200 Ok");
- die;
- } else {
- header("HTTP/1.0 404 Not Found");
- die;
- }
- }
- // loop through files and move the chunks to a temporarily created directory
- if (!empty($_FILES)) foreach ($_FILES as $file) {
- // check the error status
- if ($file['error'] != 0) {
- //@TODO RARES LOG THIS
- log_message('error', 'V05:' . $file['error'] . ' in file ' . $_POST['resumableFilename']);
- // $this->_log('error ' . $file['error'] . ' in file ' . $_POST['resumableFilename']);
- continue;
- }
- // init the destination file (format <filename.ext>.part<#chunk>
- // the file is stored in a temporary directory
- if (isset($_POST['resumableIdentifier']) && trim($_POST['resumableIdentifier']) != '') {
- $temp_dir = $tempPath . $_POST['resumableIdentifier'];
- }
- $dest_file = $temp_dir . '/' . $_POST['resumableFilename'] . '.part' . $_POST['resumableChunkNumber'];
- // print_r($dest_file); die;
- // create the temporary directory
- if (!is_dir($temp_dir)) {
- umask(0002);
- if (!mkdir($temp_dir, 0777, true)) {
- log_message('error', 'V06: Nu s-a putut crea directorul ' . $temp_dir);
- }
- }
- // move the temporary file
- if (!move_uploaded_file($file['tmp_name'], $dest_file)) {
- log_message('error', "V06: Nu s-a putut muta fisierul sursa: {$file['tmp_name']} in locatia $dest_file");
- // $this->_log('Error saving (move_uploaded_file) chunk ' . $_POST['resumableChunkNumber'] . ' for file ' . $_POST['resumableFilename']);
- } else {
- // check if all the parts present, and create the final destination file
- $this->createFileFromChunks($temp_dir, $_POST['resumableFilename'], $_POST['resumableChunkSize'], $_POST['resumableTotalSize'], $_POST['resumableTotalChunks'], $originalPath, $encodesPath, $torrentsPath);
- }
- }
- }
- //
- // private function _log($str)
- // {
- //
- // // log to the output
- // $log_str = date('d.m.Y') . ": {$str}\r\n";
- // echo $log_str;
- //
- // // log to file
- // if (($fp = fopen('upload_log.txt', 'a+')) !== false) {
- // fputs($fp, $log_str);
- // fclose($fp);
- // }
- // }
- /**
- *
- * Delete a directory RECURSIVELY
- * @param string $dir - directory path
- * @link http://php.net/manual/en/function.rmdir.php
- */
- private function rrmdir($dir)
- {
- if (is_dir($dir)) {
- $objects = scandir($dir);
- foreach ($objects as $object) {
- if ($object != "." && $object != "..") {
- if (filetype($dir . "/" . $object) == "dir") {
- $this->rrmdir($dir . "/" . $object);
- } else {
- unlink($dir . "/" . $object);
- }
- }
- }
- reset($objects);
- rmdir($dir);
- }
- }
- /**
- *
- * Check if all the parts exist, and
- * gather all the parts of the file together
- * @param string $temp_dir - the temporary directory holding all the parts of the file
- * @param string $fileName - the original file name
- * @param string $chunkSize - each chunk size (in bytes)
- * @param string $totalSize - original file size (in bytes)
- */
- private function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize, $total_files, $originalPath, $encodesPath, $torrentsPath)
- {
- // count all the parts of this file
- $total_files_on_server_size = 0;
- $temp_total = 0;
- // var_dump($this->rrmdir($temp_dir)); die;
- foreach (scandir($temp_dir) as $file) {
- $temp_total = $total_files_on_server_size;
- $tempfilesize = filesize($temp_dir . '/' . $file);
- $total_files_on_server_size = $temp_total + $tempfilesize;
- }
- // print_r($total_files_on_server_size); die;
- // check that all the parts are present
- // If the Size of all the chunks on the server is equal to the size of the file uploaded.
- if ($total_files_on_server_size >= $totalSize) {
- // create the final destination file
- if (($fp = fopen($originalPath . $fileName, 'w')) !== false) {
- for ($i = 1; $i <= $total_files; $i++) {
- fwrite($fp, file_get_contents($temp_dir . '/' . $fileName . '.part' . $i));
- // $this->_log('writing chunk ' . $i);
- }
- fclose($fp);
- // get new filename, insert in db;
- // $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
- $data = $this->setFilename($fileName, $originalPath);
- $this->encodeVideo($data, $originalPath, $encodesPath, $torrentsPath);
- } else {
- return false;
- }
- // rename the temporary directory (to avoid access from other
- // concurrent chunks uploads) and than delete it
- if (rename($temp_dir, $temp_dir . '_UNUSED')) {
- $this->rrmdir($temp_dir . '_UNUSED');
- } else {
- $this->rrmdir($temp_dir);
- }
- }
- }
- //Set Filename for uploaded file.
- public function setFilename($fileName = NULL, $originalPath = NULL)
- {
- if (!isset($fileName) || !isset($originalPath)) {
- log_message('error', "V07: $fileName sau $originalPath nu este setat ");
- return FALSE;
- }
- $userId = $this->parent();
- if (!$userId) {
- log_message('error', "V08:\$this->parent() returned invalid user id");
- return FALSE;
- }
- $lastId = $this->videos_model->getNextIdVideos();
- $stripName = preg_replace('/\s+/', '_', $fileName);
- //Generate new name
- $data['newFileName'] = "{$userId}_{$lastId}_$stripName";
- //Rename the file
- if (!rename($originalPath . '/' . $fileName, $originalPath . '/' . $data['newFileName'])) {
- log_message('error', "V09: Error renaming file $originalPath/$fileName in {$originalPath}/{$data['newFileName']}");
- }
- //Get mediainfo for file
- $data['details'] = $this->getMediainfo($data['newFileName'], $originalPath);
- if (empty($data['details'])) {
- log_message('error', "V12: Empty media info for video");
- return FALSE;
- }
- //Insert mediainfo in DB
- $this->client_db->insert('videos', array(
- 'client_id' => $userId,
- 'filename' => $data['newFileName'],
- 'duration_seconds' => $data['details']['duration_seconds'],
- 'duration_milliseconds' => $data['details']['duration_milliseconds'],
- 'width' => $data['details']['width'],
- 'height' => $data['details']['height'],
- 'added' => date('Y-m-d H:i:s'),
- 'filesize' => $data['details']['filesize']
- ));
- $data['torrent_insert_id'] = $this->client_db->insert_id();
- // $json['filename'] = $data['newFileName'];
- // $json['id'] = $data['torrent_insert_id'];
- // echo json_encode($json);
- return $data;
- }
- public function getMediainfo($fileName, $originalPath)
- {
- if (!empty($fileName)) {
- $ssh = new Net_SSH2($this->mbHost);
- if (!$ssh->login($this->mbUsername, $this->mbPassword)) {
- log_message('error', "V10:Nu s-a putut realiza conectiunea la SSH on host {$this->mbHost}");
- return FALSE;
- }
- $filePath = $originalPath . $fileName;
- $data['duration_seconds'] = ceil($ssh->exec("/usr/bin/mediainfo --Inform=\"Video;%Duration%\" $filePath") / 1000);
- $data['duration_milliseconds'] = $ssh->exec("/usr/bin/mediainfo --Inform=\"Video;%Duration%\" $filePath");
- $data['width'] = $ssh->exec("/usr/bin/mediainfo --Inform=\"Video;%Width%\" $filePath");
- $data['height'] = $ssh->exec("/usr/bin/mediainfo --Inform=\"Video;%Height%\" $filePath");
- $data['filesize'] = filesize($filePath);
- return $data;
- } else {
- log_message('error', 'V11: Empty $fileName');
- return FALSE;
- }
- }
- //Get file extension by mime type
- private function getFileExtension($fileName)
- {
- //Define mime type extensions
- $fileTypeExtensions = array(
- "video/x-matroska" => "mkv",
- "application/x-troff-msvideo" => "avi",
- "video/avi" => "avi",
- "video/msvideo" => "avi",
- "video/x-msvideo" => "avi",
- "video/mpeg" => "mpeg",
- "video/quicktime" => "mov",
- "video/mp4" => "mp4",
- "video/x-flv" => "flv",
- "video/x-m4v" => "m4v",
- );
- $mimeType = mime_content_type($fileName);
- if (isset($fileTypeExtensions[$mimeType])) {
- $ext = $fileTypeExtensions[$mimeType];
- return $ext;
- } else {
- return FALSE;
- }
- }
- private function encodeVideo($data, $originalPath, $encodesPath, $torrentsPath)
- {
- $fileName = $data['newFileName'];
- //Local filepath
- $file = $originalPath . '/' . $fileName;
- $ext = $this->getFileExtension($file);
- if (empty($ext)) {
- log_message('error', 'V14: Mime Type not allowed.');
- DIE('INVALID MIME TYPE');
- }
- //Path with original files filepath
- $remote_file_path = "/home/mediabox-converter/ftp/$fileName";
- //Connect to SSH
- $ssh = new Net_SSH2($this->mbConverterHost);
- if (!$ssh->login($this->mbConverterUsername, $this->mbConverterPassword)) {
- log_message('error', 'V15: Cannot connect to SSH on server ' . $this->mbConverterHost);
- return FALSE;
- }
- //Connect to SFTP
- $conn_id = ftp_connect($this->mbConverterHost);
- $ftp_connect = ftp_login($conn_id, $this->mbConverterUsername, $this->mbConverterPassword);
- if(!$ftp_connect) {
- log_message('error', "V16: Nu s-a putut conecta la serverul de ftp la adresa {$this->mbConverterHost}");
- }
- //UPLOAD FILE TO ENCODER SERVER
- if (ftp_put($conn_id, $remote_file_path, $file, FTP_BINARY)) {
- ftp_close($conn_id);
- //Save encode command based on video extension/container
- switch ($ext) {
- case 'mkv':
- $sshCommand['encodeVideo'] = "/usr/bin/avconv -i /home/mediabox-converter/ftp/$fileName -codec copy /home/mediabox-converter/encodes/$fileName.mp4";
- break;
- case 'avi':
- $sshCommand['encodeVideo'] = "/usr/bin/avconv -i /home/mediabox-converter/ftp/$fileName -c:v libx264 -c:a copy /home/mediabox-converter/encodes/$fileName.mp4";
- break;
- case 'mpeg':
- $sshCommand['encodeVideo'] = "/usr/bin/avconv -i /home/mediabox-converter/ftp/$fileName /home/mediabox-converter/encodes/$fileName.mp4";
- break;
- case 'mov':
- $sshCommand['encodeVideo'] = "/usr/bin/avconv -i /home/mediabox-converter/ftp/$fileName -c copy /home/mediabox-converter/encodes/$fileName.mp4";
- break;
- case 'flv':
- $sshCommand['encodeVideo'] = "/usr/bin/avconv -i /home/mediabox-converter/ftp/$fileName -codec copy /home/mediabox-converter/encodes/$fileName.mp4";
- break;
- case 'm4v':
- $sshCommand['encodeVideo'] = "/usr/bin/avconv -i /home/mediabox-converter/ftp/$fileName -strict -2 /home/mediabox-converter/encodes/$fileName.mp4";
- break;
- }
- if (isset($sshCommand['EncodeVideo'])) { /* If video is not MP4 -> Original MP4 files skips this step. */
- $sshOutput = ">> /home/mediabox-converter/logs/$fileName.log 2>&1"; /* ssh command to output stderr and stdout in file */
- //Create log file on Convertor Server
- $ssh->exec("touch /home/mediabox-converter/logs/$fileName.log"); /* Create log file to log all output of encode */
- $ssh->setTimeout(0); /* Wait until command finishes before continuing */
- $ssh->exec($sshCommand['EncodeVideo'] . $sshOutput); /* Encode Video and print output to log file */
- $ssh->setTimeout(0); /* Wait until command finishes before continuing */
- $ssh->exec("scp /home/mediabox-converter/encodes/$fileName.mp4 {$this->mbUsername}@{$this->mbHost}:$encodesPath$fileName.mp4 "); /* Move encode back to GUI */
- } else {
- copy($originalPath . $fileName, $encodesPath . "$fileName.mp4"); /* Copy encode from Original folder to Encodes folder */
- }
- //ENCODE DONE. ENCODED FILE MOVED TO GUI !!!
- //MOVE ENCODE TO TRACKER
- //Tracker Connection
- $ftpConnectionTracker = ftp_connect($this->mbTrackerHost);
- $ftpConnectionTrackerResult = ftp_login($ftpConnectionTracker, $this->mbTrackerUsername, $this->mbTrackerPassword);
- if (!$ftpConnectionTrackerResult) {
- log_message('error', "Nu s-a putut face conexiunea FTP la {$this->mbTrackerHost}.");
- }
- //Check if remote encode folder exists. If not, create it
- if (@ftp_chdir($ftpConnectionTracker, "$this->trackerFilePath/client_{$this->parent()}") === false) {
- ftp_mkdir($ftpConnectionTracker, "$this->trackerFilePath/client_{$this->parent()}"); //directory doesn't exist - so make it
- }
- //Check if remote torrent folder exists. If not, create it
- if (@ftp_chdir($ftpConnectionTracker, "$this->trackerTorrentPath/client_{$this->parent()}") === false) {
- ftp_mkdir($ftpConnectionTracker, "$this->trackerTorrentPath/client_{$this->parent()}"); //directory doesn't exist - so make it
- }
- //Get tracker's path to encode file
- $trackerPathToFile = "$this->trackerFilePath/client_{$this->parent()}/$fileName.mp4";
- // print_r("$this->trackerFilePath/client_{$this->parent()}/$fileName.mp4"); die;
- if (ftp_put($ftpConnectionTracker, $trackerPathToFile, "$encodesPath$fileName.mp4", FTP_BINARY)) {
- $ssh = new Net_SSH2($this->mbTrackerHost);
- if (!$ssh->login($this->mbTrackerUsername, $this->mbTrackerPassword)) {
- log_message('error', "Nu s-a putut face conexiunea SSH la {$this->mbTrackerHost}.");
- return FALSE;
- }
- //Get torrent filename
- $torrentFilename = "$fileName.mp4.torrent";
- $torrentSeederFilename = "$fileName.mp4_seeder.torrent";
- //Get tracker's path to torrent file
- $trackerPathToTorrent = "/home/mediabox-tracker/torrents/client_{$this->parent()}/$torrentFilename";
- $trackerPathToTorrentSeeder = "/home/mediabox-tracker/torrents/client_{$this->parent()}/$torrentSeederFilename";
- //create .torrent file
- $ssh->setTimeout(0);
- $stream = $ssh->exec("transmission-create -o $trackerPathToTorrent -s 1024KiB -c '$fileName' -t http://{$this->mbTrackerHost}/tracker/announce.php?passkey= $trackerPathToFile");
- $ssh->setTimeout(0);
- $stream = $ssh->exec("transmission-create -o $trackerPathToTorrentSeeder -s 1024KiB -c '$fileName' -t http://{$this->mbTrackerHost}/tracker/announce.php?passkey=098f6bcd4621d373cade4e832627b4f0 $trackerPathToFile");
- $ssh->setTimeout(0);
- $magnetLink = $ssh->exec("transmission-show -m $trackerPathToTorrent");
- if (!$this->videos_model->updateMagnetDB($data['torrent_insert_id'], $magnetLink)) {
- log_message("error", "Nu s-a putut ");
- return FALSE;
- }
- //Sa trimit la RabbitMQ tuturor cutiilor magnetul cu passkeyul fiecaruia.
- // if (!$this->sendTorrentAll($magnetLink)) {
- // die('eroare: nu s-a trimis magnet torrentul cutiilor;');
- // }
- if (!is_dir($torrentsPath)) {
- umask(0002);
- mkdir($torrentsPath, 0777, true);
- }
- // print_r($torrentsPath . $torrentSeederFilename);
- // print_r(" -- " . $trackerPathToTorrentSeeder); die;
- // var_dump(ftp_get($ftpConnectionTracker, $torrentsPath . $torrentSeederFilename, $trackerPathToTorrentSeeder, FTP_BINARY)); die;
- if (ftp_get($ftpConnectionTracker, $torrentsPath . $torrentSeederFilename, $trackerPathToTorrentSeeder, FTP_BINARY)) {
- //Move .torrent file and movie to mediabox-seeders
- ftp_close($ftpConnectionTracker);
- $this->initSeeders($fileName . '.mp4', $encodesPath, $torrentsPath . $torrentSeederFilename);
- }
- }
- } else {
- log_message('error', "V17:Nu s-a putut pune fisierul pe FTP conn_id=$conn_id, remote_file=$remote_file_path, file=$file");
- echo "There was a problem while uploading $file\n";
- }
- }
- //Init seeders to start seeding
- private function initSeeders($fileName, $encodesPath, $torrentsPathToFileGUI)
- {
- $data = $this->getSeeders();
- // print_r($trackerPathToTorrentSeeder); die;
- if ($data) {
- foreach ($data as $seeder) {
- $ftpConnectionSeeder = ftp_connect($seeder['hostname']);
- $ftpConnectionSeederResult = ftp_login($ftpConnectionSeeder, $seeder['username'], $seeder['password']);
- if (ftp_put($ftpConnectionSeeder, "/home/{$seeder['username']}/Downloads/$fileName", $encodesPath . $fileName, FTP_BINARY)) {
- ftp_put($ftpConnectionSeeder, "/home/{$seeder['username']}/torrents/$fileName.torrent", $torrentsPathToFileGUI, FTP_BINARY);
- }
- }
- }
- ftp_close($ftpConnectionSeeder);
- }
- private function getSeeders()
- {
- if ($data = $this->videos_model->getSeeders()) {
- return $data;
- }
- return FALSE;
- }
- public function rename_video_ajax()
- {
- $this->auth->restrict($this->permissionEdit);
- if ($this->videos_model->renameVideo($this->input->post('id'), $this->input->post('videos_name'))) {
- echo TRUE;
- }
- echo FALSE;
- }
- public function delete_video_ajax()
- {
- $this->auth->restrict($this->permissionDelete);
- if ($this->videos_model->deleteVideo($this->input->post('id'))) {
- echo TRUE;
- }
- echo FALSE;
- }
- public function createFolders($tempPath, $originalPath, $encodesPath, $torrentsPath, $logsPath)
- {
- if (!is_dir($tempPath)) {
- umask(0002);
- if (!mkdir($tempPath, 0777, true)) {
- log_message('error', 'Nu s-a putut crea folderul cu calea ' . $tempPath);
- }
- }
- if (!is_dir($originalPath)) {
- umask(0002);
- if (!mkdir($originalPath, 0777, true)) {
- log_message('error', 'V01: Nu s-a putut crea folderul cu calea ' . $tempPath);
- }
- }
- if (!is_dir($encodesPath)) {
- umask(0002);
- if (!mkdir($encodesPath, 0777, true)) {
- log_message('error', 'V02: Nu s-a putut crea folderul cu calea ' . $tempPath);
- }
- }
- if (!is_dir($torrentsPath)) {
- umask(0002);
- if (!mkdir($torrentsPath, 0777, true)) {
- log_message('error', 'V03: Nu s-a putut crea folderul cu calea ' . $tempPath);
- }
- }
- if (!is_dir($logsPath)) {
- umask(0002);
- if (!mkdir($logsPath, 0777, true)) {
- log_message('error', 'V04: Nu s-a putut crea folderul cu calea ' . $tempPath);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement