. */ // Usage // ----- // Access this file in your browser and follow the instructions to update your site config files. error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", 1); @set_time_limit(120); //////////////////////////////// // Load config file //////////////////////////////// require_once('../config.php'); $admin_page = 'update'; require_once('require_login.php'); require_once('template.php'); tpl_header('Update site patterns'); $version = include('../site_config/standard/version.php'); ///////////////////////////////// // Check for valid update key ///////////////////////////////// if (!isset($_REQUEST['key']) || trim($_REQUEST['key']) == '') { if ($_SERVER['REQUEST_METHOD'] == 'POST') { header('Location: update.php'); exit; } $auto = true; $no_auto_reasons = array(); if (!class_exists('ZipArchive')) { $auto = false; $no_auto_reasons[] = 'zip support (PHP\'s ZipArchive class) is missing'; } if (!is_writable('../site_config')) { $auto = false; $no_auto_reasons[] = 'your site_config/ folder is not writable - change permissions to 777 and try again.

'; } if (!file_exists('../site_config/standard/version.php')) { die('Could not determine current version of your site pattern files (site_config/standard/version.php). Make sure you\'re using at least version 2.9.5 of Full-Text RSS.'); } if (!@$options->registration_key) { $input_field = ''; } else { $reg_key = preg_replace('/[^a-z0-9-]/i', '', $options->registration_key); $input_field = ''; } ?>

You have Full-Text RSS (Site Patterns version: )

To see if you have the latest versions, check for updates.

Registration key

This update tool requires a registration key issued by FiveFilters.org. You do not need a registration key to use Full-Text RSS, and none of the regular funtionality is affected if you do not have one. The update tool is simply a convenience service we offer our customers.

'; if ($auto) { echo '

This update tool will attempt to fetch the latest site patterns from FiveFilters.org and update yours.

'; echo '

Important: if you\'ve modified or added your own config files in the site_config/standard/ folder, please move them to site_config/custom/ — the update process will attempt to replace everything in site_config/standard/ with our updated version.

'; echo $reg_key_info; if (!isset($reg_key)) { echo '

Your registration key should be your PayPal or Avangate transaction ID. If you don\'t have a registration key, you will get one sent to you automatically when you purchase Full-Text RSS from FiveFilters.org.

'; } echo '
',$input_field,'
'; } else { echo '
'; echo '

We cannot automatically update your site pattern files because:

'; echo ''; echo '

You can still manually update by downloading the zip file and replacing everything in your site_config/standard/ folder with the contents of the zip file.

'; echo '
'; echo $reg_key_info; if (!isset($reg_key)) { echo '

Enter your registration key below to download the latest version of the site config files from FiveFilters.org

'; echo '

Your registration key should be your PayPal or Avangate transaction ID.

'; } echo '
',$input_field,'
'; } echo '

Help

'; echo '

If you have any trouble, please contact us via our support site.

'; exit; } ////////////////////////////////// // Check for updates ////////////////////////////////// $ff_version = (float)@file_get_contents('http://fivefilters.org/content-only/site_config/standard/version.txt'); if (version_compare($version, $ff_version) != -1) { die('Your site config files are up to date! If you have trouble extracting from a particular site, please email us: help@fivefilters.org'); } else { println("Updated site patterns are available at FiveFilters.org (version $ff_version)..."); } ////////////////////////////////// // Prepare ////////////////////////////////// $latest_remote = 'http://fivefilters.org/content-only/update/get_site_config.php?key='.urlencode($_REQUEST['key']); $tmp_latest_local = '../site_config/latest_site_config.zip'; $tmp_latest_local_dir = '../site_config/standard_latest'; $tmp_old_local_dir = '../site_config/standard_old'; if (file_exists($tmp_latest_local)) unlink($tmp_latest_local); if (file_exists($tmp_latest_local_dir)) rrmdir($tmp_latest_local_dir); if (file_exists($tmp_old_local_dir)) { rrmdir($tmp_old_local_dir); } $standard_local_dir = '../site_config/standard/'; //@copy($latest_remote, $tmp_latest_local); //copy() does not appear to fill $http_response_header in certain environments @file_put_contents($tmp_latest_local, @file_get_contents($latest_remote)); $headers = implode("\n", $http_response_header); //var_dump($headers); exit; if (strpos($headers, 'HTTP/1.1 403') !== false) { println("Invalid registration key supplied"); exit; } elseif (strpos($headers, 'HTTP/1.1 200') === false) { println("Sorry, something went wrong. We're looking into it. Please contact us if the problem persists."); exit; } if (class_exists('ZipArchive') && file_exists($tmp_latest_local)) { println("Downloaded latest copy of the site pattern files to $tmp_latest_local"); $zip = new ZipArchive; if ($zip->open($tmp_latest_local) === TRUE) { $zip->extractTo($tmp_latest_local_dir); $zip->close(); @unlink($tmp_latest_local); if (file_exists($tmp_latest_local_dir)) { println("Unzipped contents to $tmp_latest_local_dir"); if (!file_exists($tmp_latest_local_dir.'/version.php')) { println("There was a problem extracting the latest site patterns archive - your current site patterns remain untouched."); println("Please update manually."); exit; } rename($standard_local_dir, $tmp_old_local_dir); if (file_exists($tmp_old_local_dir)) println("Renamed $standard_local_dir to $tmp_old_local_dir"); rename($tmp_latest_local_dir, $standard_local_dir); if (file_exists($standard_local_dir)) println("Renamed $tmp_latest_local_dir to $standard_local_dir"); println("All done! Your old site config files are in $tmp_old_local_dir — these will be removed next time you go through the update process."); } else { if (file_exists($tmp_latest_local)) @unlink($tmp_latest_local); println("Failed to unzip to $tmp_latest_local_dir - your current site patterns remain untouched"); } } else { if (file_exists($tmp_latest_local)) @unlink($tmp_latest_local); println("Failed to extract from $tmp_latest_local - your current site patterns remain untouched"); } } else { println("Could not download the latest site config files. Please update manually - your current site patterns remain untouched."); } function println($txt) { echo $txt,"
\n"; ob_end_flush(); ob_flush(); flush(); } function rrmdir($dir) { foreach(glob($dir . '/{*.txt,*.php,.*.txt,.*.php}', GLOB_BRACE|GLOB_NOSORT) as $file) { if(is_dir($file)) { rrmdir($file); } else { unlink($file); } } rmdir($dir); } ?>