diff --git a/e107_admin/db.php b/e107_admin/db.php index f2011ba74..1594cbd17 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -9,8 +9,8 @@ * Administration - Database Utilities * * $Source: /cvs_backup/e107_0.8/e107_admin/db.php,v $ - * $Revision: 1.24 $ - * $Date: 2009-08-29 18:07:42 $ + * $Revision: 1.25 $ + * $Date: 2009-08-31 02:00:50 $ * $Author: e107coders $ * */ @@ -68,7 +68,7 @@ if(isset($_POST['verify_sql']) || $_GET['mode']=='verify_sql') if(isset($_POST['exportXmlFile'])) { - exportXmlFile(); + exportXmlFile($_POST['xml_prefs'],$_POST['xml_tables'],TRUE); exit(); } @@ -134,7 +134,7 @@ class system_tools if(isset($_POST['upload'])) { - $this->importCorePrefs(); + $this->importXmlFile(); } if(isset($_POST['delpref']) || (isset($_POST['delpref_checked']) && isset($_POST['delpref2']))) @@ -337,6 +337,7 @@ class system_tools { $frm = e107::getSingleton('e_form'); + $text = "
@@ -356,23 +357,23 @@ class system_tools - - - ".$frm->checkbox('xml_core_prefs', '1')." ".LAN_PREFS.": Core - -   - "; + "; + + $pref_types = e107::getConfig()->aliases; + $exclusions = array('core_old','core_backup'); - e107::getDb()->db_Select("core", "*", "e107_name NOT REGEXP('SitePrefs|SitePrefs_Backup|IconPool|emote|emote_default|notify_prefs|search_prefs|menu_pref|pref_backup') "); - while ($row = e107::getDb()->db_Fetch()) + foreach($pref_types as $key=>$description) { - $text .= " - - ".$frm->checkbox("xml_prefs[".$row['e107_name']."]", '1')." - ".LAN_PREFS.": ".$row['e107_name']." -   - - "; + if(!in_array($key,$exclusions)) + { + $text .= " + + ".$frm->checkbox("xml_prefs[".$key."]", $key)." + ".LAN_PREFS.": ".$key." +   + + "; + } } $tables = table_list(); @@ -381,7 +382,7 @@ class system_tools { $text .= " - ".$frm->checkbox("xml_table[".$name."]", $name)." Table Data: ".$name." + ".$frm->checkbox("xml_tables[".$name."]", $name)." Table Data: ".$name." $count "; @@ -406,57 +407,19 @@ class system_tools * Import XML Dump * @return */ - private function importCorePrefs() + private function importXmlFile() { - //TODO - move to own class and make generic. - // SecretR - structure changes / improvements proposal + $ret = e107::getSingleton('xmlClass')->e107Import($_FILES['file_userfile']['tmp_name'][0]); - $xmlArray = e107::getSingleton('xmlClass')->loadXMLfile($_FILES['file_userfile']['tmp_name'][0],'advanced'); - $emessage = eMessage::getInstance(); - - if(vartrue($xmlArray['prefs']['core'])) // Save Core Prefs + foreach($ret['success'] as $table) { - foreach ($xmlArray['prefs']['core'] as $val) - { - $value = (substr($val['@value'],0,7) == "array (") ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value']; - // print_a($val['@value']); - e107::getConfig()->set($val['@attributes']['name'], $value); - } - - e107::getConfig()->save(FALSE); + eMessage::getInstance()->add("Inserted $table", E_MESSAGE_SUCCESS); } - if(vartrue($xmlArray['database'])) + foreach($ret['failed'] as $table) { - foreach($xmlArray['database']['dbTable'] as $val) - { - $table = $val['@attributes']['name']; - - foreach($val['item'] as $item) - { - $insert_array = array(); - foreach($item['field'] as $f) - { - $fieldkey = $f['@attributes']['name']; - $fieldval = $f['@value']; - - $insert_array[$fieldkey] = $fieldval; - - } - if(e107::getDB()->db_Replace($table, $insert_array)!==FALSE) - { - $emessage->add("Inserted $table", E_MESSAGE_SUCCESS); - } - else - { - $emessage->add("Failed to Inserted $table", E_MESSAGE_ERROR); - } - } - - - } - - } + eMessage::getInstance()->add("Failed to Insert $table", E_MESSAGE_ERROR); + } } /** @@ -697,69 +660,9 @@ function db_adminmenu() - - - -function exportXmlFile() +function exportXmlFile($prefs,$tables,$debug=FALSE) { - - //TODO - move export/import functions to own class. - - require_once(e_ADMIN."ver.php"); - - $text = "\n"; - $text .= "\n"; - - if(varset($_POST['xml_core_prefs'])) // Export Core Preferences. - { - $pref = e107::getPref(); - $text .= "\t\n"; - foreach($pref as $key=>$val) - { - if(isset($val)) - { - $val = is_array($val) ? e107::getArrayStorage()->WriteArray($val,FALSE) : $val; - - $text .= "\t\t\n"; - } - } - $text .= "\t\n"; - } - - if(varset($_POST['xml_table'])) - { - $text .= "\t\n"; - foreach($_POST['xml_table'] as $tbl) - { - $eTable= str_replace(MPREFIX,"",$tbl); - e107::getDB()->db_Select($eTable, "*"); - $text .= "\t\n"; - while($row = e107::getDB()-> db_Fetch()) - { - $text .= "\t\t\n"; - foreach($row as $key=>$val) - { - $text .= "\t\t\t\n"; - } - - $text .= "\t\t\n"; - } - $text .= "\t\n"; - - } - $text .= "\t\n"; - } - - - - $text .= ""; - - header('Content-type: application/xml', TRUE); - header("Content-disposition: attachment; filename= e107Export_" . date("Y-m-d").".xml"); - header("Cache-Control: max-age=30"); - header("Pragma: public"); - echo $text; - exit; + e107::getSingleton('xmlClass')->e107Export($prefs,$tables,FALSE); } diff --git a/e107_files/def_e107_prefs.php b/e107_files/def_e107_prefs.php index 390d35cda..63eb00093 100644 --- a/e107_files/def_e107_prefs.php +++ b/e107_files/def_e107_prefs.php @@ -10,12 +10,14 @@ * Default preferences * * $Source: /cvs_backup/e107_0.8/e107_files/def_e107_prefs.php,v $ -* $Revision: 1.26 $ -* $Date: 2009-07-16 10:12:26 $ -* $Author: marj_nl_fr $ +* $Revision: 1.27 $ +* $Date: 2009-08-31 02:00:51 $ +* $Author: e107coders $ * */ +//TODO - discuss deprecating this file. + if (!defined('e107_INIT')) { exit(); } $pref = array ( @@ -25,8 +27,8 @@ $pref = array ( 'sitebutton' => 'button.png', 'sitetag' => LAN_PREF_2, 'sitedescription' => '', - 'siteadmin' => $site_admin_user, - 'siteadminemail' => $site_admin_email, + 'siteadmin' => 'admin', + 'siteadminemail' => 'admin@email.com', 'sitecontactinfo' => '[b]My Company[/b] 13 My Address St. City, State, Country @@ -106,7 +108,7 @@ City, State, Country 'longdate' => '%A %d %B %Y - %H:%M:%S', 'shortdate' => '%d %b : %H:%M', 'forumdate' => '%a %b %d %Y, %I:%M%p', - 'sitelanguage' => $pref_language, + 'sitelanguage' => 'English', 'maintainance_flag' => '0', 'time_offset' => '0', 'meta_tag' => '', @@ -130,7 +132,7 @@ City, State, Country 'antiflood1' => '1', 'antiflood_timeout' => '10', 'autoban' => '1', - 'sitelang_init' => $pref_language, + 'sitelang_init' => 'English', 'linkpage_screentip' => '0', 'wmessage_sc' => '0', 'frontpage_force' => array(e_UC_PUBLIC => ''), diff --git a/e107_files/default_install.xml b/e107_files/default_install.xml new file mode 100644 index 000000000..48c79ab3c --- /dev/null +++ b/e107_files/default_install.xml @@ -0,0 +1,528 @@ + + + + 1 + 0 + 0 + 1 + style.css + 0 + classis + jayya + 0 + 0 + 0 + 1 + 10 + + 1 + 0 + 100,200 + 0 + + 0 + 0 + 0 + 0 + 0 + 0 + e107cookie + 0 + 0 + 0 + 0 + 255 + 15 + 0 + 0 + 0 + 0 + 0 + + default + 0 + 0 + 100 + 1 + 30 + 5 + %a %b %d %Y, %I:%M%p + 0 + 'news.php', +)]]> + '', +)]]> + 1 + 100 + /usr/X11R6/bin/ + 120 + 1 + 0 + 0 + 1251664949 + 0 + + 0 + 1 + 0 + 1 + 0 + 30 + %A %d %B %Y - %H:%M:%S + 3 + 4 + php + + 0 + 0 + 253 + 0 + '', +)]]> + + + array ( + 'name' => 'Login', + 'link' => 'login_menu/config.php', + ), +)]]> + + 0 + 1 + 1 + + 0 + 10 + 0 + + 0 + + 0 + 0 + 0 + 255 + 254 + + 0 + [censored] + + 0 + registration@yoursite.com + e107 Website System + gd2 + 1 + 0 + %d %b : %H:%M + 0 + + 3 + 1 + 0 + 1 + 1 + 1 + 4 + 0 + + + admin + user@yoursite.com + {e_IMAGE}button.png + [b]My Company[/b] +13 My Address St. +City, State, Country +[b]Phone:[/b] 555-555-5555 +[b]Email:[/b] sales@mydomain.com + 255 + + e107, which is released under the terms of the GNU GPL License.]]> + English + English + e107 Website System + e107 Website System + jayya + + 3_column + + array ( + '@attributes' => + array ( + 'title' => '3 Columns', + 'preview' => 'preview.jpg', + 'default' => 'true', + ), + 0 => '', + ), + '2_column' => + array ( + '@attributes' => + array ( + 'title' => '2 Columns', + 'preview' => 'preview.jpg', + ), + 0 => '', + ), +)]]> + + /e107_08/ + + 0 + + 0 + 0 + + canvas.css + 0 + GMT + 1 + 1 + 255 + 0 + + 1 + 0 + 1 + 1 + 1 + 1 + cookie + 0 + 0 + 1 + + + + + 1 + wmessage + 1145848343 + 1 + + 0 + [/center]]]> + + + + + 1 + Home + index.php + + + 1 + 1 + 0 + 0 + 0 + + + 2 + Downloads + download.php + + + 1 + 2 + 0 + 0 + 0 + + + 3 + Members + user.php + + + 1 + 3 + 0 + 0 + 0 + + + 4 + Submit News + submitnews.php + + + 1 + 4 + 0 + 0 + 0 + + + 5 + Contact Us + contact.php + + + 1 + 5 + 0 + 0 + 0 + + + + + 1 + login_menu + 1 + 1 + 0 + + login_menu/ + + + + + 3 + online_menu + 0 + 0 + 0 + + online/ + + + + + 4 + blogcalendar_menu + 0 + 0 + 0 + + blogcalendar_menu/ + + + + + 5 + tree_menu + 0 + 0 + 0 + + tree_menu/ + + + + + 6 + search_menu + 0 + 0 + 0 + + search_menu/ + + + + + 7 + compliance_menu + 0 + 0 + 0 + + siteinfo_menu/ + + + + + 8 + userlanguage_menu + 0 + 0 + 0 + + user_menu/ + + + + + 9 + powered_by_menu + 2 + 2 + 0 + + siteinfo_menu/ + + + + + 12 + banner_menu + 0 + 0 + 0 + + banner_menu/ + + + + + 14 + clock_menu + 0 + 0 + 0 + + clock_menu/ + + + + + 15 + sitebutton_menu + 0 + 0 + 0 + + siteinfo_menu/ + + + + + 16 + comment_menu + 0 + 0 + 0 + + comment_menu/ + + + + + 17 + lastseen_menu + 0 + 0 + 0 + + online/ + + + + + 18 + other_news_menu + 0 + 0 + 0 + + other_news_menu/ + + + + + 19 + other_news2_menu + 0 + 0 + 0 + + other_news_menu/ + + + + + 20 + admin_menu + 0 + 0 + 0 + + admin_menu/ + + + + + 22 + PCMag + 2 + 1 + 0 + + 1 + + + + + + + 1 + Welcome to e107 + + + 1251665200 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + + welcome.png + 0 + + + + + 1 + Misc + news_16.png + + + + + 1 + + [img]{e_IMAGE}pcmag.png[/img] + 0 + 1145843485 + 0 + 0 + + + + PCMag + + + + + 1 + PRIVATEMENU + Grants access to private menu items + 254 + 0 + + 0 + 0 + + + + 2 + PRIVATEFORUM1 + Example private forum class + 254 + 0 + + 0 + 0 + + + + + \ No newline at end of file diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index 3d48af9f6..3ad94647e 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.40 $ - * $Date: 2009-08-29 18:07:42 $ + * $Revision: 1.41 $ + * $Date: 2009-08-31 02:00:51 $ * $Author: e107coders $ */ @@ -30,6 +30,23 @@ if(defined('MYSQL_LIGHT')) $sql = new db; $sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); } +elseif(defined('E107_INSTALL')) +{ + class dummyTraffic { + function Bump() { return; } + function BumpWho($val,$val) { } + function TimeDelta() { return; } + } + global $eTraffic; + $eTraffic = new dummyTraffic; + define('E107_DEBUG_LEVEL', 0); + define('e_QUERY', ''); + require_once("e107_config.php"); + define('MPREFIX', $mySQLprefix); + + $sql = new db; + $sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); +} else { if (!defined('e107_INIT')) { exit; } @@ -44,7 +61,7 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s * MySQL Abstraction class * * @package e107 -* @version $Revision: 1.40 $ +* @version $Revision: 1.41 $ * @author $Author: e107coders $ */ class db { @@ -79,8 +96,10 @@ class db { */ function db() { + global $pref, $eTraffic, $db_defaultPrefix; - $eTraffic->BumpWho('Create db object', 1); + $eTraffic->BumpWho('Create db object', 1); + $this->mySQLPrefix = MPREFIX; // Set the default prefix - may be overridden $langid = 'e107language_'.$pref['cookie_name']; if ($pref['user_tracking'] == 'session') @@ -448,7 +467,7 @@ class db { function db_Replace($table, $arg, $debug = FALSE, $log_type = '', $log_remark = '') { $arg['_REPLACE'] = TRUE; - $this->db_Insert($table, $arg, $debug, $log_type, $log_remark); + return $this->db_Insert($table, $arg, $debug, $log_type, $log_remark); } diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 8b792de02..6e5dc9414 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -3,7 +3,7 @@ + ----------------------------------------------------------------------------+ | e107 website system | -| ©Steve Dunstan 2001-2002 +| �Steve Dunstan 2001-2002 | http://e107.org | jalist@e107.org | @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $ -| $Revision: 1.74 $ -| $Date: 2009-08-17 18:42:21 $ +| $Revision: 1.75 $ +| $Date: 2009-08-31 02:00:51 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -118,7 +118,10 @@ class e107plugin */ function update_plugins_table() { - global $sql, $sql2, $mySQLprefix, $menu_pref, $tp, $pref; + $sql = e107::getDb(); + $sql2 = e107::getDb('sql2'); + + global $mySQLprefix, $menu_pref, $tp, $pref; require_once(e_HANDLER.'file_class.php'); @@ -134,15 +137,15 @@ class e107plugin { $pluginDBList[$row['plugin_path']] = $row; $pluginDBList[$row['plugin_path']]['status'] = 'read'; - // echo "Found plugin: ".$row['plugin_path']." in DB
"; + // echo "Found plugin: ".$row['plugin_path']." in DB
"; } } $i = 1; while ( $i < count($pluginList)) { - if ($pluginList[$i-1]['path'] == $pluginList[$i]['path']) - { // Must have plugin.php and plugin.xml + if ($pluginList[$i-1]['path'] == $pluginList[$i]['path']) // Must have plugin.php and plugin.xml + { if (($pluginList[$i-1]['fname'] == 'plugin.php') && ($pluginList[$i]['fname'] == 'plugin.xml')) { // echo "deleting: {$pluginList[$i-1]['path']}
"; @@ -159,6 +162,7 @@ class e107plugin $i++; } + foreach($pluginList as $p) { $plug['plug_action'] = 'scan'; // Make sure plugin.php knows what we're up to @@ -349,7 +353,7 @@ class e107plugin */ function getinfo($id, $force=false) { - global $sql; + $sql = e107::getDb(); static $getinfo_results; if(!is_array($getinfo_results)) { $getinfo_results = array(); } @@ -1636,6 +1640,7 @@ class e107plugin // Entry point to read plugin configuration data function parse_plugin($plugName, $force=false) { + $ret = ""; if(isset($this->parsed_plugin[$plugName]) && $force != true) { $this->plug_vars = $this->parsed_plugin[$plugName]; diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index 1583f1874..60c795eee 100644 --- a/e107_handlers/xml_class.php +++ b/e107_handlers/xml_class.php @@ -9,9 +9,9 @@ * Simple XML Parser * * $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $ - * $Revision: 1.16 $ - * $Date: 2009-08-27 21:50:59 $ - * $Author: secretr $ + * $Revision: 1.17 $ + * $Date: 2009-08-31 02:00:51 $ + * $Author: e107coders $ */ if (!defined('e107_INIT')) { exit; } @@ -526,116 +526,161 @@ class xmlClass return false; } - //FIXME - TEST - remove me - function xml2ary(&$string) + + private function e107ExportValue($val) { - $parser = xml_parser_create(); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_parse_into_struct($parser, $string, $vals, $index); - xml_parser_free($parser); - $mnary = array(); - $ary = &$mnary; - foreach ($vals as $r) + if(is_array($val)) { - $t = $r['tag']; - if ($r['type'] == 'open') + return "WriteArray($val,FALSE)."]]>"; + } + + if((strpos($val,"<")!==FALSE) || (strpos($val,">")!==FALSE) || (strpos($val,"&")!==FALSE)) + { + return ""; + } + + return $val; + } + + /** + * Create an e107 Export File in XML format + * @param array $prefs - see e_core_pref $aliases (eg. core, ipool etc) + * @param array $tables - table names with the prefix + * @param boolean $debug [optional] + * @return text / file for download + */ + public function e107Export($xmlprefs,$tables,$debug=FALSE) + { + require_once(e_ADMIN."ver.php"); + + $text = "\n"; + $text .= "\n"; + + if(varset($xmlprefs)) // Export Core Preferences. + { + $text .= "\t\n"; + foreach($xmlprefs as $type) { - if (isset($ary[$t])) + $theprefs = e107::getConfig($type)->getPref(); + $prefsorted = ksort($theprefs); + foreach($theprefs as $key=>$val) { - if (isset($ary[$t][0])) - $ary[$t][] = array(); + if(isset($val)) + { + $text .= "\t\t<".$type." name='$key'>".$this->e107ExportValue($val)."\n"; + } + } + } + $text .= "\t\n"; + } + + if(varset($tables)) + { + $text .= "\t\n"; + foreach($tables as $tbl) + { + $eTable= str_replace(MPREFIX,"",$tbl); + e107::getDB()->db_Select($eTable, "*"); + $text .= "\t\n"; + while($row = e107::getDB()-> db_Fetch()) + { + $text .= "\t\t\n"; + foreach($row as $key=>$val) + { + $text .= "\t\t\t".$this->e107ExportValue($val)."\n"; + } + + $text .= "\t\t\n"; + } + $text .= "\t\n"; + + } + $text .= "\t\n"; + } + + + + $text .= ""; + + if($debug==TRUE) + { + echo "
".htmlentities($text)."
"; + } + else + { + header('Content-type: application/xml', TRUE); + header("Content-disposition: attachment; filename= e107Export_" . date("Y-m-d").".xml"); + header("Cache-Control: max-age=30"); + header("Pragma: public"); + echo $text; + exit; + } + } + + /** + * Import an e107 XML file into site preferences and DB tables + * @param path $file - e107 XML file path + * @param string $only [optional] - prefs|database + * @param boolean $debug [optional] + * @return array with keys 'success' and 'failed' - DB table entry status. + */ + public function e107Import($file,$only='',$debug=FALSE) + { + + $xmlArray = $this->loadXMLfile($file,'advanced'); + + if($debug) + { + print_a($xmlArray); + return; + } + + $ret = array(); + + if(vartrue($xmlArray['prefs']) && $only !='database') // Save Core Prefs + { + foreach($xmlArray['prefs'] as $type=>$array) + { + foreach ($array as $val) + { + $value = (substr($val['@value'],0,7) == "array (") ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value']; + e107::getConfig($type)->set($val['@attributes']['name'], $value); + } + + e107::getConfig($type)->save(FALSE); + } + } + + if(vartrue($xmlArray['database']) && $only !='prefs') + { + foreach($xmlArray['database']['dbTable'] as $val) + { + $table = $val['@attributes']['name']; + + foreach($val['item'] as $item) + { + $insert_array = array(); + foreach($item['field'] as $f) + { + $fieldkey = $f['@attributes']['name']; + $fieldval = (isset($f['@value'])) ? $f['@value'] : ""; + + $insert_array[$fieldkey] = $fieldval; + } + if(e107::getDB()->db_Replace($table, $insert_array)!==FALSE) + { + $ret['success'][] = $table; + } else - $ary[$t] = array($ary[$t], array()); - $cv = &$ary[$t][count($ary[$t]) - 1]; - } - else - $cv = &$ary[$t]; - if (isset($r['attributes'])) - { - foreach ($r['attributes'] as $k=>$v) - $cv['_a'][$k] = $v; - } - $cv['_c'] = array(); - $cv['_c']['_p'] = &$ary; - $ary = &$cv['_c']; - } - elseif ($r['type'] == 'complete') - { - if (isset($ary[$t])) - { // same as open - if (isset($ary[$t][0])) - $ary[$t][] = array(); - else - $ary[$t] = array($ary[$t], array()); - $cv = &$ary[$t][count($ary[$t]) - 1]; - } - else - $cv = &$ary[$t]; - if (isset($r['attributes'])) - { - foreach ($r['attributes'] as $k=>$v) - $cv['_a'][$k] = $v; - } - $cv['_v'] = (isset($r['value']) ? $r['value'] : ''); - } - elseif ($r['type'] == 'close') - { - $ary = &$ary['_p']; - } + { + $ret['failed'][] = $table; + } + } + } } - $this->_del_p($mnary); - return $mnary; + + return $ret; } - //FIXME - TEST - remove me - function _del_p(&$ary) - { - foreach ($ary as $k=>$v) - { - if ($k === '_p') - unset($ary[$k]); - elseif (is_array($ary[$k])) - $this->_del_p($ary[$k]); - } - } - //FIXME - TEST - remove me - function ary2xml($cary, $d = 0, $forcetag = '') - { - $res = array(); - foreach ($cary as $tag=>$r) - { - if (isset($r[0])) - { - $res[] = $this->ary2xml($r, $d, $tag); - } - else - { - if ($forcetag) - $tag = $forcetag; - $sp = str_repeat("\t", $d); - $res[] = "$sp<$tag"; - if (isset($r['_a'])) - { - foreach ($r['_a'] as $at=>$av) - $res[] = " $at=\"$av\""; - } - $res[] = ">".((isset($r['_c'])) ? "\n" : ''); - if (isset($r['_c'])) - $res[] = $this->ary2xml($r['_c'], $d + 1); - elseif (isset($r['_v'])) - $res[] = $r['_v']; - $res[] = (isset($r['_c']) ? $sp : '')."\n"; - } - } - return implode('', $res); - } - - //FIXME - TEST - remove me - function ins2ary(&$ary, $element, $pos) - { - $ar1 = array_slice($ary, 0, $pos); - $ar1[] = $element; - $ary = array_merge($ar1, array_slice($ary, $pos)); - } } diff --git a/e107_languages/English/lan_installer.php b/e107_languages/English/lan_installer.php index 70e6acf1c..63223e0af 100644 --- a/e107_languages/English/lan_installer.php +++ b/e107_languages/English/lan_installer.php @@ -9,8 +9,8 @@ * * * $Source: /cvs_backup/e107_0.8/e107_languages/English/lan_installer.php,v $ - * $Revision: 1.14 $ - * $Date: 2009-08-29 02:44:39 $ + * $Revision: 1.15 $ + * $Date: 2009-08-31 02:00:51 $ * $Author: e107coders $ */ @@ -166,12 +166,14 @@ define("LANINS_107", "Website Name"); define("LANINS_108", "eg. 'My Blog'"); define("LANINS_109", "Website Theme"); define("LANINS_110", ""); -define("LANINS_111", "Pre-configure and generate content"); -define("LANINS_112", "Recommended if you wish to quickly reproduce the look of the installed theme."); +define("LANINS_111", "Include Content/Configuration"); +define("LANINS_112", "Quickly reproduce the look of the theme preview or demo. (If Available)"); define("LANINS_113", "Please enter a website name"); define("LANINS_114", "Please select a theme"); define("LANINS_115", "Theme Name"); define("LANINS_116", "Theme Type"); define("LANINS_117", "Website Preferences"); +define("LANINS_118", "Install Plugins"); +define("LANINS_119", "Install all plugins that the theme may require."); diff --git a/install_.php b/install_.php index 8a7ca5ea2..e95bc9d8d 100644 --- a/install_.php +++ b/install_.php @@ -9,8 +9,8 @@ * Installation file * * $Source: /cvs_backup/e107_0.8/install_.php,v $ -* $Revision: 1.27 $ -* $Date: 2009-08-29 02:44:39 $ +* $Revision: 1.28 $ +* $Date: 2009-08-31 02:00:51 $ * $Author: e107coders $ * */ @@ -145,52 +145,7 @@ $e_install->template->SetTag("installer_css_http", $_SERVER['PHP_SELF']."?object //obsolete $e_install->template->SetTag("installer_folder_http", e_HTTP.$installer_folder_name."/"); $e_install->template->SetTag("files_dir_http", e_FILE_ABS); -if(!isset($_POST['stage'])) -{ - $_POST['stage'] = 1; -} -$_POST['stage'] = intval($_POST['stage']); - -switch ($_POST['stage']) -{ - case 1: - $e_install->stage_1(); - break; - case 2: - $e_install->stage_2(); - break; - case 3: - $e_install->stage_3(); - break; - case 4: - $e_install->stage_4(); - break; - case 5: - $e_install->stage_5(); - break; - case 6: - $e_install->stage_6(); - break; - case 7: - $e_install->stage_7(); - break; - case 8: - $e_install->stage_8(); - break; - default: - $e_install->raise_error("Install stage information from client makes no sense to me."); -} - -if($_SERVER['QUERY_STRING'] == "debug") -{ - $e_install->template->SetTag("debug_info", print_a($e_install,TRUE)); -} -else -{ - $e_install->template->SetTag("debug_info", (count($e_install->debug_info) ? print_a($e_install->debug_info,TRUE)."Backtrace:
".print_a($e_install,TRUE) : "")); -} - -echo $e_install->template->ParseTemplate(template_data(), TEMPLATE_TYPE_DATA); +$e_install->renderPage(); @@ -227,6 +182,56 @@ class e_install $this->template->SetTag("required", ""); } + + function renderPage() + { + if(!isset($_POST['stage'])) + { + $_POST['stage'] = 1; + } + $_POST['stage'] = intval($_POST['stage']); + + switch ($_POST['stage']) + { + case 1: + $this->stage_1(); + break; + case 2: + $this->stage_2(); + break; + case 3: + $this->stage_3(); + break; + case 4: + $this->stage_4(); + break; + case 5: + $this->stage_5(); + break; + case 6: + $this->stage_6(); + break; + case 7: + $this->stage_7(); + break; + case 8: + $this->stage_8(); + break; + default: + $this->raise_error("Install stage information from client makes no sense to me."); + } + + if($_SERVER['QUERY_STRING'] == "debug") + { + $this->template->SetTag("debug_info", print_a($this,TRUE)); + } + else + { + $this->template->SetTag("debug_info", (count($this->debug_info) ? print_a($this->debug_info,TRUE)."Backtrace:
".print_a($this,TRUE) : "")); + } + + echo $this->template->ParseTemplate(template_data(), TEMPLATE_TYPE_DATA); + } function raise_error($details) { @@ -252,7 +257,7 @@ class e_install } } - function stage_1() + private function stage_1() { global $e_forms; $this->stage = 1; @@ -268,7 +273,7 @@ class e_install $this->template->SetTag("stage_content", "
\n


\n".$e_forms->return_form()."
"); } - function stage_2() + private function stage_2() { global $e_forms; $this->stage = 2; @@ -320,7 +325,7 @@ class e_install } - function stage_3() + private function stage_3() { global $e_forms; $success = TRUE; @@ -440,7 +445,7 @@ class e_install $this->template->SetTag("stage_content", $head.$e_forms->return_form()); } - function stage_4() + private function stage_4() { global $e_forms; $this->stage = 4; @@ -562,7 +567,7 @@ class e_install * @return */ - function stage_5() + private function stage_5() { global $e_forms; $this->stage = 5; @@ -614,7 +619,7 @@ class e_install * * @return html form. */ - function stage_6() + private function stage_6() { global $e_forms; $this->stage = 6; @@ -688,7 +693,7 @@ class e_install $e_forms->start_form("pref_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $output = " -
+
@@ -727,22 +732,27 @@ class e_install - - - + + + + + +
- ".LANINS_112." - + ".LANINS_119." +
+ ".LANINS_112." +
-

\n"; + \n"; $e_forms->add_plain_html($output); $this->finish_form(); $e_forms->add_button("submit", LANINS_035); $this->template->SetTag("stage_content", $e_forms->return_form()); } - function stage_7() + private function stage_7() { global $e_forms; @@ -781,8 +791,8 @@ class e_install $this->previous_steps['prefs']['sitename'] = $_POST['sitename']; $this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme']; - $this->previous_steps['prefs']['generate_content'] = $_POST['generate_content']; - + $this->previous_steps['generate_content'] = $_POST['generate_content']; + $this->previous_steps['install_plugins'] = $_POST['install_plugins']; $this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("stage_pre", LANINS_002); @@ -798,9 +808,9 @@ class e_install } - function stage_8() + private function stage_8() { - + global $e_forms; $this->stage = 8; @@ -855,8 +865,10 @@ class e_install $page = $config_result."
"; } else - { + { $errors = $this->create_tables(); + $this->import_configuration(); + if ($errors == true) { $page = $errors."
"; @@ -871,10 +883,123 @@ class e_install $this->template->SetTag("stage_content", $page.$e_forms->return_form()); } + /** + * Import and Generate Preferences and default content. + * @return + */ + private function import_configuration() + { + define("E107_INSTALL",TRUE); //FIXME - remove the need for this - ie. make the MySQL class work without it. + + $themeImportFile = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install.xml"; + if($this->previous_steps['generate_content']==1 && is_readable($themeImportFile)) + { + $XMLImportfile = $themeImportFile; + } + else + { + $XMLImportfile = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml"; + } + + // Insert Defaults. + $udirs = "admin/|plugins/|temp"; + $e_SELF = $_SERVER['PHP_SELF']; + $e_HTTP = preg_replace("#".$udirs."#i", "", substr($e_SELF, 0, strrpos($e_SELF, "/"))."/"); - // Check a DB name or table prefix - anything starting with a numeric followed by 'e' causes problems. - // Return TRUE if acceptable, FALSE if unacceptable - // Empty string returns the value of $blank_ok (caller should set TRUE for prefix, FALSE for DB name) + $pref_language = isset($this->previous_steps['language']) ? $this->previous_steps['language'] : "English"; + + if (is_readable($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$pref_language."/lan_prefs.php")) + { + include_once($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$pref_language."/lan_prefs.php"); + } + else + { + include_once($this->e107->e107_dirs['LANGUAGES_DIRECTORY']."English/lan_prefs.php"); + } + + require_once("{$this->e107->e107_dirs['FILES_DIRECTORY']}def_e107_prefs.php"); // could be deprecated if need be + include_once("{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}arraystorage_class.php"); + + $tmp = ArrayData::WriteArray($pref); + + $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('SitePrefs', '{$tmp}')"); + $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('SitePrefs_Backup', '{$tmp}')"); + + //Create default plugin-table entries. + // e107::getSingleton('e107plugin')->update_plugins_table(); //FIXME - also relies on pref class. + + // Install Theme-required plugins + if($this->previous_steps['install_plugins']==1) + { + if($themeInfo = $this->get_theme_xml($this->previous_steps['prefs']['sitetheme'])) + { + foreach($themeInfo['pluginOptions']['plugin'] as $k=>$plug) //TODO refactor pluginOptions as 'plugins' in theme.xml etc + { + $this->install_plugin($plug['@attributes']['name']); + } + } + } + + // Import Site-Data from XML. + //FIXME remove 'database' from the function below, once the pref handler is working. + e107::getSingleton('xmlClass')->e107Import($XMLImportfile,'database'); // includes non-core preferences + + // Set Preferences defined during install - overwriting those that may exist in the XML. + + $this->previous_steps['prefs']['sitelanguage'] = $this->previous_steps['language']; + $this->previous_steps['prefs']['sitelang_init'] = $this->previous_steps['language']; + + $this->previous_steps['prefs']['siteadmin'] = $this->previous_steps['admin']['display']; + $this->previous_steps['prefs']['siteadminemail'] = $this->previous_steps['admin']['email']; + $this->previous_steps['prefs']['install_date'] = time(); + $this->previous_steps['prefs']['siteurl'] = $e_HTTP; + + $this->previous_steps['prefs']['sitetag'] = LAN_PREF_2; + $this->previous_steps['prefs']['sitedisclaimer'] = LAN_PREF_3; + + $this->previous_steps['prefs']['replyto_name'] = $this->previous_steps['admin']['display']; + $this->previous_steps['prefs']['replyto_email'] = $this->previous_steps['admin']['email']; + + + foreach($this->previous_steps['prefs'] as $key=>$val) + { + // e107::getConfig('core')->set($key, $val); //FIXME - pref class issues. + } + // e107::getConfig('core')->save(FALSE); //FIXME - pref class issues. + + // Create the admin user - replacing any that may be been included in the XML. + $ip = $_SERVER['REMOTE_ADDR']; + $userp = "1, '{$this->previous_steps['admin']['display']}', '{$this->previous_steps['admin']['user']}', '', '".md5($this->previous_steps['admin']['password'])."', '', '{$this->previous_steps['admin']['email']}', '', '', 0, ".time().", 0, 0, 0, 0, 0, '{$ip}', 0, '', 0, 1, '', '', '0', '', ".time().", ''"; + $this->dbqry("REPLACE INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})" ); + + mysql_close(); + return false; + + } + + /** + * Install a Theme required plugin. + * @param string $plugpath - plugin folder name + * @return + */ + private function install_plugin($plugpath) //FIXME - requires default plugin table entries, see above. + { + return; // remove once fixed. + e107::getDb()->db_Select('plugin','plugin_id',"plugin_path='".$plugpath." LIMIT 1"); + $row = e107::getDb()->db_Fetch(MYSQL_ASSOC); + e107::getSingleton('e107plugin')->install_plugin($row['plugin_id']); + return; + } + + + /** + * Check a DB name or table prefix - anything starting with a numeric followed by 'e' causes problems. + * Return TRUE if acceptable, FALSE if unacceptable + * Empty string returns the value of $blank_ok (caller should set TRUE for prefix, FALSE for DB name) + * @param object $str + * @param object $blank_ok [optional] + * @return boolean + */ function check_name($str, $blank_ok = FALSE) { if ($str == '') @@ -943,12 +1068,16 @@ class e_install function get_theme_xml($theme_folder) { - require_once($this->e107->e107_dirs['HANDLERS_DIRECTORY']."xml_class.php"); - $xml = new xmlClass; - $path = $this->e107->e107_dirs['THEMES_DIRECTORY'].$theme_folder."/theme.xml"; + + if(!is_readable($path)) + { + return FALSE; + } + require_once($this->e107->e107_dirs['HANDLERS_DIRECTORY']."xml_class.php"); + $xml = new xmlClass; $xmlArray = $xml->loadXMLfile($path,'advanced'); - return $xmlArray; + return (is_array($xmlArray)) ? $xmlArray : FALSE; } @@ -986,8 +1115,11 @@ class e_install return $bad_files; } - - function create_tables() + /** + * Create Core MySQL tables + * @return + */ + private function create_tables() { $link = mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']); @@ -1031,6 +1163,13 @@ class e_install } } + return FALSE; + + + + //FIXME - remove - Everything below this point should no longer be required. See import_configuration(); + + /* $datestamp = time(); $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}news VALUES (0, '".LANINS_063."', '".LANINS_062."', '', '{$datestamp}', '0', '1', 1, 0, 0, 0, 0, '0', '', 'welcome.png', 0) "); @@ -1062,15 +1201,7 @@ class e_install require_once("{$this->e107->e107_dirs['FILES_DIRECTORY']}def_e107_prefs.php"); include_once("{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}arraystorage_class.php"); - - // Set User Preferences. - foreach($this->previous_steps['prefs'] as $key=>$val) - { - $pref[$key] = $val; - } - - //TODO - Cameron - create 2 seperate methods. One for old inserts using the code below. And another using external XML files. - + $tmp = ArrayData::WriteArray($pref); $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('SitePrefs', '{$tmp}')"); @@ -1139,27 +1270,27 @@ class e_install $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}banner VALUES (0, 'e107', 'e107login', 'e107password', 'banner2.png', 'http://e107.org', 0, 0, 0, 0, 0, 0, '', 'campaign_one') "); $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}banner VALUES (0, 'e107', 'e107login', 'e107password', 'banner3.png', 'http://e107.org', 0, 0, 0, 0, 0, 0, '', 'campaign_one') "); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (1, 'login_menu', 1, 1, '0', '', 'login_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (3, 'online_menu', 0, 0, '0', '', 'online/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (4, 'blogcalendar_menu', 0, 0, '0', '', 'blogcalendar_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (5, 'tree_menu', 0, 0, '0', '', 'tree_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (6, 'search_menu', 0, 0, '0', '', 'search_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (7, 'compliance_menu', 0, 0, '0', '', 'siteinfo_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (8, 'userlanguage_menu', 0, 0, '0', '', 'user_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (9, 'powered_by_menu', 2, 2, '0', '', 'siteinfo_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (10, 'counter_menu', 0, 0, '0', '', 'siteinfo_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (11, 'usertheme_menu', 0, 0, '0', '', 'user_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (12, 'banner_menu', 0, 0, '0', '', 'banner_menu/', '')"); -// $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (13, 'online_extended_menu', 2, 1, '0', '', 'online_extended_menu/')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (14, 'clock_menu', 0, 0, '0', '', 'clock_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (15, 'sitebutton_menu', 0, 0, '0', '', 'siteinfo_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (16, 'comment_menu', 0, 0, '0', '', 'comment_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (17, 'lastseen_menu', 0, 0, '0', '', 'online/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (18, 'other_news_menu', 0, 0, '0', '', 'other_news_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (19, 'other_news2_menu', 0, 0, '0', '', 'other_news_menu/', '')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (20, 'admin_menu', 0, 0, '0', '', 'admin_menu/', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (1, 'login_menu', 1, 1, '0', '', 'login_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (3, 'online_menu', 0, 0, '0', '', 'online/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (4, 'blogcalendar_menu', 0, 0, '0', '', 'blogcalendar_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (5, 'tree_menu', 0, 0, '0', '', 'tree_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (6, 'search_menu', 0, 0, '0', '', 'search_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (7, 'compliance_menu', 0, 0, '0', '', 'siteinfo_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (8, 'userlanguage_menu', 0, 0, '0', '', 'user_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (9, 'powered_by_menu', 2, 2, '0', '', 'siteinfo_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (10, 'counter_menu', 0, 0, '0', '', 'siteinfo_menu/', '', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (11, 'usertheme_menu', 0, 0, '0', '', 'user_menu/', '', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (12, 'banner_menu', 0, 0, '0', '', 'banner_menu/', '', '')"); +// $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (13, 'online_extended_menu', 2, 1, '0', '', 'online_extended_menu/', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (14, 'clock_menu', 0, 0, '0', '', 'clock_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (15, 'sitebutton_menu', 0, 0, '0', '', 'siteinfo_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (16, 'comment_menu', 0, 0, '0', '', 'comment_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (17, 'lastseen_menu', 0, 0, '0', '', 'online/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (18, 'other_news_menu', 0, 0, '0', '', 'other_news_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (19, 'other_news2_menu', 0, 0, '0', '', 'other_news_menu/', '', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (20, 'admin_menu', 0, 0, '0', '', 'admin_menu/', '', '')"); // $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (21, 'rss_menu', 5, 1, '0', '', 'rss_menu/')"); - $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (22, 'PCMag', 2, 1, '0', '', '1', '')"); + $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (22, 'PCMag', 2, 1, '0', '', '1', '', '')"); $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}userclass_classes VALUES (1, 'PRIVATEMENU', '".LANINS_093."',".e_UC_ADMIN.", 0, '', 0, 0, '')"); $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}userclass_classes VALUES (2, 'PRIVATEFORUM1', '".LANINS_094."',".e_UC_ADMIN.", 0, '', 0, 0, '')"); @@ -1178,6 +1309,8 @@ class e_install mysql_close(); return false; + + */ } function write_config($data) @@ -1356,7 +1489,7 @@ function template_data() $data = " -{installation_heading} +{installation_heading} :: {stage_pre}{stage_num} - {stage_title}