]> git.mjollnir.org Git - moodle.git/commitdiff
Checking in some old changes
authormoodler <moodler>
Thu, 9 Mar 2006 16:45:25 +0000 (16:45 +0000)
committermoodler <moodler>
Thu, 9 Mar 2006 16:45:25 +0000 (16:45 +0000)
sso/hive/expired.php
sso/hive/lib.php
sso/hive/login.php

index 58dd43be2eee16b9db79b2bc4030ae9982551fdd..31dcfe3fa4df3859304da29d4e1d224ba4140520 100644 (file)
@@ -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$\r
+       // expired.php - called by hive when the session has expired.\r
+\r
+    require('../../config.php');\r
+\r
+    require('lib.php');\r
+\r
+    require_login();\r
+\r
+    //MW theres no easy way to log in seamlessly. We need the users unhashed password.\r
+    // It's a security risk to carry that in $SESSION so we put up login form.\r
+    print_header();\r
+    notify('Your session has expired. Please log in again.'); \r
+?>\r
+      <form action="login.php" method="post" name="login" id="login">\r
+        <table border="0" align="center">\r
+        <tr>\r
+          <td width="80%">\r
+            <table align="center" class="loginform">\r
+              <tr class="username">\r
+                <td align="right" class="c0">\r
+                  <?php print_string("username") ?>:\r
+                </td>\r
+                <td class="c1">\r
+                  <input type="text" name="username" size="15" value="<?php p($frm->username) ?>" alt="<?php print_string("username") ?>" />\r
+                </td>\r
+              </tr>\r
+              <tr class="password">\r
+                <td align="right" class="c0">\r
+                  <?php print_string("password") ?>:\r
+                </td>\r
+                <td class="c1">\r
+                  <input type="password" name="password" size="15" value="" alt="<?php print_string("password") ?>" />\r
+                </td>\r
+              </tr>\r
+            </table>\r
+          </td>\r
+          <td width="20%">\r
+            <input type="submit" value="<?php print_string("login") ?>" />\r
+          </td>\r
+        </tr>\r
+        </table>\r
+      </form>\r
+<br />\r
+<?php\r
+    close_window_button();\r
+?>\r
index 5ba3c2f4a3f09dac3e8485a0c59c93c9f283d97c..90c123d0c945deadf296e042d250c750d102dfb1 100755 (executable)
@@ -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$\r
+       // Logs into Hive from HarvestRoad and stores session ID in Moodle session\r
+       // Martin Dougiamas, Moodle\r
+       //\r
+       // Example CFG variables to make this work:\r
+\r
+       // $CFG->sso          = 'hive';\r
+       // $CFG->hiveprotocol = 'http';\r
+       // $CFG->hiveport     = '80';\r
+       // $CFG->hivehost     = 'turkey.harvestroad.com.au';\r
+       // $CFG->hivepath     = '/cgi-bin/hive/hive.cgi';\r
+       // $CFG->hivecbid     = '28';\r
+\r
+function sso_user_login($username, $password) {\r
+\r
+    global $CFG, $SESSION;\r
+\r
+    include($CFG->libdir.'/snoopy/Snoopy.class.inc');\r
+\r
+    if (empty($CFG->hivehost)) {\r
+        return false;   // Hive config variables not configured yet\r
+    }\r
+\r
+/// Set up Snoopy\r
+\r
+    $snoopy = new Snoopy;\r
+\r
+    $submit_url = $CFG->hiveprotocol .'://'. $CFG->hivehost .':'. $CFG->hiveport .''. $CFG->hivepath ;\r
+\r
+    $submit_vars['HIVE_UNAME']  = $username;\r
+    $submit_vars['HIVE_UPASS']  = $password;\r
+    $submit_vars['HIVE_ENDUSER']= $username;\r
+    $submit_vars['HIVE_REQ']    = '2112';\r
+    $submit_vars['HIVE_REF']    = 'hin:hive@API Login 3';\r
+    $submit_vars['HIVE_RET']    = 'ORG';\r
+    $submit_vars['HIVE_REM']    = '';\r
+    $submit_vars['HIVE_PROD']   = '0';\r
+    $submit_vars['HIVE_USERIP'] = getremoteaddr();\r
+\r
+\r
+/// We use POST to call Hive with a bit more security\r
+    $snoopy->submit($submit_url,$submit_vars);\r
+\r
+/// Extract HIVE_SESSION from headers\r
+\r
+    foreach ($snoopy->headers as $header) {\r
+        if (strpos($header, 'HIVE_SESSION=') !== false) {\r
+            $header = explode('HIVE_SESSION=', $header);\r
+            if (count($header) > 1) {\r
+                $cookie = explode(';', $header[1]);\r
+                $cookie = $cookie[0];\r
+                $SESSION->HIVE_SESSION = $cookie;\r
+                return true;\r
+            }\r
+        }\r
+    }\r
+\r
+/// Try again with the guest username and password\r
+\r
+    $submit_vars['HIVE_UNAME']  = $CFG->hiveusername;\r
+    $submit_vars['HIVE_UPASS']  = $CFG->hivepassword;\r
+    $submit_vars['HIVE_ENDUSER']= $CFG->hiveusername;\r
+    $snoopy->submit($submit_url,$submit_vars);\r
+    foreach ($snoopy->headers as $header) {\r
+        if (strpos($header, 'HIVE_SESSION=') !== false) {\r
+            $header = explode('HIVE_SESSION=', $header);\r
+            if (count($header) > 1) {\r
+                $cookie = explode(';', $header[1]);\r
+                $cookie = $cookie[0];\r
+                $SESSION->HIVE_SESSION = $cookie;\r
+                return true;\r
+            }\r
+        }\r
+    }\r
+\r
+    return false;  // No cookie found\r
+}\r
+\r
+?>\r
index 3d4cb11984a826c19d56d80fddc090b1033f78ca..cc83319ed3292ba6887e2e5a9f435e0432c044aa 100644 (file)
@@ -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$\r
+       // login.php - action of the login form put up by expired.php.\r
+\r
+    require('../../config.php');\r
+\r
+    require('lib.php');\r
+\r
+    require_login();\r
+\r
+    // get the login data \r
+    $frm = data_submitted('');\r
+\r
+    // log back into Hive\r
+    if (sso_user_login($frm->username, $frm->password)) {  \r
+\r
+        /// reopen Hive\r
+        redirect($CFG->wwwroot.'/mod/resource/type/repository/hive/openlitebrowse.php');\r
+    } else {\r
+        redirect($CFG->wwwroot.'/sso/hive/expired.php');\r
+    }\r
+\r
+?>\r
+\r