-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.php
46 lines (38 loc) · 1.21 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
include "phpCAS/CAS.php";
//phpCAS::setDebug("/home/youportal/tmp/tmp/CAS.log");
phpCAS::setVerbose(true);
phpCAS::client(CAS_VERSION_3_0, $cas_host, $cas_port, $cas_context, "https://".$_SERVER["SERVER_NAME"]."/");
if (file_exists($cas_server_ca_cert_path)) {
phpCAS::setCasServerCACert($cas_server_ca_cert_path);
} else {
phpCAS::setNoCasServerValidation();
}
phpCAS::forceAuthentication();
$login=phpCAS::getUser();
$attrs=phpCAS::getAttributes();
if (array_key_exists("eduPersonPrimaryAffiliation",$attrs)) {
$affil=$attrs['eduPersonPrimaryAffiliation'];
} else {
$affil="guest";
}
if (array_key_exists("displayName",$attrs)) {
$nom=$attrs['displayName'];
} else {
$nom=$login;
}
function echo_link($dest="", $lname="", $myid="") {
if ($myid == "") {
$myid=preg_replace('[^\d\w]','',$lname);
}
if ($lname == "") {
$lname=$dest;
}
if (preg_match('/^frame /',$dest)) {
$myuri=preg_replace('/^frame /','',$dest);
//echo "<a class=\"framable\" onClick=\"load_frame('$myuri');\" href=\"$myuri\" target=\"_$myid\">$lname</a>\n";
echo "<a class=\"framable\" href=\"$myuri\" target=\"_$myid\">$lname</a>\n";
} else {
echo "<a href=\"$dest\" target=\"_$myid\">$lname</a>\n";
}
}