Ping Module

Back to Module Development

Page: 1  
From User Message Body
dans34
Post #788
Member
Date: 6:47 pm, Sep 1 2008
Posts: 1


Code
<?php





class ping_mod extends module {



    public $title = "Ping Site";

    public $author = "Dans34 Dan@vidko.co.uk";

    public $version = "0.0.1";



    public function ping($line, $args)

    {
    if ($args['nargs'] <= 0)

        {

            $this->ircClass->notice($line['fromNick'], "Usage: !ping <IP>");

            return;

        }

    $host_to_ping=$args[ 'arg1' ]    
$ouputShell = shell_exec("ping -c2 -w2 $host_to_ping");
if strpos($outputShell, '0 recived')){

$this->ircClass->privMsg($channel,$host_to_ping"is down");}
else{
$this->ircClass->privMsg($channel,$host_to_ping"is up");}



    }
?>



can some one tell me where i have gone wrong

the plan was to have it trigger by !ping <ip> but i cant get the script to work .. it just wont load the script .. says someting about T_varable error ..

Mad_Clog
Post #789
user avatar
Member
Date: 7:30 pm, Sep 2 2008
Posts: 176


Code
if strpos($outputShell, '0 recived')){
should be
Code
if (strpos($outputShell, '0 recived')){


Code
$this->ircClass->privMsg($channel,$host_to_ping"is down");
should be
Code
$this->ircClass->privMsg($channel,$host_to_ping."is down");


Same for "is up" message obviously.

   

Back to Module Development