Magellan Linux

Annotation of /alx-src/tags/alx-web-0_7_0_20170406_2/include/socket_send.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9471 - (hide annotations) (download)
Thu Apr 6 13:35:59 2017 UTC (7 years, 2 months ago) by niro
File size: 1620 byte(s)
tagged 'alx-web-0_7_0_20170406_2'
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 niro 8460 global $mcore_certificate;
42    
43 niro 7708 // use sslv3
44     $schema = "sslv3://";
45    
46 niro 8460 // do not print output of system
47     ob_start();
48 niro 8459 $fingerprint = system("openssl x509 -noout -modulus -in ".$mcore_certificate." | openssl sha1 | sed 's:(stdin)=\ ::'", $retval);
49 niro 8460 ob_clean();
50 niro 8459 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 niro 8460 $out = "certauth ".$fingerprint."\n";
57 niro 8459 $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 niro 7708 }
65     }
66     }
67     ?>