OSDN Git Service

BugTrack2/62: Do remove the whole design, 'Showing TrackBack-ping list by html'.
[pukiwiki/pukiwiki.git] / plugin / versionlist.inc.php
1 <?php
2 // $Id: versionlist.inc.php,v 1.15 2005/01/29 02:12:52 henoheno Exp $
3 /*
4  * PukiWiki versionlist plugin
5  *
6  * CopyRight 2002 S.YOSHIMURA GPL2
7  * http://masui.net/pukiwiki/ yosimura@excellence.ac.jp
8  */
9
10 function plugin_versionlist_action()
11 {
12         global $_title_versionlist;
13
14         if (PKWK_SAFE_MODE) die_message('PKWK_SAFE_MODE prohibits this');
15
16         return array(
17                 'msg' => $_title_versionlist,
18                 'body' => plugin_versionlist_convert());
19 }
20
21 function plugin_versionlist_convert()
22 {
23         if (PKWK_SAFE_MODE) return ''; // Show nothing
24         
25         /* Ãµº÷¥Ç¥£¥ì¥¯¥È¥êÀßÄê */
26         $SCRIPT_DIR = array('./');
27         if (LIB_DIR   != './') array_push($SCRIPT_DIR, LIB_DIR);
28         if (DATA_HOME != './' && DATA_HOME != LIB_DIR) array_push($SCRIPT_DIR, DATA_HOME);
29         array_push($SCRIPT_DIR, PLUGIN_DIR, SKIN_DIR);
30
31         $comments = array();
32
33         foreach ($SCRIPT_DIR as $sdir)
34         {
35                 if (!$dir = @dir($sdir))
36                 {
37                         // die_message('directory '.$sdir.' is not found or not readable.');
38                         continue;
39                 }
40                 while($file = $dir->read())
41                 {
42                         if (!preg_match("/\.(php|lng|css|js)$/i",$file))
43                         {
44                                 continue;
45                         }
46                         $data = join('',file($sdir.$file));
47                         $comment = array('file'=>htmlspecialchars($sdir.$file),'rev'=>'','date'=>'');
48                         if (preg_match('/\$'.'Id: (.+),v (\d+\.\d+) (\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2})/',$data,$matches))
49                         {
50 //                              $comment['file'] = htmlspecialchars($sdir.$matches[1]);
51                                 $comment['rev'] = htmlspecialchars($matches[2]);
52                                 $comment['date'] = htmlspecialchars($matches[3]);
53                         }
54                         $comments[$sdir.$file] = $comment;
55                 }
56                 $dir->close();
57         }
58         if (count($comments) == 0)
59         {
60                 return '';
61         }
62         ksort($comments);
63         $retval = '';
64         foreach ($comments as $comment)
65         {
66                 $retval .= <<<EOD
67
68   <tr>
69    <td>{$comment['file']}</td>
70    <td align="right">{$comment['rev']}</td>
71    <td>{$comment['date']}</td>
72   </tr>
73 EOD;
74         }
75         $retval = <<<EOD
76 <table border="1">
77  <thead>
78   <tr>
79    <th>filename</th>
80    <th>revision</th>
81    <th>date</th>
82   </tr>
83  </thead>
84  <tbody>
85 $retval
86  </tbody>
87 </table>
88 EOD;
89         return $retval;
90 }
91 ?>