1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

More install-routine work. default_install.xml added

This commit is contained in:
CaMer0n
2009-08-31 02:00:51 +00:00
parent 39a9f98b18
commit d6c87894bd
8 changed files with 1000 additions and 363 deletions

View File

@@ -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);
}

View File

@@ -3,7 +3,7 @@
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <20>Steve Dunstan 2001-2002
| <20>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<br />";
// echo "Found plugin: ".$row['plugin_path']." in DB<br />";
}
}
$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']}<br />";
@@ -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];

View File

@@ -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 "<![CDATA[".e107::getArrayStorage()->WriteArray($val,FALSE)."]]>";
}
if((strpos($val,"<")!==FALSE) || (strpos($val,">")!==FALSE) || (strpos($val,"&")!==FALSE))
{
return "<![CDATA[". $val."]]>";
}
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 = "<?xml version='1.0' encoding='utf-8' ?>\n";
$text .= "<e107Export version='".$e107info['e107_version']."' timestamp='".time()."' >\n";
if(varset($xmlprefs)) // Export Core Preferences.
{
$text .= "\t<prefs>\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)."</".$type.">\n";
}
}
}
$text .= "\t</prefs>\n";
}
if(varset($tables))
{
$text .= "\t<database>\n";
foreach($tables as $tbl)
{
$eTable= str_replace(MPREFIX,"",$tbl);
e107::getDB()->db_Select($eTable, "*");
$text .= "\t<dbTable name='$eTable'>\n";
while($row = e107::getDB()-> db_Fetch())
{
$text .= "\t\t<item>\n";
foreach($row as $key=>$val)
{
$text .= "\t\t\t<field name='".$key."'>".$this->e107ExportValue($val)."</field>\n";
}
$text .= "\t\t</item>\n";
}
$text .= "\t</dbTable>\n";
}
$text .= "\t</database>\n";
}
$text .= "</e107Export>";
if($debug==TRUE)
{
echo "<pre>".htmlentities($text)."</pre>";
}
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 : '')."</$tag>\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));
}
}