? cram.d6.patch
? md5.js
Index: cram.admin.inc
===================================================================
RCS file: cram.admin.inc
diff -N cram.admin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ cram.admin.inc	18 Feb 2008 19:22:57 -0000
@@ -0,0 +1,16 @@
+<?php
+// $Id$
+
+/** 
+ * Cram settings page in the admin menu.
+ */
+function cram_admin_settings() {
+  $form = array();
+  $form['cram_default_enabled'] = array(
+    '#type' => 'radios',
+    '#title' => t('CRAM Enabled by default'),
+    '#default_value' => variable_get('cram_default_enabled', 0),
+    '#options' => array(t('Default to insecure login'), t('Default to CRAM login')),
+  );
+  return system_settings_form($form);
+}
Index: cram.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cram/cram.info,v
retrieving revision 1.2
diff -u -p -r1.2 cram.info
--- cram.info	16 Jan 2008 02:21:49 -0000	1.2
+++ cram.info	18 Feb 2008 19:22:57 -0000
@@ -1,4 +1,4 @@
 ; $Id: cram.info,v 1.2 2008/01/16 02:21:49 selmanj Exp $
 name = CRAM
 description = "A javascript implementation of CRAM (Challenge-Response Authentication Mechanism)"
-version = 5.x-1.x-dev
+core = 6.x
Index: cram.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cram/cram.install,v
retrieving revision 1.2
diff -u -p -r1.2 cram.install
--- cram.install	26 Jan 2008 05:03:17 -0000	1.2
+++ cram.install	18 Feb 2008 19:22:57 -0000
@@ -1,20 +1,37 @@
 <?php
 // $Id: cram.install,v 1.2 2008/01/26 05:03:17 selmanj Exp $
 
+function cram_schema() {
+  $schema['cram_challenge'] = array(
+    'description' => t(''),
+    'fields' => array(
+      'nonce' => array(
+        'description' => t(''),
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
+        'default' => ''),
+      'issued' => array(
+        'description' => t(''),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0),
+      'valid' => array(
+        'description' => t(''),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0),
+      ),
+    'primary key' => array('nonce', 'issued'),
+    );
+  );
+  return $schema;
+}
+
 function cram_install() {
-  switch($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {cram_nonce} (
-        nonce varchar(32) NOT NULL default '',
-        issued int(11) NOT NULL default '0',
-	valid int(1) NOT NULL default '0',
-        PRIMARY KEY (nonce, issued)
-      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      break;
-  }
+  drupal_install_schema('cram');
 }
 
 function cram_uninstall() {
-  db_query('DROP TABLE {cram_nonce}');
+  drupal_uninstall_schema('cram');
 }
Index: cram.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cram/cram.module,v
retrieving revision 1.6
diff -u -p -r1.6 cram.module
--- cram.module	27 Jan 2008 23:17:24 -0000	1.6
+++ cram.module	18 Feb 2008 19:22:59 -0000
@@ -4,37 +4,21 @@
 /**
  * Implementation of hook_menu().
  */
-function cram_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/settings/cram',
-      'title' => t('CRAM settings'),
-      'description' => t('Adjust settings for CRAM secure login.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('cram_admin_settings'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
-    );
-  }
+function cram_menu() {
+  $items['admin/settings/cram'] = array(
+    'title' => 'CRAM settings',
+    'description' => 'Adjust settings for CRAM secure login.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('cram_admin_settings'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'cram.admin.inc',
+    'file path' => drupal_get_path('module', 'cram'),
+  );
 
   return $items;
 }
 
-/** 
- * Cram settings page in the admin menu.
- */
-function cram_admin_settings() {
-  $form = array();
-  $form['cram_default_enabled'] = array(
-    '#type' => 'radios',
-    '#title' => t('CRAM Enabled by default'),
-    '#default_value' => variable_get('cram_default_enabled', 0),
-    '#options' => array(t('Default to insecure login'), t('Default to CRAM login')),
-  );
-  return system_settings_form($form);
-}
-
 /**
  * Implementation of hook_auth().
  */
@@ -47,7 +31,7 @@ function cram_auth($username, $pass, $se
   $nonce_array = explode('.', $_POST['cram_nonce']);
   // check to see if we have a valid nonce
   $query = "SELECT nonce, issued, valid FROM {cram_nonce} WHERE nonce='%s' AND issued='%d' AND issued > '%d'";
-  if (db_num_rows(db_query($query, $nonce_array[0], $nonce_array[1], time()-60)) == 0) {
+  if (db_result(db_query($query, $nonce_array[0], $nonce_array[1], time()-60)) == FALSE) {
     return FALSE;
   }
 
@@ -61,12 +45,12 @@ function cram_auth($username, $pass, $se
 /**
  * Implementation of hook_form_alter().
  */
-function cram_form_alter($form_id, &$form) {
+function cram_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == 'user_login' || $form_id == 'user_login_block') {
     $module_path = drupal_get_path('module', 'cram');
     // Make sure the md5.js file is available.
     if (!file_exists("$module_path/md5.js")) {
-      watchdog('cram', "md5.js was not found in $module_path.  See the INSTALL.txt file for details.", WATCHDOG_ERROR);
+      watchdog('cram', "md5.js was not found in $module_path. See the INSTALL.txt file for details.", array(), WATCHDOG_ERROR);
       return;
     }
     // add our md5 and cram javascript to the page view
@@ -85,7 +69,7 @@ function cram_form_alter($form_id, &$for
  */
 function cram_get_nonce() {
   // generate our nonce
-  $nonce = md5(mt_rand() . getmypid() . $_SERVER['REMOTE_ADDR']);
+  $nonce = md5(mt_rand() . getmypid() . ip_address());
   $issued = time();
 
   db_query("INSERT INTO {cram_nonce} (nonce, issued, valid) VALUES ( '%s', '%d', 1)", $nonce, $issued);
