Exemplo n.º 1
0
 public function delete_hidden_file($task_id, $file)
 {
     $filename = decode_from_url($file);
     $filepath = 'private/uploads/task_files/task_' . intval($task_id) . '/hidden/' . $filename;
     $this->output->set_content_type('application/json');
     if (file_exists($filepath)) {
         @unlink($filepath);
         $this->output->set_output(json_encode(TRUE));
     } else {
         $this->output->set_output(json_encode(FALSE));
     }
 }
Exemplo n.º 2
0
 public function do_change_password($token, $encoded_email)
 {
     if ($this->usermanager->is_student_session_valid()) {
         $this->messages->add_message('lang:students_change_password_student_loged_in', Messages::MESSAGE_TYPE_ERROR);
         redirect('/');
     }
     $this->load->library('form_validation');
     $email = decode_from_url($encoded_email);
     if ($this->form_validation->valid_email($email) && preg_match('/^[0-9a-f]{40}$/', $token)) {
         $this->_transaction_isolation();
         $this->db->trans_begin();
         $student = new Student();
         $student->where('password_token', $token);
         $student->where('email', $email);
         $student->get();
         if ($student->exists()) {
             $this->_init_language_for_student($student);
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:students_change_password_invalid_token_email', Messages::MESSAGE_TYPE_ERROR);
             redirect(create_internal_url('students/login'));
         }
         $this->form_validation->set_rules('student[password]', 'lang:students_change_password_form_field_password', 'required|min_length[6]|max_length[20]');
         $this->form_validation->set_rules('student[verify]', 'lang:students_change_password_form_field_verify', 'required|matches[student[password]]');
         if ($this->form_validation->run()) {
             $student_post = $this->input->post('student');
             $student->password = sha1($student_post['password']);
             $student->password_token = NULL;
             if ($student->save()) {
                 $this->db->trans_commit();
                 $this->messages->add_message('lang:students_change_password_success', Messages::MESSAGE_TYPE_SUCCESS);
                 redirect(create_internal_url('students/login'));
             } else {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:students_change_password_failed', Messages::MESSAGE_TYPE_ERROR);
                 redirect(create_internal_url('students/login'));
             }
         } else {
             $this->db->trans_rollback();
             $this->change_password($token, $encoded_email);
         }
     } else {
         $this->messages->add_message('lang:students_change_password_invalid_token_email', Messages::MESSAGE_TYPE_ERROR);
         redirect(create_internal_url('students/login'));
     }
 }
Exemplo n.º 3
0
 public function quick_course_change($course_id, $current_url)
 {
     $this->activate_course($course_id);
     $output = $this->output->get_output();
     $output_object = json_decode($output);
     $this->messages->add_message($output_object->message, $output_object->status ? Messages::MESSAGE_TYPE_SUCCESS : Messages::MESSAGE_TYPE_ERROR);
     $decoded_current_url = decode_from_url($current_url);
     redirect($decoded_current_url);
 }
Exemplo n.º 4
0
 public function show_file_content($task_set_id, $solution_id, $solution_file, $zip_index)
 {
     $this->output->set_content_type('text/plain');
     $task_set = new Task_set();
     $task_set->where_related('solution', 'id', $solution_id);
     $task_set->include_related('solution/student', 'id');
     $task_set->get_by_id($task_set_id);
     if ($task_set->exists()) {
         $file_name = decode_from_url($solution_file);
         $output = $task_set->extract_student_file_by_index($file_name, $zip_index);
         if ($output !== FALSE) {
             $this->output->set_output('<div class="codepreview_container"><pre class="codepreview prettyprint linenums lang-' . strtolower($output['extension']) . '">' . htmlspecialchars($output['content']) . '</pre></div>');
         } else {
             $this->output->set_output($this->lang->line('admin_solutions_valuation_file_content_error_cant_read_file'));
         }
     } else {
         $this->output->set_output($this->lang->line('admin_solutions_valuation_file_content_error_task_set_not_found'));
     }
 }
Exemplo n.º 5
0
 public function delete_csv_file($config)
 {
     $csv_data = unserialize(decode_from_url($config));
     $file_path = './private/uploads/csv_imports/' . $csv_data['f'];
     @unlink($file_path);
 }
Exemplo n.º 6
0
 public function switch_prefered_course($course_id, $current_url)
 {
     $this->usermanager->teacher_login_protected_redirect();
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $teacher = new Teacher();
     $teacher->get_by_id($this->usermanager->get_teacher_id());
     if ($teacher->exists()) {
         $course = new Course();
         $course->get_by_id($course_id);
         if ($teacher->save(array('prefered_course' => $course))) {
             $this->db->trans_commit();
             $this->usermanager->refresh_teacher_userdata();
             $this->messages->add_message('lang:admin_teachers_prefered_course_quickchange_success', Messages::MESSAGE_TYPE_DEFAULT);
             $this->load->library('filter');
             $this->filter->set_all_filters_course($teacher->prefered_course_id);
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_teachers_prefered_course_quickchange_failed', Messages::MESSAGE_TYPE_ERROR);
         }
     } else {
         $this->db->trans_rollback();
         $this->messages->add_message('lang:admin_teachers_prefered_course_quickchange_failed', Messages::MESSAGE_TYPE_ERROR);
     }
     redirect(decode_from_url($current_url));
 }
Exemplo n.º 7
0
 public function download_hidden_file($task_id, $file)
 {
     $filename = decode_from_url($file);
     $filepath = 'private/uploads/task_files/task_' . intval($task_id) . '/hidden/' . $filename;
     if (file_exists($filepath)) {
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
         $mime_type = finfo_file($finfo, $filepath);
         finfo_close($finfo);
         header('Content-Description: File Transfer');
         header('Content-Type: ' . $mime_type);
         header('Content-Disposition: attachment; filename=' . basename($filepath));
         header('Content-Transfer-Encoding: binary');
         header('Expires: 0');
         header('Cache-Control: must-revalidate');
         header('Pragma: public');
         header('Content-Length: ' . filesize($filepath));
         ob_clean();
         flush();
         $f = fopen($filepath, 'r');
         while (!feof($f)) {
             echo fread($f, 1024);
         }
         fclose($f);
         exit;
     } else {
         $this->output->set_status_header(404, 'Not found');
     }
 }