summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php8
-rw-r--r--lib/config.php1
-rw-r--r--lib/setup.php2
-rw-r--r--lib/template.php2
-rw-r--r--lib/updater.php91
-rw-r--r--lib/util.php16
6 files changed, 102 insertions, 18 deletions
diff --git a/lib/base.php b/lib/base.php
index c52b4493e01..700236c96c6 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -92,6 +92,14 @@ class OC{
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}
+ //set http auth headers for apache+php-cgi work around if variable gets renamed by apache
+ if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches))
+ {
+ list($name, $password) = explode(':', base64_decode($matches[1]));
+ $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
+ $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
+ }
+
// calculate the documentroot
OC::$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13));
diff --git a/lib/config.php b/lib/config.php
index 2c82036257f..8d03271b3ea 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -94,7 +94,6 @@ class OC_Config{
// Write changes
self::writeData();
-
return true;
}
diff --git a/lib/setup.php b/lib/setup.php
index e2d56ddaf4a..8afe0070e9b 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -77,6 +77,8 @@ class OC_Setup {
OC_Config::setValue('datadirectory', $datadir);
OC_Config::setValue('dbtype', $dbtype);
OC_Config::setValue('version',implode('.',OC_Util::getVersion()));
+ OC_Config::setValue('installedat',microtime(true));
+ OC_Config::setValue('lastupdatedat',microtime(true));
if($dbtype == 'mysql') {
$dbuser = $options['dbuser'];
$dbpass = $options['dbpass'];
diff --git a/lib/template.php b/lib/template.php
index d1439199e1e..881d2a27b1e 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -121,7 +121,7 @@ function html_select_options($options, $selected, $params=array()) {
$label = $label[$label_name];
}
$select = in_array($value, $selected) ? ' selected="selected"' : '';
- $html .= '<option value="' . $value . '"' . $select . '>' . $label . '</option>';
+ $html .= '<option value="' . $value . '"' . $select . '>' . $label . '</option>'."\n";
}
return $html;
}
diff --git a/lib/updater.php b/lib/updater.php
new file mode 100644
index 00000000000..e4db719a62c
--- /dev/null
+++ b/lib/updater.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Frank Karlitschek
+ * @copyright 2010 Frank Karlitschek karlitschek@kde.org
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * Class that handels autoupdating of ownCloud
+ */
+class OC_Updater{
+
+ /**
+ * Check if a new version is available
+ */
+ public static function check(){
+ OC_Config::setValue('lastupdatedat',microtime(true));
+
+ $updaterurl='http://apps.owncloud.com/updater.php';
+ $version=OC_Util::getVersion();
+ $version['installed']=OC_Config::getValue( "installedat");
+ $version['updated']=OC_Config::getValue( "lastupdatedat");
+ $version['updatechannel']='stable';
+ $versionstring=implode('x',$version);
+
+ //fetch xml data from updater
+ $url=$updaterurl.'?version='.$versionstring;
+ $xml=@file_get_contents($url);
+ if($xml==FALSE){
+ return array();
+ }
+ $data=@simplexml_load_string($xml);
+
+ $tmp=array();
+ $tmp['version'] = $data->version;
+ $tmp['versionstring'] = $data->versionstring;
+ $tmp['url'] = $data->url;
+ $tmp['web'] = $data->web;
+
+
+ return $tmp;
+
+ }
+
+
+
+ public static function ShowUpdatingHint(){
+ $data=OC_Updater::check();
+ if(isset($data['version']) and $data['version']<>'') {
+ $txt='<span style="color:#AA0000; font-weight:bold;">'.$data['versionstring'].' is available. Please click <a href="'.$data['web'].'">here</a> for more information</span>';
+ }else{
+ $txt='Your ownCloud is up to date';
+ }
+ return($txt);
+
+ }
+
+
+ /**
+ * do ownCloud update
+ */
+ public static function doUpdate(){
+
+ //update ownCloud core
+
+ //update all apps
+
+ //update version in config
+
+ }
+
+}
+
+
+
+?>
diff --git a/lib/util.php b/lib/util.php
index 14313569a1d..0f79948bc24 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -180,7 +180,6 @@ class OC_Util {
}
$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 giving the webserver write access to the ownCloud directory";
@@ -239,21 +238,6 @@ class OC_Util {
OC_Template::printGuestPage("", "login", $parameters);
}
- /**
- * Try to get the username the httpd server runs on, used in hints
- */
- public static function checkWebserverUser(){
- if(is_callable('posix_getuid')){
- $serverUser=posix_getpwuid(posix_getuid());
- $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