Parsable system info available in 7.6.5

Use this forum to place comments about UVK.
Forum rules
We have no special rules for UVK forums. Just try to be polite and clear in your posts.
Please don't post spam in this forum. Spammers will be banned by IP, e-mail and username.
We reserve the right to delete all posts and ban all users we consider not having respected these rules without warning.
Post Reply
Fred
Site Admin
Posts: 2322
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Parsable system info available in 7.6.5

Post by Fred »

I'm pleased to announce that version 7.6.5, currently in beta state now generates a SystemInfo INI file each time the system information is exported to an HTML file from the System info section. This INI file is automatically added to the Reporting zip file. This feature has been requested in the following topic:

viewtopic.php?f=9&t=1230

I have chosen the INI file format because it is natively supported by windows, PHP and most programing languages, and it is easily parsable. It is mainly intended to be used by PCRT, CRS and other applications of the same kind. So if you are a licensed user of one of those apps, please contact their support team asking them to integrate the file.

Thanks.
The only thing we humans have in common is that we are all different. So, if you think you're weird because you're different from everyone else, then we are all weird.

Fred
reggaemanu
Posts: 172
Joined: Wed Jun 10, 2015 9:07 pm
Location: France

Re: Parsable system info available in 7.6.5

Post by reggaemanu »

Just for information:
Luke from pcrt just released the v3 that finally include import specs infos from uvk (using the ini file)
Fred
Site Admin
Posts: 2322
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Re: Parsable system info available in 7.6.5

Post by Fred »

Thanks for the information, Manu.
The only thing we humans have in common is that we are all different. So, if you think you're weird because you're different from everyone else, then we are all weird.

Fred
Charger440
Posts: 1528
Joined: Sun May 25, 2014 7:44 am
Location: Missouri

Re: Parsable system info available in 7.6.5

Post by Charger440 »

Reggae

Did someone post a working version of Lukes UVK system.ini parser? Kinda seemed like they did but I cant find it. All the did was copy the d7 ini parsing stuff and most of it does not work with UVK. So either I need to find a corrected script or I gotta fix it myself..... really don't wanna if someone else already has.
Jim

It is not "Can it be done?" but rather, "How can we do it?"
reggaemanu
Posts: 172
Joined: Wed Jun 10, 2015 9:07 pm
Location: France

Re: Parsable system info available in 7.6.5

Post by reggaemanu »

Hi Jim,

No, was just talking about the official integration in the v3, but after testing it doesn't really work.
I'll be back to work tomorrow (end of holidays :cry:) and I need a working import so I guess I'll have to use my old mod for now while trying to make the new version work correctly

[EDIT] Just took some times to update it but I've no result with parse_ini_string() function for now, it keep returning an empty array.

@fred> that's on the parse_ini_string function manual :
Les caractères ?{}|&~![()^" ne doivent être utilisés nulle part dans les clés, et ont une signification spéciale dans les valeurs.
I thought that was the problem but even if I strip all that chars from the keys that still doesn't work.

Anyway, this file format is not easy to parse as for applications like pcrt we need keywords.
For example for hard disks, there's no "partition=", the key itself is the name of the partition so it changes all the time.
Would be more effective to have something like a plain :

Code: Select all

os=
pcname=
username=
bios=
hardisk0=
partition0=
oskey=
vga=
audio=
ramqty=
serial=
...
We don't need sections or full detailed infos (there's already system info.htm for that), we just need basic/easy import via keywords
reggaemanu
Posts: 172
Joined: Wed Jun 10, 2015 9:07 pm
Location: France

Re: Parsable system info available in 7.6.5

Post by reggaemanu »

With new html report code style in c++ version my mod for pcrt won't work anymore (too complicated to adapt to the new style) so it become more important to me (and anybody using pcrt i guess) to be able to use the ini version. Did you saw my post above Fred ? (I didn't want to bother you because you were pretty busy with c++ version but now that is urgent :p)
I guess I'll have to downgrade to last autoit version for now as I can't stay too long without report import.
Fred
Site Admin
Posts: 2322
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Re: Parsable system info available in 7.6.5

Post by Fred »

Hi Manu.

I'll try to make something that works for PCRT, for the next update.
The only thing we humans have in common is that we are all different. So, if you think you're weird because you're different from everyone else, then we are all weird.

Fred
reggaemanu
Posts: 172
Joined: Wed Jun 10, 2015 9:07 pm
Location: France

Re: Parsable system info available in 7.6.5

Post by reggaemanu »

I finally found a regex that match so I'm saved ! :D
Anyway, that would be nice to have a more natural way to parse it like said above but don't hurry Fred, that will work for now :)
You probably have better to do...

For those interested you have to change the regex line from my last mod by this one (I'll update the mod on pcrt forum):

Code: Select all

$pattern = "/$val<\/td>(<\/tr><tr>|)<td[^>]*(>&nbsp;<a[^>]*|)>([^<]*)/ui";
Fred
Site Admin
Posts: 2322
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Re: Parsable system info available in 7.6.5

Post by Fred »

Thanks, Manu. I also felt I had to do something about this, since many of you asked for it.

So I made this page, which takes a SystemInfo.ini file, and outputs a table similar to the System info HTML file. Feel free to test it out.

As Manu said, the parse_ini_string() function didn't work, actually because of PHP's lack of UNICODE support (SystemInfo.ini is UNICODE encoded to support any language).

So I used parse_ini_string_m(), which I copied from this PHP help page. That function parses the INI file just fine, but you still have to strip the first two bytes from the INI string, which are the UNICODE BOM (BYTE order mark).

So, here's an example. Feel free to post it in PCRT's forum.

Code: Select all

<?php
//First, we declare our function
function parse_ini_string_m($str) {
    
    if(empty($str)) return false;

    $lines = explode("\n", $str);
    $ret = Array();
    $inside_section = false;

    foreach($lines as $line) {
        
        $line = trim($line);

        if(!$line || $line[0] == "#" || $line[0] == ";") continue;
        
        if($line[0] == "[" && $endIdx = strpos($line, "]")){
            $inside_section = substr($line, 1, $endIdx-1);
            continue;
        }

        if(!strpos($line, '=')) continue;

        $tmp = explode("=", $line, 2);

        if($inside_section) {
            
            $key = rtrim($tmp[0]);
            $value = ltrim($tmp[1]);

            if(preg_match("/^\".*\"$/", $value) || preg_match("/^'.*'$/", $value)) {
                $value = mb_substr($value, 1, mb_strlen($value) - 2);
            }

            $t = preg_match("^\[(.*?)\]^", $key, $matches);
            if(!empty($matches) && isset($matches[0])) {

                $arr_name = preg_replace('#\[(.*?)\]#is', '', $key);

                if(!isset($ret[$inside_section][$arr_name]) || !is_array($ret[$inside_section][$arr_name])) {
                    $ret[$inside_section][$arr_name] = array();
                }

                if(isset($matches[1]) && !empty($matches[1])) {
                    $ret[$inside_section][$arr_name][$matches[1]] = $value;
                } else {
                    $ret[$inside_section][$arr_name][] = $value;
                }

            } else {
                $ret[$inside_section][trim($tmp[0])] = $value;
            }            

        } else {
            
            $ret[trim($tmp[0])] = ltrim($tmp[1]);

        }
    }
    return $ret;
}


//...
//Get the text of SystemInfo.ini directly from the report zip file
$initext = zip_entry_read($zipentry, zip_entry_filesize($zipentry));
//...
$initext = substr($initext, 2);
$inidata = parse_ini_string_m($initext, true);
if (FALSE === $inidata) :
	echo '<p><b>Could not parse the INI string</b></p>';
else :
	// The ini file was successfully parsed, output it
	foreach ($inidata as $sectionname => $sectionarray )
	{
		// Output or do whatever you need with $sectionname
		foreach ($sectionarray as $key => $val)
		{		
			// Output or do whatever you need with $key ad $val
		}
	}
endif;

?>
The only thing we humans have in common is that we are all different. So, if you think you're weird because you're different from everyone else, then we are all weird.

Fred
reggaemanu
Posts: 172
Joined: Wed Jun 10, 2015 9:07 pm
Location: France

Re: Parsable system info available in 7.6.5

Post by reggaemanu »

Thanks Fred, I'll try to do some testing with that this weekend to come up with a mod that works fine with ini and submit it to luke
Post Reply