summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2011-11-29 22:11:42 +0000
committerTom Needham <needham.thomas@gmail.com>2011-11-29 22:11:42 +0000
commitdd7a411f9aaceab1bf8eab551e5f95ff5feff6fb (patch)
tree8c21a5aa4e397e9987389b65b82c2181e900d930 /lib
parent88de9e40503833f76e79e8ac722025ceafd15c4b (diff)
downloadnextcloud-server-dd7a411f9aaceab1bf8eab551e5f95ff5feff6fb.tar.gz
nextcloud-server-dd7a411f9aaceab1bf8eab551e5f95ff5feff6fb.zip
Disable save button while saving. Streamlined code.
Diffstat (limited to 'lib')
-rw-r--r--lib/app.php4
-rw-r--r--lib/base.php8
-rw-r--r--lib/config.php1
-rw-r--r--lib/hook.php2
-rw-r--r--lib/l10n.php16
-rw-r--r--lib/setup.php2
-rw-r--r--lib/template.php27
-rw-r--r--lib/updater.php91
-rw-r--r--lib/util.php16
9 files changed, 147 insertions, 20 deletions
diff --git a/lib/app.php b/lib/app.php
index 30ebcf032b3..d3d99865762 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -100,11 +100,11 @@ class OC_App{
}
/**
- * @brief enables an app
+ * @brief disables an app
* @param $app app
* @returns true/false
*
- * This function set an app as enabled in appconfig.
+ * This function set an app as disabled in appconfig.
*/
public static function disable( $app ){
OC_Appconfig::setValue( $app, 'enabled', 'no' );
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/hook.php b/lib/hook.php
index b069a7da6c0..83a16106bf0 100644
--- a/lib/hook.php
+++ b/lib/hook.php
@@ -20,7 +20,7 @@ class OC_Hook{
* TODO: write example
*/
static public function connect( $signalclass, $signalname, $slotclass, $slotname ){
- // Cerate the data structure
+ // Create the data structure
if( !array_key_exists( $signalclass, self::$registered )){
self::$registered[$signalclass] = array();
}
diff --git a/lib/l10n.php b/lib/l10n.php
index 54331d44ae4..a5544eb3a27 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -110,6 +110,22 @@ class OC_L10N{
}
/**
+ * @brief Translating
+ * @param $textArray The text array we need a translation for
+ * @returns Translation or the same text
+ *
+ * Returns the translation. If no translation is found, $textArray will be
+ * returned.
+ */
+ public function tA($textArray){
+ $result = array();
+ foreach($textArray as $key => $text){
+ $result[$key] = $this->t($text);
+ }
+ return $result;
+ }
+
+ /**
* @brief getTranslations
* @returns Fetch all translations
*
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 440b62003e7..881d2a27b1e 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -98,6 +98,33 @@ function relative_modified_date($timestamp) {
else { return $l->t('years ago'); }
}
+function html_select_options($options, $selected, $params=array()) {
+ if (!is_array($selected)){
+ $selected=array($selected);
+ }
+ if (isset($params['combine']) && $params['combine']){
+ $options = array_combine($options, $options);
+ }
+ $value_name = $label_name = false;
+ if (isset($params['value'])){
+ $value_name = $params['value'];
+ }
+ if (isset($params['label'])){
+ $label_name = $params['label'];
+ }
+ $html = '';
+ foreach($options as $value => $label){
+ if ($value_name && is_array($label)){
+ $value = $label[$value_name];
+ }
+ if ($label_name && is_array($label)){
+ $label = $label[$label_name];
+ }
+ $select = in_array($value, $selected) ? ' selected="selected"' : '';
+ $html .= '<option value="' . $value . '"' . $select . '>' . $label . '</option>'."\n";
+ }
+ return $html;
+}
/**
* This class provides the templates for owncloud.
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