aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/appconfig.php18
-rw-r--r--lib/base.php1
-rw-r--r--lib/config.php2
-rw-r--r--lib/helper.php8
-rw-r--r--lib/json.php13
-rw-r--r--lib/mimetypes.list.php2
-rw-r--r--lib/setup.php3
-rw-r--r--lib/util.php68
8 files changed, 90 insertions, 25 deletions
diff --git a/lib/appconfig.php b/lib/appconfig.php
index 392782b2586..f43ef141732 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -100,7 +100,18 @@ class OC_Appconfig{
return $default;
}
}
-
+
+ /**
+ * @brief check if a key is set in the appconfig
+ * @param string $app
+ * @param string $key
+ * @return bool
+ */
+ public static function hasKey($app,$key){
+ $exists = self::getKeys( $app );
+ return in_array( $key, $exists );
+ }
+
/**
* @brief sets a value in the appconfig
* @param $app app
@@ -112,10 +123,7 @@ class OC_Appconfig{
*/
public static function setValue( $app, $key, $value ){
// Does the key exist? yes: update. No: insert
- $exists = self::getKeys( $app );
-
- // null: does not exist
- if( !in_array( $key, $exists )){
+ if(! self::hasKey($app,$key)){
$query = OC_DB::prepare( 'INSERT INTO *PREFIX*appconfig ( appid, configkey, configvalue ) VALUES( ?, ?, ? )' );
$query->execute( array( $app, $key, $value ));
}
diff --git a/lib/base.php b/lib/base.php
index de2e7a36eee..0156febe231 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -115,6 +115,7 @@ class OC{
OC_Util::addScript( "jquery-1.6.4.min" );
OC_Util::addScript( "jquery-ui-1.8.14.custom.min" );
OC_Util::addScript( "jquery-showpassword" );
+ OC_Util::addScript( "jquery.infieldlabel.min" );
OC_Util::addScript( "jquery-tipsy" );
OC_Util::addScript( "js" );
//OC_Util::addScript( "multiselect" );
diff --git a/lib/config.php b/lib/config.php
index 67df5e94c6d..3aa69327f56 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -175,7 +175,7 @@ class OC_Config{
$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 (".exec('whoami').")")));
+ $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;
}
diff --git a/lib/helper.php b/lib/helper.php
index 1661f38e8ab..b6332b54aea 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -266,8 +266,14 @@ class OC_Helper {
return $r;
}
+ /**
+ * returns "checked"-attribut if request contains selected radio element OR if radio element is the default one -- maybe?
+ * @param string $s Name of radio-button element name
+ * @param string $v Value of current radio-button element
+ * @param string $d Value of default radio-button element
+ */
public static function init_radio($s, $v, $d) {
- if((isset($_REQUEST[$s]) && $_REQUEST[$s]==$v) || $v == $d)
+ if((isset($_REQUEST[$s]) && $_REQUEST[$s]==$v) || (!isset($_REQUEST[$s]) && $v == $d))
print "checked=\"checked\" ";
}
diff --git a/lib/json.php b/lib/json.php
index 5ebd6c6b759..cedf79fd7c3 100644
--- a/lib/json.php
+++ b/lib/json.php
@@ -11,7 +11,7 @@ class OC_JSON{
/**
* set Content-Type header to jsonrequest
*/
- public static function setContentTypeHeader($type='application/jsonrequest'){
+ public static function setContentTypeHeader($type='application/json'){
if (!self::$send_content_type_header){
// We send json data
header( 'Content-Type: '.$type );
@@ -20,6 +20,17 @@ class OC_JSON{
}
/**
+ * Check if the app is enabled, send json error msg if not
+ */
+ public static function checkAppEnabled($app){
+ if( !OC_App::isEnabled($app)){
+ $l = new OC_L10N('core');
+ self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled') )));
+ exit();
+ }
+ }
+
+ /**
* Check if the user is logged in, send json error msg if not
*/
public static function checkLoggedIn(){
diff --git a/lib/mimetypes.list.php b/lib/mimetypes.list.php
index 24679257199..e0570e84ea5 100644
--- a/lib/mimetypes.list.php
+++ b/lib/mimetypes.list.php
@@ -32,6 +32,8 @@ return array(
'gz'=>'application/x-gzip',
'html'=>'text/html',
'htm'=>'text/html',
+ 'ics'=>'text/calendar',
+ 'ical'=>'text/calendar',
'jpeg'=>'image/jpeg',
'jpg'=>'image/jpeg',
'js'=>'application/javascript',
diff --git a/lib/setup.php b/lib/setup.php
index 8d3079720cc..355d979dc65 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -55,9 +55,6 @@ class OC_Setup {
if(empty($options['dbuser'])) {
$error[] = "$dbprettyname enter the database username.";
}
- if(empty($options['dbpass'])) {
- $error[] = "$dbprettyname enter the database password.";
- }
if(empty($options['dbname'])) {
$error[] = "$dbprettyname enter the database name.";
}
diff --git a/lib/util.php b/lib/util.php
index c7a2c509800..5d03c56f18e 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -24,7 +24,7 @@ class OC_Util {
$success=@mkdir($CONFIG_DATADIRECTORY_ROOT);
if(!$success) {
$tmpl = new OC_Template( '', 'error', 'guest' );
- $tmpl->assign('errors',array(1=>array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY_ROOT.")",'hint'=>"You can usually fix this by setting the owner of '".OC::$SERVERROOT."' to the user that the web server uses (".exec('whoami').")")));
+ $tmpl->assign('errors',array(1=>array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY_ROOT.")",'hint'=>"You can usually fix this by setting the owner of '".OC::$SERVERROOT."' to the user that the web server uses (".OC_Util::checkWebserverUser().")")));
$tmpl->printPage();
exit;
}
@@ -90,7 +90,15 @@ class OC_Util {
* @return array
*/
public static function getVersion(){
- return array(1,90,0);
+ return array(1,92,0);
+ }
+
+ /**
+ * get the current installed version string of ownCloud
+ * @return string
+ */
+ public static function getVersionString(){
+ return '2 beta 3';
}
/**
@@ -200,28 +208,21 @@ class OC_Util {
}
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
$CONFIG_DBNAME = OC_Config::getValue( "dbname", "owncloud" );
-
- //try to get the username the httpd server runs on, used in hints
- $stat=stat($_SERVER['DOCUMENT_ROOT']);
- if(is_callable('posix_getpwuid')){
- $serverUser=posix_getpwuid($stat['uid']);
- $serverUser='\''.$serverUser['name'].'\'';
- }else{
- $serverUser='\'www-data\' for ubuntu/debian';//TODO: try to detect the distro and give a guess based on that
- }
+ $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 from the web<br/>','hint'=>$permissionsHint);
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') is readable for other users<br/>','hint'=>$permissionsModHint);
}
}
if( OC_Config::getValue( "enablebackup", false )){
@@ -231,7 +232,7 @@ class OC_Util {
clearstatcache();
$prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)),-3);
if(substr($prems,2,1)!='0'){
- $errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable from the web<br/>','hint'=>$permissionsHint);
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable for other users<br/>','hint'=>$permissionsModHint);
}
}
}
@@ -244,16 +245,55 @@ class OC_Util {
// check if all required php modules are present
if(!class_exists('ZipArchive')){
- $errors[]=array('error'=>'PHP module ZipArchive not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ $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;
}
+ public static function displayLoginPage($parameters = array()){
+ if(isset($_COOKIE["username"])){
+ $parameters["username"] = $_COOKIE["username"];
+ } else {
+ $parameters["username"] = '';
+ }
+ OC_Template::printGuestPage("", "login", $parameters);
+ }
+
+ /**
+ * Try to get the username the httpd server runs on, used in hints
+ */
+ public static function checkWebserverUser(){
+ $stat=stat($_SERVER['DOCUMENT_ROOT']);
+ if(is_callable('posix_getpwuid')){
+ $serverUser=posix_getpwuid($stat['uid']);
+ $serverUser='\''.$serverUser['name'].'\'';
+ }elseif(exec('whoami')){
+ $serverUser=exec('whoami');
+ }else{
+ $serverUser='\'www-data\' for ubuntu/debian'; //TODO: try to detect the distro and give a guess based on that
+ }
+ return $serverUser;
+ }
+
+
+ /**
+ * Check if the app is enabled, send json error msg if not
+ */
+ public static function checkAppEnabled($app){
+ if( !OC_App::isEnabled($app)){
+ header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true));
+ exit();
+ }
+ }
+
/**
* Check if the user is logged in, redirects to home if not
*/