public function _remap($method) {
	$this->load->view('header');
	if(method_exists($this,$method)) {
		$this->{"{$method}"}();
	}
	$this->load->view('footer');
}
function _remap($method, $params=array()) {
	$this->lib->header();
	if(method_exists($this, $method)) { 
		$this->$method($params);
	} else {
		show_404();
	}
	$this->lib->footer();
}
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,

* 자동 필터링

/application/config/config.php
$config['global_xss_filtering'] = TRUE;

* 수동 필터링

$this->input->get(NULL, TRUE);
$this->input->post(NULL, TRUE);
$this->input->get_post(NULL, TRUE);
$this->input->server(NULL, TRUE);
$this->input->cookie(NULL, TRUE);
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,

/application/config/autoload.php

$autoload['libraies'] = array('database','seesion');
$autoload['helper'] = array('url','file');
$autoload['model'] = array();
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,

주소에서 index.php가 0번부터 순서대로 부여

$this->uri->segment(3) // http://localhost/index.php/bbs/list -> $this->uri->segment(2)는 list

<a href="bbs/list">list</a>
<a href='bbs/".$this->uri->segment(2)."'>list</a>";
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,

1. /usr/local/apache/conf/httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so // 주석해제
<Directory />
	..
	AllowOverride All // 기본값 "none" 부분을 "All"로 변경
	..
</Directory>

2. /application/config/config.php

$config['index_page'] = '' // index.php 삭제

3. html 루트 디렉토리 .htaccess

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /
	RewriteCond $1 !^(index\.php|images|captcha|robots\.txt) // 루트 밑에 js(jquery) 폴더를 생성할 경우 |  | 사이에 폴더명 추가 
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^(.*)$ /todo/index.php/$1 [L]
</IfModule>
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,
function __construct() {
	parent::__construct();
	$this->load->database();
	$this->load->model('test_model'); // $this->test_model->함수명() 사용가능
	$this->load->helper('url'); // url 헬퍼
}

* 메서드 이름에 _를 붙이면 외부에서는 로드되지 않음

블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,