changed git call from https to git readonly
[atutor.git] / mods / mahara / cookie.php
1 <?php\r
2 /*\r
3     Called by index.php when user opens a new window.\r
4     To avoid conflicting sessions between ATutor and Mahara,\r
5     we are passing information through temporary cookies.\r
6     This page simply acts as a bridge between ATutor and Mahara\r
7     by using the ATutor session to read the user login from the \r
8     database, then setting the cookies and forwarding to\r
9     the login script (mahara_login.php).\r
10 \r
11     by: Boon-Hau Teh\r
12 */\r
13 \r
14 $_user_location = 'public';\r
15 \r
16 define('AT_INCLUDE_PATH', '../../include/');\r
17 require (AT_INCLUDE_PATH.'vitals.inc.php');\r
18 \r
19 // Read login info for Mahara\r
20 $sql    = "SELECT username, SHA1(password) FROM ".TABLE_PREFIX."mahara WHERE at_login='".$_SESSION['login']."'";\r
21 $result = mysql_query($sql, $db);\r
22 \r
23 if ($row = @mysql_fetch_array($result)) {\r
24     ATutor.setcookie("ATutor_Mahara[at_login]", $_SESSION['login'], time()+1200); \r
25     ATutor.setcookie("ATutor_Mahara[username]", $row[0], time()+1200); \r
26     ATutor.setcookie("ATutor_Mahara[password]", $row[1], time()+1200); \r
27 \r
28     if (function_exists('url_rewrite')) {   // if "pretty url" feature supported (from ATutor 1.6.1)\r
29         $url = url_rewrite('mods/mahara/mahara_login.php', AT_PRETTY_URL_IS_HEADER);\r
30     } else {\r
31         $url = AT_BASE_HREF.'mods/mahara/mahara_login.php';\r
32     }\r
33 \r
34     // proceed to login script\r
35     header('Location: '.$url);\r
36 }\r
37 \r
38 ?>