<?php
/**
* An example script that updates PEAR::XML_RPC using PEAR_PackageUpdate
* with a Web front end.
*
* @author Laurent Laville
* @package PEAR_PackageUpdate_Web
* @version $Id:$
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @copyright 2006 Laurent Laville
*/
require_once 'PEAR/PackageUpdate.php';
define('PEAR_PACKAGEUPDATE_DATA_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR );
// Create a Web package updater for the XML_RPC package on the pear channel.
$ppu = PEAR_PackageUpdate::factory('Web', 'XML_RPC', 'pear');
// Uncommenting this line will change the user's preferences. It is NOT
// recommended for production use, but is handy when debugging.
//$ppu->setDontAskUntilNextRelease(false);
// Make sure the updater was created properly.
if ($ppu === false) {
echo "Could not create updater.\n";
echo "You might want to check for and install updates manually.\n";
die();
}
// Check to see if any updates are availble.
if ($ppu->checkUpdate()) {
// If updates are available, present the user with the option to update.
if ($ppu->presentUpdate()) {
// Update the package.
$ppu->update();
$ppu->forceRestart();
}
}
// Check for errors.
if ($ppu->hasErrors()) {
$ppu->errorDialog();
}
// Don't ask me again until another version has been released. This restores
// the preference changed above. Again, this is for debugging only.
//$ppu->setDontAskUntilNextRelease(true);
print 'still alive';
?>