1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 14:46:56 +02:00

Fixed installation issues

This commit is contained in:
secretr
2009-12-02 16:51:04 +00:00
parent 8c32e487a0
commit 8d32164211
4 changed files with 740 additions and 699 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -9,9 +9,9 @@
* mySQL Handler * mySQL Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
* $Revision: 1.67 $ * $Revision: 1.68 $
* $Date: 2009-12-01 20:05:54 $ * $Date: 2009-12-02 16:51:00 $
* $Author: e107steved $ * $Author: secretr $
*/ */
if(defined('MYSQL_LIGHT')) if(defined('MYSQL_LIGHT'))
@@ -24,13 +24,15 @@ if(defined('MYSQL_LIGHT'))
$sql = new db; $sql = new db;
$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); $sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
} }
elseif(defined('E107_INSTALL')) elseif(defined('E107_INSTALL'))
{ {
define('E107_DEBUG_LEVEL', 0); define('E107_DEBUG_LEVEL', 0);
define('e_QUERY', ''); //define('e_QUERY', '');
require_once("e107_config.php"); //require_once("e107_config.php");
define('MPREFIX', $mySQLprefix); //define('MPREFIX', $mySQLprefix);
require('e107_config.php');
$sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix');
e107::getInstance()->initInstallSql($sql_info);
$sql = new db; $sql = new db;
$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); $sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
} }
@@ -46,12 +48,12 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s
/** /**
* MySQL Abstraction class * MySQL Abstraction class
* *
* @package e107 * @package e107
* @category e107_handlers * @category e107_handlers
* @version $Revision: 1.67 $ * @version $Revision: 1.68 $
* @author $Author: e107steved $ * @author $Author: secretr $
* *
*/ */
class e_db_mysql { class e_db_mysql {
@@ -70,13 +72,13 @@ class e_db_mysql {
var $mySQLlanguage; var $mySQLlanguage;
var $mySQLinfo; var $mySQLinfo;
var $tabset; var $tabset;
var $mySQLtableList = array(); // list of all Db tables. var $mySQLtableList = array(); // list of all Db tables.
var $mySQLtableListLanguage = array(); // Db table list for the currently selected language var $mySQLtableListLanguage = array(); // Db table list for the currently selected language
/** /**
* MySQL Charset * MySQL Charset
* *
* @var string * @var string
*/ */
public $mySQLcharset; public $mySQLcharset;
@@ -89,12 +91,12 @@ class e_db_mysql {
*/ */
public function __construct() public function __construct()
{ {
global $pref, $db_defaultPrefix; global $pref, $db_defaultPrefix;
e107::getSingleton('e107_traffic')->BumpWho('Create db object', 1); e107::getSingleton('e107_traffic')->BumpWho('Create db object', 1);
$this->mySQLPrefix = MPREFIX; // Set the default prefix - may be overridden $this->mySQLPrefix = MPREFIX; // Set the default prefix - may be overridden
$langid = (isset($pref['cookie_name'])) ? 'e107language_'.$pref['cookie_name'] : 'e107language_temp'; $langid = (isset($pref['cookie_name'])) ? 'e107language_'.$pref['cookie_name'] : 'e107language_temp';
if (isset($pref['user_tracking']) && ($pref['user_tracking'] == 'session')) if (isset($pref['user_tracking']) && ($pref['user_tracking'] == 'session'))
{ {
@@ -168,7 +170,7 @@ class e_db_mysql {
$this->dbError('dbConnect/SelectDB'); $this->dbError('dbConnect/SelectDB');
// Save the connection resource // Save the connection resource
if ($db_ConnectionID == NULL) if ($db_ConnectionID == NULL)
$db_ConnectionID = $this->mySQLaccess; $db_ConnectionID = $this->mySQLaccess;
return TRUE; return TRUE;
} }
@@ -195,7 +197,7 @@ class e_db_mysql {
* @desc Enter description here... * @desc Enter description here...
* @access private * @access private
*/ */
function db_Show_Performance() function db_Show_Performance()
{ {
return $db_debug->Show_Performance(); return $db_debug->Show_Performance();
} }
@@ -206,7 +208,7 @@ class e_db_mysql {
* @desc add query to dblog table * @desc add query to dblog table
* @access private * @access private
*/ */
function db_Write_log($log_type = '', $log_remark = '', $log_query = '') function db_Write_log($log_type = '', $log_remark = '', $log_query = '')
{ {
global $tp, $e107; global $tp, $e107;
list($time_usec, $time_sec) = explode(" ", microtime()); list($time_usec, $time_sec) = explode(" ", microtime());
@@ -220,7 +222,7 @@ class e_db_mysql {
/** /**
* This is the 'core' routine which handles much of the interface between other functions and the DB * This is the 'core' routine which handles much of the interface between other functions and the DB
* *
* If a SELECT query includes SQL_CALC_FOUND_ROWS, the value of FOUND_ROWS() is retrieved and stored in $this->total_results * If a SELECT query includes SQL_CALC_FOUND_ROWS, the value of FOUND_ROWS() is retrieved and stored in $this->total_results
* @param string $query * @param string $query
* @param unknown $rli * @param unknown $rli
@@ -229,12 +231,12 @@ class e_db_mysql {
* For SELECT, SHOW, DESCRIBE, EXPLAIN and others returning a result set, returns a resource * For SELECT, SHOW, DESCRIBE, EXPLAIN and others returning a result set, returns a resource
* TRUE indicates success in other cases * TRUE indicates success in other cases
*/ */
public function db_Query($query, $rli = NULL, $qry_from = '', $debug = FALSE, $log_type = '', $log_remark = '') public function db_Query($query, $rli = NULL, $qry_from = '', $debug = FALSE, $log_type = '', $log_remark = '')
{ {
global $db_time,$db_mySQLQueryCount,$queryinfo; global $db_time,$db_mySQLQueryCount,$queryinfo;
$db_mySQLQueryCount++; $db_mySQLQueryCount++;
if ($debug == 'now') if ($debug == 'now')
{ {
echo "** $query<br />\n"; echo "** $query<br />\n";
} }
@@ -242,7 +244,7 @@ class e_db_mysql {
{ {
$queryinfo[] = "<b>{$qry_from}</b>: $query"; $queryinfo[] = "<b>{$qry_from}</b>: $query";
} }
if ($log_type != '') if ($log_type != '')
{ {
$this->db_Write_log($log_type, $log_remark, $query); $this->db_Write_log($log_type, $log_remark, $query);
} }
@@ -270,7 +272,7 @@ class e_db_mysql {
$this->total_results = $rc['FOUND_ROWS()']; $this->total_results = $rc['FOUND_ROWS()'];
} }
if (E107_DEBUG_LEVEL) if (E107_DEBUG_LEVEL)
{ {
global $db_debug; global $db_debug;
$aTrace = debug_backtrace(); $aTrace = debug_backtrace();
@@ -280,12 +282,12 @@ class e_db_mysql {
} else { } else {
$this->mySQLcurTable = ''; // clear before next query $this->mySQLcurTable = ''; // clear before next query
} }
if(is_object($db_debug)) if(is_object($db_debug))
{ {
$buglink = is_null($rli) ? $this->mySQLaccess : $rli; $buglink = is_null($rli) ? $this->mySQLaccess : $rli;
$nFields = $db_debug->Mark_Query($query, $buglink, $sQryRes, $aTrace, $mytime, $pTable); $nFields = $db_debug->Mark_Query($query, $buglink, $sQryRes, $aTrace, $mytime, $pTable);
} }
else else
{ {
echo "what happened to db_debug??!!<br />"; echo "what happened to db_debug??!!<br />";
} }
@@ -317,38 +319,38 @@ class e_db_mysql {
$this->mySQLcurTable = $table; $this->mySQLcurTable = $table;
if ($arg != '' && $mode == 'default') if ($arg != '' && $mode == 'default')
{ {
if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table.' WHERE '.$arg, NULL, 'db_Select', $debug, $log_type, $log_remark)) if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table.' WHERE '.$arg, NULL, 'db_Select', $debug, $log_type, $log_remark))
{ {
$this->dbError('dbQuery'); $this->dbError('dbQuery');
return $this->db_Rows(); return $this->db_Rows();
} }
else else
{ {
$this->dbError("db_Select (SELECT $fields FROM ".$this->mySQLPrefix."{$table} WHERE {$arg})"); $this->dbError("db_Select (SELECT $fields FROM ".$this->mySQLPrefix."{$table} WHERE {$arg})");
return FALSE; return FALSE;
} }
} }
elseif ($arg != '' && $mode != 'default') elseif ($arg != '' && $mode != 'default')
{ {
if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table.' '.$arg, NULL, 'db_Select', $debug, $log_type, $log_remark)) if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table.' '.$arg, NULL, 'db_Select', $debug, $log_type, $log_remark))
{ {
$this->dbError('dbQuery'); $this->dbError('dbQuery');
return $this->db_Rows(); return $this->db_Rows();
} }
else else
{ {
$this->dbError("db_Select (SELECT {$fields} FROM ".$this->mySQLPrefix."{$table} {$arg})"); $this->dbError("db_Select (SELECT {$fields} FROM ".$this->mySQLPrefix."{$table} {$arg})");
return FALSE; return FALSE;
} }
} }
else else
{ {
if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table, NULL, 'db_Select', $debug, $log_type, $log_remark)) if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table, NULL, 'db_Select', $debug, $log_type, $log_remark))
{ {
$this->dbError('dbQuery'); $this->dbError('dbQuery');
return $this->db_Rows(); return $this->db_Rows();
} }
else else
{ {
$this->dbError("db_Select (SELECT {$fields} FROM ".$this->mySQLPrefix."{$table})"); $this->dbError("db_Select (SELECT {$fields} FROM ".$this->mySQLPrefix."{$table})");
return FALSE; return FALSE;
@@ -375,20 +377,20 @@ class e_db_mysql {
$this->mySQLcurTable = $table; $this->mySQLcurTable = $table;
if(is_array($arg)) if(is_array($arg))
{ {
if(isset($arg['WHERE'])) // use same array for update and insert. if(isset($arg['WHERE'])) // use same array for update and insert.
{ {
unset($arg['WHERE']); unset($arg['WHERE']);
} }
if(isset($arg['_REPLACE'])) if(isset($arg['_REPLACE']))
{ {
$REPLACE = TRUE; $REPLACE = TRUE;
unset($arg['_REPLACE']); unset($arg['_REPLACE']);
} }
else else
{ {
$REPLACE = FALSE; $REPLACE = FALSE;
} }
if(!isset($arg['_FIELD_TYPES']) && !isset($arg['data'])) if(!isset($arg['_FIELD_TYPES']) && !isset($arg['data']))
{ {
//Convert data if not using 'new' format //Convert data if not using 'new' format
@@ -421,16 +423,16 @@ class e_db_mysql {
} }
$valList= implode(', ', $tmp); $valList= implode(', ', $tmp);
unset($tmp); unset($tmp);
if($REPLACE === FALSE) if($REPLACE === FALSE)
{ {
$query = "INSERT INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})"; $query = "INSERT INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})";
} }
else else
{ {
$query = "REPLACE INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})"; $query = "REPLACE INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})";
} }
} }
else else
{ {
@@ -471,7 +473,7 @@ class e_db_mysql {
function db_Replace($table, $arg, $debug = FALSE, $log_type = '', $log_remark = '') function db_Replace($table, $arg, $debug = FALSE, $log_type = '', $log_remark = '')
{ {
$arg['_REPLACE'] = TRUE; $arg['_REPLACE'] = TRUE;
return $this->db_Insert($table, $arg, $debug, $log_type, $log_remark); return $this->db_Insert($table, $arg, $debug, $log_type, $log_remark);
} }
@@ -503,7 +505,7 @@ class e_db_mysql {
global $db_ConnectionID; global $db_ConnectionID;
$this->mySQLaccess = $db_ConnectionID; $this->mySQLaccess = $db_ConnectionID;
} }
if (is_array($arg)) // Remove the need for a separate db_UpdateArray() function. if (is_array($arg)) // Remove the need for a separate db_UpdateArray() function.
{ {
$new_data = ''; $new_data = '';
@@ -592,11 +594,11 @@ class e_db_mysql {
case 'string': case 'string':
return "'{$fieldValue}'"; return "'{$fieldValue}'";
break; break;
case 'float': case 'float':
return (float) $fieldValue; return (float) $fieldValue;
break; break;
case 'null': case 'null':
return ($fieldValue && $fieldValue !== 'NULL' ? "'{$fieldValue}'" : 'NULL'); return ($fieldValue && $fieldValue !== 'NULL' ? "'{$fieldValue}'" : 'NULL');
break; break;
@@ -668,9 +670,9 @@ class e_db_mysql {
* *
* @access public * @access public
*/ */
function db_Fetch($type = MYSQL_ASSOC) function db_Fetch($type = MYSQL_ASSOC)
{ {
if (!(is_int($type))) if (!(is_int($type)))
{ {
$type=MYSQL_ASSOC; $type=MYSQL_ASSOC;
} }
@@ -679,11 +681,11 @@ class e_db_mysql {
{ {
$row = @mysql_fetch_array($this->mySQLresult,$type); $row = @mysql_fetch_array($this->mySQLresult,$type);
e107::getSingleton('e107_traffic')->Bump('db_Fetch', $b); e107::getSingleton('e107_traffic')->Bump('db_Fetch', $b);
if ($row) if ($row)
{ {
$this->dbError('db_Fetch'); $this->dbError('db_Fetch');
return $row; // Success - return data return $row; // Success - return data
} }
} }
$this->dbError('db_Fetch'); $this->dbError('db_Fetch');
return FALSE; // Failure return FALSE; // Failure
@@ -701,20 +703,20 @@ class e_db_mysql {
* *
* @access public * @access public
*/ */
function db_Count($table, $fields = '(*)', $arg = '', $debug = FALSE, $log_type = '', $log_remark = '') function db_Count($table, $fields = '(*)', $arg = '', $debug = FALSE, $log_type = '', $log_remark = '')
{ {
$table = $this->db_IsLang($table); $table = $this->db_IsLang($table);
if ($fields == 'generic') if ($fields == 'generic')
{ {
$query=$table; $query=$table;
if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark)) if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark))
{ {
$rows = $this->mySQLrows = @mysql_fetch_array($this->mySQLresult); $rows = $this->mySQLrows = @mysql_fetch_array($this->mySQLresult);
$this->dbError('db_Count'); $this->dbError('db_Count');
return $rows['COUNT(*)']; return $rows['COUNT(*)'];
} }
else else
{ {
$this->dbError("db_Count ({$query})"); $this->dbError("db_Count ({$query})");
return FALSE; return FALSE;
@@ -722,19 +724,19 @@ class e_db_mysql {
} }
$this->mySQLcurTable = $table; $this->mySQLcurTable = $table;
// normalize query arguments - only COUNT expected 'WHERE', not anymore // normalize query arguments - only COUNT expected 'WHERE', not anymore
if($arg && stripos(trim($arg), 'WHERE') !== 0) if($arg && stripos(trim($arg), 'WHERE') !== 0)
{ {
$arg = 'WHERE '.$arg; $arg = 'WHERE '.$arg;
} }
$query='SELECT COUNT'.$fields.' FROM '.$this->mySQLPrefix.$table.' '.$arg; $query='SELECT COUNT'.$fields.' FROM '.$this->mySQLPrefix.$table.' '.$arg;
if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark)) if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark))
{ {
$rows = $this->mySQLrows = @mysql_fetch_array($this->mySQLresult); $rows = $this->mySQLrows = @mysql_fetch_array($this->mySQLresult);
$this->dbError('db_Count'); $this->dbError('db_Count');
return $rows[0]; return $rows[0];
} }
else else
{ {
$this->dbError("db_Count({$query})"); $this->dbError("db_Count({$query})");
return FALSE; return FALSE;
@@ -754,7 +756,7 @@ class e_db_mysql {
* *
* @access public * @access public
*/ */
function db_Close() function db_Close()
{ {
if(!$this->mySQLaccess) if(!$this->mySQLaccess)
{ {
@@ -778,7 +780,7 @@ class e_db_mysql {
* <br /> * <br />
* @access public * @access public
*/ */
function db_Delete($table, $arg = '', $debug = FALSE, $log_type = '', $log_remark = '') function db_Delete($table, $arg = '', $debug = FALSE, $log_type = '', $log_remark = '')
{ {
$table = $this->db_IsLang($table); $table = $this->db_IsLang($table);
$this->mySQLcurTable = $table; $this->mySQLcurTable = $table;
@@ -790,28 +792,28 @@ class e_db_mysql {
} }
if (!$arg) if (!$arg)
{ {
if ($result = $this->mySQLresult = $this->db_Query('DELETE FROM '.$this->mySQLPrefix.$table, NULL, 'db_Delete', $debug, $log_type, $log_remark)) if ($result = $this->mySQLresult = $this->db_Query('DELETE FROM '.$this->mySQLPrefix.$table, NULL, 'db_Delete', $debug, $log_type, $log_remark))
{ {
$this->dbError('db_Delete'); $this->dbError('db_Delete');
return $result; return $result;
} }
else else
{ {
$this->dbError("db_Delete({$arg})"); $this->dbError("db_Delete({$arg})");
return FALSE; return FALSE;
} }
} }
else else
{ {
if ($result = $this->mySQLresult = $this->db_Query('DELETE FROM '.$this->mySQLPrefix.$table.' WHERE '.$arg, NULL, 'db_Delete', $debug, $log_type, $log_remark)) if ($result = $this->mySQLresult = $this->db_Query('DELETE FROM '.$this->mySQLPrefix.$table.' WHERE '.$arg, NULL, 'db_Delete', $debug, $log_type, $log_remark))
{ {
$tmp = mysql_affected_rows($this->mySQLaccess); $tmp = mysql_affected_rows($this->mySQLaccess);
$this->dbError('db_Delete'); $this->dbError('db_Delete');
return $tmp; return $tmp;
} }
else else
{ {
$this->dbError('db_Delete ('.$arg.')'); $this->dbError('db_Delete ('.$arg.')');
return FALSE; return FALSE;
@@ -825,7 +827,7 @@ class e_db_mysql {
* @desc Enter description here... * @desc Enter description here...
* @access private * @access private
*/ */
function db_Rows() function db_Rows()
{ {
$rows = $this->mySQLrows = @mysql_num_rows($this->mySQLresult); $rows = $this->mySQLrows = @mysql_num_rows($this->mySQLresult);
$this->dbError('db_Rows'); $this->dbError('db_Rows');
@@ -839,7 +841,7 @@ class e_db_mysql {
* @desc Enter description here... * @desc Enter description here...
* @access private * @access private
*/ */
function db_SetErrorReporting($mode) function db_SetErrorReporting($mode)
{ {
$this->mySQLerror = $mode; $this->mySQLerror = $mode;
} }
@@ -857,22 +859,22 @@ class e_db_mysql {
public function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '') public function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '')
{ {
$this->tabset = FALSE; $this->tabset = FALSE;
$query .= " "; // temp fix for failing regex below, when there is no space after the table name; $query .= " "; // temp fix for failing regex below, when there is no space after the table name;
if(strpos($query,'`#') !== FALSE) if(strpos($query,'`#') !== FALSE)
{ {
$query = preg_replace_callback("/\s`#([\w]*?)`\W/", array($this, 'ml_check'), $query); $query = preg_replace_callback("/\s`#([\w]*?)`\W/", array($this, 'ml_check'), $query);
} }
elseif(strpos($query,'#') !== FALSE) elseif(strpos($query,'#') !== FALSE)
{ {
$query = preg_replace_callback("/\s#([\w]*?)\W/", array($this, 'ml_check'), $query); $query = preg_replace_callback("/\s#([\w]*?)\W/", array($this, 'ml_check'), $query);
} }
$query = str_replace("#",$this->mySQLPrefix,$query); //FIXME - quick fix for those that slip-thru $query = str_replace("#",$this->mySQLPrefix,$query); //FIXME - quick fix for those that slip-thru
//FIXME - this is a quick Fix for REGEXP queries, as used in admin_ui. //FIXME - this is a quick Fix for REGEXP queries, as used in admin_ui.
$query = str_replace("`#","`".$this->mySQLPrefix,$query); $query = str_replace("`#","`".$this->mySQLPrefix,$query);
if ($this->mySQLresult === FALSE) if ($this->mySQLresult === FALSE)
@@ -899,7 +901,7 @@ class e_db_mysql {
} }
function ml_check($matches) function ml_check($matches)
{ {
$table = $this->db_IsLang($matches[1]); $table = $this->db_IsLang($matches[1]);
if($this->tabset == false) if($this->tabset == false)
{ {
@@ -916,7 +918,7 @@ class e_db_mysql {
* @desc Enter description here... * @desc Enter description here...
* @access private * @access private
*/ */
function db_Fieldname($offset) function db_Fieldname($offset)
{ {
$result = @mysql_field_name($this->mySQLresult, $offset); $result = @mysql_field_name($this->mySQLresult, $offset);
return $result; return $result;
@@ -928,7 +930,7 @@ class e_db_mysql {
* @desc Enter description here... * @desc Enter description here...
* @access private * @access private
*/ */
function db_Field_info() function db_Field_info()
{ {
$result = @mysql_fetch_field($this->mySQLresult); $result = @mysql_fetch_field($this->mySQLresult);
return $result; return $result;
@@ -940,25 +942,25 @@ class e_db_mysql {
* @desc Enter description here... * @desc Enter description here...
* @access private * @access private
*/ */
function db_Num_fields() function db_Num_fields()
{ {
$result = @mysql_num_fields($this->mySQLresult); $result = @mysql_num_fields($this->mySQLresult);
return $result; return $result;
} }
/** /**
* Check for the existence of a matching language table when multi-language tables are active. * Check for the existence of a matching language table when multi-language tables are active.
* @param string $table Name of table, without the prefix. * @param string $table Name of table, without the prefix.
* @access private * @access private
* @return name of the language table (eg. lan_french_news) * @return name of the language table (eg. lan_french_news)
*/ */
function db_IsLang($table,$multiple=FALSE) function db_IsLang($table,$multiple=FALSE)
{ {
global $pref; global $pref;
//When running a multi-language site with english included. English must be the main site language. //When running a multi-language site with english included. English must be the main site language.
if ((!$this->mySQLlanguage || !$pref['multilanguage'] || $this->mySQLlanguage=='English') && $multiple==FALSE) if ((!$this->mySQLlanguage || !$pref['multilanguage'] || $this->mySQLlanguage=='English') && $multiple==FALSE)
{ {
return $table; return $table;
} }
@@ -968,14 +970,14 @@ class e_db_mysql {
global $db_ConnectionID; global $db_ConnectionID;
$this->mySQLaccess = $db_ConnectionID; $this->mySQLaccess = $db_ConnectionID;
} }
if($multiple == FALSE) if($multiple == FALSE)
{ {
$mltable = "lan_".strtolower($this->mySQLlanguage.'_'.$table); $mltable = "lan_".strtolower($this->mySQLlanguage.'_'.$table);
return ($this->db_Table_exists($table,$this->mySQLlanguage)) ? $mltable : $table; return ($this->db_Table_exists($table,$this->mySQLlanguage)) ? $mltable : $table;
} }
else // return an array of all matching language tables. eg [french]->e107_lan_news else // return an array of all matching language tables. eg [french]->e107_lan_news
{ {
if(!is_array($table)) if(!is_array($table))
{ {
$table = array($table); $table = array($table);
@@ -996,7 +998,7 @@ class e_db_mysql {
} }
} }
} }
return (varset($lanlist)) ? $lanlist : FALSE; return (varset($lanlist)) ? $lanlist : FALSE;
} }
// ------------------------- // -------------------------
@@ -1010,17 +1012,17 @@ class e_db_mysql {
* @desc returns fields as structured array * @desc returns fields as structured array
* @access public * @access public
*/ */
function db_getList($fields = 'ALL', $amount = FALSE, $maximum = FALSE, $ordermode=FALSE) function db_getList($fields = 'ALL', $amount = FALSE, $maximum = FALSE, $ordermode=FALSE)
{ {
$list = array(); $list = array();
$counter = 1; $counter = 1;
while ($row = $this->db_Fetch()) while ($row = $this->db_Fetch())
{ {
foreach($row as $key => $value) foreach($row as $key => $value)
{ {
if (is_string($key)) if (is_string($key))
{ {
if (strtoupper($fields) == 'ALL' || in_array ($key, $fields)) if (strtoupper($fields) == 'ALL' || in_array ($key, $fields))
{ {
if(!$ordermode) if(!$ordermode)
{ {
@@ -1033,7 +1035,7 @@ class e_db_mysql {
} }
} }
} }
if ($amount && $amount == $counter || ($maximum && $counter > $maximum)) if ($amount && $amount == $counter || ($maximum && $counter > $maximum))
{ {
break; break;
} }
@@ -1047,7 +1049,7 @@ class e_db_mysql {
* @desc returns total number of queries made so far * @desc returns total number of queries made so far
* @access public * @access public
*/ */
function db_QueryCount() function db_QueryCount()
{ {
global $db_mySQLQueryCount; global $db_mySQLQueryCount;
return $db_mySQLQueryCount; return $db_mySQLQueryCount;
@@ -1181,31 +1183,31 @@ class e_db_mysql {
* @param string $lanMode [optional] When set to TRUE, searches for multilanguage tables * @param string $lanMode [optional] When set to TRUE, searches for multilanguage tables
* @return boolean TRUE if exists * @return boolean TRUE if exists
* *
* NOTES: Slower (28ms) than "SELECT 1 FROM" (4-5ms), but doesn't produce MySQL errors. * NOTES: Slower (28ms) than "SELECT 1 FROM" (4-5ms), but doesn't produce MySQL errors.
* Multiple checks on a single page will only use 1 query. ie. faster on multiple calls. * Multiple checks on a single page will only use 1 query. ie. faster on multiple calls.
*/ */
public function db_Table_exists($table,$language='') public function db_Table_exists($table,$language='')
{ {
global $pref; global $pref;
$table = strtolower($table); // precaution for multilanguage $table = strtolower($table); // precaution for multilanguage
if($language && ($language != $pref['sitelanguage'])) if($language && ($language != $pref['sitelanguage']))
{ {
if(!isset($this->mySQLtableListLanguage[$language])) if(!isset($this->mySQLtableListLanguage[$language]))
{ {
$this->mySQLtableListLanguage = $this->db_mySQLtableList($language); $this->mySQLtableListLanguage = $this->db_mySQLtableList($language);
} }
return in_array('lan_'.strtolower($language)."_".$table,$this->mySQLtableListLanguage[$language]); return in_array('lan_'.strtolower($language)."_".$table,$this->mySQLtableListLanguage[$language]);
} }
else else
{ {
if(!$this->mySQLtableList) if(!$this->mySQLtableList)
{ {
$this->mySQLtableList = $this->db_mySQLtableList(); $this->mySQLtableList = $this->db_mySQLtableList();
} }
return in_array($table,$this->mySQLtableList); return in_array($table,$this->mySQLtableList);
} }
} }
@@ -1221,39 +1223,39 @@ class e_db_mysql {
{ {
$table = array(); $table = array();
if($res = $this->db_Query("SHOW TABLES LIKE '".$this->mySQLPrefix."lan_".strtolower($language)."%' ")) if($res = $this->db_Query("SHOW TABLES LIKE '".$this->mySQLPrefix."lan_".strtolower($language)."%' "))
{ {
while($rows = $this->db_Fetch(MYSQL_NUM)) while($rows = $this->db_Fetch(MYSQL_NUM))
{ {
$table[] = str_replace($this->mySQLPrefix,"",$rows[0]); $table[] = str_replace($this->mySQLPrefix,"",$rows[0]);
} }
} }
$ret = array($language=>$table); $ret = array($language=>$table);
return $ret; return $ret;
} }
else else
{ {
return $this->mySQLtableListLanguage[$language]; return $this->mySQLtableListLanguage[$language];
} }
} }
if(!$this->mySQLtableList) if(!$this->mySQLtableList)
{ {
$table = array(); $table = array();
if($res = $this->db_Query("SHOW TABLES LIKE '".$this->mySQLPrefix."%' ")) if($res = $this->db_Query("SHOW TABLES LIKE '".$this->mySQLPrefix."%' "))
{ {
while($rows = $this->db_Fetch(MYSQL_NUM)) while($rows = $this->db_Fetch(MYSQL_NUM))
{ {
$table[] = str_replace($this->mySQLPrefix,"",$rows[0]); $table[] = str_replace($this->mySQLPrefix,"",$rows[0]);
} }
} }
return $table; return $table;
} }
else else
{ {
return $this->mySQLtableList; return $this->mySQLtableList;
} }
} }
public function db_ResetTableList() public function db_ResetTableList()
{ {
$this->mySQLtableList = array(); $this->mySQLtableList = array();
@@ -1261,29 +1263,29 @@ class e_db_mysql {
} }
/** /**
* Return a filtered list of DB tables. * Return a filtered list of DB tables.
* @param object $mode [optional] all|lan|nolan * @param object $mode [optional] all|lan|nolan
* @return array * @return array
*/ */
public function db_TableList($mode='all') public function db_TableList($mode='all')
{ {
if(!$this->mySQLtableList) if(!$this->mySQLtableList)
{ {
$this->mySQLtableList = $this->db_mySQLtableList(); $this->mySQLtableList = $this->db_mySQLtableList();
} }
if($mode == 'all') if($mode == 'all')
{ {
return $this->mySQLtableList; return $this->mySQLtableList;
} }
if($mode == 'lan' || $mode=='nolan') if($mode == 'lan' || $mode=='nolan')
{ {
$nolan = array(); $nolan = array();
$lan = array(); $lan = array();
foreach($this->mySQLtableList as $tab) foreach($this->mySQLtableList as $tab)
{ {
if(substr($tab,0,4)!='lan_') if(substr($tab,0,4)!='lan_')
@@ -1292,28 +1294,28 @@ class e_db_mysql {
} }
else else
{ {
$lan[] = $tab; $lan[] = $tab;
} }
} }
return ($mode == 'lan') ? $lan : $nolan; return ($mode == 'lan') ? $lan : $nolan;
} }
} }
function db_CopyTable($oldtable, $newtable, $drop = FALSE, $data = FALSE) function db_CopyTable($oldtable, $newtable, $drop = FALSE, $data = FALSE)
{ {
$old = $this->mySQLPrefix.strtolower($oldtable); $old = $this->mySQLPrefix.strtolower($oldtable);
$new = $this->mySQLPrefix.strtolower($newtable); $new = $this->mySQLPrefix.strtolower($newtable);
if ($drop) if ($drop)
{ {
$this->db_Select_gen("DROP TABLE IF EXISTS {$new}"); $this->db_Select_gen("DROP TABLE IF EXISTS {$new}");
} }
//Get $old table structure //Get $old table structure
$this->db_Select_gen('SET SQL_QUOTE_SHOW_CREATE = 1'); $this->db_Select_gen('SET SQL_QUOTE_SHOW_CREATE = 1');
$qry = "SHOW CREATE TABLE {$old}"; $qry = "SHOW CREATE TABLE {$old}";
if ($this->db_Select_gen($qry)) if ($this->db_Select_gen($qry))
{ {
@@ -1324,14 +1326,14 @@ class e_db_mysql {
} }
else else
{ {
return FALSE; return FALSE;
} }
if(!$this->db_Table_exists($newtable)) if(!$this->db_Table_exists($newtable))
{ {
$result = $this->db_Query($qry); $result = $this->db_Query($qry);
} }
if ($data) //We need to copy the data too if ($data) //We need to copy the data too
{ {
$qry = "INSERT INTO {$new} SELECT * FROM {$old}"; $qry = "INSERT INTO {$new} SELECT * FROM {$old}";
@@ -1348,7 +1350,7 @@ class e_db_mysql {
* @desc Calling method from within this class * @desc Calling method from within this class
* @access private * @access private
*/ */
function dbError($from) function dbError($from)
{ {
$this->mySQLlastErrNum = mysql_errno(); $this->mySQLlastErrNum = mysql_errno();
$this->mySQLlastErrText = ''; $this->mySQLlastErrText = '';
@@ -1357,7 +1359,7 @@ class e_db_mysql {
return ''; return '';
} }
$this->mySQLlastErrText = mysql_error(); // Get the error text. $this->mySQLlastErrText = mysql_error(); // Get the error text.
if ($this->mySQLerror == TRUE) if ($this->mySQLerror == TRUE)
{ {
message_handler('ADMIN_MESSAGE', '<b>mySQL Error!</b> Function: '.$from.'. ['.$this->mySQLlastErrNum.' - '.$this->mySQLlastErrText.']', __LINE__, __FILE__); message_handler('ADMIN_MESSAGE', '<b>mySQL Error!</b> Function: '.$from.'. ['.$this->mySQLlastErrNum.' - '.$this->mySQLlastErrText.']', __LINE__, __FILE__);
} }
@@ -1435,7 +1437,7 @@ class e_db_mysql {
*/ */
class db extends e_db_mysql class db extends e_db_mysql
{ {
} }
?> ?>

View File

@@ -9,9 +9,9 @@
* e107 Preference Handler * e107 Preference Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/pref_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/pref_class.php,v $
* $Revision: 1.31 $ * $Revision: 1.32 $
* $Date: 2009-11-18 01:04:43 $ * $Date: 2009-12-02 16:50:58 $
* $Author: e107coders $ * $Author: secretr $
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
@@ -27,7 +27,7 @@ require_once(e_HANDLER.'model_class.php');
* @author SecretR * @author SecretR
* @copyright Copyright (c) 2009, e107 Inc. * @copyright Copyright (c) 2009, e107 Inc.
*/ */
class e_pref extends e_admin_model class e_pref extends e_admin_model
{ {
/** /**
* Preference ID - DB row value * Preference ID - DB row value
@@ -35,22 +35,22 @@ class e_pref extends e_admin_model
* @var string * @var string
*/ */
protected $prefid; protected $prefid;
/** /**
* Preference ID alias e.g. 'core' is an alias of prefid 'SitePrefs' * Preference ID alias e.g. 'core' is an alias of prefid 'SitePrefs'
* Used in e.g. server cache file name * Used in e.g. server cache file name
* *
* @var string * @var string
*/ */
protected $alias; protected $alias;
/** /**
* Runtime cache, set on first data load * Runtime cache, set on first data load
* *
* @var string * @var string
*/ */
protected $pref_cache = ''; protected $pref_cache = '';
/** /**
* Backward compatibility - serialized preferences * Backward compatibility - serialized preferences
* Note: serialized preference storage is deprecated * Note: serialized preference storage is deprecated
@@ -58,7 +58,7 @@ class e_pref extends e_admin_model
* @var boolean * @var boolean
*/ */
protected $serial_bc = false; protected $serial_bc = false;
/** /**
* If true, $prefid.'_Backup' row will be created/updated * If true, $prefid.'_Backup' row will be created/updated
* on every {@link save()} call * on every {@link save()} call
@@ -66,7 +66,7 @@ class e_pref extends e_admin_model
* @var boolean * @var boolean
*/ */
protected $set_backup = false; protected $set_backup = false;
/** /**
* Constructor * Constructor
* *
@@ -78,19 +78,19 @@ class e_pref extends e_admin_model
function __construct($prefid, $alias = '', $data = array(), $sanitize_data = true) function __construct($prefid, $alias = '', $data = array(), $sanitize_data = true)
{ {
require_once(e_HANDLER.'cache_handler.php'); require_once(e_HANDLER.'cache_handler.php');
$this->prefid = preg_replace('/[^\w\-]/', '', $prefid); $this->prefid = preg_replace('/[^\w\-]/', '', $prefid);
if(empty($alias)) if(empty($alias))
{ {
$alias = $prefid; $alias = $prefid;
} }
$this->alias = preg_replace('/[^\w\-]/', '', $alias); $this->alias = preg_replace('/[^\w\-]/', '', $alias);
$this->loadData($data, $sanitize_data); $this->loadData($data, $sanitize_data);
} }
/** /**
* Advanced getter - $pref_name could be path in format 'pref1/pref2/pref3' (multidimensional arrays support), * Advanced getter - $pref_name could be path in format 'pref1/pref2/pref3' (multidimensional arrays support),
* alias of {@link e_model::getData()} * alias of {@link e_model::getData()}
* If $pref_name is empty, all data array will be returned * If $pref_name is empty, all data array will be returned
* *
@@ -103,11 +103,11 @@ class e_pref extends e_admin_model
{ {
return $this->getData($pref_name, $default, $index); return $this->getData($pref_name, $default, $index);
} }
/** /**
* Simple getter - $pref_name is not parsed (no multidimensional arrays support), alias of {@link e_model::get()} * Simple getter - $pref_name is not parsed (no multidimensional arrays support), alias of {@link e_model::get()}
* This is the prefered (performance wise) method when simple preference is retrieved * This is the prefered (performance wise) method when simple preference is retrieved
* *
* @param string $pref_name * @param string $pref_name
* @param mixed $default * @param mixed $default
* @return mixed * @return mixed
@@ -116,11 +116,11 @@ class e_pref extends e_admin_model
{ {
return parent::get((string) $pref_name, $default); return parent::get((string) $pref_name, $default);
} }
/** /**
* Advanced setter - $pref_name could be path in format 'pref1/pref2/pref3' (multidimensional arrays support) * Advanced setter - $pref_name could be path in format 'pref1/pref2/pref3' (multidimensional arrays support)
* If $pref_name is array, it'll be merged with existing preference data, non existing preferences will be added as well * If $pref_name is array, it'll be merged with existing preference data, non existing preferences will be added as well
* *
* @param string|array $pref_name * @param string|array $pref_name
* @param mixed $value * @param mixed $value
* @return e_pref * @return e_pref
@@ -131,18 +131,18 @@ class e_pref extends e_admin_model
//object reset not allowed, adding new pref is allowed //object reset not allowed, adding new pref is allowed
if(empty($pref_name)) if(empty($pref_name))
{ {
return $this; return $this;
} }
//Merge only allowed //Merge only allowed
if(is_array($pref_name)) if(is_array($pref_name))
{ {
$this->mergeData($pref_name, false, false, false); $this->mergeData($pref_name, false, false, false);
return $this; return $this;
} }
parent::setData($pref_name, $value, false); parent::setData($pref_name, $value, false);
//BC //BC
if($this->alias === 'core') if($this->alias === 'core')
{ {
@@ -150,11 +150,11 @@ class e_pref extends e_admin_model
} }
return $this; return $this;
} }
/** /**
* Advanced setter - $pref_name could be path in format 'pref1/pref2/pref3' (multidimensional arrays support) * Advanced setter - $pref_name could be path in format 'pref1/pref2/pref3' (multidimensional arrays support)
* Object data reseting is not allowed, adding new preferences is controlled by $strict parameter * Object data reseting is not allowed, adding new preferences is controlled by $strict parameter
* *
* @param string|array $pref_name * @param string|array $pref_name
* @param mixed $value * @param mixed $value
* @param boolean $strict true - update only, false - same as setPref() * @param boolean $strict true - update only, false - same as setPref()
@@ -166,18 +166,18 @@ class e_pref extends e_admin_model
//object reset not allowed, adding new pref is not allowed //object reset not allowed, adding new pref is not allowed
if(empty($pref_name)) if(empty($pref_name))
{ {
return $this; return $this;
} }
//Merge only allowed //Merge only allowed
if(is_array($pref_name)) if(is_array($pref_name))
{ {
$this->mergeData($pref_name, $strict, false, false); $this->mergeData($pref_name, $strict, false, false);
return $this; return $this;
} }
parent::setData($pref_name, $value, $strict); parent::setData($pref_name, $value, $strict);
//BC //BC
if($this->alias === 'core') if($this->alias === 'core')
{ {
@@ -185,11 +185,11 @@ class e_pref extends e_admin_model
} }
return $this; return $this;
} }
/** /**
* Simple setter - $pref_name is not parsed (no multidimensional arrays support) * Simple setter - $pref_name is not parsed (no multidimensional arrays support)
* Adding new pref is allowed * Adding new pref is allowed
* *
* @param string $pref_name * @param string $pref_name
* @param mixed $value * @param mixed $value
* @return e_pref * @return e_pref
@@ -202,7 +202,7 @@ class e_pref extends e_admin_model
return $this; return $this;
} }
parent::set((string) $pref_name, $value, false); parent::set((string) $pref_name, $value, false);
//BC //BC
if($this->alias === 'core') if($this->alias === 'core')
{ {
@@ -210,11 +210,11 @@ class e_pref extends e_admin_model
} }
return $this; return $this;
} }
/** /**
* Simple setter - $pref_name is not parsed (no multidimensional arrays support) * Simple setter - $pref_name is not parsed (no multidimensional arrays support)
* Non existing setting will be not created * Non existing setting will be not created
* *
* @param string $pref_name * @param string $pref_name
* @param mixed $value * @param mixed $value
* @return e_pref * @return e_pref
@@ -227,7 +227,7 @@ class e_pref extends e_admin_model
return $this; return $this;
} }
parent::set((string) $pref_name, $value, true); parent::set((string) $pref_name, $value, true);
//BC //BC
if($this->alias === 'core') if($this->alias === 'core')
{ {
@@ -235,46 +235,46 @@ class e_pref extends e_admin_model
} }
return $this; return $this;
} }
/** /**
* Add new (single) preference (ONLY if doesn't exist) * Add new (single) preference (ONLY if doesn't exist)
* No multidimensional arrays support * No multidimensional arrays support
* *
* @see addData() * @see addData()
* @param string $pref_name * @param string $pref_name
* @param mixed $value * @param mixed $value
* @return e_pref * @return e_pref
*/ */
public function add($pref_name, $value) public function add($pref_name, $value)
{ {
if(empty($pref_name) || !is_string($pref_name)) if(empty($pref_name) || !is_string($pref_name))
{ {
return $this; return $this;
} }
$this->addData($pref_name, $value); $this->addData($pref_name, $value);
return $this; return $this;
} }
/** /**
* Add new preference or preference array (ONLY if it/they doesn't exist) * Add new preference or preference array (ONLY if it/they doesn't exist)
* $pref_name could be path in format 'pref1/pref2/pref3' * $pref_name could be path in format 'pref1/pref2/pref3'
* *
* @see addData() * @see addData()
* @param string|array $pref_name * @param string|array $pref_name
* @param mixed $value * @param mixed $value
* @return e_pref * @return e_pref
*/ */
public function addPref($pref_name, $value = null) public function addPref($pref_name, $value = null)
{ {
$this->addData($pref_name, $value); $this->addData($pref_name, $value);
return $this; return $this;
} }
/** /**
* Remove single preference * Remove single preference
* $pref_name is not parsed as a path * $pref_name is not parsed as a path
* *
* @see e_model::remove() * @see e_model::remove()
* @param string $pref_name * @param string $pref_name
* @return e_pref * @return e_pref
@@ -283,7 +283,7 @@ class e_pref extends e_admin_model
{ {
global $pref; global $pref;
parent::remove((string) $pref_name); parent::remove((string) $pref_name);
//BC //BC
if($this->alias === 'core') if($this->alias === 'core')
{ {
@@ -291,21 +291,21 @@ class e_pref extends e_admin_model
} }
return $this; return $this;
} }
/** /**
* Remove single preference (parse $pref_name) * Remove single preference (parse $pref_name)
* $pref_name could be path in format 'pref1/pref2/pref3' * $pref_name could be path in format 'pref1/pref2/pref3'
* *
* @see removeData() * @see removeData()
* @param string $pref_name * @param string $pref_name
* @return e_pref * @return e_pref
*/ */
public function removePref($pref_name) public function removePref($pref_name)
{ {
$this->removeData($pref_name); $this->removeData($pref_name);
return $this; return $this;
} }
/** /**
* Disallow public use of e_model::addData() * Disallow public use of e_model::addData()
* Disallow preference override * Disallow preference override
@@ -325,11 +325,11 @@ class e_pref extends e_admin_model
} }
return $this; return $this;
} }
/** /**
* Disallow public use of e_model::setData() * Disallow public use of e_model::setData()
* Only data merge possible * Only data merge possible
* *
* @param string|array $pref_name * @param string|array $pref_name
* @param mixed $value * @param mixed $value
* @return e_pref * @return e_pref
@@ -339,18 +339,18 @@ class e_pref extends e_admin_model
global $pref; global $pref;
if(empty($pref_name)) if(empty($pref_name))
{ {
return $this; return $this;
} }
//Merge only allowed //Merge only allowed
if(is_array($pref_name)) if(is_array($pref_name))
{ {
$this->mergeData($pref_name, false, false, false); $this->mergeData($pref_name, false, false, false);
return $this; return $this;
} }
parent::setData($pref_name, $value, false); parent::setData($pref_name, $value, false);
//BC //BC
if($this->alias === 'core') if($this->alias === 'core')
{ {
@@ -358,7 +358,7 @@ class e_pref extends e_admin_model
} }
return $this; return $this;
} }
/** /**
* Disallow public use of e_model::removeData() * Disallow public use of e_model::removeData()
* Object data reseting is not allowed * Object data reseting is not allowed
@@ -370,7 +370,7 @@ class e_pref extends e_admin_model
{ {
global $pref; global $pref;
parent::removeData((string) $pref_name); parent::removeData((string) $pref_name);
//BC //BC
if($this->alias === 'core') if($this->alias === 'core')
{ {
@@ -378,7 +378,7 @@ class e_pref extends e_admin_model
} }
return $this; return $this;
} }
/** /**
* Reset object data * Reset object data
* *
@@ -405,7 +405,7 @@ class e_pref extends e_admin_model
} }
return $this; return $this;
} }
/** /**
* Load object data - public * Load object data - public
* *
@@ -426,10 +426,10 @@ class e_pref extends e_admin_model
$pref = $this->getData(); $pref = $this->getData();
} }
} }
return $this; return $this;
} }
/** /**
* Load object data * Load object data
* *
@@ -439,40 +439,40 @@ class e_pref extends e_admin_model
protected function _load($force = false) protected function _load($force = false)
{ {
$id = $this->prefid; $id = $this->prefid;
$data = $force ? false : $this->getPrefCache(true); $data = $force ? false : $this->getPrefCache(true);
if($data !== false) if($data !== false)
{ {
$this->pref_cache = e107::getArrayStorage()->WriteArray($data, false); //runtime cache $this->pref_cache = e107::getArrayStorage()->WriteArray($data, false); //runtime cache
$this->loadData($data, false); $this->loadData($data, false);
return $this; return $this;
} }
if (e107::getDb()->db_Select('core', 'e107_value', "e107_name='{$id}'")) if (e107::getDb()->db_Select('core', 'e107_value', "e107_name='{$id}'"))
{ {
$row = e107::getDb()->db_Fetch(); $row = e107::getDb()->db_Fetch();
if($this->serial_bc) if($this->serial_bc)
{ {
$data = unserialize($row['e107_value']); $data = unserialize($row['e107_value']);
$row['e107_value'] = e107::getArrayStorage()->WriteArray($data, false); $row['e107_value'] = e107::getArrayStorage()->WriteArray($data, false);
} }
else else
{ {
$data = e107::getArrayStorage()->ReadArray($row['e107_value']); $data = e107::getArrayStorage()->ReadArray($row['e107_value']);
} }
$this->pref_cache = $row['e107_value']; //runtime cache $this->pref_cache = $row['e107_value']; //runtime cache
$this->setPrefCache($row['e107_value'], true); $this->setPrefCache($row['e107_value'], true);
} }
if(empty($data)) if(empty($data))
$data = array(); $data = array();
$this->loadData($data, false); $this->loadData($data, false);
return $this; return $this;
} }
/** /**
* Save object data to DB * Save object data to DB
* *
@@ -488,49 +488,49 @@ class e_pref extends e_admin_model
{ {
return false; return false;
} }
if($from_post) if($from_post)
{ {
$this->mergePostedData(); //all posted data is sanitized and filtered vs preferences/_data_fields array $this->mergePostedData(); //all posted data is sanitized and filtered vs preferences/_data_fields array
} }
if($this->hasValidationError()) if($this->hasValidationError())
{ {
return false; return false;
} }
//FIXME - switch to new model system messages (separate eMessage namespaces) //FIXME - switch to new model system messages (separate eMessage namespaces)
$emessage = e107::getMessage(); $emessage = e107::getMessage();
if(!$this->data_has_changed && !$force) if(!$this->data_has_changed && !$force)
{ {
$emessage->add('Settings not saved as no changes were made.', E_MESSAGE_INFO, $session_messages); $emessage->add('Settings not saved as no changes were made.', E_MESSAGE_INFO, $session_messages);
return 0; return 0;
} }
//Save to DB //Save to DB
if(!$this->hasError()) if(!$this->hasError())
{ {
if($this->serial_bc) if($this->serial_bc)
{ {
$dbdata = serialize($this->getPref()); $dbdata = serialize($this->getPref());
} }
else else
{ {
$dbdata = $this->toString(false); $dbdata = $this->toString(false);
} }
if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('{$this->prefid}', '".addslashes($dbdata)."') ")) if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('{$this->prefid}', '".addslashes($dbdata)."') "))
{ {
$this->data_has_changed = false; //reset status $this->data_has_changed = false; //reset status
if($this->set_backup === true && !empty($this->pref_cache)) if($this->set_backup === true && !empty($this->pref_cache))
{ {
if($this->serial_bc) if($this->serial_bc)
{ {
$dbdata = serialize(e107::getArrayStorage()->ReadArray($this->pref_cache)); $dbdata = serialize(e107::getArrayStorage()->ReadArray($this->pref_cache));
} }
else else
{ {
$dbdata = $this->pref_cache; $dbdata = $this->pref_cache;
} }
@@ -541,14 +541,14 @@ class e_pref extends e_admin_model
} }
} }
$this->setPrefCache($this->toString(false), true); //reset pref cache - runtime & file $this->setPrefCache($this->toString(false), true); //reset pref cache - runtime & file
$emessage->add('Settings successfully saved.', E_MESSAGE_SUCCESS, $session_messages); $emessage->add('Settings successfully saved.', E_MESSAGE_SUCCESS, $session_messages);
//BC //BC
if($this->alias === 'core') if($this->alias === 'core')
{ {
$pref = $this->getData(); $pref = $this->getData();
} }
return true; return true;
} }
elseif(e107::getDb()->getLastErrorNumber()) elseif(e107::getDb()->getLastErrorNumber())
{ {
@@ -557,7 +557,7 @@ class e_pref extends e_admin_model
return false; return false;
} }
} }
if($this->hasError()) if($this->hasError())
{ {
//add errors to the eMessage stack //add errors to the eMessage stack
@@ -565,13 +565,13 @@ class e_pref extends e_admin_model
$emessage->add('Settings not saved.', E_MESSAGE_ERROR, $session_messages); $emessage->add('Settings not saved.', E_MESSAGE_ERROR, $session_messages);
return false; return false;
} }
else else
{ {
$emessage->add('Settings not saved as no changes were made.', E_MESSAGE_INFO, $session_messages); $emessage->add('Settings not saved as no changes were made.', E_MESSAGE_INFO, $session_messages);
return 0; return 0;
} }
} }
/** /**
* Get cached data from server cache file * Get cached data from server cache file
* *
@@ -584,10 +584,10 @@ class e_pref extends e_admin_model
{ {
$this->pref_cache = ecache::retrieve_sys('Config_'.$this->alias, 24 * 60, true); $this->pref_cache = ecache::retrieve_sys('Config_'.$this->alias, 24 * 60, true);
} }
return ($toArray && $this->pref_cache ? e107::getArrayStorage()->ReadArray($this->pref_cache) : $this->pref_cache); return ($toArray && $this->pref_cache ? e107::getArrayStorage()->ReadArray($this->pref_cache) : $this->pref_cache);
} }
/** /**
* Convert data to a string and store it to a server cache file * Convert data to a string and store it to a server cache file
* If $cache_string is an array, it'll be converted to a string * If $cache_string is an array, it'll be converted to a string
@@ -613,10 +613,10 @@ class e_pref extends e_admin_model
} }
return $this; return $this;
} }
/** /**
* Clear pref cache * Clear pref cache
* *
* @param string $cache_name default to current alias * @param string $cache_name default to current alias
* @param boolean $runtime clear runtime cache as well ($this->pref_cache) * @param boolean $runtime clear runtime cache as well ($this->pref_cache)
* @return e_pref * @return e_pref
@@ -630,7 +630,7 @@ class e_pref extends e_admin_model
ecache::clear_sys('Config_'.(!empty($cache_name) ? $cache_name : $this->alias)); ecache::clear_sys('Config_'.(!empty($cache_name) ? $cache_name : $this->alias));
return $this; return $this;
} }
/** /**
* Validation * Validation
* *
@@ -641,90 +641,90 @@ class e_pref extends e_admin_model
{ {
return parent::validate($data); return parent::validate($data);
} }
/** /**
* Set $set_backup option * Set $set_backup option
* *
* @param boolean $optval * @param boolean $optval
* @return e_pref * @return e_pref
* *
*/ */
public function setOptionBackup($optval) public function setOptionBackup($optval)
{ {
$this->set_backup = $optval; $this->set_backup = $optval;
return $this; return $this;
} }
/** /**
* Set $serial_bc option * Set $serial_bc option
* *
* @param boolean $optval * @param boolean $optval
* @return e_pref * @return e_pref
* *
*/ */
public function setOptionSerialize($optval) public function setOptionSerialize($optval)
{ {
$this->serial_bc = $optval; $this->serial_bc = $optval;
return $this; return $this;
} }
/** /**
* Override * Override
*/ */
public function dbInsert() public function dbInsert()
{ {
} }
/** /**
* Override * Override
*/ */
public function dbUpdate() public function dbUpdate()
{ {
} }
/** /**
* Override * Override
*/ */
public function dbReplace() public function dbReplace()
{ {
} }
/** /**
* Override * Override
*/ */
public function dbDelete() public function dbDelete()
{ {
} }
} }
/** /**
* Handle core preferences * Handle core preferences
* *
* @package e107 * @package e107
* @category e107_handlers * @category e107_handlers
* @version 1.0 * @version 1.0
* @author SecretR * @author SecretR
* @copyright Copyright (c) 2009, e107 Inc. * @copyright Copyright (c) 2009, e107 Inc.
*/ */
final class e_core_pref extends e_pref final class e_core_pref extends e_pref
{ {
/** /**
* Allowed core id array * Allowed core id array
* *
* @var array * @var array
*/ */
public $aliases = array( public $aliases = array(
'core' => 'SitePrefs', 'core' => 'SitePrefs',
'core_backup' => 'SitePrefs_Backup', 'core_backup' => 'SitePrefs_Backup',
'core_old' => 'pref', 'core_old' => 'pref',
'emote' => 'emote_default', //TODO include other emote packs of the user. 'emote' => 'emote_default', //TODO include other emote packs of the user.
'menu' => 'menu_pref', 'menu' => 'menu_pref',
'search' => 'search_prefs', 'search' => 'search_prefs',
'notify' => 'notify_prefs', 'notify' => 'notify_prefs',
'ipool' => 'IconPool' 'ipool' => 'IconPool'
); );
/** /**
* Backward compatibility - list of prefid's which operate wit serialized data * Backward compatibility - list of prefid's which operate wit serialized data
* *
@@ -743,31 +743,31 @@ final class e_core_pref extends e_pref
{ {
$pref_alias = $alias; $pref_alias = $alias;
$pref_id = $this->getConfigId($alias); $pref_id = $this->getConfigId($alias);
if(!$pref_id) if(!$pref_id)
{ {
$pref_id = $pref_alias = ''; $pref_id = $pref_alias = '';
trigger_error('Core config ID '.$alias.' not found!', E_USER_WARNING); trigger_error('Core config ID '.$alias.' not found!', E_USER_WARNING);
return; return;
} }
if(in_array($pref_alias, $this->serial_bc_array)) if(in_array($pref_alias, $this->serial_bc_array))
{ {
$this->setOptionSerialize(true); $this->setOptionSerialize(true);
} }
if('core' === $pref_alias) if('core' === $pref_alias)
{ {
$this->setOptionBackup(true); $this->setOptionBackup(true);
} }
parent::__construct($pref_id, $pref_alias); parent::__construct($pref_id, $pref_alias);
if($load && $pref_id) if($load && $pref_id)
{ {
$this->load(); $this->load();
} }
} }
/** /**
* Get config ID * Get config ID
* Allowed values: key or value from $alias array * Allowed values: key or value from $alias array
@@ -785,7 +785,7 @@ final class e_core_pref extends e_pref
} }
return false; return false;
} }
/** /**
* Get config ID * Get config ID
* Allowed values: key or value from $alias array * Allowed values: key or value from $alias array
@@ -803,14 +803,14 @@ final class e_core_pref extends e_pref
/** /**
* Handle plugin preferences * Handle plugin preferences
* *
* @package e107 * @package e107
* @category e107_handlers * @category e107_handlers
* @version 1.0 * @version 1.0
* @author SecretR * @author SecretR
* @copyright Copyright (c) 2009, e107 Inc. * @copyright Copyright (c) 2009, e107 Inc.
*/ */
class e_plugin_pref extends e_pref class e_plugin_pref extends e_pref
{ {
/** /**
* Unique plugin name * Unique plugin name
@@ -818,7 +818,7 @@ class e_plugin_pref extends e_pref
* @var string * @var string
*/ */
protected $plugin_id; protected $plugin_id;
/** /**
* Constructor * Constructor
* Note: object data will be loaded only if the plugin is installed (no matter of the passed * Note: object data will be loaded only if the plugin is installed (no matter of the passed
@@ -841,7 +841,7 @@ class e_plugin_pref extends e_pref
$this->load(); $this->load();
} }
} }
/** /**
* Retrive unique plugin name * Retrive unique plugin name
* *
@@ -872,7 +872,7 @@ class e_plugin_pref extends e_pref
// Just to be safe I have changed a number of menu_pref edits to use setArray(). // Just to be safe I have changed a number of menu_pref edits to use setArray().
// //
class prefs class prefs
{ {
var $prefVals; var $prefVals;
var $prefArrays; var $prefArrays;
@@ -885,7 +885,7 @@ class prefs
// If $use_default is TRUE, $RowList entries are added to the default array. Otherwise only $RowList is used. // If $use_default is TRUE, $RowList entries are added to the default array. Otherwise only $RowList is used.
// Returns TRUE on success (measured as getting at least one row of data); false on error. // Returns TRUE on success (measured as getting at least one row of data); false on error.
// Any data read is buffered (in serialised form) here - retrieve using get() // Any data read is buffered (in serialised form) here - retrieve using get()
function ExtractPrefs($RowList = "", $use_default = FALSE) function ExtractPrefs($RowList = "", $use_default = FALSE)
{ {
global $sql; global $sql;
$Args = ''; $Args = '';
@@ -920,29 +920,29 @@ class prefs
* @return string pref value, slashes already stripped. FALSE on error * @return string pref value, slashes already stripped. FALSE on error
* @access public * @access public
*/ */
function get($Name) function get($Name)
{ {
if(isset($this->prefVals['core'][$Name])) if(isset($this->prefVals['core'][$Name]))
{ {
if($this->prefVals['core'][$Name] != '### ROW CACHE FALSE ###') if($this->prefVals['core'][$Name] != '### ROW CACHE FALSE ###')
{ {
return $this->prefVals['core'][$Name]; // Dava from cache return $this->prefVals['core'][$Name]; // Dava from cache
} }
else else
{ {
return false; return false;
} }
} }
// Data not in cache - retrieve from DB // Data not in cache - retrieve from DB
$get_sql = new db; // required so sql loops don't break using $tp->toHTML(). $get_sql = new db; // required so sql loops don't break using $tp->toHTML().
if($get_sql->db_Select('core', '*', "`e107_name` = '{$Name}'", 'default')) if($get_sql->db_Select('core', '*', "`e107_name` = '{$Name}'", 'default'))
{ {
$row = $get_sql->db_Fetch(); $row = $get_sql->db_Fetch();
$this->prefVals['core'][$Name] = $row['e107_value']; $this->prefVals['core'][$Name] = $row['e107_value'];
return $this->prefVals['core'][$Name]; return $this->prefVals['core'][$Name];
} }
else else
{ // Data not in DB - put a 'doesn't exist' entry in cache to save another DB access { // Data not in DB - put a 'doesn't exist' entry in cache to save another DB access
$this->prefVals['core'][$Name] = '### ROW CACHE FALSE ###'; $this->prefVals['core'][$Name] = '### ROW CACHE FALSE ###';
return false; return false;

View File

@@ -9,9 +9,9 @@
* Installation file * Installation file
* *
* $Source: /cvs_backup/e107_0.8/install_.php,v $ * $Source: /cvs_backup/e107_0.8/install_.php,v $
* $Revision: 1.55 $ * $Revision: 1.56 $
* $Date: 2009-11-24 20:40:35 $ * $Date: 2009-12-02 16:51:04 $
* $Author: e107steved $ * $Author: secretr $
* *
*/ */
@@ -20,10 +20,10 @@ define('MIN_PHP_VERSION', '5.0');
define('MIN_MYSQL_VERSION', '4.1.2'); define('MIN_MYSQL_VERSION', '4.1.2');
// ensure CHARSET is UTF-8 if used // ensure CHARSET is UTF-8 if used
define('CHARSET', 'utf-8'); //define('CHARSET', 'utf-8');
/* Default Options and Paths for Installer */ /* Default Options and Paths for Installer */
$MySQLPrefix = 'e107_'; $MySQLprefix = 'e107_';
$ADMIN_DIRECTORY = "e107_admin/"; $ADMIN_DIRECTORY = "e107_admin/";
$FILES_DIRECTORY = "e107_files/"; $FILES_DIRECTORY = "e107_files/";
@@ -48,13 +48,13 @@ if(isset($_GET['object']))
} }
define("e107_INIT", TRUE); define("e107_INIT", TRUE);
define("e_UC_PUBLIC", 0); /*define("e_UC_PUBLIC", 0);
define("e_UC_MAINADMIN", 250); define("e_UC_MAINADMIN", 250);
define("e_UC_READONLY", 251); define("e_UC_READONLY", 251);
define("e_UC_GUEST", 252); define("e_UC_GUEST", 252);
define("e_UC_MEMBER", 253); define("e_UC_MEMBER", 253);
define("e_UC_ADMIN", 254); define("e_UC_ADMIN", 254);
define("e_UC_NOBODY", 255); define("e_UC_NOBODY", 255);*/
define("E107_INSTALL",TRUE); define("E107_INSTALL",TRUE);
@@ -143,9 +143,8 @@ function check_class($whatever)
$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'CACHE_DIRECTORY', 'DOWNLOADS_DIRECTORY', 'UPLOADS_DIRECTORY', 'MEDIA_DIRECTORY'); $e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'CACHE_DIRECTORY', 'DOWNLOADS_DIRECTORY', 'UPLOADS_DIRECTORY', 'MEDIA_DIRECTORY');
$e107 = e107::getInstance(); $e107 = e107::getInstance();
$e107->init($e107_paths, realpath(dirname(__FILE__))); $e107->initInstall($e107_paths, realpath(dirname(__FILE__)));
unset($e107_paths); unset($e107_paths);
function include_lan($path, $force = false) function include_lan($path, $force = false)
@@ -182,7 +181,7 @@ class e_install
var $previous_steps; var $previous_steps;
var $stage; var $stage;
var $post_data; var $post_data;
var $required = ""; //TODO - use for highlighting required fields with css/js. var $required = ""; //TODO - use for highlighting required fields with css/js.
function e_install() function e_install()
{ {
@@ -201,7 +200,7 @@ class e_install
} }
$this->get_lan_file(); $this->get_lan_file();
$this->post_data = $_POST; $this->post_data = $_POST;
$this->template->SetTag("required", ""); $this->template->SetTag("required", "");
if(isset($this->previous_steps['language'])) if(isset($this->previous_steps['language']))
{ {
@@ -210,7 +209,7 @@ class e_install
} }
} }
function renderPage() function renderPage()
{ {
if(!isset($_POST['stage'])) if(!isset($_POST['stage']))
@@ -248,7 +247,7 @@ class e_install
default: default:
$this->raise_error("Install stage information from client makes no sense to me."); $this->raise_error("Install stage information from client makes no sense to me.");
} }
if($_SERVER['QUERY_STRING'] == "debug") if($_SERVER['QUERY_STRING'] == "debug")
{ {
$this->template->SetTag("debug_info", print_a($this,TRUE)); $this->template->SetTag("debug_info", print_a($this,TRUE));
@@ -257,8 +256,8 @@ class e_install
{ {
$this->template->SetTag("debug_info", (count($this->debug_info) ? print_a($this->debug_info,TRUE)."Backtrace:<br />".print_a($this,TRUE) : "")); $this->template->SetTag("debug_info", (count($this->debug_info) ? print_a($this->debug_info,TRUE)."Backtrace:<br />".print_a($this,TRUE) : ""));
} }
echo $this->template->ParseTemplate(template_data(), TEMPLATE_TYPE_DATA); echo $this->template->ParseTemplate(template_data(), TEMPLATE_TYPE_DATA);
} }
function raise_error($details) function raise_error($details)
@@ -270,7 +269,7 @@ class e_install
) )
); );
} }
function display_required() function display_required()
{ {
if(!$this->required) if(!$this->required)
@@ -282,7 +281,7 @@ class e_install
{ {
$this->template->SetTag("required","<div class='message'>". implode("<br />",$this->required)."</div>"); $this->template->SetTag("required","<div class='message'>". implode("<br />",$this->required)."</div>");
$this->required = array(); $this->required = array();
} }
} }
private function stage_1() private function stage_1()
@@ -315,7 +314,7 @@ class e_install
$page_info = nl2br(LANINS_023); $page_info = nl2br(LANINS_023);
$e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : ""));
$output = " $output = "
<div style='width: 100%; padding-left: auto; padding-right: auto;'> <div style='width: 100%; padding-left: auto; padding-right: auto;'>
<br /><br /> <br /><br />
<table cellspacing='0'> <table cellspacing='0'>
@@ -366,8 +365,8 @@ class e_install
$this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_pre", LANINS_002);
$this->template->SetTag("stage_num", LANINS_036); $this->template->SetTag("stage_num", LANINS_036);
$this->template->SetTag("onload", "document.getElementById('name').focus()"); $this->template->SetTag("onload", "document.getElementById('name').focus()");
$this->previous_steps['mysql']['server'] = trim($_POST['server']); $this->previous_steps['mysql']['server'] = trim($_POST['server']);
$this->previous_steps['mysql']['user'] = trim($_POST['name']); $this->previous_steps['mysql']['user'] = trim($_POST['name']);
$this->previous_steps['mysql']['password'] = $_POST['password']; $this->previous_steps['mysql']['password'] = $_POST['password'];
@@ -382,7 +381,7 @@ class e_install
$e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : ""));
$head = LANINS_039."<br /><br />\n"; $head = LANINS_039."<br /><br />\n";
$output = " $output = "
<div style='width: 100%; padding-left: auto; padding-right: auto;'> <div style='width: 100%; padding-left: auto; padding-right: auto;'>
<table cellspacing='0'> <table cellspacing='0'>
<tr> <tr>
@@ -445,11 +444,11 @@ class e_install
} }
*/ */
// Do brute force for now - Should be enough // Do brute force for now - Should be enough
$DB_ALREADY_EXISTS = mysql_select_db($this->previous_steps['mysql']['db'], $res); $DB_ALREADY_EXISTS = mysql_select_db($this->previous_steps['mysql']['db'], $res);
//TODO Add option to continue install even if DB exists. //TODO Add option to continue install even if DB exists.
if($this->previous_steps['mysql']['createdb'] == 1) if($this->previous_steps['mysql']['createdb'] == 1)
{ {
$query = 'CREATE DATABASE '.$this->previous_steps['mysql']['db'].' CHARACTER SET `utf8` '; $query = 'CREATE DATABASE '.$this->previous_steps['mysql']['db'].' CHARACTER SET `utf8` ';
@@ -458,11 +457,11 @@ class e_install
{ {
$query = 'ALTER DATABASE '.$this->previous_steps['mysql']['db'].' CHARACTER SET `utf8` '; $query = 'ALTER DATABASE '.$this->previous_steps['mysql']['db'].' CHARACTER SET `utf8` ';
} }
if (!$this->dbqry($query)) if (!$this->dbqry($query))
{ {
$success = FALSE; $success = FALSE;
$page_content .= "<br /><br />".LANINS_043.nl2br("\n\n<b>".LANINS_083."\n</b><i>".mysql_error()."</i>"); $page_content .= "<br /><br />".LANINS_043.nl2br("\n\n<b>".LANINS_083."\n</b><i>".mysql_error()."</i>");
} }
else else
{ {
@@ -488,7 +487,7 @@ class e_install
private function stage_4() private function stage_4()
{ {
global $e_forms; global $e_forms;
$this->stage = 4; $this->stage = 4;
$this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("installation_heading", LANINS_001);
@@ -609,7 +608,7 @@ class e_install
* @return string HTML form of stage 5. * @return string HTML form of stage 5.
*/ */
private function stage_5() private function stage_5()
{ {
global $e_forms; global $e_forms;
$this->stage = 5; $this->stage = 5;
@@ -620,8 +619,8 @@ class e_install
$this->template->SetTag("stage_num", LANINS_046); $this->template->SetTag("stage_num", LANINS_046);
$this->template->SetTag("stage_title", LANINS_047); $this->template->SetTag("stage_title", LANINS_047);
$this->template->SetTag("onload", "document.getElementById('u_name').focus()"); $this->template->SetTag("onload", "document.getElementById('u_name').focus()");
$e_forms->start_form("admin_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $e_forms->start_form("admin_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : ""));
$output = " $output = "
<div style='width: 100%; padding-left: auto; padding-right: auto;'> <div style='width: 100%; padding-left: auto; padding-right: auto;'>
@@ -660,17 +659,17 @@ class e_install
$e_forms->add_button("submit", LANINS_035); $e_forms->add_button("submit", LANINS_035);
$this->template->SetTag("stage_content", $e_forms->return_form()); $this->template->SetTag("stage_content", $e_forms->return_form());
} }
/** /**
* Collect User's Website Preferences * Collect User's Website Preferences
* *
* @return string HTML form of stage 6. * @return string HTML form of stage 6.
*/ */
private function stage_6() private function stage_6()
{ {
global $e_forms; global $e_forms;
$this->stage = 6; $this->stage = 6;
// -------------------- Save Step 5 Data ------------------------- // -------------------- Save Step 5 Data -------------------------
@@ -680,7 +679,7 @@ class e_install
$_POST['u_name'] = str_replace(array("'", '"'), "", $_POST['u_name']); $_POST['u_name'] = str_replace(array("'", '"'), "", $_POST['u_name']);
$this->previous_steps['admin']['user'] = $_POST['u_name']; $this->previous_steps['admin']['user'] = $_POST['u_name'];
} }
if(!vartrue($this->previous_steps['admin']['display']) || varset($_POST['d_name'])) if(!vartrue($this->previous_steps['admin']['display']) || varset($_POST['d_name']))
{ {
$_POST['d_name'] = str_replace(array("'", '"'), "", $_POST['d_name']); $_POST['d_name'] = str_replace(array("'", '"'), "", $_POST['d_name']);
@@ -691,44 +690,44 @@ class e_install
else else
{ {
$this->previous_steps['admin']['display'] = $_POST['d_name']; $this->previous_steps['admin']['display'] = $_POST['d_name'];
} }
} }
if(!vartrue($this->previous_steps['admin']['email']) || varset($_POST['email'])) if(!vartrue($this->previous_steps['admin']['email']) || varset($_POST['email']))
{ {
$this->previous_steps['admin']['email'] = $_POST['email']; $this->previous_steps['admin']['email'] = $_POST['email'];
} }
if(varset($_POST['pass1']) || !vartrue($this->previous_steps['admin']['password'])) if(varset($_POST['pass1']) || !vartrue($this->previous_steps['admin']['password']))
{ {
if($_POST['pass1'] != $_POST['pass2']) if($_POST['pass1'] != $_POST['pass2'])
{ {
$this->required['pass1'] = LANINS_049; // passwords don't match. $this->required['pass1'] = LANINS_049; // passwords don't match.
} }
elseif(!vartrue($_POST['pass1'])) elseif(!vartrue($_POST['pass1']))
{ {
$this->required['pass1'] = LANINS_077; $this->required['pass1'] = LANINS_077;
} }
else else
{ {
$this->previous_steps['admin']['password'] = $_POST['pass1']; $this->previous_steps['admin']['password'] = $_POST['pass1'];
} }
} }
// ------------- Validate Step 5 Data. -------------------------- // ------------- Validate Step 5 Data. --------------------------
if(!vartrue($this->previous_steps['admin']['user']) || !vartrue($this->previous_steps['admin']['password'])) if(!vartrue($this->previous_steps['admin']['user']) || !vartrue($this->previous_steps['admin']['password']))
{ {
$this->required['u_name'] = LANINS_086; // $this->required['u_name'] = LANINS_086; //
} }
if(vartrue($this->required['u_name']) || vartrue($this->required['pass1'])) if(vartrue($this->required['u_name']) || vartrue($this->required['pass1']))
{ {
return $this->stage_5(); return $this->stage_5();
} }
// ------------- Step 6 Form -------------------------------- // ------------- Step 6 Form --------------------------------
$this->display_required(); $this->display_required();
@@ -737,8 +736,8 @@ class e_install
$this->template->SetTag("stage_num", LANINS_056); $this->template->SetTag("stage_num", LANINS_056);
$this->template->SetTag("stage_title", LANINS_117); // Website Preferences; $this->template->SetTag("stage_title", LANINS_117); // Website Preferences;
$this->template->SetTag("onload", "document.getElementById('sitename').focus()"); $this->template->SetTag("onload", "document.getElementById('sitename').focus()");
$e_forms->start_form("pref_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $e_forms->start_form("pref_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : ""));
$output = " $output = "
<div style='width: 100%; padding-left: auto; padding-right: auto; margin-bottom:20px'> <div style='width: 100%; padding-left: auto; padding-right: auto; margin-bottom:20px'>
@@ -751,7 +750,7 @@ class e_install
<td class='row-border'><label for='sitename'>".LANINS_107."</label></td> <td class='row-border'><label for='sitename'>".LANINS_107."</label></td>
<td class='row-border'><input class='tbox' type='text' name='sitename' id='sitename' size='30' value='".(vartrue($_POST['sitename']) ? $_POST['sitename'] : "")."' maxlength='60' /> <td class='row-border'><input class='tbox' type='text' name='sitename' id='sitename' size='30' value='".(vartrue($_POST['sitename']) ? $_POST['sitename'] : "")."' maxlength='60' />
".LANINS_108."</td> ".LANINS_108."</td>
</tr> </tr>
<tr> <tr>
<td class='row-border'><label>".LANINS_109."</label><br />".LANINS_110."</td> <td class='row-border'><label>".LANINS_109."</label><br />".LANINS_110."</td>
@@ -761,35 +760,35 @@ class e_install
<td class='row-border'>".LANINS_115."</td> <td class='row-border'>".LANINS_115."</td>
<td class='row-border'>".LANINS_116."</td> <td class='row-border'>".LANINS_116."</td>
</tr>"; </tr>";
$themes = $this->get_themes(); $themes = $this->get_themes();
foreach($themes as $val) foreach($themes as $val)
{ {
$themeInfo = $this->get_theme_xml($val); $themeInfo = $this->get_theme_xml($val);
$title = vartrue($themeInfo['@attributes']['name']); $title = vartrue($themeInfo['@attributes']['name']);
$category = vartrue($themeInfo['category']); $category = vartrue($themeInfo['category']);
$output .= "<tr> $output .= "<tr>
<td><input type='radio' name='sitetheme' value='{$val}' /> {$title}</td> <td><input type='radio' name='sitetheme' value='{$val}' /> {$title}</td>
<td>{$category}</td> <td>{$category}</td>
</tr>"; </tr>";
} }
$output .= "</table></td> $output .= "</table></td>
</tr> </tr>
<tr> <tr>
<td class='row-border'><label for='install_plugins'>".LANINS_118."</label></td> <td class='row-border'><label for='install_plugins'>".LANINS_118."</label></td>
<td class='row-border'><input type='checkbox' name='install_plugins' checked='checked' id='install_plugins' value='1' /> <td class='row-border'><input type='checkbox' name='install_plugins' checked='checked' id='install_plugins' value='1' />
".LANINS_119." ".LANINS_119."
</td> </td>
</tr> </tr>
<tr> <tr>
<td class='row-border'><label for='generate_content'>".LANINS_111."</label></td> <td class='row-border'><label for='generate_content'>".LANINS_111."</label></td>
<td class='row-border'><input type='checkbox' name='generate_content' checked='checked' id='generate_content' value='1' /> <td class='row-border'><input type='checkbox' name='generate_content' checked='checked' id='generate_content' value='1' />
".LANINS_112." ".LANINS_112."
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
@@ -803,51 +802,51 @@ class e_install
private function stage_7() private function stage_7()
{ {
global $e_forms; global $e_forms;
$this->stage = 7; $this->stage = 7;
if(varset($_POST['sitename'])) if(varset($_POST['sitename']))
{ {
$this->previous_steps['prefs']['sitename'] = $_POST['sitename']; $this->previous_steps['prefs']['sitename'] = $_POST['sitename'];
} }
if(varset($_POST['sitetheme'])) if(varset($_POST['sitetheme']))
{ {
$this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme']; $this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme'];
} }
if(varset($_POST['generate_content'])) if(varset($_POST['generate_content']))
{ {
$this->previous_steps['generate_content'] = $_POST['generate_content']; $this->previous_steps['generate_content'] = $_POST['generate_content'];
} }
if(varset($_POST['install_plugins'])) if(varset($_POST['install_plugins']))
{ {
$this->previous_steps['install_plugins'] = $_POST['install_plugins']; $this->previous_steps['install_plugins'] = $_POST['install_plugins'];
} }
// Validate. // Validate.
if(!vartrue($this->previous_steps['prefs']['sitename'])) if(!vartrue($this->previous_steps['prefs']['sitename']))
{ {
$this->required['sitename'] = LANINS_113; // 'Please enter a website name.'; // should be used to highlight the required field. (using css for example) $this->required['sitename'] = LANINS_113; // 'Please enter a website name.'; // should be used to highlight the required field. (using css for example)
} }
if(!vartrue($this->previous_steps['prefs']['sitetheme'])) if(!vartrue($this->previous_steps['prefs']['sitetheme']))
{ {
$this->required['sitetheme'] = LANINS_114; // 'Please select a theme.'; $this->required['sitetheme'] = LANINS_114; // 'Please select a theme.';
} }
if(vartrue($this->required['sitetheme']) || vartrue($this->required['sitename'])) if(vartrue($this->required['sitetheme']) || vartrue($this->required['sitename']))
{ {
return $this->stage_6(); return $this->stage_6();
} }
// Data is okay - Continue. // Data is okay - Continue.
// $this->previous_steps['prefs']['sitename'] = $_POST['sitename']; // $this->previous_steps['prefs']['sitename'] = $_POST['sitename'];
// $this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme']; // $this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme'];
// $this->previous_steps['generate_content'] = $_POST['generate_content']; // $this->previous_steps['generate_content'] = $_POST['generate_content'];
$this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("installation_heading", LANINS_001);
$this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_pre", LANINS_002);
$this->template->SetTag("stage_num", LANINS_058); $this->template->SetTag("stage_num", LANINS_058);
@@ -857,14 +856,14 @@ class e_install
$page = nl2br(LANINS_057); $page = nl2br(LANINS_057);
$this->finish_form(); $this->finish_form();
$e_forms->add_button("submit", LANINS_035); $e_forms->add_button("submit", LANINS_035);
$this->template->SetTag("stage_content", $page.$e_forms->return_form()); $this->template->SetTag("stage_content", $page.$e_forms->return_form());
} }
private function stage_8() private function stage_8()
{ {
global $e_forms; global $e_forms;
$this->stage = 8; $this->stage = 8;
@@ -872,7 +871,7 @@ class e_install
$this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_pre", LANINS_002);
$this->template->SetTag("stage_num", LANINS_120); $this->template->SetTag("stage_num", LANINS_120);
$this->template->SetTag("stage_title", LANINS_071); $this->template->SetTag("stage_title", LANINS_071);
$config_file = "<?php $config_file = "<?php
/* /*
@@ -920,10 +919,8 @@ class e_install
$page = $config_result."<br />"; $page = $config_result."<br />";
} }
else else
{ {
$errors = $this->create_tables(); $errors = $this->create_tables();
if ($errors == true) if ($errors == true)
{ {
$page = $errors."<br />"; $page = $errors."<br />";
@@ -950,107 +947,105 @@ class e_install
public function import_configuration() public function import_configuration()
{ {
// Basic stuff to get the handlers/classes to work. // Basic stuff to get the handlers/classes to work.
$udirs = "admin/|plugins/|temp"; // $udirs = "admin/|plugins/|temp";
$e_SELF = $_SERVER['PHP_SELF']; // $e_SELF = $_SERVER['PHP_SELF'];
$e_HTTP = preg_replace("#".$udirs."#i", "", substr($e_SELF, 0, strrpos($e_SELF, "/"))."/"); // $e_HTTP = preg_replace("#".$udirs."#i", "", substr($e_SELF, 0, strrpos($e_SELF, "/"))."/");
define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? true : false)); //define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? true : false));
// define('CHARSET', 'utf-8'); // define('CHARSET', 'utf-8');
// define("e_LANGUAGE", $this->previous_steps['language']); // define("e_LANGUAGE", $this->previous_steps['language']);
define('e_SELF', 'http://'.$_SERVER['HTTP_HOST']) . ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']); // define('e_SELF', 'http://'.$_SERVER['HTTP_HOST']) . ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']);
$themeImportFile = array(); $themeImportFile = array();
$themeImportFile[0] = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install.xml"; $themeImportFile[0] = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install.xml";
$themeImportFile[1] = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install/install.xml"; $themeImportFile[1] = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install/install.xml";
$themeImportFile[3] = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml"; $themeImportFile[3] = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml";
if(vartrue($this->previous_steps['generate_content'])) if(vartrue($this->previous_steps['generate_content']))
{ {
foreach($themeImportFile as $file) foreach($themeImportFile as $file)
{ {
if(is_readable($file)) if(is_readable($file))
{ {
$XMLImportfile = $file; $XMLImportfile = $file;
break; break;
} }
} }
} }
else else
{ {
$XMLImportfile = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml"; $XMLImportfile = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml";
} }
$tp = e107::getParser(); $tp = e107::getParser();
define('PREVIEWTHEMENAME',""); // Notice Removal. define('PREVIEWTHEMENAME',""); // Notice Removal.
include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/lan_prefs.php"); include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/lan_prefs.php");
include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/admin/lan_theme.php"); include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/admin/lan_theme.php");
//Create default plugin-table entries. //Create default plugin-table entries.
// e107::getConfig('core')->clearPrefCache(); // e107::getConfig('core')->clearPrefCache();
e107::getSingleton('e107plugin')->update_plugins_table(); e107::getSingleton('e107plugin')->update_plugins_table();
// Install Theme-required plugins // Install Theme-required plugins
if(vartrue($this->previous_steps['install_plugins'])) if(vartrue($this->previous_steps['install_plugins']))
{ {
if($themeInfo = $this->get_theme_xml($this->previous_steps['prefs']['sitetheme'])) if($themeInfo = $this->get_theme_xml($this->previous_steps['prefs']['sitetheme']))
{ {
if(isset($themeInfo['plugins']['plugin'])) if(isset($themeInfo['plugins']['plugin']))
{ {
foreach($themeInfo['plugins']['plugin'] as $k=>$plug) foreach($themeInfo['plugins']['plugin'] as $k=>$plug)
{ {
$this->install_plugin($plug['@attributes']['name']); $this->install_plugin($plug['@attributes']['name']);
} }
} }
} }
} }
//FIXME - should be 'add' not 'replace' - but 'add' doesn't insert arrays correctly. //FIXME - should be 'add' not 'replace' - but 'add' doesn't insert arrays correctly.
e107::getXml()->e107Import($XMLImportfile,'replace'); // Add missing core pref values e107::getXml()->e107Import($XMLImportfile,'replace'); // Add missing core pref values
e107::getSingleton('e107plugin')->save_addon_prefs(); // save plugin addon pref-lists. eg. e_latest_list. e107::getSingleton('e107plugin')->save_addon_prefs(); // save plugin addon pref-lists. eg. e_latest_list.
$tm = e107::getSingleton('themeHandler'); $tm = e107::getSingleton('themeHandler');
$tm->noLog = TRUE; $tm->noLog = TRUE;
$tm->setTheme($this->previous_steps['prefs']['sitetheme']); $tm->setTheme($this->previous_steps['prefs']['sitetheme']);
$pref = e107::getConfig('core')->getPref(); $pref = e107::getConfig('core')->getPref();
// Set Preferences defined during install - overwriting those that may exist in the XML. // 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']['sitelanguage'] = $this->previous_steps['language'];
$this->previous_steps['prefs']['sitelang_init'] = $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']['siteadmin'] = $this->previous_steps['admin']['display'];
$this->previous_steps['prefs']['siteadminemail'] = $this->previous_steps['admin']['email']; $this->previous_steps['prefs']['siteadminemail'] = $this->previous_steps['admin']['email'];
$this->previous_steps['prefs']['install_date'] = time(); $this->previous_steps['prefs']['install_date'] = time();
$this->previous_steps['prefs']['siteurl'] = $e_HTTP; $this->previous_steps['prefs']['siteurl'] = e_HTTP;
$this->previous_steps['prefs']['sitetag'] = LAN_PREF_2; $this->previous_steps['prefs']['sitetag'] = LAN_PREF_2;
$this->previous_steps['prefs']['sitedisclaimer'] = LAN_PREF_3; $this->previous_steps['prefs']['sitedisclaimer'] = LAN_PREF_3;
$this->previous_steps['prefs']['replyto_name'] = $this->previous_steps['admin']['display']; $this->previous_steps['prefs']['replyto_name'] = $this->previous_steps['admin']['display'];
$this->previous_steps['prefs']['replyto_email'] = $this->previous_steps['admin']['email']; $this->previous_steps['prefs']['replyto_email'] = $this->previous_steps['admin']['email'];
$cookiename = str_replace(" ","_",$this->previous_steps['prefs']['sitename']); $cookiename = str_replace(" ","_",$this->previous_steps['prefs']['sitename']);
$this->previous_steps['prefs']['cookie_name'] = substr($cookiename,0,5)."cookie"; $this->previous_steps['prefs']['cookie_name'] = substr($cookiename,0,5)."cookie";
e107::getConfig('core')->setPref($this->previous_steps['prefs']); e107::getConfig('core')->setPref($this->previous_steps['prefs']);
e107::getConfig('core')->save(FALSE,TRUE); // save preferences made during install. e107::getConfig('core')->save(FALSE,TRUE); // save preferences made during install.
// Create the admin user - replacing any that may be been included in the XML. // Create the admin user - replacing any that may be been included in the XML.
$ip = $_SERVER['REMOTE_ADDR']; $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().", ''"; $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})" ); $this->dbqry("REPLACE INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})" );
mysql_close(); mysql_close();
return false; return false;
} }
/** /**
@@ -1059,12 +1054,12 @@ class e_install
* @param string $plugpath - plugin folder name * @param string $plugpath - plugin folder name
* @return void * @return void
*/ */
public function install_plugin($plugpath) //FIXME - requires default plugin table entries, see above. public function install_plugin($plugpath) //FIXME - requires default plugin table entries, see above.
{ {
e107::getDb()->db_Select_gen("SELECT * FROM #plugin WHERE plugin_path = '".$plugpath."' LIMIT 1"); e107::getDb()->db_Select_gen("SELECT * FROM #plugin WHERE plugin_path = '".$plugpath."' LIMIT 1");
$row = e107::getDb()->db_Fetch(MYSQL_ASSOC); $row = e107::getDb()->db_Fetch(MYSQL_ASSOC);
e107::getSingleton('e107plugin')->install_plugin($row['plugin_id']); e107::getSingleton('e107plugin')->install_plugin($row['plugin_id']);
return; return;
} }
@@ -1093,7 +1088,7 @@ class e_install
{ {
$this->previous_steps['language'] = "English"; $this->previous_steps['language'] = "English";
} }
include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/lan_installer.php"); include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/lan_installer.php");
// $this->lan_file = "{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}{$this->previous_steps['language']}/lan_installer.php"; // $this->lan_file = "{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}{$this->previous_steps['language']}/lan_installer.php";
// if(is_readable($this->lan_file)) // if(is_readable($this->lan_file))
@@ -1124,55 +1119,55 @@ class e_install
closedir($handle); closedir($handle);
return $lanlist; return $lanlist;
} }
function get_themes() function get_themes()
{ {
$handle = opendir($this->e107->e107_dirs['THEMES_DIRECTORY']); $handle = opendir($this->e107->e107_dirs['THEMES_DIRECTORY']);
$lanlist = array(); $lanlist = array();
while ($file = readdir($handle)) while ($file = readdir($handle))
{ {
if (is_dir($this->e107->e107_dirs['THEMES_DIRECTORY'].$file) && $file !='_blank') if (is_dir($this->e107->e107_dirs['THEMES_DIRECTORY'].$file) && $file !='_blank')
{ {
if(is_readable("./{$this->e107->e107_dirs['THEMES_DIRECTORY']}{$file}/theme.xml")) if(is_readable("./{$this->e107->e107_dirs['THEMES_DIRECTORY']}{$file}/theme.xml"))
{ {
$lanlist[] = $file; $lanlist[] = $file;
} }
} }
} }
closedir($handle); closedir($handle);
return $lanlist; return $lanlist;
} }
function get_theme_xml($theme_folder) function get_theme_xml($theme_folder)
{ {
if(!defined("SITEURL")) if(!defined("SITEURL"))
{ {
define("SITEURL",""); define("SITEURL","");
} }
$path = $this->e107->e107_dirs['THEMES_DIRECTORY'].$theme_folder."/theme.xml"; $path = $this->e107->e107_dirs['THEMES_DIRECTORY'].$theme_folder."/theme.xml";
if(!is_readable($path)) if(!is_readable($path))
{ {
return FALSE; return FALSE;
} }
require_once($this->e107->e107_dirs['HANDLERS_DIRECTORY']."theme_handler.php"); require_once($this->e107->e107_dirs['HANDLERS_DIRECTORY']."theme_handler.php");
$tm = new themeHandler; $tm = new themeHandler;
$xmlArray = $tm->parse_theme_xml($theme_folder); $xmlArray = $tm->parse_theme_xml($theme_folder);
// $xml = e107::getXml(); // $xml = e107::getXml();
// $xmlArray = $xml->loadXMLfile($path,'advanced'); // $xmlArray = $xml->loadXMLfile($path,'advanced');
return (is_array($xmlArray)) ? $xmlArray : FALSE; return (is_array($xmlArray)) ? $xmlArray : FALSE;
} }
function finish_form($force_stage = false) function finish_form($force_stage = false)
{ {
@@ -1250,24 +1245,23 @@ class e_install
foreach ($result[0] as $sql_table) foreach ($result[0] as $sql_table)
{ {
$sql_table = preg_replace("/create table\s/si", "CREATE TABLE {$this->previous_steps['mysql']['prefix']}", $sql_table); $sql_table = preg_replace("/create table\s/si", "CREATE TABLE {$this->previous_steps['mysql']['prefix']}", $sql_table);
// Drop existing tables before creating. // Drop existing tables before creating.
$tmp = explode("\n",$sql_table); $tmp = explode("\n",$sql_table);
$drop_table = str_replace($srch,$repl,$tmp[0]); $drop_table = str_replace($srch,$repl,$tmp[0]);
$this->dbqry($drop_table); $this->dbqry($drop_table);
if (!$this->dbqry($sql_table, $link)) if (!$this->dbqry($sql_table, $link))
{ {
return nl2br(LANINS_061."\n\n<b>".LANINS_083."\n</b><i>".mysql_error($link)."</i>"); return nl2br(LANINS_061."\n\n<b>".LANINS_083."\n</b><i>".mysql_error($link)."</i>");
} }
} }
return FALSE; return FALSE;
//TODO - remove - Everything below this point should no longer be required. See import_configuration(); //TODO - remove - Everything below this point should no longer be required. See import_configuration();
/* /*
$datestamp = time(); $datestamp = time();
@@ -1300,7 +1294,7 @@ class e_install
require_once("{$this->e107->e107_dirs['FILES_DIRECTORY']}def_e107_prefs.php"); require_once("{$this->e107->e107_dirs['FILES_DIRECTORY']}def_e107_prefs.php");
include_once("{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}arraystorage_class.php"); include_once("{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}arraystorage_class.php");
$tmp = ArrayData::WriteArray($pref); $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', '{$tmp}')");
@@ -1408,7 +1402,7 @@ class e_install
mysql_close(); mysql_close();
return false; return false;
*/ */
} }
@@ -1523,8 +1517,8 @@ function create_tables_unattended()
$einstall->previous_steps['admin']['password'] = (isset($_GET['admin_password']) ? $_GET['admin_password'] : 'admin_password'); $einstall->previous_steps['admin']['password'] = (isset($_GET['admin_password']) ? $_GET['admin_password'] : 'admin_password');
$einstall->previous_steps['admin']['email'] = (isset($_GET['admin_email']) ? $_GET['admin_email'] : 'admin_email@xxx.com'); $einstall->previous_steps['admin']['email'] = (isset($_GET['admin_email']) ? $_GET['admin_email'] : 'admin_email@xxx.com');
$einstall->previous_steps['generate_content'] = isset($_GET['gen']) ? intval($_GET['gen']) : 1; $einstall->previous_steps['generate_content'] = isset($_GET['gen']) ? intval($_GET['gen']) : 1;
$einstall->previous_steps['install_plugins'] = isset($_GET['plugins']) ? intval($_GET['plugins']) : 1; $einstall->previous_steps['install_plugins'] = isset($_GET['plugins']) ? intval($_GET['plugins']) : 1;
$einstall->previous_steps['prefs']['sitename'] = isset($_GET['sitename']) ? urldecode($_GET['sitename']) : LANINS_113; $einstall->previous_steps['prefs']['sitename'] = isset($_GET['sitename']) ? urldecode($_GET['sitename']) : LANINS_113;
$einstall->previous_steps['prefs']['sitetheme'] = isset($_GET['theme']) ? urldecode($_GET['theme']) : 'jayya'; $einstall->previous_steps['prefs']['sitetheme'] = isset($_GET['theme']) ? urldecode($_GET['theme']) : 'jayya';
@@ -1534,9 +1528,9 @@ function create_tables_unattended()
$e107->init($e107_paths, realpath(dirname(__FILE__))); $e107->init($e107_paths, realpath(dirname(__FILE__)));
$einstall->e107 = &$e107; $einstall->e107 = &$e107;
//FIXME - does not appear to work for import_configuration. ie. tables are blank except for user table. //FIXME - does not appear to work for import_configuration. ie. tables are blank except for user table.
$einstall->create_tables(); $einstall->create_tables();
$einstall->import_configuration(); $einstall->import_configuration();
return true; return true;
@@ -1587,7 +1581,7 @@ class SimpleTemplate
{ {
$TemplateData = str_replace($this->open_tag.$Tag['Tag'].$this->close_tag, $Tag['Data'], $TemplateData); $TemplateData = str_replace($this->open_tag.$Tag['Tag'].$this->close_tag, $Tag['Data'], $TemplateData);
} }
return $TemplateData; return $TemplateData;
} }
} }
@@ -1713,7 +1707,7 @@ img{
padding: 10px; padding: 10px;
text-align: center; text-align: center;
margin-bottom:15px; margin-bottom:15px;
background-color:#FFCECE; background-color:#FFCECE;
border: 1px solid #CC0000; border: 1px solid #CC0000;
} }