Changeset 3998 in subversion


Ignore:
Timestamp:
Sep 29, 2010 4:30:56 AM (3 years ago)
Author:
thomasb
Message:

Pool some code for command line tools; avoid displaying password on shell (#1486947); fix msgexport now using the new imap wrapper

Location:
trunk/roundcubemail
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r3994 r3998  
    22=========================== 
    33 
     4- Fix msgexport.sh now using the new imap wrapper 
     5- Avoid displaying password on shell (#1486947) 
    46- Only lower-case user name if first login attempt failed (#1486393) 
    57- Make alias setting in squirrelmail_usercopy plugin configurable (patch by pommi, #1487007) 
  • trunk/roundcubemail/bin/msgexport.sh

    r3367 r3998  
    11#!/usr/bin/env php 
    22<?php 
    3 if (php_sapi_name() != 'cli') { 
    4     die('Not on the "shell" (php-cli).'); 
    5 } 
    63 
    74define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); 
    85ini_set('memory_limit', -1); 
    96 
    10 require_once INSTALL_PATH.'program/include/iniset.php'; 
    11  
    12 /** 
    13  * Parse commandline arguments into a hash array 
    14  */ 
    15 function get_opt($aliases=array()) 
    16 { 
    17         $args = array(); 
    18         for ($i=1; $i<count($_SERVER['argv']); $i++) 
    19         { 
    20                 $arg = $_SERVER['argv'][$i]; 
    21                 if (substr($arg, 0, 2) == '--') 
    22                 { 
    23                         $sp = strpos($arg, '='); 
    24                         $key = substr($arg, 2, $sp - 2); 
    25                         $value = substr($arg, $sp+1); 
    26                 } 
    27                 else if ($arg{0} == '-') 
    28                 { 
    29                         $key = substr($arg, 1); 
    30                         $value = $_SERVER['argv'][++$i]; 
    31                 } 
    32                 else 
    33                         continue; 
    34  
    35                 $args[$key] = preg_replace(array('/^["\']/', '/["\']$/'), '', $value); 
    36                  
    37                 if ($alias = $aliases[$key]) 
    38                         $args[$alias] = $args[$key]; 
    39         } 
    40  
    41         return $args; 
    42 } 
     7require_once INSTALL_PATH.'program/include/clisetup.php'; 
    438 
    449function print_usage() 
     
    9055                 
    9156                fwrite($out, sprintf("From %s %s UID %d\n", $from['mailto'], $headers->date, $headers->uid)); 
    92                 fwrite($out, iil_C_FetchPartHeader($IMAP->conn, $mbox, $i, null)); 
    93                 fwrite($out, iil_C_HandlePartBody($IMAP->conn, $mbox, $i, null, 1)); 
     57                fwrite($out, $IMAP->conn->fetchPartHeader($mbox, $i)); 
     58                fwrite($out, $IMAP->conn->handlePartBody($mbox, $i)); 
    9459                fwrite($out, "\n\n\n"); 
    9560                 
     
    12691 
    12792// prompt for password 
    128 vputs("Password: "); 
    129 $args['pass'] = trim(fgets(STDIN)); 
     93$args['pass'] = prompt_silent("Password: "); 
    13094 
    13195 
  • trunk/roundcubemail/bin/msgimport.sh

    r2229 r3998  
    11#!/usr/bin/env php 
    22<?php 
    3 if (php_sapi_name() != 'cli') { 
    4     die('Not on the "shell" (php-cli).'); 
    5 } 
    63 
    74define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); 
    85ini_set('memory_limit', -1); 
    96 
    10 require_once INSTALL_PATH.'program/include/iniset.php'; 
    11  
    12 /** 
    13  * Parse commandline arguments into a hash array 
    14  */ 
    15 function get_opt($aliases=array()) 
    16 { 
    17         $args = array(); 
    18         for ($i=1; $i<count($_SERVER['argv']); $i++) 
    19         { 
    20                 $arg = $_SERVER['argv'][$i]; 
    21                 if (substr($arg, 0, 2) == '--') 
    22                 { 
    23                         $sp = strpos($arg, '='); 
    24                         $key = substr($arg, 2, $sp - 2); 
    25                         $value = substr($arg, $sp+1); 
    26                 } 
    27                 else if ($arg{0} == '-') 
    28                 { 
    29                         $key = substr($arg, 1); 
    30                         $value = $_SERVER['argv'][++$i]; 
    31                 } 
    32                 else 
    33                         continue; 
    34  
    35                 $args[$key] = preg_replace(array('/^["\']/', '/["\']$/'), '', $value); 
    36                  
    37                 if ($alias = $aliases[$key]) 
    38                         $args[$alias] = $args[$key]; 
    39         } 
    40  
    41         return $args; 
    42 } 
     7require_once INSTALL_PATH.'program/include/clisetup.php'; 
    438 
    449function print_usage() 
     
    8348if (empty($args['pass'])) 
    8449{ 
    85         echo "Password: "; 
    86         $args['pass'] = trim(fgets(STDIN)); 
    87  
    88         // clear password input 
    89         echo chr(8)."\rPassword: ".str_repeat("*", strlen($args['pass']))."\n"; 
     50        $args['pass'] = prompt_silent("Password: "); 
    9051} 
    9152 
Note: See TracChangeset for help on using the changeset viewer.