• R/O
  • SSH
  • HTTPS

websvn-admin: Commit


Commit MetaInfo

Revision9 (tree)
Time2011-01-20 23:11:18
Authorinoue-h

Log Message

既存リポジトリ操作追加

Change Summary

Incremental Difference

--- trunc/style.css (revision 8)
+++ trunc/style.css (revision 9)
@@ -26,6 +26,22 @@
2626 width: 625px;
2727 }
2828
29+/* フッター */
30+div#footer {
31+ width: 795px;
32+ text-align: center;
33+ color: gray;
34+ border-top: 1px solid lightgray;
35+}
36+
37+/* 回りこみ解除 */
38+div.clear {
39+ clear:both;
40+ display:block;
41+ visibility:hidden;
42+}
43+
44+
2945 h1 {
3046 font-size: 20px;
3147 color: gray;
@@ -85,6 +101,10 @@
85101 }
86102
87103
104+#footer a {
105+ color: gray;
106+}
107+
88108 /* 入力ボックス */
89109 input, select {
90110 padding:1px;
@@ -96,7 +116,13 @@
96116 background-color:#e0e0e0;
97117 }
98118
119+/* ボタンを横一列に並べる */
120+form.horiz {
121+ display: inline;
122+ border: none;
123+}
99124
125+
100126 /* 行先頭に インフォメーション アイコン */
101127 p.info {
102128 background: url(icon-info.png) center left no-repeat;
--- trunc/index.php (revision 8)
+++ trunc/index.php (revision 9)
@@ -2,6 +2,7 @@
22 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
33 <?php
44
5+$strVersion = '0.2'; // 画面に表示するバージョン
56 // ******************************************************
67 // Software name : WebSVN Administrator
78 //
@@ -40,7 +41,7 @@
4041 <script type="text/javascript" src="../utf.js"></script>
4142 <script type="text/javascript" src="../md5.js"></script>
4243 <script type="text/javascript" src="../authpage_form_md5.js"></script>
43-
44+
4445 </head>
4546 <body>
4647
@@ -94,75 +95,42 @@
9495 ?>
9596 <div id="main_content_left">
9697 <h2>System</h2>
97-<p><?php echo date('Y/m/d H:i:s', time()) ; ?></p>
98-<p>SVN <?php echo get_svn_version(); ?></p>
98+<p><?php echo date('Y/m/d H:i:s', time()) ; ?><br />
99+WebSVN-Admin &nbsp;<?php echo $strVersion; ?><br />
100+Subversion &nbsp;<?php echo get_svn_version(); ?></p>
99101 <h2>Menu</h2>
100102 <ul>
101103 <li><a href="<?php echo $strFilenameThis;?>">Home</a></li>
104+<li><a href="<?php echo $strFilenameThis;?>?mode=backuplist">Backup Catalog</a></li>
102105 <li><a href="<?php echo $strFilenameThis; ?>?mode=chgpasswd">Change Password</a></li>
103106 <li><a href="<?php echo $strFilenameThis; ?>?mode=logout">Logout</a></li>
104107 </ul>
105108 <h2>Repositories</h2>
106-<ul>
107109 <?php
108110
109111 // *********************
110112 // 既存リポジトリ一覧を表示(左側ペイン)
111113 // *********************
112- if ($dir = opendir($strBaseDir)) {
113- while (($file = readdir($dir)) !== false) {
114- if ($file != "." && $file != ".." && is_dir($strBaseDir.$file)) {
115- print "<li class=\"repo\"><a class=\"repo\" href=\"$strFilenameThis?mode=inforepo&reponame=".htmlspecialchars($file)."\">".htmlspecialchars($file)."</a></li>\n";
116- }
117- }
118- closedir($dir);
119- }
114+display_repositories();
115+
120116 ?>
121-</ul>
122117 </div> <!-- id="main_content_left" -->
123118 <div id="main_content_right">
124119
125120 <?php
126121
127-
128122 // *********************
123+// バックアップディレクトリの一覧
124+// *********************
125+if(isset($_GET['mode']) && $_GET['mode'] === 'backuplist'){
126+ display_backup_list();
127+}
128+// *********************
129129 // 新規リポジトリ作成
130130 // *********************
131-if(isset($_GET['mode']) && $_GET['mode'] === 'makerepo' &&
132- isset($_POST['newrepo']) && strlen($_POST['newrepo'])>0){
133- // 新規リポジトリ作成(リポジトリ名が与えられた場合)
134- $strNewRepo = trim($_POST['newrepo']);
135- print("<h1>Create New Repository (リポジトリ作成)</h1>\n");
136- print("<p class=\"info\">新しいリポジトリ『".htmlspecialchars($strNewRepo)."』が有効なディテクトリ名かチェック中 ...</p>\n");
137-
138- if(preg_match("/^[A-Za-z0-9\-]+$/", $strNewRepo) && $strNewRepo[0] != '-' && $strNewRepo[strlen($strNewRepo)-1] != '-' && strlen($strNewRepo) <= 20){
139- if(file_exists($strBaseDir.$strNewRepo) || is_dir($strBaseDir.$strNewRepo)){
140- print("<p class=\"error\">指定されたリポジトリ名はすでに存在するディレクトリかファイル名です</p>");
141- }
142- else{
143- print("<p class=\"info\">リポジトリ作成コマンド実行中 (svnamin create ".htmlspecialchars($strNewRepo).") ...</p>");
144-// $strResult = system("/home/tmg1136-inue/local/bin/svnadmin create ".$strBaseDir.$strNewRepo." 2>&1", $nResult);
145- exec($strSvnCmdPath."svnadmin create ".$strBaseDir.$strNewRepo." 2>&1", $arrStdout, $nResult);
146-
147- // 結果判定
148- if($nResult == 0){ print("<p class=\"ok\">コマンドが正しく実行されました</p>\n"); }
149- else{ print("<p class=\"error\">実行エラー</p>\n"); }
150-
151- // コマンドのStdout出力がある場合
152- if(count($arrStdout)>0){
153- print("<pre>\n\n");
154- foreach($arrStdout as $str){
155- print($str."\n");
156- }
157- print("</pre>\n");
158- }
159-
160- }
161- }
162- else{
163- print("<p class=\"error\">指定されたリポジトリ名が、命名規則から外れています。<br />20文字を越える、許容文字(A-Z,a-z,0-9,-)以外、先頭末尾に - など</p>");
164- }
165-
131+elseif(isset($_GET['mode']) && $_GET['mode'] === 'makerepo' && isset($_POST['newrepo']) && strlen($_POST['newrepo'])>0){
132+ $strRepo = trim($_POST['newrepo']);
133+ create_new_repository($strRepo);
166134 }
167135 // *********************
168136 // ログアウト
@@ -200,7 +168,7 @@
200168 // *********************
201169 elseif(isset($_GET['mode']) && $_GET['mode'] === 'hotcopy' && isset($_GET['reponame'])){
202170 $strRepo = $_GET['reponame'];
203- hotcopy_repository($strRepo);
171+ hotcopy_repository($strRepo, 0);
204172 }
205173 // *********************
206174 // 既存リポジトリのバックアップ(dump)
@@ -210,11 +178,67 @@
210178 dump_repository($strRepo);
211179 }
212180 // *********************
181+// リポジトリの削除
182+// *********************
183+elseif(isset($_GET['mode']) && $_GET['mode'] === 'remove' && isset($_GET['reponame'])){
184+ $strRepo = $_GET['reponame'];
185+ remove_repository($strRepo);
186+}
187+// *********************
213188 // 新規リポジトリ作成 入力画面
214189 // *********************
215190 else{
216191 // 引数が何もなかった場合、新規リポジトリ名の入力画面を表示
192+ input_new_repository();
193+}
194+
217195 ?>
196+</div> <!-- id="main_content_right" -->
197+<p>&nbsp;</p>
198+<div class="clear"></div>
199+<div id="footer">
200+<p><a href="http://sourceforge.jp/projects/websvn-admin/">WebSVN-Admin</a> version <?php echo $strVersion; ?> &nbsp;&nbsp; GNU GPL free software</p>
201+</div> <!-- id="footer" -->
202+
203+</body>
204+</html>
205+<?php
206+
207+exit();
208+
209+// *********************
210+// 既存リポジトリ一覧を表示(左側ペイン)
211+// *********************
212+function display_repositories() {
213+ global $strBaseDir;
214+
215+ $arrDirs = array();
216+ if ($dir = opendir($strBaseDir)) {
217+ while (($file = readdir($dir)) !== false) {
218+ if ($file != "." && $file != ".." && is_dir($strBaseDir.$file)) {
219+ array_push($arrDirs, $file);
220+ }
221+ }
222+ closedir($dir);
223+ }
224+
225+ sort($arrDirs);
226+
227+ print("<ul>\n");
228+ foreach($arrDirs as $val){
229+ print "<li class=\"repo\"><a class=\"repo\" href=\"$strFilenameThis?mode=inforepo&amp;reponame=".htmlspecialchars($val)."\">".htmlspecialchars($val)."</a></li>\n";
230+ }
231+ print("</ul>\n");
232+
233+}
234+
235+
236+// *********************
237+// 新規リポジトリ名入力画面
238+// *********************
239+function input_new_repository() {
240+?>
241+
218242 <h1>Create New Repository (リポジトリ作成)</h1>
219243 <p>svnadmin create コマンドを実行して新しいリポジトリを作成します。</p>
220244 <p>&nbsp;</p>
@@ -224,11 +248,53 @@
224248 <p style="color:gray;">リポジトリ名には半角アルファベット・数字・横線(A-Z, a-z, 0-9, -)のみ利用できます。<br />
225249 また、既存のリポジトリ名と同じリポジトリは作成できません。</p>
226250 </form>
251+
227252 <?php
228253 }
229254
230255
231256 // *********************
257+// 新規リポジトリ作成
258+// *********************
259+function create_new_repository($strRepo) {
260+ global $strSvnCmdPath;
261+ global $strBaseDir;
262+
263+ print("<h1>Create New Repository (リポジトリ作成)</h1>\n");
264+ print("<p class=\"info\">新しいリポジトリ『".htmlspecialchars($strRepo)."』が有効なディテクトリ名かチェック中 ...</p>\n");
265+
266+ // リポジトリ名に不正な文字が入っていないか検査
267+ if(!preg_match("/^[A-Za-z0-9\-]+$/", $strRepo) || $strRepo[0] == '-' || $strRepo[strlen($strRepo)-1] == '-' || strlen($strRepo) > 20 || strlen($strRepo) <= 0){
268+ print("<p class=\"error\">指定されたリポジトリ名が、命名規則から外れています。<br />20文字を越える、許容文字(A-Z,a-z,0-9,-)以外、先頭末尾に - など</p>");
269+ return;
270+ }
271+
272+ // すでに存在するディレクトリ名は却下
273+ if(file_exists($strBaseDir.$strRepo)){
274+ print("<p class=\"error\">指定されたリポジトリ名はすでに存在するディレクトリかファイル名です</p>");
275+ return;
276+ }
277+
278+ // 新規リポジトリ作成
279+ print("<p class=\"info\">リポジトリ作成コマンド実行中 (svnamin create ".htmlspecialchars($strRepo).") ...</p>");
280+ exec($strSvnCmdPath."svnadmin create ".$strBaseDir.$strRepo." 2>&1", $arrStdout, $nResult);
281+
282+ // 結果判定
283+ if($nResult == 0){ print("<p class=\"ok\">コマンドが正しく実行されました</p>\n"); }
284+ else{ print("<p class=\"error\">実行エラー</p>\n"); }
285+
286+ // コマンドのStdout出力がある場合
287+ if(count($arrStdout)>0){
288+ print("<pre>\n\n");
289+ foreach($arrStdout as $str){
290+ print($str."\n");
291+ }
292+ print("</pre>\n");
293+ }
294+
295+}
296+
297+// *********************
232298 // 既存リポジトリの情報表示(バックアップ、削除サブメニュー表示)
233299 // *********************
234300 function info_repository($strRepo) {
@@ -277,12 +343,18 @@
277343 print("<p>直近のコミット日時 : ".$strDate."</p>\n");
278344 print("<p>リビジョン no : ".$strRevNo."</p>\n");
279345
280- print("<p><a class=\"repo\" href=\"$strFilenameThis?mode=verify&reponame=".htmlspecialchars($strRepo)."\">".htmlspecialchars($strRepo)." をベリファイする (svnadmin verify)</a></p>\n");
281- print("<p><a class=\"repo\" href=\"$strFilenameThis?mode=recover&reponame=".htmlspecialchars($strRepo)."\">".htmlspecialchars($strRepo)." のエラー回復を行う (svnadmin recover)</a></p>\n");
282- print("<p><a class=\"repo\" href=\"$strFilenameThis?mode=hotcopy&reponame=".htmlspecialchars($strRepo)."\">".htmlspecialchars($strRepo)." をバックアップする (svnadmin hotcopy)</a></p>\n");
283- print("<p><a class=\"repo\" href=\"$strFilenameThis?mode=dump&reponame=".htmlspecialchars($strRepo)."\">".htmlspecialchars($strRepo)." をバックアップ(ダンプ)する (svnadmin dump)</a></p>\n");
284- print("<p><a class=\"repo\" href=\"$strFilenameThis?mode=remove&reponame=".htmlspecialchars($strRepo)."\">".htmlspecialchars($strRepo)." を削除する</a></p>\n");
285-
346+ $arrCmd = array(
347+ array('verify', 'ベリファイ'),
348+// array('recover', 'エラー回復'),
349+ array('hotcopy', 'バックアップ(Hotcopy)'),
350+ array('dump', 'バックアップ(Dump)'),
351+ array('remove', '削除'),
352+ );
353+
354+ foreach($arrCmd as $val){
355+ print("<form method=\"post\" action=\"./".$strFilenameThis."?mode=".$val[0]."&amp;reponame=".htmlspecialchars($strRepo)."\" name=\"form1\" class=\"horiz\"><input type=\"submit\" value=\"".$val[1]."\" /></form>\n");
356+ }
357+
286358 }
287359
288360 // *********************
@@ -325,13 +397,15 @@
325397 // *********************
326398 // 既存リポジトリのバックアップ(hotcopy)
327399 // *********************
328-function hotcopy_repository($strRepo) {
400+function hotcopy_repository($strRepo, $flag_mode) {
329401 global $strSvnCmdPath;
330402 global $strBaseDir;
331403 global $strBackupDir;
332404
333- print("<h1>Backup (hotcopy) Repository (バックアップ : hotcopy)</h1>\n");
334- print("<p>リポジトリ名 : ".htmlspecialchars($strRepo)."</p>\n");
405+ if($flag_mode == 0){
406+ print("<h1>Backup (hotcopy) Repository (バックアップ : hotcopy)</h1>\n");
407+ print("<p>リポジトリ名 : ".htmlspecialchars($strRepo)."</p>\n");
408+ }
335409
336410 // リポジトリ名に不正な文字が入っていないか検査
337411 if(!preg_match("/^[A-Za-z0-9\-]+$/", $strRepo) || $strRepo[0] == '-' || $strRepo[strlen($strRepo)-1] == '-' || strlen($strRepo) > 20 || strlen($strRepo) <= 0){
@@ -415,6 +489,77 @@
415489 }
416490
417491 // *********************
492+// リポジトリの削除
493+// *********************
494+function remove_repository($strRepo) {
495+ global $strSvnCmdPath;
496+ global $strBaseDir;
497+
498+ print("<h1>Remove Repository (リポジトリ削除)</h1>\n");
499+ print("<p>リポジトリ名 : ".htmlspecialchars($strRepo)."</p>\n");
500+
501+ // リポジトリ名に不正な文字が入っていないか検査
502+ if(!preg_match("/^[A-Za-z0-9\-]+$/", $strRepo) || $strRepo[0] == '-' || $strRepo[strlen($strRepo)-1] == '-' || strlen($strRepo) > 20 || strlen($strRepo) <= 0){
503+ print("<p class=\"error\">不正なリポジトリ名が指定されました</p>\n");
504+ return;
505+ }
506+
507+ // バックアップ(hotcopy)
508+ print("<p class=\"info\">削除前に、バックアップを行います</p>\n");
509+ hotcopy_repository($strRepo, 1);
510+
511+ print("<p>コマンド実行中 ... (rm -rfv ".htmlspecialchars($strRepo).")</p>\n");
512+
513+ // 削除
514+ exec("rm -rfv ".$strBaseDir.$strRepo." 2>&1", $arrStdout, $nResult);
515+ if($nResult != 0){
516+ print("<p class=\"error\">削除に失敗しました</p>\n");
517+ return;
518+ }
519+ // コマンドのStdout出力がある場合
520+ if(count($arrStdout)>0){
521+ print("<pre>\n\n");
522+ print("$ rm -rfv ".htmlspecialchars($strRepo)."\n\n");
523+ foreach($arrStdout as $str){
524+ print($str."\n");
525+ }
526+ print("</pre>\n");
527+ }
528+ print("<p class=\"ok\">削除が完了しました</p>\n");
529+
530+}
531+
532+
533+// *********************
534+// バックアップ一覧を表示する
535+// *********************
536+function display_backup_list() {
537+ global $strBackupDir;
538+
539+ print("<h1>Backup Catalog</h1>\n");
540+
541+ $arrDirs = array();
542+ if ($dir = opendir($strBackupDir)) {
543+ while (($file = readdir($dir)) !== false) {
544+ if ($file != "." && $file != "..") {
545+ array_push($arrDirs, $file);
546+ }
547+ }
548+ closedir($dir);
549+ }
550+
551+ sort($arrDirs);
552+
553+ print("<ul>\n");
554+ foreach($arrDirs as $val){
555+ print "<li>".htmlspecialchars($val)."</li>\n";
556+ }
557+ print("</ul>\n");
558+
559+}
560+
561+
562+// *********************
418563 // svnコマンドのバージョン番号(文字列)を返す関数
419564 // *********************
420565 function get_svn_version() {
@@ -433,9 +578,4 @@
433578 }
434579 ?>
435580
436-</div> <!-- id="main_content_right" -->
437-<p>&nbsp;</p>
438581
439-</body>
440-</html>
441-
Show on old repository browser