home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / System / Daemon / OS / BSD.php next >
Encoding:
PHP Script  |  2008-07-02  |  2.5 KB  |  93 lines

  1. <?php
  2. /* vim: set noai expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
  3. /**
  4.  * System_Daemon turns PHP-CLI scripts into daemons.
  5.  * 
  6.  * PHP version 5
  7.  *
  8.  * @category  System
  9.  * @package   System_Daemon
  10.  * @author    Kevin van Zonneveld <kevin@vanzonneveld.net>
  11.  * @copyright 2008 Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  12.  * @license   http://www.opensource.org/licenses/bsd-license.php New BSD Licence
  13.  * @version   SVN: Release: $Id$
  14.  * @link      http://trac.plutonia.nl/projects/system_daemon
  15.  */
  16.  
  17. /**
  18.  * A System_Daemon_OS driver for BSD
  19.  *
  20.  * @category  System
  21.  * @package   System_Daemon
  22.  * @author    Kevin van Zonneveld <kevin@vanzonneveld.net>
  23.  * @copyright 2008 Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  24.  * @license   http://www.opensource.org/licenses/bsd-license.php New BSD Licence
  25.  * @version   SVN: Release: $Id$
  26.  * @link      http://trac.plutonia.nl/projects/system_daemon
  27.  * * 
  28.  */
  29. class System_Daemon_OS_BSD extends System_Daemon_OS
  30. {
  31.     /**
  32.      * Template path
  33.      *
  34.      * @var string
  35.      */
  36.     protected $autoRunTemplatePath = false;
  37.     
  38.     /**
  39.      * Determines wether the system is compatible with this OS
  40.      *
  41.      * @return boolean
  42.      */
  43.     public function isInstalled() 
  44.     {
  45.         if (!stristr(PHP_OS, "Darwin") && 
  46.             !stristr(PHP_OS, "BSD")) {
  47.             return false;
  48.         }
  49.         
  50.         return true;
  51.     }//end isInstalled
  52.     
  53.     /**
  54.      * Returns a template path to base the autuRun script on.
  55.      * Uses $autoRunTemplatePath if possible. 
  56.      *
  57.      * @return unknown
  58.      * @see autoRunTemplatePath
  59.      */
  60.     public function getAutoRunTemplatePath() 
  61.     {
  62.         $dir        = false;
  63.         $file       = "template_BSD";
  64.         $tried_dirs = array();
  65.         
  66.         if (class_exists("PEAR_Config", true)) {
  67.             $try_dir = realpath(PEAR_Config::singleton()->get("data_dir") ."/System_Daemon");
  68.             if (!is_dir($try_dir)) {
  69.                 $tried_dirs[] = $try_dir;
  70.             } else {
  71.                 $dir = $try_dir;
  72.             }
  73.         }
  74.         
  75.         if (!$dir) {
  76.             $try_dir = realpath(dirname(__FILE__)."../../../../data");
  77.             if (!is_dir($try_dir)) {
  78.                 $tried_dirs[] = $try_dir;
  79.             } else {
  80.                 $dir = $try_dir;
  81.             }
  82.         }
  83.         
  84.         if (!$dir) {
  85.             $this->errors[] = "No data dir found in either: ".implode(" or ", $tried_dirs);
  86.             return false;
  87.         }
  88.                 
  89.         return $dir."/".$file;
  90.     }//end getAutoRunTemplatePath        
  91.     
  92. }//end class
  93. ?>