OSDN Git Service

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