+++ /dev/null
-<?php\r
-/*\r
- This is the main page for the ATutor+Mahara module page.\r
- It checks if the current user is registered with Mahara by checking\r
- ATutor's 'mahara' table. If registered, an iframe is created to display\r
- the Mahara page ('mahara_login.php', a login script to the page also gets called).\r
- If not registered, 'new_account.php' is called which automatically sets up an\r
- account with Mahara and saves the user information in ATutor's mahara table.\r
- The page then automatically gets refreshed.\r
-\r
- by: Boon-Hau Teh\r
-*/\r
-\r
-\r
-$_user_location = 'public';\r
-\r
-ob_start(); // we need this to be able to set cookies\r
-\r
-define('AT_INCLUDE_PATH', '../../include/');\r
-require (AT_INCLUDE_PATH.'vitals.inc.php');\r
-\r
-\r
-if ($_SESSION['is_guest'])\r
- $msg->addFeedback ("MAHARA_LOGIN");\r
-\r
-require (AT_INCLUDE_PATH.'header.inc.php');\r
-\r
-\r
-// Check if user is logged in as a guest\r
-if (!($_SESSION['is_guest'])) {\r
- // Read login info for Mahara\r
- $sql = "SELECT username, SHA1(password) FROM ".TABLE_PREFIX."mahara WHERE at_login='".$_SESSION['login']."'";\r
- $result = mysql_query($sql, $db);\r
-\r
-\r
- if (!($row = @mysql_fetch_array($result))) {\r
- define('new_account', 1);\r
-\r
- // if not configured with ATutor, automatically register for account now\r
- require('new_account.php');\r
-\r
- // refresh the page\r
- header('Location: index.php');\r
-\r
- } else {\r
- $username = $row[0];\r
- $password = $row[1];\r
-\r
- // Login\r
- ?>\r
-\r
- <?php\r
- ATutor.setcookie("ATutor_Mahara[at_login]", $_SESSION['login'], time()+1200); \r
- ATutor.setcookie("ATutor_Mahara[username]", $username, time()+1200); \r
- ATutor.setcookie("ATutor_Mahara[password]", $password, time()+1200); \r
-\r
-\r
- if (function_exists('url_rewrite')) { // if "pretty url" feature supported (from ATutor 1.6.1)\r
- $url = url_rewrite('mods/mahara/mahara_login.php', AT_PRETTY_URL_IS_HEADER); // to be directly called in an iframe\r
- $url_cookie_forward = url_rewrite('mods/mahara/cookie.php', AT_PRETTY_URL_IS_HEADER); // to be used in a new window and redirect to mahara_login.php\r
- } else {\r
- $url = AT_BASE_HREF.'mods/mahara/mahara_login.php';\r
- $url_cookie_forward = AT_BASE_HREF.'mods/mahara/cookie.php';\r
- }\r
-\r
- ?>\r
- <script language='javascript' type='text/javascript'>\r
- function iFrameHeight() {\r
- var h = 0;\r
- if ( !document.all ) {\r
- h = document.getElementById('ATutorMahara').contentDocument.height;\r
- document.getElementById('ATutorMahara').style.height = h + 60 + 'px';\r
- } else if( document.all ) {\r
- h = document.frames('ATutorMahara').document.body.scrollHeight;\r
- document.all.ATutorMahara.style.height = h + 20 + 'px';\r
- }\r
- }\r
- function stopFrame(url, name, button) {\r
- // close iframe\r
- var ifr = document.getElementById(name);\r
- if (ifr)\r
- ifr.parentNode.removeChild(ifr);\r
-\r
- // disable button\r
- var btn = document.getElementById(button);\r
- if (btn) {\r
- btn.value = '<?=_AT('mahara_opened')?>';\r
- btn.disabled = true;\r
- }\r
-\r
- // open in new window\r
- window.open(url);\r
- }\r
- </script>\r
- <div align="center">\r
- <input type="button" name="new_win" id="new_win" value= "<?=_AT('mahara_new_win')?>" onClick="stopFrame('<?php echo $url_cookie_forward;?>', 'ATutorMahara', 'new_win')" class="button" /><br /><br />\r
- </div>\r
- <iframe onload='iFrameHeight()' id='ATutorMahara' name='ATutorMahara'\r
- src='<?=$url?>' width='100%' height='500' scrolling='auto' align='top' frameborder='0'>\r
- </iframe>\r
- <?php\r
- }\r
-}\r
-\r
-ob_end_flush();\r
-\r
-?>\r
-\r
-<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>\r