示例#1
0
 public function insert()
 {
     if ($this->input->post()) {
         $this->load->helper("misc_helper");
         $this->load->library('form_validation');
         $this->form_validation->set_rules('name', 'Playlist Name', 'required');
         $this->form_validation->set_rules('type', 'Playlist Type', 'required');
         $this->form_validation->set_rules('sort', 'Sort By', 'required');
         if ($this->input->post("type") == 2) {
             $this->form_validation->set_rules('list', 'Playlist Tags', 'required');
             $this->form_validation->set_rules('limit', 'Video Limit', 'required');
         }
         if ($this->form_validation->run()) {
             $data = ["name" => $this->input->post("name"), "ref_id" => create_refid(), "profile_id" => $this->profile_id, "type" => $this->input->post("type"), "sort" => $this->input->post("sort"), "limit" => $this->input->post("limit"), "list" => $this->input->post("type") == 2 ? json_encode(["tags" => $this->input->post("list")]) : $this->input->post("list"), "date_input" => date("Y-m-d H:i:s")];
             if ($this->playlist->proses_dbase("insert", $this->security->xss_clean($data))) {
                 redirect('playlist');
             }
         } else {
             $this->load->view('header');
             $this->load->view('playlist_add');
             $this->load->view('footer');
         }
     } else {
         redirect("playlist", "refresh");
     }
 }
示例#2
0
 public function createNew()
 {
     $profile_id = $this->data['user_session']['profileid'];
     $frompage = $this->input->post('page');
     $master = $this->input->post('master');
     $level = $this->lib_folder->getNewLevel($master);
     if ($level > MAX_FOLDER_CHILD) {
         $this->session->set_flashdata('alert', '<span class="label label-danger">Error!</span> Folder child exceed limit');
     } else {
         $this->load->helper("misc_helper");
         $data = array('profile_id' => $profile_id, 'ref_id' => create_refid(), 'name' => $this->lib_media->clear($this->input->post('folder_name')), 'master' => $master, 'level' => $level, 'date_input' => date('Y-m-d H:i:s'));
         if ($data['name'] == '') {
             $this->session->set_flashdata('alert', '<span class="label label-danger">Error!</span> Please enter folder name!');
         } else {
             $exc = $this->folder->createFolder($data);
             if ($exc) {
                 $fid = $this->lib_folder->folderLastId();
                 $arr = array($fid);
                 $this->lib_folder->updateChildFolder('create', $fid, $arr);
                 for ($a = $level - 1; $a > 0; $a--) {
                     if ($master != NULL || $master > 0) {
                         $this->lib_folder->updateChildFolder('update', $master, $arr);
                         $master = $this->lib_folder->hasMasterFolder($master);
                     }
                 }
             }
             $this->session->set_flashdata('alert', '<span class="label label-success">Success!</span> New folder ' . $data['name'] . ' has been created');
         }
     }
     redirect($frompage);
 }
示例#3
0
 public function post_process($file_name = "")
 {
     //init
     $file = $this->input->post("file");
     $file_total_chunk = $this->input->post("total");
     $file_ = explode(".", $file);
     //merge file
     if ($file_total_chunk > 1) {
         $target_path = $this->config->item("upload_path");
         $final_file_path = fopen($target_path . $file, "ab");
         //Reconstructed File
         for ($i = 1; $i < $file_total_chunk; $i++) {
             $file_chunk = $target_path . $file_[0] . $i . "." . $file_[1];
             if ($final_file_path) {
                 // Read binary input stream and append it to temp file
                 $in = fopen($file_chunk, "rb");
                 if ($in) {
                     while ($buff = fread($in, 10485760)) {
                         fwrite($final_file_path, $buff);
                     }
                 }
                 if (fclose($in)) {
                     unlink($file_chunk);
                     clearstatcache();
                 }
             }
         }
         fclose($final_file_path);
     }
     //make dir & move
     $new_ext = $this->data['user_session']['profileid'] . '/' . date('YmdHis') . "_" . url_title(strtolower($file_[0]), "_");
     $new_dir = $this->config->item("upload_path") . $new_ext;
     $this->create_dir($new_dir);
     rename($this->config->item("upload_path") . strtolower(str_replace(" ", "_", $file)), $new_dir . "/" . strtolower(str_replace(" ", "_", $file)));
     //send to database
     $this->load->model("mdl_media", "media");
     $this->load->helper("misc_helper");
     $data_db = array("ref_id" => create_refid(), "profile_id" => $this->data['user_session']['profileid'], "file_name" => strtolower(str_replace(" ", "_", $file)), "file_path" => $new_dir . "/" . strtolower(str_replace(" ", "_", $file)), "file_url" => $this->config->item("public_url") . $new_ext . "/" . strtolower(str_replace(" ", "_", $file)), "title" => strtolower(url_title($file_[0], "_")), "date_input" => date("Y-m-d H:i:s"));
     $this->media->proses_media("insert", $data_db);
 }