class_ConsoleTools.php
Go to the documentation of this file.00001 <?php
00024 class ConsoleTools extends BaseFrameworkSystem {
00030 protected function __construct () {
00031
00032 parent::__construct(__CLASS__);
00033 }
00034
00040 public static function aquireSelfIPAddress () {
00041
00042 $ip = "127.0.0.1";
00043
00044
00045 $helper = new ConsoleTools();
00046
00047 try {
00048
00049 $io = FrameworkFileInputPointer::createFrameworkFileInputPointer("/etc/hostname");
00050
00051
00052 $hostname = trim($io->readFromFile());
00053 $helper->debugOutput(sprintf("[%s:] Our host name is: <span class=\"data\">%s</span>",
00054 $helper->__toString(),
00055 $hostname
00056 ));
00057
00058
00059 $io->closeFile();
00060
00061
00062 $ipResolved = gethostbyname($hostname);
00063 if (($ipResolved !== false) && ($ipResolved != $hostname)) {
00064
00065 $ip = $ipResolved;
00066
00067
00068 $helper->debugOutput(sprintf("[%s:] Resolved IP address is: <span class=\"data\">%s</span>\n",
00069 $helper->__toString(),
00070 $ip
00071 ));
00072 }
00073 } catch (FrameworkException $e) {
00074
00075 }
00076
00077
00078 return $ip;
00079 }
00080 }
00081
00082
00083 ?>