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']; } $ploc = wiki_get_parent_path($loc); $pNS = $media->getNS($ploc); $ret = array('code'=>1, 'files'=>$files, 'parent_mkdir_level'=>$pNS['ns_mkdir_level'], 'mkdir_level'=>$ns['ns_mkdir_level'], 'upload_level'=>$ns['ns_upload_level'], 'access_level'=>$ns['ns_access_level']); echo wiki_json_encode($ret); ?>
/** * * 메모리 사용 디버그용 * * @param string $s 출력메시지 prefix */ function wiki_print_memory($s) { global $is_admin; if($is_admin) wiki_print($s ." : " . wiki_file_size(memory_get_usage()) . " (peak=" . wiki_file_size(memory_get_peak_usage()).")"); }
/** * * 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; }
$thumb_width = 30; $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);
#admbasic td { padding-left: 5px; } #progress { position:absolute;margin-top:5px;margin-left:10px; color:#0000AA} </style> <div class="list_table"> <table id="admbasic" cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <th scope="row">생성된 썸네일 총 크기</th> <td id="file_size"><?php echo wiki_file_size($file_size); ?> </td> </tr> <tr> <th scope="row">생성된 썸네일 총 개수</th> <td id="file_count"><?php echo $file_count; ?> 파일</td> </tr> <tr> <td> </td> <td> <span class="button red"><input type="submit" id="cache_clear" value="썸네일 및 문서 캐시 초기화" /></span> <span id="progress"></span>
$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; } ?>