Welcome to Gaia! ::

The Official Linux Users of Gaia

Back to Guilds

A Guild for Linux, BSD, Mac, Solaris, and other Unix like operating systems. 

Tags: Computer Help, Linux, BSD (Berkeley Software Distrobution), Mac (Macintosh), Unix 

Reply Programs, Software, and anything else
PHP signature Information Program

Quick Reply

Enter both words below, separated by a space:

Can't read the text? Click here

Submit

root-localhost

PostPosted: Wed Jun 20, 2007 8:28 am


Here is a PHP Aplication I wrote to display My webservers stats and a couple other things in my signature
Here is the main file
/*
* Copyright (c) 2007, Chris Schimp
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Chris Schimp nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Chris Schimp ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Chris Schimp BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
header("Content-type: image/png")
header('Cache-Control: no-cache, must-revalidate')
header('Pragma: no-cache')
$img = imagecreatetruecolor(500, 170)
imagesavealpha($img, true)
$trans_colour = imagecolorallocate($img, 255, 255, 255)
imagefill($img, 0, 0, $trans_colour)
//CookieBussiness
$colourcookie = $_GET['colourcookie']
if ($colourcookie == "0")
setcookie('rootlocalhostcolours', '0')
elseif ($colourcookie == "1")
setcookie('rootlocalhostcolours', '1')
//End CookieBussiness
//Colour Control
if ($_COOKIE['rootlocalhostcolours'] == "1"){
$colour = array()
for($numColors = 1; $numColors <= 15; $numColors++)
{
$colour[] = imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255))
}
}
else{
$colour = array()
for($numColors = 1; $numColors <= 15; $numColors++)
{
$colour[] = imagecolorallocate($img,0,0,0)
}
}
$barcolour = imagecolorallocate($img,0,0,0)
$bartextcolour = imagecolorallocate($img,255,0,0)
//END Colour Control Segment
//DATA Gathering/Setting
exec("uptime", $upout1)
exec("uname -r", $kernelver)
exec("uname -p", $proc)
exec("uname -o", $os)
exec("cat /var/log/apache2/gaiaweb-access_log |grep sigimg.php |wc -l", $viewcount)
$upout = substr($upout1[0],10)
$meminfo = fopen("/proc/meminfo", "r")
$mem1 = round(ereg_replace("[^0-9]", "", fgets($meminfo))/1024, 2)
$mem2 = round(ereg_replace("[^0-9]", "", fgets($meminfo))/1024, 2)
$data1 = "Uptime: $upout";
$data3 = "Kernel: $kernelver[0]";
$data4 = "Processors: $proc[0]";
$data5 = "OS: $os[0]";
$data6 = "Email: localhost.root00@gmail.com";
$cpu = file("/var/log/cpu")
$cpu1 = substr($cpu[3], 0, 3)
$cpuusage = ceil($cpu1)
$cpuusage1 = $cpuusage*2;
$memdata1 = $mem1/2;
$memdata2 = $mem2/2;
$memdata3 = $memdata1 - $memdata2;
$memdata4 = $memdata3*2;
$memdata5 = "$memdata4 Mb Used of $mem1 Mb";
$ver = "SSIS V1";
$randomnum = ceil(mt_rand(0,1000000)/2)
$pixb = 10;
$USERIP = $_SERVER['REMOTE_ADDR']
$USERDATA = "Your Current IP is $USERIP";
include 'browsercheck.php';
$OSPICH = imagesy($OSPIC)
$OSPICW = imagesx($OSPIC)
$music = file("/storage/gaiastuff/music/nowPlaying.txt")
$music1 = "Currently Listening to: $music[0]";
//End Data Gathering/Setting
imagerectangle($img, 0, 0, 499, 160, $colour[0])
imagestring($img, 3, $pixb, 5, $data1, $colour[1])
imagerectangle($img, 80, 23, $memdata1, 38, $barcolour)
imagefilledrectangle($img, 80, 23, $memdata3, 38, $barcolour)
imagestring($img, 3, $pixb, 23, "Memory:", $colour[2])
imagestring($img, 2, 81, 24, $memdata5, $bartextcolour)
imagerectangle($img, 80, 45, 270, 60, $barcolour)
imagefilledrectangle($img, 80, 45, 80+$cpuusage1, 60, $barcolour)
imagestring($img, 3, $pixb, 45, "CPU Usage:", $colour[3])
imagestring($img, 2, 81, 45, "Using $cpuusage% of 100%", $bartextcolour)
imagestring($img, 3, $pixb, 69, $data3, $colour[4])
imagestring($img, 3, $pixb, 84, $data4, $colour[5])
imagestring($img, 3, $pixb, 99, $data5, $colour[6])
imagestring($img, 3, $pixb, 114, $data6, $colour[7])
imagestring($img, 1, 460, 129, $ver, $colour[8])
imagestring($img, 3, $pixb, 129, "This Signature Has Been Viewed $viewcount[0] Times", $colour[9])
imagestring($img, 2, 282, 23, $USERDATA, $colour[12])
imagestring($img, 2, 282, 65, "Your Operating System is: $os", $colour[13])
imagestring($img, 2, 282, 45, "Your Browser is $browser", $colour[14])
imagestring($img, 3, $pixb, 145, "Currently Listening to: $music[0]", $colour[15])
imagecopymerge($img, $OSPIC, 350, 80, 0, 0, $OSPICW, $OSPICH, 100)
imagepng($img,NULL,9)
imagedestroy($img)
fclose($meminfo)
?>

The file that does the browser and OS detection(called browsercheck.php)
/*
* Copyright (c) 2007, Chris Schimp
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Chris Schimp nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Chris Schimp ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Chris Schimp BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//OS Detection
$USERAGENT = $_SERVER['HTTP_USER_AGENT']
if ( preg_match('/Linux/', $USERAGENT) ){
$os = "Linux";
$OSPIC = imagecreatefrompng("imgs/linux.png")
}
elseif (preg_match('/Windows/', $USERAGENT)){
$os = "Windows";
$OSPIC = imagecreatefrompng("imgs/windows.png")
}
elseif (preg_match('/OS X/', $USERAGENT)){
$os = "OS X";
$OSPIC = imagecreatefrompng("imgs/mac.png")
}
elseif (preg_match('/BSD/', $USERAGENT)){
$os = "BSD";
$OSPIC = imagecreatefrompng("imgs/bsd.png")
}
else {
$os = "Unknown OS";
}
//Browser Detection
if (preg_match('/Firefox/', $USERAGENT)){
$browser = "Firefox";
}
elseif (preg_match('/MSIE/', $USERAGENT)){
$browser = "Internet Explorer";
}
elseif (preg_match('/Opera/', $USERAGENT)){
$browser = "Opera";
}
elseif (preg_match('/Camino/', $USERAGENT)){
$browser = "Camino";
}
elseif (preg_match('/Safari/', $USERAGENT)){
$browser = "Safari";
}
elseif (preg_match('/Netscape/', $USERAGENT)){
$browser = "Netscape";
}
elseif (preg_match('/Seamonkey/', $USERAGENT)){
$browser = "Seamonkey";
}
elseif (preg_match('/Konqueror/', $USERAGENT)){
$browser = "Konqueror";
}
elseif (preg_match('/IceWeasel/', $USERAGENT)){
$browser = "IceWeasel";
}
else {
$browser = "Unknown Browser";
}
?>

Bash script to get the current cpu usage every 2 minutes
#/bin/bash
dstat -c --nocolor 1 1 >/var/log/cpu
sleep 120 ;sh /bin/cpuusageget.sh

Using this amarok scrip to put the music info up to my server
All that code is for the currently what I would call a beta script. Its also the first PHP app I have wrote so its most likely not perfect. It should display something like this
User Image - Blocked by "Display Image" Settings. Click to show.
(Image May break cause its the one I am working on live.)
Current problems are that after the current song name has a symbol I can not find where its coming from(that VT symbol) Its not from the file it reads. It doesn't appear to be from the way I wrote the code for it to read the file either? I need help with that part I think.
Note this script is incompatible with windows. And probably OSX. Also the cpu usage script needs dstat installed.
PostPosted: Thu Jun 21, 2007 3:54 am


nice little program biggrin how long have you been programing in PHP razz . how much time did this program take you to make ??

GodFly
Crew


root-localhost

PostPosted: Thu Jun 21, 2007 9:13 am


This is my first program. I started programing in PHP on June 8 so not that long at all and this was my first project. Its a relatively simple one I guess. Gonna have to try and make a bigger program next. It would be finished except for that damn bug in the Currently Listening to line.
PostPosted: Thu Jun 21, 2007 11:34 pm


lol you are good at programing than :d do you know any other program language ??? exsept PHP now razz

GodFly
Crew


root-localhost

PostPosted: Fri Jun 22, 2007 11:49 am


I know some html. Tried at VB but didn't like it. PHP is the only "real" language I know right now.
Reply
Programs, Software, and anything else

 
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum
//
//

// //

Have an account? Login Now!

//
//