Пример #1
0
 public function upload()
 {
     $user_id = $this->session->userdata('user_id');
     // Action not possible if an user is not logged in.
     if (!$user_id) {
         $this->load->helper('message');
         show_error_msg_page($this, $this->lang->line('ui_msg_login_restriction'));
         return;
     }
     $this->load->library('form_validation');
     $this->form_validation->set_error_delimiters('<span class="error">', '</span>');
     if ($this->form_validation->run('upload') === FALSE) {
         $params = array('title' => $this->lang->line('ui_nav_menu_upload') . ' &ndash; ' . $this->config->item('site_name'));
         $this->load->library('html_head_params', $params);
         // **
         // ** LOADING VIEWS
         // **
         $this->load->view('html_begin', $this->html_head_params);
         $this->load->view('header', array('selected_menu' => 'upload'));
         $main_params['content'] = $this->load->view('video/upload_view', array(), TRUE);
         $main_params['side'] = $this->load->view('side_default', NULL, TRUE);
         $this->load->view('main', $main_params);
         $this->load->view('footer');
         $this->load->view('html_end');
     } else {
         $this->load->model('videos_model');
         $this->load->helper('video');
         $this->config->load('content_ingestion');
         $name = urlencode(str_replace(' ', '-', $this->input->post('video-title')));
         $category_id = $this->input->post('video-category');
         // Prepare formats
         $formats = $this->config->item('formats');
         $prepared_formats = prepare_formats($formats, $this->av_info, $this->config->item('elim_dupl_res'));
         // Add video to DB.
         $activation_code = $this->videos_model->add_video($name, $this->input->post('video-title'), $this->input->post('video-description'), $this->input->post('video-tags'), $this->av_info['duration'], $prepared_formats['db_formats'], $category_id, $user_id, $this->uploaded_file);
         if ($activation_code == FALSE) {
             $this->load->helper('message');
             show_error_msg_page($this, $this->lang->line('video_msg_add_video_db_error'));
             return;
         }
         // Send a content ingestion request to
         // CIS (Content Ingestion Server).
         $r = $this->videos_model->send_content_ingestion($activation_code, $this->uploaded_file, $name, $this->av_info['size'], $prepared_formats['transcode_configs']);
         if ($r == FALSE) {
             $this->videos_model->set_cis_response($activation_code, CIS_RESP_UNREACHABLE);
             $this->load->helper('message');
             show_error_msg_page($this, $this->lang->line('video_msg_send_content_ingestion_error'));
             return;
         }
         $this->load->helper('message');
         show_info_msg_page($this, $this->lang->line('video_msg_video_uploaded'));
     }
 }
Пример #2
0
 public function activate($user_id, $method = '', $activation_code = '')
 {
     $user_id = intval($user_id);
     $res_form_validation = FALSE;
     if ($method == 'code') {
         if (!$activation_code) {
             $res_form_validation = $this->form_validation->run('activate');
         } else {
             if ($this->_valid_activation_code($activation_code) && $this->users_model->activate_account($user_id, $activation_code)) {
                 $this->load->helper('message');
                 show_info_msg_page($this, sprintf($this->lang->line('user_msg_activated_account'), site_url('user/login')));
                 return;
             } else {
                 $this->load->helper('message');
                 show_error_msg_page($this, $this->lang->line('user_msg_wrong_activation_code'));
                 return;
             }
         }
     } else {
         if ($method == 'resend') {
             $res_form_validation = $this->form_validation->run('resend_activation');
         }
     }
     $userdata = $this->users_model->get_userdata($user_id, 'email, a.activation_code');
     $email = $userdata['email'];
     $activated_account = $userdata['activation_code'] == NULL;
     if ($activated_account) {
         $this->load->helper('message');
         show_info_msg_page($this, sprintf($this->lang->line('user_msg_activated_account'), site_url('user/login')));
         return;
     }
     $this->load->library('form_validation');
     $this->form_validation->set_error_delimiters('<span class="error">', '</span>');
     if ($res_form_validation === FALSE) {
         $params = array('title' => $this->lang->line('user_title_activation') . ' &ndash; ' . $this->config->item('site_name'));
         $this->load->library('html_head_params', $params);
         // **
         // ** LOADING VIEWS
         // **
         $this->load->view('html_begin', $this->html_head_params);
         $this->load->view('header', array());
         // Show form
         $main_params['content'] = $this->load->view('user/activate_view', array('user_id' => $user_id, 'email' => $userdata['email']), TRUE);
         $main_params['side'] = $this->load->view('side_default', NULL, TRUE);
         $this->load->view('main', $main_params);
         $this->load->view('footer');
         $this->load->view('html_end');
     } else {
         if ($method == 'code') {
             // A message which tells the user that the
             // activation was successful.
             $this->load->helper('message');
             show_info_msg_page($this, sprintf($this->lang->line('user_msg_activated_account'), site_url('user/login')));
             return;
         } else {
             if ($method == 'resend') {
                 // Redirect to resent message
                 $this->load->helper('message');
                 show_info_msg_page($this, sprintf($this->lang->line('user_msg_activation_resent'), $this->input->post('email')));
                 return;
             }
         }
     }
 }