OSDN Git Service

BugTrack2/122: tempnam() fails when open_basedir is specified in php.ini
[pukiwiki/pukiwiki.git] / plugin / touchgraph.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: touchgraph.inc.php,v 1.10 2005/12/18 15:28:55 henoheno Exp $
4 //
5 // Output an index for 'TouchGraph WikiBrowser'
6 // http://www.touchgraph.com/
7 //
8 // Usage: (Check also TGWikiBrowser's sample)
9 //    java -Dfile.encoding=EUC-JP \
10 //    -cp TGWikiBrowser.jar;BrowserLauncher.jar com.touchgraph.wikibrowser.TGWikiBrowser \
11 //    http://<pukiwiki site>/index.php?plugin=touchgraph \
12 //    http://<pukiwiki site>/index.php? FrontPage 2 true
13 //
14 // Note: -Dfile.encoding=EUC-JP (or UTF-8) may not work with Windows OS
15 //   http://www.simeji.com/wiki/pukiwiki.php?Java%A4%CE%CD%AB%DD%B5 (in Japanese)
16
17
18 function plugin_touchgraph_action()
19 {
20         global $vars;
21
22         pkwk_headers_sent();
23         header('Content-type: text/plain');
24         if (isset($vars['reverse'])) {
25                 plugin_touchgraph_ref();
26         } else {
27                 plugin_touchgraph_rel();
28         }
29         exit;
30 }
31
32 // Normal
33 function plugin_touchgraph_rel()
34 {
35         foreach (get_existpages() as $page) {
36                 if (check_non_list($page)) continue;
37
38                 $file = CACHE_DIR . encode($page) . '.rel';
39                 if (file_exists($file)) {
40                         echo $page;
41                         $data = file($file);
42                         foreach(explode("\t", trim($data[0])) as $name) {
43                                 if (check_non_list($name)) continue;
44                                 echo ' ', $name;
45                         }
46                         echo "\n";
47                 }
48         }
49 }
50
51 // Reverse
52 function plugin_touchgraph_ref()
53 {
54         foreach (get_existpages() as $page) {
55                 if (check_non_list($page)) continue;
56
57                 $file = CACHE_DIR . encode($page) . '.ref';
58                 if (file_exists($file)) {
59                         echo $page;
60                         foreach (file($file) as $line) {
61                                 list($name) = explode("\t", $line);
62                                 if (check_non_list($name)) continue;
63                                 echo ' ', $name;
64                         }
65                         echo "\n";
66                 }
67         }
68 }
69 ?>