function uptime($f3) { $this->sysinfo = \SysInfo::instance(); $values = array(); $values['uptime'] = $this->sysinfo->uptime; echo json_encode($values); }
public static function create() { if (!self::$obj) { self::$obj = new SysInfo(); } return self::$obj; }
/** * The function used to set and/or retrieve the current instance of this class. * * @return object $instance A reference to an instance of this class. */ public static function get_instance() { if (null == self::$instance) { self::$instance = new self(); } // end if return self::$instance; }
/** * @covers SysInfo\SysInfo::factory */ public function testCurrentPlatform() { $os = PHP_OS; if (!isset(SysInfo::$mapping[$os])) { $this->markTestSkipped($os . ' is not implemented. Skipping test.'); } $sysInfo = SysInfo::factory(); $this->assertInstanceOf('SysInfo\\SysInfoInterface', $sysInfo); $this->assertInstanceOf(SysInfo::$mapping[$os], $sysInfo); }
public static function handleHomeRequest() { static::respond('home', ['Mounts' => SysInfo::mounts(), 'CPUInfo' => SysInfo::CPUInfo(), 'MemoryInfo' => SysInfo::MemoryInfo()]); }
public function genSysInfo() { // PHP SysInfo requires 'php-xml'. If it doesn't exist, // then we can't really do anything. if (!class_exists('DOMDocument') || !extension_loaded('mbstring')) { return false; } // Time how long it takes to run $start = microtime(true); if (!class_exists('SysInfo')) { include 'classes/SysInfo.class.php'; } $si = SysInfo::create(); $info = $si->getSysInfo(); $end = microtime(true); $delay = (double) $end - $start; // This is now a float in seconds of how long it took // to generate the sysinfo. // Make sure it's a valid number, and it's not too small. if ($delay < 0.1 || is_nan($delay)) { $delay = 0.1; } $info['generationlength'] = $delay; $this->setConfig('latestsysinfo', $info); $this->setConfig($info['timestamp'], $info, 'MINUTES'); $this->pruneSysInfo(); return $info; }
<?php // Get a reference to the SysInfo instance $sysinfo = SysInfo::get_instance(); // Now get information from the environment $theme = wp_get_theme(); $browser = $sysinfo->get_browser(); $plugins = $sysinfo->get_all_plugins(); $active_plugins = $sysinfo->get_active_plugins(); $memory_limit = ini_get('memory_limit'); $memory_usage = $sysinfo->get_memory_usage(); $all_options = $sysinfo->get_all_options(); $all_options_serialized = serialize($all_options); $all_options_bytes = round(mb_strlen($all_options_serialized, '8bit') / 1024, 2); $all_options_transients = $sysinfo->get_transients_in_options($all_options); ?> <div id="sysinfo"> <div class="wrap"> <div class="icon32"> <img src="<?php echo SYSINFO_PLUGIN_URL; ?> /images/sysinfo.png" /> </div><!-- /.icon32 --> <h2 class="title"><?php _e(' SysInfo', 'sysinfo'); ?> </h2><!-- /.title -->
public function parse_filesystems() { global $show_bind, $show_inodes; $results = array(); $j = 0; $df = SysInfo::execute_program('df', '-k' . $this->df_param); $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY); sort($df); if ($show_inodes) { $df2 = SysInfo::execute_program('df', '-i' . $this->df_param); $df2 = preg_split("/\n/", $df2, -1, PREG_SPLIT_NO_EMPTY); sort($df2); } $mount = SysInfo::execute_program('mount'); $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY); sort($mount); foreach ($df as $df_line) { $df_buf1 = preg_split("/(\\%\\s)/", $df_line, 2); if (count($df_buf1) != 2) { continue; } preg_match("/(.*)(\\s+)(([0-9]+)(\\s+)([0-9]+)(\\s+)([0-9]+)(\\s+)([0-9]+)\$)/", $df_buf1[0], $df_buf2); $df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[1]); if ($show_inodes) { preg_match_all("/([0-9]+)%/", $df2[$j + 1], $inode_buf, PREG_SET_ORDER); } if (count($df_buf) == 6) { $df_buf[5] = trim($df_buf[5]); if (SysInfo::hide_mount($df_buf[5])) { continue; } $df_buf[0] = trim(str_replace("\$", "\\\$", $df_buf[0])); $current = 0; foreach ($mount as $mount_line) { if (preg_match("#" . $df_buf[0] . " on " . $df_buf[5] . " type (.*) \\((.*)\\)#", $mount_line, $mount_buf)) { $mount_buf[1] .= "," . $mount_buf[2]; } elseif (!preg_match("#" . $df_buf[0] . "(.*) on " . $df_buf[5] . " \\((.*)\\)#", $mount_line, $mount_buf)) { continue; } $strFstype = substr($mount_buf[1], 0, strpos($mount_buf[1], ",")); if (SysInfo::hide_fstype($strFstype)) { continue; } $current++; if ($show_bind || !stristr($mount_buf[2], "bind")) { $results[$j] = array(); $results[$j]['disk'] = str_replace("\\\$", "\$", $df_buf[0]); $results[$j]['size'] = $df_buf[1]; $results[$j]['used'] = $df_buf[2]; $results[$j]['free'] = $df_buf[3]; // --> Bug 1527673 if ($results[$j]['used'] < 0) { $results[$j]['size'] = $results[$j]['free']; $results[$j]['free'] = 0; $results[$j]['used'] = $results[$j]['size']; } // <-- Bug 1527673 // --> Bug 1649430 if ($results[$j]['size'] == 0) { break; } else { $results[$j]['percent'] = round($results[$j]['used'] * 100 / $results[$j]['size']); } // <-- Bug 1649430 $results[$j]['mount'] = $df_buf[5]; $results[$j]['fstype'] = $strFstype; $results[$j]['options'] = substr($mount_buf[1], strpos($mount_buf[1], ",") + 1, strlen($mount_buf[1])); if ($show_inodes && isset($inode_buf[count($inode_buf) - 1][1])) { $results[$j]['inodes'] = $inode_buf[count($inode_buf) - 1][1]; } $j++; unset($mount[$current - 1]); sort($mount); break; } } } } return $results; }