차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판이전 판다음 판 | 이전 판 | ||
tech:randompage [2013/07/09 23:15] – V_L | tech:randompage [2016/07/12 09:26] (현재) – 바깥 편집 127.0.0.1 | ||
---|---|---|---|
줄 1: | 줄 1: | ||
+ | {{tag> | ||
+ | ======랜덤페이지 (Randompage) 플러긴====== | ||
+ | |||
+ | 랜덤페이지 플러긴이다. 네임스페이스 지원하도록 약간 수정했다. | ||
+ | 다른 위키엔진들은 대부분 기본 기능인데;; | ||
+ | (원작: https:// | ||
+ | |||
+ | 아래의 파일을 받아서 '' | ||
+ | |||
+ | ? | ||
+ | 혹은 | ||
+ | ? | ||
+ | 하면 된다. | ||
+ | |||
+ | * [[? | ||
+ | * [[? | ||
+ | |||
+ | |||
+ | This supports namespaces. | ||
+ | |||
+ | <file php action.php> | ||
+ | <?php | ||
+ | /** | ||
+ | * @license | ||
+ | * @author | ||
+ | */ | ||
+ | |||
+ | require_once(DOKU_PLUGIN.' | ||
+ | |||
+ | class action_plugin_randompage extends Dokuwiki_Action_Plugin { | ||
+ | |||
+ | /** | ||
+ | * Register its handlers with the dokuwiki' | ||
+ | */ | ||
+ | function register(& | ||
+ | $controller-> | ||
+ | } | ||
+ | |||
+ | function init(& | ||
+ | { | ||
+ | // Catch the good request | ||
+ | if ($_REQUEST[' | ||
+ | // On efface les headers par defaut | ||
+ | if ($args == ' | ||
+ | $this-> | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | function action_randompage(& | ||
+ | |||
+ | global $conf; | ||
+ | global $ID; | ||
+ | global $INFO; | ||
+ | |||
+ | $data = array(); | ||
+ | $dir = $conf[' | ||
+ | |||
+ | $data = file ($dir.'/ | ||
+ | |||
+ | //if current page is in | ||
+ | function isCurNS($value){ | ||
+ | global $INFO; | ||
+ | return stripos($value, | ||
+ | } | ||
+ | |||
+ | if ($INFO[' | ||
+ | $data=array_filter($data," | ||
+ | } | ||
+ | | ||
+ | //We loops through ten random page... | ||
+ | $i = 1; | ||
+ | while ($i <= 10 & $i <> " | ||
+ | //echo $i; | ||
+ | $i++; | ||
+ | |||
+ | $id = rtrim($data[array_rand($data)]); | ||
+ | $testACL = auth_aclcheck($id, | ||
+ | |||
+ | if (($testACL > 1) and (file_exists(wikiFN($id)))){ | ||
+ | $i=" | ||
+ | //echo $id; | ||
+ | } | ||
+ | |||
+ | endwhile; | ||
+ | |||
+ | if ($testACL < 1){ | ||
+ | $id = $ID; | ||
+ | } | ||
+ | |||
+ | header(" | ||
+ | //echo wl($page,'', | ||
+ | exit(); | ||
+ | } | ||
+ | |||
+ | // | ||
+ | function array_rand($array, | ||
+ | mt_srand((double) microtime() * 1000000); | ||
+ | for($a=0; $a< | ||
+ | $num[] = mt_srand(0, count($array)-1); | ||
+ | } | ||
+ | return @$num; | ||
+ | } | ||
+ | }</ | ||
+ | |||
+ | ^ 누구나 수정하실 수 있다. [[http:// | ||
+ | |||