From 9cb70e72b97d215bd3eb92205fb1948541a5ad51 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Tue, 1 Sep 2009 20:09:36 +0000 Subject: [PATCH] Convert serialized core prefs to e107 arrayStorage during upgrade. Modified pref_class. expecting some things to break.. work in progress. default_install.xml should now install default emoticon pack correctly. --- e107_admin/emoticon.php | 23 ++-- e107_admin/update_routines.php | 28 ++++- e107_files/default_install.xml | 220 +++++---------------------------- e107_handlers/emote_filter.php | 11 +- e107_handlers/mysql_class.php | 8 +- e107_handlers/pref_class.php | 19 +-- 6 files changed, 95 insertions(+), 214 deletions(-) diff --git a/e107_admin/emoticon.php b/e107_admin/emoticon.php index 97cf9ff29..3c9f5f81e 100644 --- a/e107_admin/emoticon.php +++ b/e107_admin/emoticon.php @@ -9,9 +9,9 @@ * Administration Area - Emotions Settings & Packs * * $Source: /cvs_backup/e107_0.8/e107_admin/emoticon.php,v $ - * $Revision: 1.16 $ - * $Date: 2009-08-28 16:11:00 $ - * $Author: marj_nl_fr $ + * $Revision: 1.17 $ + * $Date: 2009-09-01 20:09:35 $ + * $Author: e107coders $ * */ @@ -30,10 +30,11 @@ require_once("auth.php"); require_once(e_HANDLER."message_handler.php"); $emessage = &eMessage::getInstance(); -if(!$sql->db_Count("core", "(*)", "WHERE e107_name = 'emote_default'")) +if(!$sql->db_Count("core", "(*)", "WHERE e107_name = 'emote_default' AND e107_value !='' ")) { // Set up the default emotes $tmp = 'a:28:{s:9:"alien!png";s:6:"!alien";s:10:"amazed!png";s:7:"!amazed";s:9:"angry!png";s:11:"!grr !angry";s:12:"biglaugh!png";s:4:"!lol";s:11:"cheesey!png";s:10:":D :oD :-D";s:12:"confused!png";s:10:":? :o? :-?";s:7:"cry!png";s:19:"&| &-| &o| :(( !cry";s:8:"dead!png";s:21:"x) xo) x-) x( xo( x-(";s:9:"dodge!png";s:6:"!dodge";s:9:"frown!png";s:10:":( :o( :-(";s:7:"gah!png";s:10:":@ :o@ :o@";s:8:"grin!png";s:10:":D :oD :-D";s:9:"heart!png";s:6:"!heart";s:8:"idea!png";s:10:":! :o! :-!";s:7:"ill!png";s:4:"!ill";s:7:"mad!png";s:13:"~:( ~:o( ~:-(";s:12:"mistrust!png";s:9:"!mistrust";s:11:"neutral!png";s:10:":| :o| :-|";s:12:"question!png";s:2:"?!";s:12:"rolleyes!png";s:10:"B) Bo) B-)";s:7:"sad!png";s:4:"!sad";s:10:"shades!png";s:10:"8) 8o) 8-)";s:7:"shy!png";s:4:"!shy";s:9:"smile!png";s:10:":) :o) :-)";s:11:"special!png";s:3:"%-6";s:12:"suprised!png";s:10:":O :oO :-O";s:10:"tongue!png";s:21:":p :op :-p :P :oP :-P";s:8:"wink!png";s:10:";) ;o) ;-)";}'; - $sql->db_Insert("core", "'emote_default', '{$tmp}' "); + $insert = array("e107_name"=>"emote_default", "e107_value"=>$tmp); + $sql->db_Replace("core", $insert); } @@ -260,8 +261,7 @@ class emotec global $e107, $fl, $sysprefs, $tp; $corea = "emote_".$packID; - $emotecode = $sysprefs -> getArray($corea); - + $emotecode = $sysprefs -> getArray($corea); $reject = '~^emoteconf|\.html$|\.php$|\.txt$|\.pak$|\.xml|\.phpBB'; // Files to exclude $emoteArray = $fl -> get_files(e_IMAGE."emotes/".$packID, $reject); @@ -394,7 +394,8 @@ class emotec $packID = $_POST['packID']; unset($_POST['sub_conf'], $_POST['packID']); $encoded_emotes = $tp->toDB($_POST); - $tmp = addslashes(serialize($encoded_emotes)); + // $tmp = addslashes(serialize($encoded_emotes)); + $tmp = e107::getArrayStorage()->WriteArray($encoded_emotes); if ($sql->db_Select("core", "*", "e107_name='emote_".$packID."'")) { @@ -487,7 +488,8 @@ class emotec $confIC = str_replace(".", "!", $tmp[0]); $confArray[$confIC] = trim($tmp[2]); } - $tmp = addslashes(serialize($confArray)); + // $tmp = addslashes(serialize($confArray)); + $tmp = e107::getArrayStorage()->WriteArray($confArray); $File_type = EMOLAN_22; } /* end */ @@ -596,7 +598,8 @@ class emotec // Save pack info in the database - $tmp = addslashes(serialize($confArray)); + // $tmp = addslashes(serialize($confArray)); + $tmp = e107::getArrayStorage()->WriteArray($confArray); $File_type = EMOLAN_23; } diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index 7d194cbef..4012986c8 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $ -| $Revision: 1.45 $ -| $Date: 2009-09-01 02:00:55 $ +| $Revision: 1.46 $ +| $Date: 2009-09-01 20:09:35 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -252,6 +252,9 @@ function update_706_to_800($type='') // List of DB tables newly required (defined in core_sql.php) (The existing dblog table gets renamed) $new_tables = array('admin_log','audit_log', 'dblog'); + + // List of core prefs that need to be converted from serialized to e107ArrayStorage. + $serialized_prefs = array("'emote'", "'menu_pref'", "'search_prefs'", "'emote_default'"); // List of changed DB tables (defined in core_sql.php) @@ -338,6 +341,21 @@ function update_706_to_800($type='') $updateMessages[] = LAN_UPDATE_22; $do_save = TRUE; } + + // convert all serialized core prefs to e107 ArrayStorage; + $serialz_qry = "SUBSTRING( e107_value,1,5)!='array' AND e107_value !='' "; + // $serialz_qry .= "AND e107_name IN (".implode(",",$serialized_prefs).") "; + if(e107::getDb()->db_Select("core", "*", $serialz_qry)) + { + if ($just_check) return update_needed(); + while ($row = e107::getDb()->db_Fetch(MYSQL_ASSOC)) + { + e107::getDb('sql2')->db_Update('core',"e107_value=\"".convert_serialized($row['e107_value'])."\" WHERE e107_name='".$row['e107_name']."'"); + $updateMessages[] = "Converted Serialized prefs [".$row['e107_name']."]"; // LAN_UPDATE_23; + } + } + + //TODO de-serialize the user_prefs also. //change menu_path for usertheme_menu if($sql->db_Select("menus", "menu_path", "menu_path='usertheme_menu' || menu_path='usertheme_menu/'")) @@ -963,5 +981,11 @@ function get_default_prefs() return $pref; } +function convert_serialized($serializedData) +{ + $arrayData = unserialize($serializedData); + return e107::getArrayStorage()->WriteArray($arrayData,FALSE); +} + ?> diff --git a/e107_files/default_install.xml b/e107_files/default_install.xml index 4b8eab6ae..e93b99593 100644 --- a/e107_files/default_install.xml +++ b/e107_files/default_install.xml @@ -1,5 +1,5 @@ - + 1 0 @@ -27,7 +27,7 @@ 0 0 e107cookie - 'e-administrator', 1 => 'e-cpage', 2 => 'e-filemanager', @@ -187,7 +187,7 @@ City, State, Country )]]> / - + 1 0 0 @@ -211,186 +211,34 @@ City, State, Country 0 0 1 - 'cry.png', -)]]> - 'cry.png', -)]]> - 'cry.png', -)]]> - 'cry.png', -)]]> - 'mad.png', -)]]> - 'mad.png', -)]]> - 'mad.png', -)]]> - 'smile.png', -)]]> - 'smile.png', -)]]> - 'smile.png', -)]]> - 'frown.png', -)]]> - 'frown.png', -)]]> - 'frown.png', -)]]> - 'grin.png', -)]]> - 'grin.png', -)]]> - 'grin.png', -)]]> - 'confused.png', -)]]> - 'confused.png', -)]]> - 'confused.png', -)]]> - 'special.png', -)]]> - 'dead.png', -)]]> - 'dead.png', -)]]> - 'dead.png', -)]]> - 'dead.png', -)]]> - 'dead.png', -)]]> - 'dead.png', -)]]> - 'gah.png', -)]]> - 'gah.png', -)]]> - 'gah.png', -)]]> - 'idea.png', -)]]> - 'idea.png', -)]]> - 'idea.png', -)]]> - 'neutral.png', -)]]> - 'neutral.png', -)]]> - 'neutral.png', -)]]> - 'question.png', -)]]> - 'rolleyes.png', -)]]> - 'rolleyes.png', -)]]> - 'rolleyes.png', -)]]> - 'shades.png', -)]]> - 'shades.png', -)]]> - 'shades.png', -)]]> - 'suprised.png', -)]]> - 'suprised.png', -)]]> - 'suprised.png', -)]]> - 'tongue.png', -)]]> - 'tongue.png', -)]]> - 'tongue.png', -)]]> - 'tongue.png', -)]]> - 'tongue.png', -)]]> - 'tongue.png', -)]]> - 'wink.png', -)]]> - 'wink.png', -)]]> - 'wink.png', -)]]> - 'ill.png', -)]]> - 'amazed.png', -)]]> - 'cry.png', -)]]> - 'dodge.png', -)]]> - 'alien.png', -)]]> - 'heart.png', -)]]> + !alien + !amazed + !grr !angry + !lol + :D :oD :-D + :? :o? :-? + + x) xo) x-) x( xo( x-( + !dodge + :( :o( :-( + :@ :o@ :o@ + :D :oD :-D + !heart + :! :o! :-! + !ill + ~:( ~:o( ~:-( + !mistrust + :| :o| :-| + ?! + B) Bo) B-) + !sad + 8) 8o) 8-) + !shy + :) :o) :-) + %-6 + :O :oO :-O + :p :op :-p :P :oP :-P + ;) ;o) ;-) Date / Time Latest Comments 50 @@ -517,7 +365,7 @@ City, State, Country 'class' => '254', 'email' => '', ), - 'newsdel' => + 'newsdel' => array ( 'class' => '254', 'email' => '', @@ -791,10 +639,10 @@ City, State, Country 1 Welcome to e107 - + Welcome :-) :-( :-))) 1251665200 - 0 + 1 1 1 0 diff --git a/e107_handlers/emote_filter.php b/e107_handlers/emote_filter.php index 1b0465a1b..3e057dfd9 100644 --- a/e107_handlers/emote_filter.php +++ b/e107_handlers/emote_filter.php @@ -3,7 +3,7 @@ + ----------------------------------------------------------------------------+ | e107 website system | -| ©Steve Dunstan 2001-2002 +| �Steve Dunstan 2001-2002 | http://e107.org | jalist@e107.org | @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/emote_filter.php,v $ -| $Revision: 1.3 $ -| $Date: 2009-07-25 07:54:34 $ -| $Author: marj_nl_fr $ +| $Revision: 1.4 $ +| $Date: 2009-09-01 20:09:35 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -32,6 +32,8 @@ class e_emotefilter { $pref['emotepack'] = "default"; save_prefs(); } + + $this->emotes = $sysprefs->getArray("emote_".$pref['emotepack']); foreach($this->emotes as $key => $value) @@ -46,6 +48,7 @@ class e_emotefilter { $key = str_replace("!", "_", $key); $filename = e_IMAGE."emotes/" . $pref['emotepack'] . "/" . $key; + $fileloc = SITEURLBASE.e_IMAGE_ABS."emotes/" . $pref['emotepack'] . "/" . $key; if(file_exists($filename)) diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index 3ad94647e..0a105a4e9 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -9,8 +9,8 @@ * mySQL Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $ - * $Revision: 1.41 $ - * $Date: 2009-08-31 02:00:51 $ + * $Revision: 1.42 $ + * $Date: 2009-09-01 20:09:35 $ * $Author: e107coders $ */ @@ -30,7 +30,7 @@ if(defined('MYSQL_LIGHT')) $sql = new db; $sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); } -elseif(defined('E107_INSTALL')) +elseif(defined('E107_INSTALL')) //TODO Remove the need for this if possible { class dummyTraffic { function Bump() { return; } @@ -61,7 +61,7 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s * MySQL Abstraction class * * @package e107 -* @version $Revision: 1.41 $ +* @version $Revision: 1.42 $ * @author $Author: e107coders $ */ class db { diff --git a/e107_handlers/pref_class.php b/e107_handlers/pref_class.php index f8d1f68bd..f78550a6b 100644 --- a/e107_handlers/pref_class.php +++ b/e107_handlers/pref_class.php @@ -9,8 +9,8 @@ * e107 Preference Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/pref_class.php,v $ - * $Revision: 1.15 $ - * $Date: 2009-08-31 02:49:01 $ + * $Revision: 1.16 $ + * $Date: 2009-09-01 20:09:36 $ * $Author: e107coders $ */ @@ -619,7 +619,7 @@ final class e_core_pref extends e_pref 'core' => 'SitePrefs', 'core_backup' => 'SitePrefs_Backup', 'core_old' => 'pref', - 'emote' => 'emote', + 'emote' => 'emote_default', //TODO include other emote packs of the user. 'menu' => 'menu_pref', 'search' => 'search_prefs', 'notify' => 'notify_prefs', @@ -631,7 +631,8 @@ final class e_core_pref extends e_pref * * @var array */ - protected $serial_bc_array = array('core_old', 'emote', 'menu', 'search'); + // protected $serial_bc_array = array('core_old', 'emote', 'menu', 'search'); + protected $serial_bc_array = array('core_old'); /** * Constructor @@ -858,8 +859,10 @@ class prefs * - @access public */ // retrieve prefs as an array of values - function getArray($name) { - return unserialize($this->get($name)); + function getArray($name) + { + return e107::getArrayStorage()->ReadArray($this->get($name)); + // return unserialize($this->get($name)); } @@ -945,8 +948,8 @@ class prefs $$name[$key] = $tp->toDB($prefvalue); } } - - $tmp = serialize($$name); + $tmp = e107::getArrayStorage()->WriteArray($$name); + // $tmp = serialize($$name); $this->set($tmp, $name, $table, $uid); } }