public function indexAction() { try { $settings = Common::getVarFromFile($this->linfoHome . 'sample.config.inc.php', 'settings'); $settings["compress_content"] = false; $linfo = new Linfo($settings); $linfo->scan(); $output = new \Linfo\Output\Html($linfo); $output->output(); } catch (FatalException $e) { echo $e->getMessage() . "\n"; exit(1); } $this->removeViewRenderer(); }
require_once __DIR__ . '/standalone_autoload.php'; use Linfo\Exceptions\FatalException; use Linfo\Linfo; use Linfo\Common; try { // Load settings file.. // Support legacy config files define('IN_LINFO', 'true'); define('IN_INFO', 'true'); if (!is_file(__DIR__ . '/config.inc.php') && is_file(__DIR__ . '/sample.config.inc.php')) { throw new FatalException('Make changes to sample.config.inc.php then rename as config.inc.php'); } elseif (!is_file(__DIR__ . '/config.inc.php')) { throw new FatalException('Config file not found.'); } $settings = Common::getVarFromFile(__DIR__ . '/config.inc.php', 'settings'); $linfo = new Linfo($settings); $linfo->scan(); if (isset($_SERVER['LINFO_NCURSES']) && php_sapi_name() == 'cli') { $output = new \Linfo\Output\Ncurses($linfo); } else { switch (array_key_exists('out', $_GET) ? strtolower($_GET['out']) : 'html') { default: case 'html': $output = new \Linfo\Output\Html($linfo); break; case 'json': case 'jsonp': // To use JSON-P, pass the GET arg - callback=function_name $output = new \Linfo\Output\Json($linfo, array_key_exists('callback', $_GET) ? $_GET['callback'] : null); break;
protected function loadSettings($settings = array()) { // Running unit tests? if (defined('LINFO_TESTING')) { $this->settings = Common::getVarFromFile($this->linfo_testdir . '/test_settings.php', 'settings'); if (!is_array($this->settings)) { throw new FatalException('Failed getting test-specific settings'); } return; } // Don't just blindly assume we have the ob_* functions... if (!function_exists('ob_start')) { $settings['compress_content'] = false; } if (!isset($settings['hide'])) { $settings['hide'] = array('filesystems' => array(), 'storage_devices' => array()); } // Make sure these are arrays $settings['hide']['filesystems'] = is_array($settings['hide']['filesystems']) ? $settings['hide']['filesystems'] : array(); $settings['hide']['storage_devices'] = is_array($settings['hide']['storage_devices']) ? $settings['hide']['storage_devices'] : array(); // Make sure these are always hidden $settings['hide']['filesystems'][] = 'rootfs'; $settings['hide']['filesystems'][] = 'binfmt_misc'; // Default timeformat $settings['dates'] = array_key_exists('dates', $settings) ? $settings['dates'] : 'm/d/y h:i A (T)'; // Default to english translation if garbage is passed if (empty($settings['language']) || !preg_match('/^[a-z]{2}$/', $settings['language'])) { $settings['language'] = 'en'; } // If it can't be found default to english if (!is_file($this->linfo_localdir . 'src/Linfo/Lang/' . $settings['language'] . '.php')) { $settings['language'] = 'en'; } $this->settings = $settings; }
/** * @test */ public function getVarFromFile() { $file = LINFO_TESTDIR . '/files/varfile.php'; $this->assertEquals('foo', Common::getVarFromFile($file, 'var')); }