/** * Upgrades value added plugins * * @param string $plugin plugin name * @return boolean true: success; false: an error occured * */ function INST_pluginAutoUpgrade($plugin, $forceInstall = 0) { global $_CONF, $_TABLES, $_DB_table_prefix; $rc = false; $active = DB_getItem($_TABLES['plugins'], 'pi_enabled', 'pi_name="' . $plugin . '"'); if ($active || $forceInstall == 1) { if ($active && file_exists($_CONF['path'] . '/plugins/' . $plugin . '/upgrade.php')) { require_once $_CONF['path'] . '/plugins/' . $plugin . '/upgrade.php'; if (function_exists($plugin . '_upgrade')) { $plgUpgradeFunction = $plugin . '_upgrade'; $rc = $plgUpgradeFunction(); } } else { if (!$active && $forceInstall == 1) { // don't force install if already installed but marked inactive... $pcount = DB_count($_TABLES['plugins'], 'pi_name', $plugin); if ($pcount < 1) { $rc = INST_pluginAutoInstall($plugin); } else { $rc = true; } } else { $rc = true; } } } else { $rc = true; // not active, so just skip without error } return $rc; }
/** * Installs optional plugins and content * * @note redirects to success page. * */ function INST_doPluginInstall() { global $_GLFUSION, $_CONF, $_TABLES, $_DB_table_prefix; $site_url = $_CONF['site_url']; $language = $_GLFUSION['language']; $pluginsToInstall = $_POST['plugin']; if (is_array($pluginsToInstall)) { foreach ($pluginsToInstall as $plugin => $settings) { $rc = INST_pluginAutoInstall($plugin); if ($rc === false) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error Code: ' . __LINE__); } } } if (isset($_POST['installdefaultdata'])) { if (!file_exists($_CONF['path'] . 'sql/default_content.php')) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error Code: ' . __LINE__); } require_once $_CONF['path'] . 'sql/default_content.php'; // pull a list of all plugins that are installed.... $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1"); $installedPlugins = array(); while ($A = DB_fetchArray($result)) { $installedPlugins[] = $A['pi_name']; } // install the core default data first if (is_array($_CORE_DEFAULT_DATA)) { foreach ($_CORE_DEFAULT_DATA as $sql) { DB_query($sql, 1); } } // install the static pages default data if (is_array($_SP_DEFAULT_DATA)) { foreach ($_SP_DEFAULT_DATA as $sql) { $fsql = str_replace("xxxSITEURLxxx", $site_url, $sql); DB_query($fsql, 1); } } // update the site tailor menu to reflect the static pages content if (is_array($_MB_DEFAULT_DATA)) { foreach ($_MB_DEFAULT_DATA as $sql) { DB_query($sql, 1); } } // cycle through the rest of the installed plugins and add their data if (is_array($installedPlugins)) { foreach ($installedPlugins as $plugin) { if (isset($_DATA[$plugin]) && is_array($_DATA[$plugin])) { foreach ($_DATA[$plugin] as $sql) { DB_query($sql, 1); } } } } } INST_clearCache(); header('Location: success.php?type=install&language=' . $language); exit; }