사용자 도구

사이트 도구


사이드바

카테고리

webapp:mediawiki2dokuwiki

Mediawiki to dokuwiki

미디어위키 내용 덤프

미디어위키 내부의 관리 기능 중에 xml로 덤프하는 기능이 있어서, 그걸로 위키 내용을 전부를 덤프

D:\>"%path%\php.exe" dumpBackup.php --skip-header --skip-footer --current > wikidump.xml

미디어위키를 dokuwiki로 문법 변환하는 내용

php로 작성된게 있어서 다운로드 mediawiki2dokuwiki.zip

xml에서 문서 내용 추출

xml을 dokuwiki로 변환해야 하는데, 변환기는 없어서 직접 만들어야 한다.
형식이 표준이 아닌 것 같아서 잘 안읽히는거 같은데 확인해 봐야 할 것 같다.

제로보드와 계정 연동

내용설명

  • 제로보드 계정으로 도쿠위키에 로그인 되도록 할 수 있어서 두개의 계정을 연결해두었다.
  • 로그인 상태를 유지하는 것은, http://www.xpressengine.com/zb4_tip/15981669에서 다루고 있는데, 귀찮아서 일단 위치 참조만 나둔 생태로 정리
  • 원본 소스 : zbxe.class.zip

설치방법

  • zbxe.class.php 파일을 inc/auth 에 복사해서 넣는다.
  • zbxe 계정 인증을 사용하기 위해서 다음 코드를 conf/local.php 에 추가한다.
/* add to user zeroboard account */
$conf['authtype'] = 'zbxe';
$conf['auth']['zbxe']['path'] = "D:/WEBAPP/devboard/"; // 제로보드가 설치된 경로, 마지막은 '/'로 끝나야한다.
$conf['auth']['zbxe']['user'] = "devteam;user";        // 도쿠위키의 user 그룹과 같은 권한을 갖게될 zbxe의 그룹이름 
$conf['auth']['zbxe']['admin'] = "admin";              // 그룹이 여러개일때는 ';'으로 구분한다.
$conf['auth']['zbxe']['techteam'] = "devteam";         // 그룹이름이 영어만 인식하므로 주의

original code of zbxe.class.php

<?php
/**
 * ZBXE authentication backend
 * DokuWiki용 제로보드 XE 인증 모듈
 *
 * @license    Creative Commons 3.0 (원저작자 표시 조건 의무)
 * @author     Venister (Joongpil Cho) <venister@empal.com>
 */
class auth_zbxe extends auth_basic {
    var $url = array();
 
    function auth_zbxe() {
        global $conf;
 
        define('__ZBXE__', true);
 
        $config_file =  $conf['auth']['zbxe']['path']."files/config/db.config.php";
        require_once ($config_file);
 
        $this->url['path'] = $conf['auth']['zbxe']['path'];
        $this->url['db_prefix'] = $db_info->db_table_prefix;
        $this->url['host'] = $db_info->db_hostname;
        $this->url['user'] = $db_info->db_userid;
        $this->url['pass'] = $db_info->db_password;
        $this->url['database'] = $db_info->db_database;
 
        // connect to database
        $this->url['link'] = mysql_connect($this->url['host'], $this->url['user'], $this->url['pass']);
        if (!$this->url['link']) {
            msg('Cant connect to DB: ' . mysql_error());
            $this->success = false;
            return;
        }
 
        if (!mysql_select_db($this->url['database'], $this->url['link'])) {
            msg('cant connect to DB: ' . mysql_error());
            $this->success = false;
            return;
        }
        mysql_query("set names utf8");
 
        // PHP 4때문에 destructor를 명시적 선언
        register_shutdown_function("auth_zbxe_disconnect", $this);
    }
 
    // check password
    function checkPass($user, $pass) {
        $query = "select count(*) from ".$this->url['db_prefix']."_member where user_id='$user' and password=MD5('$pass')";
        $result = mysql_query($query);
        if(!$result){
            msg('query failed-1: ' . mysql_error());
            return false;
        }
        $count = mysql_result($result, 0, 0);
        return ($count == 1 ? true: false);
    }
 
   // 유저 정보를 리턴
   //
   // name : 문자열, 유저이름
   // mail : 문자열, 메일주소
   // grps : 배열, 유저의 그룹 목록
    function getUserData($user) {
        global $conf;
 
        $query = "select user_name, email_address, member_srl from ".$this->url['db_prefix']."_member where user_id='$user'";
        $result = mysql_query($query);
        if(!$result) return null;
 
        if($data = mysql_fetch_array($result)){
            $info['name'] = $data[user_name];
            $info['mail'] = $data[email_address];
            $member_srl = $data[member_srl];
        }
 
        $group_table = $this->url['db_prefix']."_member_group";
        $group_member_table = $this->url['db_prefix']."_member_group_member";
 
        $query = 
            "select g.title as title from " . $group_table . " g, " . 
            $group_member_table . " gm where g.group_srl = gm.group_srl and gm.member_srl = '$member_srl'";
        $result = mysql_query($query);
 
        if (!$result){
            msg('query failed-2: ' . mysql_error());
            return false;
        }
 
        while($data = mysql_fetch_array($result))
		{
            if(strpos($conf['auth']['zbxe']['user'], $data[title]) !== FALSE){
                $info['grps'][] = 'user';
            }
            if(strpos($conf['auth']['zbxe']['admin'], $data[title]) !== FALSE){
                $info['grps'][] = 'admin';
            }
            if(strpos($conf['auth']['zbxe']['techteam'], $data[title]) !== FALSE){
                $info['grps'][] = 'techteam';
            }
        }
        return $info;
    }
}
function auth_zbxe_disconnect($obj) {
    mysql_close($obj->url['link']);
}
?>

Create New Page 으로 페이지 생성시, 네임스페이스가 제대로 반영되지 않던 문제

  • 2009/3/17

원 제작자의 최근 소스를 받아서 업데이트함, 이후에는 정상 동작함

svn 주소

http://svn.bitflux.org/repos/public/misc/dokuwiki/plugins/npd

주소창에서 페이지 한글 이름 입력시 글자가 깨지는 문제

  • 2009/3/17

한글 언어 환경 (비유니코드언어환경인듯)에서 ie나 firefox 로 실행하면서 새 페이지 이름에 한글을 넣으면
글자가 깨져서 나오는데 utf 로 인코딩해서 보내도 제대로 되지 않는 것 같아서
받은 페이지 이름을 강제로 utf8로 변경.

이후에는 정상으로 페이지가 뜨더라

// inc/pageutils.php	
function getID($param='id',$clean=true){
  global $conf;
 
  $id = isset($_REQUEST[$param]) ? $_REQUEST[$param] : null;
 
	// convert encoding from (local language to utf8)
	$tmpstr = $id;
	// If url address enter by WebBrowser's AddressBar
	if($HTTP_REFERER == "")
	{
		if( mb_check_encoding($tmpstr, "euc-kr") == true )
		{
			$tmpstr = iconv("euc-kr", "utf-8", $tmpstr);
			//echo "<script>alert('" . 'converted' . "');</script>"; //(debug message)
		}
	}
	// echo "<script>alert('" . $tmpstr . "');</script>"; //(debug message)
	$id	= $tmpstr;
webapp/mediawiki2dokuwiki.txt · 마지막으로 수정됨: 2012/04/20 20:04 (바깥 편집)