ui - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of ui.php
- <?php
- // Function to check if a port is open
- function is_port_open($host, $port) {
- $socket = @fsockopen($host, $port, $errno, $errstr, 1);
- if ($socket) {
- fclose($socket);
- return true;
- } else {
- return false;
- }
- }
- // Get the target host and port range from the user
- $host = $_POST['host'];
- $start_port = $_POST['start_port'];
- $end_port = $_POST['end_port'];
- // Create an array to store the open ports
- $open_ports = [];
- // Scan the ports
- for ($port = $start_port; $port <= $end_port; $port++) {
- if (is_port_open($host, $port)) {
- $open_ports[] = $port;
- }
- }
- // Display the results
- echo '<h1>Open Ports</h1>';
- echo '<ul>';
- foreach ($open_ports as $port) {
- echo '<li>' . $port . '</li>';
- }
- echo '</ul>';
- ?>