1. <?php
  2. /**
  3. * An example script that try to update 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. define('PEAR_PACKAGEUPDATE_DATA_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR );
  16.  
  17. // Create a Web package updater for the XML_RPC package on an unkown channel.
  18. $ppu = PEAR_PackageUpdate::factory('Web', 'XML_RPC', '');
  19.  
  20. // Make sure the updater was created properly.
  21. if ($ppu === false) {
  22.     echo "Could not create updater.\n";
  23.     echo "You might want to check for and install updates manually.\n";
  24.     die();
  25. }
  26.  
  27. // Check to see if any updates are availble.
  28. if ($ppu->checkUpdate()) {
  29.     // If updates are available, present the user with the option to update.
  30.     if ($ppu->presentUpdate()) {
  31.         // Update the package.
  32.         $ppu->update();
  33.         $ppu->forceRestart();
  34.     }
  35. }
  36.  
  37. // Check for errors.
  38. if ($ppu->hasErrors()) {
  39.     $ppu->errorDialog(true); // with context details
  40. #    $ppu->errorDialog(false); // without context
  41. }
  42.  
  43. print 'still alive';
  44. ?>