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

class Server extends CI_Controller {

        public function __construct()
        {
                parent::__construct();
                $this->load->library('UnilaSecure');
                $this->load->model('AuthModel');
		$this->load->model('MhsModel');
        }
        public function index()
        {
                echo 'Server';
        }

	public function get_mhs_npm()
	{
		$id_client = $this->input->post('id_client');
		$key = $this->input->post('key');
		$data = $this->input->post('data');
		//echo $id_client." ".$key;

		$decypt = $this->unilasecure->decrypt_client_arr($data, $key);

		$auth_client = $this->AuthModel->get_client($id_client, $key);

		//print_r($auth_client);
		
		if(isset($auth_client))
		{
			//print_r($decypt);
			$res = $this->MhsModel->get_mhs($decypt['npm']);
		}
		else
		{
			$res = null;
		}

		$id_server = "serverSimponilaDummy";
		$key_server = "cThIIoDvwdueQB468K5xDc5633seEFoqwxjF_xSJyQQ";

		$dt['id_server'] = $id_server;
		$dt['data'] = $res[0];

		$encypt = $this->unilasecure->encrypt_client_arr($dt, $key_server);

		echo $encypt;

	}

}

