|
| 1 | +<?php |
| 2 | +// WHM API SERVER EMULATOR |
| 3 | +include 'config.php'; |
| 4 | +include 'servers/' . $reseller_server . '.php'; |
| 5 | +include 'servers/bridge.php'; |
| 6 | + |
| 7 | +// Set the content type to XML |
| 8 | +header('Content-Type: application/xml'); |
| 9 | + |
| 10 | +// Get the value of 'function' from the GET parameters |
| 11 | +$fake_endpoint = isset($_GET['function']) ? $_GET['function'] : ''; |
| 12 | + |
| 13 | +// Sanitize the input |
| 14 | +$fake_endpoint = strip_tags($fake_endpoint); // Remove any HTML or PHP tags |
| 15 | +$fake_endpoint = htmlspecialchars($fake_endpoint, ENT_QUOTES, 'UTF-8'); // Convert special characters to their HTML entities |
| 16 | + |
| 17 | +// Remove the file extension from the variable |
| 18 | +$endpoint = pathinfo($fake_endpoint, PATHINFO_FILENAME); |
| 19 | + // Define the arguments dynamically |
| 20 | +$arguments = ['arg1', 'arg2', 'arg3']; |
| 21 | +if ($endpoint === "createacct" && function_exists($endpoint)) { |
| 22 | + |
| 23 | + // call_user_func_array($endpoint, $arguments); |
| 24 | + echo '<createacct>'; |
| 25 | + echo ' <result>'; |
| 26 | + echo ' <options>'; |
| 27 | + echo ' <ip>192.168.0.1</ip>'; |
| 28 | + echo ' <nameserver>ns1.example-host.com</nameserver>'; |
| 29 | + echo ' <nameserver2>ns2.example-host.com</nameserver2>'; |
| 30 | + echo ' <nameserver3/>'; |
| 31 | + echo ' <nameserver4/>'; |
| 32 | + echo ' <nameservera/>'; |
| 33 | + echo ' <nameservera2/>'; |
| 34 | + echo ' <nameservera3/>'; |
| 35 | + echo ' <nameservera4/>'; |
| 36 | + echo ' <nameserverentry/>'; |
| 37 | + echo ' <nameserverentry2/>'; |
| 38 | + echo ' <nameserverentry3/>'; |
| 39 | + echo ' <nameserverentry4/>'; |
| 40 | + echo ' <package>package_name</package>'; |
| 41 | + echo ' </options>'; |
| 42 | + echo ' <rawout></rawout>'; |
| 43 | + echo ' <status>1</status>'; |
| 44 | + echo ' <statusmsg>Account Creation Ok</statusmsg>'; |
| 45 | + echo ' </result>'; |
| 46 | + echo '</createacct>'; |
| 47 | +} elseif ($endpoint === "removeacct" && function_exists($endpoint)) { |
| 48 | + echo '<removeacct>'; |
| 49 | + echo ' <result>'; |
| 50 | + echo ' <status>1</status>'; |
| 51 | + echo ' <statusmsg>Account Removal Ok</statusmsg>'; |
| 52 | + echo ' </result>'; |
| 53 | + echo '</removeacct>'; |
| 54 | +} elseif ($endpoint === "detect_cpanel_bridge" && function_exists($endpoint)) { |
| 55 | +echo "<detect_cpanel_bridge>"; |
| 56 | +echo "<result>"; |
| 57 | +echo "<detected> true </detected>"; |
| 58 | +echo "</result>"; |
| 59 | +echo "</detect_cpanel_bridge>"; |
| 60 | +} elseif (!function_exists($endpoint)) { |
| 61 | + // Invalid endpoint or endpoint not implemented |
| 62 | + http_response_code(501); // Set HTTP status code to 501 Not Implemented |
| 63 | + echo '<error>'; |
| 64 | + echo ' <message>Endpoint Not Implemented</message>'; |
| 65 | + echo '</error>'; |
| 66 | +} else { |
| 67 | + // Invalid endpoint or endpoint not implemented |
| 68 | + http_response_code(501); // Set HTTP status code to 501 Not Implemented |
| 69 | + echo '<error>'; |
| 70 | + echo ' <message>Endpoint Not Implemented</message>'; |
| 71 | + echo '</error>'; |
| 72 | +} |
| 73 | +?> |
0 commit comments