header("Location: " . $redirect_url); } } else { // Generate form markup and render it. $form_id = 'openid_message'; if (isset($_GET['json'])) { $form_html = $auth_request->formJSON($trust_root, $process_url, false); } else { $form_html = $auth_request->formMarkup($trust_root, $process_url, false, array('id' => $form_id)); } // Display an error if the form markup couldn't be generated; // otherwise, render the HTML. if (Auth_OpenID::isFailure($form_html)) { $error = "Could not redirect to server: " . $form_html->message; if (isset($_GET['json'])) { json_out('{"error":"' . addslashes($error) . '"}'); } include 'index.php'; exit; } else { $page_contents = array("<html><head><title>", "OpenID transaction in progress...", "</title></head>", "<body onload='document.getElementById(\"" . $form_id . "\").submit()'>", $form_html, "</body></html>"); if (isset($_GET['json'])) { json_out($form_html); } print implode("\n", $page_contents); } } if (isset($_GET['json'])) { json_out('{}'); } // This should never happen
$resp = json_decode($hostExecutedLogs_item['resp'], TRUE); $resp_data = ""; if (count($resp) > 0) { foreach ($resp as $resp_index => $resp_item) { $resp_data = $resp_data . "<p><span class=\"name\">" . esc_html($resp_index) . " : </span>" . esc_html($resp_item) . "</p>"; } } $html = $html . "\n\t\t<div class=\"item\">\n\t \t\t<a><span class=\"time\">" . $hostExecutedLogs_item['id'] . " : " . $hostExecutedLogs_item['time'] . " > </span>" . esc_html($hostExecutedLogs_item['cname']) . "</a>\n\t \t\t" . $resp_data . "\n\t \t\t<p><span class=\"name\">Response Time : </span>" . $hostExecutedLogs_item['respTime'] . "</p>\n\t \t</div>\n\t\t"; } json_out(1, "", $html); } else { $hostWaitingLogs = $pmxHost->getLogs($sid); if (!count($hostWaitingLogs) > 0) { json_out(1, "", "<center>Empty</center>"); } $html = ""; $index = 0; foreach ($hostWaitingLogs as $hostWaitingLogs_item) { if ($index >= $top) { break; } $index++; $html = $html . "<div class=\"item\"><a>Waiting : " . $hostWaitingLogs_item['id'] . " : " . $hostWaitingLogs_item["time"] . " > " . esc_html($hostWaitingLogs_item["cname"]) . "</a></div>"; } json_out(1, "", $html); } function json_out($status = 0, $msg = "", $data = "") { header('Content-Type: text/json; charset=utf-8'); die(json_encode(array("status" => "{$status}", "msg" => "{$msg}", "data" => $data))); }
}); on('PUT', '/index', function () { $vars = request_body(); echo "PUT received {$vars['name']}"; }); on('PUT', '/override', function () { echo "PUT received via _method"; }); on('DELETE', '/index/:id', function ($id) { echo "DELETE route test"; }); on('GET', '/json', function () { json_out(array('name' => 'noodlehaus', 'project' => 'dispatch')); }); on('GET', '/jsonp', function () { json_out(array('name' => 'noodlehaus', 'project' => 'dispatch'), 'callback'); }); on('GET', '/redirect/302', function () { redirect('/index'); }); on('GET', '/redirect/301', function () { redirect('/index', 301); }); filter('id', function () { echo "id found"; }); on('GET', '/index/:id', function ($id) { echo "id = {$id}"; }); on('GET', '/cookie-set', function () { cookie('cookie', '123');
/** * 校验用户提交的模块参数是否完整 * * @param unknown $config * 用户提交的模块参数 * @param unknown $config_temp * 系统中的模块参数 * @return boolean */ function validate_addcommand_mod_config($config, $config_sys) { if (!count($config_sys) > 0) { return TRUE; } if (!count($config) > 0) { return FALSE; } $config_var = array(); $config_sys_var = array(); foreach ($config as $config_item) { $config_var[] = $config_item[0]; } foreach ($config_sys as $config_sys_item) { if (!in_array($config_sys_item[0], $config_var)) { json_out(0, "The module config var [" . $config_sys_item[0] . "](" . $config_sys_item[1] . ") could not be NULL."); return FALSE; } } return TRUE; }
<?php include '../../src/dispatch.php'; before(function () { scope('object', ['name' => 'Dispatch', 'type' => 'Framework']); }); on('GET', '/json', function () { json_out(scope('object')); }); on('GET', '/jsonp', function () { json_out(scope('object'), 'callback'); }); dispatch();