OSDN Git Service

インストーラ開始時にPermissionチェック追加
authorCake <cake_67@users.sourceforge.jp>
Fri, 16 Apr 2010 10:13:41 +0000 (19:13 +0900)
committerCake <cake_67@users.sourceforge.jp>
Fri, 16 Apr 2010 10:13:41 +0000 (19:13 +0900)
app/plugins/install/controllers/install_controller.php
app/plugins/install/views/install/index.ctp

index e946f6d..9c33b1e 100644 (file)
@@ -53,6 +53,49 @@ class InstallController extends InstallAppController {
  * @return void
  */
     function index() {
+
+       // file/dir check
+       $error = array();
+       $permissions = array(
+               array(
+                       'path' => APP.'config', 
+                       'type' => 'dir',
+               ),
+               array(
+                       'path' => TMP, 
+                       'type' => 'dir',
+               ),
+               array(
+                       'path' => WWW_ROOT. 'media', 
+                       'type' => 'dir',
+               ),
+       );
+
+       // check file_exists
+       if (!file_exists(APP.'config'.DS.'database.php.install') || !is_readable(APP.'config'.DS.'database.php.install')) {
+               $error['nofile'][] = APP.'config'.DS.'database.php.install';
+       } else {
+               $permissions[] = array(
+                       'path' => APP.'config'.DS.'database.php.install', 
+                       'type' => 'file',
+               );
+       }
+
+       // check permission
+       foreach ($permissions as $k => $v) {
+               $allowed = array();
+               if ($v['type'] == 'dir') {
+                       $allowed = array('0777', '0707');
+               } elseif ($v['type'] == 'file') {
+                       $allowed = array('0777', '0707', '0666', '0606');
+               } 
+
+               if (!in_array(substr(sprintf('%o', fileperms($v['path'])), -4), $allowed)) {
+                       $error['permission'][] = $v['path'];
+               }
+       }
+       $this->set('error', $error);
+
         $this->pageTitle = __('Installation: Welcome', true);
     }
 /**
index 659d7d2..48c1464 100644 (file)
@@ -1,4 +1,28 @@
 <div class="install index">
     <h2><?php echo $this->pageTitle; ?></h2>
+<?php if (!empty($error)): ?>
+
+<?php echo $html->div('message', 'ERROR') ?>
+<?php if (isset($error['nofile'])): ?>
+<?php __('Set below Files.'); ?>
+<?php 
+       foreach($error['nofile'] as $v) {
+               echo $html->div('error-message', $v);
+       }
+ ?>
+ <?php endif; ?>
+<?php if(isset($error['permission'])): ?>
+<?php __('Check Permission of them.'); ?>
+<?php 
+       foreach($error['permission'] as $v) {
+               echo $html->div('error-message', $v);
+       }
+ ?>
+<br>
+<br>
+<?php echo $html->link(__('Reload', true), Router::url('/', true)); ?>
+<?php endif; ?>
+<?php else: ?>
     <p><?php echo $html->link('Click here to begin installation', array('action' => 'database')); ?></p>
+<?php endif; ?>
 </div>