[geeklog-cvs] Geeklog-1.x/public_html/admin/install index.php, 1.36, 1.37
Dirk Haun
dhaun at qs1489.pair.com
Thu May 1 04:46:24 EDT 2008
Update of /cvsroot/geeklog/Geeklog-1.x/public_html/admin/install
In directory qs1489.pair.com:/tmp/cvs-serv82897
Modified Files:
index.php
Log Message:
Added UTF-8 option (bug #0000610)
Index: index.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/admin/install/index.php,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** index.php 20 Apr 2008 08:26:50 -0000 1.36
--- index.php 1 May 2008 08:46:22 -0000 1.37
***************
*** 118,122 ****
function INST_installEngine($install_type, $install_step)
{
! global $_CONF, $LANG_INSTALL, $_DB, $_TABLES, $gl_path, $html_path, $dbconfig_path, $siteconfig_path, $display, $language;
switch ($install_step) {
--- 118,122 ----
function INST_installEngine($install_type, $install_step)
{
! global $_CONF, $LANG_INSTALL, $LANG_CHARSET, $_DB, $_TABLES, $gl_path, $html_path, $dbconfig_path, $siteconfig_path, $display, $language;
switch ($install_step) {
***************
*** 170,173 ****
--- 170,181 ----
$site_mail = isset($_POST['site_mail']) ? $_POST['site_mail'] : ($_CONF['site_mail'] == 'admin at example.com' ? $_CONF['site_mail'] : 'admin@' . $host_name);
$noreply_mail = isset($_POST['noreply_mail']) ? $_POST['noreply_mail'] : ($_CONF['noreply_mail'] == 'noreply at example.com' ? $_CONF['noreply_mail'] : 'noreply@' . $host_name);
+ if (isset($_POST['utf8']) && ($_POST['utf8'] == 'on')) {
+ $utf8 = true;
+ } else {
+ $utf8 = false;
+ if (strcasecmp($LANG_CHARSET, 'utf-8') == 0) {
+ $utf8 = true;
+ }
+ }
if ($install_type == 'install') {
***************
*** 204,209 ****
<p><label>' . $LANG_INSTALL[47] . ' ' . INST_helpLink('') . '</label> <input type="text" name="site_admin_url" value="' . $site_admin_url . '" size="50"' . XHTML . '> ' . $LANG_INSTALL[46] . '</p>
<p><label>' . $LANG_INSTALL[48] . ' ' . INST_helpLink('') . '</label> <input type="text" name="site_mail" value="' . $site_mail . '" size="50"' . XHTML . '></p>
! <p><label>' . $LANG_INSTALL[49] . ' ' . INST_helpLink('') . '</label> <input type="text" name="noreply_mail" value="' . $noreply_mail . '" size="50"' . XHTML . '></p>
<br' . XHTML . '>
<input type="submit" name="submit" class="submit" value="' . $buttontext . ' >>"' . XHTML . '>
--- 212,223 ----
<p><label>' . $LANG_INSTALL[47] . ' ' . INST_helpLink('') . '</label> <input type="text" name="site_admin_url" value="' . $site_admin_url . '" size="50"' . XHTML . '> ' . $LANG_INSTALL[46] . '</p>
<p><label>' . $LANG_INSTALL[48] . ' ' . INST_helpLink('') . '</label> <input type="text" name="site_mail" value="' . $site_mail . '" size="50"' . XHTML . '></p>
! <p><label>' . $LANG_INSTALL[49] . ' ' . INST_helpLink('') . '</label> <input type="text" name="noreply_mail" value="' . $noreply_mail . '" size="50"' . XHTML . '></p>';
!
! if ($install_type == 'install') {
! $display .= '
! <p><label>' . $LANG_INSTALL[92] . ' ' . INST_helpLink('') . '</label> <input type="checkbox" name="utf8"' . ($utf8 ? ' checked="checked"' : '') . XHTML . '></p>';
! }
+ $display .= '
<br' . XHTML . '>
<input type="submit" name="submit" class="submit" value="' . $buttontext . ' >>"' . XHTML . '>
***************
*** 213,217 ****
/**
! * Page 2 - Enter information into config.php
* and ask about InnoDB tables (if supported)
*/
--- 227,231 ----
/**
! * Page 2 - Enter information into db-config.php
* and ask about InnoDB tables (if supported)
*/
***************
*** 230,233 ****
--- 244,248 ----
$site_mail = $_POST['site_mail'];
$noreply_mail = $_POST['noreply_mail'];
+ $utf8 = (isset($_POST['utf8']) && ($_POST['utf8'] == 'on')) ? true : false;
// If using MySQL check to make sure the version is supported
***************
*** 313,320 ****
$dbconfig_file = fopen($dbconfig_path, 'w');
if (!fwrite($dbconfig_file, $dbconfig_data)) {
! exit($LANG_INSTALL[26] . ' ' . $dbconfig_path . $LANG_INSTALL[58]);
}
fclose($dbconfig_file);
require $dbconfig_path;
require_once $siteconfig_path;
--- 328,342 ----
$dbconfig_file = fopen($dbconfig_path, 'w');
if (!fwrite($dbconfig_file, $dbconfig_data)) {
! exit($LANG_INSTALL[26] . ' ' . $dbconfig_path
! . $LANG_INSTALL[58]);
}
fclose($dbconfig_file);
+ // for the default charset, patch siteconfig.php again
+ if (!INST_setDefaultCharset($siteconfig_path, $utf8)) {
+ exit($LANG_INSTALL[26] . ' ' . $siteconfig_path
+ . $LANG_INSTALL[58]);
+ }
+
require $dbconfig_path;
require_once $siteconfig_path;
***************
*** 328,331 ****
--- 350,356 ----
. '&site_mail=' . urlencode($site_mail)
. '&noreply_mail=' . urlencode($noreply_mail);
+ if ($utf8) {
+ $req_string .= '&utf8=true';
+ }
switch ($install_type) {
***************
*** 340,344 ****
<input type="hidden" name="site_admin_url" value="' . urlencode($site_admin_url) . '"' . XHTML . '>
<input type="hidden" name="site_mail" value="' . urlencode($site_mail) . '"' . XHTML . '>
! <input type="hidden" name="noreply_mail" value="' . urlencode($noreply_mail) . '"' . XHTML . '>';
// If using MySQL check to see if InnoDB is supported
--- 365,370 ----
<input type="hidden" name="site_admin_url" value="' . urlencode($site_admin_url) . '"' . XHTML . '>
<input type="hidden" name="site_mail" value="' . urlencode($site_mail) . '"' . XHTML . '>
! <input type="hidden" name="noreply_mail" value="' . urlencode($noreply_mail) . '"' . XHTML . '>
! <input type="hidden" name="utf8" value="' . ($utf8 ? 'true' : 'false') . '"' . XHTML . '>';
// If using MySQL check to see if InnoDB is supported
***************
*** 445,448 ****
--- 471,479 ----
}
+ $utf8 = false;
+ if ((isset($_POST['utf8']) && $_POST['utf8'] == 'true') || (isset($_GET['utf8']) && $_GET['utf8'] == 'true')) {
+ $utf8 = true;
+ }
+
// We need all this just to do one DB query
require_once $dbconfig_path;
***************
*** 519,524 ****
$config->set_default('default_photo', urldecode($site_url) . '/default.jpg');
! $charset = ''; // TBD: needs to be set ...
! $lng = INST_getDefaultLanguage($gl_path . 'language/', $language, $charset);
if (!empty($lng)) {
$config->set('language', $lng);
--- 550,554 ----
$config->set_default('default_photo', urldecode($site_url) . '/default.jpg');
! $lng = INST_getDefaultLanguage($gl_path . 'language/', $language, $utf8);
if (!empty($lng)) {
$config->set('language', $lng);
***************
*** 601,607 ****
* server. If they aren't display a warning message.
*
! * @param string $dbconfig_path Path to config.php
! * @param string $siteconfig_path Path to lib-common.php
! * @return boolean true if both files are writeable
*
*/
--- 631,636 ----
* server. If they aren't display a warning message.
*
! * @param array $files list of files to check
! * @return boolean true if all files are writeable
*
*/
***************
*** 617,620 ****
--- 646,650 ----
}
}
+
return $writable;
}
***************
*** 895,906 ****
* @param string $langpath path where the language files are kept
* @param string $language language used in the install script
! * @param string $charset character set: UTF-8 or something else
* @return string name of default language (for the config)
*
*/
! function INST_getDefaultLanguage($langpath, $language, $charset = '')
{
! if (strcasecmp('UTF-8', $charset) == 0) {
! $lngname = $language . '_' . strtolower($charset);
} else {
$lngname = $language;
--- 925,936 ----
* @param string $langpath path where the language files are kept
* @param string $language language used in the install script
! * @param boolean $utf8 whether to use UTF-8
* @return string name of default language (for the config)
*
*/
! function INST_getDefaultLanguage($langpath, $language, $utf8 = false)
{
! if ($utf8) {
! $lngname = $language . '_utf-8';
} else {
$lngname = $language;
***************
*** 910,915 ****
if (!file_exists($langpath . $lngfile)) {
// doesn't exist - fall back to English
! if (strcasecmp('UTF-8', $charset) == 0) {
! $lngname = 'english_' . strtolower($charset);
} else {
$lngname = 'english';
--- 940,945 ----
if (!file_exists($langpath . $lngfile)) {
// doesn't exist - fall back to English
! if ($utf8) {
! $lngname = 'english_utf-8';
} else {
$lngname = 'english';
***************
*** 1464,1467 ****
--- 1494,1537 ----
return $disabled;
+ }
+
+ /**
+ * Change default character set to UTF-8
+ *
+ * @param string $siteconfig_path complete path to siteconfig.php
+ * @param boolen $utf8 true: use UTF-8
+ * @return boolean true: success; false: an error occured
+ * @note Yes, this means that we need to patch siteconfig.php a second time.
+ *
+ */
+ function INST_setDefaultCharset($siteconfig_path, $utf8 = false)
+ {
+ global $LANG_CHARSET;
+
+ $result = true;
+
+ $siteconfig_file = fopen($siteconfig_path, 'r');
+ $siteconfig_data = fread($siteconfig_file, filesize($siteconfig_path));
+ fclose($siteconfig_file);
+
+ if ($utf8) {
+ $new_charset = 'utf-8';
+ } else {
+ $new_charset = $LANG_CHARSET;
+ }
+
+ require_once $siteconfig_path;
+
+ $siteconfig_data = str_replace("\$_CONF['default_charset'] = '{$_CONF['default_charset']}';",
+ "\$_CONF['default_charset'] = '{$new_charset}';",
+ $siteconfig_data);
+
+ $siteconfig_file = fopen($siteconfig_path, 'w');
+ if (!fwrite($siteconfig_file, $siteconfig_data)) {
+ $result = false;
+ }
+ @fclose($siteconfig_file);
+
+ return $result;
}
More information about the geeklog-cvs
mailing list