cvs: pear /Net_Ping Ping.php

From: Date: Mon, 27 May 2002 19:03:45 +0000
Subject: cvs: pear /Net_Ping Ping.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4160@lists.php.net to get a copy of this message
jan Mon May 27 15:03:45 2002 EDT Modified files: /pear/Net_Ping Ping.php Log: - be nice to coding standard - disabling checkHost(); needs to be fixed Index: pear/Net_Ping/Ping.php diff -u pear/Net_Ping/Ping.php:1.12 pear/Net_Ping/Ping.php:1.13 --- pear/Net_Ping/Ping.php:1.12 Mon May 27 04:41:41 2002 +++ pear/Net_Ping/Ping.php Mon May 27 15:03:44 2002 @@ -1,4 +1,4 @@ -<?php +wohawohawoha<?php // // +----------------------------------------------------------------------+ // | PHP Version 4 | @@ -19,7 +19,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Ping.php,v 1.12 2002/05/27 08:41:41 mj Exp $ +// $Id: Ping.php,v 1.13 2002/05/27 19:03:44 jan Exp $ require_once "PEAR.php"; require_once "OS/Guess.php"; @@ -50,7 +50,7 @@ * ?> * * @author Martin Jansen <mj@php.net> -* @version $Revision: 1.12 $ +* @version $Revision: 1.13 $ * @package Net * @access public */ @@ -63,7 +63,7 @@ * @var string * @access private */ - var $ping_path = ""; + var $_ping_path = ""; /** * Array with the result from the ping execution @@ -71,7 +71,7 @@ * @var array * @access private */ - var $result = array(); + var $_result = array(); /** * OS_Guess instance @@ -79,7 +79,7 @@ * @var object * @access private */ - var $OS_Guess = ""; + var $_OS_Guess = ""; /** * OS_Guess->getSysname result @@ -87,7 +87,7 @@ * @var string * @access private */ - var $sysname = ""; + var $_sysname = ""; /** * Ping command arguments @@ -95,7 +95,7 @@ * @var array * @access private */ - var $args = array(); + var $_args = array(); /** * Indicates if an empty array was given to setArgs (not used yet) @@ -103,7 +103,7 @@ * @var boolean * @access private */ - var $noArgs = true; + var $_noArgs = true; /** * Contains the argument->option relation @@ -111,7 +111,7 @@ * @var array * @access private */ - var $argRelation = array(); + var $_argRelation = array(); /** @@ -121,11 +121,11 @@ */ function Net_Ping() { - $this->OS_Guess = new OS_Guess; - $this->sysname = $this->OS_Guess->getSysname(); + $this->_OS_Guess = new OS_Guess; + $this->_sysname = $this->_OS_Guess->getSysname(); - $this->setPingPath(); - $this->initArgRelation(); + $this->_setPingPath(); + $this->_initArgRelation(); } /** @@ -143,12 +143,12 @@ /* accept empty arrays, but set flag*/ if (0 == count($args)) { - $this->noArgs = true; + $this->_noArgs = true; } else { - $this->noArgs = false; + $this->_noArgs = false; } - $this->args = $args; + $this->_args = $args; return true; } @@ -158,12 +158,12 @@ * * @access private */ - function setPingPath() + function _setPingPath() { - if ("windows" == $this->sysname) { - $this->ping_path = "ping"; + if ("windows" == $this->_sysname) { + $this->_ping_path = "ping"; } else { - $this->ping_path = exec("which ping"); /* FIXME: windows */ + $this->_ping_path = exec("which ping"); /* FIXME: windows */ } } @@ -174,7 +174,7 @@ * @return string Argument line * @access private */ - function createArgList() + function _createArgList() { $ret = ""; @@ -185,13 +185,13 @@ $quiet = ""; $size = ""; - foreach($this->args AS $option => $value) { - if(!empty($option) && NULL != $this->argRelation[$this->sysname][$option]) { - ${$option} = $this->argRelation[$this->sysname][$option]." ".$value." "; + foreach($this->_args AS $option => $value) { + if(!empty($option) && NULL != $this->_argRelation[$this->_sysname][$option]) { + ${$option} = $this->_argRelation[$this->_sysname][$option]." ".$value." "; } } - switch($this->sysname) { + switch($this->_sysname) { case "freebsd": return $quiet.$count.$ttl.$timeout; @@ -225,19 +225,18 @@ function ping($host) { - $argList = $this->createArgList(); - $cmd = $this->ping_path." ".$argList." ".$host; - exec($cmd, $result); + $argList = $this->_createArgList(); + $cmd = $this->_ping_path." ".$argList." ".$host; + exec($cmd, $this->_result); - if (!is_array($result)) { + if (!is_array($this->_result)) { return PING_FAILED; } - if (count($result) == 0) { + if (count($this->_result) == 0) { return PING_HOST_NOT_FOUND; } else { - $this->result = $result; - return $result; + return $this->_result; } } @@ -250,10 +249,16 @@ * @return bool True on success or false otherwise * * @notes Output taken from ping of netkit-base-0.10-37 + * FIXME! */ - function checkHost($host, $severely = true) + function _checkHost($host, $severely = true) { - $res = $this->ping($host, 10, 32, true); + $this->setArgs(array("count" => 10, + "size" => 32, + "quiet" => true + ) + ); + $res = $this->ping($host); if ($res == PING_HOST_NOT_FOUND) { return false; } @@ -284,9 +289,9 @@ * @return string Argument line * @access private */ - function initArgRelation() + function _initArgRelation() { - $this->argRelation = array( + $this->_argRelation = array( "freebsd" => array ( "timeout" => "-t", "ttl" => "-m", @@ -315,7 +320,6 @@ ), /* we don't know yet what's darwin's signature - "darwin" => array ( "timeout" => "-w", "iface" => "-I",

« previous php.pear.cvs (#4160) next »