本文整理汇总了PHP中OC_Util::checkWebserverUser方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Util::checkWebserverUser方法的具体用法?PHP OC_Util::checkWebserverUser怎么用?PHP OC_Util::checkWebserverUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Util
的用法示例。
在下文中一共展示了OC_Util::checkWebserverUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
{
$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;
}
示例2: writeData
/**
* @brief Writes the config file
* @returns true/false
*
* Saves the config to the config file.
*
* Known flaws: Strings are not escaped properly
*/
public static function writeData()
{
// Create a php file ...
$content = "<?php\n\$CONFIG = array(\n";
foreach (self::$cache as $key => $value) {
if (is_bool($value)) {
$value = $value ? 'true' : 'false';
$content .= "\"{$key}\" => {$value},\n";
} else {
$value = str_replace("'", "\\'", $value);
$content .= "\"{$key}\" => '{$value}',\n";
}
}
$content .= ");\n?>\n";
// Write the file
$result = @file_put_contents(OC::$SERVERROOT . "/config/config.php", $content);
if (!$result) {
$tmpl = new OC_Template('', 'error', 'guest');
$tmpl->assign('errors', array(1 => array('error' => "Can't write into config directory 'config'", 'hint' => "You can usually fix this by setting the owner of 'config' to the user that the web server uses (" . OC_Util::checkWebserverUser() . ")")));
$tmpl->printPage();
exit;
}
return true;
}