I'm working on some PHP code to make it possible for a PHP
script to do "net send" messages.  

Here's what I have so far, I've been successful sending 
to localhost with it on a Windows machine.  

If folks could try this out and make suggestions on how to 
improve it, I'd be very appreciative...



function WinPopup($Target, $Message) 
      global $COMSPEC;
      if (isset($COMSPEC))  // Windows
        /* Schedule the call to 'net send', because if 'net send' 
           can't quickly resolve the computer name it can easily exceed PHP's 
           allowed processing time, and besides don't want the user to wait */ 
        $result = shell_exec("at ".date("H:i", time()+60)." net send
\"".$Target."\" ".escapeshellarg($Message));
        preg_match("/ID = ([0-9]+)$/",$result, $matches );
        return $matches[1];    
      // *nix with Samba
      $result = shell_exec("smbclient -M ".escapeshellarg($Target)."
".escapeshellarg($Message)." >/dev/null");      
      return 1;



<h4>Winpopup / Net Send from PHP</h4>

<input type=text name=target value='<?=gethostbyaddr($REMOTE_ADDR);?>'>
<input type=submit value='go!'>

// The Test ...
if (isset($target))
$x = WinPopup($target, "PHP sent you a message at ".date("H:i"));
echo "<BR>";
echo "date = ".date("H:i");
echo "<Br>";
echo "x = [ $x ]";
if <b><?=$target?></b> is a windows PC with some kind of 
net send / winpopup compatiable maillots 
running you should hopefully get
a message in about a minute or two. 

$at = shell_exec("at");
echo "at = [ <textarea nowrap rows=10 cols=100>".$at."</textarea><Br>]";

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to