<commit_before><?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Upload extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('item_model');
    }

    public function do_upload() {
        if (!$this->session->userdata('logged_in')) {
            redirect('login');
        } else {
            $config['upload_path'] = './uploads/';
            $config['allowed_types'] = 'gif|jpg|png';
            $this->load->library('upload', $config);
            $this->load->library('form_validation');
            $this->form_validation->set_rules('title', 'Title', 'trim|required|max_length[100]');
            $this->form_validation->set_rules('description', 'Description', 'trim|max_length[255]');
            if ($this->form_validation->run() == FALSE) {
                $this->load->view('header');
                $this->load->view('item/add');
            } elseif ($this->input->post('userfile') and $this->upload->do_upload() == FALSE) {
                $this->load->view('header');
                $this->load->view('item/add');
            } else {
                $new_id = $this->item_model->add_new_item();
                redirect('item/view/' . $new_id);
            }
        }
    }

}
?>
<commit_msg>Fixed picture bug a bit<commit_after><?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Upload extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('item_model');
    }

    public function do_upload() {
        if (!$this->session->userdata('logged_in')) {
            redirect('login');
        } else {
            $config['upload_path'] = './uploads/';
            $config['allowed_types'] = 'gif|jpg|jpeg|png';
            $this->load->library('upload', $config);
            $this->load->library('form_validation');
            $this->form_validation->set_rules('title', 'Title', 'trim|required|max_length[100]');
            $this->form_validation->set_rules('description', 'Description', 'trim|max_length[255]');
            if ($this->form_validation->run() == FALSE) {
                $this->load->view('header');
                $this->load->view('item/add');
            } else {
                $this->upload->do_upload();
                $new_id = $this->item_model->add_new_item();
                redirect('item/view/' . $new_id);
            }
        }
    }

}
?>

{'fraction_non_alphanumeric': 0.1829907295445385, 'fraction_numerical': 0.0048367593712212815, 'mean_word_length': 2.2444444444444445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2995269', 'n_tokens_mistral': 724, 'n_tokens_neox': 700, 'n_words': 106}