*** /usr/local/sbin/ocs_mac_agent.php.orig 2007-12-20 14:17:37.000000000 -0500 --- /usr/local/sbin/ocs_mac_agent.php 2009-03-11 19:56:24.000000000 -0400 *************** *** 323,329 **** } if (empty($this->_hostname)) { ! if ($this->_getName == 'scutil' || (isset($a_vals[$a_index['GETNAME'][0]]['value']) && $a_vals[$a_index['GETNAME'][0]]['value'] == 'scutil')) { $this->_hostname = exec('/usr/sbin/scutil --get ComputerName'); --- 323,329 ---- } if (empty($this->_hostname)) { ! if ( ( !isset($this->_getName)) || ($this->_getName == 'scutil') || (isset($a_vals[$a_index['GETNAME'][0]]['value']) && $a_vals[$a_index['GETNAME'][0]]['value'] == 'scutil')) { $this->_hostname = exec('/usr/sbin/scutil --get ComputerName'); *************** *** 391,396 **** --- 391,397 ---- $this->_request->setBody(gzcompress(utf8_decode($this->_inventory()))); if (PEAR::isError($this->_request->sendRequest()) || $this->_request->getResponseCode() != 200) { $this->message('Cannot transmit inventory. Response Code: ' . $this->_request->getResponseCode(), 'error'); + // print $this->_inventory(); die(); } else { *************** *** 410,415 **** --- 411,418 ---- else if (strtolower($a_vals[$a_index['RESPONSE'][0]]['value']) == 'account_update') { $this->message('Updating account info'); // It's to much of a pain to try and convert $a_vals and $a_index back to XML so we just munge it + //echo "\nResponse\n"; + //print $s_xml; $s_xml = str_replace('', '', $s_xml); $s_xml = str_replace('', '', $s_xml); $s_xml = preg_replace('/\s+.*?<\/RESPONSE>$/m', '', $s_xml); *************** *** 754,760 **** // big that it's useless. Now, if we had domxml... exec('/usr/sbin/system_profiler -xml SPNetworkDataType SPPCIDataType SPModemDataType SPMemoryDataType SPUSBDataType SPSCSIDataType SPParallelSCSIDataType SPIDEDataType SPParallelATADataType SPSerialATADataType SPFireWireDataType SPHardwareDataType SPSoftwareDataType SPNetworkDataType SPApplicationsDataType SPDisplaysDataType SPPrintersDataType', $a_output, $s_error); $this->_profileData = implode("\n", $a_output); ! print $this->_profileData; } else { $this->message('Using Input file for XML data: ' . $this->_xmlinputfile); --- 757,763 ---- // big that it's useless. Now, if we had domxml... exec('/usr/sbin/system_profiler -xml SPNetworkDataType SPPCIDataType SPModemDataType SPMemoryDataType SPUSBDataType SPSCSIDataType SPParallelSCSIDataType SPIDEDataType SPParallelATADataType SPSerialATADataType SPFireWireDataType SPHardwareDataType SPSoftwareDataType SPNetworkDataType SPApplicationsDataType SPDisplaysDataType SPPrintersDataType', $a_output, $s_error); $this->_profileData = implode("\n", $a_output); ! // print $this->_profileData; } else { $this->message('Using Input file for XML data: ' . $this->_xmlinputfile); *************** *** 790,795 **** --- 793,800 ---- $this->_doModems(); $this->_doSoftwares(); $this->_doPrinters(); + //echo "\nAccount Info ARRAY\n"; + //print_r($this->_data['CONTENT']['ACCOUNTINFO']); return array_to_xml($this->_data, 'REQUEST'); } *************** *** 831,837 **** $this->_data['CONTENT']['HARDWARE']['OSCOMMENTS'] = $s_kernel; $this->_data['CONTENT']['HARDWARE']['PROCESSORT'] = $this->_getValByKey('cpu_type', $s_node); $this->_data['CONTENT']['HARDWARE']['PROCESSORS'] = $this->_toMHz($this->_getValByKey('current_processor_speed', $s_node)); ! $this->_data['CONTENT']['HARDWARE']['PROCESSORN'] = $this->_getValByKey('number_processors', $s_node, 'integer'); $this->_data['CONTENT']['HARDWARE']['MEMORY'] = $this->_toMB($this->_getValByKey('physical_memory', $s_node)); $this->_data['CONTENT']['HARDWARE']['SWAP'] = 0; $this->_data['CONTENT']['HARDWARE']['IPADDR'] = $s_ipaddr; --- 836,845 ---- $this->_data['CONTENT']['HARDWARE']['OSCOMMENTS'] = $s_kernel; $this->_data['CONTENT']['HARDWARE']['PROCESSORT'] = $this->_getValByKey('cpu_type', $s_node); $this->_data['CONTENT']['HARDWARE']['PROCESSORS'] = $this->_toMHz($this->_getValByKey('current_processor_speed', $s_node)); ! $this->_data['CONTENT']['HARDWARE']['PROCESSORN'] = $this->_getValByKey('number_processors', $s_node, 'integer'); ! if($this->_data['CONTENT']['HARDWARE']['PROCESSORN'] == "N/A") { ! $this->_data['CONTENT']['HARDWARE']['PROCESSORN'] = $this->_getValByKey('number_cpus', $s_node, 'integer'); ! } $this->_data['CONTENT']['HARDWARE']['MEMORY'] = $this->_toMB($this->_getValByKey('physical_memory', $s_node)); $this->_data['CONTENT']['HARDWARE']['SWAP'] = 0; $this->_data['CONTENT']['HARDWARE']['IPADDR'] = $s_ipaddr; *************** *** 855,860 **** --- 863,874 ---- $p = xml_parser_create(); $result = xml_parse_into_struct($p, $s_xml, $a_vals, $a_index); xml_parser_free($p); + // echo "Index array\n"; + // print_r($a_index); + // echo "\nVals array\n"; + // print_r($a_vals); + // echo "\nRaw File\n"; + // print $s_xml; if (!$result) { $this->message('Could not parse account info file [' . ACCTPATH . ']. ' . xml_error_string(xml_get_error_code($p)), 'error'); die(); *************** *** 862,868 **** foreach ($a_index['KEYNAME'] as $s_key => $s_index) { $this->_data['CONTENT']['ACCOUNTINFO'][$s_key]['KEYNAME'] = $a_vals[$s_index]['value']; ! $this->_data['CONTENT']['ACCOUNTINFO'][$s_key]['KEYVALUE'] = @$a_vals[$a_index['KEYVALUE'][$s_key]]['value']; } } --- 876,882 ---- foreach ($a_index['KEYNAME'] as $s_key => $s_index) { $this->_data['CONTENT']['ACCOUNTINFO'][$s_key]['KEYNAME'] = $a_vals[$s_index]['value']; ! $this->_data['CONTENT']['ACCOUNTINFO'][$s_key]['KEYVALUE'] = $a_vals[$a_index['KEYVALUE'][$s_key]]['value']; } } *************** *** 903,908 **** --- 917,923 ---- $this->_data['CONTENT']['MEMORIES'][$i]['CAPACITY'] = $this->_toKB($this->_getValByKey('dimm_size', $s_node)); $this->_data['CONTENT']['MEMORIES'][$i]['SPEED'] = $this->_getValByKey('dimm_speed', $s_node); $this->_data['CONTENT']['MEMORIES'][$i]['TYPE'] = $this->_getValByKey('dimm_type', $s_node); + $this->_data['CONTENT']['MEMORIES'][$i]['SERIALNUMBER'] = $this->_getValByKey('dimm_serial_number', $s_node); $this->_data['CONTENT']['MEMORIES'][$i]['NUMSLOTS'] = $i + 1; } } *************** *** 976,981 **** --- 991,998 ---- $s_manufacturer = $this->_getValByKey('device_manufacturer', $s_node); $this->_data['CONTENT']['STORAGES'][$s_index4]['MANUFACTURER'] = $s_manufacturer; $this->_data['CONTENT']['STORAGES'][$s_index4]['MODEL'] = $this->_getValByKey('device_model', $s_node); + $this->_data['CONTENT']['STORAGES'][$s_index4]['SERIALNUMBER'] = $this->_getValByKey('device_serial', $s_node); + $this->_data['CONTENT']['STORAGES'][$s_index4]['FIRMWARE'] = $this->_getValByKey('device_revision', $s_node); $this->_data['CONTENT']['STORAGES'][$s_index4]['DESCRIPTION'] = $this->_getValByKey('_name', $s_node); $this->_data['CONTENT']['STORAGES'][$s_index4]['DISKSIZE'] = $this->_toMB($this->_getValByKey('size', $s_node)); $s_node = preg_replace('/^\t{4}.*?^\t{4}<\/array>/sm', '', $s_node); *************** *** 1042,1048 **** function _doMonitors() { $s_nodeName = $this->_is10_4 ? 'SPDisplaysDataType' : 'SPPCIDataType'; ! $s_node = $this->_getDataNode($s_nodeName); $s_vendor = $this->_getValByKey('spdisplays_vendor', $s_node); preg_match_all('/.*?<\/dict>/sm', $s_node, $a_matches); foreach ($a_matches[0] as $i => $s_node) { --- 1059,1065 ---- function _doMonitors() { $s_nodeName = $this->_is10_4 ? 'SPDisplaysDataType' : 'SPPCIDataType'; ! $s_node = $this->_getDataNode($s_nodeName, false); $s_vendor = $this->_getValByKey('spdisplays_vendor', $s_node); preg_match_all('/.*?<\/dict>/sm', $s_node, $a_matches); foreach ($a_matches[0] as $i => $s_node) { *************** *** 1059,1066 **** function _doVideos() { $s_nodeName = $this->_is10_4 ? 'SPDisplaysDataType' : 'SPPCIDataType'; ! $s_node = $this->_getDataNode($s_nodeName); preg_match_all('/^\t{3}.*?^\t{3}<\/dict>/sm', $s_node, $a_matches99); // no idea how many video cards the system might have. foreach ($a_matches99[0] as $i => $s_node) { $s_name = $this->_getValByKey('_name', $s_node); if ($this->_is10_4) { --- 1076,1084 ---- function _doVideos() { $s_nodeName = $this->_is10_4 ? 'SPDisplaysDataType' : 'SPPCIDataType'; ! $s_node = $this->_getDataNode($s_nodeName, false); preg_match_all('/^\t{3}.*?^\t{3}<\/dict>/sm', $s_node, $a_matches99); // no idea how many video cards the system might have. + //print $a_matches99; foreach ($a_matches99[0] as $i => $s_node) { $s_name = $this->_getValByKey('_name', $s_node); if ($this->_is10_4) { *************** *** 1366,1372 **** } else { // Remove control characters -- breaks XML ! $value = preg_replace('/[[:cntrl:]]/', '', $value); if (trim($value) == '') { $s_xml .= str_repeat("\t", $in_level) . "<$key />\n"; } --- 1384,1390 ---- } else { // Remove control characters -- breaks XML ! $value = preg_replace('/[^ a-z0-9.,\:\-\/\(\)\\\]/i', '', $value); if (trim($value) == '') { $s_xml .= str_repeat("\t", $in_level) . "<$key />\n"; }