PEAR_PackageUpdate
[ class tree: PEAR_PackageUpdate ] [ index: PEAR_PackageUpdate ] [ all elements ]

Source for file withoutFrontend.php

Documentation is available at withoutFrontend.php

  1. <?php
  2. /**
  3.  * Always keep your application up-to-date with the most recent and stable version
  4.  * of PEAR::Log package.
  5.  *
  6.  * PHP versions 4 and 5
  7.  *
  8.  * @category PEAR
  9.  * @package  PEAR_PackageUpdate
  10.  * @author   Laurent Laville <pear@laurent-laville.org>
  11.  * @license  http://www.php.net/license/3_01.txt  PHP License 3.01
  12.  * @version  CVS: $Id: withoutFrontend.php,v 1.8 2007/11/25 16:37:36 farell Exp $
  13.  * @link     http://pear.php.net/package/PEAR_PackageUpdate
  14.  * @since    File available since Release 0.5.0
  15.  */
  16.  
  17. require_once 'Log.php';
  18. require_once 'PEAR/PackageUpdate.php';
  19.  
  20. /**
  21.  * This class allow to use PEAR_PackageUpdate as backend without any frontend.
  22.  * No end-user action needed.
  23.  *
  24.  * @ignore
  25.  */
  26. class PEAR_PackageUpdate_Null extends PEAR_PackageUpdate
  27. {
  28.     /**
  29.      * Cli driver class constructor
  30.      *
  31.      * @param string $packageName The package to update.
  32.      * @param string $channel     The channel the package resides on.
  33.      * @param string $user_file   (optional) file to read PEAR user-defined
  34.      *                             options from
  35.      * @param string $system_file (optional) file to read PEAR system-wide
  36.      *                             defaults from
  37.      * @param string $pref_file   (optional) file to read PPU user-defined
  38.      *                             options from
  39.      *
  40.      * @access public
  41.      * @return void 
  42.      * @since  0.5.0
  43.      */
  44.     function PEAR_PackageUpdate_Null($packageName$channel,
  45.         $user_file ''$system_file ''$pref_file '')
  46.     {
  47.         parent::PEAR_PackageUpdate($packageName$channel,
  48.             $user_file$system_file$pref_file);
  49.     }
  50.  
  51.     /**
  52.      * Null driver always redirects to current script
  53.      * to force the user to restart the application.
  54.      *
  55.      * @access public
  56.      * @return void 
  57.      * @since  0.5.0
  58.      */
  59.     function forceRestart()
  60.     {
  61.         // removes warning message given by pear installer
  62.         ob_end_clean();
  63.         // Reload current page.
  64.         header('Location: ' $_SERVER['PHP_SELF']);
  65.         exit();
  66.     }
  67. }
  68.  
  69. // Check for updates of PEAR::Log package though pear.php.net channel
  70. $ppu =PEAR_PackageUpdate::factory('Null''Log''peer');
  71. if ($ppu !== false{
  72.     // Check for new stable version
  73.     $ppu->setMinimumState(PEAR_PACKAGEUPDATE_STATE_STABLE);
  74.     $ppu->setMinimumReleaseType(PEAR_PACKAGEUPDATE_TYPE_BUG);
  75.     if ($ppu->checkUpdate()) {
  76.         // Update your local copy
  77.         ob_start();
  78.         if ($ppu->update()) {
  79.             // If the update succeeded, the application should be restarted.
  80.             $ppu->forceRestart();
  81.         }
  82.         ob_end_clean();
  83.     }
  84. }
  85.  
  86. // Check for errors.
  87. if ($ppu->hasErrors()) {
  88.     $error $ppu->popError();
  89.     echo "<b>Error occured when trying to update: PEAR::Log package</b> <br />\n";
  90.     echo "<b>Message:</b> " $error['message'."<br />\n";
  91.     if (isset($error['context']{
  92.         echo "<hr /><i>Context:</i><br />\n";
  93.         echo "<b>File:</b> " $error['context']['file'."<br />\n";
  94.         echo "<b>Line:</b> " $error['context']['line'."<br />\n";
  95.         echo "<b>Function:</b> " $error['context']['function'."<br />\n";
  96.         echo "<b>Class:</b> " $error['context']['class'."<br />\n";
  97.     }
  98.     exit();
  99. }
  100.  
  101. // your application code goes here ...
  102. print 'Hello World';
  103. ?>

Documentation generated on Sun, 15 Jun 2008 10:30:07 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.