1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 14:17:49 +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
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
* $Revision: 1.67 $
* $Date: 2009-12-01 20:05:54 $
* $Author: e107steved $
* $Revision: 1.68 $
* $Date: 2009-12-02 16:51:00 $
* $Author: secretr $
*/
if(defined('MYSQL_LIGHT'))
@@ -24,13 +24,15 @@ if(defined('MYSQL_LIGHT'))
$sql = new db;
$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
}
elseif(defined('E107_INSTALL'))
elseif(defined('E107_INSTALL'))
{
define('E107_DEBUG_LEVEL', 0);
define('e_QUERY', '');
require_once("e107_config.php");
define('MPREFIX', $mySQLprefix);
//define('e_QUERY', '');
//require_once("e107_config.php");
//define('MPREFIX', $mySQLprefix);
require('e107_config.php');
$sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix');
e107::getInstance()->initInstallSql($sql_info);
$sql = new db;
$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
*
*
* @package e107
* @category e107_handlers
* @version $Revision: 1.67 $
* @author $Author: e107steved $
*
* @version $Revision: 1.68 $
* @author $Author: secretr $
*
*/
class e_db_mysql {
@@ -70,13 +72,13 @@ class e_db_mysql {
var $mySQLlanguage;
var $mySQLinfo;
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
/**
* MySQL Charset
*
*
* @var string
*/
public $mySQLcharset;
@@ -89,12 +91,12 @@ class e_db_mysql {
*/
public function __construct()
{
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
$langid = (isset($pref['cookie_name'])) ? 'e107language_'.$pref['cookie_name'] : 'e107language_temp';
if (isset($pref['user_tracking']) && ($pref['user_tracking'] == 'session'))
{
@@ -168,7 +170,7 @@ class e_db_mysql {
$this->dbError('dbConnect/SelectDB');
// Save the connection resource
if ($db_ConnectionID == NULL)
if ($db_ConnectionID == NULL)
$db_ConnectionID = $this->mySQLaccess;
return TRUE;
}
@@ -195,7 +197,7 @@ class e_db_mysql {
* @desc Enter description here...
* @access private
*/
function db_Show_Performance()
function db_Show_Performance()
{
return $db_debug->Show_Performance();
}
@@ -206,7 +208,7 @@ class e_db_mysql {
* @desc add query to dblog table
* @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;
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
*
*
* 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 unknown $rli
@@ -229,12 +231,12 @@ class e_db_mysql {
* For SELECT, SHOW, DESCRIBE, EXPLAIN and others returning a result set, returns a resource
* 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;
$db_mySQLQueryCount++;
if ($debug == 'now')
if ($debug == 'now')
{
echo "** $query<br />\n";
}
@@ -242,7 +244,7 @@ class e_db_mysql {
{
$queryinfo[] = "<b>{$qry_from}</b>: $query";
}
if ($log_type != '')
if ($log_type != '')
{
$this->db_Write_log($log_type, $log_remark, $query);
}
@@ -270,7 +272,7 @@ class e_db_mysql {
$this->total_results = $rc['FOUND_ROWS()'];
}
if (E107_DEBUG_LEVEL)
if (E107_DEBUG_LEVEL)
{
global $db_debug;
$aTrace = debug_backtrace();
@@ -280,12 +282,12 @@ class e_db_mysql {
} else {
$this->mySQLcurTable = ''; // clear before next query
}
if(is_object($db_debug))
if(is_object($db_debug))
{
$buglink = is_null($rli) ? $this->mySQLaccess : $rli;
$nFields = $db_debug->Mark_Query($query, $buglink, $sQryRes, $aTrace, $mytime, $pTable);
}
else
}
else
{
echo "what happened to db_debug??!!<br />";
}
@@ -317,38 +319,38 @@ class e_db_mysql {
$this->mySQLcurTable = $table;
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');
return $this->db_Rows();
}
else
}
else
{
$this->dbError("db_Select (SELECT $fields FROM ".$this->mySQLPrefix."{$table} WHERE {$arg})");
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');
return $this->db_Rows();
}
else
}
else
{
$this->dbError("db_Select (SELECT {$fields} FROM ".$this->mySQLPrefix."{$table} {$arg})");
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');
return $this->db_Rows();
}
else
}
else
{
$this->dbError("db_Select (SELECT {$fields} FROM ".$this->mySQLPrefix."{$table})");
return FALSE;
@@ -375,20 +377,20 @@ class e_db_mysql {
$this->mySQLcurTable = $table;
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']);
}
if(isset($arg['_REPLACE']))
{
$REPLACE = TRUE;
unset($arg['_REPLACE']);
unset($arg['_REPLACE']);
}
else
{
$REPLACE = FALSE;
$REPLACE = FALSE;
}
if(!isset($arg['_FIELD_TYPES']) && !isset($arg['data']))
{
//Convert data if not using 'new' format
@@ -421,16 +423,16 @@ class e_db_mysql {
}
$valList= implode(', ', $tmp);
unset($tmp);
if($REPLACE === FALSE)
{
$query = "INSERT INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})";
$query = "INSERT INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})";
}
else
{
$query = "REPLACE INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})";
$query = "REPLACE INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})";
}
}
else
{
@@ -471,7 +473,7 @@ class e_db_mysql {
function db_Replace($table, $arg, $debug = FALSE, $log_type = '', $log_remark = '')
{
$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;
$this->mySQLaccess = $db_ConnectionID;
}
if (is_array($arg)) // Remove the need for a separate db_UpdateArray() function.
{
$new_data = '';
@@ -592,11 +594,11 @@ class e_db_mysql {
case 'string':
return "'{$fieldValue}'";
break;
case 'float':
case 'float':
return (float) $fieldValue;
break;
case 'null':
return ($fieldValue && $fieldValue !== 'NULL' ? "'{$fieldValue}'" : 'NULL');
break;
@@ -668,9 +670,9 @@ class e_db_mysql {
*
* @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;
}
@@ -679,11 +681,11 @@ class e_db_mysql {
{
$row = @mysql_fetch_array($this->mySQLresult,$type);
e107::getSingleton('e107_traffic')->Bump('db_Fetch', $b);
if ($row)
if ($row)
{
$this->dbError('db_Fetch');
return $row; // Success - return data
}
}
}
$this->dbError('db_Fetch');
return FALSE; // Failure
@@ -701,20 +703,20 @@ class e_db_mysql {
*
* @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);
if ($fields == 'generic')
if ($fields == 'generic')
{
$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);
$this->dbError('db_Count');
return $rows['COUNT(*)'];
}
else
}
else
{
$this->dbError("db_Count ({$query})");
return FALSE;
@@ -722,19 +724,19 @@ class e_db_mysql {
}
$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)
{
$arg = 'WHERE '.$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);
$this->dbError('db_Count');
return $rows[0];
}
else
}
else
{
$this->dbError("db_Count({$query})");
return FALSE;
@@ -754,7 +756,7 @@ class e_db_mysql {
*
* @access public
*/
function db_Close()
function db_Close()
{
if(!$this->mySQLaccess)
{
@@ -778,7 +780,7 @@ class e_db_mysql {
* <br />
* @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);
$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');
return $result;
}
else
}
else
{
$this->dbError("db_Delete({$arg})");
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);
$this->dbError('db_Delete');
return $tmp;
}
else
}
else
{
$this->dbError('db_Delete ('.$arg.')');
return FALSE;
@@ -825,7 +827,7 @@ class e_db_mysql {
* @desc Enter description here...
* @access private
*/
function db_Rows()
function db_Rows()
{
$rows = $this->mySQLrows = @mysql_num_rows($this->mySQLresult);
$this->dbError('db_Rows');
@@ -839,7 +841,7 @@ class e_db_mysql {
* @desc Enter description here...
* @access private
*/
function db_SetErrorReporting($mode)
function db_SetErrorReporting($mode)
{
$this->mySQLerror = $mode;
}
@@ -857,22 +859,22 @@ class e_db_mysql {
public function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '')
{
$this->tabset = FALSE;
$query .= " "; // temp fix for failing regex below, when there is no space after the table name;
if(strpos($query,'`#') !== FALSE)
{
{
$query = preg_replace_callback("/\s`#([\w]*?)`\W/", array($this, 'ml_check'), $query);
}
elseif(strpos($query,'#') !== FALSE)
{
$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
//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);
if ($this->mySQLresult === FALSE)
@@ -899,7 +901,7 @@ class e_db_mysql {
}
function ml_check($matches)
{
{
$table = $this->db_IsLang($matches[1]);
if($this->tabset == false)
{
@@ -916,7 +918,7 @@ class e_db_mysql {
* @desc Enter description here...
* @access private
*/
function db_Fieldname($offset)
function db_Fieldname($offset)
{
$result = @mysql_field_name($this->mySQLresult, $offset);
return $result;
@@ -928,7 +930,7 @@ class e_db_mysql {
* @desc Enter description here...
* @access private
*/
function db_Field_info()
function db_Field_info()
{
$result = @mysql_fetch_field($this->mySQLresult);
return $result;
@@ -940,25 +942,25 @@ class e_db_mysql {
* @desc Enter description here...
* @access private
*/
function db_Num_fields()
function db_Num_fields()
{
$result = @mysql_num_fields($this->mySQLresult);
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.
* @access private
* @return name of the language table (eg. lan_french_news)
*/
function db_IsLang($table,$multiple=FALSE)
function db_IsLang($table,$multiple=FALSE)
{
global $pref;
//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)
//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)
{
return $table;
}
@@ -968,14 +970,14 @@ class e_db_mysql {
global $db_ConnectionID;
$this->mySQLaccess = $db_ConnectionID;
}
if($multiple == FALSE)
{
{
$mltable = "lan_".strtolower($this->mySQLlanguage.'_'.$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
{
{
if(!is_array($table))
{
$table = array($table);
@@ -996,7 +998,7 @@ class e_db_mysql {
}
}
}
return (varset($lanlist)) ? $lanlist : FALSE;
}
// -------------------------
@@ -1010,17 +1012,17 @@ class e_db_mysql {
* @desc returns fields as structured array
* @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();
$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)
{
@@ -1033,7 +1035,7 @@ class e_db_mysql {
}
}
}
if ($amount && $amount == $counter || ($maximum && $counter > $maximum))
if ($amount && $amount == $counter || ($maximum && $counter > $maximum))
{
break;
}
@@ -1047,7 +1049,7 @@ class e_db_mysql {
* @desc returns total number of queries made so far
* @access public
*/
function db_QueryCount()
function db_QueryCount()
{
global $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
* @return boolean TRUE if exists
*
* 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.
* 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.
*/
public function db_Table_exists($table,$language='')
{
global $pref;
$table = strtolower($table); // precaution for multilanguage
if($language && ($language != $pref['sitelanguage']))
{
if(!isset($this->mySQLtableListLanguage[$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
{
if(!$this->mySQLtableList)
{
$this->mySQLtableList = $this->db_mySQLtableList();
}
$this->mySQLtableList = $this->db_mySQLtableList();
}
return in_array($table,$this->mySQLtableList);
}
}
@@ -1221,39 +1223,39 @@ class e_db_mysql {
{
$table = array();
if($res = $this->db_Query("SHOW TABLES LIKE '".$this->mySQLPrefix."lan_".strtolower($language)."%' "))
{
{
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);
return $ret;
return $ret;
}
else
{
return $this->mySQLtableListLanguage[$language];
}
}
return $this->mySQLtableListLanguage[$language];
}
}
if(!$this->mySQLtableList)
{
$table = array();
if($res = $this->db_Query("SHOW TABLES LIKE '".$this->mySQLPrefix."%' "))
{
{
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
{
return $this->mySQLtableList;
}
}
public function db_ResetTableList()
{
$this->mySQLtableList = array();
@@ -1261,29 +1263,29 @@ class e_db_mysql {
}
/**
* Return a filtered list of DB tables.
* @param object $mode [optional] all|lan|nolan
* @return array
* Return a filtered list of DB tables.
* @param object $mode [optional] all|lan|nolan
* @return array
*/
public function db_TableList($mode='all')
{
if(!$this->mySQLtableList)
{
$this->mySQLtableList = $this->db_mySQLtableList();
}
if($mode == 'all')
{
return $this->mySQLtableList;
}
if($mode == 'lan' || $mode=='nolan')
{
$nolan = array();
$lan = array();
foreach($this->mySQLtableList as $tab)
{
if(substr($tab,0,4)!='lan_')
@@ -1292,28 +1294,28 @@ class e_db_mysql {
}
else
{
$lan[] = $tab;
}
$lan[] = $tab;
}
}
return ($mode == 'lan') ? $lan : $nolan;
}
}
function db_CopyTable($oldtable, $newtable, $drop = FALSE, $data = FALSE)
{
$old = $this->mySQLPrefix.strtolower($oldtable);
$new = $this->mySQLPrefix.strtolower($newtable);
if ($drop)
{
$this->db_Select_gen("DROP TABLE IF EXISTS {$new}");
}
//Get $old table structure
$this->db_Select_gen('SET SQL_QUOTE_SHOW_CREATE = 1');
$qry = "SHOW CREATE TABLE {$old}";
if ($this->db_Select_gen($qry))
{
@@ -1324,14 +1326,14 @@ class e_db_mysql {
}
else
{
return FALSE;
return FALSE;
}
if(!$this->db_Table_exists($newtable))
{
$result = $this->db_Query($qry);
}
if ($data) //We need to copy the data too
{
$qry = "INSERT INTO {$new} SELECT * FROM {$old}";
@@ -1348,7 +1350,7 @@ class e_db_mysql {
* @desc Calling method from within this class
* @access private
*/
function dbError($from)
function dbError($from)
{
$this->mySQLlastErrNum = mysql_errno();
$this->mySQLlastErrText = '';
@@ -1357,7 +1359,7 @@ class e_db_mysql {
return '';
}
$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__);
}
@@ -1435,7 +1437,7 @@ class e_db_mysql {
*/
class db extends e_db_mysql
{
}
?>

View File

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

View File

@@ -9,9 +9,9 @@
* Installation file
*
* $Source: /cvs_backup/e107_0.8/install_.php,v $
* $Revision: 1.55 $
* $Date: 2009-11-24 20:40:35 $
* $Author: e107steved $
* $Revision: 1.56 $
* $Date: 2009-12-02 16:51:04 $
* $Author: secretr $
*
*/
@@ -20,10 +20,10 @@ define('MIN_PHP_VERSION', '5.0');
define('MIN_MYSQL_VERSION', '4.1.2');
// ensure CHARSET is UTF-8 if used
define('CHARSET', 'utf-8');
//define('CHARSET', 'utf-8');
/* Default Options and Paths for Installer */
$MySQLPrefix = 'e107_';
$MySQLprefix = 'e107_';
$ADMIN_DIRECTORY = "e107_admin/";
$FILES_DIRECTORY = "e107_files/";
@@ -48,13 +48,13 @@ if(isset($_GET['object']))
}
define("e107_INIT", TRUE);
define("e_UC_PUBLIC", 0);
/*define("e_UC_PUBLIC", 0);
define("e_UC_MAINADMIN", 250);
define("e_UC_READONLY", 251);
define("e_UC_GUEST", 252);
define("e_UC_MEMBER", 253);
define("e_UC_ADMIN", 254);
define("e_UC_NOBODY", 255);
define("e_UC_NOBODY", 255);*/
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 = e107::getInstance();
$e107->init($e107_paths, realpath(dirname(__FILE__)));
$e107->initInstall($e107_paths, realpath(dirname(__FILE__)));
unset($e107_paths);
function include_lan($path, $force = false)
@@ -182,7 +181,7 @@ class e_install
var $previous_steps;
var $stage;
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()
{
@@ -201,7 +200,7 @@ class e_install
}
$this->get_lan_file();
$this->post_data = $_POST;
$this->template->SetTag("required", "");
if(isset($this->previous_steps['language']))
{
@@ -210,7 +209,7 @@ class e_install
}
}
function renderPage()
{
if(!isset($_POST['stage']))
@@ -248,7 +247,7 @@ class e_install
default:
$this->raise_error("Install stage information from client makes no sense to me.");
}
if($_SERVER['QUERY_STRING'] == "debug")
{
$this->template->SetTag("debug_info", print_a($this,TRUE));
@@ -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) : ""));
}
echo $this->template->ParseTemplate(template_data(), TEMPLATE_TYPE_DATA);
echo $this->template->ParseTemplate(template_data(), TEMPLATE_TYPE_DATA);
}
function raise_error($details)
@@ -270,7 +269,7 @@ class e_install
)
);
}
function display_required()
{
if(!$this->required)
@@ -282,7 +281,7 @@ class e_install
{
$this->template->SetTag("required","<div class='message'>". implode("<br />",$this->required)."</div>");
$this->required = array();
}
}
}
private function stage_1()
@@ -315,7 +314,7 @@ class e_install
$page_info = nl2br(LANINS_023);
$e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : ""));
$output = "
<div style='width: 100%; padding-left: auto; padding-right: auto;'>
<br /><br />
<table cellspacing='0'>
@@ -366,8 +365,8 @@ class e_install
$this->template->SetTag("stage_pre", LANINS_002);
$this->template->SetTag("stage_num", LANINS_036);
$this->template->SetTag("onload", "document.getElementById('name').focus()");
$this->previous_steps['mysql']['server'] = trim($_POST['server']);
$this->previous_steps['mysql']['user'] = trim($_POST['name']);
$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" : ""));
$head = LANINS_039."<br /><br />\n";
$output = "
<div style='width: 100%; padding-left: auto; padding-right: auto;'>
<table cellspacing='0'>
<tr>
@@ -445,11 +444,11 @@ class e_install
}
*/
// Do brute force for now - Should be enough
$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)
{
$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` ';
}
if (!$this->dbqry($query))
{
$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
{
@@ -488,7 +487,7 @@ class e_install
private function stage_4()
{
global $e_forms;
$this->stage = 4;
$this->template->SetTag("installation_heading", LANINS_001);
@@ -609,7 +608,7 @@ class e_install
* @return string HTML form of stage 5.
*/
private function stage_5()
private function stage_5()
{
global $e_forms;
$this->stage = 5;
@@ -620,8 +619,8 @@ class e_install
$this->template->SetTag("stage_num", LANINS_046);
$this->template->SetTag("stage_title", LANINS_047);
$this->template->SetTag("onload", "document.getElementById('u_name').focus()");
$e_forms->start_form("admin_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : ""));
$output = "
<div style='width: 100%; padding-left: auto; padding-right: auto;'>
@@ -660,17 +659,17 @@ class e_install
$e_forms->add_button("submit", LANINS_035);
$this->template->SetTag("stage_content", $e_forms->return_form());
}
/**
* Collect User's Website Preferences
*
*
* @return string HTML form of stage 6.
*/
private function stage_6()
private function stage_6()
{
global $e_forms;
$this->stage = 6;
// -------------------- Save Step 5 Data -------------------------
@@ -680,7 +679,7 @@ class e_install
$_POST['u_name'] = str_replace(array("'", '"'), "", $_POST['u_name']);
$this->previous_steps['admin']['user'] = $_POST['u_name'];
}
if(!vartrue($this->previous_steps['admin']['display']) || varset($_POST['d_name']))
{
$_POST['d_name'] = str_replace(array("'", '"'), "", $_POST['d_name']);
@@ -691,44 +690,44 @@ class e_install
else
{
$this->previous_steps['admin']['display'] = $_POST['d_name'];
}
}
}
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($_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']))
{
$this->required['pass1'] = LANINS_077;
$this->required['pass1'] = LANINS_077;
}
else
{
$this->previous_steps['admin']['password'] = $_POST['pass1'];
}
}
}
// ------------- Validate Step 5 Data. --------------------------
if(!vartrue($this->previous_steps['admin']['user']) || !vartrue($this->previous_steps['admin']['password']))
{
$this->required['u_name'] = LANINS_086; //
}
if(vartrue($this->required['u_name']) || vartrue($this->required['pass1']))
{
return $this->stage_5();
}
return $this->stage_5();
}
// ------------- Step 6 Form --------------------------------
$this->display_required();
@@ -737,8 +736,8 @@ class e_install
$this->template->SetTag("stage_num", LANINS_056);
$this->template->SetTag("stage_title", LANINS_117); // Website Preferences;
$this->template->SetTag("onload", "document.getElementById('sitename').focus()");
$e_forms->start_form("pref_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : ""));
$output = "
<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'><input class='tbox' type='text' name='sitename' id='sitename' size='30' value='".(vartrue($_POST['sitename']) ? $_POST['sitename'] : "")."' maxlength='60' />
".LANINS_108."</td>
</tr>
<tr>
<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_116."</td>
</tr>";
$themes = $this->get_themes();
foreach($themes as $val)
{
$themeInfo = $this->get_theme_xml($val);
$title = vartrue($themeInfo['@attributes']['name']);
$category = vartrue($themeInfo['category']);
$output .= "<tr>
<td><input type='radio' name='sitetheme' value='{$val}' /> {$title}</td>
<td>{$category}</td>
</tr>";
</tr>";
}
$output .= "</table></td>
</tr>
<tr>
<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' />
".LANINS_119."
</td>
</td>
</tr>
<tr>
<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' />
".LANINS_112."
</td>
</td>
</tr>
</table>
</div>
@@ -803,51 +802,51 @@ class e_install
private function stage_7()
{
global $e_forms;
$this->stage = 7;
if(varset($_POST['sitename']))
{
$this->previous_steps['prefs']['sitename'] = $_POST['sitename'];
$this->previous_steps['prefs']['sitename'] = $_POST['sitename'];
}
if(varset($_POST['sitetheme']))
{
$this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme'];
$this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme'];
}
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']))
{
$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']))
{
$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']))
{
{
$this->required['sitetheme'] = LANINS_114; // 'Please select a theme.';
}
}
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']['sitetheme'] = $_POST['sitetheme'];
// $this->previous_steps['generate_content'] = $_POST['generate_content'];
$this->template->SetTag("installation_heading", LANINS_001);
$this->template->SetTag("stage_pre", LANINS_002);
$this->template->SetTag("stage_num", LANINS_058);
@@ -857,14 +856,14 @@ class e_install
$page = nl2br(LANINS_057);
$this->finish_form();
$e_forms->add_button("submit", LANINS_035);
$this->template->SetTag("stage_content", $page.$e_forms->return_form());
}
private function stage_8()
{
global $e_forms;
$this->stage = 8;
@@ -872,7 +871,7 @@ class e_install
$this->template->SetTag("stage_pre", LANINS_002);
$this->template->SetTag("stage_num", LANINS_120);
$this->template->SetTag("stage_title", LANINS_071);
$config_file = "<?php
/*
@@ -920,10 +919,8 @@ class e_install
$page = $config_result."<br />";
}
else
{
{
$errors = $this->create_tables();
if ($errors == true)
{
$page = $errors."<br />";
@@ -950,107 +947,105 @@ class e_install
public function import_configuration()
{
// Basic stuff to get the handlers/classes to work.
$udirs = "admin/|plugins/|temp";
$e_SELF = $_SERVER['PHP_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));
// $udirs = "admin/|plugins/|temp";
// $e_SELF = $_SERVER['PHP_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('CHARSET', 'utf-8');
// 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[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[3] = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_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[3] = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml";
if(vartrue($this->previous_steps['generate_content']))
{
foreach($themeImportFile as $file)
{
if(is_readable($file))
{
$XMLImportfile = $file;
$XMLImportfile = $file;
break;
}
}
}
}
else
{
$XMLImportfile = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml";
$XMLImportfile = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml";
}
$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']."/admin/lan_theme.php");
//Create default plugin-table entries.
//Create default plugin-table entries.
// e107::getConfig('core')->clearPrefCache();
e107::getSingleton('e107plugin')->update_plugins_table();
e107::getSingleton('e107plugin')->update_plugins_table();
// Install Theme-required plugins
if(vartrue($this->previous_steps['install_plugins']))
{
if($themeInfo = $this->get_theme_xml($this->previous_steps['prefs']['sitetheme']))
{
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::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->noLog = TRUE;
$tm->setTheme($this->previous_steps['prefs']['sitetheme']);
$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']['sitelang_init'] = $this->previous_steps['language'];
$this->previous_steps['prefs']['siteadmin'] = $this->previous_steps['admin']['display'];
$this->previous_steps['prefs']['siteadminemail'] = $this->previous_steps['admin']['email'];
$this->previous_steps['prefs']['install_date'] = time();
$this->previous_steps['prefs']['siteurl'] = $e_HTTP;
$this->previous_steps['prefs']['sitetag'] = LAN_PREF_2;
$this->previous_steps['prefs']['sitedisclaimer'] = LAN_PREF_3;
$this->previous_steps['prefs']['siteurl'] = e_HTTP;
$this->previous_steps['prefs']['sitetag'] = LAN_PREF_2;
$this->previous_steps['prefs']['sitedisclaimer'] = LAN_PREF_3;
$this->previous_steps['prefs']['replyto_name'] = $this->previous_steps['admin']['display'];
$this->previous_steps['prefs']['replyto_email'] = $this->previous_steps['admin']['email'];
$cookiename = str_replace(" ","_",$this->previous_steps['prefs']['sitename']);
$this->previous_steps['prefs']['cookie_name'] = substr($cookiename,0,5)."cookie";
e107::getConfig('core')->setPref($this->previous_steps['prefs']);
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.
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.
$ip = $_SERVER['REMOTE_ADDR'];
$userp = "1, '{$this->previous_steps['admin']['display']}', '{$this->previous_steps['admin']['user']}', '', '".md5($this->previous_steps['admin']['password'])."', '', '{$this->previous_steps['admin']['email']}', '', '', 0, ".time().", 0, 0, 0, 0, 0, '{$ip}', 0, '', 0, 1, '', '', '0', '', ".time().", ''";
$this->dbqry("REPLACE INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})" );
mysql_close();
return false;
}
/**
@@ -1059,12 +1054,12 @@ class e_install
* @param string $plugpath - plugin folder name
* @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");
$row = e107::getDb()->db_Fetch(MYSQL_ASSOC);
$row = e107::getDb()->db_Fetch(MYSQL_ASSOC);
e107::getSingleton('e107plugin')->install_plugin($row['plugin_id']);
return;
return;
}
@@ -1093,7 +1088,7 @@ class e_install
{
$this->previous_steps['language'] = "English";
}
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";
// if(is_readable($this->lan_file))
@@ -1124,55 +1119,55 @@ class e_install
closedir($handle);
return $lanlist;
}
function get_themes()
{
$handle = opendir($this->e107->e107_dirs['THEMES_DIRECTORY']);
$lanlist = array();
while ($file = readdir($handle))
{
if (is_dir($this->e107->e107_dirs['THEMES_DIRECTORY'].$file) && $file !='_blank')
{
if(is_readable("./{$this->e107->e107_dirs['THEMES_DIRECTORY']}{$file}/theme.xml"))
{
$lanlist[] = $file;
}
}
}
closedir($handle);
return $lanlist;
return $lanlist;
}
function get_theme_xml($theme_folder)
{
if(!defined("SITEURL"))
{
define("SITEURL","");
}
$path = $this->e107->e107_dirs['THEMES_DIRECTORY'].$theme_folder."/theme.xml";
if(!is_readable($path))
{
return FALSE;
}
require_once($this->e107->e107_dirs['HANDLERS_DIRECTORY']."theme_handler.php");
$tm = new themeHandler;
$xmlArray = $tm->parse_theme_xml($theme_folder);
// $xml = e107::getXml();
// $xml = e107::getXml();
// $xmlArray = $xml->loadXMLfile($path,'advanced');
return (is_array($xmlArray)) ? $xmlArray : FALSE;
return (is_array($xmlArray)) ? $xmlArray : FALSE;
}
function finish_form($force_stage = false)
{
@@ -1250,24 +1245,23 @@ class e_install
foreach ($result[0] as $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);
$drop_table = str_replace($srch,$repl,$tmp[0]);
$this->dbqry($drop_table);
if (!$this->dbqry($sql_table, $link))
{
return nl2br(LANINS_061."\n\n<b>".LANINS_083."\n</b><i>".mysql_error($link)."</i>");
}
}
return FALSE;
//TODO - remove - Everything below this point should no longer be required. See import_configuration();
/*
$datestamp = time();
@@ -1300,7 +1294,7 @@ class e_install
require_once("{$this->e107->e107_dirs['FILES_DIRECTORY']}def_e107_prefs.php");
include_once("{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}arraystorage_class.php");
$tmp = ArrayData::WriteArray($pref);
$this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('SitePrefs', '{$tmp}')");
@@ -1408,7 +1402,7 @@ class e_install
mysql_close();
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']['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['install_plugins'] = isset($_GET['plugins']) ? intval($_GET['plugins']) : 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['prefs']['sitename'] = isset($_GET['sitename']) ? urldecode($_GET['sitename']) : LANINS_113;
$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__)));
$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->import_configuration();
return true;
@@ -1587,7 +1581,7 @@ class SimpleTemplate
{
$TemplateData = str_replace($this->open_tag.$Tag['Tag'].$this->close_tag, $Tag['Data'], $TemplateData);
}
return $TemplateData;
}
}
@@ -1713,7 +1707,7 @@ img{
padding: 10px;
text-align: center;
margin-bottom:15px;
background-color:#FFCECE;
background-color:#FFCECE;
border: 1px solid #CC0000;
}