mirror of
https://github.com/YGGverse/web-api.git
synced 2025-03-13 05:51:41 +00:00
implement socket api
This commit is contained in:
parent
760ede456a
commit
70ed2168dd
43
src/public/socket.php
Normal file
43
src/public/socket.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Set headers
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
|
||||||
|
// Load dependencies
|
||||||
|
require_once(__DIR__ . '/../../vendor/autoload.php');
|
||||||
|
|
||||||
|
// Valid port required to continue
|
||||||
|
if (empty($_GET['port']) || !\Yggverse\Net\Socket::isPort($_GET['port']))
|
||||||
|
{
|
||||||
|
exit(
|
||||||
|
json_encode(
|
||||||
|
[
|
||||||
|
'success' => false,
|
||||||
|
'message' => _('valid port required')
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valid host required to continue
|
||||||
|
if (isset($_GET['host']) && !\Yggverse\Net\Socket::isHost($_GET['host']))
|
||||||
|
{
|
||||||
|
exit(
|
||||||
|
json_encode(
|
||||||
|
[
|
||||||
|
'success' => false,
|
||||||
|
'message' => _('valid host required')
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connection test
|
||||||
|
exit(
|
||||||
|
json_encode(
|
||||||
|
[
|
||||||
|
'success' => \Yggverse\Net\Socket::isOpen($_GET['host'], $_GET['port'])
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user