echo '</select>'; } function isSelected($sOption, $option) { if ($sOption == $option) { echo 'selected="selected"'; } else { echo ""; } } function xmlOut($con, $tag) { return "<" . $tag . ">" . $con . "</" . $tag . ">"; } function cdat($dat) { return "<![CDATA[" . $dat . "]]>"; } // ---------- MAIN -------- // $allProblems = getDirectoryList("/var/www/HYPC/ProblemZone/Problems/",false); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo "<result>"; echo xmlOut("loader", "TYPE"); /* echo "<pSelect><![CDATA["; echo optionsFromArray($allProblems)); // Problems to select echo "]]></pSelect>"; */ echo xmlOut(cdat("test"), "probInfo"); // Problem info echo "</result>";
$results[] = $file; } } // tidy up: close the handler closedir($handler); // Check if should include hidden files, $h parameter if ($h == false) { $results = array_filter($results, create_function('$a', 'return ($a[0]!=".");')); } // done! return $results; } function xmlOut($con, $tag) { return "<" . $tag . ">" . $con . "</" . $tag . ">"; } function cdat($dat) { return "<![CDATA[" . $dat . "]]>"; } //---------- MAIN ------------- loadProb(); runProb(); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo "<result>"; echo xmlOut("compiler", "TYPE"); echo xmlOut(cdat($code), "CODE"); echo xmlOut(cdat($input), "INPUT"); echo xmlOut(cdat($uOutput), "uOutput"); //echo xmlOut($LOG,"LOG"); echo "</result>";
if (is_writable($fullFile)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!($handle = fopen($fullFile, 'w'))) { //echo "Cannot open file ($fullFile)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $code) === FALSE) { //echo "Cannot write to file ($fullFile)"; exit; } //echo "Success, wrote ($code) to file ($fullFile)"; fclose($handle); } else { //echo "The file $fullFile is not writable"; } } function xmlOut($con, $tag) { return "<" . $tag . ">" . $con . "</" . $tag . ">"; } //---------- MAIN ------------- echo '<?xml version="1.0" encoding="UTF-8"?>'; echo "<result>"; echo xmlOut("compiler", "TYPE"); echo xmlOut($code, "CODE"); echo xmlOut($input, "INPUT"); echo xmlOut($uOutput, "uOutput"); echo "</result>";
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Methods: GET"); //now display the output in a way that is useable switch (strtolower($output_type)) { case 'json': $app->contentType("application/json; charset=utf-8"); if (isset($_GET["callback"]) && Util::isValidCallback($_GET["callback"])) { header("X-JSONP: true"); echo $_GET["callback"] . '(' . json_encode($output, JSON_NUMERIC_CHECK) . ')'; } else { echo json_encode($output, JSON_NUMERIC_CHECK); } break; case 'xml': $app->contentType("text/xml; charset=utf-8"); echo xmlOut($output); break; default: throw new Exception("Invalid return type. Please read API Information."); break; } function xmlOut($output) { //define how long it should be cached for $cachedUntil = date("Y-m-d H:i:s", strtotime("+1 hour")); //start building our xml document $xml = '<?xml version="1.0" encoding="UTF-8"?>'; $xml .= '<eveapi version="2" zkbapi="1">'; $xml .= '<currentTime>' . date('Y-m-d H:i:s') . '</currentTime>'; $xml .= '<result>'; if (!empty($output)) {
return 'selected="selected"'; } else { return ""; } } function xmlOut($con, $tag) { return "<" . $tag . ">" . $con . "</" . $tag . ">"; } function cdat($dat) { return "<![CDATA[" . $dat . "]]>"; } // ---------- MAIN -------- $allProblems = getDirectoryList("{$topDir}/HYPC/ProblemZone/Problems/", false); loadProb(); loadCode(); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo "<result>"; echo xmlOut("loader", "TYPE"); echo xmlOut($pname, "pname"); echo "<pSelect><![CDATA["; echo optionsFromArray($allProblems, $pname); // Problems to select // echo "Test"; echo "]]></pSelect>"; echo xmlOut(cdat($probInfo), "probInfo"); // Problem info echo xmlOut(cdat($code), "code"); // Problem code echo "</result>";