binaries = $this->path_to_binaries(); if ( isset($this->binaries[SUDO]) && !empty($this->binaries[SUDO]) && !($this->binaries[SUDO] === DISABLE) ) { $this->adelante = TRUE; } return ( $this->adelante ); } /** * * Function: * path_to_binaries ( ) * * Function to obtain absolute paths to specific package binaries * * @param NULL * @return @array * **/ function path_to_binaries() { global $_SERVER; $this->ENVPATH_array = ini_get('safe_mode') ? explode(":",ini_get('safe_mode_exec_dir')) : explode(":",$_SERVER['PATH']); $this->ENVPATH_array[] = '/usr/local/bin'; $this->binary_array = array( CLAMSCAN => array('clamd'), CLAMASSASSIN => array('clamassassin'), MAILDROP => array('maildrop'), CONVERT => array('convert'), COURIER => array('courier-imapd','imapd'), MAILDIRMAKE => array('maildirmake'), SALEARN => array('sa-learn'), PERL => array('perl'), POSTFIX => array('postconf'), SPAMASSASSIN => array('spamassassin'), SUDO => array('sudo'), PYZOR => array('pyzor'), DCC => array('dccproc'), RAZOR2 => array('razor-report','razor-admin'), DSPAM => array('dspam'), ); ksort($this->binary_array); // loop though environment path array... foreach ( $this->ENVPATH_array as $key1 => $ENVPATH ) { // loop through binary_array $this->binaries[$key2] = DISABLE; foreach ( $this->binary_array as $key2 => $bin_array ) { // finally, loop through nested binaries... // this ensures that the many...... ugh... different binary // names are searched for across the many different POSIX // compliant UNIX/Linux servers..... // For example, on FreeBSD, the imapd daemon is "imapd" // while on a gentoo system, it's courier-imapd... You will most likely // get errors if you if crucial requirements are not met, thus you'll // need to add your binary to the array ($this->binary_array) above. // If you add a new binary, // PLEASE PLEASE PLEASE, drop me an email with the addition for future // releases... =) foreach ( $bin_array as $key3 => $binary ) { $path_to_binary = sprintf('%s/%s',$ENVPATH,$binary); if ( file_exists($path_to_binary) ) { $this->binaries[$key2] = trim(str_replace("\n","",$path_to_binary)); break; } } } } return ( $this->binaries ); } /** * * Function: * get_version_info ( ) * * Function to obtain versions for specific packages * * @param NULL * @return @array * **/ function get_version_info() { $this->version = array( // Thus far, apache, maildrop and courier are not found on some systems... APACHE => array('bin' => NULL, 'version' => function_exists('apache_get_version') ? apache_get_version() : 'N/A'), CLAMSCAN => array('bin' => $this->binaries[CLAMSCAN], 'version' => '-V |cut -d" " -f 2 |cut -d"/" -f 1'), CLAMASSASSIN => array('bin' => $this->binaries[CLAMASSASSIN], 'version' => '-V |cut -d" " -f 2'), MAILDROP => array('bin' => $this->binaries[MAILDROP], 'version' => '-v |grep maildrop |cut -d" " -f 2 |tr "," " "'), CONVERT => array('bin' => $this->binaries[CONVERT], 'version' => '-version |grep "Version" |cut -d" " -f 3'), COURIER => array('bin' => $this->binaries[COURIER], 'version' => '--version |cut -d"/" -f 1 | cut -d" " -f 2'), PERL => array('bin' => $this->binaries[PERL], 'version' => '-v |grep "built" |cut -d" " -f 4'), POSTFIX => array('bin' => $this->binaries[POSTFIX], 'version' => '-d |grep "mail_version =" |cut -d" " -f 3 |tr "," " "'), POSTFIXDOMAIN => array('bin' => $this->binaries[POSTFIX], 'version' => '-d |grep "mydomain =" |cut -d"=" -f 2 |tr " " " "'), SPAMASSASSIN => array('bin' => $this->binaries[SPAMASSASSIN], 'version' => '-V |grep -i "spamassassin" |cut -d" " -f 3'), SUDO => array('bin' => $this->binaries[SUDO], 'version' => '-V |grep -i "Sudo version" |cut -d" " -f 3 |tr "," " "'), DSPAM => array('bin' => $this->binaries[DSPAM], 'version' => '--version |grep "(agent/library)" |cut -d" " -f 4'), SQL => DATABASE === 'postgre' ? pg_version() : mysql_get_server_info() ); while ( list($var,$param) = @each($this->version) ) { if ( $var == SQL || $var == APACHE ) { switch ( $var ) { case APACHE: $this->versions[$var] = substr(strrchr($param['version'],'/'),1); break; case SQL: $this->versions[$var] = DATABASE === 'postgre' ? $this->version[$var]['server'] : $this->version[$var]; break; } } else if ( !($this->binaries[$var] === DISABLE) ) { $exec = sprintf('%s %s',$param['bin'],$param['version']); $this->versions[$var] = exec($exec); $this->versions[$var] = $this->versions[$var]; } else { $this->versions[$var] = _('Not Available'); } $this->versions[$var] = trim(str_replace("\n","",$this->versions[$var])); } return ( $this->versions ); } } ?>