| Line 12... |
Line 12... |
| 12 |
* them to simpl eval() blocks.
|
12 |
* them to simpl eval() blocks.
|
| 13 |
*
|
13 |
*
|
| 14 |
*/
|
14 |
*/
|
| 15 |
|
15 |
|
| 16 |
require 'library.php';
|
16 |
require 'library.php';
|
| 17 |
$VERSION='0.9';
|
17 |
$VERSION='0.9.1';
|
| 18 |
|
18 |
|
| 19 |
|
19 |
|
| 20 |
class sysinfo {
|
20 |
class sysinfo {
|
| 21 |
private $report; // this will hold an entire report
|
21 |
private $report; // this will hold an entire report
|
| 22 |
private $messages = array();
|
22 |
private $messages = array();
|
| Line 60... |
Line 60... |
| 60 |
"Report on $this->reportDateSQL, client $this->clientName, system $this->machineName ($this->fileType)");
|
60 |
"Report on $this->reportDateSQL, client $this->clientName, system $this->machineName ($this->fileType)");
|
| 61 |
// now, we do every step in turn. If they set the FATAL flag, we exit.
|
61 |
// now, we do every step in turn. If they set the FATAL flag, we exit.
|
| 62 |
if ( $this->FATAL ) return $this->returnCode;
|
62 |
if ( $this->FATAL ) return $this->returnCode;
|
| 63 |
$this->getMachineID();
|
63 |
$this->getMachineID();
|
| 64 |
if ( empty( $this->machineID ) ) return $this->returnCode;
|
64 |
if ( empty( $this->machineID ) ) return $this->returnCode;
|
| 65 |
$this->recordReport();
|
65 |
$this->checkDuplicate();
|
| 66 |
if ( $this->FATAL) return $this->returnCode;
|
66 |
if ( $this->FATAL) return $this->returnCode;
|
| 67 |
$this->updateComputerMakeup();
|
67 |
$this->updateComputerMakeup();
|
| 68 |
$this->updateOS();
|
68 |
$this->updateOS();
|
| 69 |
$this->updateBootTime();
|
69 |
$this->updateBootTime();
|
| 70 |
$this->doIPAddresses();
|
70 |
$this->doIPAddresses();
|
| 71 |
$this->processPCI();
|
71 |
$this->processPCI();
|
| 72 |
$this->processSoftwarePackages();
|
72 |
$this->processSoftwarePackages();
|
| - |
|
73 |
// at this point, we don't really need the report title information
|
| - |
|
74 |
// so we will remove it before recordReport has a chance to put it
|
| - |
|
75 |
// in database
|
| - |
|
76 |
array_shift( $this->messages );
|
| - |
|
77 |
// now record the report
|
| - |
|
78 |
$this->recordReport();
|
| 73 |
return $this->returnCode;;
|
79 |
return $this->returnCode;;
|
| 74 |
} // function processReport
|
80 |
} // function processReport
|
| 75 |
|
81 |
|
| 76 |
/*
|
82 |
/*
|
| 77 |
* Name: loadFromFile
|
83 |
* Name: loadFromFile
|
| Line 145... |
Line 151... |
| 145 |
private function processINI() {
|
151 |
private function processINI() {
|
| 146 |
return false;
|
152 |
return false;
|
| 147 |
}
|
153 |
}
|
| 148 |
|
154 |
|
| 149 |
public function dumpMessages () {
|
155 |
public function dumpMessages () {
|
| - |
|
156 |
$return = '';
|
| - |
|
157 |
if ( $this->messages ) {
|
| 150 |
$return = implode( "\n", $this->messages );
|
158 |
$return = implode( "\n", $this->messages );
|
| 151 |
$return .= "\n";
|
159 |
$return .= "\n";
|
| - |
|
160 |
}
|
| 152 |
return $return;
|
161 |
return $return;
|
| 153 |
}
|
162 |
}
|
| 154 |
|
163 |
|
| 155 |
/*
|
164 |
/*
|
| 156 |
* Name: validateReport
|
165 |
* Name: validateReport
|
| Line 227... |
Line 236... |
| 227 |
|
236 |
|
| 228 |
/*
|
237 |
/*
|
| 229 |
* checks for a duplicate report, ie one that has already been run.
|
238 |
* checks for a duplicate report, ie one that has already been run.
|
| 230 |
* if this computer has a report already for this date/time
|
239 |
* if this computer has a report already for this date/time
|
| 231 |
*/
|
240 |
*/
|
| 232 |
private function recordReport() {
|
241 |
private function checkDuplicate() {
|
| 233 |
$count = getOneDBValue("select count(*) from sysinfo_report where device_id = $this->machineID and report_date = '$this->reportDateSQL'");
|
242 |
$count = getOneDBValue("select count(*) from sysinfo_report where device_id = $this->machineID and report_date = '$this->reportDateSQL'");
|
| 234 |
if ( $this->processDuplicates ) { $count = 0; } // for testing
|
243 |
if ( $this->processDuplicates ) { $count = 0; } // for testing
|
| 235 |
if ( $count ) {
|
244 |
if ( $count ) {
|
| 236 |
$this->messages[] = "Duplicate Report for $this->machineName (id $this->machineID) on $this->reportDateSQL";
|
245 |
$this->messages[] = "Duplicate Report for $this->machineName (id $this->machineID) on $this->reportDateSQL";
|
| 237 |
$this->returnCode = 4;
|
246 |
$this->returnCode = 4;
|
| 238 |
$this->FATAL = true;
|
247 |
$this->FATAL = true;
|
| 239 |
return false;
|
248 |
return false;
|
| 240 |
}
|
249 |
}
|
| - |
|
250 |
return true;
|
| - |
|
251 |
} // recordReport
|
| - |
|
252 |
|
| - |
|
253 |
|
| - |
|
254 |
/*
|
| - |
|
255 |
* Creates an entry in the sysinfo_report table
|
| - |
|
256 |
*/
|
| - |
|
257 |
private function recordReport() {
|
| 241 |
$version = $this->report['report']['version'];
|
258 |
$version = $this->report['report']['version'];
|
| - |
|
259 |
$messages = makeSafeSQLValue( $this->dumpMessages() );
|
| 242 |
# if we made it this far, we are ok, so just add the report id
|
260 |
// if we made it this far, we are ok, so just add the report id
|
| 243 |
queryDatabaseExtended("insert into sysinfo_report(device_id,version,report_date,added_date) values ($this->machineID ,'$version','$this->reportDateSQL',now())");
|
261 |
queryDatabaseExtended("insert into sysinfo_report(device_id,version,report_date, notes,added_date) values ($this->machineID ,'$version','$this->reportDateSQL',$messages,now())");
|
| 244 |
$this->reportID = getOneDBValue("select max( sysinfo_report_id ) from sysinfo_report where device_id = $this->machineID and report_date = '$this->reportDateSQL'");
|
262 |
$this->reportID = getOneDBValue("select max( sysinfo_report_id ) from sysinfo_report where device_id = $this->machineID and report_date = '$this->reportDateSQL'");
|
| 245 |
return true;
|
263 |
return true;
|
| 246 |
}
|
264 |
} // recordReport
|
| 247 |
|
265 |
|
| 248 |
|
266 |
|
| 249 |
function makeUnknown( $clientName, $machineName, $reportDate ) {
|
267 |
function makeUnknown( $clientName, $machineName, $reportDate ) {
|
| 250 |
$result = getOneDBValue("select report_date from unknown_entry where client_name = '$clientName' and device_name = '$machineName'");
|
268 |
$result = getOneDBValue("select report_date from unknown_entry where client_name = '$clientName' and device_name = '$machineName'");
|
| 251 |
if ( empty( $result ) ) {
|
269 |
if ( empty( $result ) ) {
|
| Line 256... |
Line 274... |
| 256 |
$this->returnCode = 6;
|
274 |
$this->returnCode = 6;
|
| 257 |
return "New entry detected, but entry already made. You must update Camp before this can be processed";
|
275 |
return "New entry detected, but entry already made. You must update Camp before this can be processed";
|
| 258 |
}
|
276 |
}
|
| 259 |
}
|
277 |
}
|
| 260 |
|
278 |
|
| 261 |
# simply used to get an attrib_id. If it does not exit, will create it
|
279 |
// simply used to get an attrib_id. If it does not exit, will create it
|
| 262 |
|
280 |
|
| 263 |
private function getAttributeID ( $attributeName, $reportDate ) {
|
281 |
private function getAttributeID ( $attributeName, $reportDate ) {
|
| 264 |
$attributeName = makeSafeSQLValue( $attributeName );
|
282 |
$attributeName = makeSafeSQLValue( $attributeName );
|
| 265 |
$result = getOneDBValue( "select attrib_id from attrib where name = $attributeName and removed_date is null" );
|
283 |
$result = getOneDBValue( "select attrib_id from attrib where name = $attributeName and removed_date is null" );
|
| 266 |
if ( !isset( $result) ) {
|
284 |
if ( !isset( $result) ) {
|