38 |
|
|
39 |
function mcore_socket_send($ip, $port, $cmd) |
function mcore_socket_send($ip, $port, $cmd) |
40 |
{ |
{ |
41 |
|
global $mcore_certificate; |
42 |
|
|
43 |
// use sslv3 |
// use sslv3 |
44 |
$schema = "sslv3://"; |
$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); |
$fingerprint = system("openssl x509 -noout -modulus -in ".$mcore_certificate." | openssl sha1 | sed 's:(stdin)=\ ::'", $retval); |
49 |
|
ob_clean(); |
50 |
if ($retval == 0) |
if ($retval == 0) |
51 |
{ |
{ |
52 |
$fp = fsockopen($schema.$ip, $port, $errno, $errstr, 30); |
$fp = fsockopen($schema.$ip, $port, $errno, $errstr, 30); |
53 |
if (!$fp) { |
if (!$fp) { |
54 |
echo "$errstr ($errno)<br />\n"; |
echo "$errstr ($errno)<br />\n"; |
55 |
} else { |
} else { |
56 |
$out = "certauth 7acca14a60139d47d5ea591816991ef733b1e500\n"; |
$out = "certauth ".$fingerprint."\n"; |
57 |
$out .= $cmd."\n"; |
$out .= $cmd."\n"; |
58 |
$out .= "quit\n"; |
$out .= "quit\n"; |
59 |
fwrite($fp, $out); |
fwrite($fp, $out); |