當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OC_Helper::chmodr方法代碼示例

本文整理匯總了PHP中OC_Helper::chmodr方法的典型用法代碼示例。如果您正苦於以下問題:PHP OC_Helper::chmodr方法的具體用法?PHP OC_Helper::chmodr怎麽用?PHP OC_Helper::chmodr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OC_Helper的用法示例。


在下文中一共展示了OC_Helper::chmodr方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkServer

 /**
  * check if the current server configuration is suitable for ownCloud
  * @return array arrays with error messages and hints
  */
 public static function checkServer()
 {
     $errors = array();
     $web_server_restart = false;
     //check for database drivers
     if (!(is_callable('sqlite_open') or class_exists('SQLite3')) and !is_callable('mysql_connect') and !is_callable('pg_connect')) {
         $errors[] = array('error' => 'No database drivers (sqlite, mysql, or postgresql) installed.<br/>', 'hint' => '');
         //TODO: sane hint
         $web_server_restart = true;
     }
     //common hint for all file permissons error messages
     $permissionsHint = "Permissions can usually be fixed by giving the webserver write access to the ownCloud directory";
     // Check if config folder is writable.
     if (!is_writable(OC::$SERVERROOT . "/config/") or !is_readable(OC::$SERVERROOT . "/config/")) {
         $errors[] = array('error' => "Can't write into config directory 'config'", 'hint' => "You can usually fix this by giving the webserver user write access to the config directory in owncloud");
     }
     // Check if there is a writable install folder.
     if (OC_Config::getValue('appstoreenabled', true)) {
         if (OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath())) {
             $errors[] = array('error' => "Can't write into apps directory", 'hint' => "You can usually fix this by giving the webserver user write access to the apps directory\n\t\t\t\tin owncloud or disabling the appstore in the config file.");
         }
     }
     $CONFIG_DATADIRECTORY = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     //check for correct file permissions
     if (!stristr(PHP_OS, 'WIN')) {
         $permissionsModHint = "Please change the permissions to 0770 so that the directory cannot be listed by other users.";
         $prems = substr(decoct(@fileperms($CONFIG_DATADIRECTORY)), -3);
         if (substr($prems, -1) != '0') {
             OC_Helper::chmodr($CONFIG_DATADIRECTORY, 0770);
             clearstatcache();
             $prems = substr(decoct(@fileperms($CONFIG_DATADIRECTORY)), -3);
             if (substr($prems, 2, 1) != '0') {
                 $errors[] = array('error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') is readable for other users<br/>', 'hint' => $permissionsModHint);
             }
         }
         if (OC_Config::getValue("enablebackup", false)) {
             $CONFIG_BACKUPDIRECTORY = OC_Config::getValue("backupdirectory", OC::$SERVERROOT . "/backup");
             $prems = substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
             if (substr($prems, -1) != '0') {
                 OC_Helper::chmodr($CONFIG_BACKUPDIRECTORY, 0770);
                 clearstatcache();
                 $prems = substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
                 if (substr($prems, 2, 1) != '0') {
                     $errors[] = array('error' => 'Data directory (' . $CONFIG_BACKUPDIRECTORY . ') is readable for other users<br/>', 'hint' => $permissionsModHint);
                 }
             }
         }
     } else {
         //TODO: permissions checks for windows hosts
     }
     // Create root dir.
     if (!is_dir($CONFIG_DATADIRECTORY)) {
         $success = @mkdir($CONFIG_DATADIRECTORY);
         if (!$success) {
             $errors[] = array('error' => "Can't create data directory (" . $CONFIG_DATADIRECTORY . ")", 'hint' => "You can usually fix this by giving the webserver write access to the ownCloud directory '" . OC::$SERVERROOT . "' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' ");
         }
     } else {
         if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
             $errors[] = array('error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud<br/>', 'hint' => $permissionsHint);
         }
     }
     // check if all required php modules are present
     if (!class_exists('ZipArchive')) {
         $errors[] = array('error' => 'PHP module zip not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
         $web_server_restart = false;
     }
     if (!function_exists('mb_detect_encoding')) {
         $errors[] = array('error' => 'PHP module mb multibyte not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
         $web_server_restart = false;
     }
     if (!function_exists('ctype_digit')) {
         $errors[] = array('error' => 'PHP module ctype is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
         $web_server_restart = false;
     }
     if (!function_exists('json_encode')) {
         $errors[] = array('error' => 'PHP module JSON is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
         $web_server_restart = false;
     }
     if (!function_exists('imagepng')) {
         $errors[] = array('error' => 'PHP module GD is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
         $web_server_restart = false;
     }
     if (!function_exists('gzencode')) {
         $errors[] = array('error' => 'PHP module zlib is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
         $web_server_restart = false;
     }
     if (!function_exists('iconv')) {
         $errors[] = array('error' => 'PHP module iconv is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
         $web_server_restart = false;
     }
     if (!function_exists('simplexml_load_string')) {
         $errors[] = array('error' => 'PHP module SimpleXML is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
         $web_server_restart = false;
     }
     if (floatval(phpversion()) < 5.3) {
         $errors[] = array('error' => 'PHP 5.3 is required.<br/>', 'hint' => 'Please ask your server administrator to update PHP to version 5.3 or higher. PHP 5.2 is no longer supported by ownCloud and the PHP community.');
//.........這裏部分代碼省略.........
開發者ID:ryanshoover,項目名稱:core,代碼行數:101,代碼來源:util.php

示例2: checkServer

 /**
  * check if the current server configuration is suitable for ownCloud
  * @return array arrays with error messages and hints
  */
 public static function checkServer()
 {
     $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     $CONFIG_BACKUPDIRECTORY = OC_Config::getValue("backupdirectory", OC::$SERVERROOT . "/backup");
     $CONFIG_INSTALLED = OC_Config::getValue("installed", false);
     $errors = array();
     //check for database drivers
     if (!(is_callable('sqlite_open') or class_exists('SQLite3')) and !is_callable('mysql_connect') and !is_callable('pg_connect')) {
         $errors[] = array('error' => 'No database drivers (sqlite, mysql, or postgresql) installed.<br/>', 'hint' => '');
         //TODO: sane hint
     }
     $CONFIG_DBTYPE = OC_Config::getValue("dbtype", "sqlite");
     $CONFIG_DBNAME = OC_Config::getValue("dbname", "owncloud");
     //common hint for all file permissons error messages
     $permissionsHint = "Permissions can usually be fixed by giving the webserver write access to the ownCloud directory";
     //check for correct file permissions
     if (!stristr(PHP_OS, 'WIN')) {
         $permissionsModHint = "Please change the permissions to 0770 so that the directory cannot be listed by other users.";
         $prems = substr(decoct(@fileperms($CONFIG_DATADIRECTORY_ROOT)), -3);
         if (substr($prems, -1) != '0') {
             OC_Helper::chmodr($CONFIG_DATADIRECTORY_ROOT, 0770);
             clearstatcache();
             $prems = substr(decoct(@fileperms($CONFIG_DATADIRECTORY_ROOT)), -3);
             if (substr($prems, 2, 1) != '0') {
                 $errors[] = array('error' => 'Data directory (' . $CONFIG_DATADIRECTORY_ROOT . ') is readable for other users<br/>', 'hint' => $permissionsModHint);
             }
         }
         if (OC_Config::getValue("enablebackup", false)) {
             $prems = substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
             if (substr($prems, -1) != '0') {
                 OC_Helper::chmodr($CONFIG_BACKUPDIRECTORY, 0770);
                 clearstatcache();
                 $prems = substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
                 if (substr($prems, 2, 1) != '0') {
                     $errors[] = array('error' => 'Data directory (' . $CONFIG_BACKUPDIRECTORY . ') is readable for other users<br/>', 'hint' => $permissionsModHint);
                 }
             }
         }
     } else {
         //TODO: permissions checks for windows hosts
     }
     if (is_dir($CONFIG_DATADIRECTORY_ROOT) and !is_writable($CONFIG_DATADIRECTORY_ROOT)) {
         $errors[] = array('error' => 'Data directory (' . $CONFIG_DATADIRECTORY_ROOT . ') not writable by ownCloud<br/>', 'hint' => $permissionsHint);
     }
     // check if all required php modules are present
     if (!class_exists('ZipArchive')) {
         $errors[] = array('error' => 'PHP module zip not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
     }
     if (!function_exists('mb_detect_encoding')) {
         $errors[] = array('error' => 'PHP module mb multibyte not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
     }
     if (!function_exists('ctype_digit')) {
         $errors[] = array('error' => 'PHP module ctype is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
     }
     if (!function_exists('json_encode')) {
         $errors[] = array('error' => 'PHP module JSON is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
     }
     if (!function_exists('imagepng')) {
         $errors[] = array('error' => 'PHP module GD is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
     }
     if (floatval(phpversion()) < 5.3) {
         $errors[] = array('error' => 'PHP 5.3 is required.<br/>', 'hint' => 'Please ask your server administrator to update PHP to version 5.3 or higher. PHP 5.2 is no longer supported by ownCloud and the PHP community.');
     }
     if (!defined('PDO::ATTR_DRIVER_NAME')) {
         $errors[] = array('error' => 'PHP PDO module is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
     }
     return $errors;
 }
開發者ID:jaeindia,項目名稱:ownCloud-Enhancements,代碼行數:72,代碼來源:util.php

示例3: checkServer

 /**
  * check if the current server configuration is suitable for ownCloud
  * @return array arrays with error messages and hints
  */
 public static function checkServer()
 {
     $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     $CONFIG_BACKUPDIRECTORY = OC_Config::getValue("backupdirectory", OC::$SERVERROOT . "/backup");
     $CONFIG_INSTALLED = OC_Config::getValue("installed", false);
     $errors = array();
     //check for database drivers
     if (!is_callable('sqlite_open') and !is_callable('mysql_connect')) {
         $errors[] = array('error' => 'No database drivers (sqlite or mysql) installed.<br/>', 'hint' => '');
         //TODO: sane hint
     }
     $CONFIG_DBTYPE = OC_Config::getValue("dbtype", "sqlite");
     $CONFIG_DBNAME = OC_Config::getValue("dbname", "owncloud");
     $serverUser = OC_Util::checkWebserverUser();
     //common hint for all file permissons error messages
     $permissionsHint = "Permissions can usually be fixed by setting the owner of the file or directory to the user the web server runs as ({$serverUser})";
     //check for correct file permissions
     if (!stristr(PHP_OS, 'WIN')) {
         $permissionsModHint = "Please change the permissions to 0770 so that the directory cannot be listed by other users.";
         $prems = substr(decoct(@fileperms($CONFIG_DATADIRECTORY_ROOT)), -3);
         if (substr($prems, -1) != '0') {
             OC_Helper::chmodr($CONFIG_DATADIRECTORY_ROOT, 0770);
             clearstatcache();
             $prems = substr(decoct(@fileperms($CONFIG_DATADIRECTORY_ROOT)), -3);
             if (substr($prems, 2, 1) != '0') {
                 $errors[] = array('error' => 'Data directory (' . $CONFIG_DATADIRECTORY_ROOT . ') is readable for other users<br/>', 'hint' => $permissionsModHint);
             }
         }
         if (OC_Config::getValue("enablebackup", false)) {
             $prems = substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
             if (substr($prems, -1) != '0') {
                 OC_Helper::chmodr($CONFIG_BACKUPDIRECTORY, 0770);
                 clearstatcache();
                 $prems = substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
                 if (substr($prems, 2, 1) != '0') {
                     $errors[] = array('error' => 'Data directory (' . $CONFIG_BACKUPDIRECTORY . ') is readable for other users<br/>', 'hint' => $permissionsModHint);
                 }
             }
         }
     } else {
         //TODO: permissions checks for windows hosts
     }
     if (is_dir($CONFIG_DATADIRECTORY_ROOT) and !is_writable($CONFIG_DATADIRECTORY_ROOT)) {
         $errors[] = array('error' => 'Data directory (' . $CONFIG_DATADIRECTORY_ROOT . ') not writable by ownCloud<br/>', 'hint' => $permissionsHint);
     }
     // check if all required php modules are present
     if (!class_exists('ZipArchive')) {
         $errors[] = array('error' => 'PHP module zip not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
     }
     if (!function_exists('mb_detect_encoding')) {
         $errors[] = array('error' => 'PHP module mb multibyte not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
     }
     if (!function_exists('ctype_digit')) {
         $errors[] = array('error' => 'PHP module ctype is not installed.<br/>', 'hint' => 'Please ask your server administrator to install the module.');
     }
     return $errors;
 }
開發者ID:Teino1978-Corp,項目名稱:Teino1978-Corp-owncloud_.htaccess-,代碼行數:61,代碼來源:owncloud_lib_util.php

示例4: checkDataDirectoryPermissions

 /**
  * @brief Check for correct file permissions of data directory
  * @paran string $dataDirectory
  * @return array arrays with error messages and hints
  */
 public static function checkDataDirectoryPermissions($dataDirectory)
 {
     $errors = array();
     if (self::runningOnWindows()) {
         //TODO: permissions checks for windows hosts
     } else {
         $permissionsModHint = 'Please change the permissions to 0770 so that the directory' . ' cannot be listed by other users.';
         $perms = substr(decoct(@fileperms($dataDirectory)), -3);
         if (substr($perms, -1) != '0') {
             OC_Helper::chmodr($dataDirectory, 0770);
             clearstatcache();
             $perms = substr(decoct(@fileperms($dataDirectory)), -3);
             if (substr($perms, 2, 1) != '0') {
                 $errors[] = array('error' => 'Data directory (' . $dataDirectory . ') is readable for other users', 'hint' => $permissionsModHint);
             }
         }
     }
     return $errors;
 }
開發者ID:omusico,項目名稱:isle-web-framework,代碼行數:24,代碼來源:util.php


注:本文中的OC_Helper::chmodr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。