Changeset 145

Show
Ignore:
Timestamp:
05/23/06 10:38:18 (3 years ago)
Author:
ludo
Message:

fixes and improvements for OCSng clients (from r3446)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/webmin/lrs-inventory/agent/transfertNG.php

    r135 r145  
    3737        fclose($stdin); 
    3838        // Uncompress it 
    39         $DATA = gzuncompress($data); 
    40          
    41         system("rm /tmp/${_SERVER[REMOTE_ADDR]}.tmp -f"); 
     39        // Write it in a temporary file (proc_open is only for php >=4.3) 
     40        $tname = tempnam("/tmp", "OCS"); 
     41        $fh = fopen($tname, 'w');   
     42        fwrite($fh,$data);   
     43        fclose($fh);   
     44        exec("perl uncompress.pl $tname",$DATA);   
     45        $DATA = join('',$DATA);   
     46        unlink($tname); 
    4247         
    4348        // Retrieve query and sender 
     
    5560                $resp = '<?xml version="1.0" encoding="utf-8" ?><REPLY><RESPONSE>SEND</RESPONSE></REPLY>'; 
    5661        } 
     62        if ( $QUERY=='UPDATE' ) { 
     63                // Always send the inventory 
     64                $resp = '<?xml version="1.0" encoding="utf-8" ?><REPLY><RESPONSE>no_update</RESPONSE></REPLY>'; 
     65        } 
    5766        else if ( $QUERY=='INVENTORY' ) 
    5867        { 
    5968                // Extract inventory data 
    6069                ereg('<CONTENT>(.+)<\/CONTENT>', $DATA, $matches); 
    61                 $INVENTORY = '<?xml version="1.0" encoding="utf-8" ?><Inventory>'. $matches[1] .'</Inventory>'; 
     70                eregi(' encoding="([^"]+)"', $DATA, $matches2); 
     71                $enc = $matches2[1]; 
     72                 
     73                $INVENTORY = '<?xml version="1.0" encoding="'.$enc.'" ?><Inventory>'. $matches[1] .'</Inventory>'; 
    6274                $resp = '<?xml version="1.0" encoding="utf-8" ?><REPLY><RESPONSE>no_account_update</RESPONSE></REPLY>'; 
    6375 
  • trunk/webmin/lrs-inventory/classes/Drivers/Sql/SqlDriver.php

    r135 r145  
    10261026                        $hastbl = "hasBootGeneral"; 
    10271027                        if ($type == "") $hastbl = "hasHardware"; 
    1028                         $sql = "SELECT m.Name, TO_DAYS(NOW()) - TO_DAYS(MAX(i.Date)) as maxi  
     1028                        $sql = "SELECT m.Name, TO_DAYS(NOW()) - TO_DAYS(MAX(i.Date)) as maxi, i.Date, i.Time 
    10291029                        FROM Machine m, $hastbl h, Inventory i WHERE 
    10301030                        h.Machine=m.Id AND h.Inventory=i.Id GROUP BY m.Name;"; 
     
    10341034                while ( $connection->next_record() ) { 
    10351035                        if ($date <=0 || ($date > 0 && $connection->Record['maxi'] >= $date)) 
    1036                                 $ret[] = $connection->Record['Name']; 
     1036                                $ret[] = array ( $connection->Record['Name'], 
     1037                                                 $connection->Record['Date'], 
     1038                                                 $connection->Record['Time'] 
     1039                                                ); 
    10371040                 
    10381041                } 
  • trunk/webmin/lrs-inventory/classes/Drivers/Xml/Maps/OcsNGMap.xml

    r135 r145  
    7575                <MappedField from="MANUFACTURER" to="Manuf" /> 
    7676                <MappedField from="TYPE" to="Type" /> 
     77                <MappedField from="SERIAL" to="Serial" /> 
    7778 
    7879        </MappedObject> 
  • trunk/webmin/lrs-inventory/classes/Drivers/Xml/XmlDriver.php

    r135 r145  
    1414        var $m_MappedFields; 
    1515        var $m_DataPath; 
     16        var $m_UTF8 = false; 
    1617 
    1718        function XmlDriver($source, $parameters) 
     
    196197 
    197198                $parser = & $this->createParser($machine); 
    198                          
     199                 
     200                if (eregi(" encoding=.utf-8.", $content)) { 
     201                        $this->m_UTF8 = true; 
     202                } 
     203                 
    199204                xml_parse($parser, $content); 
    200205 
     
    262267                                        { 
    263268                                                global $datasource; 
    264                                                 $datasource->loadComponentClass($class); 
     269                                                @$datasource->loadComponentClass($class); 
    265270                                        } 
    266271 
     
    323328                        $object = & $GLOBALS['CURRENTOBJECT']; 
    324329         
    325                         $object->setProperty($GLOBALS['CURRENTFIELD'], utf8_decode($data)); 
     330                        if ($this->m_UTF8) { $data = utf8_decode($data); } 
     331                        $object->setProperty($GLOBALS['CURRENTFIELD'], $data); 
    326332         
    327333                        $machine = & $GLOBALS['CURRENTMACHINE']; 
  • trunk/webmin/lrs-inventory/config

    r133 r145  
    33adresse_mail=ocsinventory 
    44showempty=1 
     5genfromocs=0 
  • trunk/webmin/lrs-inventory/config.info

    r133 r145  
    33adresse_mail=Email,0 
    44showempty=Show hosts with no inventory,1,1-Yes,0-No 
     5genfromocs=Show general information using:,1,1-OCS Inventory,0-PXE Boot Inventory 
  • trunk/webmin/lrs-inventory/config.info.fr

    r133 r145  
    33adresse_mail=Adresse mail,0 
    44showempty=Afficher les clients sans inventaire,1,1-Oui,0-Non 
     5genfromocs=Afficher les informations générales en utilisant:,1,1-L'inventaire OCS,0-L'inventaire au boot PXE 
  • trunk/webmin/lrs-inventory/debian/changelog

    r135 r145  
    1 webmin-lrs-inventory (2.0.9) stable; urgency=low 
     1webmin-lrs-inventory (2.1.0) stable; urgency=low 
    22 
    33  * First package. Replaces webmin-lbs-inventory 
  • trunk/webmin/lrs-inventory/functions.php

    r133 r145  
    588588        } 
    589589 
     590        /** 
     591         * 
     592         */ 
    590593        function getMacForMachine(&$machine) 
    591594        { 
     
    605608        } 
    606609         
    607          
    608  
     610        /** 
     611         * Reverse a date (should be in lbs_common ?) 
     612         * 
     613         * @param data string containing a date like DD/MM/YYYY 
     614         * @return returns YYYY-MM-DD. 
     615         */ 
     616        function dateReverseToSQL($data) 
     617        { 
     618                global $reversedate; 
     619                if (!$reversedate) return $data; 
     620 
     621                $ret = ereg_replace("([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})", "\\3-\\2-\\1", $data); 
     622                return $ret; 
     623        } 
     624 
     625        /** 
     626         * Reverse a date (should be in lbs_common ?) 
     627         * 
     628         * @param data string containing a date like YYYY-MM-DD 
     629         * @return returns DD/MM/YYYY. 
     630         */ 
     631        function dateReverseFromSQL($data) 
     632        { 
     633                global $reversedate; 
     634                if (!$reversedate) return $data; 
     635 
     636                $ret = ereg_replace("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", "\\3/\\2/\\1", $data); 
     637                return $ret; 
     638        } 
     639         
    609640?> 
  • trunk/webmin/lrs-inventory/general.cgi

    r133 r145  
    2929        print perl_exec("./lbs_header.cgi", array("lrs-inventory general", $text{'title_gen'}, "general")); 
    3030 
    31         renderTable('BootGeneral', 'System.tpl', array(), null, 'FilterSplitPipe'); 
     31        if ($config['genfromocs'] == "1") { 
     32                renderTable('Bios', 'SystemOCS.tpl'); 
     33        } else { 
     34                renderTable('BootGeneral', 'System.tpl', array(), null, 'FilterSplitPipe'); 
     35        }                
     36         
    3237        renderTable('Hardware', 'OS.tpl' ); 
    3338 
  • trunk/webmin/lrs-inventory/lang/en

    r133 r145  
    7070 
    7171no=No 
     72 
     73received=received at 
  • trunk/webmin/lrs-inventory/lang/fr

    r133 r145  
    5757 
    5858no=Non 
     59 
     60received=reçu le 
  • trunk/webmin/lrs-inventory/module.info

    r135 r145  
    33desc_fr=LRS : Inventaire 
    44depends=1.030 lbs_common 
    5 version=2.0.9 
     5version=2.1.0 
  • trunk/webmin/lrs-inventory/sql/create-db.sh

    r135 r145  
    4242    echo "Create the database" 
    4343    create 
     44    VER=1 
    4445    upgrade 
    4546else 
  • trunk/webmin/lrs-inventory/status.cgi

    r133 r145  
    2323        sort($hosts); 
    2424        foreach ($hosts as $id => $val) { 
    25                 $template->set_var("HOST", "$val");      
     25                $template->set_var("HOST", "$val[0]");   
     26                if ($val[1]) { 
     27                        $template->set_var("DATE", " &nbsp; ".$text[received]." ".dateReverseFromSQL($val[1])." $val[2]"); 
     28                } 
    2629                $template->parse('rows', 'row', true); 
    2730        } 
     
    3538        sort($hosts); 
    3639        foreach ($hosts as $id => $val) { 
    37                 $template->set_var("HOST", "$val");      
     40                $template->set_var("HOST", "$val[0]"); 
     41                if ($val[1]) { 
     42                        $template->set_var("DATE", " &nbsp; ".$text[received]." ".dateReverseFromSQL($val[1])." $val[2]"); 
     43                } 
    3844                $template->parse('rowsboot', 'rowboot', true); 
    3945        } 
  • trunk/webmin/lrs-inventory/tmpl/en/Monitor.tpl

    r135 r145  
    1919                                <th>Type {SORT_TYPE}</th> 
    2020                                <th>Category {SORT_STAMP}</th> 
     21                                <th>Serial {SORT_SERIAL}</th> 
    2122                                <th>Appearance {SORT_FIRSTAPPARITION}</th> 
    2223                        </tr> 
     
    3031                                <td class="{TYPE_CLASS}">{TYPE}</td> 
    3132                                <td class="{STAMP_CLASS}">{STAMP}</td> 
     33                                <td class="{SERIAL_CLASS}">{SERIAL}</td> 
    3234                                <td class="{FIRSTAPPARITION_CLASS}">{FIRSTAPPARITION}</td> 
    3335                        </tr> 
  • trunk/webmin/lrs-inventory/tmpl/en/Status.tpl

    r133 r145  
    44<form> 
    55Clients without inventory since:  
    6 <input type="checkbox" name="cb" onSelect="since.value=0" checked /> always or more than 
     6<input type="checkbox" name="cb" onClick="since.value=0" checked /> always or more than 
    77<input type="text" name="since" onKeyDown="cb.checked=0" value="{SINCE}" size=3 /> days. 
    88</from> 
     
    1313        <ul>     
    1414        <!-- BEGIN row -->                       
    15         <li><a href="general.cgi?host={HOST}">{HOST}</a></li> 
     15        <li><a href="general.cgi?host={HOST}">{HOST}</a> {DATE}</li> 
    1616        <!-- END row --> 
    1717        </ul> 
     
    2121        <ul>     
    2222        <!-- BEGIN rowboot --> 
    23         <li><a href="general.cgi?host={HOST}">{HOST}</a></li> 
     23        <li><a href="general.cgi?host={HOST}">{HOST}</a> {DATE}</li> 
    2424        <!-- END rowboot --> 
    2525        </ul> 
  • trunk/webmin/lrs-inventory/tmpl/en/System.tpl

    r133 r145  
    99                </div> 
    1010 
    11                 <h3>General informations</h3> 
     11                <h3>General information</h3> 
    1212 
    1313                <table> 
  • trunk/webmin/lrs-inventory/tmpl/fr/Modem.tpl

    r135 r145  
    1919                                <th>Description {SORT_EXPANDEDDESCRIPTION}</th> 
    2020                                <th>Type {SORT_TYPE}</th> 
    21                                 <th>Appearance {SORT_FIRSTAPPARITION}</th> 
     21                                <th>Apparition {SORT_FIRSTAPPARITION}</th> 
    2222                        </tr> 
    2323                         
  • trunk/webmin/lrs-inventory/tmpl/fr/Monitor.tpl

    r135 r145  
    1919                                <th>Type {SORT_TYPE}</th> 
    2020                                <th>Categorie {SORT_STAMP}</th> 
     21                                <th>No série {SORT_SERIAL}</th> 
    2122                                <th>Apparition {SORT_FIRSTAPPARITION}</th> 
    2223                        </tr> 
     
    3031                                <td class="{TYPE_CLASS}">{TYPE}</td> 
    3132                                <td class="{STAMP_CLASS}">{STAMP}</td> 
     33                                <td class="{SERIAL_CLASS}">{SERIAL}</td> 
    3234                                <td class="{FIRSTAPPARITION_CLASS}">{FIRSTAPPARITION}</td> 
    3335                        </tr> 
  • trunk/webmin/lrs-inventory/tmpl/fr/Status.tpl

    r133 r145  
    44<form> 
    55Clients sans inventaire depuis:  
    6 <input type="checkbox" name="cb" onSelect="since.value=0" checked /> toujours ou plus de 
     6<input type="checkbox" name="cb" onClick="since.value=0" checked /> toujours ou plus de 
    77<input type="text" name="since" onKeyDown="cb.checked=0" value="{SINCE}" size=3 /> jours. 
    88</from> 
     
    1313        <ul>     
    1414        <!-- BEGIN row -->                       
    15         <li><a href="general.cgi?host={HOST}">{HOST}</a></li> 
     15        <li><a href="general.cgi?host={HOST}">{HOST}</a> {DATE}</li> 
    1616        <!-- END row --> 
    1717        </ul> 
     
    2121        <ul>     
    2222        <!-- BEGIN rowboot --> 
    23         <li><a href="general.cgi?host={HOST}">{HOST}</a></li> 
     23        <li><a href="general.cgi?host={HOST}">{HOST}</a> {DATE}</li> 
    2424        <!-- END rowboot --> 
    2525        </ul> 
  • trunk/webmin/lrs-inventory/tmpl/fr/System.tpl

    r133 r145  
    1818                                <th>Modèle {SORT_SYSTEM1}</th> 
    1919                                <th>Version {SORT_SYSTEM2}</th> 
    20                                 <th>Serie {SORT_SYSTEM3}</th> 
     20                                <th>Série {SORT_SYSTEM3}</th> 
    2121                                <th>UUID {SORT_SYSTEM4}</th> 
    2222                                <th>Type {SORT_CHASSIS1}</th>