function plugin_activate($id, $version, &$errors) { global $conf; /* Cleaning obsolete files */ /* *********************** */ PH_Obsolete_Files(); include_once PH_PATH . 'include/upgradedb.inc.php'; /* Check database upgrade */ /* ********************** */ $conf_PH = unserialize($conf['PruneHistory']); if (isset($conf_PH[0])) { if (version_compare($conf_PH['PHVersion'], '1.1.0') < 0) { /* upgrade from 1.0 to 1.1 */ /* *********************** */ upgrade_100_110(); } } /* Update plugin version number in #_config table */ /* and check consistency of #_plugins table */ /* ********************************************** */ PH_version_update(); /* Reload plugin parameters */ /* ************************ */ load_conf_from_db('param like \'PruneHistory\''); }
function plugin_activate($id, $version, &$errors) { global $conf; /* Cleaning obsolete files */ /* *********************** */ regfluxbb_obsolete_files(); include_once REGFLUXBB_PATH . 'include/upgradedb.inc.php'; /* Database upgrade */ /* **************** */ $conf_RegFluxBB = isset($conf['Register_FluxBB']) ? explode(";", $conf['Register_FluxBB']) : array(); if (isset($conf_RegFluxBB[0]) and strpos($conf_RegFluxBB[0], "{") === false) { upgrade_240_250(); } /* Check database upgrade for version > 2.5.0 */ /* ****************************************** */ $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']); if (isset($conf_Register_FluxBB['REGFLUXBB_VERSION'])) { if (version_compare($conf_Register_FluxBB['REGFLUXBB_VERSION'], '2.5.5') < 0) { /* upgrade from 2.5.x to 2.5.5 */ /* *************************** */ upgrade_250_255(); } } /* Update plugin version number in #_config table */ /* and check consistency of #_plugins table */ /* ********************************************** */ RegFluxBB_version_update(); /* Reload plugin parameters */ /* ************************ */ load_conf_from_db('param like \'Register_FluxBB\''); }
function plugin_activate($id, $version, &$errors) { global $conf; /* Cleaning obsolete files */ /* *********************** */ CM_Obsolete_Files(); include_once CM_PATH . 'include/upgradedb.inc.php'; $conf_CM = unserialize($conf['CommentsManager']); // Database upgrade process if (isset($conf_CM[0])) { $conf_CM = unserialize($conf['CommentsManager']); // upgrade from 2.2.0 to 2.2.1 if (version_compare($conf_CM[0], '2.2.1') < 0) { upgradeCM_220_221(); } // upgrade from 2.2.1 to 2.2.2 if (version_compare($conf_CM[0], '2.2.2') < 0) { upgradeCM_221_222(); } // upgrade from 2.4 to 2.5 if (version_compare($conf_CM[0], '2.5.0') < 0) { upgradeCM_240_250(); } // Preset for future upgrades // if (isset($conf_CM['CMVersion'])) // { // } } // Update plugin version number in #_config table and check consistency of #_plugins table CM_version_update(); load_conf_from_db('param like \'CommentsManager\''); }
function activate($theme_version, &$errors = array()) { global $conf, $prefixeTable; if (empty($conf['smartpocket'])) { $conf['smartpocket'] = serialize($this->default_conf); $query = "\n INSERT INTO " . CONFIG_TABLE . " (param,value,comment)\n VALUES ('smartpocket' , '" . pwg_db_real_escape_string($conf['smartpocket']) . "' , 'loop#autohide');"; pwg_query($query); } elseif (count(unserialize($conf['smartpocket'])) != 2) { $conff = unserialize($conf['smartpocket']); $config = array('loop' => !empty($conff['loop']) ? $conff['loop'] : true, 'autohide' => !empty($conff['autohide']) ? $conff['autohide'] : 5000); conf_update_param('smartpocket', pwg_db_real_escape_string(serialize($config))); load_conf_from_db(); } $this->installed = true; }
// We fill the tables with basic informations execute_sqlfile(PHPWG_ROOT_PATH . 'install/config.sql', DEFAULT_PREFIX_TABLE, $prefixeTable, 'mysql'); $query = ' INSERT INTO ' . $prefixeTable . 'config (param,value,comment) VALUES (\'secret_key\',md5(' . pwg_db_cast_to_text(DB_RANDOM_FUNCTION . '()') . '), \'a secret key specific to the gallery for internal use\');'; pwg_query($query); conf_update_param('piwigo_db_version', get_branch_from_version(PHPWG_VERSION)); conf_update_param('gallery_title', l10n('Just another Piwigo gallery')); conf_update_param('page_banner', '<h1>%gallery_title%</h1>' . "\n\n<p>" . l10n('Welcome to my photo gallery') . '</p>'); // fill languages table foreach ($languages->fs_languages as $language_code => $fs_language) { $languages->perform_action('activate', $language_code); } // fill $conf global array load_conf_from_db(); // PWG_CHARSET is required for building the fs_themes array in the // themes class if (!defined('PWG_CHARSET')) { define('PWG_CHARSET', 'utf-8'); } activate_core_themes(); activate_core_plugins(); $insert = array('id' => 1, 'galleries_url' => PHPWG_ROOT_PATH . 'galleries/'); mass_inserts(SITES_TABLE, array_keys($insert), array($insert)); // webmaster admin user $inserts = array(array('id' => 1, 'username' => $admin_name, 'password' => md5($admin_pass1), 'mail_address' => $admin_mail), array('id' => 2, 'username' => 'guest')); mass_inserts(USERS_TABLE, array_keys($inserts[0]), $inserts); create_user_infos(array(1, 2), array('language' => $language)); // Available upgrades must be ignored after a fresh installation. To // make PWG avoid upgrading, we must tell it upgrades have already been
/** * Perform requested actions * @param string - action * @param string - plugin id * @param array - errors */ function perform_action($action, $plugin_id, $options = array()) { if (isset($this->db_plugins_by_id[$plugin_id])) { $crt_db_plugin = $this->db_plugins_by_id[$plugin_id]; } if ($action !== 'update') { // wait for files to be updated $plugin_maintain = self::build_maintain_class($plugin_id); } $errors = array(); switch ($action) { case 'install': if (!empty($crt_db_plugin) or !isset($this->fs_plugins[$plugin_id])) { break; } $plugin_maintain->install($this->fs_plugins[$plugin_id]['version'], $errors); if (empty($errors)) { $query = ' INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES (\'' . $plugin_id . '\', \'' . $this->fs_plugins[$plugin_id]['version'] . '\') ;'; pwg_query($query); } break; case 'update': $previous_version = $this->fs_plugins[$plugin_id]['version']; $errors[0] = $this->extract_plugin_files('upgrade', $options['revision'], $plugin_id); if ($errors[0] === 'ok') { $this->get_fs_plugin($plugin_id); // refresh plugins list $new_version = $this->fs_plugins[$plugin_id]['version']; $plugin_maintain = self::build_maintain_class($plugin_id); $plugin_maintain->update($previous_version, $new_version, $errors); if ($new_version != 'auto') { $query = ' UPDATE ' . PLUGINS_TABLE . ' SET version=\'' . $new_version . '\' WHERE id=\'' . $plugin_id . '\' ;'; pwg_query($query); } } break; case 'activate': if (!isset($crt_db_plugin)) { $errors = $this->perform_action('install', $plugin_id); list($crt_db_plugin) = get_db_plugins(null, $plugin_id); load_conf_from_db(); } elseif ($crt_db_plugin['state'] == 'active') { break; } if (empty($errors)) { $plugin_maintain->activate($crt_db_plugin['version'], $errors); } if (empty($errors)) { $query = ' UPDATE ' . PLUGINS_TABLE . ' SET state=\'active\' WHERE id=\'' . $plugin_id . '\' ;'; pwg_query($query); } break; case 'deactivate': if (!isset($crt_db_plugin) or $crt_db_plugin['state'] != 'active') { break; } $query = ' UPDATE ' . PLUGINS_TABLE . ' SET state=\'inactive\' WHERE id=\'' . $plugin_id . '\' ;'; pwg_query($query); $plugin_maintain->deactivate(); break; case 'uninstall': if (!isset($crt_db_plugin)) { break; } if ($crt_db_plugin['state'] == 'active') { $this->perform_action('deactivate', $plugin_id); } $query = ' DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\' ;'; pwg_query($query); $plugin_maintain->uninstall(); break; case 'restore': $this->perform_action('uninstall', $plugin_id); unset($this->db_plugins_by_id[$plugin_id]); $errors = $this->perform_action('activate', $plugin_id); break; case 'delete': if (!empty($crt_db_plugin)) { $this->perform_action('uninstall', $plugin_id); } if (!isset($this->fs_plugins[$plugin_id])) { break; } deltree(PHPWG_PLUGINS_PATH . $plugin_id, PHPWG_PLUGINS_PATH . 'trash'); break; } return $errors; }
if (isset($_POST[$nbm_user['param']])) { $value = $_POST[$nbm_user['param']]; $query = ' update ' . CONFIG_TABLE . ' set value = \'' . str_replace("\\'", "''", $value) . '\' where param = \'' . $nbm_user['param'] . '\';'; pwg_query($query); $updated_param_count += 1; } } $page['infos'][] = l10n_dec('%d parameter was updated.', '%d parameters were updated.', $updated_param_count); // Reload conf with new values load_conf_from_db('param like \'nbm\\_%\''); } case 'subscribe': if (isset($_POST['falsify']) and isset($_POST['cat_true'])) { $check_key_treated = unsubscribe_notification_by_mail(true, $_POST['cat_true']); do_timeout_treatment('cat_true', $check_key_treated); } else { if (isset($_POST['trueify']) and isset($_POST['cat_false'])) { $check_key_treated = subscribe_notification_by_mail(true, $_POST['cat_false']); do_timeout_treatment('cat_false', $check_key_treated); } } break; case 'send': if (isset($_POST['send_submit']) and isset($_POST['send_selection']) and isset($_POST['send_customize_mail_content'])) { $check_key_treated = do_action_send_mail_notification('send', $_POST['send_selection'], stripslashes($_POST['send_customize_mail_content']));
function plugin_activate($id, $version, &$errors) { global $conf; /* Cleaning obsolete files */ /* *********************** */ clean_obsolete_files(); include_once UAM_PATH . 'include/upgradedb.inc.php'; /* Check if old version is < 2.15 */ /* ****************************** */ $query = ' SELECT param FROM ' . CONFIG_TABLE . ' WHERE param = "nbc_UserAdvManager" ;'; $count1 = pwg_db_num_rows(pwg_query($query)); $query = ' SELECT * FROM ' . CONFIG_TABLE . ' WHERE param = "nbc_UserAdvManager_ConfirmMail" ;'; $count2 = pwg_db_num_rows(pwg_query($query)); /* If old params exist an upgrade is needed */ /* **************************************** */ if ($count1 == 1) { /* Check for upgrade from 2.10 to 2.11 */ /* *********************************** */ if ($count1 == 1 and $count2 == 0) { /* upgrade from branch 2.10 to 2.11 */ /* ******************************** */ upgrade_210_211(); } /* Check for upgrade from 2.11 to 2.12 */ /* *********************************** */ if (!table_exist(USER_LASTVISIT_TABLE)) { /* upgrade from branch 2.11 to 2.12 */ /* ******************************** */ upgrade_211_212(); } /* Check for upgrade from 2.12 to 2.13 */ /* *********************************** */ $fields = pwg_query('SHOW COLUMNS FROM ' . USER_CONFIRM_MAIL_TABLE . ';'); $nb_fields = pwg_db_num_rows($fields); if ($nb_fields < 6) { /* upgrade from branch 2.12 to 2.13 */ /* ******************************** */ upgrade_212_213(); } /* Serializing conf parameters - Available since 2.14.0 */ /* **************************************************** */ if (unserialize($conf['nbc_UserAdvManager']) === false) { /* upgrade from branch 2.13 to 2.14 */ /* ******************************** */ upgrade_213_214(); } /* upgrade from branch 2.14 to 2.15 */ /* ******************************** */ upgrade_214_215(); } /* Old version is > 2.15 */ /* ********************* */ $query = ' SELECT param FROM ' . CONFIG_TABLE . ' WHERE param = "UserAdvManager_Redir" ;'; $count = pwg_db_num_rows(pwg_query($query)); if ($count == 0) { upgrade_2153_2154(); } /* Check for upgrade from 2.15 to 2.16 */ /* *********************************** */ $query = ' SELECT param FROM ' . CONFIG_TABLE . ' WHERE param = "UserAdvManager_Version" ;'; $count = pwg_db_num_rows(pwg_query($query)); if ($count == 0) { /* upgrade from branch 2.15 to 2.16 */ /* ******************************** */ upgrade_215_2160(); } /* Check database upgrade since version 2.16.0 */ /* ******************************************* */ if (isset($conf['UserAdvManager_Version'])) { if (version_compare($conf['UserAdvManager_Version'], '2.20.0') < 0) { /* upgrade from branch 2.16 to 2.20 */ /* ******************************** */ upgrade_216_220(); } if (version_compare($conf['UserAdvManager_Version'], '2.20.4') < 0) { /* upgrade from version 2.20.3 to 2.20.4 */ /* ************************************* */ upgrade_2203_2204(); } if (version_compare($conf['UserAdvManager_Version'], '2.20.7') < 0) { /* upgrade from version 2.20.4 to 2.20.7 */ /* ************************************* */ upgrade_2204_2207(); } if (version_compare($conf['UserAdvManager_Version'], '2.20.8') < 0) { /* upgrade from version 2.20.7 to 2.20.8 */ /* ************************************* */ upgrade_2207_2208(); } if (version_compare($conf['UserAdvManager_Version'], '2.30.0') < 0) { /* upgrade from version 2.20.8 to 2.30.0 */ /* ************************************* */ upgrade_2208_2300(); } if (version_compare($conf['UserAdvManager_Version'], '2.30.2') < 0) { /* upgrade from version 2.30.x to 2.30.2 */ /* ************************************* */ upgrade_2300_2302(); } if (version_compare($conf['UserAdvManager_Version'], '2.40.0') < 0) { /* upgrade from version 2.30.x to 2.40.0 */ /* ************************************* */ upgrade_2300_2400(); } if (version_compare($conf['UserAdvManager_Version'], '2.41.0') < 0) { /* upgrade from version 2.40.x to 2.41.0 */ /* ************************************* */ upgrade_2400_2410(); } if (version_compare($conf['UserAdvManager_Version'], '2.50.0') < 0) { /* upgrade from version 2.41.x to 2.50.0 */ /* ************************************* */ upgrade_2410_2500(); } if (version_compare($conf['UserAdvManager_Version'], '2.50.11') < 0) { /* upgrade from version 2.50.x to 2.50.11 */ /* ************************************** */ upgrade_2500_25011(); } if (version_compare($conf['UserAdvManager_Version'], '2.51.0') < 0) { /* upgrade from version 2.50.x to 2.51.0 */ /* ************************************* */ upgrade_2500_2510(); } if (version_compare($conf['UserAdvManager_Version'], '2.70.3') < 0) { /* upgrade from version 2.51.0 to 2.70.3 */ /* ************************************* */ upgrade_2510_2703(); } } // Update plugin version number in #_config table and check consistency of #_plugins table // --------------------------------------------------------------------------------------- UAM_version_update(); load_conf_from_db('param like \'UserAdvManager\\_%\''); }