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("", "
Update required in ".basename(__FILE__)." on line ".$tmp[0]['line']."
"); - $emessage->add("Update required in ".basename(__FILE__)." on line ".$tmp[0]['line']." (".$message.")", E_MESSAGE_DEBUG); + e107::getMessage()->add("Update required in ".basename(__FILE__)." on line ".$tmp[0]['line']." (".$message.")", E_MESSAGE_DEBUG); } return FALSE; } diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index ed4ba2c98..d0ffda725 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -1485,7 +1485,7 @@ Inverse 10 10 if(varset($plug_vars['adminLinks']['link'])) { - if($row['plugin_category'] == 'menu' || !vartrue($plug_vars['adminLinks']['link'][0]['@attributes']['url'])) + if(!empty($row['plugin_category']) && $row['plugin_category'] == 'menu' || !vartrue($plug_vars['adminLinks']['link'][0]['@attributes']['url'])) { continue; } @@ -1511,7 +1511,7 @@ Inverse 10 10 $tmp[$id]['perm'] = 'P'.$row['plugin_id']; $tmp[$id]['sub_class'] = ''; $tmp[$id]['sort'] = 2; - $tmp[$id]['category'] = $row['plugin_category']; + $tmp[$id]['category'] = varset($row['plugin_category']); if($pref['admin_slidedown_subs'] && vartrue($plug_vars['adminLinks']['link']) ) { @@ -1570,9 +1570,13 @@ Inverse 10 10 foreach($tmp as $pg) { - $id = $convert[$pg['category']][1]; - $menu_vars[$id]['sub'][] = $pg; + if(!empty($pg['category'])) + { + $id = $convert[$pg['category']][1]; + $menu_vars[$id]['sub'][] = $pg; + } } + unset($menu_vars['plugMenu']); diff --git a/e107_handlers/admin_log_class.php b/e107_handlers/admin_log_class.php index e5d3d4c4e..3f687c278 100644 --- a/e107_handlers/admin_log_class.php +++ b/e107_handlers/admin_log_class.php @@ -636,7 +636,7 @@ class e_admin_log */ public function addDebug($text, $message = true, $session = false) { - return $this->logMessage($text, ($message ? E_MESSAGE_DEBUG : LOG_MESSAGE_NODISPLAY), E_MESSAGE_NOTICE, $session); + return $this->logMessage($text, ($message ? E_MESSAGE_DEBUG : LOG_MESSAGE_NODISPLAY), E_MESSAGE_DEBUG, $session); } @@ -658,7 +658,7 @@ class e_admin_log * Add an array to the log queue * @param $array * @param $oldArray (optional) - when included, only the changes between the arrays is saved. - * @param $type (optional) default: LOG_MESSAGE_NODISPLAY. or E_MESSAGE_WARNING, E_MESSAGE_NOTICE, E_MESSAGE_SUCCESS + * @param $type (optional) default: LOG_MESSAGE_NODISPLAY. or E_MESSAGE_WARNING, E_MESSAGE_DEBUG, E_MESSAGE_SUCCESS */ public function addArray($array, $oldArray= null, $type = LOG_MESSAGE_NODISPLAY , $session = false) { diff --git a/e107_handlers/date_handler.php b/e107_handlers/date_handler.php index 206751cd4..6c6d3130c 100644 --- a/e107_handlers/date_handler.php +++ b/e107_handlers/date_handler.php @@ -885,5 +885,18 @@ class convert } + /** + * Check if TimeZone is valid + * @param $timezone + * @return bool + */ + function isValidTimezone($timezone) + { + return in_array($timezone, timezone_identifiers_list()); + } + + + + } ?> \ No newline at end of file diff --git a/e107_handlers/db_verify_class.php b/e107_handlers/db_verify_class.php index 1487f6ec2..ce765aae5 100644 --- a/e107_handlers/db_verify_class.php +++ b/e107_handlers/db_verify_class.php @@ -873,9 +873,7 @@ class db_verify function getSqlData($tbl,$language='') { - $mes = e107::getMessage(); - $prefix = MPREFIX; if($language) @@ -890,6 +888,13 @@ class db_verify } $sql = e107::getDb(); + + if(!$sql->isTable($tbl)) + { + $mes->addDebug('Missing table on db-verify: '.$tbl); + return false; + } + $sql->gen('SET SQL_QUOTE_SHOW_CREATE = 1'); // mysql_query('SET SQL_QUOTE_SHOW_CREATE = 1'); $qry = 'SHOW CREATE TABLE `' . $prefix . $tbl . "`"; diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php index 326a4b3a7..75e03393c 100644 --- a/e107_handlers/media_class.php +++ b/e107_handlers/media_class.php @@ -50,7 +50,7 @@ class e_media * @param string $fmask [optional] filetypes eg. .jpg|.gif IMAGES is the default mask. * @return e_media */ - public function import($cat='',$epath,$fmask='',$options=array()) + public function import($cat='', $epath, $fmask='', $options=array()) { if(!vartrue($cat)){ return $this;} @@ -61,6 +61,7 @@ class e_media if(!is_readable($epath)) { + e107::getMessage()->addDebug("Unable to import: ".$epath); return $this; } @@ -70,11 +71,13 @@ class e_media $mes = e107::getMessage(); $fl->setFileInfo('all'); - if(!$fmask) + + if(empty($fmask)) { $fmask = '[a-zA-z0-9_-]+\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF)$'; } - $img_array = $fl->get_files($epath,$fmask,'',2); + + $img_array = $fl->get_files($epath, $fmask,'',2); if(!count($img_array)) { diff --git a/e107_handlers/menu_class.php b/e107_handlers/menu_class.php index e7c2c0861..429294e7f 100644 --- a/e107_handlers/menu_class.php +++ b/e107_handlers/menu_class.php @@ -64,7 +64,7 @@ class e_menu } // print_a($eMenuArea); - if(varset($_SERVER['E_DEV_MENU']) == 'true') // New in v2.x + if(varset($_SERVER['E_DEV_MENU']) == 'true') // New in v2.x Experimental { $layouts = e107::getPref('menu_layouts'); if(!is_array($layouts)) @@ -76,7 +76,7 @@ class e_menu $eMenuArea = $this->getData(THEME_LAYOUT); //print_a($eMenuArea); } - else // the old v1.x way. + else // standard DB 'table' method. { $eMenuArea = $this->getDataLegacy(); } @@ -188,7 +188,7 @@ class e_menu /** * @DEPRECATED - * Legacy Function to retrieve Menu data from tables. - ie. the old v1.x method. + * Legacy Function to retrieve Menu data from tables. */ private function getDataLegacy() { diff --git a/e107_handlers/message_handler.php b/e107_handlers/message_handler.php index 0d2730066..2c6bbe726 100644 --- a/e107_handlers/message_handler.php +++ b/e107_handlers/message_handler.php @@ -174,7 +174,7 @@ class eMessage * @param string $mstack message stack which should have only unique message values * @return eMessage */ - public function setUnique($mstack) + public function setUnique($mstack='default') { if(!in_array($mstack, $this->_unique)) { diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index c9f346f92..cc6c3e948 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -1904,6 +1904,30 @@ class e_db_mysql } + /** + * Check if a database table is empty or not. + * @param $table + * @return bool + */ + function isEmpty($table) + { + if(empty($table)) + { + return false; + } + + $result = $this->gen("SELECT NULL FROM `#".$table."` LIMIT 1"); + + if($result === 0) + { + return true; + } + + return false; + } + + + /** * Populate mySQLtableList and mySQLtableListLanguage diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index ddc7e462f..d10d7fa4f 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -2371,7 +2371,7 @@ class e107plugin if ($mode != "core") // Do only one core pref save during install/uninstall etc. { - $config->save(); + $config->save(true, false, false); } return; } @@ -2839,7 +2839,7 @@ class e107plugin } } - $core->save(FALSE); + $core->save(FALSE, false, false); if ($this->manage_icons()) { diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php index 206899993..3fe2f4d29 100644 --- a/e107_handlers/sitelinks_class.php +++ b/e107_handlers/sitelinks_class.php @@ -968,8 +968,8 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } { continue; } - - if(!in_array($plugin_path, $pref['lan_global_list'])) + + if(!empty($pref['lan_global_list']) && !in_array($plugin_path, $pref['lan_global_list'])) { e107::loadLanFiles($plugin_path, 'admin'); } diff --git a/e107_handlers/user_extended_class.php b/e107_handlers/user_extended_class.php index 9510f602f..044d0526e 100644 --- a/e107_handlers/user_extended_class.php +++ b/e107_handlers/user_extended_class.php @@ -116,7 +116,7 @@ class e107_user_extended if($sql->select('user_extended_struct', '*', "user_extended_struct_text != '_system_' ORDER BY user_extended_struct_order ASC")) { - while($row = $sql->db_Fetch(MYSQL_ASSOC)) + while($row = $sql->fetch(MYSQL_ASSOC)) { if ($row['user_extended_struct_type'] == 0) { // Its a category @@ -543,15 +543,15 @@ class e107_user_extended { extract($name); } - - if(!is_numeric($type)) + + if(!is_numeric($type)) { $type = $this->typeArray[$type]; } if($this->user_extended_field_exist($name)) { - return TRUE; + return true; } if (!$this->user_extended_reserved($name)) @@ -559,7 +559,11 @@ class e107_user_extended $field_info = $this->user_extended_type_text($type, $default); // wrong type - if(false === $field_info) return false; + if(false === $field_info) + { + e107::getMessage()->addDebug("\$field_info is false ".__METHOD__); + return false; + } if($order === '' && $field_info) { @@ -577,9 +581,31 @@ class e107_user_extended { $sql->gen('ALTER TABLE #user_extended ADD user_'.$tp -> toDB($name, true).' '.$field_info); } - - $sql->insert('user_extended_struct',"null,'".$tp -> toDB($name, true)."','".$tp -> toDB($text, true)."','".intval($type)."','".$tp -> toDB($parms, true)."','".$tp -> toDB($values, true)."', '".$tp -> toDB($default, true)."', '".intval($read)."', '".intval($write)."', '".intval($required)."', '0', '".intval($applicable)."', '".intval($order)."', '".intval($parent)."'"); - + + /* TODO + $extStructInsert = array( + 'user_extended_struct_id' => '_NULL_', + 'user_extended_struct_name' => '', + 'user_extended_struct_text' => '', + 'user_extended_struct_type' => '', + 'user_extended_struct_parms' => '', + 'user_extended_struct_values' => '', + 'user_extended_struct_default' => '', + 'user_extended_struct_read' => '', + 'user_extended_struct_write' => '', + 'user_extended_struct_required' => '', + 'user_extended_struct_signup' => '', + 'user_extended_struct_applicable' => '', + 'user_extended_struct_order' => '', + 'user_extended_struct_parent' => '' + + ); + + */ + + $rest = $sql->insert('user_extended_struct',"null,'".$tp -> toDB($name, true)."','".$tp -> toDB($text, true)."','".intval($type)."','".$tp -> toDB($parms, true)."','".$tp -> toDB($values, true)."', '".$tp -> toDB($default, true)."', '".intval($read)."', '".intval($write)."', '".intval($required)."', '0', '".intval($applicable)."', '".intval($order)."', '".intval($parent)."'"); + + if ($this->user_extended_field_exist($name)) { return TRUE; diff --git a/e107_handlers/userclass_class.php b/e107_handlers/userclass_class.php index f3ca6d76b..104e2aaab 100644 --- a/e107_handlers/userclass_class.php +++ b/e107_handlers/userclass_class.php @@ -146,15 +146,15 @@ class user_class } else { - $this->sql_r->db_Select('userclass_classes', '*', 'ORDER BY userclass_parent', 'nowhere'); // The order statement should give a consistent return - - while ($row = $this->sql_r->db_Fetch(MYSQL_ASSOC)) + if($this->sql_r->field('userclass_classes','userclass_parent') && $this->sql_r->select('userclass_classes', '*', 'ORDER BY userclass_parent', 'nowhere')) // The order statement should give a consistent return { - $this->class_tree[$row['userclass_id']] = $row; - $this->class_tree[$row['userclass_id']]['class_children'] = array(); // Create the child array in case needed + while ($row = $this->sql_r->fetch(MYSQL_ASSOC)) + { + $this->class_tree[$row['userclass_id']] = $row; + $this->class_tree[$row['userclass_id']]['class_children'] = array(); // Create the child array in case needed + } } - // Add in any fixed classes that aren't already defined (they historically didn't have a DB entry, although now its facilitated (and necessary for tree structure) foreach ($this->fixed_classes as $c => $d) { diff --git a/e107_plugins/forum/forum_setup.php b/e107_plugins/forum/forum_setup.php index 9b00d9b7e..eef2ece88 100644 --- a/e107_plugins/forum/forum_setup.php +++ b/e107_plugins/forum/forum_setup.php @@ -64,23 +64,39 @@ class forum_setup { e107::getDb()->gen("ALTER TABLE `#forum_thread` DROP `thread_sef` "); } - + + return false; } function upgrade_pre($var) { - //Redirect upgrade to customized upgrade routine - - e107::getRedirect()->redirect(e_PLUGIN_ABS.'forum/forum_update.php'); + + $sql = e107::getDb(); + + if(!$sql->isTable('forum_t')) // no table, so run a default plugin install procedure. + { + return false; + // e107::getSingleton('e107plugin')->refresh('forum'); + } + else + { + e107::getRedirect()->go(e_PLUGIN_ABS.'forum/forum_update.php'); //Redirect upgrade to customized upgrade routine + } //header('Location: '.e_PLUGIN.'forum/forum_update.php'); } // After Automatic Upgrade Routine has completed.. run this. ;-) function upgrade_post($var) - { - $mes = e107::getMessage(); - $mes->addSuccess("Migration is required. Please click 'Continue'.
Continue"); + { + $sql = e107::getDb(); + + if($sql->isEmpty('forum_thread') === true && $sql->isTable('forum_t') && $sql->isEmpty('forum_t') === false) + { + $mes = e107::getMessage(); + $mes->addSuccess("Migration is required. Please click 'Continue'.
Continue"); + } + } } diff --git a/e107_plugins/forum/forum_update.php b/e107_plugins/forum/forum_update.php index a33d01940..d5674f592 100644 --- a/e107_plugins/forum/forum_update.php +++ b/e107_plugins/forum/forum_update.php @@ -250,15 +250,17 @@ function step3() $fieldList = array( - 'plugin_forum_posts' => EUF_INTEGER, - 'plugin_forum_viewed' => EUF_TEXTAREA + 'plugin_forum_posts' => 'integer', + 'plugin_forum_viewed' => 'radio' ); $failed = false; + $ext = e107::getUserExt(); + foreach ($fieldList as $fieldName => $fieldType) { - $result = e107::getUserExt()->user_extended_add_system($fieldName, $fieldType); + $result = $ext->user_extended_add_system($fieldName, $fieldType); if ($result === true) { @@ -267,6 +269,7 @@ function step3() else { $mes -> addError('Creating extended user field user_' . $fieldName); + $mes->addDebug(print_a($result,true)); $failed = true; } } @@ -550,7 +553,7 @@ function renderProgress($caption, $step)
-
+
'.$caption.' @@ -1355,12 +1358,11 @@ class forumUpgrade function setNewVersion() { - $pref = e107::getPref(); $sql = e107::getDb(); $sql -> update('plugin', "plugin_version = '{$this->newVersion}' WHERE plugin_name='Forum'"); - $pref['plug_installed']['forum'] = $this -> newVersion; - save_prefs(); + e107::getConfig()->setPref('plug_installed/forum', $this->newVersion)->save(false,true,false); + return "Forum Version updated to version: {$this->newVersion}
"; } @@ -1740,14 +1742,17 @@ function forum_update_adminmenu() $var[14]['text'] = 'Reset'; $var[14]['link'] = e_SELF . "?reset"; - $var[15]['text'] = 'Reset to 6'; - $var[15]['link'] = e_SELF . "?step=6&reset=6"; + $var[15]['text'] = 'Reset to 3'; + $var[15]['link'] = e_SELF . "?step=3&reset=3"; - $var[16]['text'] = 'Reset to 7'; - $var[16]['link'] = e_SELF . "?step=7&reset=7"; + $var[16]['text'] = 'Reset to 6'; + $var[16]['link'] = e_SELF . "?step=6&reset=6"; + + $var[17]['text'] = 'Reset to 7'; + $var[17]['link'] = e_SELF . "?step=7&reset=7"; - $var[17]['text'] = 'Reset to 10'; - $var[17]['link'] = e_SELF . "?step=10&reset=10"; + $var[18]['text'] = 'Reset to 10'; + $var[18]['link'] = e_SELF . "?step=10&reset=10"; }