⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common_functions.php

📁 这是一个可以显示localhost 的系统信息的php 生成网页
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php /*************************************************************************** *   Copyright (C) 2006 by phpSysInfo - A PHP System Information Script    * *   http://phpsysinfo.sourceforge.net/                                    * *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * *   This program is distributed in the hope that it will be useful,       * *   but WITHOUT ANY WARRANTY; without even the implied warranty of        * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * *   GNU General Public License for more details.                          * *                                                                         * *   You should have received a copy of the GNU General Public License     * *   along with this program; if not, write to the                         * *   Free Software Foundation, Inc.,                                       * *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * ***************************************************************************/// $Id: common_functions.php,v 1.55 2007/02/20 19:20:20 bigmichi1 Exp $// usefull during developmentif( isset($showerrors) && $showerrors ) {	error_reporting( E_ALL | E_NOTICE );} else {	error_reporting( E_ERROR | E_WARNING | E_PARSE );}// HTML/XML Commentfunction created_by () {	global $VERSION;		return "<!--\n\tCreated By: phpSysInfo - " . $VERSION . "\n\thttp://phpsysinfo.sourceforge.net/\n-->\n";} // print out the bar graph// $value as full percentages// $maximim as current maximum // $b as scale factor// $type as filesystem typefunction create_bargraph ($value, $maximum, $b, $type = "") {	global $webpath;		$textdir = direction();	$imgpath = $webpath . 'templates/' . TEMPLATE_SET . '/images/';	$maximum == 0 ? $barwidth = 0 : $barwidth = round((100  / $maximum) * $value) * $b;	$red = 90 * $b;	$yellow = 75 * $b;	if (!file_exists(APP_ROOT . "/templates/" . TEMPLATE_SET . "/images/nobar_left.gif")) {		if ($barwidth == 0) {			return '<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'bar_' . $textdir['left'] . '.gif">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'bar_middle.gif" width="1">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'bar_' . $textdir['right'] . '.gif">';		} elseif ( file_exists( APP_ROOT . "/templates/" . TEMPLATE_SET . "/images/yellowbar_left.gif") && ( $barwidth > $yellow ) && ( $barwidth < $red ) ) {			return '<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'yellowbar_' . $textdir['left'] . '.gif">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'yellowbar_middle.gif" width="' . $barwidth . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'yellowbar_' . $textdir['right'] . '.gif">';		} elseif ( ( $barwidth < $red ) || ( $type == "iso9660" ) || ( $type == "CDFS" ) ) {			return '<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'bar_' . $textdir['left'] . '.gif">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'bar_middle.gif" width="' . $barwidth . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'bar_' . $textdir['right'] . '.gif">';		} else {			return '<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'redbar_' . $textdir['left'] . '.gif">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'redbar_middle.gif" width="' . $barwidth . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'redbar_' . $textdir['right'] . '.gif">';		}	} else {		if ($barwidth == 0) {			return '<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'nobar_' . $textdir['left'] . '.gif">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'nobar_middle.gif" width="' . ( 100 * $b ) . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'nobar_' . $textdir['right'] . '.gif">';		} elseif ( file_exists( APP_ROOT . "/templates/" . TEMPLATE_SET . "/images/yellowbar_left.gif" ) && ( $barwidth > $yellow ) && ( $barwidth < $red ) ) {			return '<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'yellowbar_' . $textdir['left'] . '.gif">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'yellowbar_middle.gif" width="' . $barwidth . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'nobar_middle.gif" width="' . ( ( 100 * $b ) - $barwidth ) . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'nobar_' . $textdir['right'] . '.gif">';		} elseif ( ( $barwidth < $red ) || ( $type == "iso9660" ) || ( $type == "CDFS" ) ) {			return '<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'bar_' . $textdir['left'] . '.gif">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'bar_middle.gif" width="' . $barwidth . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'nobar_middle.gif" width="' . ( ( 100 * $b ) - $barwidth ) . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'nobar_' . $textdir['right'] . '.gif">';		} elseif ( $barwidth == ( 100 * $b ) ) {			return '<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'redbar_' . $textdir['left'] . '.gif">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'redbar_middle.gif" width="' . ( 100 * $b ) . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'redbar_' . $textdir['right'] . '.gif">';		} else {			return '<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'redbar_' . $textdir['left'] . '.gif">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'redbar_middle.gif" width="' . $barwidth . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'nobar_middle.gif" width="' . ( ( 100 * $b ) - $barwidth ) . '">'				  .'<img height="' . BAR_HEIGHT . '" alt="" src="' . $imgpath . 'nobar_' . $textdir['right'] . '.gif">';		}	}}function create_bargraph_grad( $value, $maximum, $b, $type = "" ) {	global $webpath;		$maximum == 0 ? $barwidth = 0 : $barwidth = round( ( 100  / $maximum ) * $value );	$startColor = '0ef424'; // green	$endColor = 'ee200a'; // red	if ( $barwidth > 100 ) {		$barwidth = 0;	}		return '<img height="' . BAR_HEIGHT . '" width="300" src="' . $webpath . 'includes/indicator.php?height=' . BAR_HEIGHT . '&amp;percent=' . $barwidth . '&amp;color1=' . $startColor . '&amp;color2=' . $endColor . '" alt="">';}function direction() {	global $text_dir;		if( ! isset( $text_dir ) || ( $text_dir == "ltr" ) ) {		$arrResult['direction'] = "ltr";		$arrResult['left'] = "left";		$arrResult['right'] = "right";	} else {		$arrResult['direction'] = "rtl";		$arrResult['left'] = "right";		$arrResult['right'] = "left";	}		return $arrResult;}// Find a system program.  Do path checkingfunction find_program ($strProgram) {	global $addpaths;		$arrPath = array( '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin' );	if( isset( $addpaths ) && is_array( $addpaths ) ) {		$arrPath = array_merge( $arrPath, $addpaths );	}	if ( function_exists( "is_executable" ) ) {		foreach ( $arrPath as $strPath ) {			$strProgrammpath = $strPath . "/" . $strProgram;			if( is_executable( $strProgrammpath ) ) {				return $strProgrammpath;			}		}	} else {		return strpos( $strProgram, '.exe' );	}}// Execute a system program. return a trim()'d result.// does very crude pipe checking.  you need ' | ' for it to work// ie $program = execute_program('netstat', '-anp | grep LIST');// NOT $program = execute_program('netstat', '-anp|grep LIST');function execute_program ($strProgramname, $strArgs = '', $booErrorRep = true ) {	global $error;	$strBuffer = '';	$strError = '';		$strProgram = find_program($strProgramname);	if ( ! $strProgram ) {		if( $booErrorRep ) {			$error->addError( 'find_program(' . $strProgramname . ')', 'program not found on the machine', __LINE__, __FILE__);		}		return "ERROR";	}	// see if we've gotten a |, if we have we need to do patch checking on the cmd	if( $strArgs ) {		$arrArgs = split( ' ', $strArgs );		for( $i = 0; $i < count( $arrArgs ); $i++ ) {			if ( $arrArgs[$i] == '|' ) {				$strCmd = $arrArgs[$i + 1];				$strNewcmd = find_program( $strCmd );				$strArgs = ereg_replace( "\| " . $strCmd, "| " . $strNewcmd, $strArgs );			}		}	}	// no proc_open() below php 4.3	if( function_exists( 'proc_open' ) ) {		$descriptorspec = array(			0 => array("pipe", "r"),  // stdin is a pipe that the child will read from			1 => array("pipe", "w"),  // stdout is a pipe that the child will write to			2 => array("pipe", "w")   // stderr is a pipe that the child will write to		);		$process = proc_open( $strProgram . " " . $strArgs, $descriptorspec, $pipes );		if( is_resource( $process ) ) {			while( !feof( $pipes[1] ) ) {				$strBuffer .= fgets( $pipes[1], 1024 );			}			fclose( $pipes[1] );			while( !feof( $pipes[2] ) ) {				$strError .= fgets( $pipes[2], 1024 );			}			fclose( $pipes[2] );		}		$return_value = proc_close( $process );	} else {		if( $fp = popen( "(" . $strProgram . " " . $strArgs . " > /dev/null) 3>&1 1>&2 2>&3", 'r' ) ) {			while( ! feof( $fp ) ) {				$strError .= fgets( $fp, 4096 );			}			pclose( $fp );		}		$strError = trim( $strError );		if( $fp = popen( $strProgram . " " . $strArgs, 'r' ) ) {			while( ! feof( $fp ) ) {				$strBuffer .= fgets( $fp, 4096 );			}			$return_value = pclose( $fp );		}	}	$strError = trim( $strError );	$strBuffer = trim( $strBuffer );		if( ! empty( $strError ) || $return_value <> 0 ) {		if( $booErrorRep ) {			$error->addError( $strProgram, $strError . "\nReturn value: " . $return_value, __LINE__, __FILE__);		}	}	return $strBuffer;}// A helper function, when passed a number representing KB,// and optionally the number of decimal places required,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -