This method is used to access an HTTP[S] service.
public static serviceWeb ( string $url, &$err_code, &$output ) : boolean | ||
$url | string | the service to access. |
Результат | boolean | true on success, false otherwise (in this later case, $err_code gives the reason why it failed and $output contains an error message). |
function getConnexionBar() { if (CASUser::checkAuth()) { $service = SITE_CAS_CONNEXIONBAR_URL; phpCAS::serviceWeb($service, $err_code, $output); $xml = simplexml_load_string($output); $result = $xml->xpath('/reportoutput/reportdata'); return html_entity_decode($result[0]->asXML()); } else { return ""; } }
function getConnexionBar() { if (CASUser::checkAuth()) { $service = SITE_CAS_CONNEXIONBAR_URL; phpCAS::serviceWeb($service, $err_code, $output); $xml = simplexml_load_string($output); $result = $xml->xpath('/reportoutput/reportdata'); return str_replace("https://signin.mygcx.org/cas/logout", "https://intranet.campusforchrist.org/index.php?p_Mod=Logout", html_entity_decode($result[0]->asXML())); } else { return ""; } }
<title>phpCAS proxied proxy example (with sessioning)</title> <link rel="stylesheet" type='text/css' href='example.css'/> </head> <body> <h1>phpCAS proxied proxy example (with sessioning)</h1> <?php include 'script_info.php'; ?> <p>the user's login is <b><?php echo phpCAS::getUser(); ?> </b>.</p> <h2>Response from service <?php echo $serviceUrl; ?> </h2> <?php flush(); // call a service and change the color depending on the result if (phpCAS::serviceWeb($serviceUrl, $err_code, $output)) { echo '<div class="success">'; } else { echo '<div class="error">'; } echo $output; echo '</div>'; ?> </body> </html>
$_SESSION['phpCAS']['service_cookies'] = array(); } $sm = $_SESSION['ovd-client']['sessionmanager']; foreach ($sm->get_cookies() as $k => $v) { $cookie = array('domain' => parse_url($sm->get_base_url(), PHP_URL_HOST), 'path' => '/', 'secure' => false, 'name' => $k, 'value' => $v); $_SESSION['phpCAS']['service_cookies'][] = $cookie; } } $port = parse_url($CAS_server_url, PHP_URL_PORT); if (is_null($port)) { if (parse_url($CAS_server_url, PHP_URL_SCHEME) == 'https') { $port = 443; } else { $port = 80; } } $path = !parse_url($CAS_server_url, PHP_URL_PATH) ? '' : parse_url($CAS_server_url, PHP_URL_PATH); phpCAS::proxy(CAS_VERSION_2_0, parse_url($CAS_server_url, PHP_URL_HOST), $port, $path, false); phpCAS::setNoCasServerValidation(); phpCAS::setPGTStorageFile(CAS_PGT_STORAGE_FILE_FORMAT_PLAIN, session_save_path()); phpCAS::setFixedCallbackURL($CAS_callback_url); //HTTPS required, and Apache's CRT must be added in Tomcat's keystore (CAS server) phpCAS::forceAuthentication(); if (!phpCAS::serviceWeb($_SESSION['ovd-client']['sessionmanager_url'] . '/start', $errno, $output)) { $_SESSION['ovd-client']['from_SM_start_XML'] = 'ERROR'; finish(); die; } $_SESSION['ovd-client']['from_SM_start_XML'] = $output; finish(); die;