diff --git a/class2.php b/class2.php
index 219f01eb6..102b30216 100644
--- a/class2.php
+++ b/class2.php
@@ -718,7 +718,7 @@ define('USER_REGISTRATION', vartrue($pref['user_reg'],false)); // User Registrat
define('e_DEVELOPER', $developerMode);
unset($developerMode);
-if(is_array($pref['xurl']))
+if(!empty($pref['xurl']) && is_array($pref['xurl']))
{
define('XURL_FACEBOOK', vartrue($pref['xurl']['facebook'], false));
define('XURL_TWITTER', vartrue($pref['xurl']['twitter'], false));
@@ -845,7 +845,8 @@ if (!function_exists('checkvalidtheme'))
}
closedir($handle);
}
- $e107tmp_theme = search_validtheme();
+
+ $e107tmp_theme = 'bootstrap3'; // set to bootstrap3 by default. search_validtheme();
define('THEME', e_THEME.$e107tmp_theme.'/');
define('THEME_ABS', e_THEME_ABS.$e107tmp_theme.'/');
if (ADMIN && strpos(e_SELF, $ADMIN_DIRECTORY) === false)
diff --git a/e107_admin/admin.php b/e107_admin/admin.php
index 3fbb76429..5cbf9a480 100644
--- a/e107_admin/admin.php
+++ b/e107_admin/admin.php
@@ -77,21 +77,64 @@ class admin_start
private $allowed_types = null;
+ private $refresh = false;
function __construct()
{
+ $this->checkPaths();
+ $this->checkTimezone();
$this->checkWritable();
$this->checkHtmlarea();
$this->checkIncompatiblePlugins();
$this->checkFileTypes();
$this->checkSuspiciousFiles();
$this->checkDeprecated();
-
+
+ if($this->refresh == true)
+ {
+ e107::getRedirect()->go(e_SELF);
+ }
+
}
+ function checkPaths()
+ {
+ $create_dir = array(e_MEDIA,e_SYSTEM,e_CACHE,e_CACHE_CONTENT,e_CACHE_IMAGE, e_CACHE_DB, e_LOG, e_BACKUP, e_CACHE_URL, e_TEMP, e_IMPORT);
+
+ $refresh = false;
+
+ foreach($create_dir as $dr)
+ {
+ if(!is_dir($dr))
+ {
+ if(mkdir($dr, 0755))
+ {
+ $this->refresh = true;
+ }
+ }
+ }
+
+ }
+
+
+
+ function checkTimezone()
+ {
+ $mes = e107::getMessage();
+ $timezone = e107::pref('core','timezone');
+
+ if(e107::getDate()->isValidTimezone($timezone) == false)
+ {
+ $mes->addWarning("Your timezone setting (".$timezone.") is invalid. It has been reset to UTC. To Modify, please go to Admin -> Preferences -> Date Display Options.", 'default', true);
+ e107::getConfig()->set('timezone','UTC')->save(false,true,false);
+ $this->refresh = true;
+ }
+
+ }
+
function checkWritable()
{
@@ -153,7 +196,8 @@ class admin_start
{
$deprecated = array(
e_ADMIN."ad_links.php",
- e_PLUGIN."tinymce4/e_meta.php", e_THEME."bootstrap3/css/bootstrap_dark.css",
+ e_PLUGIN."tinymce4/e_meta.php",
+ e_THEME."bootstrap3/css/bootstrap_dark.css",
e_PLUGIN."search_menu/languages/English.php",
e_LANGUAGEDIR."English/lan_parser_functions.php",
e_HANDLER."np_class.php",
diff --git a/e107_admin/boot.php b/e107_admin/boot.php
index 0bb381030..566a3ea60 100644
--- a/e107_admin/boot.php
+++ b/e107_admin/boot.php
@@ -31,7 +31,7 @@ e107::coreLan('footer', true);
{
$_globalLans = e107::pref('core', 'lan_global_list');
$_plugins = e107::getPref('plug_installed');
- if(is_array($_plugins) && count($_plugins) > 0)
+ if(!empty($_plugins) && !empty($_globalLans) && is_array($_plugins) && count($_plugins) > 0)
{
$_plugins = array_keys($_plugins);
diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php
index a3f55ff2b..a45e86f92 100644
--- a/e107_admin/update_routines.php
+++ b/e107_admin/update_routines.php
@@ -442,7 +442,8 @@ function update_core_prefs($type='')
if ($k && !array_key_exists($k,$pref))
{
if ($just_check) return update_needed('Missing pref: '.$k);
- $pref[$k] = $v;
+ // $pref[$k] = $v;
+ e107::getConfig()->set($k,$v);
$admin_log->logMessage($k.' => '.$v, E_MESSAGE_NODISPLAY, E_MESSAGE_INFO);
$do_save = TRUE;
}
@@ -450,7 +451,7 @@ function update_core_prefs($type='')
if ($do_save)
{
//save_prefs();
- e107::getConfig('core')->setPref($pref)->save();
+ e107::getConfig('core')->save(false,true);
$admin_log->logMessage(LAN_UPDATE_14.$e107info['e107_version'], E_MESSAGE_NODISPLAY, E_MESSAGE_INFO);
$admin_log->flushMessages('UPDATE_03',E_LOG_INFORMATIVE);
//e107::getLog()->add('UPDATE_03',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode(', ',$accum),E_LOG_INFORMATIVE,''); // Log result of actual update
@@ -502,6 +503,8 @@ function update_706_to_800($type='')
e107::getCache()->clearAll('db');
e107::getCache()->clearAll('system');
+ e107::getMessage()->setUnique();
+
// List of unwanted $pref values which can go
$obs_prefs = array('frontpage_type','rss_feeds', 'log_lvcount', 'zone', 'upload_allowedfiletype', 'real', 'forum_user_customtitle',
'utf-compatmode','frontpage_method','standards_mode','image_owner','im_quality', 'signup_option_timezone',
@@ -522,15 +525,7 @@ function update_706_to_800($type='')
$serialized_prefs = array("'emote'", "'menu_pref'", "'search_prefs'", "'emote_default'", "'pm_prefs'");
- $create_dir = array(e_MEDIA,e_SYSTEM,e_CACHE,e_CACHE_CONTENT,e_CACHE_IMAGE, e_CACHE_DB, e_LOG, e_BACKUP, e_CACHE_URL, e_TEMP, e_IMPORT);
-
- foreach($create_dir as $dr)
- {
- if(!is_dir($dr))
- {
- mkdir($dr, 0755);
- }
- }
+
// List of changed DB tables (defined in core_sql.php)
// No Longer required. - automatically checked against core_sql.php.
@@ -606,7 +601,7 @@ function update_706_to_800($type='')
$do_save = FALSE; // Set TRUE to update prefs when update complete
$updateMessages = array(); // Used to log actions for the admin log - TODO: will go once all converted to new class
- $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing whether an update is needed
+ $just_check = ($type == 'do') ? FALSE : TRUE; // TRUE if we're just seeing whether an update is needed
// if (!$just_check)
// {
@@ -629,14 +624,7 @@ function update_706_to_800($type='')
$statusTexts = array(E_MESSAGE_SUCCESS => 'Success', E_MESSAGE_ERROR => 'Fail', E_MESSAGE_INFO => 'Info');
- if (isset($pref['forum_user_customtitle']) && !isset($pref['signup_option_customtitle']))
- {
- if ($just_check) return update_needed('pref: forum_user_customtitle needs to be renamed');
- $pref['signup_option_customtitle'] = $pref['forum_user_customtitle'];
- unset($pref['forum_user_customtitle']);
- $log->logMessage(LAN_UPDATE_20.'customtitle', E_MESSAGE_SUCCESS);
- $do_save = TRUE;
- }
+
if($pref['admintheme'] == 'bootstrap')//TODO Force an admin theme update or not?
{
@@ -653,7 +641,7 @@ function update_706_to_800($type='')
$serialz_qry .= "AND e107_name IN (".implode(",",$serialized_prefs).") ";
if(e107::getDb()->select("core", "*", $serialz_qry))
{
- if ($just_check) return update_needed('Convert serialized core prefs');
+ if($just_check) return update_needed('Convert serialized core prefs');
while ($row = e107::getDb()->fetch(MYSQL_ASSOC))
{
$status = e107::getDb('sql2')->update('core',"e107_value=\"".convert_serialized($row['e107_value'])."\" WHERE e107_name='".$row['e107_name']."'") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
@@ -893,6 +881,10 @@ function update_706_to_800($type='')
$pref['frontpage'] = array(e_UC_PUBLIC => $fpdef);
// $_pdateMessages[] = LAN_UPDATE_38; //FIXME
$log->logMessage(LAN_UPDATE_20."frontpage",E_MESSAGE_DEBUG);
+
+ e107::getConfig()->add('frontpage_force', $pref['frontpage_force']);
+ e107::getConfig()->add('frontpage', $pref['frontpage']);
+ unset($pref['frontpage_force'], $pref['frontpage']);
$do_save = TRUE;
}
@@ -940,153 +932,15 @@ function update_706_to_800($type='')
}
+ if($sql->isTable('forum_t') && $sql->isEmpty('forum') && $sql->isEmpty('forum_t'))
+ {
+ if ($just_check) return update_needed('Empty forum tables need to be removed.');
+ $obs_tables[] = 'forum_t';
+ $obs_tables[] = 'forum';
+
+ }
- // New tables required (list at top. Definitions in core_sql.php)
- // ALL DEPRECATED by db_verify class.. see below.
- /*
- foreach ($new_tables as $nt)
- {
- if (!$sql->isTable($nt))
- {
- if ($just_check) return update_needed('Add table: '.$nt);
- // Get the definition
- $defs = $db_parser->get_table_def($nt,e_ADMIN.'sql/core_sql.php');
- if (count($defs)) // **** Add in table here
- {
- $status = $sql->gen('CREATE TABLE `'.MPREFIX.$defs[0][1].'` ('.$defs[0][2].') TYPE='.$defs[0][3]) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- // $updateMessages[] = LAN_UPDATE_45.$defs[0][1];
- $log->logMessage(LAN_UPDATE_27.$defs[0][1], $status);
- // catch_error($sql);
- }
- else
- { // error parsing defs file
- $log->logMessage(LAN_UPDATE_46.$defs[0][1], E_MESSAGE_ERROR);
- }
- unset($defs);
- }
- }
-
-
- // Tables whose definition needs changing significantly
- $debugLevel = E107_DBG_SQLDETAILS;
-
- foreach ($changed_tables as $ct)
- {
- $req_defs = $db_parser->get_table_def($ct,e_ADMIN."sql/core_sql.php");
- $req_fields = $db_parser->parse_field_defs($req_defs[0][2]); // Required definitions
- if ($debugLevel)
- {
- $log->logMessage("Required table structure:
".$db_parser->make_field_list($req_fields), E_MESSAGE_DEBUG);
- }
-
- if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs)) // Adds current default prefix
- {
- $log->logMessage("Couldn't get table structure: ".$ct, E_MESSAGE_DEBUG);
- }
- else
- {
-// echo $db_parser->make_table_list($actual_defs);
- $actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]);
- if ($debugLevel)
- {
- $log->logMessage("Actual table structure:
".$db_parser->make_field_list($actual_fields), E_MESSAGE_DEBUG);
- }
-
- $diffs = $db_parser->compare_field_lists($req_fields,$actual_fields);
- if (count($diffs[0]))
- { // Changes needed
- if ($just_check) return update_needed("Field changes rqd; table: ".$ct);
-
- // Do the changes here
- if ($debugLevel)
- {
- $log->logMessage("List of changes found:
".$db_parser->make_changes_list($diffs), E_MESSAGE_DEBUG);
- }
-
- $qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]);
-
- if ($debugLevel)
- {
- $log->logMessage("Update Query used: ".$qry, E_MESSAGE_DEBUG);
- }
-
- $status = $sql->gen($qry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $log->logMessage(LAN_UPDATE_21.$ct, $status);
- catch_error($sql);
- }
- }
- }
-
-
- // Plugin tables whose definition needs changing significantly
- foreach ($pluginChangedTables as $plugName => $plugList)
- {
- if (e107::isInstalled($plugName))
- {
- $ttc = explode(',',$plugList);
- foreach ($ttc as $ct)
- {
- $sqlDefs = e_PLUGIN.$plugName.'/'.str_replace('_menu','',$plugName).'_sql.php'; // Filename containing definitions
-// echo "Looking at file: {$sqlDefs}, table {$ct}
";
- $req_defs = $db_parser->get_table_def($ct,$sqlDefs);
- if (!is_array($req_defs))
- {
- echo "Couldn't get definitions from file {$sqlDefs}
";
- continue;
- }
- $req_fields = $db_parser->parse_field_defs($req_defs[0][2]); // Required definitions
- if (E107_DBG_SQLDETAILS)
- {
- $message = "Required plugin table structure:
".$db_parser->make_field_list($req_fields);
-
- $log->logMessage($message, E_MESSAGE_DEBUG);
-
- }
-
- if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs)) // Adds current default prefix
- {
-// echo "Couldn't get table structure: {$ct}
";
- }
- else
- {
-// echo $db_parser->make_table_list($actual_defs);
- $actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]);
- if (E107_DBG_SQLDETAILS)
- {
- $message= "Actual table structure:
".$db_parser->make_field_list($actual_fields);
- $log->logMessage($message, E_MESSAGE_DEBUG);
- }
-
- $diffs = $db_parser->compare_field_lists($req_fields,$actual_fields);
- if (count($diffs[0]))
- { // Changes needed
- if (E107_DBG_SQLDETAILS)
- {
- $message = "List of changes found:
".$db_parser->make_changes_list($diffs);
- $log->logMessage($message, E_MESSAGE_DEBUG);
- }
- if ($just_check) return update_needed("Field changes rqd; plugin table: ".$ct);
- // Do the changes here
- $qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]);
- if (E107_DBG_SQLDETAILS)
- {
- $message = "Update Query used: ".$qry."
";
- $log->logMessage($message, E_MESSAGE_DEBUG);
- }
- $sql->gen($qry);
- $updateMessages[] = LAN_UPDATE_51.$ct;
- $log->logMessage(LAN_UPDATE_51.$ct, E_MESSAGE_SUCCESS);
- catch_error($sql);
- }
- }
- }
- }
- }
-
-*/
-
-
// Obsolete tables (list at top)
$sql->mySQLtableList = false; // clear the cached table list.
foreach ($obs_tables as $ot)
@@ -1148,6 +1002,8 @@ function update_706_to_800($type='')
+
+
/* -------------- Upgrade Entire Table Structure - Multi-Language Supported ----------------- */
// ONLY ever add fields, never deletes.
@@ -1171,6 +1027,7 @@ function update_706_to_800($type='')
if ($just_check)
{
$mes = e107::getMessage();
+ // $mes->addDebug(print_a($dbv->errors,true));
$log->addDebug(print_a($dbv->errors,true));
return update_needed("Database Tables require updating.");
}
@@ -1261,16 +1118,25 @@ function update_706_to_800($type='')
$message = str_replace('--COUNT--',$nt_changed,LAN_UPDATE_20);
$log->logMessage($message, $status);
}
-
-
-
-
+
+
+
+ if (isset($pref['forum_user_customtitle']) && !isset($pref['signup_option_customtitle']))
+ {
+ if ($just_check) return update_needed('pref: forum_user_customtitle needs to be renamed');
+ // $pref['signup_option_customtitle'] = $pref['forum_user_customtitle'];
+ e107::getConfig()->add('signup_option_customtitle', $pref['forum_user_customtitle']);
+ e107::getConfig()->remove('forum_user_customtitle');
+
+ $log->logMessage(LAN_UPDATE_20.'customtitle', E_MESSAGE_SUCCESS);
+ $do_save = TRUE;
+ }
// --------------- Saved emails - copy across
- if (!$just_check && $sql->db_Select('generic', '*', "gen_type='massmail'"))
+ if (!$just_check && $sql->select('generic', '*', "gen_type='massmail'"))
{
if ($just_check) return update_needed('Copy across saved emails');
require_once(e_HANDLER.'mail_manager_class.php');
@@ -1304,10 +1170,13 @@ function update_706_to_800($type='')
{
if ($just_check) return update_needed('Legacy shortcode conversion');
// Reset, legacy and new shortcode list will be generated in plugin update routine
- $pref['shortcode_legacy_list'] = array();
- $pref['shortcode_list'] = array();
- save_prefs();
-
+ // $pref['shortcode_legacy_list'] = array();
+ // $pref['shortcode_list'] = array();
+
+ e107::getConfig()->add('shortcode_legacy_list', array());
+ e107::getConfig()->set('shortcode_list', array());
+ e107::getConfig()->save(false,true,false);
+
$ep = e107::getPlugin();
$ep->update_plugins_table($mode); // scan for e_xxx changes and save to plugin table.
$ep->save_addon_prefs($mode); // generate global e_xxx_list prefs from plugin table.
@@ -1540,10 +1409,10 @@ function update_706_to_800($type='')
// $publicFilter = array(1);
$public_files = $fl->get_files(e_FILE.'public','',$publicFilter);
- if((count($dl_files) || count($public_files)) && !$sql->gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_file' "))
+ if((count($dl_files) || count($public_files)) && !$sql->gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_file' OR `media_category` = '_common_file' "))
{
if ($just_check) return update_needed('Import '.count($dl_files).' Download File(s) and '.count($public_files).' Public File(s) into Media Manager');
-
+
if($sql->gen("SELECT download_url FROM `#download` "))
{
$allowed_types = array();
@@ -1567,9 +1436,23 @@ function update_706_to_800($type='')
$allowed_types = array('zip','gz','pdf');
}
- $fmask = '[a-zA-z0-9_-]+\.('.implode('|',$allowed_types).')$';
+ $fmask = '[a-zA-Z0-9_.-]+\.('.implode('|',$allowed_types).')$';
+
$med->import('download_file',e_DOWNLOAD, $fmask);
- $med->import('_common_file',e_FILE.'public', $fmask);
+
+ // add found Public file-types.
+ foreach($public_files as $v)
+ {
+ $ext = strrchr($v['fname'], ".");
+ $suffix = ltrim($ext,".");
+ if(!isset($allowed_types[$suffix]))
+ {
+ $allowed_types[$suffix] = $suffix;
+ }
+ }
+
+ $publicFmask = '[a-zA-Z0-9_.-]+\.('.implode('|',$allowed_types).')$';
+ $med->import('_common_file', e_FILE.'public', $publicFmask);
}
@@ -1664,12 +1547,9 @@ function update_706_to_800($type='')
if ($do_save)
{
// save_prefs();
- e107::getConfig()->setPref($pref)->save(false,true,true);
-
- $log->logMessage(LAN_UPDATE_50);
+ e107::getConfig()->setPref($pref)->save(false,true,false);
+ // $log->logMessage(LAN_UPDATE_50);
// $log->logMessage(implode(', ', $accum), E_MESSAGE_NODISPLAY);
-
-
//$updateMessages[] = LAN_UPDATE_50.implode(', ',$accum); // Note for admin log
}
@@ -1684,7 +1564,7 @@ function update_706_to_800($type='')
-
+
@@ -1873,16 +1753,12 @@ function copy_user_timezone()
function update_needed($message='')
{
- global $ns, $update_debug;
- $emessage = e107::getMessage();
-
-// if ($update_debug) $emessage->add("Update: ".$message, E_MESSAGE_DEBUG);
if(E107_DEBUG_LEVEL)
{
$tmp = debug_backtrace();
//$ns->tablerender("", "