Subversion Repositories computer_asset_manager_v1

Rev

Rev 3 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 5
Line 3... Line 3...
3
/*
3
/*
4
 * Requires php-pear and libyaml under Debian Wheezy
4
 * Requires php-pear and libyaml under Debian Wheezy
5
 * apt-get install php-pear php5-dev libyaml0dev
5
 * apt-get install php-pear php5-dev libyaml0dev
6
 * I don't know if you also need libyaml-0-2 libyaml-0-2-dbg
6
 * I don't know if you also need libyaml-0-2 libyaml-0-2-dbg
7
 * pecl install yaml
7
 * pecl install yaml
-
 
8
 *
-
 
9
 * V0.9 20160203 RWR
-
 
10
 * Changed to use yaml for the configuration file. Had to take the
-
 
11
 * anonymous functions which parsed the different file types and convert
-
 
12
 * them to simpl eval() blocks.
-
 
13
 * 
8
*/
14
*/
9
 
15
 
10
require 'library.php';
16
require 'library.php';
-
 
17
$VERSION='0.9';
11
 
18
 
12
$VERSION='0.8';
-
 
13
 
19
 
14
class sysinfo {
20
class sysinfo {
15
   private $report; // this will hold an entire report
21
   private $report; // this will hold an entire report
16
   private $messages = array();
22
   private $messages = array();
17
   private $FATAL = false;
23
   private $FATAL = false;
Line 103... Line 109...
103
         $matches;
109
         $matches;
104
         $pattern = $regexes['startTag'] . '.*' . $regexes['endTag'];
110
         $pattern = $regexes['startTag'] . '.*' . $regexes['endTag'];
105
         if ( preg_match( "/$pattern/ms", $this->fileContents, $matches ) ) {
111
         if ( preg_match( "/$pattern/ms", $this->fileContents, $matches ) ) {
106
            $this->fileType = $key;
112
            $this->fileType = $key;
107
            $this->fileContents = $matches[0];
113
            $this->fileContents = $matches[0];
-
 
114
            $body = $this->fileContents;
108
            $this->report = $regexes['eval']($this->fileContents);
115
            $this->report = eval( $regexes['eval'] );
109
            return true;
116
            if ( $this->report ) return true;
110
         } // if
117
         } // if
111
      } // foreach
118
      } // foreach
112
      return false;
119
      return false;
113
   }
120
   }
114
 
121
 
Line 838... Line 845...
838
   } // processSoftwarePackages
845
   } // processSoftwarePackages
839
 
846
 
840
} // class sysinfo
847
} // class sysinfo
841
 
848
 
842
 
849
 
843
require "sysinfoRead.php.conf";
-
 
844
global $bodyContents;
-
 
845
 
850
 
-
 
851
/*
-
 
852
 * we don't know where the configuration file will be, so we have a list
-
 
853
 * below (searchPaths) to look for it. It will load the first one it 
-
 
854
 * finds, then exit. THUS, you could have multiple configuration files
-
 
855
 * but only the first one in the list will be used
-
 
856
 */
-
 
857
 
-
 
858
$confFileName = "sysinfoRead.conf.yaml";
-
 
859
$searchPaths = array( '/etc/camp', '/opt/camp', '/opt/camp/sysinfo', $_SERVER['SCRIPT_FILENAME'], getcwd() );
-
 
860
$configuration = array();
-
 
861
foreach ( $searchPaths as $path ) {
-
 
862
   if ( file_exists( "$path/$confFileName" ) ) {
-
 
863
      #print "Found $path/$confFileName\n";
-
 
864
      $configuration = yaml_parse_file( "$path/$confFileName" );
-
 
865
      #require "$path/$confFileName";
-
 
866
      break; // exit out of the loop; we don't try to load it more than once
-
 
867
   } // if
-
 
868
} // foreach
-
 
869
 
846
mysql_connect( $databaseServer, $databaseUsername, $databasePassword ) or die(mysql_error());
870
mysql_connect( $configuration['database']['databaseServer'], $configuration['database']['databaseUsername'], $configuration['database']['databasePassword'] ) or die(mysql_error());
847
mysql_select_db( $database ) or die(mysql_error());
871
mysql_select_db( $configuration['database']['database'] ) or die(mysql_error());
848
 
872
 
849
 
873
 
850
$thisReport = new sysinfo( $bodyContents );
874
$thisReport = new sysinfo( $configuration['bodyContents'] );
851
$result; 
875
$result; 
852
 
876
 
853
$result = $thisReport->loadFromFile( $argc > 1 ? $argv[1] : "php://stdin" );
877
$result = $thisReport->loadFromFile( $argc > 1 ? $argv[1] : "php://stdin" );
854
if ( $result == 'ini' ) {
878
if ( $result == 'ini' ) {
855
   print $thisReport->dumpMessages();
879
   print $thisReport->dumpMessages();