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

/**
 * Appinfo
 */


class Appinfo extends CI_Controller
{

    private $CI;

    function __construct()
    {
        $this->CI = & get_instance();

    }

	function main()
	{

		if ( ! $this->CI->input->post_get('token')) {
			$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
        }
		$token = $this->CI->input->post_get('token');


        $app_id = (int) trim($this->CI->input->post_get('app_id'));
        if (empty($app_id)) {
			$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
        }

		$this->CI->load->model(array('Apps_model'));

        $where = array(
			'app_id' => $app_id,
		);
		$result = $this->CI->Apps_model->get_one('', '', $where);
		if ( ! element('app_id', $result)) {
			$this->CI->apilib->make_error("존재하지 않는 어플입니다");
		}

		$arr = array(
			'result' => 'ok',
			'token' => $token,
			'app_id' => $app_id,
			'app_package' => html_escape(element('app_package', $result)),
			'app_name' => html_escape(element('app_name', $result)),
			'app_sort' => html_escape(element('app_sort', $result)),
			'app_policy' => nl2br(html_escape(element('app_policy', $result))),
		);
		return $arr;

	}


}
