Einzelnen Beitrag anzeigen
Alt 03.10.2005, 21:16   #2
Alter
Sack
 
Benutzerbild von Alter
 
Registriert seit: 19.07.2001
Alter: 54
Beiträge: 1.962

Mein Computer

Standard

Das Script hat folgenden Code:
PHP-Code:
<HTML>
<HEAD>
<TITLE>phpBOINC v1.0 by Richard Silvers</TITLE>
</HEAD>
<BODY>
<?
class BOINClass {
  var 
$cpuName;
  var 
$cpuModel;
  var 
$cpuOSName;
  var 
$cpuOSVersion;
  var 
$cpuProcs;
  var 
$cpuVendor;
  var 
$cpuFLOPS;
  var 
$cpuIOPS;

  var 
$perOn;
  var 
$perConnected;
  var 
$perActive;

  var 
$bwUp;
  var 
$bwDown;

  var 
$projectName;
  var 
$userName;
  var 
$teamName;

  var 
$creditTotal;
  var 
$creditAverage;

}


function 
startElement($parser, $name, $attrs) {
  global 
$curTag;
  
$curTag .= "^$name";
}

function 
endElement($parser, $name) {
  global 
$curTag;
  
$caret_pos = strrpos($curTag, '^');
  
$curTag = substr($curTag, 0, $caret_pos);
}

function 
characterData($parser, $data) { 
  global 
$curTag; 
  global 
$BOINC;

  
$cpuNameKey = "^CLIENT_STATE^HOST_INFO^DOMAIN_NAME";
  
$cpuModelKey = "^CLIENT_STATE^HOST_INFO^P_MODEL";
  
$cpuOSNameKey = "^CLIENT_STATE^HOST_INFO^OS_NAME";
  
$cpuOSVersionKey = "^CLIENT_STATE^HOST_INFO^OS_VERSION";
  
$cpuProcsKey = "^CLIENT_STATE^HOST_INFO^P_NCPUS";
  
$cpuVendorKey = "^CLIENT_STATE^HOST_INFO^P_VENDOR";
  
$cpuFLOPSKey = "^CLIENT_STATE^HOST_INFO^P_FPOPS";
  
$cpuIOPSKey = "^CLIENT_STATE^HOST_INFO^P_IOPS";

  
$perOnKey = "^CLIENT_STATE^TIME_STATS^ON_FRAC";
  
$perConnectedKey = "^CLIENT_STATE^TIME_STATS^CONNECTED_FRAC";
  
$perActiveKey = "^CLIENT_STATE^TIME_STATS^ACTIVE_FRAC";

  
$bwUpKey = "^CLIENT_STATE^NET_STATS^BWUP";
  
$bwDownKey = "^CLIENT_STATE^NET_STATS^BWDOWN";

  
$projectNameKey = "^CLIENT_STATE^PROJECT^PROJECT_NAME";
  
$userNameKey = "^CLIENT_STATE^PROJECT^USER_NAME";
  
$teamNameKey = "^CLIENT_STATE^PROJECT^TEAM_NAME";

  
$creditTotalKey = "^CLIENT_STATE^PROJECT^USER_TOTAL_CREDIT";
  
$creditAverageKey = "^CLIENT_STATE^PROJECT^USER_EXPAVG_CREDIT";


  switch (
$curTag) {
    case 
$cpuNameKey:
      
$BOINC->cpuName = $data;
      break;
    case 
$cpuModelKey:
      
$BOINC->cpuModel = $data;
      break;
    case 
$cpuOSNameKey:
      
$BOINC->cpuOSName = $data;
      break;
    case 
$cpuOSVersionKey:
      
$BOINC->cpuOSVersion = $data;
      break;
    case 
$cpuProcsKey:
      
$BOINC->cpuProcs = $data;
      break;
    case 
$cpuVendorKey:
      
$BOINC->cpuVendor = $data;
      break;
    case 
$cpuFLOPSKey:
      
$BOINC->cpuFLOPS = $data;
      break;
    case 
$cpuIOPSKey:
      
$BOINC->cpuIOPS = $data;
      break;

    case 
$perOnKey:
      
$BOINC->perOn = $data;
      break;
    case 
$perConnectedKey:
      
$BOINC->perConnected = $data;
      break;
    case 
$perActiveKey:
      
$BOINC->perActive = $data;
      break;

    case 
$bwUpKey:
      
$BOINC->bwUp = $data;
      break;
    case 
$bwDownKey:
      
$BOINC->bwDown = $data;
      break;

    case 
$projectNameKey:
      
$BOINC->projectName = $data;
      break;
    case 
$userNameKey:
      
$BOINC->userName = $data;
      break;
    case 
$teamNameKey:
      
$BOINC->teamName = "A";
      break;

    case 
$creditTotalKey:
      
$BOINC->creditTotal = $data;
      break;
    case 
$creditAverageKey:
      
$BOINC->creditAverage = $data;
      break;

  }


}

global 
$BOINC;

$BIONC = new BOINClass();
$dir = "";
$file = "client_state";
$xml_parser = xml_parser_create();

xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");

if (!(
$fp = fopen($dir . $file,"r"))) {
  die (
"Could not locate BOINC directory at: " . $dir);
}

while (
$data = fread($fp, 4096)) {
  if (!
xml_parse($xml_parser, $data, feof($fp))) {
    die(
sprintf("XML parse error: %s at line %d", 
        
xml_error_string(xml_get_error_code($xml_parser)), 
        
xml_get_current_line_number($xml_parser)));
  }
}
xml_parser_free($xml_parser);

echo 
"BOINC Statistics:

"
;
echo 
"Computer Name: " . $BOINC->cpuName . "
"
;
echo 
"CPU Vendor: " . $BOINC->cpuVendor . "
"
;
echo 
"CPU Model: " . $BOINC->cpuModel . "
"
;
echo 
"Number Of Processors: " . $BOINC->cpuProcs . "
"
;
echo 
"OS: " . $BOINC->cpuOSName . " " . $BOINC->cpuOSVersion . "
"
;
printf("Floating Point Speed: %0.2f million ops/sec
"
, ($BOINC->cpuFLOPS / 1000000));
printf("Integer Speed: %0.2f million ops/sec

"
, ($BOINC->cpuIOPS / 1000000));

echo 
"Percent On: " . ($BOINC->perOn * 100) . "%
"
;
echo 
"Percent Connected: " . ($BOINC->perConnected * 100) . "%
"
;
echo 
"Percent Active: " . ($BOINC->perActive * 100) . "%

"
;

printf("Bandwidth (UP): %0.1f KB/sec
"
, ($BOINC->bwUp / 1024));
printf("Bandwidth (DOWN): %0.1f KB/sec

"
, ($BOINC->bwDown / 1024));

echo 
"Project: " . $BOINC->projectName . "
"
;
echo 
"User: " . $BOINC->userName . "

"
;

echo 
"Total Credits: " . $BOINC->creditTotal . "
"
;
echo 
"Average Credits: " . $BOINC->creditAverage . "
"
;
?>
</BODY>
</HTML>
Alter ist offline   Mit Zitat antworten