System Info.txt for PCRT import of specs

Do you know of a feature that UVK should have? Post it here!
Xander
Posts: 438
Joined: Sun May 24, 2015 11:55 pm
Contact:

System Info.txt for PCRT import of specs

Post by Xander »

Copying this from another post as it's really more of a request:
I also asked Luke about showing the System Info report on the asset page (and not just the work order) which he'll look at.

Additionally asked about parsing the report for system specs to import like he does with "that other" software.
"It cannot, the ****(other software) report is a flat plain text file with one spec per line and a colon separating the label with the value.
The report that comes out of UVK is html, which is almost impossible to parse."

Fred, while UVK creates the HTML report, could it also create a plain text version that's parsable? If you need to see how the "other" format he's already parsing, I can send you an example.
Charger440
Posts: 1529
Joined: Sun May 25, 2014 7:44 am
Location: Missouri

Re: System Info.txt for PCRT import of specs

Post by Charger440 »

I would like that added myself :)
Jim

It is not "Can it be done?" but rather, "How can we do it?"
Charger440
Posts: 1529
Joined: Sun May 25, 2014 7:44 am
Location: Missouri

Re: System Info.txt for PCRT import of specs

Post by Charger440 »

Fred

Here is the format that PCRT is already setup for:

Array
(
[model] => Mfgr / Model:
[motherboard] => MB:
[bios] => BIOS:
[partitiontype] => Partition Type:
[cpu] => CPU String:
[ram] => RAM:
[operatingsystem] => OS:
[windowsproductkey] => Product Key:
[serial] => Serial#:
[videocard] => Video Card:
[partition] => Partition Space:
[antivirus] => Anti-Virus:
[antispyware] => Anti-Spyware:
[internetexplorer] => Internet Explorer:
[firewall] => Firewall:
[computername] => Computer Name:
[ipaddress] => IP Address:
[username] => User Name:
[domain] => Domain:
[gateway] => Gateway:
[dns] => DNS:
[networkinterfacecard] => NIC:
[macaddress] => MAC:
[installedon] => Installed on:
)
Jim

It is not "Can it be done?" but rather, "How can we do it?"
Fred
Site Admin
Posts: 2357
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Re: System Info.txt for PCRT import of specs

Post by Fred »

Luke hasn't received my PM yet. If someone can contact ask him to reply here and in the other topic, it's appreciated. Does the array need to be formatted with this info, or can I choose what to display? It would also be useful if one of you could send me a real file from the other app.
One 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: 1529
Joined: Sun May 25, 2014 7:44 am
Location: Missouri

Re: System Info.txt for PCRT import of specs

Post by Charger440 »

Xander would have to do that as I don't even have a copy of that pos any more even though I paid a life time license. From what I understand, you just do this, and you don't have to include them all either.

CPU String: Intel Core i7 4580
RAM: 16GB DDR3 10600
OS: Windows 10

They went with colon separated instead of the usual comma delimited.
Jim

It is not "Can it be done?" but rather, "How can we do it?"
Charger440
Posts: 1529
Joined: Sun May 25, 2014 7:44 am
Location: Missouri

Re: System Info.txt for PCRT import of specs

Post by Charger440 »

Does this mean adding the system txt for PCRT is a confirmed feature at this point?
Jim

It is not "Can it be done?" but rather, "How can we do it?"
Fred
Site Admin
Posts: 2357
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Re: System Info.txt for PCRT import of specs

Post by Fred »

Yes, I'll do it as soon as I figure out how it needs to be done.
One 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: 1529
Joined: Sun May 25, 2014 7:44 am
Location: Missouri

Re: System Info.txt for PCRT import of specs

Post by Charger440 »

OK I just wanted to know sure whether to add it to the confirmed features and I don't like to add things without you saying you will do it. Basically I don't want to feel like I'm trying to force you. No rush on that, whenever you figure it out. Luke will prolly have to update as well so it might be a while before it all actually works.
Jim

It is not "Can it be done?" but rather, "How can we do it?"
Fred
Site Admin
Posts: 2357
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Re: System Info.txt for PCRT import of specs

Post by Fred »

No problem, Jim. It's nice of you to want to help. Thanks.
One 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
Xander
Posts: 438
Joined: Sun May 24, 2015 11:55 pm
Contact:

Re: System Info.txt for PCRT import of specs

Post by Xander »

I've emailed him about this thread and your PM, Fred.

This is from his last email:
On 9/3/2015 3:28 PM, Luke Stroven wrote:
> Yes.
>
> The report file looks something like this:.... Or even XML would probably work.
>
> Mfgr / Model: Dell Inc. - Inspiron 1545 ()
> Serial#: 7RT1XJ1
> CPU String: Pentium(R) Dual-Core CPU T4200 @ 2.00GHz
> CPU Actual: 1995 MHz HT/Multi Core (2)
> MB: Dell Inc. - Service Tag: 7RT1XJ1
> BIOS: Version: A14 - Date: 12/07/2009
> Video Card: Mobile Intel(R) 4 Series Express Chipset Family
> Vid Driver: Driver Version: 8.15.10.2302 - Date: 2-11-2011
> RAM: 3,032 MB
> Paging File: 3.25 GB (30% used)
> OS Partition: C:
> Partition Space: 232.88 GB, 85.86 GB free
> Partition Type: (NTFS)
> [Drive 0 SMART REPORT]
> Model: WDC WD2500BEVT-00ZCT0
> FirmWare: 11.01A11
> Serial Number: WD-WXE309HL2151
>
> Value Threshold WorstValue Status Attribute
> ----------------------------------------------------------------------
> 200 51 200 0x2F Read Error Rate
> 187 21 186 0x27 Spin-up Time
> 99 0 99 0x32 Start/Stop Count
> 200 140 200 0x33 Reallocated Sector Count
> 100 0 253 0x2E Seek Error Rate
> 92 0 92 0x32 Power-On Hours
> 100 51 100 0x33 Spin Retry Count
> 100 0 100 0x32 CALIBRATION_RETRY_COUNT
> 99 0 99 0x32 Power Cycle Count
> 200 0 200 0x32 POWER_OFF_RETRACT_CYCLE
> 132 0 132 0x32 LOAD_UNLOAD_CYCLE_COUNT
> 118 0 88 0x22 Temperature
> 200 0 200 0x32 REALLOCATION_EVENTS_COUNT
> 200 0 200 0x32 Current Pending Sector Count
> 100 0 253 0x30 Uncorrectable Sector Count
> 200 0 200 0x32 UltraDMA CRC Error Count
> 100 51 253 0x9 WRITE_ERROR_RATE
> Software
> OS: Win Vista Home Premium SP2 (64 bit) OEM
> Product Key: _____-_____-_____-_____-_____
> Installed on: 10/28/2010 - (This Windows installation is 996.5 days old.)
> Activation: Windows is Activated.
> User Account Control: Disabled
> System Restore: System Restore enabled.
> Windows Updates: Auto Updates Enabled
> Internet Explorer: 9
> Anti-Virus: ---
> Anti-Spyware: Windows Defender (Disabled, Up to Date)
> Firewall: Windows Firewall
> Last Crash Dump: Mini042013-01.dmp - 4/20/2013 04:12 PM
> Last Boot Time: 76s
> Microsoft Office Single Image 2010 Retail:Microsoft Office Single Image 2010 Retail
> Network
> User Name: Owner
> Profile Path: C:\Users\Owner
> Computer Name: LUKE-CODER
> Domain: No
> IP Address: 192.168.10.153 (DHCP)
> DHCP Server: 192.168.10.1
> Gateway: 192.168.10.1
> Subnet: 255.255.255.0
> DNS: 192.168.10.1
> NIC: Intel(R) WiFi Link 5100
> MAC: 00:22:FB:9E:1E:D8
> Remote Desktop Port: 3389
Charger440
Posts: 1529
Joined: Sun May 25, 2014 7:44 am
Location: Missouri

Re: System Info.txt for PCRT import of specs

Post by Charger440 »

I don't feel like doing the homework on that but I have seen that format format before. Who's tool is he using to gather that info?
Jim

It is not "Can it be done?" but rather, "How can we do it?"
stro
Posts: 4
Joined: Sun Jul 19, 2015 5:46 am

Re: System Info.txt for PCRT import of specs

Post by stro »

Not sure what is generating the output, it is different than systeminfo, wmic or speccy.

There is nothing special about it. What allows me to parse it, is it is one spec per line, a label and value separated by a colon. The format was not designed for PCRT.
Charger440
Posts: 1529
Joined: Sun May 25, 2014 7:44 am
Location: Missouri

Re: System Info.txt for PCRT import of specs

Post by Charger440 »

Yea, I figured it was generated by that other program. Just figured UVK could use the same format and save some coding in PCRT. I was just curious what he used to format that info but not really intrigued enough to find it :)

I figure with a format that simple Fred can follow it pretty easy :)
Jim

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

Re: System Info.txt for PCRT import of specs

Post by reggaemanu »

I've made a mod to add specs import from uvk in pcrt (just like it does for d7).
If someone is interested I can share it
Charger440
Posts: 1529
Joined: Sun May 25, 2014 7:44 am
Location: Missouri

Re: System Info.txt for PCRT import of specs

Post by Charger440 »

I'm always interested in new things
Jim

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

Re: System Info.txt for PCRT import of specs

Post by reggaemanu »

First, you'll have to create a new file in repair dir with the following code and name it uvkspec.php.

Code: Select all

<?php

function pullspec($filename) {

	require("deps.php");
	require_once("validate.php");
	require_once("common.php");


	if (!function_exists('zip_open'))  {
		echo "<div style=\"border: #ff0000 2px solid; background:#FFBCBC; color:#ff0000; margin: 20px; padding:20px;\">";
		echo "
		Sorry you server does not have support for opening zip files. Please see your administrator about adding support for the php zip functions
		";
		echo "</div>";
		exit;
	}


	$zipres = zip_open("../attachments/$filename");

	function validate_zipfile($v_filename) {
	   return preg_match('/^[\w\W]+\.(zipfile|zip)$/ui', $v_filename) ? '1' : '0';
	}

	if (validate_zipfile($filename) == '1') {

		while ($zipres2 = zip_read($zipres)) {
			$fileentry = zip_entry_name($zipres2);
			if($fileentry == "System Info.htm") {

				$filesize = zip_entry_filesize($zipres2);

				$filecont = zip_entry_read($zipres2, $filesize);

				$valuestopull = array(
				"cpu" => "Processors",
				"ram" => "Total physical memory",
				"partition" => "Hard disk 0",
				"operatingsystem" => "Operating system",
				"windowsproductkey" => "Windows product key",
				"videocard" => "Video adapters",
				"serial" => "Serial and SNID\/Service tag",
				"model" => "Computer",
				"ipaddress" => "IP address 1",
				"motherboard" => "Motherboard",
				"bios" => "Bios",
				"antivirus" => "Antivirus software&nbsp; &nbsp; State: Enabled, Updated ",
				"username" => "PC owner info",
				"computername" => "PC Info",
				"firewall" => "Windows firewall",
				"networkinterfacecard" => "Network adapters",
				);


				foreach ($valuestopull as $key => $val) {
					$pattern = "/$val<\/td>[<\/tr>]*\\r\\n[<tr>]*<td[a-z0-9=\": ;%]*>(.*)<\/td>/ui";
					if (preg_match($pattern, $filecont, $results)) {
						$result = trim(strip_tags(preg_replace("/&nbsp;/ui"," ",$results[1])));
						if (preg_match("/To Be Filled By O.E.M.*/ui",$result)) $result = "";		
						if ("$key" == "serial") {
							$specarrayreturn[$key] = preg_replace("/Serial: /ui","","$result");
						}
						else {
							$specarrayreturn[$key] = $result;
						}

					}
				}


			}

		}

		zip_close($zipres);

	}

	if(!isset($specarrayreturn)) {
		$specarrayreturn = array();
	}
	return $specarrayreturn;

}

?>
Then we will have to edit some existing files :

* in file repair/pc.php

Search for :

Code: Select all

if (array_key_exists("attach_filename", $_REQUEST)) {
$attach_filename = $_REQUEST['attach_filename'];
require("d7spec.php");
$specarray = pullspec("$attach_filename");
if(count($specarray) == 0) {
$specnotice = pcrtlang("Sorry, machine specs were not found in this d7 report.");
}
}
Add after :

Code: Select all

//mod uvk import
if (array_key_exists("uvk_filename", $_REQUEST)) {
$uvk_filename = $_REQUEST['uvk_filename'];
require("uvkspec.php");
$specarray = pullspec("$uvk_filename");
if(count($specarray) == 0) {
$specnotice = pcrtlang("Sorry, machine specs were not found in this UVK report.");
}
}
//end mod uvk import
Search for :

Code: Select all

$prefcontact = "$rs_result_item_q->prefcontact";
$pcnotes = "$rs_result_item_q->pcnotes";
Add after :

Code: Select all

//mod uvk import
if(isset($specarray) && $specarray["model"]) {
	$pcmake = $specarray["model"];
}
//end mod uvk import
Search for :

Code: Select all

if (array_key_exists("attach_filename", $_REQUEST)) {
$attach_filename = $_REQUEST['attach_filename'];
$varpass = "&assettype=$mainassettypedefaultid&attach_filename=$attach_filename";
} else {
$varpass = "&assettype=$mainassettypedefaultid";
}
Add after :

Code: Select all

//mod uvk import
if (array_key_exists("uvk_filename", $_REQUEST)) {
$uvk_filename = $_REQUEST['uvk_filename'];
$varpass = "&assettype=$mainassettypedefaultid&uvk_filename=$uvk_filename";
} else {
$varpass = "&assettype=$mainassettypedefaultid";
}
//end mod uvk import
Search for :

Code: Select all

if (array_key_exists("attach_filename", $_REQUEST)) {
$attach_filename = $_REQUEST['attach_filename'];
require("d7spec.php");
$specarray = pullspec("$attach_filename");
}
Add after :

Code: Select all

//mod uvk import
if (array_key_exists("uvk_filename", $_REQUEST)) {
$uvk_filename = $_REQUEST['uvk_filename'];
require("uvkspec.php");
$specarray = pullspec("$uvk_filename");
}
//end mod uvk import
* In file repair/wo.php

Search for:

Code: Select all

if (preg_match("/uvk/i", "$attach_title")) {
echo "<br>&nbsp;&nbsp;&nbsp;<font class=text10b>".pcrtlang("UVK report").": </font><a href=\"uvk.php?func=readsystemreport&filename=$attach_filename\" class=smalllink>".pcrtlang("view system info")."</a>";
}
Replace by:

Code: Select all

//mod uvk import
if (preg_match("/uvk/i", "$attach_title")) {
echo "<br>&nbsp;&nbsp;&nbsp;<font class=text10b>".pcrtlang("UVK report").": </font><a href=\"uvk.php?func=readsystemreport&filename=$attach_filename\" class=smalllink>".pcrtlang("view system info")."</a> | <a href=\"pc.php?func=editowner&woid=$pcwo&pcid=$pcid&uvk_filename=$attach_filename\" class=smalllink $therel>".pcrtlang("Import system info")."</a>";
}
//end mod uvk import
* in file repair/admin.php

Search for:

Code: Select all

echo "<br><br><br><font class=text12b>".pcrtlang("Available d7 Field Keywords").":</font> <font class=text12i>(".pcrtlang("these are the values that can be imported from d7 and mapped to PCRT fields").")</font><br>";
echo "<pre>";
Add before :

Code: Select all

//mod uvk import
echo "<br><br><br><font class=text12b>".pcrtlang("Available UVK Field Keywords").":</font> <font class=text12i>(".pcrtlang("these are the values that can be imported from UVK and mapped to PCRT fields").")</font><br>";
echo "<pre>";

$valuestopull = array(
"cpu" => "Processors",
"ram" => "Total physical memory",
"partition" => "Hard disk 0",
"operatingsystem" => "Operating system",
"windowsproductkey" => "Windows product key",
"videocard" => "Video adapters",
"serial" => "Serial and SNID\/Service tag",
"model" => "Computer",
"ipaddress" => "IP address 1",
"motherboard" => "Motherboard",
"bios" => "Bios",
"antivirus" => "Antivirus software&nbsp; &nbsp; State: Enabled, Updated ",
"username" => "PC owner info",
"computername" => "PC Info",
"firewall" => "Windows firewall",
"networkinterfacecard" => "Network adapters",
);


print_r($valuestopull);
echo "</pre>";
//end mod uvk import
That's it, now when you're viewing a work order that have an uvk report attached you have a link to import system specifications.
Fred
Site Admin
Posts: 2357
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Re: System Info.txt for PCRT import of specs

Post by Fred »

Thanks, Manu. This imports the specs directly from the HTML file, right?
One 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: 175
Joined: Wed Jun 10, 2015 9:07 pm
Location: France

Re: System Info.txt for PCRT import of specs

Post by reggaemanu »

Fred wrote:Thanks, Manu. This imports the specs directly from the HTML file, right?
Yes, I just had to use his d7 import system and adapt the parsing for your html file :)
Charger440
Posts: 1529
Joined: Sun May 25, 2014 7:44 am
Location: Missouri

Re: System Info.txt for PCRT import of specs

Post by Charger440 »

Yep Fred, it sure looks like it. He put some keyboard time in there :). I will for sure add this later today.

Side note, Luke's code is really hard to read, I think he does that on purpose :). When I code php I use include files so everything stays neat and organized

Thanks Manu!
Last edited by Charger440 on Sun Oct 04, 2015 6:45 am, edited 1 time in total.
Jim

It is not "Can it be done?" but rather, "How can we do it?"
Fred
Site Admin
Posts: 2357
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Re: System Info.txt for PCRT import of specs

Post by Fred »

I just wouldn't use font tags. They were deprecated in HTML 4.01 and are no longer supported in HTML 5. You can use div, p, span, etc instead.

Code: Select all

echo "<br><br><br><div class=text12b>".pcrtlang("Available UVK Field Keywords").":</div><div class=text12i>(".pcrtlang("these are the values that can be imported from UVK and mapped to PCRT fields").")</div><br>";
echo "<pre>";
http://www.w3schools.com/tags/tag_font.asp
One 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
Post Reply