当前位置: 首页>>代码示例>>PHP>>正文


PHP Toolbox::testWriteAccessToDirectory方法代码示例

本文整理汇总了PHP中Toolbox::testWriteAccessToDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::testWriteAccessToDirectory方法的具体用法?PHP Toolbox::testWriteAccessToDirectory怎么用?PHP Toolbox::testWriteAccessToDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Toolbox的用法示例。


在下文中一共展示了Toolbox::testWriteAccessToDirectory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDir

   public function testDir() {

      // From Toolbox::commonCheckForUseGLPI
      $this->assertTrue(error_log("PHPUnit\n", 3, GLPI_LOG_DIR."/php-errors.log"),
                        "Fail: no write access to ".GLPI_LOG_DIR);
      $this->assertEquals(0, Toolbox::testWriteAccessToDirectory(GLPI_DUMP_DIR),
                          "Fail: no write access to ".GLPI_DUMP_DIR);
      $this->assertEquals(0, Toolbox::testWriteAccessToDirectory(GLPI_DOC_DIR),
                          "Fail: no write access to ".GLPI_DOC_DIR);
      $this->assertEquals(0, Toolbox::testWriteAccessToDirectory(GLPI_CONFIG_DIR),
                          "Fail: no write access to ".GLPI_CONFIG_DIR);
      $this->assertEquals(0, Toolbox::testWriteAccessToDirectory(GLPI_SESSION_DIR),
                          "Fail: no write access to ".GLPI_SESSION_DIR);
      $this->assertEquals(0, Toolbox::testWriteAccessToDirectory(GLPI_CRON_DIR),
                          "Fail: no write access to ".GLPI_CRON_DIR);
      $this->assertEquals(0, Toolbox::testWriteAccessToDirectory(GLPI_CACHE_DIR),
                          "Fail: no write access to ".GLPI_CACHE_DIR);
   }
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:18,代码来源:AllTests.php

示例2: showForm

 /**
  * Print the rssfeed form
  *
  * @param $ID        integer  Id of the item to print
  * @param $options   array    of possible options:
  *     - target filename : where to go when done.
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     // Test _rss cache directory. I permission trouble : unable to edit
     if (Toolbox::testWriteAccessToDirectory(GLPI_RSS_DIR) > 0) {
         echo "<div class='center'>";
         printf(__('Check permissions to the directory: %s'), GLPI_RSS_DIR);
         echo "<p class='red b'>" . __('Error') . "</p>";
         echo "</div>";
         return false;
     }
     $this->initForm($ID, $options);
     $canedit = $this->can($ID, UPDATE);
     $this->showFormHeader($options);
     $rowspan = 4;
     if (!$this->isNewID($ID)) {
         // Force getting feed :
         $feed = self::getRSSFeed($this->fields['url'], $this->fields['refresh_rate']);
         if (!$feed || $feed->error()) {
             $this->setError(true);
         } else {
             $this->setError(false);
         }
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Name') . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, "name", array('entity' => -1, 'user' => $this->fields["users_id"]));
         echo "</td><td colspan ='2'>&nbsp;</td></tr>\n";
     }
     echo "<tr class='tab_bg_1'><td>" . __('URL') . "</td>";
     echo "<td colspan='3'>";
     echo "<input type='text' name='url' size='100' value='" . $this->fields["url"] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('By') . "</td>";
     echo "<td>";
     echo getUserName($this->fields["users_id"]);
     echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>\n";
     echo "</td>";
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Active') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Refresh rate') . "</td>";
     echo "<td>";
     Dropdown::showTimeStamp("refresh_rate", array('value' => $this->fields["refresh_rate"], 'min' => HOUR_TIMESTAMP, 'max' => DAY_TIMESTAMP, 'step' => HOUR_TIMESTAMP, 'display_emptychoice' => false, 'toadd' => array(5 * MINUTE_TIMESTAMP, 15 * MINUTE_TIMESTAMP, 30 * MINUTE_TIMESTAMP, 45 * MINUTE_TIMESTAMP)));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Number of items displayed') . "</td>";
     echo "<td>";
     Dropdown::showNumber("max_items", array('value' => $this->fields["max_items"], 'min' => 5, 'max' => 100, 'step' => 5, 'toadd' => array(1), 'display_emptychoice' => false));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Error retrieving RSS feed') . "</td>";
     echo "<td>";
     echo Dropdown::getYesNo($this->fields['have_error']);
     echo "</td>";
     if ($this->fields['have_error']) {
         echo "<td>" . __('RSS feeds found');
         echo "</td><td>";
         $this->showDiscoveredFeeds();
         echo "</td>\n";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
开发者ID:stweil,项目名称:glpi,代码行数:82,代码来源:rssfeed.class.php

示例3: checkWriteAccessToDirs

 /**
  * Check Write Access to needed directories
  *
  * @param $fordebug boolean display for debug (no html, no gettext required) (false by default)
  *
  * @return 2 : creation error 1 : delete error 0: OK
  **/
 static function checkWriteAccessToDirs($fordebug = false)
 {
     global $CFG_GLPI;
     $dir_to_check = array(GLPI_CONFIG_DIR => __('Checking write permissions for setting files'), GLPI_DOC_DIR => __('Checking write permissions for document files'), GLPI_DUMP_DIR => __('Checking write permissions for dump files'), GLPI_SESSION_DIR => __('Checking write permissions for session files'), GLPI_CRON_DIR => __('Checking write permissions for automatic actions files'), GLPI_GRAPH_DIR => __('Checking write permissions for graphic files'), GLPI_LOCK_DIR => __('Checking write permissions for lock files'), GLPI_PLUGIN_DOC_DIR => __('Checking write permissions for plugins document files'), GLPI_TMP_DIR => __('Checking write permissions for temporary files'), GLPI_RSS_DIR => __('Checking write permissions for rss files'), GLPI_UPLOAD_DIR => __('Checking write permissions for upload files'), GLPI_PICTURE_DIR => __('Checking write permissions for pictures files'));
     $error = 0;
     foreach ($dir_to_check as $dir => $message) {
         if (!$fordebug) {
             echo "<tr class='tab_bg_1'><td class='left b'>" . $message . "</td>";
         }
         $tmperror = Toolbox::testWriteAccessToDirectory($dir);
         $errors = array(4 => __('The directory could not be created.'), 3 => __('The directory was created but could not be removed.'), 2 => __('The file could not be created.'), 1 => __("The file was created but can't be deleted."));
         if ($tmperror > 0) {
             if ($fordebug) {
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/ko_min.png'> " . sprintf(__('Check permissions to the directory: %s'), $dir) . " " . $errors[$tmperror] . "\n";
             } else {
                 echo "<td><img src='" . $CFG_GLPI['root_doc'] . "/pics/ko_min.png'><p class='red'>" . $errors[$tmperror] . "</p> " . sprintf(__('Check permissions to the directory: %s'), $dir) . "'</td></tr>";
             }
             $error = 2;
         } else {
             if ($fordebug) {
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/ok_min.png' alt=\"" . __s('OK') . "\">{$dir} : OK\n";
             } else {
                 echo "<td><img src='" . $CFG_GLPI['root_doc'] . "/pics/ok_min.png' alt=\"" . __s('A file and a directory have be created and deleted - Perfect!') . "\"\n                          title=\"" . __s('A file and a directory have be created and deleted - Perfect!') . "\">" . "</td></tr>";
             }
         }
     }
     // Only write test for GLPI_LOG as SElinux prevent removing log file.
     if (!$fordebug) {
         echo "<tr class='tab_bg_1'><td class='b left'>" . __('Checking write permissions for log files') . "</td>";
     }
     if (error_log("Test\n", 3, GLPI_LOG_DIR . "/php-errors.log")) {
         if ($fordebug) {
             echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/ok_min.png' alt=\"" . __s('OK') . "\">" . GLPI_LOG_DIR . " : OK\n";
         } else {
             echo "<td><img src='" . $CFG_GLPI['root_doc'] . "/pics/ok_min.png' alt=\"" . __s('A file was created - Perfect!') . "\" title=\"" . __s('A file was created - Perfect!') . "\"></td></tr>";
         }
     } else {
         if ($fordebug) {
             echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/warning_min.png'>" . sprintf(__('Check permissions to the directory: %s'), GLPI_LOG_DIR) . "\n";
         } else {
             echo "<td><img src='" . $CFG_GLPI['root_doc'] . "/pics/warning_min.png'>" . "<p class='red'>" . __('The file could not be created.') . "</p>" . sprintf(__('Check permissions to the directory: %s'), GLPI_LOG_DIR) . "</td></tr>";
         }
         $error = 1;
     }
     $oldhand = set_error_handler(function ($errno, $errmsg, $filename, $linenum, $vars) {
         return true;
     });
     $oldlevel = error_reporting(0);
     /* TODO: could be improved, only default vhost checked */
     if ($fic = fopen('http://localhost' . $CFG_GLPI['root_doc'] . '/index.php', 'r')) {
         fclose($fic);
         if (!$fordebug) {
             echo "<tr class='tab_bg_1'><td class='b left'>" . __('Web access to files directory is protected') . "</td>";
         }
         if ($fic = fopen('http://localhost' . $CFG_GLPI['root_doc'] . '/files/_log/php-errors.log', 'r')) {
             fclose($fic);
             if ($fordebug) {
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/warning_min.png'>" . __('Web access to the files directory, should not be allowed') . "\n" . __('Check the .htaccess file and the web server configuration.') . "\n";
             } else {
                 echo "<td><img src='" . $CFG_GLPI['root_doc'] . "/pics/warning_min.png'>" . "<p class='red'>" . __('Web access to the files directory, should not be allowed') . "<br/>" . __('Check the .htaccess file and the web server configuration.') . "</p></td></tr>";
             }
             $error = 1;
         } else {
             if ($fordebug) {
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/ok_min.png' alt=\"" . __s('Web access to files directory is protected') . "\">" . __s('Web access to files directory is protected') . " : OK\n";
             } else {
                 echo "<td><img src='" . $CFG_GLPI['root_doc'] . "/pics/ok_min.png' alt=\"" . __s('Web access to files directory is protected') . "\" title=\"" . __s('Web access to files directory is protected') . "\"></td></tr>";
             }
         }
     }
     error_reporting($oldlevel);
     set_error_handler($oldhand);
     return $error;
 }
开发者ID:UnidadInformaticaSERVIUVI,项目名称:Administrador-de-Inventario,代码行数:81,代码来源:config.class.php

示例4: checkWriteAccessToDirs

 /**
  * Check Write Access to needed directories
  *
  * @param $fordebug boolean display for debug (no html, no gettext required) (false by default)
  *
  * @return 2 : creation error 1 : delete error 0: OK
  **/
 static function checkWriteAccessToDirs($fordebug = false)
 {
     global $CFG_GLPI;
     $dir_to_check = array(GLPI_CONFIG_DIR => __('Checking write permissions for setting files'), GLPI_DOC_DIR => __('Checking write permissions for document files'), GLPI_DUMP_DIR => __('Checking write permissions for dump files'), GLPI_SESSION_DIR => __('Checking write permissions for session files'), GLPI_CRON_DIR => __('Checking write permissions for automatic actions files'), GLPI_CACHE_DIR => __('Checking write permissions for cache files'), GLPI_GRAPH_DIR => __('Checking write permissions for graphic files'), GLPI_LOCK_DIR => __('Checking write permissions for lock files'), GLPI_PLUGIN_DOC_DIR => __('Checking write permissions for plugins document files'), GLPI_TMP_DIR => __('Checking write permissions for temporary files'), GLPI_RSS_DIR => __('Checking write permissions for rss files'), GLPI_UPLOAD_DIR => __('Checking write permissions for upload files'), GLPI_PICTURE_DIR => __('Checking write permissions for pictures files'));
     $error = 0;
     foreach ($dir_to_check as $dir => $message) {
         if (!$fordebug) {
             echo "<tr class='tab_bg_1'><td class='left b'>" . $message . "</td>";
         }
         $tmperror = Toolbox::testWriteAccessToDirectory($dir);
         $errors = array(4 => __('The directory could not be created.'), 3 => __('The directory was created but could not be removed.'), 2 => __('The file could not be created.'), 1 => __("The file was created but can't be deleted."));
         if ($tmperror > 0) {
             if ($fordebug) {
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png'> " . sprintf(__('Check permissions to the directory: %s'), $dir) . " " . $errors[$tmperror] . "\n";
             } else {
                 echo "<td><img src='" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png'><p class='red'>" . $errors[$tmperror] . "</p> " . sprintf(__('Check permissions to the directory: %s'), $dir) . "'</td></tr>";
             }
             $error = 2;
         } else {
             if ($fordebug) {
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/greenbutton.png' alt=\"" . __s('OK') . "\">{$dir} : OK\n";
             } else {
                 echo "<td><img src='" . $CFG_GLPI['root_doc'] . "/pics/greenbutton.png' alt=\"" . __s('A file and a directory have be created and deleted - Perfect!') . "\"\n                          title=\"" . __s('A file and a directory have be created and deleted - Perfect!') . "\">" . "</td></tr>";
             }
         }
     }
     // Only write test for GLPI_LOG as SElinux prevent removing log file.
     if (!$fordebug) {
         echo "<tr class='tab_bg_1'><td class='b left'>" . __('Checking write permissions for log files') . "</td>";
     }
     if (error_log("Test\n", 3, GLPI_LOG_DIR . "/php-errors.log")) {
         if ($fordebug) {
             echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/greenbutton.png' alt=\"" . __s('OK') . "\">" . GLPI_LOG_DIR . " : OK\n";
         } else {
             echo "<td><img src='" . $CFG_GLPI['root_doc'] . "/pics/greenbutton.png' alt=\"" . __s('A file was created - Perfect!') . "\" title=\"" . __s('A file was created - Perfect!') . "\"></td></tr>";
         }
     } else {
         if ($fordebug) {
             echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/orangebutton.png'>" . sprintf(__('Check permissions to the directory: %s'), GLPI_LOG_DIR) . "\n";
         } else {
             echo "<td><img src='" . $CFG_GLPI['root_doc'] . "/pics/orangebutton.png'>" . "<p class='red'>" . __('The file could not be created.') . "</p>" . sprintf(__('Check permissions to the directory: %s'), GLPI_LOG_DIR) . "</td></tr>";
         }
         $error = 1;
     }
     return $error;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:53,代码来源:config.class.php


注:本文中的Toolbox::testWriteAccessToDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。