UTF-8 - konverter now working
This commit is contained in:
66
install/updates/froxlor/0.9/update_0.9.inc.php
Normal file
66
install/updates/froxlor/0.9/update_0.9.inc.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if($settings['panel']['frontend'] == 'froxlor'
|
||||||
|
&& $settings['panel']['version'] == '0.9-r1')
|
||||||
|
{
|
||||||
|
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 0.9-r1 to 0.9-r2");
|
||||||
|
|
||||||
|
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (119, 'spf', 'use_spf', '0');");
|
||||||
|
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (120, 'spf', 'spf_entry', '@ IN TXT \"v=spf1 a mx -all\"');");
|
||||||
|
|
||||||
|
// Convert all data to UTF-8 to have a sane standard across all data
|
||||||
|
$result = $db->query("SHOW TABLES");
|
||||||
|
while($table = $db->fetch_array($result, 'num'))
|
||||||
|
{
|
||||||
|
$db->query("ALTER TABLE " . $table[0] . " CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;");
|
||||||
|
$db->query("ALTER TABLE " . $table[0] . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
|
||||||
|
|
||||||
|
$affected_columns = array();
|
||||||
|
|
||||||
|
$primarykey = "";
|
||||||
|
$columns = $db->query("SHOW COLUMNS FROM ".$table[0]);
|
||||||
|
while ($column = $db->fetch_array($columns))
|
||||||
|
{
|
||||||
|
if (!(strpos($column['Type'], "char") === false) || !(strpos($column['Type'], "text") === false))
|
||||||
|
{
|
||||||
|
$affected_columns[] = $column['Field'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($column['Key'] == 'PRI') {
|
||||||
|
$primarykey = $column['Field'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$count_cols = count($affected_columns);
|
||||||
|
if ($count_cols > 0)
|
||||||
|
{
|
||||||
|
$load = "";
|
||||||
|
foreach($affected_columns as $col)
|
||||||
|
{
|
||||||
|
$load .= ", `" . $col . "`";
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows = $db->query("SELECT $primarykey" . $load . " FROM `" . $table[0] . "`");
|
||||||
|
while ($row = $db->fetch_array($rows))
|
||||||
|
{
|
||||||
|
$changes = "";
|
||||||
|
for ($i = 0; $i < $count_cols; $i++)
|
||||||
|
{
|
||||||
|
$base = "`" . $affected_columns[$i] . "` = '" . convertUtf8($row[$affected_columns[$i]]) . "'";
|
||||||
|
$changes .= ($i == ($count_cols-1)) ? $base : $base . ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->query("UPDATE `" . $table[0] . "` SET " . $changes . " WHERE `$primarykey` = " . $db->escape($row[$primarykey]) . ";");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->query("UPDATE `panel_settings` SET `varname` = 'froxlor_graphic' WHERE `varname` = 'syscp_graphic'");
|
||||||
|
|
||||||
|
// set new version
|
||||||
|
|
||||||
|
$query = 'UPDATE `%s` SET `value` = \'0.9-r2\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\'';
|
||||||
|
$query = sprintf($query, TABLE_PANEL_SETTINGS);
|
||||||
|
$db->query($query);
|
||||||
|
$settings['panel']['version'] = '0.9-r2';
|
||||||
|
}
|
||||||
@@ -37,6 +37,8 @@ if($settings['panel']['frontend'] == 'froxlor'
|
|||||||
&& $settings['panel']['version'] == '0.9')
|
&& $settings['panel']['version'] == '0.9')
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 0.9 to 0.9-r1");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* add missing database-updates if necessary (old: update/update_database.php
|
* add missing database-updates if necessary (old: update/update_database.php
|
||||||
*/
|
*/
|
||||||
@@ -197,60 +199,13 @@ if($settings['panel']['frontend'] == 'froxlor'
|
|||||||
$db->query("ALTER TABLE `" . TABLE_PANEL_ADMINS . "`
|
$db->query("ALTER TABLE `" . TABLE_PANEL_ADMINS . "`
|
||||||
MODIFY `traffic` BIGINT(30),
|
MODIFY `traffic` BIGINT(30),
|
||||||
MODIFY `traffic_used` BIGINT(30)");
|
MODIFY `traffic_used` BIGINT(30)");
|
||||||
|
// set new version
|
||||||
|
|
||||||
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (119, 'spf', 'use_spf', '0');");
|
$query = 'UPDATE `%s` SET `value` = \'0.9-r1\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\'';
|
||||||
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (120, 'spf', 'spf_entry', '@ IN TXT \"v=spf1 a mx -all\"');");
|
$query = sprintf($query, TABLE_PANEL_SETTINGS);
|
||||||
|
$db->query($query);
|
||||||
|
$settings['panel']['version'] = '0.9-r1';
|
||||||
|
|
||||||
// Convert all data to UTF-8 to have a sane standard across all data
|
|
||||||
$tables = $db->fetch_array("SHOW TABLES");
|
|
||||||
foreach ($tables as $table)
|
|
||||||
{
|
|
||||||
$db->query("ALTER TABLE " . $table[0] . " CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;");
|
|
||||||
$db->query("ALTER TABLE " . $table[0] . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
|
|
||||||
|
|
||||||
$columns = $db->fetch_array("SHOW COLUMNS FROM ".$table[0]);
|
|
||||||
|
|
||||||
$affected_columns = array();
|
|
||||||
|
|
||||||
$primarykey = "";
|
|
||||||
foreach ($columns as $column)
|
|
||||||
{
|
|
||||||
if (!(strpos($column['Type'], "char") === false) || !(strpos($column['Type'], "text") === false))
|
|
||||||
{
|
|
||||||
$affected_columns[] = $column['Field'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($column['Key'] == 'PRI') {
|
|
||||||
$primarykey = $column['Field'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$count_cols = count($affected_columns);
|
|
||||||
if ($count_cols > 0)
|
|
||||||
{
|
|
||||||
$load = "";
|
|
||||||
foreach($affected_columns as $col)
|
|
||||||
{
|
|
||||||
$load .= ", " . $col;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows = $db->fetch_array("SELECT $primarykey" . $load . " FROM " . $table[0]);
|
|
||||||
|
|
||||||
foreach($rows as $row)
|
|
||||||
{
|
|
||||||
$changes = "";
|
|
||||||
for ($i = 0; $i < $count_cols; $i++)
|
|
||||||
{
|
|
||||||
$base = $affected_columns[$i] . " = " . $db->escape(convertUtf8($row[$affected_columns[$i]])) ;
|
|
||||||
$changes .= ($i == ($count_cols-1)) ? $base : $base . ", ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->query("UPDATE " . $table[0] . " SET " . $changes . " WHERE $primarykey = " . $db->escape($row['id']) . ";");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->query("UPDATE `panel_settings` SET `varname` = 'froxlor_graphic' WHERE `varname` = 'syscp_graphic'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ unset($result);
|
|||||||
|
|
||||||
require ('../lib/functions.php');
|
require ('../lib/functions.php');
|
||||||
|
|
||||||
$updatelog = SysCPLogger::getInstanceOf(array('loginname' => 'updater'), $db, $settings);
|
$updatelog = FroxlorLogger::getInstanceOf(array('loginname' => 'updater'), $db, $settings);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* since froxlor, we have to check if there's still someone
|
* since froxlor, we have to check if there's still someone
|
||||||
@@ -68,7 +68,7 @@ if(!isset($settings['panel']['frontend'])
|
|||||||
|| (substr($settings['panel']['version'], 0, 3) == '1.0' && $settings['panel']['version'] != '1.0.10'))
|
|| (substr($settings['panel']['version'], 0, 3) == '1.0' && $settings['panel']['version'] != '1.0.10'))
|
||||||
{
|
{
|
||||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.0 to 1.0.10");
|
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.0 to 1.0.10");
|
||||||
include_once ('./updates/1.0/update_1.0_1.0.10.inc.php');
|
include_once ('./updates/syscp/1.0/update_1.0_1.0.10.inc.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,7 +78,7 @@ if(!isset($settings['panel']['frontend'])
|
|||||||
if($settings['panel']['version'] == '1.0.10')
|
if($settings['panel']['version'] == '1.0.10')
|
||||||
{
|
{
|
||||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.0.10 to 1.2-beta1");
|
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.0.10 to 1.2-beta1");
|
||||||
include_once ('./updates/1.0/update_1.0.10_1.2-beta1.inc.php');
|
include_once ('./updates/syscp/1.0/update_1.0.10_1.2-beta1.inc.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +88,7 @@ if(!isset($settings['panel']['frontend'])
|
|||||||
if(substr($settings['panel']['version'], 0, 3) == '1.2')
|
if(substr($settings['panel']['version'], 0, 3) == '1.2')
|
||||||
{
|
{
|
||||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.2-beta1 to 1.2.19");
|
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.2-beta1 to 1.2.19");
|
||||||
include_once ('./updates/1.2/update_1.2-beta1_1.2.19.inc.php');
|
include_once ('./updates/syscp/1.2/update_1.2-beta1_1.2.19.inc.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +98,7 @@ if(!isset($settings['panel']['frontend'])
|
|||||||
if(substr($settings['panel']['version'], 0, 6) == '1.2.19')
|
if(substr($settings['panel']['version'], 0, 6) == '1.2.19')
|
||||||
{
|
{
|
||||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.2.19 to 1.4");
|
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.2.19 to 1.4");
|
||||||
include_once ('./updates/1.2/update_1.2.19_1.4.inc.php');
|
include_once ('./updates/syscp/1.2/update_1.2.19_1.4.inc.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,7 +108,7 @@ if(!isset($settings['panel']['frontend'])
|
|||||||
if(substr($settings['panel']['version'], 0, 3) == '1.4')
|
if(substr($settings['panel']['version'], 0, 3) == '1.4')
|
||||||
{
|
{
|
||||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.4");
|
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.4");
|
||||||
include_once ('./updates/1.4/update_1.4.inc.php');
|
include_once ('./updates/syscp/1.4/update_1.4.inc.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,6 +120,16 @@ if(!isset($settings['panel']['frontend'])
|
|||||||
*/
|
*/
|
||||||
include_once ('./updates/froxlor/upgrade_syscp.inc.php');
|
include_once ('./updates/froxlor/upgrade_syscp.inc.php');
|
||||||
|
|
||||||
|
}
|
||||||
|
if(!isset($settings['panel']['frontend'])
|
||||||
|
|| $settings['panel']['frontend'] == 'froxlor')
|
||||||
|
{
|
||||||
|
if($settings['panel']['version'] == '0.9-r1')
|
||||||
|
{
|
||||||
|
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 0.9");
|
||||||
|
include_once ('./updates/froxlor/0.9/update_0.9.inc.php');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCounters();
|
updateCounters();
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ define('PACKAGE_ENABLED', 2);
|
|||||||
|
|
||||||
// VERSION INFO
|
// VERSION INFO
|
||||||
|
|
||||||
$version = '0.9';
|
$version = '0.9-r2';
|
||||||
$dbversion = '2';
|
$dbversion = '2';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user