svncommit
2009-05-12 f22c2cefb4c7f8b1a995d5de6f706d49861c473c
bin/msgimport.sh
@@ -1,7 +1,10 @@
#!/usr/bin/php
#!/usr/bin/env php
<?php
if (php_sapi_name() != 'cli') {
    die('Not on the "shell" (php-cli).');
}
define('INSTALL_PATH', preg_replace('/bin\/$/', '', getcwd()) . '/');
define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
ini_set('memory_limit', -1);
require_once INSTALL_PATH.'program/include/iniset.php';
@@ -77,11 +80,14 @@
}
// prompt for password
echo "Password: ";
$args['pass'] = trim(fgets(STDIN));
if (empty($args['pass']))
{
   echo "Password: ";
   $args['pass'] = trim(fgets(STDIN));
// clear password input
echo chr(8)."\rPassword: ".str_repeat("*", strlen($args['pass']))."\n";
   // clear password input
   echo chr(8)."\rPassword: ".str_repeat("*", strlen($args['pass']))."\n";
}
// parse $host URL
$a_host = parse_url($args['host']);
@@ -119,7 +125,7 @@
            if ($IMAP->save_message($args['mbox'], rtrim($message)))
               $count++;
            else
               die("Failed to save message to $mailbox\n");
               die("Failed to save message to {$args['mbox']}\n");
            $message = '';
         }
         continue;
@@ -134,7 +140,7 @@
   // upload message from file
   if ($count)
      print "$count messages successfully added to $mailbox.\n";
      print "$count messages successfully added to {$args['mbox']}.\n";
   else
      print "Adding messages failed!\n";
}
@@ -143,4 +149,4 @@
   print "IMAP login failed.\n";
}
?>
?>