Esempio n. 1
0
 /**
  * Initializes fEmail for creating message ids
  * 
  * @return fEmail
  */
 public function __construct()
 {
     if (self::$local_hostname !== NULL) {
         return;
     }
     if (isset($_ENV['HOST'])) {
         self::$local_hostname = $_ENV['HOST'];
     }
     if (strpos(self::$local_hostname, '.') === FALSE && isset($_ENV['HOSTNAME'])) {
         self::$local_hostname = $_ENV['HOSTNAME'];
     }
     if (strpos(self::$local_hostname, '.') === FALSE) {
         self::$local_hostname = php_uname('n');
     }
     if (strpos(self::$local_hostname, '.') === FALSE && !in_array('exec', explode(',', ini_get('disable_functions'))) && !ini_get('safe_mode') && !ini_get('open_basedir')) {
         if (fCore::checkOS('linux')) {
             self::$local_hostname = trim(shell_exec('hostname --fqdn'));
         } elseif (fCore::checkOS('windows')) {
             $output = shell_exec('ipconfig /all');
             if (preg_match('#DNS Suffix Search List[ .:]+([a-z0-9_.-]+)#i', $output, $match)) {
                 self::$local_hostname .= '.' . $match[1];
             }
         } elseif (fCore::checkOS('bsd', 'osx') && file_exists('/etc/resolv.conf')) {
             $output = file_get_contents('/etc/resolv.conf');
             if (preg_match('#^domain ([a-z0-9_.-]+)#im', $output, $match)) {
                 self::$local_hostname .= '.' . $match[1];
             }
         }
     }
 }