[geeklog-hg] geeklog: Installer will now set cookie path properly (bug #0001541)
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Thu Jan 17 07:46:53 EST 2013
changeset 8916:bb29276bbb31
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/bb29276bbb31
user: Kenji ITO <mystralkk at gmail.com>
date: Wed Jan 16 22:05:42 2013 +0900
description:
Installer will now set cookie path properly (bug #0001541)
diffstat:
public_html/admin/install/index.php | 9 ++++---
public_html/admin/install/lib-install.php | 31 +++++++++++++++++++++++++--
public_html/admin/install/migrate.php | 34 +++++++++++++++---------------
3 files changed, 50 insertions(+), 24 deletions(-)
diffs (236 lines):
diff -r ed1753c5dd03 -r bb29276bbb31 public_html/admin/install/index.php
--- a/public_html/admin/install/index.php Wed Jan 16 17:05:04 2013 +0900
+++ b/public_html/admin/install/index.php Wed Jan 16 22:05:42 2013 +0900
@@ -421,7 +421,7 @@
require_once $dbconfig_path;
require_once $siteconfig_path;
require_once $_CONF['path_system'] . 'lib-database.php';
-
+
if($_DB_dbms=='pgsql')
{
//Create a func to check if plpgsql is already installed
@@ -518,6 +518,7 @@
$config->set('path_themes', $html_path . 'layout/');
$config->set('rdf_file', $html_path . 'backend/geeklog.rss');
$config->set('path_pear', $_CONF['path_system'] . 'pear/');
+ $config->set('cookie_path', INST_guessCookiePath(urldecode($site_url)));
$config->set_default('default_photo', urldecode($site_url) . '/default.jpg');
$lng = INST_getDefaultLanguage($gl_path . 'language/', $language, $utf8);
@@ -939,10 +940,10 @@
// $display holds all the outputted HTML and content
if (defined('XHTML')) {
- $display = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ $display = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
} else {
- $display = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+ $display = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>';
}
@@ -1216,7 +1217,7 @@
. '<input type="submit" name="install_type" class="button big-button" value="' . $LANG_INSTALL[25] . '"' . XHTML .'>' . LB
. '<input type="submit" name="install_type" class="button big-button" value="' . $LANG_INSTALL[16] . '"' . XHTML .'>' . LB
. '</form> </div> <br' . XHTML . '>' . LB;
-
+
}
break;
diff -r ed1753c5dd03 -r bb29276bbb31 public_html/admin/install/lib-install.php
--- a/public_html/admin/install/lib-install.php Wed Jan 16 17:05:04 2013 +0900
+++ b/public_html/admin/install/lib-install.php Wed Jan 16 22:05:42 2013 +0900
@@ -560,7 +560,7 @@
$mRetval = false;
}
-
+
return $mRetval;
}
@@ -910,7 +910,7 @@
if (DB_error()) {
COM_errorLog('Error adding plugin default data', 1);
PLG_uninstall($plugin);
-
+
return false;
}
}
@@ -1039,7 +1039,7 @@
// 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', '/');
+ $config->set('cookie_path', INST_guessCookiePath($site_url));
}
if (! empty($site_admin_url) &&
($_CONF['site_admin_url'] != $site_admin_url)) {
@@ -1307,4 +1307,29 @@
}
}
+/**
+* Returns a cookie path for a site URL
+*
+* @param string $site_url site URL
+* @return string a cookie path
+*/
+function INST_guessCookiePath($site_url)
+{
+ $retval = '/';
+
+ if (preg_match('|(^https?://[^/]+)|i', $site_url, $match)) {
+ $path = substr($site_url, strlen($match[1]));
+
+ if (($path !== '') AND ($path !== FALSE)) {
+ $retval = $path;
+
+ if (substr($retval, -1) !== '/') {
+ $retval .= '/';
+ }
+ }
+ }
+
+ return $retval;
+}
+
?>
diff -r ed1753c5dd03 -r bb29276bbb31 public_html/admin/install/migrate.php
--- a/public_html/admin/install/migrate.php Wed Jan 16 17:05:04 2013 +0900
+++ b/public_html/admin/install/migrate.php Wed Jan 16 22:05:42 2013 +0900
@@ -353,7 +353,7 @@
// Check if there are any files in the backups directory
if (count($backup_files) > 0) {
-
+
$display .= '<select name="backup_file">' . LB
. '<option value="">' . $LANG_MIGRATE[10] . '</option>' . LB;
@@ -369,7 +369,7 @@
. ')</option>' . LB;
}
-
+
$display .= '</select>' . LB;
} else {
@@ -380,7 +380,7 @@
$display .= '</span>' . LB
. '<span id="migration-upload">' . LB ;
-
+
// Check if the user's PHP configuration has 'file_uploads' enabled
$file_uploads = ini_get('file_uploads') ? true : false;
@@ -390,7 +390,7 @@
if ($file_uploads && $is_writable) {
$display .= '<input class="input_file" type="file" name="backup_file"' . XHTML . '><br' . XHTML . '>' . LB;
-
+
}
$display .= '</span>' . LB
@@ -400,7 +400,7 @@
if ($file_uploads) {
if ($is_writable) {
-
+
$display .= INST_getAlertMsg($LANG_MIGRATE[12] . ini_get('upload_max_filesize') . $LANG_MIGRATE[13] . ini_get('upload_max_filesize') . $LANG_MIGRATE[14], 'notice');
} else {
@@ -562,7 +562,7 @@
} else {
if (!move_uploaded_file($backup_file['tmp_name'], $backup_dir . $backup_file['name'])) { // If able to save the uploaded file
-
+
$display .= $LANG_MIGRATE[19] . $backup_file['name'] . $LANG_MIGRATE[20] . $backup_dir . '.' . LB;
} else {
@@ -846,8 +846,8 @@
// reset cookie domain and path as wrong values may prevent login
$config->set('cookiedomain', '');
$_CONF['cookiedomain'] = '';
- $config->set('cookie_path', '/');
- $_CONF['cookie_path'] = '/';
+ $config->set('cookie_path', INST_guessCookiePath($_CONF['site_url']));
+ $_CONF['cookie_path'] = INST_guessCookiePath($_CONF['site_url']);
// check the default theme
$theme = '';
@@ -891,7 +891,7 @@
$result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
$num_plugins = DB_numRows($result);
for ($i = 0; $i < $num_plugins; $i++) { // Look in the plugins directories to ensure that those plugins exist.
-
+
$plugin = DB_fetchArray($result);
if (!file_exists($_CONF['path'] . 'plugins/' . $plugin['pi_name'])) { // If plugin does not exist
@@ -958,13 +958,13 @@
}
}
-
+
// Topic images
$missing_topic_images = false;
$result = DB_query("SELECT `imageurl` FROM {$_TABLES['topics']}");
$num_topic_images = DB_numRows($result);
for ($i = 0; $i < $num_topic_images; $i++) {
-
+
$topic_image = DB_fetchArray($result);
if (!file_exists($html_path . $topic_image['imageurl'])) { // If topic image does not exist
@@ -973,9 +973,9 @@
$missing_topic_images = true;
$missing_images = true;
-
+
}
-
+
}
// Userphoto images
@@ -983,16 +983,16 @@
$result = DB_query("SELECT `photo` FROM {$_TABLES['users']} WHERE `photo` != NULL AND `photo` != ''");
$num_userphoto_images = DB_numRows($result);
for ($i = 0; $i < $num_userphoto_images; $i++) {
-
+
$userphoto_image = DB_fetchArray($result);
if (!file_exists($html_path . 'images/userphotos/' . $userphoto_image['photo'])) { // If userphoto image does not exist
-
+
// Log the error
COM_errorLog($LANG_MIGRATE[26] . $LANG_MIGRATE[29] . $userphoto_image['photo'] . $LANG_MIGRATE[30] . $_TABLES['users'] . $LANG_MIGRATE[31] . $html_path . 'images/userphotos/');
$missing_userphoto_images = true;
$missing_images = true;
-
+
}
}
@@ -1044,7 +1044,7 @@
// Topic images
if ($missing_topic_images) {
-
+
$display .= INST_getAlertMsg($LANG_MIGRATE[34] . ' <code>' . $html_path . 'images/topics/</code> ' . $LANG_MIGRATE[35], 'notice');
}
More information about the geeklog-cvs
mailing list