aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrice Maron <brice@bmaron.net>2013-01-26 16:09:16 +0000
committerBrice Maron <brice@bmaron.net>2013-01-26 16:09:16 +0000
commit8c3519acf32ddf9107800ed0f1f922dde4c9daa0 (patch)
treefe7bee3191974092031d336a6b47ff3bd9f840ac
parent6c87a0713d5b7330be4c276cc78a39bc2a496c38 (diff)
downloadnextcloud-server-8c3519acf32ddf9107800ed0f1f922dde4c9daa0.tar.gz
nextcloud-server-8c3519acf32ddf9107800ed0f1f922dde4c9daa0.zip
Backport of #1113 should fix #622
-rw-r--r--core/js/js.js2
-rw-r--r--core/templates/layout.base.php1
-rw-r--r--core/templates/layout.guest.php1
-rw-r--r--lib/db.php17
-rw-r--r--lib/setup.php2
-rw-r--r--lib/template.php1
-rw-r--r--lib/templatelayout.php17
7 files changed, 24 insertions, 17 deletions
diff --git a/core/js/js.js b/core/js/js.js
index e3590c1f4f9..4018dc86903 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -56,7 +56,7 @@ var OC={
PERMISSION_DELETE:8,
PERMISSION_SHARE:16,
webroot:oc_webroot,
- appswebroots:oc_appswebroots,
+ appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
coreApps:['', 'admin','log','search','settings','core','3rdparty'],
/**
diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php
index f78b6ff8bbd..3323d847e63 100644
--- a/core/templates/layout.base.php
+++ b/core/templates/layout.base.php
@@ -9,7 +9,6 @@
<?php endforeach; ?>
<script type="text/javascript">
var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
- var oc_appswebroots = <?php echo $_['apps_paths'] ?>;
var oc_requesttoken = '<?php echo $_['requesttoken']; ?>';
var oc_requestlifespan = '<?php echo $_['requestlifespan']; ?>';
</script>
diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php
index 6f59e18a8e1..084974f4714 100644
--- a/core/templates/layout.guest.php
+++ b/core/templates/layout.guest.php
@@ -9,7 +9,6 @@
<?php endforeach; ?>
<script type="text/javascript">
var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
- var oc_appswebroots = <?php echo $_['apps_paths'] ?>;
var oc_requesttoken = '<?php echo $_['requesttoken']; ?>';
var oc_requestlifespan = '<?php echo $_['requestlifespan']; ?>';
</script>
diff --git a/lib/db.php b/lib/db.php
index 4c1c18fcc5e..57feebe9b2d 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -147,7 +147,7 @@ class OC_DB {
$dsn='pgsql:dbname='.$name.';host='.$host;
}
/**
- * Ugly fix for pg connections pbm when password use spaces
+ * Ugly fix for pg connections pbm when password use spaces (php#62479)
*/
$e_user = addslashes($user);
$e_password = addslashes($pass);
@@ -168,7 +168,13 @@ class OC_DB {
try{
self::$PDO=new PDO($dsn, $user, $pass, $opts);
}catch(PDOException $e) {
- OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.$e->getMessage().')' );
+ OC_Log::write('core', $e->getMessage(), OC_Log::FATAL);
+ OC_User::setUserId(null);
+ // send http status 503
+ header('HTTP/1.1 503 Service Temporarily Unavailable');
+ header('Status: 503 Service Temporarily Unavailable');
+ OC_Template::printErrorPage('Failed to connect to database');
+ die();
}
// We always, really always want associative arrays
self::$PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
@@ -262,7 +268,12 @@ class OC_DB {
// Die if we could not connect
if( PEAR::isError( self::$MDB2 )) {
- OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')' );
+ OC_User::setUserId(null);
+
+ header('HTTP/1.1 503 Service Temporarily Unavailable');
+ header('Status: 503 Service Temporarily Unavailable');
+ OC_Template::printErrorPage('Failed to connect to database');
+ die();
}
// We always, really always want associative arrays
diff --git a/lib/setup.php b/lib/setup.php
index 8e9ffd14713..7097d115076 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -386,6 +386,8 @@ class OC_Setup {
if(count($error) == 0) {
OC_Appconfig::setValue('core', 'installedat',microtime(true));
OC_Appconfig::setValue('core', 'lastupdatedat',microtime(true));
+ OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
+ OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
OC_Group::createGroup('admin');
OC_Group::addToGroup($username, 'admin');
diff --git a/lib/template.php b/lib/template.php
index f58e6e6f675..7fbfa151371 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -490,6 +490,7 @@ class OC_Template{
*/
public static function printErrorPage( $error_msg, $hint = '' ) {
$errors = array(array('error' => $error_msg, 'hint' => $hint));
+ OC_Util::addStyle( "styles" );
OC_Template::printGuestPage("", "error", array("errors" => $errors));
die();
}
diff --git a/lib/templatelayout.php b/lib/templatelayout.php
index 715b68cf9c1..a6842c22002 100644
--- a/lib/templatelayout.php
+++ b/lib/templatelayout.php
@@ -29,23 +29,18 @@ class OC_TemplateLayout extends OC_Template {
break;
}
}
+ $apps_paths = array();
+ foreach(OC_App::getEnabledApps() as $app) {
+ $apps_paths[$app] = OC_App::getAppWebPath($app);
+ }
+ $this->assign( 'apps_paths', str_replace('\\/', '/', json_encode($apps_paths)), false ); // Ugly unescape slashes
+
} else if ($renderas == 'guest') {
parent::__construct('core', 'layout.guest');
} else {
parent::__construct('core', 'layout.base');
}
- $apps_paths = array();
- foreach(OC_App::getEnabledApps() as $app) {
- $apps_paths[$app] = OC_App::getAppWebPath($app);
- }
- $this->assign( 'apps_paths', str_replace('\\/', '/',json_encode($apps_paths)),false ); // Ugly unescape slashes waiting for better solution
-
- if (OC_Config::getValue('installed', false) && !OC_AppConfig::getValue('core', 'remote_core.css', false)) {
- OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
- OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
- }
-
// Add the js files
$jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
$this->assign('jsfiles', array(), false);