| Line 42... |
Line 42... |
| 42 |
*/
|
42 |
*/
|
| 43 |
|
43 |
|
| 44 |
$VERSION = '1.1';
|
44 |
$VERSION = '1.1';
|
| 45 |
$MAXDOWNLOAD = 5000; // maximum number of e-mails to download at one time
|
45 |
$MAXDOWNLOAD = 5000; // maximum number of e-mails to download at one time
|
| 46 |
$CLI = isset( $_SERVER["TERM"]); // only set if we are not in a cron job
|
46 |
$CLI = isset( $_SERVER["TERM"]); // only set if we are not in a cron job
|
| 47 |
|
- |
|
| 48 |
/*
|
- |
|
| 49 |
* we don't know where the configuration file will be, so we have a list
|
47 |
// where to load the configuration file from
|
| 50 |
* below (searchPaths) to look for it. It will load the first one it
|
- |
|
| 51 |
* finds, then exit. THUS, you could have multiple configuration files
|
- |
|
| 52 |
* but only the first one in the list will be used
|
- |
|
| 53 |
*/
|
- |
|
| 54 |
|
- |
|
| 55 |
$confFileName = "sysinfoRead.conf.yaml";
|
48 |
$confFileName = "sysinfoRead.conf.yaml";
|
| 56 |
$searchPaths = array( '/etc/camp', '/opt/camp', '/opt/camp/sysinfo', $_SERVER['SCRIPT_FILENAME'], getcwd() );
|
49 |
$searchPaths = array( '/etc/camp', '/opt/camp', '/opt/camp/sysinfo', $_SERVER['SCRIPT_FILENAME'], getcwd() );
|
| 57 |
$configuration = array();
|
- |
|
| 58 |
|
- |
|
| 59 |
|
- |
|
| 60 |
foreach ( $searchPaths as $path ) {
|
- |
|
| 61 |
if ( file_exists( "$path/$confFileName" ) ) {
|
- |
|
| 62 |
print "Found $path/$confFileName\n";
|
- |
|
| 63 |
$configuration = yaml_parse_file( "$path/$confFileName" );
|
- |
|
| 64 |
#require "$path/$confFileName";
|
- |
|
| 65 |
break; // exit out of the loop; we don't try to load it more than once
|
- |
|
| 66 |
} // if
|
- |
|
| 67 |
} // foreach
|
- |
|
| 68 |
|
50 |
|
| - |
|
51 |
/*
|
| - |
|
52 |
* function loadConfig
|
| - |
|
53 |
* Parameters $confFileName - the name of the configuration file
|
| - |
|
54 |
* $searchPaths - an array of paths to be searched
|
| - |
|
55 |
* Returns An array containing the configuration
|
| - |
|
56 |
* will search for a configuration file in $searchPaths for $confFileName
|
| - |
|
57 |
* in order (so as to give priorities). The configuration file is
|
| - |
|
58 |
* assumed to be a YAML file
|
| - |
|
59 |
*/
|
| - |
|
60 |
|
| - |
|
61 |
function loadConfig ( $confFileName, $searchPaths ) {
|
| - |
|
62 |
|
| - |
|
63 |
/*
|
| - |
|
64 |
* we don't know where the configuration file will be, so we have a list
|
| - |
|
65 |
* below (searchPaths) to look for it. It will load the first one it
|
| - |
|
66 |
* finds, then exit. THUS, you could have multiple configuration files
|
| - |
|
67 |
* but only the first one in the list will be used
|
| - |
|
68 |
*/
|
| - |
|
69 |
|
| - |
|
70 |
$configuration = array();
|
| - |
|
71 |
|
| - |
|
72 |
|
| - |
|
73 |
foreach ( $searchPaths as $path ) {
|
| - |
|
74 |
if ( file_exists( "$path/$confFileName" ) ) {
|
| - |
|
75 |
print "Found $path/$confFileName\n";
|
| - |
|
76 |
$configuration = yaml_parse_file( "$path/$confFileName" );
|
| - |
|
77 |
#require "$path/$confFileName";
|
| - |
|
78 |
break; // exit out of the loop; we don't try to load it more than once
|
| - |
|
79 |
} // if
|
| - |
|
80 |
} // foreach
|
| - |
|
81 |
return $configuration;
|
| - |
|
82 |
}
|
| 69 |
|
83 |
|
| 70 |
/*
|
84 |
/*
|
| 71 |
* function OpenMailbox
|
85 |
* function OpenMailbox
|
| 72 |
* Parameters: $username
|
86 |
* Parameters: $username
|
| 73 |
* $password
|
87 |
* $password
|
| Line 200... |
Line 214... |
| 200 |
|
214 |
|
| 201 |
/**************************************************************************************************************
|
215 |
/**************************************************************************************************************
|
| 202 |
* Begin Main Program
|
216 |
* Begin Main Program
|
| 203 |
**************************************************************************************************************/
|
217 |
**************************************************************************************************************/
|
| 204 |
|
218 |
|
| - |
|
219 |
// get the configuration
|
| - |
|
220 |
$configuration = loadConfig( $confFileName, $searchPaths );
|
| 205 |
|
221 |
|
| 206 |
// ensure the path we want to write to exists
|
222 |
// ensure the path we want to write to exists
|
| 207 |
if ( ! is_dir( $configuration['outpath'] ) ) {
|
223 |
if ( ! is_dir( $configuration['outpath'] ) ) {
|
| 208 |
if ( ! mkdir( $configuration['outpath'], 0777, true ) ) {
|
224 |
if ( ! mkdir( $configuration['outpath'], 0777, true ) ) {
|
| 209 |
die( "Could not create path " . $configuration['outpath'] . "\n" );
|
225 |
die( "Could not create path " . $configuration['outpath'] . "\n" );
|