Esempio n. 1
0
	/**
	 * 
	 * AJAX 콜에 대한 응답
	 * 
	 * ajax로 문서 lock 갱신
	 * 
	 * @param array $params {@link NarinEvent) 에서 넘겨주는 파라미터
	 */
	public function on_ajax_call($params) {

		$member = $this->member;
		
		$get = $params['get'];
		$ns = $get['path'];
		$recursive = (isset($get['nosub']) ? false : true);
		$rows = (isset($get['rows']) ? $get['rows'] : 5);
		$cutstr = (isset($get['title_length']) ? $get['title_length'] : 512);
		$dateformat = (isset($get['dateformat']) ? $get['dateformat'] : "Y-m-d h:i:s");
		$order = (isset($get['order']) ? $get['order'] : 'date');
		$reverse = (isset($get['reverse']) ? true : false);
		$with_content = ($get['type'] == 'webzine' ? true : false);
		
		$wild = '';
		foreach($get as $k => $v) {
			if(strpos($k, '*') !== false) {
				$wild = $k;				
				break;				
			}
		}				
		
		define("_LIST_PLUGIN_", 1);
		include_once dirname(__FILE__).'/list.lib.php';
		
		$list = wiki_list_docs($this->wiki, $this->g4, stripslashes($ns), $order, $wild, $recursive, $dateformat, $rows, $cutstr, $reverse, $with_content);

		echo wiki_json_encode(array('code'=>1, 'current_time'=>$this->g4['time_ymdhis'], 'list'=>$list));
		exit;
	}
Esempio n. 2
0
	/**
	 * 
	 * HTML 변환
	 * 
	 * @param array $matches 패턴매칭 결과
	 * @param array $params {@link NarinParser} 에서 전달하는 파라미터
	 * @return string HTML 태그
	 */
	public function wiki_gallery($matches, $params) {
		// $matches[1] = gallery= 또는 gal=
		// $matches[2] = 경로
		// $matches[4] = 파라미터
		
		$args = array();

		if($matches[5]) {
			parse_str($matches[5], $args);	
		}
		
		$args['path'] = $matches[2];
		$options = wiki_json_encode($args);		
		
		return '<div class="wiki_gallery" style="display:none">'.$options.'</div>';
	}
Esempio n. 3
0
	/**
	 * 
	 * HTML 변환
	 * 
	 * @param array $matches 패턴매칭 결과
	 * @param array $params {@link NarinParser} 에서 전달하는 파라미터
	 * @return string HTML 태그
	 */
	public function wiki_list($matches, $params) {
		// $matches[1] = list=
		// $matches[1] = 경로
		// $matches[4] = 파라미터
		
		$args = array();

		if($matches[4]) {
			parse_str($matches[4], $args);	
		}
				
		$args['path'] = $matches[1];

		$list = $this->wiki_list_nojs($args, &$params);
		
		$options = wiki_json_encode($args);		
		
		return '<nocache plugin="list" method="cache_render" params="'.addslashes($options).'">'.$list.'</nocache>';
		//return $list.'<div class="wiki_lister" style="display:none">'.$options.'</div>';
	}
Esempio n. 4
0
	/**
	 *
	 * inline 형태의 출력: datacount / datalist / dataitem / datarank
	 *
	 * @param array $matches 패턴매칭 결과
	 * @param array $params {@link NarinParser} 에서 전달하는 파라미터
	 * @return string output
	 */
	public function wiki_dataout_inline($matches, $params) {
		// matches[1] : method (count or list)
		// matches[2] : '=' if any
		// matches[3] : anything b/w '=' and '?'  e.g.  도시:^인구&name=부산
		// matches[5] : list of parameter=value after '?'

		$args = array();

		$args['method'] = $matches[1];

		// keyword
		$args['filter_keyword'] = "1";
		$keyword = "";

		// target filtering
		$args['filter_target'] = "1";
		$filters_target = array();		// filters for target.. only for rank method

		// condition filtering
		$args['filter_where'] = "1";
		$filters = array();

		// for datalist
		$args['field'] = 'fullpath';
	
		// for datarank
		$args['sort'] = 'ASC';
			
		// process $matches[2] if exists
		if($matches[2]) {
			$list = explode("&", str_replace("&amp;", "&", $matches[3]));
			$targets = explode(":", array_shift($list));		// first one should be keyword (count) or keyword:field or field (list,item,rank)
			if($args['method'] == "count") {
				$keyword = $targets[0];
			}else {
				if(count($targets)==1) {
					$args['field'] = $targets[0];
				}else {
					$keyword = $targets[0];
					$args['field']   = $targets[1];
					if($args['method'] == "rank" && preg_match('/^\^(.*)$/', $args['field'], $sort_match)) {
						$args['sort']  = 'DESC';
						$args['field'] = $sort_match[1];
					}
				}
			}
			if($keyword) $args['filter_keyword'] = " keyword = '".$keyword."' ";
	
			foreach($list as $el) {
				$op_pattern = '/^(.*?)(=|\!=|&lt;&gt;|&lt;|&lt;=|=&gt;|&gt;|\~|\!\~)(.*?)$/s';
				preg_match($op_pattern, $el, $op_matches);
				$col = $op_matches[1];
				$val = $op_matches[3];
				$op  = $op_matches[2];
				$not = "";
	
				if($op=='~') {
					// wildcard
					$op = 'LIKE';
					$val = preg_replace('/\*/', '%', $val);
				}elseif($op=='!~') {
					// wildcard
					$op = 'LIKE';
					$not = 'NOT';
					$val = preg_replace('/\*/', '%', $val);
				}elseif($op=='!=' || $op=='<>') {
					$op = '=';
					$not = 'NOT';
				}else {
					$op = preg_replace('/&lt;/','<',$op);
					$op = preg_replace('/&gt;/','>',$op);
				}
	
				if($col == 'class') {
					$keyword = 'class';
					$args['filter_keyword'] = $not." keyword ".$op." '".$val."' ";
				}
				else array_push($filters_target, "(col = '".$col."' AND ".$not." val ".$op." '".$val."')");
			}
			
			// target filtering
			$args['having_target'] = 0;
			if(count($filters_target)) {
				$args['filter_target'] = implode(' OR ', $filters_target);
				$args['having_target'] = count($filters_target);
			}
		}
	
			
		if($matches[5]) {
			$list = explode("&", str_replace("&amp;", "&", $matches[5]));
			foreach($list as $el) {
				$op_pattern = '/^(.*?)((=|\!=|&lt;&gt;|&lt;|&lt;=|=&gt;|&gt;|\~|\!\~)(.*))?$/s';
				preg_match($op_pattern, $el, $op_matches);
				$col = $op_matches[1];
				$val = $op_matches[4];
				$op  = $op_matches[3];
				$not = "";
				if(!$op_matches[2]) {
					// no comparison.. so class
					// datalist 인경우는 keyword:field 형태로 한 field를 선택, 없는 경우는 %pageid%
					if($args['method'] == "list" || $args['method'] == "item" || $args['method'] == "rank") {
						$kv = explode(":", $col);
						$val = $kv[0];
						if($kv[1]) $args['field'] = $kv[1];
						if($args['method'] == "rank" && preg_match('/^\^(.*)$/', $args['field'], $sort_match)) {
							$args['sort']  = 'DESC';
							$args['field'] = $sort_match[1];
						}
					}else {
						$val = $op_matches[1];
					}
					$col = 'class';
					$op = '=';
				}else {
					if($op=='~') {
						// wildcard
						$op = 'LIKE';
						$val = preg_replace('/\*/', '%', $val);
					}elseif($op=='!~') {
						// wildcard
						$op = 'LIKE';
						$not = 'NOT';
						$val = preg_replace('/\*/', '%', $val);
					}elseif($op=='!=' || $op=='<>') {
						$op = '=';
						$not = 'NOT';
					}else {
						$op = preg_replace('/&lt;/','<',$op);
						$op = preg_replace('/&gt;/','>',$op);
					}
				}
	
				if($col == 'class') {
					$keyword = 'class';
					$args['filter_keyword'] = $not." keyword ".$op." '".$val."' ";
				}
				else array_push($filters, "(col = '".$col."' AND ".$not." val ".$op." '".$val."')");
			}
		}
	
		// filtering
		$args['having'] = 0;
		if(count($filters)) {
			$args['filter_where'] = implode(' OR ', $filters);
			$args['having'] = count($filters);
		}
			
		$args['db_table'] = $this->db_table;
		$dataout_inline = $this->wiki_dataout_inline_nojs($args, &$params);
	
		$options = wiki_json_encode($args);
	
		return '<nocache plugin="data" method="cache_render_inline" params="'.addslashes($options).'">'.$dataout_inline.'</nocache>';
	}
Esempio n. 5
0
<?
/**
 * 
 * 임시 저장 삭제
 *
 * @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(!$member['mb_id'] || !$wr_doc) wiki_ajax_error();

$id = md5($member['mb_id']."_".$wr_doc);
$reg = "tmpsave/$id";	
$tmp_saved = wiki_get_option($reg);	
$ret = array();	
if($tmp_saved) {
	$ret['code'] = 1;
	$ret['wr_date'] = $tmp_saved['wr_date'];
	$ret['wr_content'] = $tmp_saved['wr_content'];
} else {
	$ret['code'] = -1;
}	
echo wiki_json_encode($ret);		

?>
Esempio n. 6
0
function wiki_ajax_error($msg = "파라미터 오류") {
	echo wiki_json_encode(array('code'=>-1, 'msg'=>$msg));
	exit;
}
Esempio n. 7
0
	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';

if(!$zip->open($zipFile, ZIPARCHIVE::CREATE)) {
	echo wiki_json_encode(array('code'=>-1, 'msg'=>'압축파일 생성 실패 (1)'));
	exit;
}

foreach($files as $k=>$file) {
	$zip->addFile($file['path'], $file['source']);
}

$zip->close();

if(!file_exists($zipFile)) {
	echo wiki_json_encode(array('code'=>-1, 'msg'=>'압축파일 생성 실패 (2)'));
	exit;
}

echo wiki_json_encode(array('code'=>1, 'file'=>$name));
	
?>
Esempio n. 8
0
 * @filesource
 */
 
if(!defined("__NARIN_API__")) wiki_not_found_page();

if(!$ploc || !$loc) wiki_ajax_error();

$loc = wiki_ajax_data($loc);
$ploc = wiki_ajax_data($ploc);

$media =& wiki_class_load("Media");
$parent = $media->getNS($ploc);
if(!$parent && $ploc == '/') {
	$media->addNamespace('/');
} else if(!$parent || $parent['ns_mkdir_level'] > $member['mb_level']) {
	$ret = array('code'=>'-1', 'msg'=>'권한이 없습니다.');
	echo wiki_json_encode($ret);
	exit;		
}

if(!wiki_check_folder_name($loc)) {
	$ret = array('code'=>'-1', 'msg'=>'폴더명 형식이 잘못되었습니다');
	echo wiki_json_encode($ret);
	exit;
}

$media->addNamespace($loc, $parent);
echo wiki_json_encode(array('code'=>1));
	
?>
Esempio n. 9
0
<?
/**
 * 
 * 미디어 트리 출력
 *
 * @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) wiki_ajax_error();

$loc = wiki_ajax_data($loc);

$media =& wiki_class_load("Media");
$ns = $media->getNS($loc);
if(!$ns && $loc == '/') $media->addNamespace('/');
else if(!$ns) {
	echo wiki_json_encode(array('code'=>-1, 'msg'=>'존재하지 않는 폴더입니다.'));
	exit;
}

echo wiki_json_encode(array('code'=>1, 'tree'=>$media->get_tree("/", $loc)));	
	
?>
Esempio n. 10
0
	/**
	 *
	 * 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));
	}
Esempio n. 11
0
 /**
  * 
  * template 처리
  * 
  * @param array $matches 패턴매칭 결과
  * @param array $params {@link NarinParser} 에서 전달하는 파라미터
  * @return
  */
 public function wiki_template($matches, $params)
 {
     // matches[1] : /template/form
     // matches[4] : list of parameter=value after '?'
     $pattern = '/((.*)\\/)([^\\/\\#]*)(\\#(.*))?$/';
     preg_match($pattern, $matches[1], $m);
     // m[1]: root namespace if m[2]=NULL
     // m[2]: non-root namespace
     // m[3]: docname
     // m[5]: secname if any
     $args = array();
     $args['loc'] = $m[2] ? $m[2] : $m[1];
     $args['docname'] = $m[3];
     $args['secname'] = $m[5] ? $m[5] : "";
     $args['path'] = wiki_doc($args['loc'], $args['docname']);
     //		$args['options'] = htmlspecialchars($matches[4]);
     $args['options'] = urlencode($matches[4]);
     // 작성자 레벨 셋팅
     if ($params[view][mb_id]) {
         $writer = get_member($params[view][mb_id]);
         $args['writer_level'] = $writer[mb_level];
     } else {
         $args['writer_level'] = 0;
     }
     $templated = $this->wiki_template_nojs(&$args, &$params);
     $options = wiki_json_encode($args);
     return '<nocache plugin="template" method="cache_render" params="' . addslashes($options) . '">' . $templated . '</nocache>';
 }
Esempio n. 12
0
	/**
	 * 
	 * 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;
	}
Esempio n. 13
0
 /**
  * 
  * include 처리
  * 
  * @param array $matches 패턴매칭 결과
  * @param array $params {@link NarinParser} 에서 전달하는 파라미터
  * @return string include되고 파싱된 결과
  */
 public function wiki_include($matches, $params)
 {
     // matches[1] : (/folder)/article(#section)
     // matches[4] : parameters after '?'
     $args = array();
     $pattern = '/((.*)\\/)([^\\/\\#]*)(\\#(.*))?$/';
     preg_match($pattern, $matches[1], $m);
     // parse options
     if ($matches[4]) {
         parse_str(str_replace("&amp;", "&", $matches[4]), $args);
     }
     // m[1]: root namespace if m[2]=NULL
     // m[2]: non-root namespace
     // m[3]: docname
     // m[5]: secname if any
     $args['loc'] = $m[2] ? $m[2] : $m[1];
     $args['docname'] = $m[3];
     $args['secname'] = $m[5] ? $m[5] : "";
     $args['path'] = wiki_doc($args['loc'], $args['docname']);
     // plugin settings and alternative flags
     $args['nocontainer'] = $this->setting_nocontainer && ($args['box'] == "no" || isset($args['nocontainer'])) ? true : false;
     $args['firstseconly'] = $this->include_range == "FS" || (isset($args['firstseconly']) || isset($args['fso'])) ? true : false;
     // 작성자 레벨 셋팅
     if ($params[view][mb_id]) {
         $writer = get_member($params[view][mb_id]);
         $writer_level = $writer[mb_level];
     } else {
         $writer_level = 0;
     }
     // Include 사용 level check
     if ($this->allow_level > $writer_level) {
         return "";
     }
     $args['includeTopSectionLevel'] = 999;
     $args['outdentation'] = 0;
     $included = $this->wiki_include_nojs($args, &$params);
     if (isset($args['partialnocache']) || isset($args['pnc'])) {
         $options = wiki_json_encode($args);
         return '<nocache plugin="include" method="cache_render" params="' . addslashes($options) . '">' . $included . '</nocache>';
     } else {
         return $included;
     }
 }
Esempio n. 14
0
$thumb_height = 30;
$f = $media->getFile($loc, $source);	
if($f['img_width']) {
	$thumb_path = $thumb->getMediaThumb($ns=$loc, $filename=$f['source'], $thumb_width, $thumb_height, $quality=90, $crop=true);
	$f['thumb'] = $thumb_path;
} else $f['thumb'] = "";

preg_match("/\.([a-zA-Z0-9]{2,4})$/", $f['source'], $m);
if($m[1] && file_exists(WIKI_PATH.'/imgs/media_manager/ext/'.strtolower($m[1]).'.png')) {		
	$f['ext_icon'] = $wiki['url'].'/imgs/media_manager/ext/'.strtolower($m[1]).'.png';			
} else $f['ext_icon'] = $wiki['url'].'/imgs/media_manager/ext/_blank.png';

$f['code'] = 1;
$f['filesize'] = wiki_file_size($f['filesize']);

$json = wiki_json_encode($f);
	
wiki_set_option("uploading", $file, null);

// uploading 이 기록된 시간이 6시간 이전이면..
// (6시간 이전에 파일 올리다 중단된 것이면)
// 삭제
$ctime = time();
$expire = 6*60*60; // 6시간
$not_completed_files = wiki_get_option("uploading");
if(!empty($not_completed_files)) {
	foreach($not_completed_files as $file => $timestamp) {	
		if($ctime - $timestamp > $expire) {		
			$deleted = $media->deleteUnusedFile($file);
			unset($not_completed_files[$file]);
		}
Esempio n. 15
0
<?
/**
 * 
 * 문서 검색 응답 (by toolbar)
 *
 * @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(wiki_is_euckr()) $find_doc = iconv("UTF-8", "CP949", rawurldecode($find_doc)); 

$sql = "SELECT * FROM ".$wiki['write_table']." AS wt 
			  LEFT JOIN ".$wiki['nsboard_table']." AS nt ON nt.bo_table = '".$wiki['bo_table']."' AND wt.wr_id = nt.wr_id 
			  WHERE nt.ns <> '' AND wt.wr_subject LIKE '%$find_doc%'";
$result = wiki_sql_list($sql);
$list = array();
foreach($result as $idx => $v) {
	array_push($list, array("folder"=>$v['ns'], "docname"=>$v['wr_subject']));
}

echo wiki_json_encode($list);

?>
Esempio n. 16
0
	$from_record = ($page - 1) * $page_rows;
	$sql = "SELECT nb.wr_id, nb.ns, wb.wr_subject AS doc, wb.* FROM ".$wiki['nsboard_table']." AS nb
					LEFT JOIN ".$wiki['write_table']." AS wb 
						ON wb.wr_id = nb.wr_id
					WHERE nb.bo_table = '".$wiki['bo_table']."' 					
					ORDER BY id LIMIT $from_record, $page_rows";	
	$res = sql_query($sql);
	$idx = 0;
	$wikiCache =& wiki_class_load("Cache");
	
	$wikiParser =& wiki_class_load("Parser");	
	while($write = sql_fetch_array($res)) {		
		if(!$write['wr_id']) { $idx++; continue; }
		$content = $wikiParser->parse($write);
		$wikiCache->update($write['wr_id'], $content);
		$idx++;
	}
	if($idx < $page_rows) {
		list($file_size, $file_count) = wiki_dir_filesize(WIKI_PATH.'/data/'.$bo_table.'/thumb');
		echo wiki_json_encode(array('code'=>100, 'file_size'=>wiki_file_size($file_size), 'file_count'=>$file_count)); 		// 더이상 없음
	} else {
		echo wiki_json_encode(array('code'=>1, 'total'=>$total, 'from'=>$from_record, 'to'=>($from_record+$page_rows)));
	}
	
	exit;
}

?>