mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
Checking in some old changes
This commit is contained in:
parent
9b2831eb77
commit
8a8333860e
sso/hive
@ -1,47 +1,47 @@
|
||||
<?php // $Id$
|
||||
// expired.php - called by hive when the session has expired.
|
||||
|
||||
require('../../config.php');
|
||||
|
||||
require('lib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
//MW theres no easy way to log in seamlessly. We need the users unhashed password.
|
||||
// It's a security risk to carry that in $SESSION so we put up login form.
|
||||
print_header();
|
||||
notify('Your Hive session has expired. Please reauthenticate using your usual Moodle login');
|
||||
?>
|
||||
<form action="login.php" method="post" name="login" id="login">
|
||||
<table border="0" align="center">
|
||||
<tr>
|
||||
<td width="80%">
|
||||
<table align="center" class="loginform">
|
||||
<tr class="username">
|
||||
<td align="right" class="c0">
|
||||
<?php print_string("username") ?>:
|
||||
</td>
|
||||
<td class="c1">
|
||||
<input type="text" name="username" size="15" value="<?php p($frm->username) ?>" alt="<?php print_string("username") ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="password">
|
||||
<td align="right" class="c0">
|
||||
<?php print_string("password") ?>:
|
||||
</td>
|
||||
<td class="c1">
|
||||
<input type="password" name="password" size="15" value="" alt="<?php print_string("password") ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td width="20%">
|
||||
<input type="submit" value="<?php print_string("login") ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br />
|
||||
<?php
|
||||
close_window_button();
|
||||
?>
|
||||
<?php // $Id$
|
||||
// expired.php - called by hive when the session has expired.
|
||||
|
||||
require('../../config.php');
|
||||
|
||||
require('lib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
//MW theres no easy way to log in seamlessly. We need the users unhashed password.
|
||||
// It's a security risk to carry that in $SESSION so we put up login form.
|
||||
print_header();
|
||||
notify('Your session has expired. Please log in again.');
|
||||
?>
|
||||
<form action="login.php" method="post" name="login" id="login">
|
||||
<table border="0" align="center">
|
||||
<tr>
|
||||
<td width="80%">
|
||||
<table align="center" class="loginform">
|
||||
<tr class="username">
|
||||
<td align="right" class="c0">
|
||||
<?php print_string("username") ?>:
|
||||
</td>
|
||||
<td class="c1">
|
||||
<input type="text" name="username" size="15" value="<?php p($frm->username) ?>" alt="<?php print_string("username") ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="password">
|
||||
<td align="right" class="c0">
|
||||
<?php print_string("password") ?>:
|
||||
</td>
|
||||
<td class="c1">
|
||||
<input type="password" name="password" size="15" value="" alt="<?php print_string("password") ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td width="20%">
|
||||
<input type="submit" value="<?php print_string("login") ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br />
|
||||
<?php
|
||||
close_window_button();
|
||||
?>
|
||||
|
147
sso/hive/lib.php
147
sso/hive/lib.php
@ -1,68 +1,79 @@
|
||||
<?php // $Id$
|
||||
// Logs into Hive from HarvestRoad and stores session ID in Moodle session
|
||||
// Martin Dougiamas, Moodle
|
||||
//
|
||||
// Example CFG variables to make this work:
|
||||
|
||||
// $CFG->sso = 'hive';
|
||||
// $CFG->hiveprotocol = 'http';
|
||||
// $CFG->hiveport = '80';
|
||||
// $CFG->hivehost = 'turkey.harvestroad.com.au';
|
||||
// $CFG->hivepath = '/cgi-bin/hive/hive.cgi';
|
||||
// $CFG->hivecbid = '28';
|
||||
|
||||
function sso_user_login($username, $password) {
|
||||
|
||||
global $CFG, $SESSION;
|
||||
|
||||
include($CFG->libdir.'/snoopy/Snoopy.class.inc');
|
||||
|
||||
if (empty($CFG->hivehost)) {
|
||||
return false; // Hive config variables not configured yet
|
||||
}
|
||||
|
||||
/// Set up Snoopy
|
||||
|
||||
$snoopy = new Snoopy;
|
||||
|
||||
$submit_url = $CFG->hiveprotocol .'://'. $CFG->hivehost .':'. $CFG->hiveport .''. $CFG->hivepath ;
|
||||
|
||||
$submit_vars['HIVE_UNAME'] = $username;
|
||||
$submit_vars['HIVE_UPASS'] = $password;
|
||||
$submit_vars['HIVE_ENDUSER']= $username;
|
||||
$submit_vars['HIVE_REQ'] = '2112';
|
||||
$submit_vars['HIVE_REF'] = 'hin:hive@API Login 3';
|
||||
$submit_vars['HIVE_RET'] = 'ORG';
|
||||
$submit_vars['HIVE_REM'] = '';
|
||||
$submit_vars['HIVE_PROD'] = '0';
|
||||
$submit_vars['HIVE_USERIP'] = getremoteaddr();
|
||||
|
||||
|
||||
/// We use POST to call Hive with a bit more security
|
||||
$snoopy->submit($submit_url,$submit_vars);
|
||||
|
||||
/// If there's a bug, we may need to use GET instead
|
||||
/// foreach ($submit_vars as $name => $value) {
|
||||
/// $params[] = "$name=".urlencode($value);
|
||||
/// }
|
||||
/// $submit_url .= '?'.implode('&', $params);
|
||||
/// $snoopy->fetch($submit_url);
|
||||
|
||||
/// Extract HIVE_SESSION from headers
|
||||
|
||||
foreach ($snoopy->headers as $header) {
|
||||
if (strpos($header, 'HIVE_SESSION=') !== false) {
|
||||
$header = explode('HIVE_SESSION=', $header);
|
||||
if (count($header) > 1) {
|
||||
$cookie = explode(';', $header[1]);
|
||||
$cookie = $cookie[0];
|
||||
$SESSION->HIVE_SESSION = $cookie;
|
||||
$SESSION->HIVE_PASSWORD = $password;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; // No cookie found
|
||||
}
|
||||
|
||||
?>
|
||||
<?php // $Id$
|
||||
// Logs into Hive from HarvestRoad and stores session ID in Moodle session
|
||||
// Martin Dougiamas, Moodle
|
||||
//
|
||||
// Example CFG variables to make this work:
|
||||
|
||||
// $CFG->sso = 'hive';
|
||||
// $CFG->hiveprotocol = 'http';
|
||||
// $CFG->hiveport = '80';
|
||||
// $CFG->hivehost = 'turkey.harvestroad.com.au';
|
||||
// $CFG->hivepath = '/cgi-bin/hive/hive.cgi';
|
||||
// $CFG->hivecbid = '28';
|
||||
|
||||
function sso_user_login($username, $password) {
|
||||
|
||||
global $CFG, $SESSION;
|
||||
|
||||
include($CFG->libdir.'/snoopy/Snoopy.class.inc');
|
||||
|
||||
if (empty($CFG->hivehost)) {
|
||||
return false; // Hive config variables not configured yet
|
||||
}
|
||||
|
||||
/// Set up Snoopy
|
||||
|
||||
$snoopy = new Snoopy;
|
||||
|
||||
$submit_url = $CFG->hiveprotocol .'://'. $CFG->hivehost .':'. $CFG->hiveport .''. $CFG->hivepath ;
|
||||
|
||||
$submit_vars['HIVE_UNAME'] = $username;
|
||||
$submit_vars['HIVE_UPASS'] = $password;
|
||||
$submit_vars['HIVE_ENDUSER']= $username;
|
||||
$submit_vars['HIVE_REQ'] = '2112';
|
||||
$submit_vars['HIVE_REF'] = 'hin:hive@API Login 3';
|
||||
$submit_vars['HIVE_RET'] = 'ORG';
|
||||
$submit_vars['HIVE_REM'] = '';
|
||||
$submit_vars['HIVE_PROD'] = '0';
|
||||
$submit_vars['HIVE_USERIP'] = getremoteaddr();
|
||||
|
||||
|
||||
/// We use POST to call Hive with a bit more security
|
||||
$snoopy->submit($submit_url,$submit_vars);
|
||||
|
||||
/// Extract HIVE_SESSION from headers
|
||||
|
||||
foreach ($snoopy->headers as $header) {
|
||||
if (strpos($header, 'HIVE_SESSION=') !== false) {
|
||||
$header = explode('HIVE_SESSION=', $header);
|
||||
if (count($header) > 1) {
|
||||
$cookie = explode(';', $header[1]);
|
||||
$cookie = $cookie[0];
|
||||
$SESSION->HIVE_SESSION = $cookie;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Try again with the guest username and password
|
||||
|
||||
$submit_vars['HIVE_UNAME'] = $CFG->hiveusername;
|
||||
$submit_vars['HIVE_UPASS'] = $CFG->hivepassword;
|
||||
$submit_vars['HIVE_ENDUSER']= $CFG->hiveusername;
|
||||
$snoopy->submit($submit_url,$submit_vars);
|
||||
foreach ($snoopy->headers as $header) {
|
||||
if (strpos($header, 'HIVE_SESSION=') !== false) {
|
||||
$header = explode('HIVE_SESSION=', $header);
|
||||
if (count($header) > 1) {
|
||||
$cookie = explode(';', $header[1]);
|
||||
$cookie = $cookie[0];
|
||||
$SESSION->HIVE_SESSION = $cookie;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false; // No cookie found
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,23 +1,23 @@
|
||||
<?php // $Id$
|
||||
// login.php - action of the login form put up by expired.php.
|
||||
|
||||
require('../../config.php');
|
||||
|
||||
require('lib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
// get the login data
|
||||
$frm = data_submitted('');
|
||||
|
||||
// log back into Hive
|
||||
if (sso_user_login($frm->username, $frm->password)) {
|
||||
|
||||
/// reopen Hive
|
||||
redirect($CFG->wwwroot.'/mod/resource/type/repository/hive/openhive.php');
|
||||
} else {
|
||||
redirect($CFG->wwwroot.'/sso/hive/expired.php');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php // $Id$
|
||||
// login.php - action of the login form put up by expired.php.
|
||||
|
||||
require('../../config.php');
|
||||
|
||||
require('lib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
// get the login data
|
||||
$frm = data_submitted('');
|
||||
|
||||
// log back into Hive
|
||||
if (sso_user_login($frm->username, $frm->password)) {
|
||||
|
||||
/// reopen Hive
|
||||
redirect($CFG->wwwroot.'/mod/resource/type/repository/hive/openlitebrowse.php');
|
||||
} else {
|
||||
redirect($CFG->wwwroot.'/sso/hive/expired.php');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user