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. define('PEAR_PACKAGEUPDATE_DATA_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR );
  16.  
  17. // Create a Web package updater for the XML_RPC package on the pear channel.
  18. $ppu = PEAR_PackageUpdate::factory('Web', 'XML_RPC', 'pear');
  19.  
  20. // Uncommenting this line will change the user's preferences. It is NOT
  21. // recommended for production use, but is handy when debugging.
  22. //$ppu->setDontAskUntilNextRelease(false);
  23.  
  24. // Make sure the updater was created properly.
  25. if ($ppu === false) {
  26.     echo "Could not create updater.\n";
  27.     echo "You might want to check for and install updates manually.\n";
  28.     die();
  29. }
  30.  
  31. // Check to see if any updates are availble.
  32. if ($ppu->checkUpdate()) {
  33.     // If updates are available, present the user with the option to update.
  34.     if ($ppu->presentUpdate()) {
  35.         // Update the package.
  36.         $ppu->update();
  37.         $ppu->forceRestart();
  38.     }
  39. }
  40.  
  41. // Check for errors.
  42. if ($ppu->hasErrors()) {
  43.     $ppu->errorDialog();
  44. }
  45.  
  46. // Don't ask me again until another version has been released. This restores
  47. // the preference changed above. Again, this is for debugging only.
  48. //$ppu->setDontAskUntilNextRelease(true);
  49. print 'still alive';
  50. ?>