Magellan Linux

Diff of /alx-src/tags/alx-web-0_7_0_20171218_1/include/socket_send.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

alx-src/branches/alx-web-070/include/socket_send.php revision 7712 by niro, Fri Sep 25 09:01:52 2015 UTC alx-src/tags/alx-web-0_7_0_20171218_1/include/socket_send.php revision 11135 by niro, Mon Dec 18 12:03:27 2017 UTC
# Line 1  Line 1 
1  <?  <?
2  // $address = "192.168.0.6";  include("config.inc.php");
 // $port = "6666";  
 //  
 // // create and connect socket  
 // $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);  
 // socket_connect($sock, $address, $port);  
 //  
 // // send the message to the daemon  
 // //$mesg = "resolution=800x600\nquit";  
 // $mesg = "resolution\nquit";  
 // //$mesg = "printer\ngfxcard\nnetcard\nkeyboard\nmouse\nsound\nquit";  
 // socket_write($sock, $mesg, strlen($mesg));  
 //  
 // // close socket  
 // socket_close($sock);  
   
   
 /* fgets needs 'auto-detect-line-endings = On' in php.ini to detect unix CRLFs!  
  * see: http://www.php.net/manual/de/filesystem.configuration.php#ini.auto-detect-line-endings  
  */  
   
 // // ssl  
 // $fp = fsockopen("sslv3://192.168.0.6", 6666, $errno, $errstr, 30);  
 // if (!$fp) {  
 // echo "$errstr ($errno)<br />\n";  
 // } else {  
 // $out = "resolution\n";  
 // $out .= "quit\n";  
 // fwrite($fp, $out);  
 // while (!feof($fp)) {  
 // echo fgets($fp, 128);  
 // }  
 // fclose($fp);  
 // }  
3    
4  function mcore_socket_send($ip, $port, $cmd)  function mcore_socket_send($ip, $port, $cmd)
5  {  {
6   // use sslv3   global $mcore_certificate;
  $schema = "sslv3://";  
7    
8   $fp = fsockopen($schema.$ip, $port, $errno, $errstr, 30);   // do not print output of system
9   if (!$fp) {   ob_start();
10   echo "$errstr ($errno)<br />\n";   $fingerprint = system("openssl x509 -noout -modulus -in ".$mcore_certificate." | openssl sha1 | sed 's:(stdin)=\ ::'", $retval);
11   } else {   ob_clean();
12   $out = "certauth 7acca14a60139d47d5ea591816991ef733b1e500\n";   if ($retval == 0)
13   $out = $cmd."\n";   {
14   $out .= "quit\n";   ob_start();
15   fwrite($fp, $out);   system("/usr/bin/mcore-socket-send --ip='".$ip."' --port='".$port."' --fingerprint='".$fingerprint."' --command='".$cmd."'", $sockretval);
16   while (!feof($fp)) {   ob_clean();
17   echo fgets($fp, 128);   if ($sockretval != 0) echo "socket send failed";
  }  
  fclose($fp);  
18   }   }
19  }  }
20  ?>  ?>

Legend:
Removed from v.7712  
changed lines
  Added in v.11135