Changeset 1385

Show
Ignore:
Timestamp:
05/01/05 23:47:37 (4 years ago)
Author:
anarcat
Message:

lire les options et ne pas imprimer d'info si -v n'est pas present

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bin/alternc_stats_web.php

    r1365 r1385  
    5656$argv0 = array_shift($argv); 
    5757 
     58# crude getopt for portability 
     59$verbose = 0; 
     60foreach ($argv as $pos => $arg) { 
     61  if ($arg == "-v") { 
     62    unset($argv[$pos]); 
     63    $verbose = 1; 
     64  } 
     65} 
     66 
    5867// process all logfiles 
    5968foreach ($argv as $file) { 
    6069 
    61  echo "################################################\n"; 
    62  echo date("d/m/Y H:i:s")." : Traitement de $file\n"; 
    63  echo "################################################\n"; 
    64  
     70  if ($verbose) { 
     71    echo "################################################\n"; 
     72    echo date("d/m/Y H:i:s")." : Traitement de $file\n"; 
     73    echo "################################################\n"; 
     74  } 
    6575 
    6676if (substr($file,-3)==".gz") { 
     
    112122    $domstat[$mat[6]."/".$day]["size"]+=intval($mat[5]); 
    113123  } else { 
    114     printf("Can't parse: %.60s...\n", $s); 
     124    if ($verbose) 
     125      printf("Can't parse: %.60s...\n", $s); 
    115126  } 
    116127  if ($i/100==intval($i/100)) { echo "."; flush(); } 
     
    119130  // insérer une fois que notre bloc de lignes est plein 
    120131  if ($i==$each) { 
    121     echo " $l lines read\nInserting... "; 
     132    if ($verbose) echo " $l lines read\nInserting... "; 
    122133    insert_stuff($domstat, $mat, &$domuid); 
    123134    $i=0; 
     
    126137 
    127138// insérer les lignes qui n'avaient pas rempli un bloc 
    128  echo " $l lines read\nInserting remaining lines... "; 
     139if ($verbose) echo " $l lines read\nInserting remaining lines... "; 
    129140 insert_stuff($domstat, $mat, &$domuid);  
    130141 
     
    135146// handy function to avoid a copy-paste 
    136147function insert_stuff($domstat, $mat, &$domuid) { 
     148  global $verbose; 
    137149    // on insère le tableau dans mysql. 
    138150    $update=0; $insert=0; 
     
    155167      mysql_query($sql) || die("Query failed: " . mysql_error()); 
    156168    } 
    157     echo "$update updates and $insert inserts (uidcache size = ".count($domuid).") \n"; 
     169    if ($verbose) echo "$update updates and $insert inserts (uidcache size = ".count($domuid).") \n"; 
    158170} 
    159171