git-svn-id: http://xe-core.googlecode.com/svn/trunk@2 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-02-06 15:11:13 +00:00
parent 2569c554ce
commit c040d4d713
317 changed files with 14496 additions and 0 deletions

View file

@ -0,0 +1,264 @@
<?php
/**
* @file : modules/install/install.module.php
* @author : zero <zero@nzeo.com>
* @desc : 기본 모듈중의 하나인 install module
* Module class에서 상속을 받아서 사용
* action 경우 disp/proc 2가지만 존재하며 이는 action명세서에
* 미리 기록을 하여야
**/
class install extends Module {
/**
* 모듈의 정보
**/
var $cur_version = "20070130_0.01";
/**
* 기본 action 지정
* $act값이 없거나 잘못된 값이 들어올 경우 $default_act 값으로 진행
**/
var $default_act = 'dispIntroduce';
/**
* 현재 모듈의 초기화를 위한 작업을 지정해 놓은 method
* css/js파일의 load라든지 lang파일 load등을 미리 선언
*
* Init() => 공통
* dispInit() => disp시에
* procInit() => proc시에
*
* $this->module_path는 현재 모듈파일의 위치를 나타낸다
* (ex: $this->module_path = "./modules/install/";
**/
// 초기화
function init() {/*{{{*/
Context::loadLang($this->module_path.'lang');
// 설치시 필수항목 검사
$this->checkInstallEnv();
if(Context::get('install_enable')) $this->makeDefaultDirectory();
}/*}}}*/
// disp 초기화
function dispInit() {/*{{{*/
// 설치가 가능하면 기본 디렉토리등을 만듬
if(!Context::get('install_enable')) {
$this->act = 'dispIntroduce';
}
return true;
}/*}}}*/
// proc 초기화
function procInit() {/*{{{*/
// 설치가 불가능한 환경인데 요청이 오면 에러 표시
if(!Context::get('install_enable')) return $this->doError('msg_already_installed');
return true;
}/*}}}*/
/**
* 여기서부터는 action의 구현
* request parameter의 경우 method의 첫번째 인자로 넘어온다
*
* dispXXXX : 출력을 위한 method, output에 tpl file이 지정되어야 한다
* procXXXX : 처리를 위한 method, output에는 error, message가 지정되어야 한다
*
* 변수의 사용은 Context::get('이름')으로 얻어오면 된다
**/
function dispIntroduce() {/*{{{*/
// disp_license.html 파일 출력
$this->setTemplateFile('disp_license');
}/*}}}*/
function dispDBInfoForm() {/*{{{*/
// db_type이 지정되지 않았다면 다시 초기화면 출력
if(!Context::get('db_type')) return $this->dispIntroduce();
// disp_db_info_form.html 파일 출력
$tpl_filename = sprintf('db_form.%s.html', Context::get('db_type'));
$this->setTemplateFile($tpl_filename);
}/*}}}*/
function procInstall() {/*{{{*/
// 설치가 되어 있는지에 대한 체크
if(Context::isInstalled()) {
return $this->doError('msg_already_installed');
}
// DB와 관련된 변수를 받음
$db_info = Context::gets('db_type','db_hostname','db_userid','db_password','db_database','db_table_prefix');
// DB의 타입과 정보를 등록
Context::setDBInfo($db_info);
// DB Instance 생성
$oDB = &DB::getInstance();
// DB접속이 가능한지 체크
if(!$oDB->isConnected()) {
return $this->doError('msg_dbconnect_failed');
}
// 모든 모듈의 테이블 생성
$output = $this->makeTable();
if(!$output->toBool()) return $output;
// 관리자 정보 입력 (member 모듈을 찾아서 method 실행)
$oMember = getModule('member');
// 그룹을 입력
$group_args->title = Context::getLang('default_group_1');
$group_args->is_default = 'Y';
$oMember->insertGroup($group_args);
$group_args->title = Context::getLang('default_group_2');
$group_args->is_default = 'N';
$oMember->insertGroup($group_args);
// 금지 아이디 등록
$oMember->insertDeniedID('www','');
$oMember->insertDeniedID('root','');
$oMember->insertDeniedID('admin','');
$oMember->insertDeniedID('administrator','');
$oMember->insertDeniedID('ftp','');
$oMember->insertDeniedID('http','');
// 관리자 정보 세팅
$admin_info = Context::gets('user_id','password','nick_name','user_name', 'email_address');
// 관리자 정보 입력
$oMember->insertAdmin($admin_info);
// 로그인 처리시킴
$oMember->doLogin($admin_info->user_id, $admin_info->password);
// 기본 모듈을 생성
$oModule = getModule('module_manager');
$oModule->makeDefaultModule();
// config 파일 생성
if(!$this->makeConfigFile()) return $this->doError('msg_install_failed');
// 설치 완료 메세지 출력
$this->setMessage('msg_install_completed');
}/*}}}*/
/**
* 여기부터는 모듈과 관련된 라이브러리 개념의 method들
**/
// public void checkInstallEnv()/*{{{*/
// 기본적으로 필수적인 체크항목들을 검사하여 Context에 바로 넣어버림..
function checkInstallEnv() {
// 각 필요한 항목 체크
$checklist = array();
// 1. permission 체크
if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true;
else $checklist['permission'] = false;
// 2. xml_parser_create함수 유무 체크
if(function_exists('xml_parser_create')) $checklist['xml'] = true;
else $checklist['xml'] = false;
// 3. ini_get(session.auto_start)==1 체크
if(ini_get(session.auto_start)!=1) $checklist['session'] = true;
else $checklist['session'] = false;
// 4. iconv 체크
if(function_exists('iconv')) $checklist['iconv'] = true;
else $checklist['iconv'] = false;
// 5. gd 체크 (imagecreatefromgif함수)
if(function_exists('imagecreatefromgif')) $checklist['gd'] = true;
else $checklist['gd'] = false;
// 6. mysql_get_client_info() 체크
if(mysql_get_client_info() < "4.1.00") $checklist['mysql'] = false;
else $checklist['mysql'] = true;
if(!$checklist['permission'] || !$checklist['xml'] || !$checklist['session']) $install_enable = false;
else $install_enable = true;
// 체크 결과를 Context에 저장
Context::set('install_enable', $install_enable);
Context::set('checklist', $checklist);
}/*}}}*/
// public void makeDefaultDirectory()/*{{{*/
// files 및 하위 디렉토리 생성
function makeDefaultDirectory() {
$directory_list = array(
'./files',
'./files/modules',
'./files/plugins',
'./files/addons',
'./files/layouts',
'./files/queries',
'./files/schemas',
'./files/js_filter_compiled',
'./files/template_compiled',
'./files/config',
'./files/attach',
'./files/attach/images',
'./files/attach/binaries',
);
foreach($directory_list as $dir) {
if(is_dir($dir)) continue;
@mkdir($dir, 0707);
@chmod($dir, 0707);
}
}/*}}}*/
// public void makeTable()/*{{{*/
// 모든 모듈의 테이블 생성 schema를 찾아서 생성
function makeTable() {
// db instance생성
$oDB = &DB::getInstance();
// 각 모듈의 schemas/*.xml 파일을 모두 찾아서 table 생성
$module_list_1 = FileHandler::readDir('./modules/', NULL, false, true);
$module_list_2 = FileHandler::readDir('./files/modules/', NULL, false, true);
$module_list = array_merge($module_list_1, $module_list_2);
foreach($module_list as $module_path) {
$schema_dir = sprintf('%s/schemas/', $module_path);
$schema_files = FileHandler::readDir($schema_dir, NULL, false, true);
$file_cnt = count($schema_files);
if(!$file_cnt) continue;
for($i=0;$i<$file_cnt;$i++) {
$file = trim($schema_files[$i]);
if(!$file || substr($file,-4)!='.xml') continue;
$output = $oDB->createTableByXmlFile($file);
if($oDB->isError()) return $oDB->getError();
}
}
return new Output();
}/*}}}*/
// public boolean makeConfigFile() /*{{{*/
// config 파일을 생성
function makeConfigFile() {
$config_file = Context::getConfigFile();
if(file_exists($config_file)) return;
$db_info = Context::getDbInfo();
if(!$db_info) return;
$buff = '<?php if(!__ZB5__) exit();'."\n";
foreach($db_info as $key => $val) {
$buff .= sprintf("\$db_info->%s = \"%s\";\n", $key, $val);
}
$buff .= "?>";
FileHandler::writeFile($config_file, $buff);
if(@file_exists($config_file)) return true;
return false;
}/*}}}*/
}
?>

View file

@ -0,0 +1,65 @@
<?php
/**
* @file : modules/install/lang/ko.lang.php
* @author : zero <zero@nzeo.com>
* @desc : 한국어 언어팩 (기본적인 내용만 수록)
**/
$lang->introduce_title = '제로보드5 설치';
$lang->introduce =
"제로보드5를 사용해주셔서 감사합니다.\n".
"제로보드5는 GPL라이센스를 따르며 블라블라..\n";
$lang->install_condition_title = "설치 조건";
$lang->install_checklist_title = array(
'permission' => '퍼미션',
'xml' => 'XML 라이브러리',
'iconv' => 'ICONV 라이브러리',
'gd' => 'GD 라이브러리',
'session' => 'Session.auto_start 설정',
'mysql' => 'MySQL 버전',
);
$lang->install_checklist_desc = array(
'permission' => '[필수] 제로보드의 설치 경로 또는 ./files 디렉토리의 퍼미션이 707이어야 합니다',
'xml' => '[필수] XML통신을 위하여 XML 라이브러리가 필요합니다',
'session' => '[필수] 제로보드에서 세션 사용을 위해 php.ini 설정의 session.auto_start=0 이어야 합니다',
'iconv' => 'UTF-8과 다른 언어셋의 변환을 위한 iconv설치가 필요합니다',
'gd' => '이미지변환 기능을 사용하기 위해 GD라이브러리가 설치되어 있어야 합니다',
'mysql' => 'UTF-8 언어셋 사용을 위해 mysql버전이 4.1 이상이어야 합니다',
);
$lang->install_checklist_xml = 'XML라이브러리 설치';
$lang->install_without_xml = 'xml 라이브러리가 설치되어 있지 않습니다';
$lang->install_checklist_gd = 'GD라이브러리 설치';
$lang->install_without_gd = '이미지 변환을 위한 gd 라이브러리가 설치되어 있지 않습니다';
$lang->install_checklist_gd = 'GD라이브러리 설치';
$lang->install_without_iconv = '문자열을 처리하기 위한 iconv 라이브러리가 설치되어 있지 않습니다';
$lang->install_mysql_version = 'mysql client version이 4.1 이하라서 문제가 발생할 수 있습니다';
$lang->install_session_auto_start = 'php설정의 session.auto_start==1 이라 세션 처리에 문제가 발생할 수 있습니다';
$lang->install_permission_denied = '설치대상 디렉토리의 퍼미션이 707이 아닙니다';
$lang->cmd_install_fix_checklist = '필수 조건을 만족시켰습니다.';
$lang->cmd_install_next = '설치를 진행합니다';
$lang->db_title = 'DB정보 입력';
$lang->db_type = 'DB 종류';
$lang->db_hostname = 'DB 호스트네임';
$lang->db_userid = 'DB 아이디';
$lang->db_password = 'DB 비밀번호';
$lang->db_database = 'DB 데이터베이스';
$lang->db_table_prefix = '테이블 머릿말';
$lang->admin_title = '관리자정보';
$lang->default_group_1 = "준회원";
$lang->default_group_2 = "정회원";
$lang->msg_cannot_proc = '설치 환경이 갖춰지지 않아 요청을 실행할 수가 없습니다';
$lang->msg_already_installed = '이미 설치가 되어 있습니다';
$lang->msg_dbconnect_failed = "DB접속 오류가 발생하였습니다.\nDB정보를 다시 확인해주세요";
$lang->msg_table_is_exists = "이미 DB에 테이블이 생성되어 있습니다.\nconfig파일을 재생성하였습니다";
$lang->msg_install_completed = "설치가 완료되었습니다.\n감사합니다";
$lang->msg_install_failed = "설치 파일 생성시에 오류가 발생하였습니다.";
?>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<module version="0.1">
<title xml:lang="ko">설치관리</title>
<title xml:lang="en">install</title>
<author email_address="zero@zeroboard.com" link="http://www.zeroboard.com" date="2007. 2. 28">
<name xml:lang="ko">제로</name>
<name xml:lang="en">zero</name>
<description xml:lang="ko">설치 관리 모듈</description>
<description xml:lang="en">install</description>
</author>
<module>

View file

@ -0,0 +1,3 @@
<table name="sequence">
<column name="seq" type="number" size="1" notnull="notnull" primary_key="primary_key" auto_increment="auto_increment" />
</table>

View file

@ -0,0 +1,92 @@
<!--%import("css/install.css")-->
<!--%import("js/install.js")-->
<!--%import("filter/filter.mysql_form.xml")-->
<form action="./" method="post" onsubmit="return procFormFilter(this, install_filter, procInstall)">
<input type="hidden" name="mid" value="system_install" />
<input type="hidden" name="act" value="procInstall" />
<input type="hidden" name="db_type" value="{$db_type}" />
<table border="1">
<tr>
<td colspan="2">
{$lang->db_title}
</td>
</tr>
<tr>
<td>{$lang->db_hostname}</td>
<td>
<input type="text" name="db_hostname" value="127.0.0.1" />
</td>
</tr>
<tr>
<td>{$lang->db_userid}</td>
<td>
<input type="text" name="db_userid" value="dev" />
</td>
</tr>
<tr>
<td>{$lang->db_password}</td>
<td>
<input type="password" name="db_password" value="dev" />
</td>
</tr>
<tr>
<td>{$lang->db_database}</td>
<td>
<input type="text" name="db_database" value="dev" />
</td>
</tr>
<tr>
<td>{$lang->db_table_prefix}</td>
<td>
<input type="text" name="db_table_prefix" value="zb" />
</td>
</tr>
</table>
<table border="1">
<tr>
<td colspan="2">
{$lang->admin_title}
</td>
</tr>
<tr>
<td>{$lang->user_id}</td>
<td>
<input type="text" name="user_id" value="zero" />
</td>
</tr>
<tr>
<td>{$lang->password1}</td>
<td>
<input type="password" name="password1" value="1234" />
</td>
</tr>
<tr>
<td>{$lang->password2}</td>
<td>
<input type="password" name="password2" value="1234" />
</td>
</tr>
<tr>
<td>{$lang->user_name}</td>
<td>
<input type="text" name="user_name" value="zero" />
</td>
</tr>
<tr>
<td>{$lang->nick_name}</td>
<td>
<input type="text" name="nick_name" value="zero" />
</td>
</tr>
<tr>
<td>{$lang->email_address}</td>
<td>
<input type="text" name="email_address" value="zero@nzeo.com" />
</td>
</tr>
</table>
<input type="submit" value="{$lang->cmd_registration}" />
</form>

View file

@ -0,0 +1,48 @@
<!--%import("css/install.css")-->
<!--%import("js/install.js")-->
<table border="1">
<tr>
<td colspan="2">{$lang->introduce_title}</td>
</tr>
<tr>
<td>
{nl2br($lang->introduce)}
</td>
</tr>
</table>
<table border="1">
<tr>
<td colspan="2">{$lang->install_condition_title}</td>
</tr>
<!--@foreach($checklist as $key => $val)-->
<tr>
<td rowspan="2">{$lang->install_checklist_title[$key]}</td>
<td><!--@if($val)-->{$lang->enable}<!--@else-->{$lang->disable}<!--@end--></td>
</tr>
<tr>
<td>{$lang->install_checklist_desc[$key]}</td>
</tr>
<!--@end-->
</table>
<!--@if($install_enable)-->
<form method="get" action="./">
<input type="hidden" name="act" value="dispDBInfoForm" />
<table border="1">
<tr>
<td>{$lang->db_type}</td>
<td>
<select name="db_type">
<!--@foreach(DB::getSupportedList() as $_key => $_db_name)-->
<option value="{$_db_name}">{$_db_name}</option>
<!--@end-->
</select>
</td>
<td><input type="submit" value="{$lang->cmd_install_next}" /></td>
</tr>
</table>
</form>
<!--@else-->
<a href="./">{$lang->cmd_install_fix_checklist}</a>
<!--@end-->

View file

@ -0,0 +1,35 @@
<filter id='install_filter'>
<field>
<item target="db_type" required="true" />
<item target="db_hostname" required="true" minlength="1" maxlength="250" />
<item target="db_userid" required="true" minlength="1" maxlength="250"/>
<item target="db_password" required="true" minlength="1" maxlength="250" />
<item target="db_database" required="true" minlength="1" maxlength="250" />
<item target="db_table_prefix" required="true" minlength="2" maxlength="20" filter="alpha"/>
<item target="user_id" required="true" minlength="3" maxlength="20" filter="alpha,userid" />
<item target="password1" required="true" minlength="1" maxlength="20" />
<item target="password2" required="true" equalto="password1" minlength="1" maxlegnth="20" />
<item target="user_name" required="true" minlength="3" maxlength="20" />
<item target="nick_name" required="true" minlength="3" maxlength="20" />
<item target="email_address" required="true" minlength="1" maxlength="200" filter="email"/>
</field>
<parameter>
<item param="mid" target="mid" />
<item param="act" target="act" />
<item param="db_type" target="db_type" />
<item param="db_hostname" target="db_hostname" />
<item param="db_userid" target="db_userid" />
<item param="db_password" target="db_password" />
<item param="db_database" target="db_database" />
<item param="db_table_prefix" target="db_table_prefix" />
<item param="user_id" target="user_id" />
<item param="password" target="password1" />
<item param="user_name" target="user_name" />
<item param="nick_name" target="nick_name" />
<item param="email_address" target="email_address" />
</parameter>
<response>
<item name="error" />
<item name="message" />
</response>
</filter>

View file

@ -0,0 +1,6 @@
function procInstall(ret_obj, response_tags) {
var error = ret_obj['error'];
var message = ret_obj['message'];
alert(message);
location.href = "./";
}