12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- function process()
- {
- $language = isset($_REQUEST['language']) ? $_REQUEST['language'] : null;
-
- if(!$language)
- {
- return array("error" => "Language not requested. Please pass the GET parameter 'language'.");
- }
-
- if(isset($_POST['code']))
- {
- $code = $_POST['code'];
- if($_POST['code'] == '')
- {
- $code = "if(true) { echo 'hello'; }";
- }
- elseif(empty(trim($code)))
- {
- return array(
- "error" => "No code provided to analyze. Please pass the POST parameter 'code'.");
- }
- }
-
- switch (strtolower($language))
- {
- case 'php':
- include ("cc_php.php");
- break;
- default:
- return array("error" => "Language not supported.");
- }
- return array("value" => calculate($code));
- }
- echo json_encode(process());
|