Example #1
0
 /**
  * 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.');
         $web_server_restart = false;
     }
     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.');
         $web_server_restart = false;
     }
     if ($web_server_restart) {
         $errors[] = array('error' => 'PHP modules have been installed, but they are still listed as missing?<br/>', 'hint' => 'Please ask your server administrator to restart the web server.');
     }
     return $errors;
 }
Example #2
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Example #4
0
 /**
  * @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;
 }