Fix for Code

  1. <?php
  2. function bootstrap($drupaldir, $http_host = 'example.com') {
  3.   // Change to the Drupal directory.
  4.   chdir($drupaldir);
  5.  
  6.   // Set some server variables so Drupal doesn't freak out.
  7.   $_SERVER['SCRIPT_NAME']     = '/script.php';
  8.   $_SERVER['SCRIPT_FILENAME'] = '/script.php';
  9.   $_SERVER['HTTP_HOST']       = $http_host;
  10.   $_SERVER['REMOTE_ADDR']     = NULL;
  11.   $_SERVER['REQUEST_METHOD']  = 'POST';
  12.  
  13.   // Load Drupal.
  14.   require_once('includes/bootstrap.inc');
  15.   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  16.  
  17.   // Allow script to run forever.
  18.   set_time_limit(0);
  19.   ini_set('memory_limit', '2G');
  20.  
  21.   // Log in as admin user.
  22.   global $user;
  23.   $user = user_load(array('uid' => 1));
  24.  
  25. }
  26. $type=article;
  27. function dedupe($type) {
  28.   $previous = array();
  29.   $result = db_query("SELECT nid, title FROM {node}
  30.    WHERE title IN
  31.       (SELECT title FROM {node}
  32.        WHERE type = '%s'
  33.        GROUP BY title HAVING count(*) > 1)
  34.    ORDER BY title, created DESC", $type);
  35.   while ($row = db_fetch_array($result)) {
  36.     if ($row['title'] == $previous['title']) {
  37.       node_delete($previous['nid']);
  38.     }
  39.     $previous = $row;
  40.   }
  41. }
  42.  
  43. ?>

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.