<?php
include_once('config.php');
include_once($phpcas_path.'/CAS.php');
phpCAS::setDebug();
phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
header('HTTP/1.1 400 Bad Request');
print "<h1>I only respond to POST requests. This is a ".$_SERVER['REQUEST_METHOD']." request.</h1>";
exit;
}
if (empty($_POST['favorite_color'])) {
header('HTTP/1.1 400 Bad Request');
print '<h1>You must post a <strong>favorite_color</strong>.</h1>';
exit;
}
print '<h1>I am a service that responds to POST requests.</h1>';
include 'script_info.php';
echo '<p>The user\'s login is <b>'.phpCAS::getUser().'</b>.</p>';
print '<h1>Your favorite color is '.htmlentities($_POST['favorite_color']).'</h1>';
if (!isset($_SESSION['n']))
$_SESSION['n'] = 0;
echo '<p>request #'.(++$_SESSION['n']).'</p>';