function get_server_extensions($version = PHPWG_VERSION) { global $user; $get_data = array('format' => 'php'); // Retrieve PEM versions $versions_to_check = array(); $url = PEM_URL . '/api/get_version_list.php'; if (fetchRemote($url, $result, $get_data) and $pem_versions = @unserialize($result)) { if (!preg_match('/^\\d+\\.\\d+\\.\\d+$/', $version)) { $version = $pem_versions[0]['name']; } $branch = get_branch_from_version($version); foreach ($pem_versions as $pem_version) { if (strpos($pem_version['name'], $branch) === 0) { $versions_to_check[] = $pem_version['id']; } } } if (empty($versions_to_check)) { return false; } // Extensions to check $ext_to_check = array(); foreach ($this->types as $type) { $fs = 'fs_' . $type; foreach ($this->{$type}->{$fs} as $ext) { if (isset($ext['extension'])) { $ext_to_check[$ext['extension']] = $type; } } } // Retrieve PEM plugins infos $url = PEM_URL . '/api/get_revision_list.php'; $get_data = array_merge($get_data, array('last_revision_only' => 'true', 'version' => implode(',', $versions_to_check), 'lang' => substr($user['language'], 0, 2), 'get_nb_downloads' => 'true')); $post_data = array(); if (!empty($ext_to_check)) { $post_data['extension_include'] = implode(',', array_keys($ext_to_check)); } if (fetchRemote($url, $result, $get_data, $post_data)) { $pem_exts = @unserialize($result); if (!is_array($pem_exts)) { return false; } foreach ($pem_exts as $ext) { if (isset($ext_to_check[$ext['extension_id']])) { $server = 'server_' . $ext_to_check[$ext['extension_id']]; $this->{$ext_to_check}[$ext['extension_id']]->{$server} += array($ext['extension_id'] => $ext); unset($ext_to_check[$ext['extension_id']]); } } $this->check_missing_extensions($ext_to_check); return true; } return false; }
@fputs($fh, $file_content, strlen($file_content)); @fclose($fh); $template->assign(array('config_creation_failed' => true, 'config_url' => 'install.php?dl=' . $tmp_filename, 'config_file_content' => $file_content)); } @fputs($fp, $file_content, strlen($file_content)); @fclose($fp); // tables creation, based on piwigo_structure.sql execute_sqlfile(PHPWG_ROOT_PATH . 'install/piwigo_structure-mysql.sql', DEFAULT_PREFIX_TABLE, $prefixeTable, 'mysql'); // 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();
include PHPWG_ROOT_PATH . 'include/functions.inc.php'; include PHPWG_ROOT_PATH . 'include/template.class.php'; include PHPWG_ROOT_PATH . 'include/cache.class.php'; include PHPWG_ROOT_PATH . 'include/Logger.class.php'; $persistent_cache = new PersistentFileCache(); // Database connection try { pwg_db_connect($conf['db_host'], $conf['db_user'], $conf['db_password'], $conf['db_base']); } catch (Exception $e) { my_error(l10n($e->getMessage()), true); } pwg_db_check_charset(); load_conf_from_db(); $logger = new Logger(array('directory' => PHPWG_ROOT_PATH . $conf['data_location'] . $conf['log_dir'], 'severity' => $conf['log_level'], 'filename' => 'log_' . date('Y-m-d') . '_' . sha1(date('Y-m-d') . $conf['db_password']) . '.txt', 'globPattern' => 'log_*.txt', 'archiveDays' => $conf['log_archive_days'])); if (!$conf['check_upgrade_feed']) { if (!isset($conf['piwigo_db_version']) or $conf['piwigo_db_version'] != get_branch_from_version(PHPWG_VERSION)) { redirect(get_root_url() . 'upgrade.php'); } } ImageStdParams::load_from_db(); session_start(); load_plugins(); // users can have defined a custom order pattern, incompatible with GUI form if (isset($conf['order_by_custom'])) { $conf['order_by'] = $conf['order_by_custom']; } if (isset($conf['order_by_inside_category_custom'])) { $conf['order_by_inside_category'] = $conf['order_by_inside_category_custom']; } include PHPWG_ROOT_PATH . 'include/user.inc.php'; if (in_array(substr($user['language'], 0, 2), array('fr', 'it', 'de', 'es', 'pl', 'hu', 'ru', 'nl', 'tr', 'da'))) {
$page['upgrade_end'] = get_moment(); $template->assign('upgrade', array('VERSION' => $current_release, 'TOTAL_TIME' => get_elapsed_time($page['upgrade_start'], $page['upgrade_end']), 'SQL_TIME' => number_format($page['queries_time'], 3, '.', ' ') . ' s', 'NB_QUERIES' => $page['count_queries'])); $page['infos'][] = l10n('Perform a maintenance check in [Administration>Tools>Maintenance] if you encounter any problem.'); // Save $page['infos'] in order to restore after maintenance actions $page['infos_sav'] = $page['infos']; $page['infos'] = array(); $query = ' REPLACE INTO ' . PLUGINS_TABLE . ' (id, state) VALUES (\'TakeATour\', \'active\') ;'; pwg_query($query); $template->assign(array('button_label' => l10n('Home'), 'button_link' => 'index.php')); // if the webmaster has a session, let's give a link to discover new features if (!empty($_SESSION['pwg_uid'])) { $version_ = str_replace('.', '_', get_branch_from_version(PHPWG_VERSION) . '.0'); if (file_exists(PHPWG_PLUGINS_PATH . 'TakeATour/tours/' . $version_ . '/config.inc.php')) { load_language('plugin.lang', PHPWG_PLUGINS_PATH . 'TakeATour/', array('language' => $language, 'force_fallback' => 'en_UK')); // we need the secret key for get_pwg_token() load_conf_from_db(); $template->assign(array('button_label' => l10n('2_7_0_descrp'), 'button_link' => 'admin.php?submited_tour_path=tours/' . $version_ . '&pwg_token=' . get_pwg_token())); } } // Delete cache data invalidate_user_cache(true); $template->delete_compiled_templates(); // Restore $page['infos'] in order to hide informations messages from functions calles // errors messages are not hide $page['infos'] = $page['infos_sav']; } } else {
/** * Retrieve PEM server datas to $server_languages */ function get_server_languages($new = false) { global $user, $conf; $get_data = array('category_id' => $conf['pem_languages_category'], 'format' => 'php'); // Retrieve PEM versions $version = PHPWG_VERSION; $versions_to_check = array(); $url = PEM_URL . '/api/get_version_list.php'; if (fetchRemote($url, $result, $get_data) and $pem_versions = @unserialize($result)) { if (!preg_match('/^\\d+\\.\\d+\\.\\d+$/', $version)) { $version = $pem_versions[0]['name']; } $branch = get_branch_from_version($version); foreach ($pem_versions as $pem_version) { if (strpos($pem_version['name'], $branch) === 0) { $versions_to_check[] = $pem_version['id']; } } } if (empty($versions_to_check)) { return false; } // Languages to check $languages_to_check = array(); foreach ($this->fs_languages as $fs_language) { if (isset($fs_language['extension'])) { $languages_to_check[] = $fs_language['extension']; } } // Retrieve PEM languages infos $url = PEM_URL . '/api/get_revision_list.php'; $get_data = array_merge($get_data, array('last_revision_only' => 'true', 'version' => implode(',', $versions_to_check), 'lang' => $user['language'], 'get_nb_downloads' => 'true')); if (!empty($languages_to_check)) { if ($new) { $get_data['extension_exclude'] = implode(',', $languages_to_check); } else { $get_data['extension_include'] = implode(',', $languages_to_check); } } if (fetchRemote($url, $result, $get_data)) { $pem_languages = @unserialize($result); if (!is_array($pem_languages)) { return false; } foreach ($pem_languages as $language) { if (preg_match('/^.*? \\[[A-Z]{2}\\]$/', $language['extension_name'])) { $this->server_languages[$language['extension_id']] = $language; } } @uasort($this->server_languages, array($this, 'extension_name_compare')); return true; } return false; }
function get_versions_to_check($version = PHPWG_VERSION) { global $conf; $versions_to_check = array(); $url = PEM_URL . '/api/get_version_list.php?category_id=' . $conf['pem_plugins_category'] . '&format=php'; if (fetchRemote($url, $result) and $pem_versions = @unserialize($result)) { if (!preg_match('/^\\d+\\.\\d+\\.\\d+$/', $version)) { $version = $pem_versions[0]['name']; } $branch = get_branch_from_version($version); foreach ($pem_versions as $pem_version) { if (strpos($pem_version['name'], $branch) === 0) { $versions_to_check[] = $pem_version['id']; } } } return $versions_to_check; }