<? /** * * 임시 저장 삭제 * * @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); ?>
/** * * 위키 옵션 설정 * * @uses 옵션 설정/업데이트 : wiki_set_option("js_modified", "timestamp", time()); * @uses 옵션 삭제 : wiki_set_option("js_modified", null, null); * @uses 한 옵션에 여러 필드 설정 : wiki_set_option("multi", array("field1", "field2"), array("value1", "value2")); * @uses 한 필드만 업데이트 : wiki_set_option("multi", "field1", "value1-2"); * * @param string $name 옵션명 * @param string $field 옵션 필드명 * @param mixed $value 값 */ function wiki_set_option($name, $field, $value) { global $wiki; $eName = mysql_real_escape_string($name); if($field == null && $value == null) { sql_query("DELETE FROM ".$wiki['option_table']." WHERE name = '/".$wiki['bo_table']."/$eName'"); return true; } $opt = wiki_get_option($name); if($value == null && $opt) { unset($opt[$field]); $json_string = mysql_real_escape_string(json_encode($opt)); $sql = "UPDATE ".$wiki['option_table']." SET content = '$json_string' WHERE name = '/".$wiki['bo_table']."/$eName'"; sql_query($sql); return true; } if($opt) { // 저장된 옵션이 있다면 수정 // 필드와 값이 모두 배열이면.. if(is_array($field) && is_array($value)) { // 필드와 값이 갯수가 같아야 함 if(count($field) != count($value)) return false; for($i=0; $i<count($field); $i++) { $opt[$field[$i]] = $value[$i]; } } else if(!is_array($field) && !is_array($value)) { $opt[$field] = $value; } else return false; $json_string = mysql_real_escape_string(json_encode($opt)); $sql = "UPDATE ".$wiki['option_table']." SET content = '$json_string' WHERE name = '/".$wiki['bo_table']."/$eName'"; } else { // 저장된 옵션이 없다면 삽입 if(is_array($field) && is_array($value)) { // 필드와 값이 갯수가 같아야 함 if(count($field) != count($value)) return false; $data = array(); for($i=0; $i<count($field); $i++) { $data[$field[$i]] = $value[$i]; } } else if(!is_array($field) && !is_array($value)) { $data = array("$field"=>$value); } else return false; $json = mysql_real_escape_string(json_encode($data)); $sql = "INSERT INTO ".$wiki['option_table']." VALUES ('/".$wiki['bo_table']."/$eName', '$json')"; } sql_query($sql); return true; }
/** * * 잠겼는가? * * @param string $doc 경로를 포함한 문서명 */ protected function initialize_lock($doc) { if($this->initialized) return; $doc_code = md5($doc); $this->locked = wiki_get_option("locked_docs/$doc_code"); $this->initialized = true; }
$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]); } } $uploading_files = array(); $uploading_times = array(); foreach($not_completed_files as $file => $timestamp) { array_push($uploading_files, $file); array_push($uploading_times, $timestamp); } wiki_set_option("uploading", $uploading_files, $uploading_times); } else {