Repository navigation
Expand file tree
/
Copy pathezproxy.php
More file actions
64 lines (55 loc) · 1.43 KB
/
Copy pathezproxy.php
File metadata and controls
64 lines (55 loc) · 1.43 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/*
Plugin Name: EZProxy Shortcode
Plugin URI: http://www.delputnam.com/plugins/ezproxy.zip
Description: Provides a shortcode that generates an EZProxy ticket and link.
Version: 1.0
Author: Del Putnam
Author URI: http://www.delputnam.com
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
class EZproxyTicket {
var $EZproxyStartingPointURL;
function EZproxyTicket(
$EZproxyServerURL,
$secret,
$user,
$groups = "")
{
if (strcmp($secret, "") == 0) {
echo("EZproxyURLInit secret cannot be blank");
exit(1);
}
$packet = '$u' . time();
if (strcmp($groups, "") != 0) {
$packet .= '$g' . $groups;
}
$packet .= '$e';
$EZproxyTicket = urlencode(md5($secret . $user . $packet) . $packet);
$this->EZproxyStartingPointURL = $EZproxyServerURL . "/login?user=" .
urlencode($user) . "&ticket=" . $EZproxyTicket;
}
function URL($url)
{
return $this->EZproxyStartingPointURL . "&url=" . $url;
}
}
function ezproxy_shortcode( $atts ) {
extract( shortcode_atts( array(
'proxy' => null,
'url' => null,
'userid' => null,
'userguid' => false,
'secret' => null
), $atts ) );
if ( $userguid ) {
if ( !empty( $userid ) ) {
$userid = $userid . '_';
}
$userid = uniqid( $userid, true );
}
$ezproxy = new EZproxyTicket( $proxy, $secret, $userid );
return $ezproxy->url( $url );
}
add_shortcode( 'ezproxy', 'ezproxy_shortcode' );