Files

1148 lines
55 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Login class
*/
/**
* 로그인 페이지와 관련된 controller 입니다.
*/
class Install extends CI_Controller
{
/**
* 모델을 로딩합니다
*/
protected $models = array();
function __construct()
{
parent::__construct();
$this->load->helper(array('array', 'form'));
ini_set('display_errors', 0);
if (version_compare(PHP_VERSION, '5.3', '>=')) {
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
} else {
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
}
}
/**
* 인스톨 페이지입니다
*/
public function index()
{
if (config_item('install_ip') !== 'all' AND ( config_item('install_ip') === '' OR config_item('install_ip') !== $this->input->ip_address())) {
$header = array();
$header['install_step'] = 0;
$this->load->view('install/header', $header);
$this->load->view('install/step0');
$this->load->view('install/footer');
return;
}
if ($this->_check_installed()) {
alert('이미 데이터베이스에 config 테이블이 존재하여 설치를 진행하지 않습니다');
}
redirect('install/step1');
}
public function step1()
{
if (config_item('install_ip') !== 'all' AND ( config_item('install_ip') === '' OR config_item('install_ip') !== $this->input->ip_address())) {
$header = array();
$header['install_step'] = 0;
$this->load->view('install/header', $header);
$this->load->view('install/step0');
$this->load->view('install/footer');
return;
}
if ($this->_check_installed()) {
alert('이미 데이터베이스에 config 테이블이 존재하여 설치를 진행하지 않습니다');
}
$header = array();
$header['install_step'] = 1;
$this->load->view('install/header', $header);
$this->load->view('install/step1');
$this->load->view('install/footer');
}
public function step2()
{
if (config_item('install_ip') !== 'all' AND ( config_item('install_ip') === '' OR config_item('install_ip') !== $this->input->ip_address())) {
$header = array();
$header['install_step'] = 0;
$this->load->view('install/header', $header);
$this->load->view('install/step0');
$this->load->view('install/footer');
return;
}
if ($this->_check_installed()) {
alert('이미 데이터베이스에 config 테이블이 존재하여 설치를 진행하지 않습니다');
}
if ( ! $this->input->post('agree')) {
alert('약관에 동의하신 후에 설치가 가능합니다', site_url('install'));
return;
}
$view = array();
$header = array();
$message = '';
$install_avaiable = true;
$view['title1'] = 'PHP VERSION';
$phpversion = phpversion();
if (version_compare($phpversion, '5.3.0') >= 0) {
$view['content1'] = '<span class="bold color_blue">' . $phpversion . '</span>';
} else {
$view['content1'] = '<span class="bold color_red">' . $phpversion . '</span>';
$install_avaiable = false;
$message .= 'PHP Version 을 5.3.0 이상으로 업그레이드 한 후에 설치가 가능합니다<br />';
}
$view['desc1'] = 'PHP version 5.3.0 or newer is recommended.';
$view['title2'] = 'GD Support';
if (extension_loaded('gd') && function_exists('gd_info')) {
$view['content2'] = '<span class="bold color_blue">지원</span>';
} else {
$view['content2'] = '<span class="bold color_red">미지원</span>';
$install_avaiable = false;
$message .= 'GD Library 를 설치한 후에 Install 이 가능합니다<br />';
}
$view['title3'] = 'XML Support';
$xml_support = extension_loaded('xml');
if ($xml_support) {
$view['content3'] = '<span class="bold color_blue">지원</span>';
} else {
$view['content3'] = '<span class="bold color_red">미지원</span>';
$install_avaiable = false;
$message .= 'XML Library 를 설치한 후에 Install 이 가능합니다<br />';
}
$view['title4'] = 'iconv Support';
$iconv = function_exists('iconv');
if ($iconv) {
$view['content4'] = '<span class="bold color_blue">지원</span>';
} else {
$view['content4'] = '<span class="bold color_red">미지원</span>';
$install_avaiable = false;
$message .= 'Iconv Library 를 설치한 후에 Install 이 가능합니다<br />';
}
$view['title5'] = 'CURL Support';
$curl = function_exists('curl_version');
if ($curl) {
$view['content5'] = '<span class="bold color_blue">지원</span>';
} else {
$view['content5'] = '<span class="bold color_red">미지원</span>';
$install_avaiable = false;
$message .= 'CURL Extension 을 설치한 후에 Install 이 가능합니다<br />';
}
$view['title6'] = 'uploads directory';
$uploads_dir = config_item('uploads_dir');
if (is_dir($uploads_dir) === false) {
$install_avaiable = false;
$view['content6'] = '<span class="bold color_red">루트 디렉토리에 ' . config_item('uploads_dir') . ' 라는 디렉토리가 존재하지 않습니다</span>';
$message .= '루트 디렉토리에서 ' . config_item('uploads_dir') . ' 라는 디렉토리를 생성하시고 그 퍼미션을 707 로 변경해주세요<br />';
} elseif ( ! (is_readable($uploads_dir) && is_writeable($uploads_dir))) {
$install_avaiable = false;
$view['content6'] = '<span class="bold color_red">' . config_item('uploads_dir') . ' 디렉토리의 퍼미션이 올바르지 않습니다</span>';
$message .= config_item('uploads_dir') . ' 라는 디렉토리의 퍼미션을 707 로 변경해주세요<br />';
} else {
$view['content6'] = '<span class="bold color_blue"> 정상</span>';
}
$view['title7'] = 'cache directory';
$cache_dir = APPPATH . 'cache';
if (is_dir($cache_dir) === false) {
$install_avaiable = false;
$view['content7'] = '<span class="bold color_red">application 디렉토리에 cache 라는 디렉토리가 존재하지 않습니다</span>';
$message .= 'application/cache 를 생성해주시고 그 퍼미션을 707 로 변경해주세요<br />';
} elseif ( ! (is_readable($cache_dir) && is_writeable($cache_dir))) {
$install_avaiable = false;
$view['content7'] = '<span class="bold color_red">application/cache 디렉토리의 퍼미션이 올바르지 않습니다</span>';
$message .= 'application/cache 디렉토리의 퍼미션을 707 로 변경해주세요<br />';
} else {
$view['content7'] = '<span class="bold color_blue"> 정상</span>';
}
$view['title8'] = 'logs directory';
$log_dir = APPPATH . 'logs';
if (is_dir($log_dir) === false) {
$install_avaiable = false;
$view['content8'] = '<span class="bold color_red">application 디렉토리에 logs 라는 디렉토리가 존재하지 않습니다</span>';
$message .= 'application/logs 를 생성해주시고 그 퍼미션을 707 로 변경해주세요<br />';
} elseif ( ! (is_readable($log_dir) && is_writeable($log_dir))) {
$install_avaiable = false;
$view['content8'] = '<span class="bold color_red">application/logs 디렉토리의 퍼미션이 올바르지 않습니다</span>';
$message .= 'application/logs 디렉토리의 퍼미션을 707 로 변경해주세요<br />';
} else {
$view['content8'] = '<span class="bold color_blue"> 정상</span>';
}
$view['title9'] = 'migration_enabled';
$this->config->load('migration');
if (config_item('migration_enabled') === false) {
$install_avaiable = false;
$view['content9'] = '<span class="bold color_red">config[\'migration_enabled\'] 가 활성화되어있지 않습니다</span>';
$message .= 'application/config/migration.php 안에 config[\'migration_enabled\'] 의 값을 true 로 변경해주세요<br />';
} else {
$view['content9'] = '<span class="bold color_blue"> 정상</span>';
}
$view['install_avaiable'] = $install_avaiable;
$view['message'] = $message;
$header['install_step'] = 2;
$this->load->view('install/header', $header);
$this->load->view('install/step2', $view);
$this->load->view('install/footer');
}
public function step3()
{
if (config_item('install_ip') !== 'all' AND ( config_item('install_ip') === '' OR config_item('install_ip') !== $this->input->ip_address())) {
$header = array();
$header['install_step'] = 0;
$this->load->view('install/header', $header);
$this->load->view('install/step0');
$this->load->view('install/footer');
return;
}
if ($this->_check_installed()) {
alert('이미 데이터베이스에 config 테이블이 존재하여 설치를 진행하지 않습니다');
}
if ( ! $this->input->post('agree')) {
alert('약관에 동의하신 후에 설치가 가능합니다', site_url('install'));
return;
}
$view = array();
$header = array();
$message = '';
$install_avaiable = true;
$view['title1'] = 'encryption_key';
if (config_item('encryption_key')) {
$view['content1'] = '<span class="bold color_blue">설정완료</span>';
} else {
$install_avaiable = false;
$view['content1'] = '<span class="bold color_red">비어있음</span>';
$message .= 'application/config/config.php 의 &dollar;config[\'encryption_key\'] 에 내용을 입력해주세요, 현재 그 값이 비어있습니다. 한번 입력하신 값은 변경하지 말아주세요. 패스워드 암호화에 사용됩니다<br />';
}
$view['title2'] = 'base_url';
if (config_item('base_url')) {
$view['content2'] = '<span class="bold color_blue">설정완료</span>';
} else {
$install_avaiable = false;
$view['content2'] = '<span class="bold color_red">비어있음</span>';
$message .= 'application/config/config.php 의 &dollar;config[\'base_url\'] 에 현재 사이트 주소를 입력해주세요, 현재 그 값이 비어있습니다<br />';
}
$view['install_avaiable'] = $install_avaiable;
$view['message'] = $message;
$header['install_step'] = 3;
$this->load->view('install/header', $header);
$this->load->view('install/step3', $view);
$this->load->view('install/footer');
}
public function step4()
{
if (config_item('install_ip') !== 'all' AND ( config_item('install_ip') === '' OR config_item('install_ip') !== $this->input->ip_address())) {
$header = array();
$header['install_step'] = 0;
$this->load->view('install/header', $header);
$this->load->view('install/step0');
$this->load->view('install/footer');
return;
}
if ($this->_check_installed()) {
alert('이미 데이터베이스에 config 테이블이 존재하여 설치를 진행하지 않습니다');
}
if ( ! $this->input->post('agree')) {
alert('약관에 동의하신 후에 설치가 가능합니다', site_url('install'));
return;
}
$view = array();
$header = array();
$message = '';
include(APPPATH . 'config/database.php');
$install_avaiable = true;
$dbinfo = $db['default'];
$view['title2'] = 'username';
if ( ! empty($dbinfo['username'])) {
$view['content2'] = '<span class="bold color_blue">설정완료</span>';
} else {
$install_avaiable = false;
$view['content2'] = '<span class="bold color_red">비어있음</span>';
$message .= 'application/config/database.php 의 &dollar;db[\'default\'][\'username\'] 에 데이터베이스 정보를 입력해주세요<br />';
}
$view['title3'] = 'password';
if ( ! empty($dbinfo['password'])) {
$view['content3'] = '<span class="bold color_blue">설정완료</span>';
} else {
$install_avaiable = false;
$view['content3'] = '<span class="bold color_red">비어있음</span>';
$message .= 'application/config/database.php 의 &dollar;db[\'default\'][\'password\'] 에 데이터베이스 정보를 입력해주세요<br />';
}
$view['title4'] = 'database';
if ( ! empty($dbinfo['database'])) {
$view['content4'] = '<span class="bold color_blue">설정완료</span>';
} else {
$install_avaiable = false;
$view['content4'] = '<span class="bold color_red">비어있음</span>';
$message .= 'application/config/database.php 의 &dollar;db[\'default\'][\'database\'] 에 데이터베이스 정보를 입력해주세요<br />';
}
$view['title5'] = 'db connect';
$view['content5'] = '';
if ($install_avaiable) {
$database = $this->load->database($dbinfo, true);
$connected = $database->initialize();
if ($connected) {
$view['content5'] = '<span class="bold color_blue">데이터베이스 접속 성공</span>';
} else {
$install_avaiable = false;
$view['content5'] = '<span class="bold color_red">데이터베이스 접속 실패</span>';
$message .= 'application/config/database.php 의 데이터베이스 정보가 올바르게 입력되었는지 확인해주세요<br />';
}
}
$view['install_avaiable'] = $install_avaiable;
$view['message'] = $message;
$header['install_step'] = 4;
$this->load->view('install/header', $header);
$this->load->view('install/step4', $view);
$this->load->view('install/footer');
}
public function step5()
{
if (config_item('install_ip') !== 'all' AND ( config_item('install_ip') === '' OR config_item('install_ip') !== $this->input->ip_address())) {
$header = array();
$header['install_step'] = 0;
$this->load->view('install/header', $header);
$this->load->view('install/step0');
$this->load->view('install/footer');
return;
}
if ($this->_check_installed()) {
alert('이미 데이터베이스에 config 테이블이 존재하여 설치를 진행하지 않습니다');
}
if ( ! $this->input->post('agree')) {
alert('약관에 동의하신 후에 설치가 가능합니다', site_url('install'));
return;
}
$view = array();
$header = array();
$config = array();
$config['user_password'] = array(
'field' => 'user_password',
'label' => '패스워드',
'rules' => 'trim|required|min_length[4]',
);
$config['user_password_re'] = array(
'field' => 'user_password_re',
'label' => '패스워드 확인',
'rules' => 'trim|required|min_length[4]|matches[user_password]',
);
$config['user_username'] = array(
'field' => 'user_username',
'label' => '회원명',
'rules' => 'trim|required|min_length[2]|max_length[20]',
);
$config['user_email'] = array(
'field' => 'user_email',
'label' => '이메일',
'rules' => 'trim|required|valid_email|max_length[50]',
);
$form_validation = '';
if ($this->input->post('user_email')) {
$this->load->library('form_validation');
$this->form_validation->set_rules($config);
$form_validation = $this->form_validation->run();
}
$this->load->database();
if ($form_validation) {
if ($this->_create_tables() === false) {
alert('설치에 실패하였습니다', site_url('install'));
return;
}
if ($this->_migration_tables() === false) {
alert('설치에 실패하였습니다', site_url('install'));
return;
}
$this->_insert_init_data();
redirect();
} else {
$header['install_step'] = 5;
$this->load->view('install/header', $header);
$this->load->view('install/step5', $view);
$this->load->view('install/footer');
}
}
public function _check_installed()
{
include(APPPATH . 'config/database.php');
$dbinfo = $db['default'];
if (empty($dbinfo['username'])) {
return false;
}
if (empty($dbinfo['password'])) {
return false;
}
if (empty($dbinfo['database'])) {
return false;
}
$database = $this->load->database($dbinfo, true);
if (empty($database->conn_id)) {
return false;
}
$connected = $database->initialize();
if ($connected) {
$this->load->database();
if ($this->db->table_exists('config')) {
return true;
}
}
return false;
}
public function _create_tables()
{
$this->load->database();
$this->load->dbforge();
// config table
$this->dbforge->add_field(array(
'cfg_key' => array(
'type' => 'VARCHAR',
'constraint' => '100',
'default' => '',
),
'cfg_value' => array(
'type' => 'TEXT',
'null' => true,
),
));
if ($this->dbforge->create_table('config', true) === false) {
return false;
}
$this->db->query('ALTER TABLE ' . $this->db->dbprefix . 'config ADD UNIQUE KEY `cfg_key` (`cfg_key`)');
// editor_image table
$this->dbforge->add_field(array(
'eim_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
),
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'default' => '0',
),
'eim_originname' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'eim_filename' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'eim_filesize' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'default' => '0',
),
'eim_width' => array(
'type' => 'MEDIUMINT',
'constraint' => 6,
'unsigned' => true,
'default' => '0',
),
'eim_height' => array(
'type' => 'MEDIUMINT',
'constraint' => 6,
'unsigned' => true,
'default' => '0',
),
'eim_type' => array(
'type' => 'VARCHAR',
'constraint' => '10',
'default' => '',
),
'eim_datetime' => array(
'type' => 'DATETIME',
'null' => true,
),
'eim_ip' => array(
'type' => 'VARCHAR',
'constraint' => '50',
'default' => '',
),
));
$this->dbforge->add_key('eim_id', true);
$this->dbforge->add_key('user_id');
if ($this->dbforge->create_table('editor_image', true) === false) {
return false;
}
// session table
$this->dbforge->add_field(array(
'id' => array(
'type' => 'VARCHAR',
'constraint' => '40',
'default' => '',
),
'ip_address' => array(
'type' => 'VARCHAR',
'constraint' => '45',
'default' => '',
),
'timestamp' => array(
'type' => 'INT',
'constraint' => 10,
'default' => '0',
),
'data' => array(
'type' => 'BLOB',
),
));
$this->dbforge->add_key('id', true);
$this->dbforge->add_key('timestamp');
if ($this->dbforge->create_table('session', true) === false) {
return false;
}
// social table
$this->dbforge->add_field(array(
'soc_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
),
'soc_type' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'soc_account_id' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'soc_key' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'soc_value' => array(
'type' => 'TEXT',
'null' => true,
),
));
$this->dbforge->add_key('soc_id', true);
$this->dbforge->add_key('soc_account_id');
if ($this->dbforge->create_table('social', true) === false) {
return false;
}
// social_meta table
$this->dbforge->add_field(array(
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'default' => '0',
),
'smt_key' => array(
'type' => 'VARCHAR',
'constraint' => '100',
'default' => '',
),
'smt_value' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
));
$this->dbforge->add_key(array('smt_value'));
if ($this->dbforge->create_table('social_meta', true) === false) {
return false;
}
$this->db->query('ALTER TABLE ' . $this->db->dbprefix . 'social_meta ADD UNIQUE KEY `user_id_smt_key` (`user_id`, `smt_key`)');
// upload_file table
$this->dbforge->add_field(array(
'ufi_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
),
'origin_table' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'origin_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'default' => '0',
),
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'default' => '0',
),
'ufi_originname' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'ufi_filename' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'ufi_download' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'default' => '0',
),
'ufi_filesize' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'default' => '0',
),
'ufi_width' => array(
'type' => 'MEDIUMINT',
'constraint' => 6,
'unsigned' => true,
'default' => '0',
),
'ufi_height' => array(
'type' => 'MEDIUMINT',
'constraint' => 6,
'unsigned' => true,
'default' => '0',
),
'ufi_type' => array(
'type' => 'VARCHAR',
'constraint' => '10',
'default' => '',
),
'ufi_is_image' => array(
'type' => 'TINYINT',
'constraint' => 3,
'unsigned' => true,
'default' => '0',
),
'ufi_datetime' => array(
'type' => 'DATETIME',
'null' => true,
),
'ufi_ip' => array(
'type' => 'VARCHAR',
'constraint' => '50',
'default' => '',
),
));
$this->dbforge->add_key('ufi_id', true);
if ($this->dbforge->create_table('upload_file', true) === false) {
return false;
}
// user table
$this->dbforge->add_field(array(
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
),
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'default' => 0,
),
'user_email' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'user_password' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'user_username' => array(
'type' => 'VARCHAR',
'constraint' => '100',
'default' => '',
),
'user_homepage' => array(
'type' => 'TEXT',
'null' => true,
),
'user_phone' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'user_birthday' => array(
'type' => 'CHAR',
'constraint' => '10',
'default' => '',
),
'user_sex' => array(
'type' => 'TINYINT',
'constraint' => 4,
'unsigned' => true,
'default' => '0',
),
'user_zipcode' => array(
'type' => 'VARCHAR',
'constraint' => '7',
'default' => '',
),
'user_address1' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'user_address2' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'user_address3' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'user_address4' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'user_receive_email' => array(
'type' => 'TINYINT',
'constraint' => 4,
'unsigned' => true,
'default' => '0',
),
'user_denied' => array(
'type' => 'TINYINT',
'constraint' => 4,
'unsigned' => true,
'default' => '0',
),
'user_email_cert' => array(
'type' => 'TINYINT',
'constraint' => 4,
'unsigned' => true,
'default' => '0',
),
'user_register_datetime' => array(
'type' => 'DATETIME',
'null' => true,
),
'user_register_ip' => array(
'type' => 'VARCHAR',
'constraint' => '50',
'default' => '',
),
'user_lastlogin_datetime' => array(
'type' => 'DATETIME',
'null' => true,
),
'user_lastlogin_ip' => array(
'type' => 'VARCHAR',
'constraint' => '50',
'default' => '',
),
'user_is_admin' => array(
'type' => 'TINYINT',
'constraint' => 4,
'unsigned' => true,
'default' => '0',
),
'user_adminmemo' => array(
'type' => 'TEXT',
'null' => true,
),
'user_icon' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'user_photo' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
),
'user_token' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'null' => true,
),
'user_fcm_token' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'null' => true,
),
));
$this->dbforge->add_key('user_id', true);
$this->dbforge->add_key('app_id');
$this->dbforge->add_key('user_email');
$this->dbforge->add_key('user_lastlogin_datetime');
$this->dbforge->add_key('user_register_datetime');
if ($this->dbforge->create_table('user', true) === false) {
return false;
}
// user_auth_email table
$this->dbforge->add_field(array(
'uae_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
),
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'default' => '0',
),
'uae_key' => array(
'type' => 'VARCHAR',
'constraint' => '100',
'default' => '',
),
'uae_type' => array(
'type' => 'TINYINT',
'constraint' => 4,
'unsigned' => true,
'default' => '0',
),
'uae_generate_datetime' => array(
'type' => 'DATETIME',
'null' => true,
),
'uae_use_datetime' => array(
'type' => 'DATETIME',
'null' => true,
),
'uae_expired' => array(
'type' => 'TINYINT',
'constraint' => 4,
'unsigned' => true,
'default' => '0',
),
));
$this->dbforge->add_key('uae_id', true);
$this->dbforge->add_key(array('uae_key', 'user_id'));
if ($this->dbforge->create_table('user_auth_email', true) === false) {
return false;
}
// user_meta table
$this->dbforge->add_field(array(
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'default' => '0',
),
'umt_key' => array(
'type' => 'VARCHAR',
'constraint' => '100',
'default' => '',
),
'umt_value' => array(
'type' => 'TEXT',
'null' => true,
),
));
if ($this->dbforge->create_table('user_meta', true) === false) {
return false;
}
$this->db->query('ALTER TABLE ' . $this->db->dbprefix . 'user_meta ADD UNIQUE KEY `user_id_umt_key` (`user_id`, `umt_key`)');
return true;
}
public function _migration_tables()
{
$this->load->library('migration');
$this->config->load('migration');
$row = $this->db->get('migrations')->row();
$latest_version = config_item('migration_version');
if ($latest_version && ! $this->migration->version($latest_version)) {
return false;
}
return true;
}
public function _insert_init_data()
{
$this->load->library(array('user_agent', 'session'));
$this->load->model(array(
'User_model', 'User_meta_model', 'Config_model',
));
if ( ! function_exists('password_hash')) {
$this->load->helper('password');
}
$this->load->driver('cache', config_item('cache_method'));
$configdata = array(
'site_title' => '홈페이지',
'admin_logo' => 'Admin',
'webmaster_name' => '관리자',
'webmaster_email' => 'noreply@domain.com',
'spam_word' => '18아,18놈,18새끼,18년,18뇬,18노,18것,18넘,개년,개놈,개뇬,개새,개색끼,개세끼,개세이,개쉐이,개쉑,개쉽,개시키,개자식,개좆,게색기,게색끼,광뇬,뇬,눈깔,뉘미럴,니귀미,니기미,니미,도촬,되질래,뒈져라,뒈진다,디져라,디진다,디질래,병쉰,병신,뻐큐,뻑큐,뽁큐,삐리넷,새꺄,쉬발,쉬밸,쉬팔,쉽알,스패킹,스팽,시벌,시부랄,시부럴,시부리,시불,시브랄,시팍,시팔,시펄,실밸,십8,십쌔,십창,싶알,쌉년,썅놈,쌔끼,쌩쑈,썅,써벌,썩을년,쎄꺄,쎄엑,쓰바,쓰발,쓰벌,쓰팔,씨8,씨댕,씨바,씨발,씨뱅,씨봉알,씨부랄,씨부럴,씨부렁,씨부리,씨불,씨브랄,씨빠,씨빨,씨뽀랄,씨팍,씨팔,씨펄,씹,아가리,아갈이,엄창,접년,잡놈,재랄,저주글,조까,조빠,조쟁이,조지냐,조진다,조질래,존나,존니,좀물,좁년,좃,좆,좇,쥐랄,쥐롤,쥬디,지랄,지럴,지롤,지미랄,쫍빱,凸,퍽큐,뻑큐,빠큐,ㅅㅂㄹㅁ',
'white_iframe' => 'www.youtube.com
www.youtube-nocookie.com
maps.google.co.kr
maps.google.com
flvs.daum.net
player.vimeo.com
sbsplayer.sbs.co.kr
serviceapi.rmcnmv.naver.com
serviceapi.nmv.naver.com
www.mgoon.com
videofarm.daum.net
player.sbs.co.kr
sbsplayer.sbs.co.kr
www.tagstory.com
play.tagstory.com
flvr.pandora.tv',
'site_blacklist_title' => '사이트가 공사중에 있습니다',
'site_blacklist_content' => '<p>안녕하세요</p><p>블편을 드려 죄송합니다. 지금 이 사이트는 접근이 금지되어있습니다</p><p>감사합니다</p>',
'use_popup_auto_url' => '1',
'use_login_account' => 'both',
'password_length' => '4',
'use_user_photo' => '1',
'user_photo_width' => '80',
'user_photo_height' => '80',
'use_user_icon' => '1',
'user_icon_width' => '20',
'user_icon_height' => '20',
'denied_username_list' => 'admin,administrator,관리자,운영자,어드민,주인장,webmaster,웹마스터,sysop,시삽,시샵,manager,매니저,메니저,root,루트,su,guest,방문객',
'change_password_date' => '180',
'max_login_try_count' => '5',
'max_login_try_limit_second' => '30',
'send_email_register_admin_title' => '[회원가입알림] {회원명}님이 회원가입하셨습니다',
'send_email_register_admin_content' => '<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">{홈페이지명}</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 관리자님,</span><br /></td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>안녕하세요,</p><p>{회원명} 님이 회원가입 하셨습니다.</p><p>회원명 : {회원명}</p><p>이메일 : {회원이메일}</p><p>가입한 곳 IP : {회원아이피}</p><p>감사합니다.</p></td></tr></table>',
'send_email_register_user_title' => '[{홈페이지명}] {회원명}님의 회원가입을 축하드립니다',
'send_email_register_user_content' => '<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">{홈페이지명}</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 {회원명}님,</span><br />회원가입을 축하드립니다.</td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>안녕하세요 {회원명} 회원님,</p><p>회원가입을 축하드립니다.</p><p>{홈페이지명} 회원으로 가입해주셔서 감사합니다.</p><p>더욱 편리한 서비스를 제공하기 위해 항상 최선을 다하겠습니다.</p><p>&nbsp;</p><p>감사합니다.</p></td></tr></table>',
'send_email_register_user_verifytitle' => '[{홈페이지명}] {회원명}님의 회원가입을 축하드립니다',
'send_email_register_user_verifycontent' => '<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">{홈페이지명}</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 {회원명}님,</span><br />회원가입을 축하드립니다.</td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>안녕하세요 {회원명} 회원님,</p><p>회원가입을 축하드립니다.</p><p>{홈페이지명} 회원으로 가입해주셔서 감사합니다.</p><p>더욱 편리한 서비스를 제공하기 위해 항상 최선을 다하겠습니다.</p><p>&nbsp;</p><p>아래 링크를 클릭하시면 회원가입이 완료됩니다.</p><p><a href="{메일인증주소}" target="_blank" style="font-weight:bold;">메일인증 받기</a></p><p>&nbsp;</p><p>감사합니다.</p></td></tr></table>',
'send_email_changepw_admin_title' => '{회원명}님이 패스워드를 변경하셨습니다',
'send_email_changepw_admin_content' => '<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">{홈페이지명}</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 관리자님,</span><br /></td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>안녕하세요,</p><p>{회원명} 님이 패스워드를 변경하셨습니다.</p><p>회원아이디 : {회원아이디}</p><p>회원명 : {회원명}</p><p>이메일 : {회원이메일}</p><p>변경한 곳 IP : {회원아이피}</p><p>감사합니다.</p></td></tr></table>',
'send_email_changepw_user_title' => '[{홈페이지명}] 패스워드가 변경되었습니다',
'send_email_changepw_user_content' => '<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">{홈페이지명}</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 {회원명}님,</span><br />회원님의 패스워드가 변경되었습니다.</td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>안녕하세요 {회원명} 회원님,</p><p>회원님의 패스워드가 변경되었습니다.</p><p>변경한 곳 IP : {회원아이피}</p><p>더욱 편리한 서비스를 제공하기 위해 항상 최선을 다하겠습니다.</p><p>&nbsp;</p><p>감사합니다.</p></td></tr></table>',
'send_email_userleave_admin_title' => '{회원명}님이 회원탈퇴하셨습니다',
'send_email_userleave_admin_content' => '<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">{홈페이지명}</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 관리자님,</span><br /></td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>안녕하세요,</p><p>{회원명} 님이 회원탈퇴하셨습니다.</p><p>회원아이디 : {회원아이디}</p><p>회원명 : {회원명}</p><p>이메일 : {회원이메일}</p><p>탈퇴한 곳 IP : {회원아이피}</p><p>감사합니다.</p></td></tr></table>',
'send_email_userleave_user_title' => '[{홈페이지명}] 회원탈퇴가 완료되었습니다',
'send_email_userleave_user_content' => '<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">{홈페이지명}</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 {회원명}님,</span><br />회원님의 탈퇴가 처리되었습니다.</td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>안녕하세요 {회원명} 회원님,</p><p>그 동안 {홈페이지명} 이용을 해주셔서 감사드립니다</p><p>요청하신대로 회원님의 탈퇴가 정상적으로 처리되었습니다.</p><p>더욱 편리한 서비스를 제공하기 위해 항상 최선을 다하겠습니다.</p><p>&nbsp;</p><p>감사합니다.</p></td></tr></table>',
'send_email_changeemail_user_title' => '[{홈페이지명}] 회원님의 이메일정보가 변경되었습니다',
'send_email_changeemail_user_content' => '<table width="100%" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">{홈페이지명}</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 {회원명}님,</span><br />회원님의 이메일 주소가 변경되어 알려드립니다.</td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>안녕하세요,</p><p>회원님의 이메일 주소가 변경되었으므로 다시 인증을 받아주시기 바랍니다.</p><p>&nbsp;</p><p>아래 링크를 클릭하시면 주소변경 인증이 완료됩니다.</p><p><a href="{메일인증주소}" target="_blank" style="font-weight:bold;">메일인증 받기</a></p><p>&nbsp;</p><p>감사합니다.</p></td></tr></table>',
'send_email_findaccount_user_title' => '{회원명}님의 아이디와 패스워드를 보내드립니다',
'send_email_findaccount_user_content' => '<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">{홈페이지명}</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 {회원명}님,</span><br />회원님의 아이디와 패스워드를 보내드립니다.</td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>안녕하세요,</p><p>&nbsp;</p><p>회원님의 아이디는 <strong>{회원아이디}</strong> 입니다.</p><p>아래 링크를 클릭하시면 회원님의 패스워드 변경이 가능합니다.</p><p><a href="{패스워드변경주소}" target="_blank" style="font-weight:bold;">패스워드 변경하기</a></p><p>&nbsp;</p><p>감사합니다.</p></td></tr></table>',
'send_email_resendverify_user_title' => '{회원명}님의 인증메일이 재발송되었습니다',
'send_email_resendverify_user_content' => '<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">{홈페이지명}</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 {회원명}님,</span><br />회원님의 인증메일을 다시 보내드립니다..</td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>안녕하세요,</p><p>&nbsp;</p><p>아래 링크를 클릭하시면 이메일 인증이 완료됩니다.</p><p><a href="{메일인증주소}" target="_blank" style="font-weight:bold;">메일인증 받기</a></p><p>&nbsp;</p><p>감사합니다.</p></td></tr></table>',
);
$registerform = array(
'user_email' => array(
'field_name' => 'user_email',
'func' => 'basic',
'display_name' => '이메일주소',
'field_type' => 'email',
'use' => '1',
'open' => '',
'required' => '1',
),
'user_password' => array(
'field_name' => 'user_password',
'func' => 'basic',
'display_name' => '비밀번호',
'field_type' => 'password',
'use' => '1',
'open' => '',
'required' => '1',
),
'user_username' => array(
'field_name' => 'user_username',
'func' => 'basic',
'display_name' => '이름',
'field_type' => 'text',
'use' => '1',
'open' => '1',
'required' => '1',
),
'user_homepage' => array(
'field_name' => 'user_homepage',
'func' => 'basic',
'display_name' => '홈페이지',
'field_type' => 'url',
'use' => '',
'open' => '1',
'required' => '',
),
'user_phone' => array(
'field_name' => 'user_phone',
'func' => 'basic',
'display_name' => '전화번호',
'field_type' => 'phone',
'use' => '',
'open' => '',
'required' => '',
),
'user_birthday' => array(
'field_name' => 'user_birthday',
'func' => 'basic',
'display_name' => '생년월일',
'field_type' => 'date',
'use' => '',
'open' => '',
'required' => '',
),
'user_sex' => array(
'field_name' => 'user_sex',
'func' => 'basic',
'display_name' => '성별',
'field_type' => 'radio',
'use' => '',
'open' => '',
'required' => '',
),
'user_address' => array(
'field_name' => 'user_address',
'func' => 'basic',
'display_name' => '주소',
'field_type' => 'address',
'use' => '',
'open' => '',
'required' => '',
),
);
$configdata['registerform'] = json_encode($registerform);
$this->cache->delete('config-model-get');
$this->cache->clean();
$this->Config_model->save($configdata);
$hash = password_hash($this->input->post('user_password'), PASSWORD_BCRYPT);
$insertdata = array(
'user_email' => $this->input->post('user_email'),
'user_password' => $hash,
'user_username' => $this->input->post('user_username'),
'user_receive_email' => 1,
'user_email_cert' => 1,
'user_register_datetime' => cdate('Y-m-d H:i:s'),
'user_register_ip' => $this->input->ip_address(),
'user_lastlogin_datetime' => cdate('Y-m-d H:i:s'),
'user_lastlogin_ip' => $this->input->ip_address(),
'user_is_admin' => 1,
);
$user_id = $this->User_model->insert($insertdata);
$usermeta = array(
'meta_change_pw_datetime' => cdate('Y-m-d H:i:s'),
'meta_email_cert_datetime' => cdate('Y-m-d H:i:s'),
'meta_username_datetime' => cdate('Y-m-d H:i:s'),
);
$this->User_meta_model->save($user_id, $usermeta);
$this->load->library(array('user_agent', 'session'));
$this->load->model(array(
'Config_model'
));
if ( ! function_exists('password_hash')) {
$this->load->helper('password');
}
$this->load->driver('cache', config_item('cache_method'));
$this->session->set_userdata(
'user_id',
$user_id
);
}
}