function check_upgrade() { _log("Checking for upgrades..."); $version_feed = VersionChecker::check(true); if (!($version_feed instanceof VersionsFeed)) { _log("Error checking for upgrades."); } else { if ($version_feed->hasNewVersions(product_version())) { _log("Found new versions."); } else { _log("No new versions."); } } }
$language = config_option('installation_base_language', 'en_us'); if (isset($_GET['language'])) { $_SESSION['language'] = $_GET['language']; $_GET['language'] = ''; } if (isset($_SESSION['language'])) { $language = $_SESSION['language']; } if (!plugin_active('i18n')) { Localization::instance()->loadSettings($language, ROOT . '/language'); } try { trace(__FILE__, 'CompanyWebsite::init()'); CompanyWebsite::init(); if (config_option('upgrade_check_enabled', false)) { VersionChecker::check(false); } // if if (config_option('file_storage_adapter', 'mysql') == FILE_STORAGE_FILE_SYSTEM) { trace(__FILE__, 'FileRepository::setBackend() - use file storage'); FileRepository::setBackend(new FileRepository_Backend_FileSystem(FILES_DIR)); } else { trace(__FILE__, 'FileRepository::setBackend() - use mysql storage'); FileRepository::setBackend(new FileRepository_Backend_MySQL(DB::connection()->getLink(), TABLE_PREFIX)); } // if PublicFiles::setRepositoryPath(ROOT . '/public/files'); if (trim(PUBLIC_FOLDER) == '') { PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'files'); } else { PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . PUBLIC_FOLDER . '/files');
function auto_upgrade() { $this->setLayout("dialog"); $version_number = array_var($_GET, 'version'); if (!$version_number) { flash_error(lang('error upgrade version must be specified')); return; } $versions_feed = VersionChecker::check(true); $versions = $versions_feed->getNewVersions(product_version()); if (count($versions) <= 0) { flash_error(lang('error upgrade version not found', $version_number)); return; } $zipurl = null; foreach ($versions as $version) { if ($version->getVersionNumber() == $version_number) { $zipurl = $version->getDownloadLinkByFormat("zip")->getUrl(); break; } } @set_time_limit(0); if (!$zipurl) { flash_error(lang('error upgrade invalid zip url', $version_number)); return; } $zipname = "fengoffice_" . str_replace(" ", "_", $version_number) . ".zip"; try { $in = fopen($zipurl, "r"); $zippath = "tmp/" . $zipname; $out = fopen($zippath, "w"); fwrite($out, stream_get_contents($in)); fclose($out); fclose($in); $zip = zip_open($zippath); if (!is_resource($zip)) { flash_error("error upgrade cannot open zip file"); return; } while ($zip_entry = zip_read($zip)) { $completePath = dirname(zip_entry_name($zip_entry)); $completeName = zip_entry_name($zip_entry); $completePath = substr($completePath, strpos($completePath, "fengoffice") + strlen("fengoffice") + 1); $completeName = substr($completeName, strpos($completeName, "fengoffice") + strlen("fengoffice") + 1); @mkdir($completePath, 0777, true); if (zip_entry_open($zip, $zip_entry, "r")) { if ($fd = @fopen($completeName, 'w')) { fwrite($fd, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry))); fclose($fd); } else { // Empty directory @mkdir($completeName, 0777); } zip_entry_close($zip_entry); } } zip_close($zip); } catch (Error $ex) { flash_error($ex->getMessage()); return; } $this->redirectToUrl("public/upgrade/index.php?upgrade_to=" . urlencode($version_number)); }
define('FILE_STORAGE_FILE_SYSTEM', 'fs'); define('FILE_STORAGE_MYSQL', 'mysql'); // Init flash! Flash::instance(); Hook::init(); include_once APPLICATION_PATH . '/functions.php'; try { CompanyWebsite::init(); if (defined('FORCE_UPGRADE_CHECK') && FORCE_UPGRADE_CHECK) { // if two days since last upgrade check => check for upgrades $lastUpgradeCheck = config_option('upgrade_last_check_datetime', 0); if ($lastUpgradeCheck instanceof DateTimeValue) { $lastUpgradeCheck = $lastUpgradeCheck->getTimestamp(); } if ($lastUpgradeCheck < DateTimeValueLib::now()->getTimestamp() - 60 * 60 * 24 * 2) { VersionChecker::check(true); } } $locale = get_locale(); Localization::instance()->loadSettings($locale, ROOT . '/language'); if (config_option('file_storage_adapter', 'mysql') == FILE_STORAGE_FILE_SYSTEM) { FileRepository::setBackend(new FileRepository_Backend_FileSystem(FILES_DIR, TABLE_PREFIX)); } else { FileRepository::setBackend(new FileRepository_Backend_DB(TABLE_PREFIX)); } // if PublicFiles::setRepositoryPath(ROOT . '/public/files'); if (trim(PUBLIC_FOLDER) == '') { PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'files'); } else { PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'public/files');
/** * Show upgrade page * * @param void * @return null */ function upgrade() { $this->addHelper('textile'); $version_feed = VersionChecker::check(true); if (!$version_feed instanceof VersionsFeed) { flash_error(lang('error check for upgrade')); $this->redirectTo('administration', 'upgrade'); } // if tpl_assign('versions_feed', $version_feed); }