<commit_before><?php defined('BASEPATH') OR exit('No direct script access allowed');

// This can be removed if you use __autoload() in config.php OR use Modular Extensions
require APPPATH . '/libraries/REST_Controller.php';
define('TABLE', 'user');

/**
 * Author : Knunu
 * Date: 2016. 7. 22.
 * Time: 오후 7:28
 */

class Api extends REST_Controller {

    public function __construct() {
        // Construct the parent class
        parent::__construct();

        $this->load->model('api_model');
    }

    public function user_get() {

        // user from a data store e.g. database
        $condition = array(
            'email' => $this->get('email'),
            'login_group' => $this->get('login_group'),
            'password' => $<PASSWORD>('password')
        );

        foreach ($condition as $column => $value) {
            if (!$value) {
                unset($condition[$column]);
            }
        }

        if (isset($condition['password'])) {
            $condition['password'] = password_hash($condition['password'], PASSWORD_BCRYPT);
        }
        $user = $this->api_model->get(TABLE, $condition);

        // Check if there is user-data that user want to get
        if ($user->num_rows() > 0) {
            // Set the response and exit
            $this->response($user->result_arrays(), REST_Controller::HTTP_OK);
        } else {
            // Set the response and exit
            $this->response([
                'status' => FALSE,
                'message' => 'No users were found'
            ], REST_Controller::HTTP_NOT_FOUND);
        }
    }

    public function user_post() {
        $new_value = array(
            'email' => $this->post('email'),
            'login_group' => $this->post('login_group'),
            'password' => $this->post('password'),
            'name' => $this->post('name')
        );
        if (!$new_value['password']) {
            $new_value['password'] = password_hash($new_value['password'], PASSWORD_BCRYPT);
        }

        if ($this->api_model->post(TABLE, $new_value)) {
            $this->response([
                'status' => True,
                'message' => 'Success'
            ], REST_Controller::HTTP_OK);
        } else {
            $this->response([
                'status' => False,
                'message' => 'Failed'
            ], REST_Controller::HTTP_BAD_REQUEST);
        }
    }

    public function user_put() {
        $condition = array(
            'email' => $this->post('email'),
            'login_group' => $this->post('login_group')
        );

        $new_value = array(<commit_msg>error fixing...<commit_after><?php defined('BASEPATH') OR exit('No direct script access allowed');

// This can be removed if you use __autoload() in config.php OR use Modular Extensions
require APPPATH . '/libraries/REST_Controller.php';
define('TABLE', 'user');

/**
 * Author : Knunu
 * Date: 2016. 7. 22.
 * Time: 오후 7:28
 */

class Api extends REST_Controller {

    public function __construct() {
        // Construct the parent class
        parent::__construct();

        $this->load->model('api_model');
    }

    public function user_get() {

        // user from a data store e.g. database
        $condition = array(
            'email' => $this->get('email'),
            'login_group' => $this->get('login_group'),
            'password' => $this->get('password')
        );

        foreach ($condition as $column => $value) {
            if (!$value) {
                unset($condition[$column]);
            }
        }

        if (isset($condition['password'])) {
            $condition['password'] = password_hash($condition['password'], PASSWORD_BCRYPT);
        }
        $user = $this->api_model->get(TABLE, $condition);

        // Check if there is user-data that user want to get
        if ($user->num_rows() > 0) {
            // Set the response and exit
            $this->response($user->result_arrays(), REST_Controller::HTTP_OK);
        } else {
            // Set the response and exit
            $this->response([
                'status' => FALSE,
                'message' => 'No users were found'
            ], REST_Controller::HTTP_NOT_FOUND);
        }
    }

    public function user_post() {
        $new_value = array(
            'email' => $this->post('email'),
            'login_group' => $this->post('login_group'),
            'password' => $this->post('password'),
            'name' => $this->post('name')
        );
        if (!$new_value['password']) {
            $new_value['password'] = password_hash($new_value['password'], PASSWORD_BCRYPT);
        }
        echo $new_value['password'];

        if ($this->api_model->post(TABLE, $new_value)) {
            $this->response([
                'status' => True,
                'message' => 'Success'
            ], REST_Controller::HTTP_OK);
        } else {
            $this->response([
                'status' => False,
                'message' => 'Failed'
            ], REST_Controller::HTTP_BAD_REQUEST);
        }
    }

    public function user_put() {
        $condition = array(
            'email' => $this->post('email'),
            'login_group' => $this->post('login_group')
        );

        $new_value = array(
{'fraction_non_alphanumeric': 0.1570830159939071, 'fraction_numerical': 0.004188880426504189, 'mean_word_length': 1.905420353982301, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 79, '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': '1054913', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1459, 'n_words': 328}