/** * * Checks details of configuration change */ function checkSignature($mandatory) { global $_configMutex, $_zp_DB_connection, $_reconfigureMutex; $old = NULL; if (function_exists('query_full_array') && $_zp_DB_connection) { $old = @unserialize(getOption('zenphoto_install')); $new = installSignature(); } if (!is_array($old)) { $new = array(); switch ($mandatory) { case 11: $reason = gettext('The configuration file is missing.'); break; case 12: $reason = gettext('The <code>db_software</code> specification is not valid.'); break; case 13: $reason = gettext('The database connection failed.'); break; default: $reason = ''; break; } $old = array('CONFIGURATION' => $reason); if (!$mandatory) { $mandatory = 6; } } $diff = array(); $keys = array_unique(array_merge(array_keys($new), array_keys($old))); foreach ($keys as $key) { if (!array_key_exists($key, $new) || !array_key_exists($key, $old) || $old[$key] != $new[$key]) { $diff[$key] = array('old' => @$old[$key], 'new' => @$new[$key]); } } $package = file_get_contents(dirname(__FILE__) . '/zenphoto.package'); preg_match_all('|' . ZENFOLDER . '/setup/(.*)|', $package, $matches); $needs = array(); $restore = $found = false; foreach ($matches[1] as $need) { $needs[] = rtrim(trim($need), ":*"); } // serialize the following $_configMutex->lock(); if (file_exists(dirname(__FILE__) . '/setup/')) { chdir(dirname(__FILE__) . '/setup/'); //just in case files were uploaded over a protected setup folder $have = safe_glob('*.php'); foreach ($have as $key => $f) { $f = str_replace('.php', '.xxx', $f); if (file_exists($f)) { @chmod($f, 0777); @unlink($f); } } $restore = safe_glob('*.xxx'); if (!empty($restore) && $mandatory > 1 && defined('ADMIN_RIGHTS') && zp_loggedin(ADMIN_RIGHTS)) { restoreSetupScrpts($mandatory); } $found = safe_glob('*.*'); $needs = array_diff($needs, $found); } $_configMutex->unlock(); return array($diff, $needs, $restore, $found); }
foreach ($optionlist as $option) { query('DELETE FROM ' . prefix('options') . ' WHERE `id`=' . $option['id']); setOption($option['name'], $active[$option['name']]); } } $lib_auth_extratext = ""; $salt = 'abcdefghijklmnopqursuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#$%^&*()_+-={}[]|;,.<>?/'; $list = range(0, strlen($salt) - 1); shuffle($list); for ($i = 0; $i < 30; $i++) { $lib_auth_extratext = $lib_auth_extratext . $salt[$list[$i]]; } purgeOption('zenphoto_release'); purgeOption('zenphoto_version'); purgeOption('zenphoto_install'); setOption('zenphoto_install', serialize(installSignature())); if (Zenphoto_Authority::$preferred_version > ($oldv = getOption('libauth_version'))) { if (empty($oldv)) { // The password hash of these old versions did not have the extra text. // Note: if the administrators table is empty we will re-do this option with the good stuff. purgeOption('extra_auth_hash_text'); setOptionDefault('extra_auth_hash_text', ''); } $msg = sprintf(gettext('Migrating lib-auth data version %1$s => version %2$s'), $oldv, Zenphoto_Authority::$preferred_version); if (!$_zp_authority->migrateAuth(Zenphoto_Authority::$preferred_version)) { $msg .= ': ' . gettext('failed'); } echo $msg; setupLog($msg, true); } $admins = $_zp_authority->getAdministrators('all');
/** * * Check to see if the setup script needs to be run */ function checkInstall() { preg_match('|([^-]*)|', ZENPHOTO_VERSION, $version); if ($i = getOption('zenphoto_install')) { $install = getSerializedArray($i); } else { $install = array('ZENPHOTO' => '0.0.0[0000]'); } preg_match('|([^-]*).*\\[(.*)\\]|', $install['ZENPHOTO'], $matches); if (isset($matches[1]) && isset($matches[2]) && $matches[1] != $version[1] || $matches[2] != ZENPHOTO_RELEASE || (time() & 7) == 0 && OFFSET_PATH != 2 && $i != serialize(installSignature())) { require_once dirname(__FILE__) . '/reconfigure.php'; reconfigureAction(0); } }
<?php // force UTF-8 Ø /** * stores all the default values for options * @package setup */ require CONFIGFILE; require_once dirname(dirname(__FILE__)) . '/' . PLUGIN_FOLDER . '/security-logger.php'; zp_apply_filter('log_setup', true, 'install', ''); setOption('zenphoto_release', ZENPHOTO_RELEASE); setOption('zenphoto_install', installSignature()); //clear out old admin user and cleartext password unset($_zp_conf_vars['adminuser']); unset($_zp_conf_vars['adminpass']); $admin = getOption('adminuser'); if (!empty($admin)) { // transfer the old credentials and then remove them $sql = 'DELETE FROM ' . prefix('options') . ' WHERE `name`="adminuser"'; query($sql); $sql = 'DELETE FROM ' . prefix('options') . ' WHERE `name`="adminpass"'; query($sql); $sql = 'DELETE FROM ' . prefix('options') . ' WHERE `name`="admin_name"'; query($sql); $sql = 'DELETE FROM ' . prefix('options') . ' WHERE `name`="admin_email"'; query($sql); } if ($_zp_authority->preferred_version > ($oldv = getOption('libauth_version'))) { if (empty($oldv)) { // The password hash of these old versions did not have the extra text. // Note: if the administrators table is empty we will re-do this option with the good stuff.
/** * * Checks details of configuration change */ function checkSignature($auto) { global $_configMutex; global $_zp_DB_connection, $_reconfigureMutex; if (function_exists('query_full_array') && $_zp_DB_connection) { $old = @unserialize(getOption('zenphoto_install')); $new = installSignature(); } else { $old = NULL; $new = array(); } if (!is_array($old)) { $old = array('ZENPHOTO' => gettext('an unknown release')); } $diff = array(); $keys = array_unique(array_merge(array_keys($new), array_keys($old))); foreach ($keys as $key) { if (!array_key_exists($key, $new) || !array_key_exists($key, $old) || $old[$key] != $new[$key]) { $diff[$key] = array('old' => @$old[$key], 'new' => @$new[$key]); } } $package = file_get_contents(dirname(__FILE__) . '/Zenphoto.package'); preg_match_all('|' . ZENFOLDER . '/setup/(.*)|', $package, $matches); $needs = array(); foreach ($matches[1] as $need) { $needs[] = rtrim(trim($need), ":*"); } // serialize the following $_configMutex->lock(); if (file_exists(dirname(__FILE__) . '/setup/')) { chdir(dirname(__FILE__) . '/setup/'); $found = safe_glob('*.xxx'); if (!empty($found) && $auto && zp_loggedin(ADMIN_RIGHTS)) { foreach ($found as $script) { chmod($script, 0777); if (@rename($script, stripSuffix($script))) { chmod(stripSuffix($script), FILE_MOD); } else { chmod($script, FILE_MOD); } } } $found = safe_glob('*.*'); $needs = array_diff($needs, $found); } $_configMutex->unlock(); return array($diff, $needs); }
/** * * Check to see if the setup script needs to be run */ function checkInstall() { if (OFFSET_PATH != 2) { preg_match('|([^-]*)|', ZENPHOTO_VERSION, $version); if ($i = getOption('zenphoto_install')) { $install = getSerializedArray($i); if (isset($install['ZENPHOTO'])) { preg_match('|([^-]*).*\\[(.*)\\]|', $install['ZENPHOTO'], $matches); if (isset($matches[1]) && isset($matches[2]) && $matches[1] != $version[1] || $matches[2] != ZENPHOTO_RELEASE) { _setup(14); } } } if ($i != serialize(installSignature())) { _setup((int) ($i === NULL)); } } }
/** * * Check to see if the setup script needs to be run */ function checkInstall() { if (getOption('zenphoto_release') != ZENPHOTO_RELEASE || defined('RELEASE') && getOption('zenphoto_install') != installSignature()) { if (file_exists(dirname(__FILE__) . '/setup.php')) { header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/setup.php"); exit; } else { die('setup scripts missing'); } } }