changed git call from https to git readonly
[atutor.git] / mods / tle / assembler.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2006 by Greg Gay & Joel Kronenberg        */
6 /* Adaptive Technology Resource Centre / University of Toronto  */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 // $Id: index.php 5901 2006-02-07 17:13:41Z joel $
14
15 define('AT_INCLUDE_PATH', '../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17
18 function createToken ($token, $sharedSecret) {
19         //String time = Long.toString(System.currentTimeMillis());
20         $time = mktime() . '000';
21
22         //String toMd5 = token+time+sharedSecret;
23         $toMd5 = $token . $time . $sharedSecret;
24
25         //String enctoken = URLEncoder.encode(token, "UTF-8");
26         $enctoken = urlencode($token);
27
28         //byte[] bytes = new Md5(toMd5).getDigest();
29         $bytes = pack('H*', md5($toMd5));
30         
31         //BASE64Encoder encoder = new BASE64Encoder();
32         //String fullToken = enctoken+':'+time+':'+encoder.encode(bytes);
33
34         $fullToken = $enctoken . ':' . $time . ':' . base64_encode($bytes);
35
36         return $fullToken;
37 }
38
39 require (AT_INCLUDE_PATH.'header.inc.php');
40 ?>
41
42
43 <?php
44 if (!isset($_config['tle_server']) || !$_config['tle_server']) {
45         $msg->printErrors('TLE_MISSING_SERVER');
46 } else {
47         $callback = $_base_href . 'mods/tle/import.php?';
48
49         $url = $_config['tle_server'] . '?method=lms'
50                                 . '&returnurl=' . urlencode($callback)
51                                 . '&action=searchPlans'
52                                 . '&returnprefix=tle'
53                                 . '&template=standard'
54                                 . '&token=' . urlencode(createToken($_config['tle_username'], $_config['tle_secret']));
55         echo '<iframe src="'. $url . '" width="620" height="600" frameborder="0" /></iframe>';
56 }
57 require(AT_INCLUDE_PATH.'footer.inc.php');
58 ?>