[geeklog-cvs] geeklog: Fix paths and URLs during an upgrade, so we can install...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Jan 5 05:06:39 EST 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/8a7add14f603
changeset: 6607:8a7add14f603
user: Dirk Haun <dirk at haun-online.de>
date: Mon Dec 29 19:11:16 2008 +0100
description:
Fix paths and URLs during an upgrade, so we can install database backups elsewhere, e.g. locally
diffstat:
2 files changed, 81 insertions(+), 6 deletions(-)
public_html/admin/install/index.php | 14 +++--
public_html/admin/install/lib-install.php | 73 ++++++++++++++++++++++++++++-
diffs (141 lines):
diff -r 83b0e1e24d5b -r 8a7add14f603 public_html/admin/install/index.php
--- a/public_html/admin/install/index.php Sun Dec 28 20:12:04 2008 +0100
+++ b/public_html/admin/install/index.php Mon Dec 29 19:11:16 2008 +0100
@@ -2,7 +2,7 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Geeklog 1.5 |
+// | Geeklog 1.6 |
// +---------------------------------------------------------------------------+
// | index.php |
// | |
@@ -36,10 +36,8 @@
// | You don't need to change anything in this file. |
// | Please read docs/install.html which describes how to install Geeklog. |
// +---------------------------------------------------------------------------+
-//
-// $Id: index.php,v 1.47 2008/06/15 06:41:26 mwest Exp $
-require_once "lib-install.php";
+require_once 'lib-install.php';
/*
@@ -48,7 +46,7 @@
* The guts of the installation and upgrade package.
*
* @param string $install_type 'install' or 'upgrade'
- * @param int $install_step 1 - 3
+ * @param int $install_step 1 - 4
*/
function INST_installEngine($install_type, $install_step)
{
@@ -549,6 +547,12 @@
$config->set('site_mail', urldecode($site_mail));
$config->set('noreply_mail', urldecode($noreply_mail));
$config->set_default('default_photo', urldecode($site_url) . '/default.jpg');
+ } else {
+ $site_url = isset($_POST['site_url']) ? $_POST['site_url'] : (isset($_GET['site_url']) ? $_GET['site_url'] : '') ;
+ $site_admin_url = isset($_POST['site_admin_url']) ? $_POST['site_admin_url'] : (isset($_GET['site_admin_url']) ? $_GET['site_admin_url'] : '') ;
+
+ INST_fixPathsAndUrls($_CONF['path'], $html_path,
+ urldecode($site_url), urldecode($site_admin_url));
}
// disable plugins for which we don't have the source files
diff -r 83b0e1e24d5b -r 8a7add14f603 public_html/admin/install/lib-install.php
--- a/public_html/admin/install/lib-install.php Sun Dec 28 20:12:04 2008 +0100
+++ b/public_html/admin/install/lib-install.php Mon Dec 29 19:11:16 2008 +0100
@@ -2,7 +2,7 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Geeklog 1.5 |
+// | Geeklog 1.6 |
// +---------------------------------------------------------------------------+
// | lib-install.php |
// | |
@@ -11,6 +11,7 @@
// | Copyright (C) 2008 by the following authors: |
// | |
// | Authors: Matt West - matt.danger.west AT gmail DOT com |
+// | Dirk Haun - dirk AT haun-online DOT de |
// +---------------------------------------------------------------------------+
// | |
// | This program is free software; you can redistribute it and/or |
@@ -1051,4 +1052,74 @@
}
}
+/**
+* Do a sanity check on the paths and URLs
+*
+* This is somewhat speculative but should provide the user with a working
+* site even if, for example, a site backup was installed elsewhere.
+*
+* @param string $path proper /path/to/Geeklog
+* @param string $path_html path to public_html
+* @param string $site_url The site's URL
+* @param string $site_admin_url URL to the admin directory
+*
+*/
+function INST_fixPathsAndUrls($path, $path_html, $site_url, $site_admin_url)
+{
+ // no global $_CONF here!
+
+ require_once $path . 'system/classes/config.class.php';
+
+ $config = config::get_instance();
+ $config->set_configfile($path . 'db-config.php');
+ $config->load_baseconfig();
+ $config->initConfig();
+ $_CONF = $config->get_config('Core');
+
+ if (! file_exists($_CONF['path_log'] . 'error.log')) {
+ $config->set('path_log', $path . 'logs/');
+ }
+ if (! file_exists($_CONF['path_language'] . $_CONF['language'] . '.php')) {
+ $config->set('path_language', $path . 'language/');
+ }
+ if (! file_exists($_CONF['backup_path'])) {
+ $config->set('backup_path', $path . 'backups/');
+ }
+ if (! file_exists($_CONF['path_data'])) {
+ $config->set('path_data', $path . 'data/');
+ }
+ if ((! $_CONF['have_pear']) &&
+ (! file_exists($_CONF['path_pear'] . 'PEAR.php'))) {
+ $config->set('path_pear', $path . 'system/pear/');
+ }
+
+ if (! file_exists($_CONF['path_html'] . 'lib-common.php')) {
+ $config->set('path_html', $path_html);
+ }
+ if (! file_exists($_CONF['path_themes'] . $_CONF['theme']
+ . '/header.thtml')) {
+ $config->set('path_themes', $path_html . 'layout/');
+ }
+ if (! file_exists($_CONF['path_images'] . 'articles')) {
+ $config->set('path_images', $path_html . 'images/');
+ }
+ if (substr($_CONF['rdf_file'], strlen($path_html)) != $path_html) {
+ // this may not be correct but neither was the old value apparently ...
+ $config->set('rdf_file', $path_html . 'backend/geeklog.rss');
+ }
+
+ if (! empty($site_url) && ($_CONF['site_url'] != $site_url)) {
+ $config->set('site_url', $site_url);
+
+ // if we had to fix the site's URL, chances are that cookie domain
+ // and path are also wrong and the user won't be able to log in
+ $config->set('cookiedomain', '');
+ $config->set('cookie_path', '/');
+ }
+ if (! empty($site_admin_url) &&
+ ($_CONF['site_admin_url'] != $site_admin_url)) {
+ $config->set('site_admin_url', $site_admin_url);
+ }
+}
+
?>
More information about the geeklog-cvs
mailing list