Пример #1
0
<?php

error_reporting(E_ALL & ~E_NOTICE);
ini_set("display_errors", 1);
// Load up the LTI Support code
require_once 'util/lti_util.php';
require_once 'util/mimeparse.php';
session_start();
header('Content-Type: text/html; charset=utf-8');
// Initialize, all secrets are 'secret', do not set session, and do not redirect
$key = isset($_POST['oauth_consumer_key']) ? $_POST['oauth_consumer_key'] : false;
$secret = "secret";
$_SESSION['oauth_consumer_key'] = $_POST['oauth_consumer_key'];
$_SESSION['secret'] = "secret";
$context = new BLTI($secret, false, false);
?>
<html>
<head>
  <title>Sakai External Tool API Test Harness</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body style="font-family:sans-serif; background-color:#add8e6">
<?php 
echo "<p><b>Sakai External Tool API Test Harness</b></p>\n";
$sourcedid = $_REQUEST['lis_result_sourcedid'];
if (get_magic_quotes_gpc()) {
    $sourcedid = stripslashes($sourcedid);
}
if ($context->valid) {
    print "<p style=\"color:green\">Launch Validated.<p>\n";
    if ($_POST['launch_presentation_return_url']) {
Пример #2
0
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * The main entry point for the external system.
 *
 * @package    enrol_lti
 * @copyright  2016 Mark Nelson <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(__FILE__) . '/../../config.php';
require_once $CFG->dirroot . '/user/lib.php';
require_once $CFG->dirroot . '/enrol/lti/ims-blti/blti.php';
$toolid = required_param('id', PARAM_INT);
// Get the tool.
$tool = \enrol_lti\helper::get_lti_tool($toolid);
// Create the BLTI request.
$ltirequest = new BLTI($tool->secret, false, false);
// Correct launch request.
if ($ltirequest->valid) {
    // Check if the authentication plugin is disabled.
    if (!is_enabled_auth('lti')) {
        print_error('pluginnotenabled', 'auth', '', get_string('pluginname', 'auth_lti'));
        exit;
    }
    // Check if the enrolment plugin is disabled.
    if (!enrol_is_enabled('lti')) {
        print_error('enrolisdisabled', 'enrol_lti');
        exit;
    }
    // Check if the enrolment instance is disabled.
    if ($tool->status != ENROL_INSTANCE_ENABLED) {
        print_error('enrolisdisabled', 'enrol_lti');
Пример #3
0
<?php

error_reporting(E_ALL & ~E_NOTICE);
ini_set("display_errors", 1);
// Load up the LTI Support code
require_once 'util/lti_util.php';
session_start();
header('Content-Type: text/html; charset=utf-8');
// Initialize, all secrets are 'secret', do not set session, and do not redirect
$context = new BLTI("secret", false, false);
?>
<html>
<head>
  <title>Sakai External Tool API Test Harness</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body style="font-family:sans-serif; background-color:#add8e6">
<?php 
echo "<p><b>Sakai External Tool API Test Harness</b></p>\n";
$sourcedid = $_REQUEST['lis_result_sourcedid'];
if (get_magic_quotes_gpc()) {
    $sourcedid = stripslashes($sourcedid);
}
$sourcedid = htmlentities($sourcedid);
if ($context->valid) {
    if ($_POST['launch_presentation_return_url']) {
        $msg = 'A%20message%20from%20the%20tool%20provider.';
        $error_msg = 'An%20error%20message%20from%20the%20tool%20provider.';
        $sep = strpos($_POST['launch_presentation_return_url'], '?') === FALSE ? '?' : '&amp;';
        print "<p><a href=\"{$_POST['launch_presentation_return_url']}\">Return to tool consumer</a> (";
        print "<a href=\"{$_POST['launch_presentation_return_url']}{$sep}lti_msg={$msg}&amp;lti_log=LTI%20log%20entry:%20{$msg}\">with a message</a> or ";
Пример #4
0
    $domain = $_REQUEST['custom_canvas_api_domain'];
}
if (empty($domain)) {
    $domain = $_COOKIE['domain'];
} else {
    //lost the POST vars when we redirected
    setcookie('domain', $domain, 0, '/');
}
include "/home/bkinney/includes/lti_mysqli.php";
include '../ims-blti/blti.php';
//no token query here anymore - require_once was causing a problem?
include '../canvasapi.php';
//'/home/bkinney/includes/get_ud_canvas_endpoint_paginate.php';
//change this to look up in db
//try this with the redirect. Does that help with masquerading??/
$context = new BLTI($secret, true, false);
//secret is set in the including page
if ($context->valid) {
    //set some session variables
    //die();
    $context_id = $context->info['context_id'];
    //$domain =$context->info['custom_canvas_api_domain'];
    $isAdmin = $context->isAdministrator();
    setcookie("context", $context_id, 0, '/');
    setcookie("isAdmin", $isAdmin, 0, '/');
    setcookie("lti_url", "https://apps.ats.udel.edu" . $_SERVER['PHP_SELF'], 0, '/');
    if (isset($token)) {
        //this should alway be false
        $api = new CanvasAPI($token, $domain, $context->info['custom_canvas_user_id']);
        $valid = $api->ready;
    } else {
Пример #5
0
    // Initialize, no secret, pull from session, and do not redirect
    $context = new BLTI(false, true, false);
    if (isset($_SESSION['oauth_consumer_key']) && isset($_SESSION['oauth_consumer_secret'])) {
        $oauth_consumer_key = $_SESSION['oauth_consumer_key'];
        $oauth_consumer_secret = $_SESSION['oauth_consumer_secret'];
    }
} else {
    if (isset($_POST['oauth_consumer_key'])) {
        $oauth_comsumer_key = $_POST['oauth_consumer_key'];
        require_once 'keys.php';
        if (isset($LTI_KEYS[$oauth_consumer_key])) {
            $oauth_consumer_secret = $LTI_KEYS[$oauth_consumer_key];
        }
    }
    // Initialize, all secrets are 'secret', set session, and do not redirect
    $context = new BLTI($oauth_consumer_secret, true, false);
    if (!$context->valid) {
        echo "<h1>Error: Incorrect LTI secret</h1>";
        return;
    }
    $_SESSION['oauth_consumer_secret'] = $oauth_consumer_secret;
    $_SESSION['oauth_consumer_key'] = $oauth_consumer_key;
}
?>
<!DOCTYPE html>
<html>
<head>
<?php 
require_once "header.php";
require_once "exercises.php";
$QTEXT = 'Please write a Python program to open the file 
Пример #6
0
        return false;
    if ($newuser->timezone != $olduser->timezone)
        return false;
    if ($newuser->maildisplay != $olduser->maildisplay)
        return false;
    if ($newuser->mnethostid != $olduser->mnethostid)
        return false;
    if ($newuser->confirmed != $olduser->confirmed)
        return false;
    if ($newuser->lang != $olduser->lang)
        return false;
    return true;
}

// Do not set session, do not redirect
$context = new BLTI($tool->secret, false, false);

// Correct launch request
if ($context->valid) {

    // Check that we can perform enrolments
    if (enrol_is_enabled('manual')) {
        $manual = enrol_get_plugin('manual');
    } else {
        print_error('nomanualenrol', 'local_ltiprovider');
    }

    // Transform to utf8 all the post and get data
    $textlib = textlib_get_instance();
    foreach ($_POST as $key => $value) {
        $_POST[$key] = $textlib->convert($value, $tool->encoding);
Пример #7
0
<?php

require_once "setup.php";
// Load up the LTI Support code
require_once 'util/lti_util.php';
session_start();
// Initialize, no secret, pull from session, and do not redirect
$context = new BLTI(false, true, false);
if (!$context->valid) {
    echo json_encode(array("status" => "failure", "detail" => "No context in session"));
    return;
}
$endpoint = $context->getOutcomeService();
if ($endpoint === false) {
    echo json_encode(array("status" => "failure", "detail" => "No grade service available"));
    return;
}
$sourcedid = $context->getOutcomeSourceDID();
if ($sourcedid === false) {
    echo json_encode(array("status" => "failure", "detail" => "No grade entry available"));
    return;
}
if (isset($_SESSION['oauth_consumer_key']) && isset($_SESSION['oauth_consumer_secret'])) {
    $oauth_consumer_key = $_SESSION['oauth_consumer_key'];
    $oauth_consumer_secret = $_SESSION['oauth_consumer_secret'];
} else {
    echo json_encode(array("status" => "failure", "detail" => "No key/secret in session"));
    return;
}
$method = "POST";
$content_type = "application/xml";
}
//echo "cookie=" . $_COOKIE['domain'];
$testing = $domain == "udel.test.instructure.com";
if (empty($_COOKIE['context_id'])) {
    setcookie('context_id', $_REQUEST['context_id'], 0, '/');
}
include "/home/bkinney/includes/lti_mysqli.php";
require_once 'ims-blti/blti.php';
//this is the beta version
include 'canvasapi.php';
//this is the beta version
//'/home/bkinney/includes/get_ud_canvas_endpoint_paginate.php';
//change this to look up in db
//changelog - use same secret for all
$secret = array("table" => "blti_keys", "key_column" => "oauth_consumer_key", "secret_column" => "secret", "context_column" => "context_id");
$context = new BLTI($secret, true, false);
//try redirect
if ($context->valid) {
    //set some session variables
    //echo "valid";
    //die();
    $context_id = $context->info['context_id'];
    //echo $context_id;
    //these are used to update db by get_token_domain
    $isAdmin = $context->isAdministrator();
    setcookie("context", $context_id, 0, '/');
    setcookie("isAdmin", $isAdmin, 0, '/');
    setcookie("lti_url", "https://apps.ats.udel.edu" . $_SERVER['PHP_SELF'], 0, '/');
    //changelog - get token from token table
    $shared = array_key_exists('custom_shared', $context->info);
    //this is a Haywood J token. He is an instructor in Becky Test
Пример #9
0
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
ini_set('session.use_cookies', '0');
try {
    session_start();
} catch (Exception $e) {
    $warning_session = true;
}
error_reporting(E_ALL & ~E_NOTICE);
ini_set("display_errors", 1);
// Load up the Basic LTI Support code
require_once '../ims-blti/blti.php';
// Establish the database connnection
require_once "db.php";
// Establish the context
$context = new BLTI(array('table' => 'blti_keys'));
if ($context->complete) {
    exit;
}
if (!$context->valid) {
    print "Could not establish context: " . $context->message . "<p>\n";
    exit;
}
// Start of the ad code
$self = $context->addSession($_SERVER['PHP_SELF']);
if (strpos($self, '?') > 0) {
    $selfp = $self . '&';
} else {
    $selfp = $self . '?';
}
$action = $_REQUEST['action'];
Пример #10
0
require_once dirname(__FILE__) . "/ltilib.php";
require_login();
$context = context_system::instance();
$key = $CFG->equella_lti_oauth_key;
$secret = $CFG->equella_lti_oauth_secret;
$returnurl = optional_param('launch_presentation_return_url', '', PARAM_URL);
$sourcedid = optional_param('lis_result_sourcedid', '', PARAM_RAW);
$outcomeurl = optional_param('lis_outcome_service_url', '', PARAM_URL);
$title = 'IMS Learning Tools Interoperability 1.1';
$heading = 'IMS LTI 1.1 PHP Provider';
$PAGE->set_context($context);
$PAGE->set_pagelayout('embedded');
$PAGE->set_url('/mod/equella/tools/lti.php');
echo $OUTPUT->header();
// Initialize, all secrets are 'secret', do not set session, and do not redirect
$lticontext = new BLTI($key, $secret, false, false);
echo $OUTPUT->heading($heading, 5);
if ($lticontext->valid) {
    if (!empty($returnurl)) {
        $links = array();
        $msg = 'A message from the tool provider.';
        $error_msg = 'An error message from the tool provider.';
        $url = new moodle_url($returnurl);
        $links[] = html_writer::link($url, 'Return to tool consumer');
        $url->param('lti_msg', $msg);
        $url->param('lti_log', 'LTI log entry');
        $links[] = html_writer::link($url, 'Return to tool consumer with a message');
        $url->remove_params(array('lti_msg', 'lti_log'));
        $url->param('lti_errormsg', $error_msg);
        $url->param('lti_errorlog', 'LTI error entry: ' . $error_msg);
        $links[] = html_writer::link($url, 'Return to tool consumer with an error');
Пример #11
0
<?php

error_reporting(E_ALL & ~E_NOTICE);
ini_set("display_errors", 1);
// Load up the LTI Support code
require_once 'util/lti_util.php';
session_start();
header('Content-Type: text/html; charset=utf-8');
// Initialize, all secrets are 'secret', do not set session, and do not redirect
$context = new BLTI("secret", false, false);
?>
<html>
<head>
  <title>IMS Learning Tools Interoperability 1.1</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body style="font-family:sans-serif; background-color:#add8e6">
<?php 
echo "<p><b>IMS LTI 1.1 PHP Provider</b></p>\n";
echo "<p>This is a very simple reference implementaton of the Tool side (i.e. provider)\nfor IMS LTI 1.1.</p>\n";
$sourcedid = $_REQUEST['lis_result_sourcedid'];
if (get_magic_quotes_gpc()) {
    $sourcedid = stripslashes($sourcedid);
}
$sourcedid = urlencode($sourcedid);
if ($context->valid) {
    if ($_POST['launch_presentation_return_url']) {
        $msg = 'A%20message%20from%20the%20tool%20provider.';
        $error_msg = 'An%20error%20message%20from%20the%20tool%20provider.';
        $sep = strpos($_POST['launch_presentation_return_url'], '?') === FALSE ? '?' : '&amp;';
        print "<p><a href=\"{$_POST['launch_presentation_return_url']}\">Return to tool consumer</a> (";
/**
 * BLTI
 *
 * @file
 * @ingroup Extensions
 * @version 0.1
 * @author Charles Severance based on for from Antoni Bertran and Jose Diago
 */
$going2MW = false;
// BLTI integration
require_once 'IMSBasicLTI/ims-blti/blti.php';
if (!is_basic_lti_request()) {
    return;
}
//Let's get the user's data
$context = new BLTI("secret", false, false);
if ($context->valid) {
    $agentCourse = $context->getCourseName();
    $agentUserName = $context->getUserShortName();
    $agentEmail = $context->getUserEmail();
    $agentFullName = $context->getUserName();
    $going2MW = true;
    session_start();
    $_SESSION['BLTIclassroom'] = $agentCourse;
} else {
    echo 'Error validating: ' . $context->message;
}
$context = null;
if ($going2MW) {
    $myURI = $_SERVER['REQUEST_URI'];
    $newURI = str_replace("extensions/Redirect2CourseBLTI.php", "index.php", $myURI);
<?php

// Load up the LTI Support code
require_once 'ims-blti/blti.php';
// Set error reporting
error_reporting(E_ALL & ~E_NOTICE);
ini_set("display_errors", 1);
// Start the session and send basic HTTP headers.
session_start();
header('Content-Type: text/html; charset=utf-8');
// Initialize, all secrets are 'secret', do not set session, and do not redirect.
$context = new BLTI("secret", false, false);
// Sort the POST array, just for kicks.
ksort($_POST);
// That's it! As long as the appropriate POST values are submitted, we
// have a valid LTI request. We can now write our PHP code to handle the
// web page.
?>

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <link rel="stylesheet" type="text/css" href="css/default.css" />
    <link rel="stylesheet" type="text/css" href="css/helloharvard.css" />
    <title>Hello, Harvard!</title>
  </head>
  
  <body>
    <div id="page-wrapper">
      <header class="header-footer">
Пример #14
0
<?php 
include '/home/bkinney/includes/lti_mysqli.php';
include "../ims-blti/blti.php";
$secret = array("table" => "tokens", "key_column" => "consumer_key", "secret_column" => "secret", "context_column" => "context");
$context = new BLTI($secret, true, false);
//do this elsewhere
//print_r($context->info);
$instructor = false;
session_start();
if ($context->valid) {
    $instructor = $_SESSION['isInstructor'] = $context->isInstructor();
    $contextid = $_SESSION['contextid'] = $context->info['context_id'];
    $uid = $_SERVER['uid'] = $context->info['lis_person_sourcedid'];
} else {
    $instructor = $_SESSION['isInstructor'];
    $uid = $_SESSION['uid'];
    $contextid = $_SESSION['contextid'];
}
if (!empty($_FILES["postemfile"])) {
    $instructor = true;
    $data = '<table class="stickyHeader" ><thead>';
    $handle = fopen($_FILES["postemfile"]["tmp_name"], "r");
    $cols = fgetcsv($handle, 10000, ",");
    //just the first row
    $data .= "<tr><th>" . implode("</th><th>", $cols) . "</th></tr>";
    $data .= "</thead><tbody>";
    while (($cols = fgetcsv($handle, 10000, ",")) !== FALSE) {
        $clean = array_map(htmlspecialchars, $cols);
        $data .= "<tr><td>" . implode("</td><td>", $clean) . "</td></tr>";
    }
    $data .= "</tbody></table>";
Пример #15
0
require_once $CFG->dirroot . '/local/ltiprovider/ims-blti/blti.php';
$toolid = optional_param('id', 0, PARAM_INT);
$lticontextid = optional_param('context_id', false, PARAM_RAW);
$custom_create_context = optional_param('custom_create_context', false, PARAM_RAW);
// Temporary context.
$mycontext = new stdClass();
$mycontext->info = array();
$mycontext->info['context_id'] = optional_param('context_id', false, PARAM_RAW);
$mycontext->info['context_title'] = optional_param('context_title', false, PARAM_RAW);
$mycontext->info['context_label'] = optional_param('context_label', false, PARAM_RAW);
$mycontext->info['oauth_consumer_key'] = optional_param('oauth_consumer_key', false, PARAM_RAW);
$mycontext->info['resource_link_id'] = optional_param('resource_link_id', false, PARAM_RAW);
if (optional_param('custom_lti_message_encoded_base64', 0, PARAM_INT) == 1) {
    $lticontextid = base64_decode($lticontextid);
    $custom_create_context = base64_decode($custom_create_context);
    $blti = new BLTI(false, false, false);
    $mycontext->info = $blti->decodeBase64($mycontext->info);
}
if (!$toolid and !$lticontextid) {
    print_error('invalidtoolid', 'local_ltiprovider');
}
if (!$toolid and $lticontextid) {
    // Check if there is more that one course for this LTI context id.
    $idnumber = local_ltiprovider_get_new_course_info('idnumber', $mycontext);
    if ($DB->count_records('course', array('idnumber' => $idnumber)) > 1) {
        print_error('cantdeterminecontext', 'local_ltiprovider');
    }
    if ($course = $DB->get_record('course', array('idnumber' => $idnumber))) {
        // Look for a course created for this LTI context id.
        if ($coursecontext = context_course::instance($course->id)) {
            if ($DB->count_records('local_ltiprovider', array('contextid' => $coursecontext->id)) > 1) {
Пример #16
0
<?php 
include '/home/bkinney/includes/lti_mysqli.php';
include "../ims-blti/blti.php";
$secret = array("table" => "tokens", "key_column" => "consumer_key", "secret_column" => "secret", "context_column" => "context");
$context = new BLTI($secret, true, false);
//do this elsewhere
//print_r($context);
$instructor = false;
if ($context->valid) {
    $instructor = $context->isInstructor();
}
if (!empty($_FILES["postemfile"])) {
    $instructor = true;
    $data = file_get_contents($_FILES["postemfile"]["tmp_name"]);
    $query = sprintf("insert into files (context_id,postem) values('%s','%s') on duplicate key update postem=values(postem)", $_POST['context_id'], mysqli_real_escape_string($link, $data));
    //echo $query;
    $response = mysqli_query($link, $query);
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
body,td,th {
	font-family: Verdana, Geneva, sans-serif;
}
h1,h2,h3,h4 {
	
	color:#2e6e9e;