Magellan Linux

Contents of /alx-src/branches/alx-web-070/include/socket_send.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8460 - (show annotations) (download)
Fri Jan 29 12:57:52 2016 UTC (8 years, 3 months ago) by niro
File size: 1620 byte(s)
-fixed use of system fingerprint
1 <?
2 // $address = "192.168.0.6";
3 // $port = "6666";
4 //
5 // // create and connect socket
6 // $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
7 // socket_connect($sock, $address, $port);
8 //
9 // // send the message to the daemon
10 // //$mesg = "resolution=800x600\nquit";
11 // $mesg = "resolution\nquit";
12 // //$mesg = "printer\ngfxcard\nnetcard\nkeyboard\nmouse\nsound\nquit";
13 // socket_write($sock, $mesg, strlen($mesg));
14 //
15 // // close socket
16 // socket_close($sock);
17
18
19 /* fgets needs 'auto-detect-line-endings = On' in php.ini to detect unix CRLFs!
20 * see: http://www.php.net/manual/de/filesystem.configuration.php#ini.auto-detect-line-endings
21 */
22
23 // // ssl
24 // $fp = fsockopen("sslv3://192.168.0.6", 6666, $errno, $errstr, 30);
25 // if (!$fp) {
26 // echo "$errstr ($errno)<br />\n";
27 // } else {
28 // $out = "resolution\n";
29 // $out .= "quit\n";
30 // fwrite($fp, $out);
31 // while (!feof($fp)) {
32 // echo fgets($fp, 128);
33 // }
34 // fclose($fp);
35 // }
36
37 include("config.inc.php");
38
39 function mcore_socket_send($ip, $port, $cmd)
40 {
41 global $mcore_certificate;
42
43 // use sslv3
44 $schema = "sslv3://";
45
46 // do not print output of system
47 ob_start();
48 $fingerprint = system("openssl x509 -noout -modulus -in ".$mcore_certificate." | openssl sha1 | sed 's:(stdin)=\ ::'", $retval);
49 ob_clean();
50 if ($retval == 0)
51 {
52 $fp = fsockopen($schema.$ip, $port, $errno, $errstr, 30);
53 if (!$fp) {
54 echo "$errstr ($errno)<br />\n";
55 } else {
56 $out = "certauth ".$fingerprint."\n";
57 $out .= $cmd."\n";
58 $out .= "quit\n";
59 fwrite($fp, $out);
60 while (!feof($fp)) {
61 echo fgets($fp, 128);
62 }
63 fclose($fp);
64 }
65 }
66 }
67 ?>