Subversion Repositories computer_asset_manager_v1

Rev

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

Rev 6 Rev 11
Line 7... Line 7...
7
 * YAML configuration stream will be sent to STDOUT, where you can
7
 * YAML configuration stream will be sent to STDOUT, where you can
8
 * capture it.
8
 * capture it.
9
 * OF COURSE, you can definitely hand code the YAML. It is actually much
9
 * OF COURSE, you can definitely hand code the YAML. It is actually much
10
 * simpler than doing the PHP, but not if you're familiar with PHP
10
 * simpler than doing the PHP, but not if you're familiar with PHP
11
 * and not so good with YAML.
11
 * and not so good with YAML.
-
 
12
 * Requires php-pear and libyaml under Debian Wheezy
-
 
13
 *
-
 
14
 * apt-get install php-pear php5-dev libyaml-dev libyaml-0-2 libyaml-0-2-dbg
-
 
15
 * pecl install yaml
-
 
16
 * echo 'extension=yaml.so' >> /etc/php5/cli/php.ini
-
 
17
 * echo 'extension=yaml.so' >> /etc/apache2/cli/php.ini
-
 
18
 *
12
 */
19
 */
-
 
20
 
-
 
21
/* 
-
 
22
   I use a nowdoc to define this large block of code which evaluates an ini file.  
-
 
23
   (see http://php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc
-
 
24
   nowdoc's don't really work in an array, or at least I have not been able
-
 
25
   to figure out the syntax, so I use the following to get the code into the variable
-
 
26
   $eval_ini, then put that into the $configuration array.
-
 
27
   Also, nowdoc's are pretty sloppy looking, so another reason to do it here :)
-
 
28
*/
-
 
29
$eval_ini = <<<'END'
-
 
30
$data = array();
-
 
31
preg_match( '/\[report date\](.*)[\r\n]/', $body, $_date );
-
 
32
preg_match( '/\[client name\](.*)[\r\n]/', $body, $_client );
-
 
33
preg_match( '/\[hostname\](.*)[\r\n]/', $body, $_host );
-
 
34
$data['report']['date'] = str_replace(array("\n", "\r"), '', $_date[1]);
-
 
35
$data['report']['client'] = str_replace(array("\n", "\r"), '', $_client[1]);
-
 
36
$data['system']['hostname'] = str_replace(array("\n", "\r"), '', $_host[1]);
-
 
37
return $data;
-
 
38
END;
-
 
39
// end of the nowdoc, now on to the regular stuff 
-
 
40
 
13
// Configuration file for getSysinfoMail.php, parse_sysinfo.php and other files
41
// Configuration file for getSysinfoMail.php, parse_sysinfo.php and other files
14
$configuration = array( 
42
$configuration = array( 
15
      // set this to where the files parsed from mail should be placed.
43
      // set this to where the files parsed from mail should be placed.
16
      'outpath' => '/home/rodolico/temp/sysinfo_reports/unprocessed',
44
      'outpath' => '/home/rodolico/temp/sysinfo_reports/unprocessed',
17
      'logFile' => '/home/rodolico/temp/sysinfo_reports/errors.log',
45
      'logFile' => '/home/rodolico/temp/sysinfo_reports/errors.log',
Line 118... Line 146...
118
      'bodyContents' => array( 
146
      'bodyContents' => array( 
119
                      'xml'  => array( 
147
                      'xml'  => array( 
120
                            'startTag' => '\<sysinfo', 
148
                            'startTag' => '\<sysinfo', 
121
                            'endTag' => '\<\/sysinfo[^>]*\>', 
149
                            'endTag' => '\<\/sysinfo[^>]*\>', 
122
                            // see http://stackoverflow.com/questions/6578832/how-to-convert-xml-into-array-in-php
150
                            // see http://stackoverflow.com/questions/6578832/how-to-convert-xml-into-array-in-php
123
                            'eval' => 'function ($body) { return json_decode(json_encode((array)simplexml_load_string($body)),1); }'
151
                            'eval' => 'return(json_decode(json_encode((array)simplexml_load_string($body)),1));',
124
                            
152
                            
125
                            ),
153
                            ),
126
                      'yaml' => array( 
154
                      'yaml' => array( 
127
                            'startTag' => '\-\-\-',
155
                            'startTag' => '\-\-\-',
128
                            'endTag' => '\.\.\.',
156
                            'endTag' => '\.\.\.',
129
                            'eval' => 'function ($body) { return yaml_parse( $body, 0 ); }'
157
                            'eval' => 'return( yaml_parse( $body, 0 ) );',
130
                            ),
158
                            ),
131
                      'ini'  => array( # this is an older format which we don't support, so we'll just write it out
159
                      'ini'  => array( # this is an older format which we don't support, so we'll just write it out
132
                            'startTag' => '\[sysinfo version\]', 
160
                            'startTag' => '\[sysinfo version\]', 
133
                            'endTag' => '', 
161
                            'endTag' => '',
134
 
-
 
-
 
162
                            'eval' => $eval_ini,
135
                            )
163
                            )
136
                    ),
164
                    ),
137
 
165
 
138
      'datase' => array(
166
      'datase' => array(
139
         'databaseServer' => 'localhost',
167
         'databaseServer' => 'localhost',