입력 (input) Sample

<?php
/**
 * Input Class
 *
 * Created on 2011. 11. 16.
 * @author 불의회상 <hoksi2k@hanmail.net>
 * @package library
 * @subpackage controllers
 * @version 1.0
 */
class Input_lib extends CI_Controller {
	function __construct() {
		parent::__construct();
		
		$this->load->helper('url');
	}
	
	function index() {
		// Cookie 설정
		if($this->input->post('cookie_test')) {
			$this->input->set_cookie('test', $this->input->post('cookie_test'), 60);
			redirect('input_lib');
		}
		
		// $_POST 데이타 가져오기
		$data['post'] = $this->input->post();
		$data['post_xss'] = $this->input->post(NULL, TRUE);
		$data['post_test'] = $this->input->post('test');
		$data['post_test_xss'] = $this->input->post('test', TRUE);
		
		// $_GET 데이타 가져오기
		$data['get'] = $this->input->get();
		$data['get_xss'] = $this->input->get(NULL, TRUE);
		$data['get_test'] = $this->input->get('test');
		$data['get_test_xss'] = $this->input->get('test', TRUE);
		
		// $this->input->get_post()
		$data['get_post_test'] = $this->input->get_post('test');
		$data['get_post_test_xss'] = $this->input->get_post('test', TRUE);
		
		// $this->input->cookie()
		$data['cookie_test'] = $this->input->cookie('test');
		$data['cookie_test_xss'] = $this->input->cookie('test', TRUE);
		
		$this->load->view('input_lib_sample', $data);
	}
}
<?php $this->load->view('inc/header')?>

<table class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
  <th style="text-align:center" width="20%">구분</th>
  <th width="80%">질의</th>
</tr>
</thead>
<form method="post" action="<?=site_url('input_lib')?>">
<tr>
	<td>POST</td>
	<td>
		<input type="test" name="post_test" value="<b style='color:blue'>POST</b><script>var i=0;</script>" />
		<input type="test" name="test" value="<b style='color:blue'>POST test</b><script>var i=0;</script>" />
		<input type="submit" value="전송" />
	</td>
</tr>
</form>
<form method="get" action="<?=site_url('input_lib')?>">
<tr>
	<td>GET</td>
	<td>
		<input type="test" name="get_test" value="<b style='color:blue'>GET</b><script>var i=0;</script>" />
		<input type="test" name="test" value="<b style='color:blue'>GET test</b><script>var i=0;</script>" />
		<input type="submit" value="전송" />
	</td>
</tr>
</form>
<form method="post" action="<?=site_url('input_lib')?>">
<tr>
	<td>Set Cookie</td>
	<td>
		<input type="test" name="cookie_test" size="20" value="<b style='color:blue'>Cookie(<?php echo date('YmdHis')?>)</b><script>var i=0;</script>" />
		<input type="submit" value="전송" />
	</td>
</tr>
</form>
<thead>
<tr>
  <th style="text-align:center" colspan="2">POST</th>
</tr>
</thead>
<tr>
  <td>$this->input->post()</td>
  <td><xmp><?php print_r($post)?></xmp></td>
</tr>
<tr>
  <td>$this->input->post(NULL, TRUE)</td>
  <td><xmp><?php print_r($post_xss)?></xmp></td>
</tr>
<tr>
  <td>$this->input->post('test')</td>
  <td><xmp><?php echo $post_test?></xmp></td>
</tr>
<tr>
  <td>$this->input->post('test', TRUE)</td>
  <td><xmp><?php echo $post_test_xss?></xmp></td>
</tr>
<thead>
<tr>
  <th style="text-align:center" colspan="2">GET</th>
</tr>
</thead>
<tr>
  <td>$this->input->get()</td>
  <td><xmp><?php print_r($get)?></xmp></td>
</tr>
<tr>
  <td>$this->input->get(NULL, TRUE)</td>
  <td><xmp><?php print_r($get_xss)?></xmp></td>
</tr>
<tr>
  <td>$this->input->get('test')</td>
  <td><xmp><?php echo $get_test?></xmp></td>
</tr>
<tr>
  <td>$this->input->get('test', TRUE)</td>
  <td><xmp><?php echo $get_test_xss?></xmp></td>
</tr>
<thead>
<tr>
  <th style="text-align:center" colspan="2">GET, POST</th>
</tr>
</thead>
<tr>
  <td>$this->input->get_post('test')</td>
  <td><xmp><?php echo $get_post_test?></xmp></td>
</tr>
<tr>
  <td>$this->input->get_post('test', TRUE)</td>
  <td><xmp><?php echo $get_post_test_xss?></xmp></td>
</tr>
<thead>
<tr>
  <th style="text-align:center" colspan="2">COOKIE</th>
</tr>
</thead>
<tr>
  <td>$this->input->cookie('test')</td>
  <td><xmp><?php echo $cookie_test?></xmp></td>
</tr>
<tr>
  <td>$this->input->cookie('test', TRUE)</td>
  <td><xmp><?php echo $cookie_test_xss?></xmp></td>
</tr>
<thead>
<tr>
  <th style="text-align:center" colspan="2">SERVER</th>
</tr>
</thead>
<tr>
  <td>$this->input->server('HTTP_HOST')</td>
  <td><?php echo $this->input->server('HTTP_HOST')?></pre></td>
</tr>
<thead>
<tr>
  <th style="text-align:center" colspan="2">REQUEST_HEADER</th>
</tr>
</thead>
<tr>
  <td>$this->input->request_headers()</td>
  <td><pre><?php print_r($this->input->request_headers())?></pre></td>
</tr>
<tr>
  <td>$this->input->get_request_header('Host')</td>
  <td><?php echo $this->input->get_request_header('Host')?></pre></td>
</tr>
<thead>
<tr>
  <th style="text-align:center" colspan="2">ETC</th>
</tr>
</thead>
<tr>
  <td>$this->input->ip_address()</td>
  <td><?php echo $this->input->ip_address()?></td>
</tr>
<tr>
  <td>$this->input->user_agent()</td>
  <td><?php echo $this->input->user_agent()?></td>
</tr>
<tr>
  <td>$this->input->valid_ip('168.126.63.1')</td>
  <td><?php echo $this->input->valid_ip('168.126.63.1') ? 'TRUE' : 'FALSE'?></td>
</tr>
<tr>
  <td>$this->input->is_ajax_request()</td>
  <td><?php echo $this->input->is_ajax_request() ? 'TRUE' : 'FALSE'?></td>
</tr>
<tr>
  <td>$this->input->is_cli_request()</td>
  <td><?php echo $this->input->is_cli_request() ? 'TRUE' : 'FALSE'?></td>
</tr>
</table>

<?php $this->load->view('inc/footer')?>

© Copyright by hoksi(Page rendered in 0.0063 seconds)