Sign in to follow this  
Followers 0
Xantioss

ComputerInfo WebInterface

2 posts in this topic

I was bored...

so i made up a tool that show's the specification's of your computer in a web-page

its just a very simple web-server,with 1 page...

maybe usefull to someone?

default it listens to localhost:1200

#include <date.au3>
#include <array.au3>
TCPStartUp()

dim $recv,$IP,$PORT

$IP = "127.0.0.1"
$PORT = 1200

;==============================================
; Create a New socket
;==============================================
$MainSocket = TCPListen($IP,$PORT,  100 )
If $MainSocket = -1 Then 
    MsgBox(64,"Error","Cant open Port "&$port&" Posibly it is in use already")
    Exit
endif

;==============================================
; Listen for connection users
;==============================================
While 1
$con = TCPAccept( $MainSocket)
$page = "page.html"
If $con >= 0 Then
    Do
        $recv &= TCPRecv($con,1024*10)
    until StringInStr($recv,@CRLF&@CRLF)
    $pagecon = getpage($page)
    TCPSend($con,header(stringlen($pagecon))&$pagecon)
    TCPCloseSocket($con)
EndIf
Wend

;============================================================
; Header($length)
; Arguments: Length in bytes
; This function wil generate a ready-to-use HTTP Header
;============================================================
func header($length)
    dim $string
    $string &=  "HTTP/1.0 200 OK"&@crlf
    ;$string &=     "Date: "_DateDayOfWeek( @WDAY, 1 )&", "&@WDAY&" "&_DateToMonth(@MON, 1)&" "&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&"GMT+1"&@crlf
    $string &=  "Date: "&_DateDayOfWeek( @WDAY, 1 )&", "&@WDAY&" "&_DateToMonth(@MON, 1)&" "&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&"CET"&@crlf
    $string &=  "Server: Apache/1.3.29 (Unix) PHP/4.3.4"&@crlf
    $string &=  "X-Powered-By: PHP/4.3.4"&@crlf
    $string &=  "Content-Language: nl"&@crlf
    $string &=  "Content-Type: text/html; charset=iso-8859-1"&@crlf
    ;$string &=     "X-Cache: MISS from wikipedia.org"
    $string &=  "Connection: close"&@crlf
    $string &=  "Content Type: TEXT/HTML"&@crlf
    $string &=  "Content Length: "&$length&" bytes (received)"&@CRLF&@CRLF
    return $string
endfunc

;============================================================
; Getpage($filename)
; Arguments: The file name to parse 
; This function wil parse some data defined as {vars}
;============================================================
func getpage($filename)

    if FileExists($filename) then 
;~  $array[0] = Memory Load (Percentage of memory in use)
;~  $array[1] = Total physical RAM
;~  $array[2] = Available physical RAM
;~  $array[3] = Total Pagefile
;~  $array[4] = Available Pagefile
;~  $array[5] = Total virtual
;~  $array[6] = Available virtual
        $mem = MemGetStats()
        $page = FileRead($filename)
        $page = StringReplace($page,"{computername}",@ComputerName)
        $page = StringReplace($page,"{cpu}",getcpuspeed()&"Mhz ("&@ProcessorArch&")")
        $page = StringReplace($page,"{mem}",round($mem[1]/1024,0)&"MB "& "( Used "&$mem[0]&"% )")
        $page = StringReplace($page,"{uptime}",getuptime())
        $page = StringReplace($page,"{os}",GetOS())
        $page = StringReplace($page,"{hdd}",GetSpace())
        return $page
    Else
        return -1
    endif
endfunc

;============================================================
; getuptime()
; Arguments: none
; This function wil return the uptime of your system
;============================================================
func getuptime()
    dim $Hours, $Mins, $Secs
    $call = DllCall ("kernel32.dll", "long", "GetTickCount")
    $num = $call[0]
    _TicksToTime ( $num, $Hours, $Mins, $Secs )
    $Days = int($Hours / 24)
    $Hours = $Hours - ($Days * 24)
    return $Days&"Days "&$Hours&" Hours "&$Mins&" Minutes "&$Secs&" Seconds"
endfunc

;============================================================
; GetOs()
; Arguments: none
; This function wil return the full name of your operating system
;============================================================
func GetOS()
;~  @OSVersion
;~  Returns one of the following: "WIN_2008", "WIN_VISTA", "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95" 
$string = @OSVersion
$string = StringReplace($string,"WIN_2008","Windows server 2008")
$string = StringReplace($string,"WIN_VISTA","Windows Vista")
$string = StringReplace($string,"WIN_2003","Windows server 2003")
$string = StringReplace($string,"WIN_XP","Windows XP ("&@OSServicePack&")")
$string = StringReplace($string,"WIN_2000","Windows 2000")
$string = StringReplace($string,"WIN_NT4","Windows NT 4")
$string = StringReplace($string,"WIN_ME","Windows Millenium Edition")
$string = StringReplace($string,"WIN_98","Windows 98")
$string = StringReplace($string,"WIN_95","Windows 95")
return $string
endfunc

;============================================================
; GetSpace()
; Arguments: none
; This function wil return almost all information about your hard-drive
; Warning: this is in a HTML format!
;============================================================
func GetSpace()
    $drives = DriveGetDrive("ALL")
    _ArrayDisplay($drives,"asdasda")
    $string = ""
    if not @error then 
        for $i = 1 to $drives[0]
            $string &= "&nbsp; File System: "&DriveGetFileSystem($drives[$i])&" Label: "&DriveGetLabel($drives[$i])&" Space Total: "&round(DriveSpaceTotal($drives[$i])/1024,2)&"GB"&" Space free: "&round(DriveSpaceFree($drives[$i]),2)&"MB"&" Space Used: "&round(DriveSpaceTotal($drives[$i])-DriveSpaceFree($drives[$i]),2)&"MB"&@CRLF&"<br>" 
        Next
        ConsoleWrite($string)
        return $string
    Else
        return -1
    endif
    return -2
EndFunc

;============================================================
; GetCpuSpeed()
; Arguments: none
; This funtion wil return your current CPU speed (in megahertz)
;============================================================
func getcpuspeed()
    $colItems = ""
    $strComputer = "localhost"
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL",0x10+0x20)
    If IsObj($colItems) then
        For $objItem In $colItems    
        $SPEED = $objItem.MaxClockSpeed
        Next
    EndIf
    return $speed
endfunc

and the mantioned HTML page,name it Page.html to work default.

<html>
<head>
    <title> Current specs for {computername} </title>
</head>

<h1> Specs for {computername} </h1>
<br>
Computername: {computername}<br>
Cpu: {cpu}<br>
Memory: {mem}<br>
Uptime: {uptime}<br>
Operating System: {os}<br>
Hardisk(s):<br>{hdd}<br>
</html>

Ofcourse you are free to edit,reproduce reuse anything in this script,if you give me so credit for this :)

hf!

greetz Xantios

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0