Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8459 - (hide annotations) (download)
Fri Jan 29 11:59:29 2016 UTC (8 years, 3 months ago) by niro
File size: 1555 byte(s)
-read fingerprint from mcored certificate
1 niro 7708 <?
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 niro 8459 include("config.inc.php");
38    
39 niro 7708 function mcore_socket_send($ip, $port, $cmd)
40     {
41     // use sslv3
42     $schema = "sslv3://";
43    
44 niro 8459 $fingerprint = system("openssl x509 -noout -modulus -in ".$mcore_certificate." | openssl sha1 | sed 's:(stdin)=\ ::'", $retval);
45     if ($retval == 0)
46     {
47     $fp = fsockopen($schema.$ip, $port, $errno, $errstr, 30);
48     if (!$fp) {
49     echo "$errstr ($errno)<br />\n";
50     } else {
51     $out = "certauth 7acca14a60139d47d5ea591816991ef733b1e500\n";
52     $out .= $cmd."\n";
53     $out .= "quit\n";
54     fwrite($fp, $out);
55     while (!feof($fp)) {
56     echo fgets($fp, 128);
57     }
58     fclose($fp);
59 niro 7708 }
60     }
61     }
62     ?>