Passed
Push — master ( bd4945...f42790 )
by Patrick
02:05
created

Mib   F

Complexity

Total Complexity 83

Size/Duplication

Total Lines 503
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 268
dl 0
loc 503
rs 2
c 1
b 0
f 0
wmc 83

4 Methods

Rating   Name   Duplication   Size   Complexity  
F update_oid() 0 110 25
F trap_objects() 0 133 23
F update_mib_database() 0 207 34
A __construct() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Mib often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Mib, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Trapdirector;
4
5
use Trapdirector\Logging;
6
use Trapdirector\Database;
7
use PDO;
8
use Exception;
9
10
class Mib
11
{
12
    
13
    protected $logging; //< logging class
14
    protected $trapsDB; //< Database class
15
    
16
    
17
    /**
18
     * Setup Mib Class
19
     * @param Logging $logClass : where to log
20
     * @param Database $dbClass : Database
21
     */
22
    function __construct($logClass,$dbClass)
23
    {
24
        $this->logging=$logClass;
25
        $this->trapsDB=$dbClass;       
26
    }
27
    
28
    
29
    /**
30
     * Update or add an OID to database uses $this->dbOidIndex for mem cache
31
     * @param string $oid
32
     * @param string $mib
33
     * @param string $name
34
     * @param string $type
35
     * @param string $textConv
36
     * @param string $dispHint
37
     * @param string $syntax
38
     * @param string $type_enum
39
     * @param string $description
40
     * @return number : 0=unchanged, 1 = changed, 2=created
41
     */
42
    public function update_oid($oid,$mib,$name,$type,$textConv,$dispHint,$syntax,$type_enum,$description=NULL)
43
    {
44
        $db_conn=$this->trapsDB->db_connect_trap();
45
        $description=$db_conn->quote($description);
46
        if (isset($this->dbOidIndex[$oid]))
47
        {
48
            if ($this->dbOidIndex[$oid]['key'] == -1)
49
            { // newly created.
50
                return 0;
51
            }
52
            if ( $name != $this->dbOidAll[$this->dbOidIndex[$oid]['key']]['name'] ||
53
                $mib != $this->dbOidAll[$this->dbOidIndex[$oid]['key']]['mib'] ||
54
                $type != $this->dbOidAll[$this->dbOidIndex[$oid]['key']]['type'] //||
55
                //$textConv != $this->dbOidAll[$this->dbOidIndex[$oid]['key']]['textual_convention'] //||
56
                //$dispHint != $this->dbOidAll[$this->dbOidIndex[$oid]['key']]['display_hint'] ||
57
                //$syntax != $this->dbOidAll[$this->dbOidIndex[$oid]['key']]['syntax'] ||
58
                //$type_enum != $this->dbOidAll[$this->dbOidIndex[$oid]['key']]['type_enum'] ||
59
                //$description != $this->dbOidAll[$this->dbOidIndex[$oid]['key']]['description']
60
                )
61
            { // Do update
62
                $sql='UPDATE '.$this->trapsDB->dbPrefix.'mib_cache SET '.
63
                    'name = :name , type = :type , mib = :mib , textual_convention = :tc , display_hint = :display_hint'.
64
                    ', syntax = :syntax, type_enum = :type_enum, description = :description '.
65
                    ' WHERE id= :id';
66
                $sqlQuery=$db_conn->prepare($sql);
67
                
68
                $sqlParam=array(
69
                    ':name' => $name,
70
                    ':type' => $type,
71
                    ':mib' => $mib,
72
                    ':tc' =>  ($textConv==null)?'null':$textConv ,
73
                    ':display_hint' => ($dispHint==null)?'null':$dispHint ,
74
                    ':syntax' => ($syntax==null)?'null':$syntax,
75
                    ':type_enum' => ($type_enum==null)?'null':$type_enum,
76
                    ':description' => ($description==null)?'null':$description,
77
                    ':id' => $this->dbOidAll[$this->dbOidIndex[$oid]['id']]
78
                );
79
                
80
                if ($sqlQuery->execute($sqlParam) === false) {
81
                    $this->logging->log('Error in query : ' . $sql,ERROR,'');
82
                }
83
                $this->logging->log('Trap updated : '.$name . ' / OID : '.$oid,DEBUG );
84
                return 1;
85
            }
86
            else
87
            {
88
                $this->logging->log('Trap unchanged : '.$name . ' / OID : '.$oid,DEBUG );
89
                return 0;
90
            }
91
        }
92
        // create new OID.
93
        
94
        // Insert data
95
        
96
        $sql='INSERT INTO '.$this->trapsDB->dbPrefix.'mib_cache '.
97
            '(oid, name, type , mib, textual_convention, display_hint '.
98
            ', syntax, type_enum , description ) ' .
99
            'values (:oid, :name , :type ,:mib ,:tc , :display_hint'.
100
            ', :syntax, :type_enum, :description )';
101
        
102
        if ($this->trapsDB->trapDBType == 'pgsql') $sql .= 'RETURNING id';
103
        
104
        $sqlQuery=$db_conn->prepare($sql);
105
        
106
        $sqlParam=array(
107
            ':oid' => $oid,
108
            ':name' => $name,
109
            ':type' => $type,
110
            ':mib' => $mib,
111
            ':tc' =>  ($textConv==null)?'null':$textConv ,
112
            ':display_hint' => ($dispHint==null)?'null':$dispHint ,
113
            ':syntax' => ($syntax==null)?'null':$syntax,
114
            ':type_enum' => ($type_enum==null)?'null':$type_enum,
115
            ':description' => ($description==null)?'null':$description
116
        );
117
        
118
        if ($sqlQuery->execute($sqlParam) === false) {
119
            $this->logging->log('Error in query : ' . $sql,1,'');
120
        }
121
        
122
        switch ($this->trapsDB->trapDBType)
123
        {
124
            case 'pgsql':
125
                // Get last id to insert oid/values in secondary table
126
                if (($inserted_id_ret=$sqlQuery->fetch(PDO::FETCH_ASSOC)) === false) {
127
                    $this->logging->log('Error getting id - pgsql - ',1,'');
128
                }
129
                if (! isset($inserted_id_ret['id'])) {
130
                    $this->logging->log('Error getting id - pgsql - empty.',1,'');
131
                }
132
                $this->dbOidIndex[$oid]['id']=$inserted_id_ret['id'];
0 ignored issues
show
Bug Best Practice introduced by
The property dbOidIndex does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
133
                break;
134
            case 'mysql':
135
                // Get last id to insert oid/values in secondary table
136
                $sql='SELECT LAST_INSERT_ID();';
137
                if (($ret_code=$db_conn->query($sql)) === false) {
138
                    $this->logging->log('Erreur getting id - mysql - ',1,'');
139
                }
140
                
141
                $inserted_id=$ret_code->fetch(PDO::FETCH_ASSOC)['LAST_INSERT_ID()'];
142
                if ($inserted_id==false) throw new Exception("Weird SQL error : last_insert_id returned false : open issue");
143
                $this->dbOidIndex[$oid]['id']=$inserted_id;
144
                break;
145
            default:
146
                $this->logging->log('Error SQL type Unknown : '.$this->trapsDB->trapDBType,1,'');
147
        }
148
        
149
        // Set as newly created.
150
        $this->dbOidIndex[$oid]['key']=-1;
151
        return 2;
152
    }
153
    
154
    /**
155
     * create or update (with check_existing = true) objects of trap
156
     * @param string $trapOID : trap oid
157
     * @param string $trapmib : mib of trap
158
     * @param array $objects : array of objects name (without MIB)
159
     * @param bool $check_existing : check instead of create
160
     */
161
    public function trap_objects($trapOID,$trapmib,$objects,$check_existing)
162
    {
163
        $dbObjects=null; // cache of objects for trap in db
164
        $db_conn=$this->trapsDB->db_connect_trap();
165
        
166
        // Get id of trapmib.
167
        
168
        $trapId = $this->dbOidIndex[$trapOID]['id'];
169
        if ($check_existing === true)
170
        {
171
            // Get all objects
172
            $sql='SELECT * FROM '.$this->trapsDB->dbPrefix.'mib_cache_trap_object where trap_id='.$trapId.';';
173
            $this->logging->log('SQL query get all traps: '.$sql,DEBUG );
174
            if (($ret_code=$db_conn->query($sql)) === false) {
175
                $this->logging->log('No result in query : ' . $sql,1,'');
176
            }
177
            $dbObjectsRaw=$ret_code->fetchAll();
178
            
179
            foreach ($dbObjectsRaw as $val)
180
            {
181
                $dbObjects[$val['object_id']]=1;
182
            }
183
        }
184
        foreach ($objects as $object)
185
        {
186
            $match=$snmptrans=array();
187
            $retVal=0;
188
            $objOid=$objTc=$objDispHint=$objSyntax=$objDesc=$objEnum=NULL;
189
            $tmpdesc='';$indesc=false;
190
            
191
            $objMib=$trapmib;
192
            exec($this->snmptranslate . ' -m ALL -M +'.$this->snmptranslate_dirs.
0 ignored issues
show
Bug Best Practice introduced by
The property snmptranslate_dirs does not exist on Trapdirector\Mib. Did you maybe forget to declare it?
Loading history...
Bug Best Practice introduced by
The property snmptranslate does not exist on Trapdirector\Mib. Did you maybe forget to declare it?
Loading history...
193
                ' -On -Td '.$objMib.'::'.$object . ' 2>/dev/null',$snmptrans,$retVal);
194
            if ($retVal!=0)
195
            {
196
                // Maybe not trap mib, search with IR
197
                exec($this->snmptranslate . ' -m ALL -M +'.$this->snmptranslate_dirs.
198
                    ' -IR '.$object . ' 2>/dev/null',$snmptrans,$retVal);
199
                if ($retVal != 0 || !preg_match('/(.*)::(.*)/',$snmptrans[0],$match))
200
                { // Not found -> continue with warning
201
                    $this->logging->log('Error finding trap object : '.$trapmib.'::'.$object,2,'');
202
                    continue;
203
                }
204
                $objMib=$match[1];
205
                
206
                // Do the snmptranslate again.
207
                exec($this->snmptranslate . ' -m ALL -M +'.$this->snmptranslate_dirs.
208
                    ' -On -Td '.$objMib.'::'.$object,$snmptrans,$retVal);
209
                if ($retVal!=0) {
210
                    $this->logging->log('Error finding trap object : '.$objMib.'::'.$object,2,'');
211
                }
212
                
213
            }
214
            foreach ($snmptrans as $line)
215
            {
216
                if ($indesc===true)
217
                {
218
                    $line=preg_replace('/[\t ]+/',' ',$line);
219
                    if (preg_match('/(.*)"$/', $line,$match))
220
                    {
221
                        $objDesc = $tmpdesc . $match[1];
222
                        $indesc=false;
223
                    }
224
                    $tmpdesc.=$line;
225
                    continue;
226
                }
227
                if (preg_match('/^\.[0-9\.]+$/', $line))
228
                {
229
                    $objOid=$line;
230
                    continue;
231
                }
232
                if (preg_match('/^[\t ]+SYNTAX[\t ]+([^{]*) \{(.*)\}/',$line,$match))
233
                {
234
                    $objSyntax=$match[1];
235
                    $objEnum=$match[2];
236
                    continue;
237
                }
238
                if (preg_match('/^[\t ]+SYNTAX[\t ]+(.*)/',$line,$match))
239
                {
240
                    $objSyntax=$match[1];
241
                    continue;
242
                }
243
                if (preg_match('/^[\t ]+DISPLAY-HINT[\t ]+"(.*)"/',$line,$match))
244
                {
245
                    $objDispHint=$match[1];
246
                    continue;
247
                }
248
                if (preg_match('/^[\t ]+DESCRIPTION[\t ]+"(.*)"/',$line,$match))
249
                {
250
                    $objDesc=$match[1];
251
                    continue;
252
                }
253
                if (preg_match('/^[\t ]+DESCRIPTION[\t ]+"(.*)/',$line,$match))
254
                {
255
                    $tmpdesc=$match[1];
256
                    $indesc=true;
257
                    continue;
258
                }
259
                if (preg_match('/^[\t ]+-- TEXTUAL CONVENTION[\t ]+(.*)/',$line,$match))
260
                {
261
                    $objTc=$match[1];
262
                    continue;
263
                }
264
            }
265
            $this->logging->log("Adding trap $object : $objOid / $objSyntax / $objEnum / $objDispHint / $objTc",DEBUG );
266
            //echo "$object : $objOid / $objSyntax / $objEnum / $objDispHint / $objTc / $objDesc\n";
267
            // Update
268
            $this->update_oid($objOid, $objMib, $object, '3', $objTc, $objDispHint, $objSyntax, $objEnum,$objDesc);
269
            
270
            if (isset($dbObjects[$this->dbOidIndex[$objOid]['id']]))
271
            {   // if link exists, continue
272
                $dbObjects[$this->dbOidIndex[$objOid]['id']]=2;
273
                continue;
274
            }
275
            if ($check_existing === true)
276
            {
277
                // TODO : check link trap - objects exists, mark them.
278
            }
279
            // Associate in object table
280
            $sql='INSERT INTO '.$this->trapsDB->dbPrefix.'mib_cache_trap_object (trap_id,object_id) '.
281
                'values (:trap_id, :object_id)';
282
            $sqlQuery=$db_conn->prepare($sql);
283
            $sqlParam=array(
284
                ':trap_id' => $trapId,
285
                ':object_id' => $this->dbOidIndex[$objOid]['id'],
286
            );
287
            
288
            if ($sqlQuery->execute($sqlParam) === false) {
289
                $this->logging->log('Error adding trap object : ' . $sql . ' / ' . $trapId . '/'. $this->dbOidIndex[$objOid]['id'] ,1,'');
290
            }
291
        }
292
        if ($check_existing === true)
293
        {
294
            // TODO : remove link trap - objects that wasn't marked.
295
        }
296
        
297
    }
298
    
299
    /**
300
     * Cache mib in database
301
     * @param boolean $display_progress : Display progress on standard output
302
     * @param boolean $check_change : Force check of trap params & objects
303
     * @param boolean $onlyTraps : only cache traps and objects (true) or all (false)
304
     * @param string $startOID : only cache under startOID (NOT IMPLEMENTED)
305
     */
306
    public function update_mib_database($display_progress=false,$check_change=false,$onlyTraps=true,$startOID='.1')
0 ignored issues
show
Unused Code introduced by
The parameter $startOID is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

306
    public function update_mib_database($display_progress=false,$check_change=false,$onlyTraps=true,/** @scrutinizer ignore-unused */ $startOID='.1')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
307
    {
308
        // Timing
309
        $timeTaken = microtime(true);
310
        $retVal=0;
311
        // Get all mib objects from all mibs
312
        $snmpCommand=$this->snmptranslate . ' -m ALL -M +'.$this->snmptranslate_dirs.' -On -Tto 2>/dev/null';
0 ignored issues
show
Bug Best Practice introduced by
The property snmptranslate_dirs does not exist on Trapdirector\Mib. Did you maybe forget to declare it?
Loading history...
Bug Best Practice introduced by
The property snmptranslate does not exist on Trapdirector\Mib. Did you maybe forget to declare it?
Loading history...
313
        $this->logging->log('Getting all traps : '.$snmpCommand,DEBUG );
314
        unset($this->objectsAll);
0 ignored issues
show
Bug Best Practice introduced by
The property objectsAll does not exist on Trapdirector\Mib. Did you maybe forget to declare it?
Loading history...
315
        exec($snmpCommand,$this->objectsAll,$retVal);
316
        if ($retVal!=0)
317
        {
318
            $this->logging->log('error executing snmptranslate',ERROR,'');
319
        }
320
        
321
        // Get all mibs from databse to have a memory index
322
        
323
        $db_conn=$this->trapsDB->db_connect_trap();
324
        
325
        $sql='SELECT * from '.$this->trapsDB->dbPrefix.'mib_cache;';
326
        $this->logging->log('SQL query : '.$sql,DEBUG );
327
        if (($ret_code=$db_conn->query($sql)) === false) {
328
            $this->logging->log('No result in query : ' . $sql,ERROR,'');
329
        }
330
        $this->dbOidAll=$ret_code->fetchAll();
0 ignored issues
show
Bug Best Practice introduced by
The property dbOidAll does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
331
        $this->dbOidIndex=array();
0 ignored issues
show
Bug Best Practice introduced by
The property dbOidIndex does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
332
        // Create the index for db;
333
        foreach($this->dbOidAll as $key=>$val)
334
        {
335
            $this->dbOidIndex[$val['oid']]['key']=$key;
336
            $this->dbOidIndex[$val['oid']]['id']=$val['id'];
337
        }
338
        
339
        // Count elements to show progress
340
        $numElements=count($this->objectsAll);
341
        $this->logging->log('Total snmp objects returned by snmptranslate : '.$numElements,INFO );
342
        
343
        $step=$basestep=$numElements/10; // output display of % done
344
        $num_step=0;
345
        $timeFiveSec = microtime(true); // Used for display a '.' every <n> seconds
346
        
347
        // Create index for trap objects
348
        $this->trapObjectsIndex=array();
0 ignored issues
show
Bug Best Practice introduced by
The property trapObjectsIndex does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
349
        
350
        // detailed timing (time_* vars)
351
        $time_parse1=$time_check1=$time_check2=$time_check3=$time_update=$time_objects=0;
352
        $time_parse1N=$time_check1N=$time_check2N=$time_check3N=$time_updateN=$time_objectsN=0;
353
        $time_num_traps=0;
354
        
355
        for ($curElement=0;$curElement < $numElements;$curElement++)
356
        {
357
            $time_1= microtime(true);
358
            if ((microtime(true)-$timeFiveSec) > 2 && $display_progress)
359
            { // echo a . every 2 sec
360
                echo '.';
361
                $timeFiveSec = microtime(true);
362
            }
363
            if ($curElement>$step)
364
            { // display progress
365
                $num_step++;
366
                $step+=$basestep;
367
                if ($display_progress)
368
                {
369
                    echo "\n" . ($num_step*10). '% : ';
370
                }
371
            }
372
            // Get oid or pass if not found
373
            if (!preg_match('/^\.[0-9\.]+$/',$this->objectsAll[$curElement]))
374
            {
375
                $time_parse1 += microtime(true) - $time_1;
376
                $time_parse1N ++;
377
                continue;
378
            }
379
            $oid=$this->objectsAll[$curElement];
380
            
381
            // get next line
382
            $curElement++;
383
            $match=$snmptrans=array();
384
            if (!preg_match('/ +([^\(]+)\(.+\) type=([0-9]+)( tc=([0-9]+))?( hint=(.+))?/',
385
                $this->objectsAll[$curElement],$match))
386
            {
387
                $time_check1 += microtime(true) - $time_1;
388
                $time_check1N++;
389
                continue;
390
            }
391
            
392
            $name=$match[1]; // Name
393
            $type=$match[2]; // type (21=trap, 0: may be trap, else : not trap
394
            
395
            if ($type==0) // object type=0 : check if v1 trap
396
            {
397
                // Check if next is suboid -> in that case is cannot be a trap
398
                if (preg_match("/^$oid/",$this->objectsAll[$curElement+1]))
399
                {
400
                    $time_check2 += microtime(true) - $time_1;
401
                    $time_check2N++;
402
                    continue;
403
                }
404
                unset($snmptrans);
405
                exec($this->snmptranslate . ' -m ALL -M +'.$this->snmptranslate_dirs.
406
                    ' -Td '.$oid . ' | grep OBJECTS ',$snmptrans,$retVal);
407
                if ($retVal!=0)
408
                {
409
                    $time_check2 += microtime(true) - $time_1;
410
                    $time_check2N++;
411
                    continue;
412
                }
413
                //echo "\n v1 trap found : $oid \n";
414
                // Force as trap.
415
                $type=21;
416
            }
417
            if ($onlyTraps===true && $type!=21) // if only traps and not a trap, continue
418
            {
419
                $time_check3 += microtime(true) - $time_1;
420
                $time_check3N++;
421
                continue;
422
            }
423
            
424
            $time_num_traps++;
425
            
426
            $this->logging->log('Found trap : '.$match[1] . ' / OID : '.$oid,INFO );
427
            if ($display_progress) echo '#'; // echo a # when trap found
428
            
429
            // get trap objects & source MIB
430
            unset($snmptrans);
431
            exec($this->snmptranslate . ' -m ALL -M +'.$this->snmptranslate_dirs.
432
                ' -Td '.$oid,$snmptrans,$retVal);
433
            if ($retVal!=0)
434
            {
435
                $this->logging->log('error executing snmptranslate',ERROR,'');
436
            }
437
            
438
            if (!preg_match('/^(.*)::/',$snmptrans[0],$match))
439
            {
440
                $this->logging->log('Error getting mib from trap '.$oid.' : ' . $snmptrans[0],1,'');
441
            }
442
            $trapMib=$match[1];
443
            
444
            $numLine=1;$trapDesc='';
445
            while (isset($snmptrans[$numLine]) && !preg_match('/^[\t ]+DESCRIPTION[\t ]+"(.*)/',$snmptrans[$numLine],$match)) $numLine++;
446
            if (isset($snmptrans[$numLine]))
447
            {
448
                $snmptrans[$numLine] = preg_replace('/^[\t ]+DESCRIPTION[\t ]+"/','',$snmptrans[$numLine]);
449
                
450
                while (isset($snmptrans[$numLine]) && !preg_match('/"/',$snmptrans[$numLine]))
451
                {
452
                    $trapDesc.=preg_replace('/[\t ]+/',' ',$snmptrans[$numLine]);
453
                    $numLine++;
454
                }
455
                if (isset($snmptrans[$numLine])) {
456
                    $trapDesc.=preg_replace('/".*/','',$snmptrans[$numLine]);
457
                    $trapDesc=preg_replace('/[\t ]+/',' ',$trapDesc);
458
                }
459
                
460
            }
461
            $update=$this->update_oid($oid,$trapMib,$name,$type,NULL,NULL,NULL,NULL,$trapDesc);
462
            $time_update += microtime(true) - $time_1; $time_1= microtime(true);
463
            
464
            if (($update==0) && ($check_change===false))
465
            { // Trapd didn't change & force check disabled
466
                $time_objects += microtime(true) - $time_1;
467
                if ($display_progress) echo "C";
468
                continue;
469
            }
470
            
471
            $synt=null;
472
            foreach ($snmptrans as $line)
473
            {
474
                if (preg_match('/OBJECTS.*\{([^\}]+)\}/',$line,$match))
475
                {
476
                    $synt=$match[1];
477
                }
478
            }
479
            if ($synt == null)
480
            {
481
                //echo "No objects for $trapOID\n";
482
                $time_objects += microtime(true) - $time_1;
483
                continue;
484
            }
485
            //echo "$synt \n";
486
            $trapObjects=array();
487
            while (preg_match('/ *([^ ,]+) *,* */',$synt,$match))
488
            {
489
                array_push($trapObjects,$match[1]);
490
                $synt=preg_replace('/'.$match[0].'/','',$synt);
491
            }
492
            
493
            $this->trap_objects($oid, $trapMib, $trapObjects, false);
494
            
495
            $time_objects += microtime(true) - $time_1;
496
            $time_objectsN++;
497
        }
498
        
499
        if ($display_progress)
500
        {
501
            echo "\nNumber of processed traps : $time_num_traps \n";
502
            echo "\nParsing : " . number_format($time_parse1+$time_check1,1) ." sec / " . ($time_parse1N+ $time_check1N)  . " occurences\n";
503
            echo "Detecting traps : " . number_format($time_check2+$time_check3,1) . " sec / " . ($time_check2N+$time_check3N) ." occurences\n";
504
            echo "Trap processing ($time_updateN): ".number_format($time_update,1)." sec , ";
505
            echo "Objects processing ($time_objectsN) : ".number_format($time_objects,1)." sec \n";
506
        }
507
        
508
        // Timing ends
509
        $timeTaken=microtime(true) - $timeTaken;
510
        if ($display_progress)
511
        {
512
            echo "Global time : ".round($timeTaken)." seconds\n";
513
        }
514
        
515
    }
516
    
517
    
518
}