diff --git CREDITS.txt CREDITS.txt
index 2fe8140..d1f6cea 100644
--- CREDITS.txt
+++ CREDITS.txt
@@ -1,33 +1,33 @@
-$Id
-
-This module is sponsored by the 63reasons team at 63reasons.com
-
-Architecture:
-Louis-Eric Simard
-
-First Implementation:
-Yuriy Pobezhimov
-Louis-Eric Simard
-
-Multithreading Code:
-Rene-Marc Simard
-
-Throttle Support, Firewall, Code Readiness:
-Mustafah El Banna
-
-Selective Call and Per-Task Scheduling:
-Andy Truong
-
-AutoCron & Crash Safety:
-Louis-Eric Simard (based on David Reid's Poormanscron)
-
-Thanks to (in alphabetical order, and I am certain that we inadvertently forgot a lot of good people so our apologies):
-agharbeia, arhak, cpliakas, NikLP, geerlingguy, giorgio79, piloro, shunting, tseven, vacilando, whatdoesitwant
-for patches, ideas, translations, and good words.
-
-(In chronological order of contribution)
-Icons Courtesy Of:
-http://www.famfamfam.com/lab/icons/silk/
-Used under the Creative Commons Attribution 2.5 License
-
-cron syntax help file courtesy of Wikipedia
+$Id
+
+This module is sponsored by the 63reasons team at 63reasons.com
+
+Architecture:
+Louis-Eric Simard
+
+First Implementation:
+Yuriy Pobezhimov
+Louis-Eric Simard
+
+Multithreading Code:
+Rene-Marc Simard
+
+Throttle Support, Firewall, Code Readiness:
+Mustafah El Banna
+
+Selective Call and Per-Task Scheduling:
+Andy Truong
+
+AutoCron & Crash Safety:
+Louis-Eric Simard (based on David Reid's Poormanscron)
+
+Thanks to (in alphabetical order, and I am certain that we inadvertently forgot a lot of good people so our apologies):
+agharbeia, arhak, cpliakas, NikLP, geerlingguy, giorgio79, piloro, shunting, tseven, vacilando, whatdoesitwant
+for patches, ideas, translations, and good words.
+
+(In chronological order of contribution)
+Icons Courtesy Of:
+http://www.famfamfam.com/lab/icons/silk/
+Used under the Creative Commons Attribution 2.5 License
+
+cron syntax help file courtesy of Wikipedia
diff --git README.txt README.txt
index 0c70dc5..d7a87ff 100644
--- README.txt
+++ README.txt
@@ -1,17 +1,17 @@
-$Id$
-
-SuperCron must be installed in three steps.
-
-* First, install the module as usual and enable it (the module is found in the
-  Other section of the Modules page).
-* Once installed, copy the supercron.php file from the module directory to the
-  public root of your web installation (in the same directory as the existing
-  cron.php)
-* Update your crontab definitions to call supercron.php instead of the regular
-  cron.php
-* You can delete the original cron.php file if desired; supercron.php is a safer
-  entry point
-
-Cheers,
-
-The 63reasons Team
+$Id$
+
+SuperCron must be installed in three steps.
+
+* First, install the module as usual and enable it (the module is found in the
+  Other section of the Modules page).
+* Once installed, copy the supercron.php file from the module directory to the
+  public root of your web installation (in the same directory as the existing
+  cron.php)
+* Update your crontab definitions to call supercron.php instead of the regular
+  cron.php
+* You can delete the original cron.php file if desired; supercron.php is a safer
+  entry point
+
+Cheers,
+
+The 63reasons Team
diff --git help/rule.html help/rule.html
index 5f5d023..f547234 100644
--- help/rule.html
+++ help/rule.html
@@ -1,50 +1,50 @@
-<h3>1. FIELDS ORDER</h3>
-
-<pre>
- +---------------- minute (0 - 59)
- |  +------------- hour (0 - 23)
- |  |  +---------- day of month (1 - 31)
- |  |  |  +------- month (1 - 12)
- |  |  |  |  +---- day of week (0 - 7) (Sunday=0)
- |  |  |  |  |
- *  *  *  *  *
-</pre>
-
-<p>Each of the patterns from the first five fields may be either * (an asterisk),
-which matches all legal values, or a list of elements separated by commas
-(see below).</p>
-
-<p>For "day of the week" (field 5), 0 is considered Sunday, 6 is Saturday (7 is
-an illegal value)</p>
-
-<p>A job is executed when the time/date specification fields all match the current
-time and date. There is one exception: if both "day of month" and "day of week"
-are restricted (not "*"), then either the "day of month" field (3) or the "day
-of week" field (5) must match the current day (even though the other of the two
-fields need not match the current day).</p>
-
-<h3>2. FIELDS OPERATOR</h3>
-
-<p>There are several ways of specifying multiple date/time values in a field:</p>
-
-<ul>
-  <li>* The comma (',') operator specifies a list of values, for example: "1,3,4,7,8"</li>
-  <li>* The dash ('-') operator specifies a range of values, for example: "1-6", which
-  is equivalent to "1,2,3,4,5,6"</li>
-  <li>* The asterisk ('*') operator specifies all possible values for a field. For
-  example, an asterisk in the hour time field would be equivalent to 'every hour'
-  (subject to matching other specified fields).</li>
-  <li>* The slash ('/') operator (called "step") can be used to skip a given number of
-  values. For example, "*/3" in the hour time field is equivalent to
-  "0,3,6,9,12,15,18,21".</li>
-</ul>
-
-<h3>3. EXAMPLES</h3>
-
-<ul>
-  <li>*/15 * * * : Execute job every 15 minutes</li>
-  <li>0 2,14 * * *: Execute job every day at 2:00 and 14:00</li>
-  <li>0 2 * * 1-5: Execute job at 2:00 of every working day</li>
-  <li>0 12 1 */2 1: Execute job every 2 month, at 12:00 of first day of the month OR at
- every monday.</li>
+<h3>1. FIELDS ORDER</h3>
+
+<pre>
+ +---------------- minute (0 - 59)
+ |  +------------- hour (0 - 23)
+ |  |  +---------- day of month (1 - 31)
+ |  |  |  +------- month (1 - 12)
+ |  |  |  |  +---- day of week (0 - 7) (Sunday=0)
+ |  |  |  |  |
+ *  *  *  *  *
+</pre>
+
+<p>Each of the patterns from the first five fields may be either * (an asterisk),
+which matches all legal values, or a list of elements separated by commas
+(see below).</p>
+
+<p>For "day of the week" (field 5), 0 is considered Sunday, 6 is Saturday (7 is
+an illegal value)</p>
+
+<p>A job is executed when the time/date specification fields all match the current
+time and date. There is one exception: if both "day of month" and "day of week"
+are restricted (not "*"), then either the "day of month" field (3) or the "day
+of week" field (5) must match the current day (even though the other of the two
+fields need not match the current day).</p>
+
+<h3>2. FIELDS OPERATOR</h3>
+
+<p>There are several ways of specifying multiple date/time values in a field:</p>
+
+<ul>
+  <li>* The comma (',') operator specifies a list of values, for example: "1,3,4,7,8"</li>
+  <li>* The dash ('-') operator specifies a range of values, for example: "1-6", which
+  is equivalent to "1,2,3,4,5,6"</li>
+  <li>* The asterisk ('*') operator specifies all possible values for a field. For
+  example, an asterisk in the hour time field would be equivalent to 'every hour'
+  (subject to matching other specified fields).</li>
+  <li>* The slash ('/') operator (called "step") can be used to skip a given number of
+  values. For example, "*/3" in the hour time field is equivalent to
+  "0,3,6,9,12,15,18,21".</li>
+</ul>
+
+<h3>3. EXAMPLES</h3>
+
+<ul>
+  <li>*/15 * * * : Execute job every 15 minutes</li>
+  <li>0 2,14 * * *: Execute job every day at 2:00 and 14:00</li>
+  <li>0 2 * * 1-5: Execute job at 2:00 of every working day</li>
+  <li>0 12 1 */2 1: Execute job every 2 month, at 12:00 of first day of the month OR at
+ every monday.</li>
 </ul>
\ No newline at end of file
diff --git help/supercron.help.ini help/supercron.help.ini
index 0305ef0..2b2f089 100644
--- help/supercron.help.ini
+++ help/supercron.help.ini
@@ -1,9 +1,9 @@
-; $Id$
-
-[multithread]
-title = "Multithread"
-file = multithread
-
-[rule]
-title = "Rule"
-file = rule
+; $Id$
+
+[multithread]
+title = "Multithread"
+file = multithread
+
+[rule]
+title = "Rule"
+file = rule
diff --git js/jquery.thickbox/thickbox.js js/jquery.thickbox/thickbox.js
index 86bcf73..4a7fe0c 100644
--- js/jquery.thickbox/thickbox.js
+++ js/jquery.thickbox/thickbox.js
@@ -316,4 +316,3 @@ function tb_detectMacXFF() {
   }
 }
 
-
diff --git js/supercron.admin.js js/supercron.admin.js
index c0cd064..2198251 100644
--- js/supercron.admin.js
+++ js/supercron.admin.js
@@ -1,24 +1,24 @@
-// $Id$
-
-/**
- * Show/Hide custom script path textfield.
- */
-Drupal.behaviors.supercron_script_path = function(context) {
-  $('#supercron-settings input[name="supercron_script_path"]', context).click(function(){
-    if ($(this).val() == 3) {
-      $('#edit-supercron-script-path-text').show();
-    }
-    else {
-      $('#edit-supercron-script-path-text').hide();
-    }
-  });
-
-  try {
-    if ($('#supercron-settings input[name="supercron_script_path"]:checked', context).val() != 3) {
-      $('#edit-supercron-script-path-text').hide();
-    }
-  }
-  catch(e) {
-    $('#edit-supercron-script-path-text').hide();
-  }
-};
+// $Id$
+
+/**
+ * Show/Hide custom script path textfield.
+ */
+Drupal.behaviors.supercron_script_path = function(context) {
+  $('#supercron-settings input[name="supercron_script_path"]', context).click(function(){
+    if ($(this).val() == 3) {
+      $('#edit-supercron-script-path-text').show();
+    }
+    else {
+      $('#edit-supercron-script-path-text').hide();
+    }
+  });
+
+  try {
+    if ($('#supercron-settings input[name="supercron_script_path"]:checked', context).val() != 3) {
+      $('#edit-supercron-script-path-text').hide();
+    }
+  }
+  catch(e) {
+    $('#edit-supercron-script-path-text').hide();
+  }
+};
diff --git js/supercron.admin.rule.js js/supercron.admin.rule.js
index 974453b..e2b7484 100644
--- js/supercron.admin.rule.js
+++ js/supercron.admin.rule.js
@@ -1,260 +1,260 @@
-// $Id$
-
-function supercron_rule_wizard() {
-  // Minutes
-  try {
-    var minutes = $('#edit-options-wizard-wrapper [name="minutes"]:checked').val();
-    if (minutes.length == 0) {
-      try {
-        minutes = $('#edit-options-wizard-wrapper #edit-minutes-custom').val();
-        minutes = minutes.join(',');
-      }
-      catch(e) {
-        minutes = '*';
-      }
-    }
-  }
-  catch(e) {
-    minutes = '*';
-  }
-
-  // Hours
-  try {
-    var hours = $('#edit-options-wizard-wrapper [name="hours"]:checked').val();
-    if (hours.length == 0) {
-      try {
-        hours = $('#edit-options-wizard-wrapper #edit-hours-custom').val();
-        hours = hours.join(',');
-      }
-      catch(e) {
-        hours = '*';
-      }
-    }
-  }
-  catch(e) {
-    hours = '*';
-  }
-
-  // Days of month
-  try {
-    var days = $('#edit-options-wizard-wrapper [name="days"]:checked').val();
-    if (days.length == 0) {
-      try {
-        days = $('#edit-options-wizard-wrapper #edit-days-custom').val();
-        days = days.join(',');
-      }
-      catch(e) {
-        days = '*';
-      }
-    }
-  }
-  catch(e) {
-    hours = '*';
-  }
-
-  // Months
-  try {
-    var months = $('#edit-options-wizard-wrapper [name="months"]:checked').val();
-    if (months.length == 0) {
-      try {
-        months = $('#edit-options-wizard-wrapper #edit-months-custom').val();
-        months = months.join(',');
-      }
-      catch(e) {
-        months = '*';
-      }
-    }
-  }
-  catch(e) {
-    months = '*';
-  }
-
-  // Week days
-  try {
-    var week_days = $('#edit-options-wizard-wrapper [name="week_days"]:checked').val();
-    if (week_days.length == 0) {
-      try {
-        week_days = $('#edit-options-wizard-wrapper #edit-week-days-custom').val();
-        week_days = week_days.join(',');
-      }
-      catch(e) {
-        week_days = '*';
-      }
-    }
-  }
-  catch(e) {
-    week_days = '*';
-  }
-
-  return [minutes, hours, days, months, week_days].join(' ');
-}
-
-function _supercron_update_wizard_form(section, values) {
-  if ($('[id="edit-'+ section +'-' + values + '"]').size()) {
-    $('[id="edit-'+ section +'-' + values + '"]').trigger('click');
-  }
-  else {
-    $('[id="edit-'+ section +'-"]').trigger('click');
-
-    $('#edit-'+ section +'-custom option')
-      .removeClass('supercron-processed')
-      .removeAttr('selected');
-    values = values.split(',');
-    for (var i in values) {
-      $('#edit-'+ section +'-custom option:not(.supercron-processed)').each(function(){
-        if ($(this).val() == values[i]) {
-          $(this).attr('selected', 'selected').addClass('supercron-processed');
-        }
-        else {
-          $(this).removeAttr('selected');
-        }
-      });
-    }
-  }
-}
-
-function supercron_update_wizard_form() {
-  var query = '';
-  
-  // Reset the wizard form first
-  query = '#supercron-settings-rule-toolbox input[type="reset"]';
-  $(query).trigger('click');
-
-  // Get active rule value
-  query = '#supercron-settings .supercron-rule-setting:eq('+ supercron_active_rule +')';
-  var rules = $(query).parent().find('input').val();
-
-  if (rules.length == 0) {
-    // Reset rule
-    query = '#edit-minutes-, #edit-hours-, #edit-days-, #edit-months-, #edit-week-days-, #edit-options-all';
-    $(query).trigger('click');
-    return;
-  }
-
-  try {
-    // Click the option
-    $('#edit-options-wizard').trigger('click');
-
-    rules = rules.split(' ');
-    for (var i in rules) {
-      var section = '';
-      switch (parseInt(i)) {
-        // Minutes
-        case 0:
-          section = 'minutes';
-          break;
-
-        // Hours
-        case 1:
-          section = 'hours';
-          break;
-
-        // Day of month
-        case 2:
-          section = 'days';
-          break;
-          
-        // Months
-        case 3:
-          section = 'months';
-          break;
-          
-        // Days of week
-        case 4:
-          section = 'week-days';
-          break;
-      }
-
-      if (section) {
-        _supercron_update_wizard_form(section, rules[i]);
-      }
-    }
-
-    // @TODO: Open the wizard section
-    $('#edit-options-wizard-wrapper').trigger('click');
-  }
-  catch(e) {
-    return;
-  }
-}
-
-var supercron_active_rule = 0;
-
-Drupal.behaviors.supercron_rules = function(context) {
-  var query = '';
-  
-  /**
-   * Add clock icons to rule textfields
-   */
-  $('form#supercron-settings .form-text.supercron-rule', context).each(function(){
-    $(this).after('<a href="#TB_inline?height=500&width=1000&inlineId=supercron-settings-rule-toolbox" class="thickbox supercron-rule-setting"></a>');
-  });
-
-  /**
-   * Handle these icon click-event
-   */
-  $('form#supercron-settings a.supercron-rule-setting', context).each(function(i){
-    $(this).click(function(){
-      supercron_active_rule = i;
-
-      // Update wizard form
-      supercron_update_wizard_form();
-
-      return false;
-    });
-  });
-
-  /**
-   * Move...
-   */
-  $('fieldset.supercron-wizard').appendTo('#edit-options-wizard-wrapper');
-  $('fieldset.supercron_advanced_fieldset').appendTo('#edit-options-advanced-wrapper');
-
-  query = '#supercron_rule_toolbox > div.form-radios > div.form-item';
-  var $options = $(query);
-
-  // Hide sub sections.
-  $options.parent().find('div.form-item > fieldset').hide().end()
-  
-  $options.each(function(){
-    var $option = $(this);
-
-    $('input[name="options"]', $(this)).click(function(){
-      // Hide others
-      $options.parent().find('div.form-item > fieldset').hide();
-
-      $option.find('fieldset:eq(0)').fadeIn();
-    });
-  });
-
-  // Handle rule generating button
-  $('#supercron_rule_toolbox #edit-generate-rule').click(function(){
-    var option = $options.find('input[name="options"]:checked').val();
-    var rule   = '';
-
-    switch (option) {
-      case 'all':
-        // Clean rule textfield
-        break;
-
-      case 'advanced':
-        // Copy advanced-rule-textfield to rule text field.
-        rule = $('#edit-advanced').val();
-        break;
-
-      case 'wizard':
-        rule = supercron_rule_wizard();
-        break;
-    };
-
-    // Update rule field
-    $('form#supercron-settings a.supercron-rule-setting:eq('+ supercron_active_rule +')', context)
-      .parent().find('input').val(rule);
-
-    // Close thickbox
-    $('#TB_closeWindowButton').trigger('click');
-
-    // Bread form submission
-    return false;
-  });
-};
+// $Id$
+
+function supercron_rule_wizard() {
+  // Minutes
+  try {
+    var minutes = $('#edit-options-wizard-wrapper [name="minutes"]:checked').val();
+    if (minutes.length == 0) {
+      try {
+        minutes = $('#edit-options-wizard-wrapper #edit-minutes-custom').val();
+        minutes = minutes.join(',');
+      }
+      catch(e) {
+        minutes = '*';
+      }
+    }
+  }
+  catch(e) {
+    minutes = '*';
+  }
+
+  // Hours
+  try {
+    var hours = $('#edit-options-wizard-wrapper [name="hours"]:checked').val();
+    if (hours.length == 0) {
+      try {
+        hours = $('#edit-options-wizard-wrapper #edit-hours-custom').val();
+        hours = hours.join(',');
+      }
+      catch(e) {
+        hours = '*';
+      }
+    }
+  }
+  catch(e) {
+    hours = '*';
+  }
+
+  // Days of month
+  try {
+    var days = $('#edit-options-wizard-wrapper [name="days"]:checked').val();
+    if (days.length == 0) {
+      try {
+        days = $('#edit-options-wizard-wrapper #edit-days-custom').val();
+        days = days.join(',');
+      }
+      catch(e) {
+        days = '*';
+      }
+    }
+  }
+  catch(e) {
+    hours = '*';
+  }
+
+  // Months
+  try {
+    var months = $('#edit-options-wizard-wrapper [name="months"]:checked').val();
+    if (months.length == 0) {
+      try {
+        months = $('#edit-options-wizard-wrapper #edit-months-custom').val();
+        months = months.join(',');
+      }
+      catch(e) {
+        months = '*';
+      }
+    }
+  }
+  catch(e) {
+    months = '*';
+  }
+
+  // Week days
+  try {
+    var week_days = $('#edit-options-wizard-wrapper [name="week_days"]:checked').val();
+    if (week_days.length == 0) {
+      try {
+        week_days = $('#edit-options-wizard-wrapper #edit-week-days-custom').val();
+        week_days = week_days.join(',');
+      }
+      catch(e) {
+        week_days = '*';
+      }
+    }
+  }
+  catch(e) {
+    week_days = '*';
+  }
+
+  return [minutes, hours, days, months, week_days].join(' ');
+}
+
+function _supercron_update_wizard_form(section, values) {
+  if ($('[id="edit-'+ section +'-' + values + '"]').size()) {
+    $('[id="edit-'+ section +'-' + values + '"]').trigger('click');
+  }
+  else {
+    $('[id="edit-'+ section +'-"]').trigger('click');
+
+    $('#edit-'+ section +'-custom option')
+      .removeClass('supercron-processed')
+      .removeAttr('selected');
+    values = values.split(',');
+    for (var i in values) {
+      $('#edit-'+ section +'-custom option:not(.supercron-processed)').each(function(){
+        if ($(this).val() == values[i]) {
+          $(this).attr('selected', 'selected').addClass('supercron-processed');
+        }
+        else {
+          $(this).removeAttr('selected');
+        }
+      });
+    }
+  }
+}
+
+function supercron_update_wizard_form() {
+  var query = '';
+  
+  // Reset the wizard form first
+  query = '#supercron-settings-rule-toolbox input[type="reset"]';
+  $(query).trigger('click');
+
+  // Get active rule value
+  query = '#supercron-settings .supercron-rule-setting:eq('+ supercron_active_rule +')';
+  var rules = $(query).parent().find('input').val();
+
+  if (rules.length == 0) {
+    // Reset rule
+    query = '#edit-minutes-, #edit-hours-, #edit-days-, #edit-months-, #edit-week-days-, #edit-options-all';
+    $(query).trigger('click');
+    return;
+  }
+
+  try {
+    // Click the option
+    $('#edit-options-wizard').trigger('click');
+
+    rules = rules.split(' ');
+    for (var i in rules) {
+      var section = '';
+      switch (parseInt(i)) {
+        // Minutes
+        case 0:
+          section = 'minutes';
+          break;
+
+        // Hours
+        case 1:
+          section = 'hours';
+          break;
+
+        // Day of month
+        case 2:
+          section = 'days';
+          break;
+          
+        // Months
+        case 3:
+          section = 'months';
+          break;
+          
+        // Days of week
+        case 4:
+          section = 'week-days';
+          break;
+      }
+
+      if (section) {
+        _supercron_update_wizard_form(section, rules[i]);
+      }
+    }
+
+    // @TODO: Open the wizard section
+    $('#edit-options-wizard-wrapper').trigger('click');
+  }
+  catch(e) {
+    return;
+  }
+}
+
+var supercron_active_rule = 0;
+
+Drupal.behaviors.supercron_rules = function(context) {
+  var query = '';
+  
+  /**
+   * Add clock icons to rule textfields
+   */
+  $('form#supercron-settings .form-text.supercron-rule', context).each(function(){
+    $(this).after('<a href="#TB_inline?height=500&width=1000&inlineId=supercron-settings-rule-toolbox" class="thickbox supercron-rule-setting"></a>');
+  });
+
+  /**
+   * Handle these icon click-event
+   */
+  $('form#supercron-settings a.supercron-rule-setting', context).each(function(i){
+    $(this).click(function(){
+      supercron_active_rule = i;
+
+      // Update wizard form
+      supercron_update_wizard_form();
+
+      return false;
+    });
+  });
+
+  /**
+   * Move...
+   */
+  $('fieldset.supercron-wizard').appendTo('#edit-options-wizard-wrapper');
+  $('fieldset.supercron_advanced_fieldset').appendTo('#edit-options-advanced-wrapper');
+
+  query = '#supercron_rule_toolbox > div.form-radios > div.form-item';
+  var $options = $(query);
+
+  // Hide sub sections.
+  $options.parent().find('div.form-item > fieldset').hide().end()
+  
+  $options.each(function(){
+    var $option = $(this);
+
+    $('input[name="options"]', $(this)).click(function(){
+      // Hide others
+      $options.parent().find('div.form-item > fieldset').hide();
+
+      $option.find('fieldset:eq(0)').fadeIn();
+    });
+  });
+
+  // Handle rule generating button
+  $('#supercron_rule_toolbox #edit-generate-rule').click(function(){
+    var option = $options.find('input[name="options"]:checked').val();
+    var rule   = '';
+
+    switch (option) {
+      case 'all':
+        // Clean rule textfield
+        break;
+
+      case 'advanced':
+        // Copy advanced-rule-textfield to rule text field.
+        rule = $('#edit-advanced').val();
+        break;
+
+      case 'wizard':
+        rule = supercron_rule_wizard();
+        break;
+    };
+
+    // Update rule field
+    $('form#supercron-settings a.supercron-rule-setting:eq('+ supercron_active_rule +')', context)
+      .parent().find('input').val(rule);
+
+    // Close thickbox
+    $('#TB_closeWindowButton').trigger('click');
+
+    // Bread form submission
+    return false;
+  });
+};
diff --git js/supercron.crontab.js js/supercron.crontab.js
index f414ee7..55f541f 100644
--- js/supercron.crontab.js
+++ js/supercron.crontab.js
@@ -1,30 +1,30 @@
-// $Id$
-
-var clip = null;
-var moviePath = '';
-
-Drupal.behaviors.supercron_cron_tab = function(context) {
-  // setup single ZeroClipboard object for all our elements
-  ZeroClipboard.setMoviePath(Drupal.settings.basePath + Drupal.settings.supercron_module_path + '/js/ZeroClipboard.swf');
-  clip = new ZeroClipboard.Client();
-  clip.setHandCursor( true );
-
-  // assign a common mouseover function for all elements using jQuery
-  $('a.supercron-crontab-command', context).mouseover( function() {
-    // set the clip text to our innerHTML
-    clip.setText($(this).attr('rel'));
-
-    // reposition the movie over our element
-    // or create it if this is the first time
-    if (clip.div) {
-      clip.receiveEvent('mouseout', null);
-      clip.reposition(this);
-    }
-    else clip.glue(this);
-
-    // gotta force these events due to the Flash movie
-    // moving all around.  This insures the CSS effects
-    // are properly updated.
-    clip.receiveEvent('mouseover', null);
-  });
-};
+// $Id$
+
+var clip = null;
+var moviePath = '';
+
+Drupal.behaviors.supercron_cron_tab = function(context) {
+  // setup single ZeroClipboard object for all our elements
+  ZeroClipboard.setMoviePath(Drupal.settings.basePath + Drupal.settings.supercron_module_path + '/js/ZeroClipboard.swf');
+  clip = new ZeroClipboard.Client();
+  clip.setHandCursor( true );
+
+  // assign a common mouseover function for all elements using jQuery
+  $('a.supercron-crontab-command', context).mouseover( function() {
+    // set the clip text to our innerHTML
+    clip.setText($(this).attr('rel'));
+
+    // reposition the movie over our element
+    // or create it if this is the first time
+    if (clip.div) {
+      clip.receiveEvent('mouseout', null);
+      clip.reposition(this);
+    }
+    else clip.glue(this);
+
+    // gotta force these events due to the Flash movie
+    // moving all around.  This insures the CSS effects
+    // are properly updated.
+    clip.receiveEvent('mouseover', null);
+  });
+};
diff --git supercron-main.inc supercron-main.inc
index 95a58ee..75fab0c 100644
--- supercron-main.inc
+++ supercron-main.inc
@@ -2,7 +2,6 @@
 
 include_once(drupal_get_path('module', 'supercron') . '/supercron.inc');
 
-
 /**
  * Implement hook_help().
  */
@@ -51,8 +50,6 @@ function supercron_autocron_url() {
   return $url;
 }
 
-
-
 /**
  * Implements hook_menu().
  */
@@ -197,7 +194,6 @@ function supercron_perm() {
   return array(SUPERCRON_ADMIN_PERMISSION, SUPERCRON_EXCEPTION_FEED_PERMISSION);
 }
 
-
 /**
  * Implements hook_exit().
  */
@@ -213,7 +209,6 @@ function supercron_exit() {
     if ($execute) _supercron_parallel_call(url(supercron_autocron_url(), array('absolute'=>TRUE)));
 }
 
-
 function supercron_base_path() {
   global $base_path;
 
@@ -253,8 +248,6 @@ function supercron_get_script_path() {
   }
 }
 
-
-
 /**
  * A generic function for generating RSS feeds from a set of supercron
  * exceptions.
@@ -299,7 +292,6 @@ function supercron_exception_rss() {
   print $output;
 }
 
-
 // Qualify the agressive cache warning
 function supercron_form_system_performance_settings_alter(&$form, &$form_state) {
     $form['page_cache']['cache']['#description'] = str_replace('supercron', t('supercron (if cron daemon crash protection or autocron are enabled these features will not function, but the rest of supercron will function normally)'), $form['page_cache']['cache']['#description']);
diff --git supercron.admin.inc supercron.admin.inc
index e7656ae..b3ca56c 100644
--- supercron.admin.inc
+++ supercron.admin.inc
@@ -41,8 +41,6 @@ function _supercron_help_link($module_name, $file_name) {
   return ' <a class="supercron-help" href="'. $file_path .'" target="_blank"><img src="'. $image_path .'" alt="[?]" /></a>';
 }
 
-
-
 function _supercron_format_seconds($value = NULL) {
   if (is_null($value)) {
       return '';
@@ -55,7 +53,6 @@ function _supercron_format_seconds($value = NULL) {
   return drupal_strlen($value) ? t('!value sec', array('!value' => $value)) : '';
 }
 
-
 /**
  * Process and stat data to be used by the settings form or the AJAX callback.
  */
@@ -231,7 +228,6 @@ function supercron_settings(&$form_state) {
       '#value' => $module->execution_time_formatted_json_id
     );
 
-
     $form['rows'][$module->id]['how_long_took_avg'] = array(
       '#type' => 'value',
       '#value' => $module->average_execution_time_formatted
@@ -312,7 +308,6 @@ function supercron_settings(&$form_state) {
       );
     
 
-
   // Option for user to clear cron-successfully logs
   $dblog_exists = module_exists('dblog');
   $form['clear-log'] = array(
diff --git supercron.admin.js supercron.admin.js
index c0cd064..2198251 100644
--- supercron.admin.js
+++ supercron.admin.js
@@ -1,24 +1,24 @@
-// $Id$
-
-/**
- * Show/Hide custom script path textfield.
- */
-Drupal.behaviors.supercron_script_path = function(context) {
-  $('#supercron-settings input[name="supercron_script_path"]', context).click(function(){
-    if ($(this).val() == 3) {
-      $('#edit-supercron-script-path-text').show();
-    }
-    else {
-      $('#edit-supercron-script-path-text').hide();
-    }
-  });
-
-  try {
-    if ($('#supercron-settings input[name="supercron_script_path"]:checked', context).val() != 3) {
-      $('#edit-supercron-script-path-text').hide();
-    }
-  }
-  catch(e) {
-    $('#edit-supercron-script-path-text').hide();
-  }
-};
+// $Id$
+
+/**
+ * Show/Hide custom script path textfield.
+ */
+Drupal.behaviors.supercron_script_path = function(context) {
+  $('#supercron-settings input[name="supercron_script_path"]', context).click(function(){
+    if ($(this).val() == 3) {
+      $('#edit-supercron-script-path-text').show();
+    }
+    else {
+      $('#edit-supercron-script-path-text').hide();
+    }
+  });
+
+  try {
+    if ($('#supercron-settings input[name="supercron_script_path"]:checked', context).val() != 3) {
+      $('#edit-supercron-script-path-text').hide();
+    }
+  }
+  catch(e) {
+    $('#edit-supercron-script-path-text').hide();
+  }
+};
diff --git supercron.admin.rule.inc supercron.admin.rule.inc
index b6d4d71..6661564 100644
--- supercron.admin.rule.inc
+++ supercron.admin.rule.inc
@@ -1,199 +1,199 @@
-<?php
-// $Id$
-
-/**
- * @file
- * Contains administrative configuration details for complex cron scheduling
- */
-
-
-function supercron_settings_rule_toolbox() {
-  $module_path = drupal_get_path('module', 'supercron');
-  drupal_add_js("{$module_path}/js/supercron.admin.rule.js");
-  drupal_add_js("{$module_path}/js/jquery.thickbox/thickbox-compressed.js");
-  drupal_add_css("{$module_path}/js/jquery.thickbox/thickbox.css");
-
-  $form['rule_toolbox'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Rule toolbox'),
-    '#attributes' => array(
-      'id' => 'supercron_rule_toolbox',
-    ),
-  );
-
-  $form['rule_toolbox']['options'] = array(
-    '#type' => 'radios',
-    '#options' => array(
-      'all'      => t('Execute with every cron call'),
-      'wizard'   => t('Execute according to these rules'),
-      'advanced' => t('Advanced definition')
-    ),
-    '#default_value' => 'wizard'
-  );
-
-  $form['rule_toolbox']['wizard'] = array(
-    '#type' => 'fieldset',
-    # '#title' => t('Wizard'),
-    '#attributes' => array('class' => 'supercron-wizard'),
-  );
-
-  $form['rule_toolbox']['wizard']['minute'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Minutes'),
-    'minutes_custom' => array(
-      '#type' => 'select',
-      '#title' => t('Custom'),
-      '#options' => range(0, 59),
-      '#multiple' => TRUE,
-      '#size' => 10,
-    ),
-    'minutes' => array(
-      '#title' => t('Templates'),
-      '#type' => 'radios',
-      '#multiple' => TRUE,
-      '#attributes' => array('class' => 'supercron-wizard-minutes'),
-      '#options' => array(
-        '' => t('Custom'),
-        '*'  => t('Every Minute'),
-        '0,5,10,15,20,25,30,35,40,45,50,55'  => t('Every 5 Minutes'),
-        '0,10,20,30,40,50' => t('Every 10 Minutes'),
-        '0,15,30,45' => t('Every 1/4 Hour'),
-        '0,30' => t('Every 1/2 Hour'),
-        '0'  => t('Once Per Hour'),
-      ),
-    )
-  );
-
-  $form['rule_toolbox']['wizard']['hour'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Hours'),
-    'hours_custom' => array(
-      '#type'     => 'select',
-      '#title'    => t('Custom'),
-      '#options'  => range(0, 23),
-      '#multiple' => TRUE,
-      '#size' => 10,
-    ),
-    'hours' => array(
-      '#title' => t('Templates'),
-      '#type' => 'radios',
-      '#multiple' => TRUE,
-      '#attributes' => array('class' => 'supercron-wizard-minutes'),
-      '#options' => array(
-        '' => t('Custom'),
-        '*'  => t('Every Hour'),
-        '0,2,4,6,8,10,12,14,16,18,20,22' => t('Even Hours'),
-        '1,3,5,7,9,11,13,15,17,19,21,23' => t('Odd Hours'),
-        '0,6,12,18'  => t('Every 1/4 Day'),
-        '0,12' => t('Every 1/2 Day'),
-        '0' => t('Once Per Day'),
-      ),
-    )
-  );
-
-  $day_options = array();
-  for ($i = 1; $i <= 31; ++$i) {
-    $day_options[$i] = $i;
-  }
-
-  $form['rule_toolbox']['wizard']['day'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Days of month'),
-    'days_custom' => array(
-      '#type' => 'select',
-      '#title' => t('Custom'),
-      '#options' => $day_options,
-      '#multiple' => TRUE,
-      '#size' => 10,
-    ),
-    'days' => array(
-      '#title' => t('Templates'),
-      '#type' => 'radios',
-      '#multiple' => TRUE,
-      '#attributes' => array('class' => 'supercron-wizard-minutes'),
-      '#options' => array(
-        ''   => t('Custom'),
-        '*'  => t('Every Day'),
-        '2,4,6,8,10,12,14,16,18,20,22,24,26,28,30' => t('Even Days'),
-        '1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31' => t('Odd Days'),
-        '1,15'  => t('Twice Per Month'),
-        '1' => t('Once Per Month'),
-      ),
-    )
-  );
-
-  $form['rule_toolbox']['wizard']['month'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Months'),
-    '#attributes' => array('style' => 'clear: left'),
-    'months_custom' => array(
-      '#type' => 'select',
-      '#title' => t('Custom'),
-      '#options' => range(0, 59),
-      '#multiple' => TRUE,
-      '#size' => 10,
-    ),
-    'months' => array(
-      '#title' => t('Templates'),
-      '#type' => 'radios',
-      '#multiple' => TRUE,
-      '#attributes' => array('class' => 'supercron-wizard-minutes'),
-      '#options' => array(
-        '' => t('Custom'),
-        '*'  => t('Every Month'),
-        '2,4,6,8,10,12' => t('Even Months'),
-        '1,3,5,7,9,11' => t('Odd Months'),
-        '1,4,7,10'  => t('Every 1/4 Year'),
-        '1,7' => t('Every 1/2 Year'),
-        '1' => t('Once Per Year'),
-      ),
-    )
-  );
-
-  $form['rule_toolbox']['wizard']['week_day'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Days of week'),
-    'week_days_custom' => array(
-      '#type' => 'select',
-      '#title' => t('Custom'),
-      '#options' => range(0, 59),
-      '#multiple' => TRUE,
-      '#size' => 10,
-    ),
-    'week_days' => array(
-      '#title' => t('Templates'),
-      '#type' => 'radios',
-      '#multiple' => TRUE,
-      '#attributes' => array('class' => 'supercron-wizard-minutes'),
-      '#options' => array(
-        '' => t('Custom'),
-        '*'  => t('Every Day of the Week'),
-        '1-5' => t('Non-Weekend Days (Mon-Fri)'),
-        '0,6' => t('Weekend Days'),
-        '0' => t('Once Per Week (Sunday)'),
-      ),
-    )
-  );
-
-  $form['rule_toolbox']['radios']['advanced-fieldset'] = array(
-    '#type'  => 'fieldset',
-    '#attributes' => array(
-      'class' => 'supercron_advanced_fieldset',
-    ),
-    'advanced' => array(
-      '#type'  => 'textfield',
-      '#title' => t('Advanced definition'),
-    )
-  );
-
-  $form['rule_toolbox']['generate_rule'] = array(
-    '#type' => 'button',
-    '#value' => t('Update rule')
-  );
-
-  $form['rule_toolbox']['reset'] = array(
-    '#value' => '<input class="form-button" type="reset" value="Reset" />',
-  );
-
-  return $form;
-}
+<?php
+// $Id$
+
+/**
+ * @file
+ * Contains administrative configuration details for complex cron scheduling
+ */
+
+
+function supercron_settings_rule_toolbox() {
+  $module_path = drupal_get_path('module', 'supercron');
+  drupal_add_js("{$module_path}/js/supercron.admin.rule.js");
+  drupal_add_js("{$module_path}/js/jquery.thickbox/thickbox-compressed.js");
+  drupal_add_css("{$module_path}/js/jquery.thickbox/thickbox.css");
+
+  $form['rule_toolbox'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Rule toolbox'),
+    '#attributes' => array(
+      'id' => 'supercron_rule_toolbox',
+    ),
+  );
+
+  $form['rule_toolbox']['options'] = array(
+    '#type' => 'radios',
+    '#options' => array(
+      'all'      => t('Execute with every cron call'),
+      'wizard'   => t('Execute according to these rules'),
+      'advanced' => t('Advanced definition')
+    ),
+    '#default_value' => 'wizard'
+  );
+
+  $form['rule_toolbox']['wizard'] = array(
+    '#type' => 'fieldset',
+    # '#title' => t('Wizard'),
+    '#attributes' => array('class' => 'supercron-wizard'),
+  );
+
+  $form['rule_toolbox']['wizard']['minute'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Minutes'),
+    'minutes_custom' => array(
+      '#type' => 'select',
+      '#title' => t('Custom'),
+      '#options' => range(0, 59),
+      '#multiple' => TRUE,
+      '#size' => 10,
+    ),
+    'minutes' => array(
+      '#title' => t('Templates'),
+      '#type' => 'radios',
+      '#multiple' => TRUE,
+      '#attributes' => array('class' => 'supercron-wizard-minutes'),
+      '#options' => array(
+        '' => t('Custom'),
+        '*'  => t('Every Minute'),
+        '0,5,10,15,20,25,30,35,40,45,50,55'  => t('Every 5 Minutes'),
+        '0,10,20,30,40,50' => t('Every 10 Minutes'),
+        '0,15,30,45' => t('Every 1/4 Hour'),
+        '0,30' => t('Every 1/2 Hour'),
+        '0'  => t('Once Per Hour'),
+      ),
+    )
+  );
+
+  $form['rule_toolbox']['wizard']['hour'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Hours'),
+    'hours_custom' => array(
+      '#type'     => 'select',
+      '#title'    => t('Custom'),
+      '#options'  => range(0, 23),
+      '#multiple' => TRUE,
+      '#size' => 10,
+    ),
+    'hours' => array(
+      '#title' => t('Templates'),
+      '#type' => 'radios',
+      '#multiple' => TRUE,
+      '#attributes' => array('class' => 'supercron-wizard-minutes'),
+      '#options' => array(
+        '' => t('Custom'),
+        '*'  => t('Every Hour'),
+        '0,2,4,6,8,10,12,14,16,18,20,22' => t('Even Hours'),
+        '1,3,5,7,9,11,13,15,17,19,21,23' => t('Odd Hours'),
+        '0,6,12,18'  => t('Every 1/4 Day'),
+        '0,12' => t('Every 1/2 Day'),
+        '0' => t('Once Per Day'),
+      ),
+    )
+  );
+
+  $day_options = array();
+  for ($i = 1; $i <= 31; ++$i) {
+    $day_options[$i] = $i;
+  }
+
+  $form['rule_toolbox']['wizard']['day'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Days of month'),
+    'days_custom' => array(
+      '#type' => 'select',
+      '#title' => t('Custom'),
+      '#options' => $day_options,
+      '#multiple' => TRUE,
+      '#size' => 10,
+    ),
+    'days' => array(
+      '#title' => t('Templates'),
+      '#type' => 'radios',
+      '#multiple' => TRUE,
+      '#attributes' => array('class' => 'supercron-wizard-minutes'),
+      '#options' => array(
+        ''   => t('Custom'),
+        '*'  => t('Every Day'),
+        '2,4,6,8,10,12,14,16,18,20,22,24,26,28,30' => t('Even Days'),
+        '1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31' => t('Odd Days'),
+        '1,15'  => t('Twice Per Month'),
+        '1' => t('Once Per Month'),
+      ),
+    )
+  );
+
+  $form['rule_toolbox']['wizard']['month'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Months'),
+    '#attributes' => array('style' => 'clear: left'),
+    'months_custom' => array(
+      '#type' => 'select',
+      '#title' => t('Custom'),
+      '#options' => range(0, 59),
+      '#multiple' => TRUE,
+      '#size' => 10,
+    ),
+    'months' => array(
+      '#title' => t('Templates'),
+      '#type' => 'radios',
+      '#multiple' => TRUE,
+      '#attributes' => array('class' => 'supercron-wizard-minutes'),
+      '#options' => array(
+        '' => t('Custom'),
+        '*'  => t('Every Month'),
+        '2,4,6,8,10,12' => t('Even Months'),
+        '1,3,5,7,9,11' => t('Odd Months'),
+        '1,4,7,10'  => t('Every 1/4 Year'),
+        '1,7' => t('Every 1/2 Year'),
+        '1' => t('Once Per Year'),
+      ),
+    )
+  );
+
+  $form['rule_toolbox']['wizard']['week_day'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Days of week'),
+    'week_days_custom' => array(
+      '#type' => 'select',
+      '#title' => t('Custom'),
+      '#options' => range(0, 59),
+      '#multiple' => TRUE,
+      '#size' => 10,
+    ),
+    'week_days' => array(
+      '#title' => t('Templates'),
+      '#type' => 'radios',
+      '#multiple' => TRUE,
+      '#attributes' => array('class' => 'supercron-wizard-minutes'),
+      '#options' => array(
+        '' => t('Custom'),
+        '*'  => t('Every Day of the Week'),
+        '1-5' => t('Non-Weekend Days (Mon-Fri)'),
+        '0,6' => t('Weekend Days'),
+        '0' => t('Once Per Week (Sunday)'),
+      ),
+    )
+  );
+
+  $form['rule_toolbox']['radios']['advanced-fieldset'] = array(
+    '#type'  => 'fieldset',
+    '#attributes' => array(
+      'class' => 'supercron_advanced_fieldset',
+    ),
+    'advanced' => array(
+      '#type'  => 'textfield',
+      '#title' => t('Advanced definition'),
+    )
+  );
+
+  $form['rule_toolbox']['generate_rule'] = array(
+    '#type' => 'button',
+    '#value' => t('Update rule')
+  );
+
+  $form['rule_toolbox']['reset'] = array(
+    '#value' => '<input class="form-button" type="reset" value="Reset" />',
+  );
+
+  return $form;
+}
diff --git supercron.classes.inc supercron.classes.inc
index a4bae65..dfc86ef 100644
--- supercron.classes.inc
+++ supercron.classes.inc
@@ -249,7 +249,6 @@ class supercron_module {
         if (TRUE === empty($this->rule))
             return TRUE;
 
-
         $now = $_SERVER['REQUEST_TIME'];
 
 // job never run or run one year ago
@@ -359,7 +358,6 @@ class supercron_module {
 
     }
 
-
     private function log_output($output) {
         db_query(
                 "UPDATE {supercron_enabled_mods}"
@@ -494,10 +492,8 @@ class supercron_firewall_class {
 
         if (!in_array('127.0.0.1', $ips)) $ips[] = '127.0.0.1';
 
-
     }
 
-
 }
 
 class supercron_registry_class {
@@ -522,7 +518,6 @@ class supercron_registry_class {
     const controller_path_is_module_root = 2;
     const controller_path_is_custom = 3;
 
-
     const controller_name = 'supercron.php';
 
     const placeholder_safety_token = '@safety';
@@ -533,10 +528,8 @@ class supercron_registry_class {
     const prefs_default_autocron_autoenabled_treshold_in_hours = 12; // 12 hours
     const exceptions_feed_url_prefix = 'supercron/exceptions';
 
-
     const drupal_cron_last = 'cron_last';
 
-
     private $safety_variable = NULL;
     public  $module_location = NULL;
 
@@ -558,7 +551,6 @@ class supercron_registry_class {
         return $url;
     }
 
-
     static function get_clear_logs() {
         return variable_get(self::prefs_clear_logs, FALSE);
     }
@@ -567,13 +559,10 @@ class supercron_registry_class {
         variable_set(self::prefs_clear_logs, (bool)$value);
     }
 
-
     static function logs_must_be_cleared() {
         return module_exists('dblog') ? self::get_clear_logs() : TRUE;
     }
 
-
-
     static function set_php_binary_location($value) {
         $value = trim($value);
         if (strlen($value) > 0) variable_set(self::prefs_php_binary_location, $value);
@@ -699,7 +688,6 @@ class supercron_registry_class {
         else return TRUE;
     }
 
-
     static function clear_registry() {
         variable_del(self::prefs_autocron_autoenabled);
         variable_del(self::prefs_autocron_autoenabled_treshold);
@@ -795,7 +783,6 @@ class supercron_registry_class {
         variable_set(self::prefs_autocron_treshold, (int)$value);
     }
 
-
     static function get_script_path_value() {
         return (int)variable_get(self::prefs_controller_path, self::controller_path_is_module_root);
     }
diff --git supercron.crontab-admin.inc supercron.crontab-admin.inc
index 5611323..574e19e 100644
--- supercron.crontab-admin.inc
+++ supercron.crontab-admin.inc
@@ -6,7 +6,6 @@
  * Contains administrative configuration helper for Cron tasks
  */
 
-
 function supercron_invocation_form(&$form_state) {
   $module_path = drupal_get_path('module', 'supercron');
   drupal_add_js("{$module_path}/js/ZeroClipboard.js");
@@ -110,7 +109,6 @@ function supercron_invocation_form_submit($form, &$form_state) {
   }
 }
 
-
 /**
  * Theming function for invocation form.
  */
diff --git supercron.css supercron.css
index 2fc76f4..1c10d17 100644
--- supercron.css
+++ supercron.css
@@ -1,24 +1,24 @@
-/* $Id$ */
-
-form#supercron-settings th a.advanced-help-link {padding-right: 7px;}
-a.invoke {padding: 0 0 0 20px; background: url(images/cog_go.png) 0 0 no-repeat; z-index: 1}
-
-td a.invoke {display: block; padding: 0 0; height: 16px; width: 16px; overflow: hidden; }
-
-a.supercron-rule-setting {padding: 4px 0 0 22px; background: url(images/clock_edit.png) 5px 5px no-repeat; line-height: 20px; }
-
-
-#supercron-settings-rule-toolbox {display: none;}
-
-fieldset.supercron-wizard .form-item {float: left;}
-
-#edit-minutes-custom-wrapper,
-#edit-hours-custom-wrapper,
-#edit-days-custom-wrapper,
-#edit-months-custom-wrapper,
-#edit-week-days-custom-wrapper {width: 65px;}
-#supercron-lower-warning {color: red;}
-
-fieldset.supercron-wizard .form-item .form-item {float: none;}
-
-fieldset.supercron-wizard fieldset {float: left; width: 280px; margin-right: 5px;}
+/* $Id$ */
+
+form#supercron-settings th a.advanced-help-link {padding-right: 7px;}
+a.invoke {padding: 0 0 0 20px; background: url(images/cog_go.png) 0 0 no-repeat; z-index: 1}
+
+td a.invoke {display: block; padding: 0 0; height: 16px; width: 16px; overflow: hidden; }
+
+a.supercron-rule-setting {padding: 4px 0 0 22px; background: url(images/clock_edit.png) 5px 5px no-repeat; line-height: 20px; }
+
+
+#supercron-settings-rule-toolbox {display: none;}
+
+fieldset.supercron-wizard .form-item {float: left;}
+
+#edit-minutes-custom-wrapper,
+#edit-hours-custom-wrapper,
+#edit-days-custom-wrapper,
+#edit-months-custom-wrapper,
+#edit-week-days-custom-wrapper {width: 65px;}
+#supercron-lower-warning {color: red;}
+
+fieldset.supercron-wizard .form-item .form-item {float: none;}
+
+fieldset.supercron-wizard fieldset {float: left; width: 280px; margin-right: 5px;}
diff --git supercron.firewall-admin.inc supercron.firewall-admin.inc
index 82c5202..7cbaefd 100644
--- supercron.firewall-admin.inc
+++ supercron.firewall-admin.inc
@@ -143,4 +143,3 @@ function supercron_firewall_delete($id) {
   drupal_goto('admin/settings/supercron/firewall');
 }
 
-
diff --git supercron.inc supercron.inc
index cefb06c..8c93803 100644
--- supercron.inc
+++ supercron.inc
@@ -1,519 +1,519 @@
-<?php
-// $Id$
-
-/**
- * @file
- * Contains helper methods
- */
-
-// SuperCron invoke-all jobs path
-define('SUPERCRON_INVOKE_ALL',                  'admin/reports/status/run-supercron');
-
-// Variable constants; duplicating literals is an open invitation to bugs
-define('SUPERCRON_SCRIPT_NAME',                 'supercron.php');
-define('SUPERCRON_PHP_BINARY_PATH_PLACEHOLDER', t('[path to php binary]'));
-define('SUPERCRON_ADMIN_PERMISSION',            'administer supercron');
-define('SUPERCRON_EXCEPTION_FEED_PERMISSION',   'access the supercron exception feed');
-define('SUPERCRON_AJAX_CALLBACK',               'admin/settings/supercron/get-results');
-define('SUPERCRON_ADMIN_MENU_PATH_CRONTAB_CONFIGURATION', 'admin/settings/supercron/invocation');
-define('SUPERCRON_ADMIN_MENU_PATH_SETTINGS', 'admin/settings/supercron/settings');
-define('SUPERCRON_ADMIN_MENU_PATH_FIREWALL', 'admin/settings/supercron/firewall');
-define('SUPERCRON_ADMIN_MENU_PATH_AUTOCRON', 'admin/settings/supercron/autocron');
-define('SUPERCRON_MENU_PATH_EXCEPTION_RSS_FEED', 'supercron/exceptions');
-define('SUPERCRON_MENU_PATH_RUN_CRON', 'admin/reports/status/run-cron');
-define('SUPERCRON_MENU_PATH_AUTO_CRON', 'supercron/run-autocron-');
-define('SUPERCRON_AUTOCRON_URL', 'supercron_autocron_url');
-define('SUPERCRON_EXCEPTIONS_RSS_URL', 'supercron_exceptions_RSS_url');
-
-define('SUPERCRON_SAFETY_VARIABLE',  'supercron_safety');
-define('SUPERCRON_FIREWALL_ENABLED_VARIABLE',   'supercron_firewall_enabled');
-define('SUPERCRON_FIREWALL_MODE_VARIABLE',      'supercron_firewall_mode');
-define('SUPERCRON_THROTTLE_SUPPORT_VARIABLE',   'supercron_respond_to_throttling');
-define('SUPERCRON_CLEAR_LOGS',      'supercron_dblog_clear_messages');
-define('SUPERCRON_SCRIPT_PATH',                 'supercron_script_path');
-define('SUPERCRON_SCRIPT_PATH_DRUPAL_ROOT',     1);
-define('SUPERCRON_SCRIPT_PATH_MODULE_ROOT',     2);
-define('SUPERCRON_SCRIPT_PATH_CUSTOM',          3);
-define('SUPERCRON_PHP_BINARY_PATH',             'supercron_php_binary_path');
-define('SUPERCRON_AUTOCRON_TRESHOLD',           'supercron_autocron_treshold');
-define('SUPERCRON_AUTOCRON_ENABLED',           'supercron_autocron_enabled');
-define('SUPERCRON_AUTOCRON_AUTOENABLED',           'supercron_autocron_auto_enabled');
-define('SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD',           'supercron_autocron_auto_enabled_treshold');
-define('SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD_DEFAULT_HOURS', (int)12); // 12 hours in minutes
-define('SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD_DEFAULT', (int)SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD_DEFAULT_HOURS*60*60); // 12 hours in minutes
-
-function supercron_drupal_cron_run() {
-  // If not in 'safe mode', increase the maximum execution time:
-  if (!ini_get('safe_mode')) {
-    set_time_limit(240);
-  }
-
-  // Fetch the cron semaphore
-  $semaphore = variable_get('cron_semaphore', FALSE);
-
-  if ($semaphore) {
-    if (time() - $semaphore > 3600) {
-      // Either cron has been running for more than an hour or the semaphore
-      // was not reset due to a database error.
-      watchdog('cron', 'Cron has been running for more than an hour and is most likely stuck.', array(), WATCHDOG_ERROR);
-
-      // Release cron semaphore
-      variable_del('cron_semaphore');
-    }
-    else {
-      // Cron is still running normally.
-      watchdog('cron', 'Attempting to re-run cron while it is already running.', array(), WATCHDOG_WARNING);
-    }
-  }
-  else {
-    // Register shutdown callback
-    register_shutdown_function('drupal_cron_cleanup');
-
-    // Lock cron semaphore
-    variable_set('cron_semaphore', time());
-
-    // Iterate through the modules calling their cron handlers (if any):
-    supercron_module_invoke_all_cron();
-
-    // Record cron time
-    variable_set('cron_last', time());
-    watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
-
-    // Release cron semaphore
-    variable_del('cron_semaphore');
-    drupal_goto(getenv("HTTP_REFERER"));
-  }
-}
-
-function supercron_module_set_exec_intervals_and_times_count($module, $start_time, $end_time) {
-  $interval = $end_time - $start_time;
-
-  db_query(
-    "UPDATE {supercron_enabled_mods} "
-      . "SET timestamp = %d,"
-      . " last_exec_interval = %d,"
-      . " total_exec_interval = total_exec_interval + %d,"
-      . " times_count = times_count + 1"
-      . " WHERE module_name = '%s'",
-    $start_time, $interval, $interval, $module
-  );
-}
-
-function supercron_clear_logs() {
-  if (module_exists('dblog') && variable_get(SUPERCRON_CLEAR_LOGS, TRUE)) {
-    db_query(
-      "DELETE FROM {watchdog} WHERE type = 'cron' AND severity = %d",
-      WATCHDOG_NOTICE
-    );
-  }
-}
-
-
-function supercron_module_add_output($module, $output) {
-  db_query(
-    "UPDATE {supercron_enabled_mods}"
-    . " SET output = Concat(output, '%s<br />')"
-    . " WHERE module_name = '%s'",
-    $output, $module
-  );
-}
-
-function supercron_module_invoke_all_cron() {
-  if (variable_get(SUPERCRON_CLEAR_LOGS, TRUE)) {
-    supercron_clear_logs();
-  }
-
-  module_load_include('inc', 'supercron', 'supercron');
-  return _supercron_module_invoke_all_cron();
-}
-
-function supercron_invoke_one($module, $return = FALSE, $multithread = FALSE) {
-  try {
-    ob_start();
-    $start_time = time();
-    module_invoke($module, 'cron');
-    supercron_module_set_exec_intervals_and_times_count($module, $start_time, time());
-    $output = ob_get_contents();
-    ob_end_clean();
-    if (!empty($output)) {
-      supercron_module_add_output($module, $output);
-    }
-
-    // Record cron time
-    variable_set('cron_last', time());
-  }
-  catch (Exception $e) {
-    ob_end_clean();
-    $massage = $e->getMessage();
-    watchdog(
-      'cron exception',
-      t("Module name: @module;\nException message: @message;"),
-      array(
-        '@module'  => $module,
-        '@message' => !empty($massage) ? $massage : t('no message')
-      ),
-      WATCHDOG_ERROR
-    );
-  }
-
-  if ($return) {
-    drupal_goto(getenv("HTTP_REFERER"));
-  }
-}
-
-// based on Kyle Florence's code at http://php.net/manual/en/function.rand.php
-function _supercron_rand_str($length = 128, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()_+=-[]{}\|\'"<>,.?/')
-{
-  mt_srand(); // not necessary, except when it is
-    // Length of character list
-    $chars_length = (strlen($chars) - 1);
-
-    // Start our string
-    $string = $chars{mt_rand(0, $chars_length)};
-
-    // Generate random string
-    for ($i = 1; $i < $length; $i = strlen($string))
-    {
-        // Grab a random character from our list
-        $r = $chars{rand(0, $chars_length)};
-
-        // Make sure the same two characters don't appear next to each other
-        if ($r != $string{$i - 1}) $string .=  $r;
-    }
-
-    // Return the string
-    return $string;
-}
-
-function _supercron_make_safety_token()
-{
-  return md5(_supercron_rand_str() . '-' .rand() .'-'. mt_rand() . '-' . _supercron_rand_str()); // yes, we are a tad paranoid
-}
-
-function _supercron_get_safety_variable() {
-    $value = variable_get(SUPERCRON_SAFETY_VARIABLE, '');
-    if (empty($value))
-    {
-        $value = _supercron_make_safety_token();
-        variable_set(SUPERCRON_SAFETY_VARIABLE, $value);
-    }
-  return $value;
-}
-
-function _supercron_parallel_call($url)
-{
-  $parts = parse_url($url);
-  $u     = $parts['path'] .'?'. $parts['query'];
-  $port  = isset($parts['port']) ? $parts['port'] : 80;
-  $fp    = fsockopen($parts['host'], $port, $errno, $errstr, 20);
-  if ($fp) {
-        $out = "GET {$u} HTTP/1.1\r\n";
-        $out .= "Host: {$parts['host']}\r\n";
-        $out .= "Connection: Close\r\n\r\n";
-        fwrite($fp, $out);
-
-        stream_set_blocking($fp, FALSE);
-        stream_set_timeout($fp, 2);
-        fclose($fp);
-      }
-}
-
-function supercron_list_of_cron_modules() {
-  return module_implements('cron', TRUE);
-}
-
-function supercron_fetch_all($sort = 0, $only_enabled = 0) {
-  $filter = $only_enabled ? ' WHERE enabled = 1' : '';
-  $sort   = $sort == 0 ? "ASC" : "DESC";
-
-  $modules = array();
-  $q = db_query('SELECT * FROM {supercron_enabled_mods}'. $filter .' ORDER BY weight ' . $sort);
-  while ($module = db_fetch_object($q)) {
-    $modules[] = $module;
-  }
-
-  return $modules;
-}
-
-function supercron_list_handled_modules() {
-  $result = array();
-  $modulenames = db_query('SELECT module_name FROM {supercron_enabled_mods} ORDER BY module_name ASC');
-  while ($row = db_fetch_object($modulenames)) {
-    $result [] = $row->module_name;
-  }
-  return $result;
-}
-
-function supercron_remove_disabled_modules() {
-  $modules = supercron_list_handled_modules();
-  foreach ($modules as $module) {
-    if (!module_hook($module, 'cron')) {
-      db_query('DELETE FROM {supercron_enabled_mods} WHERE module_name = \'%s\'', $module);
-    }
-  }
-}
-
-function supercron_update_module_list() {
-  supercron_remove_disabled_modules();
-  supercron_add_newly_enabled_modules();
-}
-
-function supercron_add_newly_enabled_modules() {
-  $modules = supercron_list_of_cron_modules();
-  $max_weight = db_result(db_query("SELECT MAX(weight) FROM {supercron_enabled_mods}"));
-  if ($max_weight == NULL) {
-    $max_weight = 0;
-  }
-  else {
-    $max_weight++;
-  }
-
-  foreach ($modules as $module) {
-    $is = db_result(db_query_range(
-      "SELECT COUNT(*) FROM {supercron_enabled_mods} WHERE module_name = '%s'",
-      $module, 0, 1
-    ));
-
-    if (!$is) {
-      db_query(
-        "INSERT INTO {supercron_enabled_mods} (module_name, weight, output) VALUES ('%s', %d, '')",
-        $module, $max_weight
-      );
-
-      $max_weight++;
-    }
-  }
-}
-
-function supercron_rule_is_valid($rule) {
-  // check for valid rule format
-  $format = '([0-9*,/-]+)';
-  $format = "@^{$format}\s+{$format}\s+{$format}\s+{$format}\s+{$format}$@";
-  if (!preg_match($format, $rule, $rules)) {
-    return FALSE;
-  }
-
-  return $rules;
-}
-
-function _supercron_module_invoke_all_cron() {
-  global $base_url;
-
-  $safety = _supercron_get_safety_variable();
-  supercron_update_module_list();
-  
-  $modules         = array();
-  $run_in_parallel = array();
-  foreach (supercron_fetch_all(0, 1) as $module) {
-    $modules[] = $module;
-    $run_in_parallel[$module->module_name] = $module->detached;
-  }
-  unset($modules_config_result);
-
-  // there is no cron jobs enabled.
-  if (empty($modules)) {
-    variable_set('cron_last', time());
-    return FALSE;
-  }
-
-  variable_set('cron_semaphore', time());
-
-  foreach ($modules as $module) {
-    if (FALSE === supercron_should_run($module)) {
-      continue;
-    }
-
-    if ($run_in_parallel[$module->module_name]) {
-      $url = supercron_get_script_URL();
-      $url .= '?safety='. drupal_urlencode($safety);
-      $url .= '&module='. drupal_urlencode($module->module_name);
-      $url .= '&multithread=yes';
-      _supercron_parallel_call($url);
-    }
-    else {
-      supercron_invoke_one($module->module_name);
-    }
-  }
-
-  // Record cron time
-  variable_set('cron_last', time());
-  watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
-
-  // Release cron semaphore
-  variable_del('cron_semaphore');
-
-  return TRUE;
-}
-
-/**
- * Used by _supercron_should_run().
- */
-function _supercronDecodeRule($rule, $min, $max) {
-  if ($rule == '*')
-    return range($min, $max);
-
-  $result = array();
-  foreach (explode(',', $rule) as $token) {
-    if (preg_match('/^([0-9]+)-([0-9]+)$/', $token, $r)) {
-      $result = array_merge($result, range($r[1], $r[2]));
-    }
-    elseif (preg_match('/^\*\/([0-9]+)$/', $token, $r)) {
-      for ($i = $min; $i <= $max; $i++)
-        if ($i % $r[1] == 0)
-          $result[] = $i;
-    }
-    elseif (is_numeric($token)) {
-      $result[] = $token;
-    }
-  }
-  return $result;
-}
-
-/**
- * Used by _supercron_should_run().
- */
-function _supercronT($time, $d = -1, $h = -1, $m = -1) {
-  if ($d < 0) {
-    return date('n', $time) * 31 * 24 * 60 + date('j', $time) * 24 * 60 + date('H', $time) * 60 + date('i', $time);
-  }
-  else {
-    return $time * 31 * 24 * 60 + $d * 24 * 60 + $h * 60 + $m;
-  }
-}
-
-/**
- * Used by _supercron_should_run().
- */
-function _supercronMonDaysFromWeekDays($year, $mon, $weekdays) {
-  $result = array();
-  for ($i = 1; checkdate($mon, $i, $year); $i++) {
-    $w = date('w', mktime(12, 00, 00, $mon, $i, $year));
-    if (in_array($w, $weekdays)) {
-      $result[] = $i;
-    }
-  }
-  return $result;
-}
-
-/**
- * Limit job run by checking rule.
- */
-function supercron_should_run($module) {
-  if (TRUE === empty($module->rule)) {
-    return TRUE;
-  }
-
-  $now = $_SERVER['REQUEST_TIME'];
-
-  // job never run or run one year ago
-  if ((!$module->timestamp) || ($now - $module->timestamp > 365 * 86400)) {
-    return TRUE;
-  }
-  
-  return _supercron_should_run($module, $now);
-}
-
-/**
- * Time check
- */
-function _supercron_should_run($module, $now) {
-  // check for valid rule format
-  $rules = supercron_rule_is_valid($rule, $module->rule);
-  if (FALSE === $rules) {
-    watchdog('cron', 'Invalid rule found (%module): %rule', array(
-      '%module' => $module->module_name,
-      '%rule'   => $module->rule
-    ));
-    
-    return FALSE;
-  }
-
-  $weekdayspec = ($rules[5] != '*');
-  $mondayspec  = ($rules[3] != '*');
-
-  $rules[5] = _supercronDecodeRule($rules[5], 0, 6);
-  $rules[4] = _supercronDecodeRule($rules[4], 1, 12);
-  $rules[3] = _supercronDecodeRule($rules[3], 1, 31);
-  $rules[2] = _supercronDecodeRule($rules[2], 0, 23);
-  $rules[1] = _supercronDecodeRule($rules[1], 0, 59);
-
-  $last_t     = _supercronT($module->timestamp + 30);
-  $now_t      = _supercronT($now);
-  $now_t_delta = $now_t - $last_t + ($last_t > $now_t ? 12 * 31 * 24 * 60 : 0);
-  $year      = date('Y', $module->timestamp);
-
-  if ($mondayspec || (!$mondayspec && !$weekdayspec)) {
-    $first = -1;
-
-    foreach ($rules[4] as $mon) {
-      foreach ($rules[3] as $d) {
-        if (checkdate($mon, $d, $year)) {
-          foreach ($rules[2] as $h) {
-            foreach ($rules[1] as $m) {
-              $t = _supercronT($mon, $d, $h, $m);
-
-              if ($first < 0) {
-                $first = $t;
-              }
-
-              if ($t > $last_t) {
-                $next_t = $t;
-                break 4;
-              }
-            }
-          }
-        }
-      }
-    }
-
-    if (!$next_t) {
-      $next_t = $first;
-    }
-
-    $next_t_delta = $next_t - $last_t + ($last_t > $next_t ? 12 * 31 * 24 * 60 : 0);
-
-    if ($now_t_delta >= $next_t_delta) {
-      return TRUE;
-    }
-  }
-
-  if ($weekdayspec) {
-    foreach ($rules[4] as $mon) {
-      foreach (_supercronMonDaysFromWeekDays($year, $mon, $rules[5]) as $d) {
-        foreach ($rules[2] as $h) {
-          foreach ($rules[1] as $m) {
-            $t = _supercronT($mon, $d, $h, $m);
-
-            if ($t > $last_t) {
-              $next_t = $t;
-              break 4;
-            }
-          }
-        }
-      }
-    }
-
-    if (!$next_t) {
-      // ust get the first of following year (if day_of_week is specified it's
-      // not the same of previous one)
-      foreach ($rules[4] as $mon) {
-        foreach (_supercronMonDaysFromWeekDays($year + 1, $mon, $rules[5]) as $d) {
-          foreach ($rules[2] as $h) {
-            foreach ($rules[1] as $m) {
-              $next_t = _supercronT($mon, $d, $h, $m);
-              break 4;
-            }
-          }
-        }
-      }
-    }
-
-    $next_t_delta = $next_t - $last_t + ($last_t > $next_t ? 12 * 31 * 24 * 60 : 0);
-
-    if ($now_t_delta >= $next_t_delta) {
-      return TRUE;
-    }
-  }
-
-  return FALSE;
-}
+<?php
+// $Id$
+
+/**
+ * @file
+ * Contains helper methods
+ */
+
+// SuperCron invoke-all jobs path
+define('SUPERCRON_INVOKE_ALL',                  'admin/reports/status/run-supercron');
+
+// Variable constants; duplicating literals is an open invitation to bugs
+define('SUPERCRON_SCRIPT_NAME',                 'supercron.php');
+define('SUPERCRON_PHP_BINARY_PATH_PLACEHOLDER', t('[path to php binary]'));
+define('SUPERCRON_ADMIN_PERMISSION',            'administer supercron');
+define('SUPERCRON_EXCEPTION_FEED_PERMISSION',   'access the supercron exception feed');
+define('SUPERCRON_AJAX_CALLBACK',               'admin/settings/supercron/get-results');
+define('SUPERCRON_ADMIN_MENU_PATH_CRONTAB_CONFIGURATION', 'admin/settings/supercron/invocation');
+define('SUPERCRON_ADMIN_MENU_PATH_SETTINGS', 'admin/settings/supercron/settings');
+define('SUPERCRON_ADMIN_MENU_PATH_FIREWALL', 'admin/settings/supercron/firewall');
+define('SUPERCRON_ADMIN_MENU_PATH_AUTOCRON', 'admin/settings/supercron/autocron');
+define('SUPERCRON_MENU_PATH_EXCEPTION_RSS_FEED', 'supercron/exceptions');
+define('SUPERCRON_MENU_PATH_RUN_CRON', 'admin/reports/status/run-cron');
+define('SUPERCRON_MENU_PATH_AUTO_CRON', 'supercron/run-autocron-');
+define('SUPERCRON_AUTOCRON_URL', 'supercron_autocron_url');
+define('SUPERCRON_EXCEPTIONS_RSS_URL', 'supercron_exceptions_RSS_url');
+
+define('SUPERCRON_SAFETY_VARIABLE',  'supercron_safety');
+define('SUPERCRON_FIREWALL_ENABLED_VARIABLE',   'supercron_firewall_enabled');
+define('SUPERCRON_FIREWALL_MODE_VARIABLE',      'supercron_firewall_mode');
+define('SUPERCRON_THROTTLE_SUPPORT_VARIABLE',   'supercron_respond_to_throttling');
+define('SUPERCRON_CLEAR_LOGS',      'supercron_dblog_clear_messages');
+define('SUPERCRON_SCRIPT_PATH',                 'supercron_script_path');
+define('SUPERCRON_SCRIPT_PATH_DRUPAL_ROOT',     1);
+define('SUPERCRON_SCRIPT_PATH_MODULE_ROOT',     2);
+define('SUPERCRON_SCRIPT_PATH_CUSTOM',          3);
+define('SUPERCRON_PHP_BINARY_PATH',             'supercron_php_binary_path');
+define('SUPERCRON_AUTOCRON_TRESHOLD',           'supercron_autocron_treshold');
+define('SUPERCRON_AUTOCRON_ENABLED',           'supercron_autocron_enabled');
+define('SUPERCRON_AUTOCRON_AUTOENABLED',           'supercron_autocron_auto_enabled');
+define('SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD',           'supercron_autocron_auto_enabled_treshold');
+define('SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD_DEFAULT_HOURS', (int)12); // 12 hours in minutes
+define('SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD_DEFAULT', (int)SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD_DEFAULT_HOURS*60*60); // 12 hours in minutes
+
+function supercron_drupal_cron_run() {
+  // If not in 'safe mode', increase the maximum execution time:
+  if (!ini_get('safe_mode')) {
+    set_time_limit(240);
+  }
+
+  // Fetch the cron semaphore
+  $semaphore = variable_get('cron_semaphore', FALSE);
+
+  if ($semaphore) {
+    if (time() - $semaphore > 3600) {
+      // Either cron has been running for more than an hour or the semaphore
+      // was not reset due to a database error.
+      watchdog('cron', 'Cron has been running for more than an hour and is most likely stuck.', array(), WATCHDOG_ERROR);
+
+      // Release cron semaphore
+      variable_del('cron_semaphore');
+    }
+    else {
+      // Cron is still running normally.
+      watchdog('cron', 'Attempting to re-run cron while it is already running.', array(), WATCHDOG_WARNING);
+    }
+  }
+  else {
+    // Register shutdown callback
+    register_shutdown_function('drupal_cron_cleanup');
+
+    // Lock cron semaphore
+    variable_set('cron_semaphore', time());
+
+    // Iterate through the modules calling their cron handlers (if any):
+    supercron_module_invoke_all_cron();
+
+    // Record cron time
+    variable_set('cron_last', time());
+    watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
+
+    // Release cron semaphore
+    variable_del('cron_semaphore');
+    drupal_goto(getenv("HTTP_REFERER"));
+  }
+}
+
+function supercron_module_set_exec_intervals_and_times_count($module, $start_time, $end_time) {
+  $interval = $end_time - $start_time;
+
+  db_query(
+    "UPDATE {supercron_enabled_mods} "
+      . "SET timestamp = %d,"
+      . " last_exec_interval = %d,"
+      . " total_exec_interval = total_exec_interval + %d,"
+      . " times_count = times_count + 1"
+      . " WHERE module_name = '%s'",
+    $start_time, $interval, $interval, $module
+  );
+}
+
+function supercron_clear_logs() {
+  if (module_exists('dblog') && variable_get(SUPERCRON_CLEAR_LOGS, TRUE)) {
+    db_query(
+      "DELETE FROM {watchdog} WHERE type = 'cron' AND severity = %d",
+      WATCHDOG_NOTICE
+    );
+  }
+}
+
+
+function supercron_module_add_output($module, $output) {
+  db_query(
+    "UPDATE {supercron_enabled_mods}"
+    . " SET output = Concat(output, '%s<br />')"
+    . " WHERE module_name = '%s'",
+    $output, $module
+  );
+}
+
+function supercron_module_invoke_all_cron() {
+  if (variable_get(SUPERCRON_CLEAR_LOGS, TRUE)) {
+    supercron_clear_logs();
+  }
+
+  module_load_include('inc', 'supercron', 'supercron');
+  return _supercron_module_invoke_all_cron();
+}
+
+function supercron_invoke_one($module, $return = FALSE, $multithread = FALSE) {
+  try {
+    ob_start();
+    $start_time = time();
+    module_invoke($module, 'cron');
+    supercron_module_set_exec_intervals_and_times_count($module, $start_time, time());
+    $output = ob_get_contents();
+    ob_end_clean();
+    if (!empty($output)) {
+      supercron_module_add_output($module, $output);
+    }
+
+    // Record cron time
+    variable_set('cron_last', time());
+  }
+  catch (Exception $e) {
+    ob_end_clean();
+    $massage = $e->getMessage();
+    watchdog(
+      'cron exception',
+      t("Module name: @module;\nException message: @message;"),
+      array(
+        '@module'  => $module,
+        '@message' => !empty($massage) ? $massage : t('no message')
+      ),
+      WATCHDOG_ERROR
+    );
+  }
+
+  if ($return) {
+    drupal_goto(getenv("HTTP_REFERER"));
+  }
+}
+
+// based on Kyle Florence's code at http://php.net/manual/en/function.rand.php
+function _supercron_rand_str($length = 128, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()_+=-[]{}\|\'"<>,.?/')
+{
+  mt_srand(); // not necessary, except when it is
+    // Length of character list
+    $chars_length = (strlen($chars) - 1);
+
+    // Start our string
+    $string = $chars{mt_rand(0, $chars_length)};
+
+    // Generate random string
+    for ($i = 1; $i < $length; $i = strlen($string))
+    {
+        // Grab a random character from our list
+        $r = $chars{rand(0, $chars_length)};
+
+        // Make sure the same two characters don't appear next to each other
+        if ($r != $string{$i - 1}) $string .=  $r;
+    }
+
+    // Return the string
+    return $string;
+}
+
+function _supercron_make_safety_token()
+{
+  return md5(_supercron_rand_str() . '-' .rand() .'-'. mt_rand() . '-' . _supercron_rand_str()); // yes, we are a tad paranoid
+}
+
+function _supercron_get_safety_variable() {
+    $value = variable_get(SUPERCRON_SAFETY_VARIABLE, '');
+    if (empty($value))
+    {
+        $value = _supercron_make_safety_token();
+        variable_set(SUPERCRON_SAFETY_VARIABLE, $value);
+    }
+  return $value;
+}
+
+function _supercron_parallel_call($url)
+{
+  $parts = parse_url($url);
+  $u     = $parts['path'] .'?'. $parts['query'];
+  $port  = isset($parts['port']) ? $parts['port'] : 80;
+  $fp    = fsockopen($parts['host'], $port, $errno, $errstr, 20);
+  if ($fp) {
+        $out = "GET {$u} HTTP/1.1\r\n";
+        $out .= "Host: {$parts['host']}\r\n";
+        $out .= "Connection: Close\r\n\r\n";
+        fwrite($fp, $out);
+
+        stream_set_blocking($fp, FALSE);
+        stream_set_timeout($fp, 2);
+        fclose($fp);
+      }
+}
+
+function supercron_list_of_cron_modules() {
+  return module_implements('cron', TRUE);
+}
+
+function supercron_fetch_all($sort = 0, $only_enabled = 0) {
+  $filter = $only_enabled ? ' WHERE enabled = 1' : '';
+  $sort   = $sort == 0 ? "ASC" : "DESC";
+
+  $modules = array();
+  $q = db_query('SELECT * FROM {supercron_enabled_mods}'. $filter .' ORDER BY weight ' . $sort);
+  while ($module = db_fetch_object($q)) {
+    $modules[] = $module;
+  }
+
+  return $modules;
+}
+
+function supercron_list_handled_modules() {
+  $result = array();
+  $modulenames = db_query('SELECT module_name FROM {supercron_enabled_mods} ORDER BY module_name ASC');
+  while ($row = db_fetch_object($modulenames)) {
+    $result [] = $row->module_name;
+  }
+  return $result;
+}
+
+function supercron_remove_disabled_modules() {
+  $modules = supercron_list_handled_modules();
+  foreach ($modules as $module) {
+    if (!module_hook($module, 'cron')) {
+      db_query('DELETE FROM {supercron_enabled_mods} WHERE module_name = \'%s\'', $module);
+    }
+  }
+}
+
+function supercron_update_module_list() {
+  supercron_remove_disabled_modules();
+  supercron_add_newly_enabled_modules();
+}
+
+function supercron_add_newly_enabled_modules() {
+  $modules = supercron_list_of_cron_modules();
+  $max_weight = db_result(db_query("SELECT MAX(weight) FROM {supercron_enabled_mods}"));
+  if ($max_weight == NULL) {
+    $max_weight = 0;
+  }
+  else {
+    $max_weight++;
+  }
+
+  foreach ($modules as $module) {
+    $is = db_result(db_query_range(
+      "SELECT COUNT(*) FROM {supercron_enabled_mods} WHERE module_name = '%s'",
+      $module, 0, 1
+    ));
+
+    if (!$is) {
+      db_query(
+        "INSERT INTO {supercron_enabled_mods} (module_name, weight, output) VALUES ('%s', %d, '')",
+        $module, $max_weight
+      );
+
+      $max_weight++;
+    }
+  }
+}
+
+function supercron_rule_is_valid($rule) {
+  // check for valid rule format
+  $format = '([0-9*,/-]+)';
+  $format = "@^{$format}\s+{$format}\s+{$format}\s+{$format}\s+{$format}$@";
+  if (!preg_match($format, $rule, $rules)) {
+    return FALSE;
+  }
+
+  return $rules;
+}
+
+function _supercron_module_invoke_all_cron() {
+  global $base_url;
+
+  $safety = _supercron_get_safety_variable();
+  supercron_update_module_list();
+  
+  $modules         = array();
+  $run_in_parallel = array();
+  foreach (supercron_fetch_all(0, 1) as $module) {
+    $modules[] = $module;
+    $run_in_parallel[$module->module_name] = $module->detached;
+  }
+  unset($modules_config_result);
+
+  // there is no cron jobs enabled.
+  if (empty($modules)) {
+    variable_set('cron_last', time());
+    return FALSE;
+  }
+
+  variable_set('cron_semaphore', time());
+
+  foreach ($modules as $module) {
+    if (FALSE === supercron_should_run($module)) {
+      continue;
+    }
+
+    if ($run_in_parallel[$module->module_name]) {
+      $url = supercron_get_script_URL();
+      $url .= '?safety='. drupal_urlencode($safety);
+      $url .= '&module='. drupal_urlencode($module->module_name);
+      $url .= '&multithread=yes';
+      _supercron_parallel_call($url);
+    }
+    else {
+      supercron_invoke_one($module->module_name);
+    }
+  }
+
+  // Record cron time
+  variable_set('cron_last', time());
+  watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
+
+  // Release cron semaphore
+  variable_del('cron_semaphore');
+
+  return TRUE;
+}
+
+/**
+ * Used by _supercron_should_run().
+ */
+function _supercronDecodeRule($rule, $min, $max) {
+  if ($rule == '*')
+    return range($min, $max);
+
+  $result = array();
+  foreach (explode(',', $rule) as $token) {
+    if (preg_match('/^([0-9]+)-([0-9]+)$/', $token, $r)) {
+      $result = array_merge($result, range($r[1], $r[2]));
+    }
+    elseif (preg_match('/^\*\/([0-9]+)$/', $token, $r)) {
+      for ($i = $min; $i <= $max; $i++)
+        if ($i % $r[1] == 0)
+          $result[] = $i;
+    }
+    elseif (is_numeric($token)) {
+      $result[] = $token;
+    }
+  }
+  return $result;
+}
+
+/**
+ * Used by _supercron_should_run().
+ */
+function _supercronT($time, $d = -1, $h = -1, $m = -1) {
+  if ($d < 0) {
+    return date('n', $time) * 31 * 24 * 60 + date('j', $time) * 24 * 60 + date('H', $time) * 60 + date('i', $time);
+  }
+  else {
+    return $time * 31 * 24 * 60 + $d * 24 * 60 + $h * 60 + $m;
+  }
+}
+
+/**
+ * Used by _supercron_should_run().
+ */
+function _supercronMonDaysFromWeekDays($year, $mon, $weekdays) {
+  $result = array();
+  for ($i = 1; checkdate($mon, $i, $year); $i++) {
+    $w = date('w', mktime(12, 00, 00, $mon, $i, $year));
+    if (in_array($w, $weekdays)) {
+      $result[] = $i;
+    }
+  }
+  return $result;
+}
+
+/**
+ * Limit job run by checking rule.
+ */
+function supercron_should_run($module) {
+  if (TRUE === empty($module->rule)) {
+    return TRUE;
+  }
+
+  $now = $_SERVER['REQUEST_TIME'];
+
+  // job never run or run one year ago
+  if ((!$module->timestamp) || ($now - $module->timestamp > 365 * 86400)) {
+    return TRUE;
+  }
+  
+  return _supercron_should_run($module, $now);
+}
+
+/**
+ * Time check
+ */
+function _supercron_should_run($module, $now) {
+  // check for valid rule format
+  $rules = supercron_rule_is_valid($rule, $module->rule);
+  if (FALSE === $rules) {
+    watchdog('cron', 'Invalid rule found (%module): %rule', array(
+      '%module' => $module->module_name,
+      '%rule'   => $module->rule
+    ));
+    
+    return FALSE;
+  }
+
+  $weekdayspec = ($rules[5] != '*');
+  $mondayspec  = ($rules[3] != '*');
+
+  $rules[5] = _supercronDecodeRule($rules[5], 0, 6);
+  $rules[4] = _supercronDecodeRule($rules[4], 1, 12);
+  $rules[3] = _supercronDecodeRule($rules[3], 1, 31);
+  $rules[2] = _supercronDecodeRule($rules[2], 0, 23);
+  $rules[1] = _supercronDecodeRule($rules[1], 0, 59);
+
+  $last_t     = _supercronT($module->timestamp + 30);
+  $now_t      = _supercronT($now);
+  $now_t_delta = $now_t - $last_t + ($last_t > $now_t ? 12 * 31 * 24 * 60 : 0);
+  $year      = date('Y', $module->timestamp);
+
+  if ($mondayspec || (!$mondayspec && !$weekdayspec)) {
+    $first = -1;
+
+    foreach ($rules[4] as $mon) {
+      foreach ($rules[3] as $d) {
+        if (checkdate($mon, $d, $year)) {
+          foreach ($rules[2] as $h) {
+            foreach ($rules[1] as $m) {
+              $t = _supercronT($mon, $d, $h, $m);
+
+              if ($first < 0) {
+                $first = $t;
+              }
+
+              if ($t > $last_t) {
+                $next_t = $t;
+                break 4;
+              }
+            }
+          }
+        }
+      }
+    }
+
+    if (!$next_t) {
+      $next_t = $first;
+    }
+
+    $next_t_delta = $next_t - $last_t + ($last_t > $next_t ? 12 * 31 * 24 * 60 : 0);
+
+    if ($now_t_delta >= $next_t_delta) {
+      return TRUE;
+    }
+  }
+
+  if ($weekdayspec) {
+    foreach ($rules[4] as $mon) {
+      foreach (_supercronMonDaysFromWeekDays($year, $mon, $rules[5]) as $d) {
+        foreach ($rules[2] as $h) {
+          foreach ($rules[1] as $m) {
+            $t = _supercronT($mon, $d, $h, $m);
+
+            if ($t > $last_t) {
+              $next_t = $t;
+              break 4;
+            }
+          }
+        }
+      }
+    }
+
+    if (!$next_t) {
+      // ust get the first of following year (if day_of_week is specified it's
+      // not the same of previous one)
+      foreach ($rules[4] as $mon) {
+        foreach (_supercronMonDaysFromWeekDays($year + 1, $mon, $rules[5]) as $d) {
+          foreach ($rules[2] as $h) {
+            foreach ($rules[1] as $m) {
+              $next_t = _supercronT($mon, $d, $h, $m);
+              break 4;
+            }
+          }
+        }
+      }
+    }
+
+    $next_t_delta = $next_t - $last_t + ($last_t > $next_t ? 12 * 31 * 24 * 60 : 0);
+
+    if ($now_t_delta >= $next_t_delta) {
+      return TRUE;
+    }
+  }
+
+  return FALSE;
+}
diff --git supercron.info supercron.info
index 77547e3..a29994b 100644
--- supercron.info
+++ supercron.info
@@ -1,7 +1,7 @@
-; $Id$
-name = SuperCron
-description = Get absolute control over Cron tasks
-core = 6.x
-version = 6.x-1.4-alpha
-php = 5.0
-depends[] = dblog
+; $Id$
+name = SuperCron
+description = Get absolute control over Cron tasks
+core = 6.x
+version = 6.x-1.4-alpha
+php = 5.0
+depends[] = dblog
diff --git supercron.install supercron.install
index 2a31dac..aba6bd1 100644
--- supercron.install
+++ supercron.install
@@ -1,142 +1,142 @@
-<?php
-// $Id$
-/**
- * @file
- * User supercron installation
- */
-
-include_once('supercron.inc');
-
-/**
- * Implement hook_schema().
- */
-function supercron_schema() {
-  $schema['supercron_enabled_mods'] = array(
-    'fields' => array(
-      'id'                  => array('type' => 'serial', 'not null' => TRUE),
-      'module_name'         => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE),
-      'weight'              => array('type' => 'int', 'not null' => TRUE),
-      'rule'                => array('type' => 'varchar', 'length' => '256', 'not null' => TRUE),
-      'output'              => array('type' => 'text', 'size' => 'big', 'not null' => TRUE),
-      'enabled'             => array('type' => 'int', 'not null' => TRUE, 'default' => 1),
-      'timestamp'           => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
-      'last_exec_interval'  => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
-      'total_exec_interval' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
-      'times_count'         => array('type' => 'int', 'size' => 'big', 'not null' => TRUE, 'default' => 0),
-      'detached'            => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
-    ),
-    'primary key' => array('id'),
-  );
-
-  $schema['supercron_ips'] = array(
-    'fields' => array(
-      'iid' => array('type' => 'serial', 'not null' => TRUE),
-      'ip'  => array('type' => 'text', 'size' => 'big', 'not null' => TRUE),
-    ),
-    'primary key' => array('iid'),
-  );
-  
-  return $schema;
-}
-
-/**
- * Necessary to avoid some attack scenarios where a safe URL or safety token is pre-planted in the variables table
- */
-function supercron_delete_all_variables() {
-  variable_del(SUPERCRON_FIREWALL_ENABLED_VARIABLE);
-  variable_del(SUPERCRON_SAFETY_VARIABLE);
-  variable_del(SUPERCRON_FIREWALL_MODE_VARIABLE);
-  variable_del(SUPERCRON_THROTTLE_SUPPORT_VARIABLE);
-  variable_del(SUPERCRON_CLEAR_LOGS);
-  variable_del(SUPERCRON_SCRIPT_PATH);
-  variable_del(SUPERCRON_PHP_BINARY_PATH);
-  variable_del(SUPERCRON_AUTOCRON_TRESHOLD);
-  variable_del(SUPERCRON_AUTOCRON_ENABLED);
-  variable_del(SUPERCRON_AUTOCRON_AUTOENABLED);
-  variable_del(SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD);
-  variable_del(SUPERCRON_AUTOCRON_URL);
-  variable_del(SUPERCRON_EXCEPTIONS_RSS_URL);
-}
-
-/**
- * Implement hook_install().
- */
-function supercron_install() {
-
-  // Better be safe
-  supercron_delete_all_variables();
-
-  // Install supercron schema.
-  drupal_install_schema('supercron');
-
-  // Create a random safety token.
-  $ignore = _supercron_get_safety_variable();
-  
-  // Insert host IP address to supercon_ips table -- Allow cron run requests from these IPs
-  $inserted_ips = array();
-  $host_ips = gethostbynamel($_SERVER['HTTP_HOST']);
-  if (!empty($host_ips)) {
-    foreach (gethostbynamel($_SERVER['HTTP_HOST']) as $ip) {
-      db_query("INSERT INTO {supercron_ips} (ip) VALUES ('%s')", $ip);
-      $inserted_ips[] = $ip;
-    }
-  }
-
-  if (!in_array('127.0.0.1', $inserted_ips)) {
-    db_query("INSERT INTO {supercron_ips} (ip) VALUES ('%s')", '127.0.0.1');
-  }
-
-  // First module settings
-  supercron_update_module_list();
-
-  // Import Elysia Cron schedule settings if they exist
-  $modules = supercron_list_of_cron_modules();
-  foreach ($modules as $module)
-  {
-      $schedule = variable_get('ec_' . $module . '_cron_rul', '');
-      $disabled = variable_get('ec_' . $module . '_cron_d', 0) == '1';
-      if (!empty($schedule))
-      {
-        db_query('UPDATE {supercron_enabled_mods} SET rule=\'%s\', enabled=%d WHERE module_name = \'%s\' LIMIT 1', array($schedule, !$disabled, $module));
-      }
-
-  }
-
-  // Keep Poormanscron settings is they exist
-  variable_set(SUPERCRON_AUTOCRON_TRESHOLD, variable_get('cron_safe_threshold', 180));
-  if (module_exists('poormanscron'))
-    variable_set(SUPERCRON_AUTOCRON_ENABLED,(variable_get('cron_safe_threshold', 0) != 0));
-  else
-    variable_set(SUPERCRON_AUTOCRON_ENABLED, FALSE);
-
-  // Set some defaults
-  variable_set(SUPERCRON_AUTOCRON_AUTOENABLED, TRUE);
-  variable_set(SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD, SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD_DEFAULT); // 12 hours in seconds
-
-}
-
-/**
- * Implement hook_uninstall().
- */
-function supercron_uninstall() {
-  // Uninstall supercron schema.
-  drupal_uninstall_schema('supercron');
-
-  // Remove no longer needed variables.
-  supercron_delete_all_variables();
-}
-
-/**
- * Update script to add 'rule' column to supercron_enabled_mods table.
- */
-function supercron_update_1() {
-  $rets = array();
-  $field = array(
-    'type'     => 'varchar',
-    'length'   => '256',
-    'not null' => TRUE,
-  );
-  db_add_field($rets, 'supercron_enabled_mods', 'rule', $field);
-
-  return $rets;
-}
+<?php
+// $Id$
+/**
+ * @file
+ * User supercron installation
+ */
+
+include_once('supercron.inc');
+
+/**
+ * Implement hook_schema().
+ */
+function supercron_schema() {
+  $schema['supercron_enabled_mods'] = array(
+    'fields' => array(
+      'id'                  => array('type' => 'serial', 'not null' => TRUE),
+      'module_name'         => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE),
+      'weight'              => array('type' => 'int', 'not null' => TRUE),
+      'rule'                => array('type' => 'varchar', 'length' => '256', 'not null' => TRUE),
+      'output'              => array('type' => 'text', 'size' => 'big', 'not null' => TRUE),
+      'enabled'             => array('type' => 'int', 'not null' => TRUE, 'default' => 1),
+      'timestamp'           => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'last_exec_interval'  => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'total_exec_interval' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'times_count'         => array('type' => 'int', 'size' => 'big', 'not null' => TRUE, 'default' => 0),
+      'detached'            => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+    ),
+    'primary key' => array('id'),
+  );
+
+  $schema['supercron_ips'] = array(
+    'fields' => array(
+      'iid' => array('type' => 'serial', 'not null' => TRUE),
+      'ip'  => array('type' => 'text', 'size' => 'big', 'not null' => TRUE),
+    ),
+    'primary key' => array('iid'),
+  );
+  
+  return $schema;
+}
+
+/**
+ * Necessary to avoid some attack scenarios where a safe URL or safety token is pre-planted in the variables table
+ */
+function supercron_delete_all_variables() {
+  variable_del(SUPERCRON_FIREWALL_ENABLED_VARIABLE);
+  variable_del(SUPERCRON_SAFETY_VARIABLE);
+  variable_del(SUPERCRON_FIREWALL_MODE_VARIABLE);
+  variable_del(SUPERCRON_THROTTLE_SUPPORT_VARIABLE);
+  variable_del(SUPERCRON_CLEAR_LOGS);
+  variable_del(SUPERCRON_SCRIPT_PATH);
+  variable_del(SUPERCRON_PHP_BINARY_PATH);
+  variable_del(SUPERCRON_AUTOCRON_TRESHOLD);
+  variable_del(SUPERCRON_AUTOCRON_ENABLED);
+  variable_del(SUPERCRON_AUTOCRON_AUTOENABLED);
+  variable_del(SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD);
+  variable_del(SUPERCRON_AUTOCRON_URL);
+  variable_del(SUPERCRON_EXCEPTIONS_RSS_URL);
+}
+
+/**
+ * Implement hook_install().
+ */
+function supercron_install() {
+
+  // Better be safe
+  supercron_delete_all_variables();
+
+  // Install supercron schema.
+  drupal_install_schema('supercron');
+
+  // Create a random safety token.
+  $ignore = _supercron_get_safety_variable();
+  
+  // Insert host IP address to supercon_ips table -- Allow cron run requests from these IPs
+  $inserted_ips = array();
+  $host_ips = gethostbynamel($_SERVER['HTTP_HOST']);
+  if (!empty($host_ips)) {
+    foreach (gethostbynamel($_SERVER['HTTP_HOST']) as $ip) {
+      db_query("INSERT INTO {supercron_ips} (ip) VALUES ('%s')", $ip);
+      $inserted_ips[] = $ip;
+    }
+  }
+
+  if (!in_array('127.0.0.1', $inserted_ips)) {
+    db_query("INSERT INTO {supercron_ips} (ip) VALUES ('%s')", '127.0.0.1');
+  }
+
+  // First module settings
+  supercron_update_module_list();
+
+  // Import Elysia Cron schedule settings if they exist
+  $modules = supercron_list_of_cron_modules();
+  foreach ($modules as $module)
+  {
+      $schedule = variable_get('ec_' . $module . '_cron_rul', '');
+      $disabled = variable_get('ec_' . $module . '_cron_d', 0) == '1';
+      if (!empty($schedule))
+      {
+        db_query('UPDATE {supercron_enabled_mods} SET rule=\'%s\', enabled=%d WHERE module_name = \'%s\' LIMIT 1', array($schedule, !$disabled, $module));
+      }
+
+  }
+
+  // Keep Poormanscron settings is they exist
+  variable_set(SUPERCRON_AUTOCRON_TRESHOLD, variable_get('cron_safe_threshold', 180));
+  if (module_exists('poormanscron'))
+    variable_set(SUPERCRON_AUTOCRON_ENABLED,(variable_get('cron_safe_threshold', 0) != 0));
+  else
+    variable_set(SUPERCRON_AUTOCRON_ENABLED, FALSE);
+
+  // Set some defaults
+  variable_set(SUPERCRON_AUTOCRON_AUTOENABLED, TRUE);
+  variable_set(SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD, SUPERCRON_AUTOCRON_AUTOENABLED_TRESHOLD_DEFAULT); // 12 hours in seconds
+
+}
+
+/**
+ * Implement hook_uninstall().
+ */
+function supercron_uninstall() {
+  // Uninstall supercron schema.
+  drupal_uninstall_schema('supercron');
+
+  // Remove no longer needed variables.
+  supercron_delete_all_variables();
+}
+
+/**
+ * Update script to add 'rule' column to supercron_enabled_mods table.
+ */
+function supercron_update_1() {
+  $rets = array();
+  $field = array(
+    'type'     => 'varchar',
+    'length'   => '256',
+    'not null' => TRUE,
+  );
+  db_add_field($rets, 'supercron_enabled_mods', 'rule', $field);
+
+  return $rets;
+}
diff --git supercron.module supercron.module
index 911ebdb..2d084c2 100644
--- supercron.module
+++ supercron.module
@@ -1,20 +1,20 @@
-<?php
-// $Id$
-
-/**
- * @file
- * The supercron module functions.
- */
-
-/*
- * It is possible for a cron call to be started *just* before this module is disabled during
- * uninstallation, and to complete right after uninstallation is complete. This conditional insert
- * allows these scenarios to not have consequenceson the uninstallation process.
- *
- * We'll say it here and again in the code: the team at 63reasons is paranoid about code
- * stability. We want to reduce any source of error as much as we can.
- */
-
-
-if (function_exists('drupal_get_path')) include_once(drupal_get_path('module', 'supercron') . '/supercron-main.inc');
-
+<?php
+// $Id$
+
+/**
+ * @file
+ * The supercron module functions.
+ */
+
+/*
+ * It is possible for a cron call to be started *just* before this module is disabled during
+ * uninstallation, and to complete right after uninstallation is complete. This conditional insert
+ * allows these scenarios to not have consequenceson the uninstallation process.
+ *
+ * We'll say it here and again in the code: the team at 63reasons is paranoid about code
+ * stability. We want to reduce any source of error as much as we can.
+ */
+
+
+if (function_exists('drupal_get_path')) include_once(drupal_get_path('module', 'supercron') . '/supercron-main.inc');
+
diff --git supercron.php supercron.php
index b5c3d75..406a37a 100644
--- supercron.php
+++ supercron.php
@@ -1,90 +1,90 @@
-<?php
-// $Id$
-
-/**
- * @file
- * Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).
- */
-
-// If you place your supercron.php in other place than Drupal root, or supercron
-// directory. Specify your script here.
-// $drupal_dir = '';
-
-// Ignore user aborts and allow the script to run forever
-ignore_user_abort(TRUE);
-
-// Finding Drupal root directory
-if (!isset($drupal_dir)) {
-  if (!file_exists('includes/bootstrap.inc')) {
-    $exp = '@^(.*)[\\\/]sites[\\\/][^\\\/]+[\\\/]modules[\\\/]supercron$@';
-    preg_match($exp, getcwd(), $matches);
-    
-    if (!empty($matches)) {
-      chdir($matches[1]);
-    }
-  }
-}
-else {
-  chdir($drupal_dir);
-}
-
-if (!file_exists('includes/bootstrap.inc')) {
-  exit('Can not find Drupal directory.');
-}
-
-// Running full Drupal bootstrap
-include_once './includes/bootstrap.inc';
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
-
-$safety       = isset($_GET['safety']) ? $_GET['safety'] : '';
-$valid_safety = $safety === variable_get(SUPERCRON_SAFETY_VARIABLE, NULL);
-
-// IP authorization check
-if (variable_get(SUPERCRON_FIREWALL_ENABLED_VARIABLE, FALSE)) {
-  $mode   = variable_get(SUPERCRON_FIREWALL_MODE_VARIABLE, 'only');
-  $ip     = ip_address();
-  if (is_null($ip)) $ip = '127.0.0.1'; // bash calls return a null calling IP
-  $result = db_query('SELECT * FROM {supercron_ips}');
-  
-  $authorized = $mode === 'except';
-  while ($dbip = db_fetch_object($result)) {
-    if ($ip == $dbip->ip) {
-      $authorized = $mode === 'only';
-      break;
-    }
-  }
-
-  if (!$authorized) {
-    exit("IP '$ip' not authorized!");
-  }
-}
-
-// Throttle check
-if (
-  module_exists('throttle') 
-  && variable_get(SUPERCRON_THROTTLE_SUPPORT_VARIABLE, FALSE)
-  && throttle_status()
-) {
-  exit('Site is under heavy load; cron tasks postponed.');
-}
-
-variable_set(SUPERCRON_PHP_BINARY_PATH, $_SERVER['_']);
-
-if ($safety) {
-  if (!$valid_safety) {
-    exit('Safety mismatch');
-  }
-  
-  $module = isset($_GET['module']) ? $_GET['module'] : '';
-  if (!module_exists($module)) {
-    exit('Specifically-called module does not exist');
-  }
-
-  // multi thread check
-  $multithread = isset($_GET['multithread']) ? $_GET['multithread'] : '';
-  $multithread = $multithread === 'yes';
-  supercron_invoke_one($module, FALSE, $multithread);
-}
-else {
-  supercron_module_invoke_all_cron();
-}
+<?php
+// $Id$
+
+/**
+ * @file
+ * Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).
+ */
+
+// If you place your supercron.php in other place than Drupal root, or supercron
+// directory. Specify your script here.
+// $drupal_dir = '';
+
+// Ignore user aborts and allow the script to run forever
+ignore_user_abort(TRUE);
+
+// Finding Drupal root directory
+if (!isset($drupal_dir)) {
+  if (!file_exists('includes/bootstrap.inc')) {
+    $exp = '@^(.*)[\\\/]sites[\\\/][^\\\/]+[\\\/]modules[\\\/]supercron$@';
+    preg_match($exp, getcwd(), $matches);
+    
+    if (!empty($matches)) {
+      chdir($matches[1]);
+    }
+  }
+}
+else {
+  chdir($drupal_dir);
+}
+
+if (!file_exists('includes/bootstrap.inc')) {
+  exit('Can not find Drupal directory.');
+}
+
+// Running full Drupal bootstrap
+include_once './includes/bootstrap.inc';
+drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+
+$safety       = isset($_GET['safety']) ? $_GET['safety'] : '';
+$valid_safety = $safety === variable_get(SUPERCRON_SAFETY_VARIABLE, NULL);
+
+// IP authorization check
+if (variable_get(SUPERCRON_FIREWALL_ENABLED_VARIABLE, FALSE)) {
+  $mode   = variable_get(SUPERCRON_FIREWALL_MODE_VARIABLE, 'only');
+  $ip     = ip_address();
+  if (is_null($ip)) $ip = '127.0.0.1'; // bash calls return a null calling IP
+  $result = db_query('SELECT * FROM {supercron_ips}');
+  
+  $authorized = $mode === 'except';
+  while ($dbip = db_fetch_object($result)) {
+    if ($ip == $dbip->ip) {
+      $authorized = $mode === 'only';
+      break;
+    }
+  }
+
+  if (!$authorized) {
+    exit("IP '$ip' not authorized!");
+  }
+}
+
+// Throttle check
+if (
+  module_exists('throttle') 
+  && variable_get(SUPERCRON_THROTTLE_SUPPORT_VARIABLE, FALSE)
+  && throttle_status()
+) {
+  exit('Site is under heavy load; cron tasks postponed.');
+}
+
+variable_set(SUPERCRON_PHP_BINARY_PATH, $_SERVER['_']);
+
+if ($safety) {
+  if (!$valid_safety) {
+    exit('Safety mismatch');
+  }
+  
+  $module = isset($_GET['module']) ? $_GET['module'] : '';
+  if (!module_exists($module)) {
+    exit('Specifically-called module does not exist');
+  }
+
+  // multi thread check
+  $multithread = isset($_GET['multithread']) ? $_GET['multithread'] : '';
+  $multithread = $multithread === 'yes';
+  supercron_invoke_one($module, FALSE, $multithread);
+}
+else {
+  supercron_module_invoke_all_cron();
+}
