/** * * 문서 등록/수정 시 처리 * * @param array $params {@link NarinEvent} 에서 전달하는 파라미터 */ public function on_write_head($params) { $wr_content = $params['write']['wr_content']; $member = $this->member; $setting = $this->plugin_info->getPluginSetting(); $allow_level = $setting['allow_level']['value']; $allow_iframe_level = $setting['allow_iframe_level']['value']; $allow_script_level = $setting['allow_script_level']['value']; if($allow_level > $member['mb_level']) { if(preg_match("/<html>/i", $wr_content)) { $wikiControl =& wiki_class_load("Control"); $wikiControl->error("권한 없음", "접근할 수 없는 내용을 가지고 있습니다. (html)"); } } if($allow_iframe_level > $member['mb_level']) { if(preg_match("/<iframe([^\>]*)/i", $wr_content)) { $wikiControl =& wiki_class_load("Control"); $wikiControl->error("권한 없음", "접근할 수 없는 내용을 가지고 있습니다. (iframe)"); } } if($allow_script_level > $member['mb_level']) { if(preg_match("/<script([^\>]*)/i", $wr_content)) { $wikiControl =& wiki_class_load("Control"); $wikiControl->error("권한 없음", "접근할 수 없는 내용을 가지고 있습니다. (script)"); exit; } } }
/** * * 문서 등록/수정 시 처리 * * @param array $params {@link NarinEvent} 에서 전달하는 파라미터 */ public function on_write_update_tail($params) { $wr_id = $params['wr_id']; $wr_content = $params['write']['wr_content']; $member = $this->member; $setting = $this->plugin_info->getPluginSetting(); $allow_level = $setting['dataentry_allow_level']['value']; if($allow_level > $member['mb_level']) { $patternB = '/---- dataentry (.*?)----/s'; $patternI = '/{{dataentry=(.*?)\?(.*?)}}/s'; if(preg_match($patternB, $wr_content) || preg_match($patternI, $wr_content)) { $wikiControl =& wiki_class_load("Control"); $wikiControl->error("권한 없음", "사용할 수 없는 내용이 있습니다. (dataentry)"); } } //TODO: wiki parsing // ignore pre, nowiki, code, html $wr_content = preg_replace('/<pre>(.*?)<\/pre>/si', '', $wr_content); $wr_content = preg_replace('/<pre>(.*?)<\/pre>/si', '', $wr_content); $wr_content = preg_replace('/<nowiki>(.*?)<\/nowiki>/si', '', $wr_content); $wr_content = preg_replace('/<nowiki>(.*?)<\/nowiki>/si', '', $wr_content); $wr_content = preg_replace('/<code>(.*?)<\/code>/si', '', $wr_content); $wr_content = preg_replace('/<code>(.*?)<\/code>/si', '', $wr_content); $wr_content = preg_replace('/<html>(.*?)<\/html>/si', '', $wr_content); $wr_content = preg_replace('/<html>(.*?)<\/html>/si', '', $wr_content); // clear the previous one: for now no easy way to find updated dataentry.. so delete every dataentry on this page $sql_clear = "DELETE FROM ".$this->db_table." WHERE bo_table = '".$this->wiki['bo_table']."' AND wr_id=".$wr_id; sql_query($sql_clear); // find block dataentry $pattern = '/---- dataentry (.*?)----(.*?)----/s'; preg_match_all($pattern, $wr_content, $matches_all, PREG_SET_ORDER); foreach ($matches_all as $matches) { $keyword = trim($matches[1]); $options = preg_split( '/\r\n|\r|\n/', $matches[2]); $this->insert_dataentry($wr_id, $keyword, $options); } // find inline dataentry $pattern = '/{{dataentry=(.*?)\?(.*?)}}/s'; preg_match_all($pattern, $wr_content, $matches_all, PREG_SET_ORDER); foreach ($matches_all as $matches) { $keyword = trim($matches[1]); $matches[2] = str_replace('=', ":", $matches[2]); $options = explode("&", str_replace("&", "&", $matches[2])); $this->insert_dataentry($wr_id, $keyword, $options); } }
/** * * 해당 글에 대한 캐시 반환 * * @param int $wr_id 글 id * @return string parsing 되어 저장된 cache */ public function get($wr_id) { $row = sql_fetch("SELECT content FROM ".$this->wiki['cache_table']." WHERE bo_table = '".$this->wiki['bo_table']."' AND wr_id = $wr_id"); // @todo 동작 확인해야 함 // cache 된 내용이 없으면 parsing 수행 if(!$row) { $write = sql_fetch(" select * from ".$this->wiki['write_table']." where wr_id = '$wr_id' "); $wikiParser =& wiki_class_load("Parser"); $content = mysql_real_escape_string($wikiParser->parse($write)); sql_query("INSERT INTO ".$this->wiki['cache_table']." VALUES ('', '".$this->wiki['bo_table']."', $wr_id, '$content')"); return $content; } return $row['content']; }
/** * * 문서 등록/수정 시 처리 * * @param array $params {@link NarinEvent} 에서 전달하는 파라미터 */ public function on_write_update_tail($params) { $wr_id = $params['wr_id']; $wr_content = $params['write']['wr_content']; $member = $this->member; $setting = $this->plugin_info->getPluginSetting(); $allow_level = $setting['entry_allow_level']['value']; if($allow_level > $member['mb_level']) { $pattern = '/~~SEMANTIC:(.*?)~~/s'; if(preg_match($pattern, $wr_content)) { $wikiControl =& wiki_class_load("Control"); $wikiControl->error("권한 없음", "사용할 수 없는 내용이 있습니다."); } } //TODO: wiki parsing // ignore pre, nowiki, code, html $wr_content = preg_replace('/<pre>(.*?)<\/pre>/si', '', $wr_content); $wr_content = preg_replace('/<pre>(.*?)<\/pre>/si', '', $wr_content); $wr_content = preg_replace('/<nowiki>(.*?)<\/nowiki>/si', '', $wr_content); $wr_content = preg_replace('/<nowiki>(.*?)<\/nowiki>/si', '', $wr_content); $wr_content = preg_replace('/<code>(.*?)<\/code>/si', '', $wr_content); $wr_content = preg_replace('/<code>(.*?)<\/code>/si', '', $wr_content); $wr_content = preg_replace('/<html>(.*?)<\/html>/si', '', $wr_content); $wr_content = preg_replace('/<html>(.*?)<\/html>/si', '', $wr_content); // clear the previous one: for now no easy way to find updated dataentry.. so delete every dataentry on this page $sql_clear = "DELETE FROM byfun_narin_dataplugin WHERE bo_table = '".$this->wiki['bo_table']."' AND wr_id=".$wr_id; sql_query($sql_clear); // find semantic dataentry if(preg_match('/~~SEMANTIC:(.*?)~~/s', $wr_content, $keywords)) { $class = $keywords[1]; $props = array (); $pattern = '/::(.*?):(.*?)::/s'; preg_match_all($pattern, $wr_content, $matches_all, PREG_SET_ORDER); foreach ($matches_all as $matches) { $type = trim($matches[1]); $val = trim($matches[2]); array_push($props, array("type"=>$type, "val"=>$val)); } $this->insert_dataentry($wr_id, $class, $props); } }
$ns = $media->getNS($loc); if(!$ns) { echo wiki_json_encode(array('code'=>-101, 'msg'=>'존재하지 않는 폴더입니다 : ' . $loc)); exit; } // 권한 검사 if($ns['ns_access_level'] > $member['mb_level']) { $ret = array('code'=>'-1', 'msg'=>'권한 없음'); echo wiki_json_encode($ret); exit; } $thumb =& wiki_class_load("Thumb"); $thumb_width = 30; $thumb_height = 30; $files = $media->getList($loc); foreach($files as $k=>$file) { if($file['img_width'] > 0) { $thumb_path = $thumb->getMediaThumb($loc, $filename=$file['source'], $thumb_width, $thumb_height, $quality=90, $crop=true); $files[$k]['thumb'] = $thumb_path; } else $files[$k]['thumb'] = ""; preg_match("/\.([a-zA-Z0-9]{2,4})$/", $file['source'], $m); if($m[1] && file_exists(WIKI_PATH.'/imgs/media_manager/ext/'.strtolower($m[1]).'.png')) { $files[$k]['ext_icon'] = $wiki['url'].'/imgs/media_manager/ext/'.strtolower($m[1]).'.png'; } else $files[$k]['ext_icon'] = $wiki['url'].'/imgs/media_manager/ext/_blank.png'; $files[$k]['filesize'] = wiki_file_size($file['filesize']); $files[$k]['bytes'] = $file['filesize']; }
* 미디어 폴더 zip * * @package narinwiki * @subpackage pages * @license GPL2 (http://narinwiki.org/license) * @author byfun (http://byfun.com) * @filesource */ if(!defined("__NARIN_API__")) wiki_not_found_page(); if(!$loc || !$is_wiki_admin) wiki_ajax_error(); $loc = wiki_ajax_data($loc); $media =& wiki_class_load("Media"); $files = $media->getList($loc); if(empty($files)) { echo wiki_json_encode(array('code'=>-1, 'msg'=>'빈 폴더입니다.')); exit; } if(!class_exists('ZipArchive')) { echo wiki_json_encode(array('code'=>-1, 'msg'=>'PHP 에서 ZipArchive 를 지원하지 않습니다.')); exit; } $zip = new ZipArchive(); $name = md5(time()); $zipFile = WIKI_PATH.'/data/'.$bo_table.'/'.$name.'.zip';
/** * * AJAX 콜에 대한 응답 * * ajax로 문서 lock 갱신 * * @param array $params {@link NarinEvent) 에서 넘겨주는 파라미터 */ public function on_ajax_call($params) { $member = $this->member; $get = $params['get']; // 크롭 사용? $crop = (isset($get['nocrop']) ? false : true); // 썸네일 품질 $quality= (isset($get['q']) && is_int($get['q']) ? $get['q'] : 90); // 패턴 처리 $add_where = ""; foreach($params['get'] as $k => $v) { if(strpos($k, '*')) { // *.jpg => %.jpg // image_* => image_% // image_*.jpg => image%.jpg $add_where = ' AND m.source LIKE "' . addslashes(str_replace('*', '%', $k)) . '"'; break; } } // 페이징 처리 $paging = $get['paging']; $page = $get['page']; if($paging > 0 && $page > 0) { $arg_paging = array('page'=>$page, 'page_rows'=>$paging); } else $arg_paging = array(); // 너비, 높이 처리 $width = (isset($get['width']) ? $get['width'] : $this->width); $height = (isset($get['height']) ? $get['height'] : $this->height); if(isset($get['width']) && !isset($get['height'])) { $height = -1; } if(isset($get['height']) && !isset($get['width'])) { $width = -1; } // 정렬 처리 $sort = $get['sort']; $possible_ordering = array('name'=>'source', 'date'=>'reg_date', 'filesize'=>'filesize', 'width'=>'img_width', 'height'=>'img_height', 'random'=>'random'); if(isset($possible_ordering[$sort])) { $order = ( isset($get['reverse']) ? 'ASC' : 'DESC' ); $arg_ordering = array('by'=>$possible_ordering[$sort], 'order'=>$order); } else $arg_ordering = array('by'=>'reg_date', 'order'=>'DESC'); // 이미지 목록 가져오기 $path = wiki_ajax_data($get['path']); $wikiMedia =& wiki_class_load('Media'); $ns = $wikiMedia->getNS($path); if($ns['ns_access_level'] > $member['mb_level']) { echo wiki_json_encode(array('code'=>-1, 'msg'=>'권한이 없어 이미지를 표시할 수 없습니다.')); exit; } list($total, $from_record, $page_rows, $files) = $this->get_media_list($path, $add_where, $arg_paging, $arg_ordering); // 목록 정리 $images = array(); $wikiThumb =& wiki_class_load('Thumb'); foreach($files as $k=>$f) { if(!$f['img_width']) continue; list($w, $h) = $this->get_size($width, $height, $f['img_width'], $f['img_height']); $thumb = $wikiThumb->getMediaThumb($f['ns'], $f['source'], $w, $h, $quality, $crop); array_push($images, array('name'=>$f['source'], 'thumb'=>$thumb, 'href'=>$f['imgsrc'], 'thumb_width'=>$w, 'thumb_height'=>$h, 'width'=>$f['img_width'], 'height'=>$f['img_height'], 'filesize'=>wiki_file_size($f['filesize']), 'filesize_byte'=>$f['filesize'], 'user'=>$f['mb_id'], 'date'=>$f['reg_date'] )); } $more = 0; if(!empty($images) && !empty($arg_paging)) { if(count($images) >= $page_rows && $total != $from_record + $page_rows) $more = 1; } echo wiki_json_encode(array('code'=>1, 'files'=>$images, 'more'=>$more)); exit; }
* @license GPL2 (http://narinwiki.org/license) * @author byfun (http://byfun.com) * @filesource */ $use_minify = true; if($use_minify) ob_start(); include_once "_common.php"; @mkdir(WIKI_PATH.'/data/'.$bo_table, 0707); @mkdir(WIKI_PATH.'/data/'.$bo_table.'/files', 0707); @mkdir(WIKI_PATH.'/data/'.$bo_table.'/thumb', 0707); $g4['title'] = '나린위키 미디어 관리자'; $wikiConfig =& wiki_class_load("Config"); $media_setting = $wikiConfig->media_setting; $is_admin_mode = false; $colspan = 5; if($is_wiki_admin && $md == 'admin') { $is_admin_mode = true; $colspan++; } $no_layout = true; include_once "head.php"; ?> <style> html, body { background-color:#fff; } #media_manager_wrapper { padding:10px; background-color:#fff;}
* @filesource */ include_once "_common.php"; $doc = wiki_ajax_data($doc); $content = wiki_ajax_data($content); list($ns, $doc, $path) = wiki_page_name(stripslashes($doc)); $wr = array('mb_id'=>$member['mb_id'], 'mb_level'=>$member['mb_level'], 'mb_name'=>$member['mb_name'], 'mb_nick'=>$member['mb_nick'], 'wr_subject'=>$doc, 'wr_content'=>stripslashes($content) ); $parser =& wiki_class_load("Parser"); $html = $parser->parse($wr); $no_layout = true; ob_start(); include_once WIKI_PATH."/head.php"; echo $html; include_once WIKI_PATH."/tail.php"; $content = ob_get_contents(); ob_clean(); echo $content; ?>
/** * * 폴더 이름 변경 * * 실제 이름 변경 매소드이다. * 폴더 이름을 변경하고 폴더이름 변경의 영향을 받는 백링크들을 모두 업데이트한다. * 백링크 업데이트 후 문서 이력으로 남긴다. * * @param WikiArticle $wikiArticle {@link NarinArticle} 객체 * @param string $srcNS 변경전 이름 * @param string $toNS 변경후 이름 */ function _updateNamespace($wikiArticle, $srcNS, $toNS) { $wikiHistory =& wiki_class_load("History"); // $srcNS 에 포함된 documents 목록을 읽어온다. $list = $this->getList($srcNS, $withArticle = true); $escapedSrcNS = mysql_real_escape_string($srcNS); $escapedToNS = mysql_real_escape_string($toNS); // $srcNS / $document[] 에 대한 백 링크들을 업데이트한다. for($i=0; $i<count($list); $i++) { if($list[$i][type] == 'folder') continue; $wikiArticle->fromDoc = $fromDoc = $list[$i][path]; $wikiArticle->toDoc = preg_replace("/^(".preg_quote($srcNS, "/").")(.*?)/", $toNS, $fromDoc); // 백링크 업데이트 $backLinks = $wikiArticle->getBackLinks($fromDoc, $includeSelf=true); for($k=0; $k<count($backLinks); $k++) { $content = mysql_real_escape_string(preg_replace_callback('/(\[\[)(.*?)(\]\])/', array(&$wikiArticle, 'wikiLinkReplace'), $backLinks[$k]['wr_content'])); // 문서 이력에 백업 $wikiHistory->update($backLinks[$k]['wr_id'], stripcslashes($content), $this->member['mb_id'], "폴더명 변경에 따른 자동 업데이트"); $wikiArticle->shouldUpdateCache($backLinks[$k]['wr_id'], 1); sql_query("UPDATE ".$this->wiki['write_table']." SET wr_content = '$content' WHERE wr_id = ".$backLinks[$k]['wr_id'].""); } } sql_query("UPDATE ".$this->wiki['ns_table']." SET ns = '$escapedToNS' WHERE bo_table = '".$this->wiki['bo_table']."' AND ns = '$escapedSrcNS'", false); sql_query("UPDATE ".$this->wiki['nsboard_table']." SET ns = '$escapedToNS' WHERE bo_table = '".$this->wiki['bo_table']."' AND ns = '$escapedSrcNS'", false); $this->addNamespace($toNS); $this->checkAndRemove($srcNS); $wikiChanges =& wiki_class_load("Changes"); $wikiChanges->update("FOLDER", $srcNS, "폴더명변경 (이전)", $this->member['mb_id']); $wikiChanges->update("FOLDER", $toNS, "폴더명변경 (이후)", $this->member['mb_id']); }
<? /** * * 문서 관리 실행 스크립트 * * @package narinwiki * @subpackage pages * @license GPL2 (http://narinwiki.org/license) * @author byfun (http://byfun.com) * @filesource */ include_once "./_common.php"; $wikiArticle =& wiki_class_load("Article"); $write = &$wikiArticle->getArticle($ns, $docname); if(!$write) { alert("존재하지 않는 문서입니다."); exit; } if( !$is_wiki_admin && ($member['mb_id'] && $member['mb_id'] != $write['mb_id']) ) { alert("권한이 없습니다"); exit; } if(!$w || !$doc || !$wiki_folder_switch || !$wiki_doc ||!$write || !$wiki_access_level || (!$is_wiki_admin && $member['mb_id'] != $write['mb_id'])) { alert("잘못된 접근입니다."); exit; }
if($url) { header("location:$url"); } $wiki_path = $g4['path'] . "/" . $board['bo_1']; $wiki_config = $wiki_path."/narin.config.php"; // 위키 설정 & 라이브러리 로드 if(file_exists($wiki_config)) { define("__NARINWIKI__", TRUE); include_once $wiki_config; include_once $wiki_path . "/lib/narin.wiki.lib.php"; $wikiControl =& wiki_class_load("Control"); // 스킨 경로 변경 $board_skin_path = $wiki['inc_skin_path']; // 게시판 스킨 & 헤더-테일 변경 $board['bo_include_head'] = WIKI_PATH . "/head.php"; $board['bo_include_tail'] = WIKI_PATH . "/tail.php"; // 위키를 전체 검색에 노출 안되도록 함 // 위키 자체 권한, 파싱 문제 등... $board['bo_use_search'] = 0; $wikiControl->board($scriptFile); } // if wiki_config
/** * * 모든변경내역 삭제 */ function clear() { sql_query("DELETE FROM ".$this->wiki['changes_table']." WHERE bo_table = '".$this->wiki['bo_table']."'"); $wikiEvent =& wiki_class_load("Event"); $wikiEvent->trigger("CHANGES_DELETE_ALL", array()); }
header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // Settings $targetDir = WIKI_PATH . '/data/' . $bo_table . '/files/'; // 5 minutes execution time @set_time_limit(5 * 60); // Get parameters $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0; $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0; $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; if (!$loc || !trim($filename)) { die('{"jsonrpc" : "2.0", "error" : {"code": 901, "message": "잘못된 요청"}, "id" : "id"}'); } $loc = wiki_ajax_data($loc); $filename = wiki_ajax_data($filename); $media =& wiki_class_load('Media'); $reg_file = $media->getFile(stripslashes($loc), stripslashes($filename)); if ($reg_file['id']) { die('{"jsonrpc" : "2.0", "error" : {"code": 902, "message": "' . $filename . ' : 같은 이름의 파일이 있습니다"}, "id" : "id"}'); } // Clean the fileName for security reasons $fileName = preg_replace('/[^\\w\\._]+/', '', $fileName); // Make sure the fileName is unique but only if chunking is disabled if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) { $ext = strrpos($fileName, '.'); $fileName_a = substr($fileName, 0, $ext); $fileName_b = substr($fileName, $ext); $count = 1; while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b)) { $count++; }
/** * * 문서 제목 문자열 반환 * * 'write.skin.php' 에서 문서 제목을 설정하기 위함 */ function wiki_doc_from_write($doc, $wr_id) { $wikiArticle =& wiki_class_load("Article"); if(!$doc) { $write = &$wikiArticle->getArticleById($wr_id); $doc = ($write[ns] == "/" ? "" : $write[ns]) . "/" . $write[wr_subject]; } list($ns, $doc, $full) = wiki_page_name($doc); return array(get_text($doc), get_text($full)); }
/** * * AJAX 모듈 : 권한 설정 실행 * * @param $params /adm/admin.plugin.php 에서 넘겨주는 파라미터로 array('get'=>$_GET, 'post'=>$_POST) 임 */ public function update_level($params) { $update_list = wiki_ajax_data($params['get']['update_list']); $recursive = (wiki_ajax_data($params['get']['recursive']) == 'true'); if(!$update_list) { echo wiki_json_encode(array('code'=>-1, 'msg'=>'잘못된 파라미터')); exit; } $wikiArticle =& wiki_class_load('Article'); $wikiNS =& wiki_class_load('Namespace'); foreach($update_list as $k => $item) { if($item['type'] == 'doc') $wikiArticle->updateLevel(stripcslashes($item['path']), $item['access_level'], $item['edit_level']); else $wikiNS->updateAccessLevel(stripcslashes($item['path']), $item['access_level'], $recursive); } echo wiki_json_encode(array('code'=>1)); }
/** * 생성자 */ public function __construct() { $this->wiki_config = &wiki_class_load("Config"); }
include_once("_common.php"); $wikiConfig =& wiki_class_load("Config"); $current_using_plugins = $wikiConfig->using_plugins; $use_plugins = array(); for($i=0; $i<count($wiki_plugin); $i++) { if($wiki_plugin_use[$i]) array_push($use_plugins, $wiki_plugin[$i]); } $wikiConfig->update("/using_plugins", $use_plugins); $unused_plugins = array_diff($current_using_plugins, $use_plugins); foreach($unused_plugins as $k=>$p) { $pi = wiki_plugin_info($p); $pi->onUnused(); } $wikiJsCss = wiki_class_load('JsCss'); $wikiJsCss->updateJs(); $wikiJsCss->updateCss(); header("location:".$wiki['url']."/adm/plugin.php"); ?>
<? /** * * 액션 스크립트 : 댓글 보기 전 처리 * * @package narinwiki * @subpackage event * @license GPL2 (http://narinwiki.org/license) * @author byfun (http://byfun.com) * @filesource */ if (!defined('_GNUBOARD_')) exit; /** * 댓글에 대한 위키 문법 분석 */ $list = &$params['list']; if($use_comment) { if(count($list)) $wikiParser =& wiki_class_load("Parser"); for ($i=0; $i<count($list); $i++) { $list[$i]['del_link'] = $wiki['g4_url'].'/bbs/'.substr($list[$i]['del_link'], 2); if (!strstr($list[$i]['wr_option'], "secret") || $is_admin || $is_wiki_admin || ($write['mb_id']==$member['mb_id'] && $member['mb_id']) || ($list[$i]['mb_id']==$member['mb_id'] && $member['mb_id'])) { $list[$i]['content'] = $wikiParser->parse($list[$i]); } } } else $list = ""; ?>
<? /** * * 위키 관리 : media 실행 스크립트 * * @package narinwiki * @subpackage admin * @license GPL2 (http://narinwiki.org/license) * @author byfun (http://byfun.com) * @filesource */ include_once("_common.php"); $narin_config =& wiki_class_load("Config"); $_POST['media_setting']['allow_extensions'] = str_replace(" ", "", $_POST['media_setting']['allow_extensions']); $narin_config->update("/media_setting", $_POST['media_setting']); header("location:".$wiki['url']."/adm/media.php"); ?>
* @author byfun (http://byfun.com) * @filesource */ if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 if(file_exists(WIKI_PATH."/narin.config.php") ) { if(!$doc && $wr_id) { $wikiArticle =& wiki_class_load("Article"); $tmp = &$wikiArticle->getArticleById($wr_id); $doc = wiki_doc($tmp['ns'], $tmp['doc']); list($ns, $docname, $doc) = wiki_page_name($doc); } $scriptFile = basename($_SERVER['SCRIPT_NAME']); $wikiEvent =& wiki_class_load("Event"); extract($wikiEvent->trigger("LOAD_HEAD", array("script"=>$scriptFile, "folder"=>$ns, "docname"=>$docname, "doc"=>$doc))); $css_path = $wiki['url'].'/css.php'; $js_path = $wiki['url'].'/js.php'; if($wiki['fancy_url']) { $css_path = $wiki['url'].'/_narin.css'; $js_path = $wiki['url'].'/_narin.js'; } if(isset($wiki_head)) { echo $wiki_head; } ?> <link rel="stylesheet" href="<?php
/** * * template 처리 without js (currently no js version though) * * @param array $args 파라미터 * @param array $params {@link NarinParser} 에서 전달하는 파라미터/ can be null * @return string include되고 파싱된 결과 */ public function wiki_template_nojs($args, $params) { // default parser, if params is not null if ($params) { $wikiParser = new NarinParser(); $plugins =& $params['plugins']; $default =& $plugins[array_search('wiki_default_parser', $plugins)]; } else { $wikiParser = wiki_class_load("Parser"); } $parameters = array(); $values = array(); if ($args['options']) { // $list = explode("&", str_replace("&", "&", htmlspecialchars_decode($args['options']) )); $list = explode("&", str_replace("&", "&", urldecode($args['options']))); foreach ($list as $el) { $pair = explode("=", $el); array_push($parameters, "/@@" . $pair[0] . "@@/"); array_push($values, $pair[1]); } } // Template 사용 level check if ($this->allow_level > $args['writer_level']) { return ""; } // folder access level check $wikiNS = wiki_class_load("Namespace"); $n = $wikiNS->get($args['loc']); if ($this->member['mb_level'] < $n['ns_access_level']) { return ""; } // template access level check $wikiArticle = wiki_class_load("Article"); if (!$wikiArticle->exists($args['loc'], $args['docname'])) { return ""; } $t = $wikiArticle->getArticle($args['loc'], $args['docname']); if ($this->member['mb_level'] < $t['access_level']) { return ""; } // $prefix = "<div style='border:1px gray dotted; padding:5px;'><div style='padding:5px 10px;background-color:#f8f8f8;'>사용된 틀: " // .$matches[1]."</div>"; // $postfix = "</div>"; $prefix = "<div class='wiki_template'>"; $postfix = "</div>"; // cannot include itself, just in case //if($this->doc == $path) return $prefix."<div style='color:red;'>자기자신은 include 할 수 없습니다.</div>".$postfix; // close all open tags if (preg_match('/~~CLOSEALL~~/', $t['wr_content'])) { if ($params) { // save the 'closing' html $args['closeall'] = htmlspecialchars($this->get_close(&$default)); } $prefix = htmlspecialchars_decode($args['closeall']) . $prefix; // it might mess up with section level when used with ~~PAGEBOTTOME~~ $t['wr_content'] = preg_replace('/~~CLOSEALL~~/', '', $t['wr_content']); } // move template $template_position = "HERE"; if (preg_match('/~~PAGETOP~~/', $t['wr_content'])) { $template_position = "TOP"; $t['wr_content'] = preg_replace('/~~PAGETOP~~/', '', $t['wr_content']); } if (preg_match('/~~PAGEBOTTOM~~/', $t['wr_content'])) { $template_position = "BOTTOM"; $t['wr_content'] = preg_replace('/~~PAGEBOTTOM~~/', '', $t['wr_content']); } // onlyinclude if (preg_match('/<onlyinclude>(.*?)<\\/onlyinclude>/s', $t['wr_content'], $onlyinclude)) { $t['wr_content'] = $onlyinclude[1]; } // noinclude $t['wr_content'] = preg_replace('/<noinclude>(.*?)<\\/noinclude>/s', "", $t['wr_content']); // can we do foreach (##...@@--@@...##) and exist (<<...@@--@@...>>) ?? // e.g. <<카테고리: ##[[/카테고리/@@name@@]]## \\>> foreach ($parameters as $k => $p) { if (!$values[$k]) { continue; } $pattern = '/(<<([^<#@]*?))?(##([^<#@]*?))?' . trim($p, "/") . '(([^<#@]*?)##)?(([^<#@]*?)>>)?/s'; preg_match_all($pattern, $t[wr_content], $matches_all, PREG_SET_ORDER); foreach ($matches_all as $m) { $old = $m[0]; $start = $m[2]; $R_open = $m[4]; $R_end = $m[6]; $end = $m[8]; $val = $values[$k]; // assume ', ' being delimiter $array = array(); $array = explode(', ', $val); $new_array = array(); foreach ($array as $a) { array_push($new_array, $R_open . $a . $R_end); } $new = implode(', ', $new_array); $t['wr_content'] = str_replace($old, $start . $new . $end, $t['wr_content']); } } // clean rest of <<..@@..@@..>> // TODO: <<..{{expr=@@..@@+@@..@@}}..>> cannot be cleaned when one of the args in expr $pattern = '/(<<([^<#@]*?))?(##([^<@]*?))?@@[^@]*@@(([^<@]*?)##)?(([^<@]*?)>>)?/s'; preg_match($pattern, $t['wr_content'], $matches); $t['wr_content'] = preg_replace($pattern, "", $t['wr_content']); // now anything without <<..>> or ##..##, althought seems unnecessary // replacing $t['wr_content'] = preg_replace($parameters, $values, $t['wr_content']); // delete any missing @@--@@s $t['wr_content'] = preg_replace("/@@[^@]*@@/", "", $t['wr_content']); // parse the replaced template $content = $wikiParser->parse($t); // some post parsing.. $pattern = '/^<div class=\'narin_contents\'>|<div id=\'wiki_toc\'>.*<!--\\/\\/ wiki_toc -->|<a name[^<]*><\\/a>|<\\/div>$/s'; $content = preg_replace($pattern, "", $content); // currently, just return it withouth adjusting the position of templated content in 2012-01-11 version return $prefix . $content . $postfix; // try to do both, addEvent(EVENT_AFTER_PARSING_ALL, ...) and partial nocache if ($params) { // for initial rendering array_push($this->blocks, array("position" => $template_position, "content" => $prefix . $content . $postfix)); return "<template></template>"; } else { return $prefix . $content . $postfix; } }
/** * * dataout inline 처리 without js (currently no js version though) * * @param array $args 파라미터 * @param array $params {@link NarinParser} 에서 전달하는 파라미터/ can be null * @return string output */ public function wiki_dataout_inline_nojs($args, $params) { if($args['having']>0) { $having = "HAVING COUNT(1)=".$args['having']; } if($args['method'] == "rank") { if($args['having_target']>0) { $having_target = "HAVING COUNT(1)=".$args['having_target']; } $sql_wr_id = "SELECT wr_id FROM ".$args['db_table']." WHERE bo_table='".$this->bo_table."' AND ".$args['filter_keyword']." AND (".$args['filter_target'].") GROUP BY wr_id ".$having_target; $res_wr_id = sql_query($sql_wr_id); $row_wr_id = mysql_fetch_assoc($res_wr_id); $sort_wr_id = $row_wr_id['wr_id']; if(!$sort_wr_id) return " <span style='color:red;'>등록정보없음</span> "; // make all wr_id list without filter_target mysql_query("SET @rank=0"); $sql_rank = "SELECT rank FROM ( SELECT @rank:=@rank+1 AS rank, wr_id, val FROM ( SELECT d.wr_id, val FROM ( SELECT wr_id FROM ".$args['db_table']." WHERE bo_table='".$this->bo_table."' AND ".$args['filter_keyword']." AND (".$args['filter_where'].") GROUP BY wr_id ".$having." ) c, ".$args['db_table']." d WHERE d.bo_table='".$this->bo_table."' AND ".$args['filter_keyword']." AND d.wr_id=c.wr_id AND col = '".$args['field']."' ORDER BY CAST(val AS DECIMAL) ".$args['sort']." ) r ) g WHERE g.wr_id = ".$sort_wr_id; //TODO: order should be done by proper casting.. maybe need to specify the data type // e.g. _int --> CAST(val AS UNSIGNED), _dt --> CAST(val AS DATETIME), _num --> CAST(val AS DECIMAL) $res_rank = sql_query($sql_rank); $row_rank = mysql_fetch_assoc($res_rank); return " ".$row_rank['rank']." "; } $sql_wr_id = "SELECT wr_id FROM ".$args['db_table']." WHERE bo_table='".$this->bo_table."' AND ".$args['filter_keyword']." AND (".$args['filter_where'].") GROUP BY wr_id ".$having; $res_wr_id = sql_query($sql_wr_id); if($args['method'] == "count") { $nb_count = mysql_num_rows($res_wr_id); return " ".$nb_count." "; }else { $data_array = array(); while($row_wr_id = mysql_fetch_assoc($res_wr_id)) { $wr_id = $row_wr_id['wr_id']; // fullpath is reserved for %pageid%, docname is reserved for %title% if($args['field']=='fullpath' || $args['field']=='%pageid%' || $args['field']=='%title%') { $wikiArticle =& wiki_class_load("Article"); $write = $wikiArticle->getArticleById($wr_id); $fullpath = wiki_doc($write['ns'], $write['doc']); $href = wiki_url('read', array('doc'=>$fullpath)); if($args['field']=='fullpath' || $args['field']=='%pageid%') { array_push($data_array, "<a href='".$href."' class='wiki_active_link'>".$fullpath."</a>"); }else { array_push($data_array, "<a href='".$href."' class='wiki_active_link'>".$write['doc']."</a>"); } }else { $sql = "SELECT val FROM ".$args['db_table']." WHERE bo_table='".$this->bo_table."' AND ".$args['filter_keyword']." AND col='".$args['field']."' AND wr_id=".$wr_id." GROUP BY wr_id"; $row = sql_fetch($sql); array_push($data_array, $row['val']); } if($args['method'] == "item") { return " ".array_shift($data_array)." "; } } if(count($data_array) == 0) return " <span style='color:red;'>등록정보없음</span> "; sort($data_array); return " ".implode(", ", $data_array)." "; } }
* * 위키 관리 : 관리 플러그인 실행 * * @package narinwiki * @subpackage admin * @license GPL2 (http://narinwiki.org/license) * @author byfun (http://byfun.com) * @filesource */ $pageid = "front"; include_once("_common.php"); $wikiAdmin =& wiki_class_load("Admin"); $plugin = $wikiAdmin->getPlugin($p); if(!$wikiAdmin->isUsable($p) || !$plugin) { alert('사용할 수 없는 플러그인입니다.'); exit; } if(!$m) $m = 'view'; else if(!is_callable(array($plugin, $m))) { alert('지원되지 않는 기능입니다.'); exit; } if(!$nolayout) include_once "admin.head.php"; $plugin->$m(array('get'=>$_GET, 'post'=>$_POST));
/** * * 문서 작성 로드시 * * 문서가 lock 되어있는지 검사하고 lock * * @param array $params {@link NarinEvent) 에서 넘겨주는 파라미터 */ public function on_write_head($params) { if($this->plugin_info->shouldInstall()) return; $doc = $params['doc']; $setting = $this->plugin_info->getPluginSetting(); $this->initialize_lock($doc); if(!$this->locked) { $this->lock($doc); } else { $l_duration = ( time() - $this->locked['time'] ); // in seconds if($this->lock_life > $l_duration) { $wikiControl =& wiki_class_load("Control"); $wikiControl->error("문서 잠김", "편집중인 문서입니다."); } else { $this->lock($doc); } } }
if(!$view) { $wikiControl->noDocument($ns, $docname, $doc); } else { $wikiControl->acl($doc); // 권한 체크 if($view['mb_id'] && $view['mb_id'] == $member['mb_id']) $is_doc_owner = true; else $is_doc_owner = false; if( !$is_doc_owner && $is_wiki_admin && $member['mb_level'] < $history_access_level) { $wikiControl->notAllowedDocument($ns, $docname, $doc); } $wikiHistory =& wiki_class_load("History"); list($history, $paging) = $wikiHistory->getHistory($view['wr_id'], stripcslashes($doc), $page, $rows=15); if($is_wiki_admin) { $clear_href = "javascript:clear_history(".$view['wr_id'].");"; $delete_selected_href = "javascript:delete_selected_history(".$view['wr_id'].");"; } else { $clear_href = ""; $delete_selected_href = ""; } $wikiControl->includePage($wiki['inc_skin_path'] . "/history.skin.php", $layout=true); } ?>
$wikiArticle =& wiki_class_load("Article"); $article = $delete_article; $doc = wiki_doc($article['ns'], $article['doc']); $backlinks = $wikiArticle->getBackLinks($doc, $includeSelf = false); for($i=0; $i<count($backlinks); $i++) { $wikiArticle->shouldUpdateCache($backlinks[$i]['wr_id'], 1); } $wikiArticle->deleteArticleById($wr_id); // 문서 이력 삭제 $wikiHistory =& wiki_class_load("History"); $wikiHistory->setUnlinked($wr_id, $doc); //$wikiHistory->clear($wr_id, $delete_all = true); // 캐시 삭제 $wikiCache =& wiki_class_load("Cache"); $wikiCache->delete($wr_id); // 최근 변경 내역 업데이트 $wikiChanges =& wiki_class_load("Changes"); $wikiChanges->update("DOC", $doc, "삭제", ($member['mb_id'] ? $member['mb_id'] : $write[wr_name])); wiki_goto_url(wiki_url()); exit; ?>
/** * * 미디어 이미지 * * FORMAT : {{media=/폴더1/폴더2/이미지}} * FORMAT : {{media=/폴더1/폴더2/이미지?style=float:left;margin-right:5px}} : style for 'a' wrapping image * FORMAT : {{media=/폴더1/폴더2/이미지?imgstyle=padding:2px;border:1px solid #ccc}} : style for image * * @param array $fileinfo 파일 정보 배열 * @param string $args ? 다음의 문자열 * @param string $title 제목 * @param array $params {@link NarinParser} 에서 전달하는 파라미터 * @return string 이미지 링크 */ private function _wiki_media_image($fileinfo, $args, $title, $params) { if($args) parse_str(str_replace("&", "&", $args)); if(!$title) $title = $fileinfo['source']; $use_thumb = false; if($width && $height) { $width = intval($width); $height= intval($height); $use_thumb = true; } $rn = rand(1, 999999); $origin = $fileinfo['imgsrc']; if($use_thumb) { $thumb =& wiki_class_load("Thumb"); $img = $thumb->getMediaThumb($ns=$fileinfo['ns'], $filename=$fileinfo['source'], $width, $height, $quality=90); } else { $img = $fileinfo['imgsrc']; } return "<a href='$origin' class='wiki_image wiki_modal' style='$style' rel='$rn'><img src='$img' class='$align' style='border:1px solid #888;padding:4px;$imgstyle' border='0' title='$title'/></a>"; }
* @package narinwiki * @subpackage event * @license GPL2 (http://narinwiki.org/license) * @author byfun (http://byfun.com) * @filesource */ if (!defined('_GNUBOARD_')) exit; list($subject, $wr_doc) = wiki_doc_from_write($doc, $wr_id); if(!$write['is_owner'] && !$is_wiki_admin) $return_array['is_file'] = false; $title_msg = "문서 편집"; if(!$w) { $title_msg = "새 문서"; $wikiNS =& wiki_class_load("Namespace"); $folder = $wikiNS->get($folder); $tpl = $folder['tpl']; $source = array("/@DOCNAME@/", "/@FOLDER@/", "/@USER@/", "/@NAME@/", "/@NICK@/", "/@MAIL@/", "/@DATE@/"); $target = array($docname, $folder['ns'], $member['mb_id'], $member['mb_name'], $member['mb_nick'], $member['mb_email'], date("Y-m-d h:i:s")); $content = preg_replace($source, $target, $tpl); $return_array['content'] = $content; } $return_array['title_msg'] = $title_msg; $return_array['subject'] = wiki_input_value($subject); $return_array['wr_doc'] = wiki_input_value($wr_doc); ?>
/** * * 그누보드 extend 처리 * * <g4>/extends/narin.wiki.extend.php 에서 호출하며, * 요청되는 스크립트 파일에 따라 위키에서 필요한 처리를 수행 * * @param string $scriptFile 스크립트 파일 (write.php, board.php, write_update.php ...) */ function board($scriptFile) { global $wiki, $bo_table, $wr_id, $board, $doc; // view if($scriptFile == "board.php" && $wr_id) { $wikiArticle =& wiki_class_load("Article"); $view = & $wikiArticle->getArticleById($wr_id); $doc = ($view[ns] == "/" ? "" : $view[ns]."/") . $view[doc]; wiki_goto_url(wiki_url('read', array('doc'=>$doc))); exit; } // list if($scriptFile == "board.php" && !$wr_id) { header("location:".wiki_url()); exit; } // 에디터에게 글 작성 권한을 주기 위해... if($wr_id && $this->member['mb_id'] && $this->member['mb_id'] != $this->write['mb_id']) { $wikiArticle =& wiki_class_load("Article"); $wikiConfig =& wiki_class_load("Config"); $default_edit_level = $wikiConfig->setting['edit_level']; $article = & $wikiArticle->getArticleById($wr_id); $edit_level = ( $article['edit_level'] ? $article['edit_level'] : $default_edit_level); $is_doc_editor = ($this->member['mb_level'] >= $edit_level ); if($scriptFile == "write.php" || $scriptFile == "write_update.php") { if($is_doc_editor) { $this->write['mb_id'] = $this->member['mb_id']; $this->write['is_editor'] = true; } } } else if($wr_id && $this->member['mb_id'] && $this->member['mb_id'] == $this->write['mb_id']) { $this->write['is_owner'] = true; } // write if($scriptFile == "write.php" && !$doc && !$wr_id ) { header("location:".wiki_url()); exit; } }