<? /** * * 에디터 미리보기 스크립트 * * @package narinwiki * @subpackage pages * @license GPL2 (http://narinwiki.org/license) * @author byfun (http://byfun.com) * @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();
header("Cache-Control: no-store, no-cache, must-revalidate"); 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++;
/** * * 미디어 파일 목록 * * @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) { 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;
/** * * AJAX 통신으로 받은 데이터 변환 * * euc-kr 일 경우, 인코딩 변환이 필요함 * * @param string $data 변환할 데이터 * @return string 변환된 데이터 */ function wiki_ajax_data($data) { if(is_array($data)) { foreach($data as $k => $v) { $data[$k] = wiki_ajax_data($v); } return $data; } if(wiki_is_euckr()) { return iconv("UTF-8", "CP949", rawurldecode($data)); } return $data; }
/** * * 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)); }
/** * * 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; }
* 미디어 파일 등록 * * @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 || !$source || !$file) wiki_ajax_error(); $loc = wiki_ajax_data($loc); $file = wiki_ajax_data($file); $source = wiki_ajax_data($source); $media =& wiki_class_load("Media"); $thumb =& wiki_class_load("Thumb"); $ns = $media->getNS($loc); if($ns['ns_access_level'] > $member['mb_level'] || $ns['ns_upload_level'] > $member['mb_level']) { echo "권한이 없습니다."; exit; } $media->addFile($loc, $source, $file); $thumb_width = 30; $thumb_height = 30; $f = $media->getFile($loc, $source);
* * 미디어 파일 삭제 * * @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 || !$file) wiki_ajax_error(); $loc = wiki_ajax_data($loc); $file = wiki_ajax_data($file); $media =& wiki_class_load("Media"); $file_info = $media->getFile($loc, $file); if(!$file_info) { $ret = array('code'=>'-1', 'msg'=>'파일 정보가 없습니다.'); echo wiki_json_encode($ret); exit; } // 권한 검사 if($file_info['mb_id'] != $member['mb_id'] && !$is_wiki_admin) { $ret = array('code'=>'-1', 'msg'=>'권한이 없습니다.'); echo wiki_json_encode($ret); exit;