1. <?php
  2. /**
  3. * An example script that updates PEAR::XML_RPC using PEAR_PackageUpdate
  4. * with a Web front end.
  5. *
  6. * @author    Laurent Laville
  7. * @package   PEAR_PackageUpdate_Web
  8. * @version   $Id:$
  9. * @license   http://www.php.net/license/3_01.txt  PHP License 3.01
  10. * @copyright 2006 Laurent Laville
  11. */
  12.  
  13. require_once 'PEAR/PackageUpdate.php';
  14.  
  15. // Create a Web package updater for the XML_RPC package on the pear channel.
  16. $ppu = PEAR_PackageUpdate::factory('Web', 'XML_RPC', 'pear');
  17.  
  18. // Make sure the updater was created properly.
  19. if ($ppu === false) {
  20.     echo "Could not create updater.\n";
  21.     echo "You might want to check for and install updates manually.\n";
  22.     die();
  23. }
  24.  
  25. // Check to see if any updates are availble.
  26. if ($ppu->checkUpdate()) {
  27.     // If updates are available, present the user with the option to update.
  28.     if ($ppu->presentUpdate()) {
  29.         // Update the package.
  30.         $ppu->update();
  31.         $ppu->forceRestart();
  32.     }
  33. }
  34.  
  35. // Check for errors.
  36. if ($ppu->hasErrors()) {
  37.     $ppu->errorDialog();
  38. }
  39.  
  40. print 'still alive';
  41. ?>