Author Topic: My signature (Source)  (Read 659 times)

Commando

  • Hydlaa Citizen
  • *
  • Posts: 221
    • View Profile
My signature (Source)
« on: January 13, 2004, 09:48:13 pm »
I just saw that i had 3 unread PMs :D

Well, here\'s the source code to my img.. Requerments:
MySQL (Loggs all IPs :p)
PHP (Duh) with GD support

set_time_limit(60*1);
mysql_connect(\"localhost\", \"user\", \"pass\");
mysql_select_db(\"jpeg_log\");
mysql_query(\"INSERT INTO log (ip,time) VALUES (\'\".$_SERVER[\'REMOTE_ADDR\'].\"\',\'\".date(\"H:i:s Y/m/d\").\"\')\");

$comments=array(\"Don\'t complain, it\'s free!\",\"Great work devs!\",\"Long live PlaneShift!\",\"Greetings!\",\"I would like a beer\",\"Sorry, I know nothing about that\");

$handle = fopen (\"http://planeshift.fragnetics.com/\", \"r\");
if(!$handle){
exit(\"FILE ERROR\");
}

while (!feof ($handle)) {
    $buffer = fgets($handle, 4096);
    $contents=$contents.$buffer;
}
fclose ($handle);

$contents= substr($contents,strpos($contents,\"Server Status :\"));
$contents= substr($contents,0,strpos($contents,\"\"));
$contents=str_replace(\"\",\"\",$contents);
$contents=str_replace(\" \",\"\",$contents);
$contents=str_replace(\"   \",\"\",$contents);
$contents=str_replace(\"\",\"\",$contents);

if(strpos($contents,\"\") > 0 ) {
$status=\"Online\";
}

if(strpos($contents,\"\") > 0 ) {
$status=\"Offline\";  
}


$contents=str_replace(\"

\",\"\",$contents);
$contents=str_replace(\"

\",\"\",$contents);
$contents=str_replace(\"\\n\",\"\",$contents);
$contents=str_replace(\"
\",\"\",$contents);

for($i=5;$i > 0;$i--) {
   
    $clients=(substr($contents,strpos($contents,\"Clients:\")+8,$i));

   if(is_numeric($clients)) {
      break;
  }
   
}
if($i == 0) {
$clients=\"??\";
}

$server= \"PlaneShift Laanx (planeshift.fragnetics.com/203.81.47.74)\";
$world=substr($contents,strpos($contents,\"World:\")+6,strpos($contents,\".Clients\")-(strpos($contents,\"World:\")+6));

  // create the image
  $width=660;
  $height=100;
  $im = imagecreate($width, $height);

  // white background and blue text
  $bg = imagecolorallocate($im, 255, 255, 255);
  $textcolor = imagecolorallocate($im, 255, 255, 255);
  $green = imagecolorallocate($im, 0, 255, 0);
  $red = imagecolorallocate($im, 255, 0, 0);
  $backRec = imagecolorallocate($im, 0, 0, 0);
  $orange=imagecolorallocate($im, 255, 128, 0);
  $blue=imagecolorallocate($im, 0, 0,255);
  $colors=array($red,$green,$blue,$orange);


 
  ImageFilledRectangle($im,0,0,$width,$height,$backRec);
  ImageRectangle($im,0,0,$width-1,$height-1,$red);
 
  // write the string at the top left
  imagestring($im, 5, 5, 2, \"$server server status:\", $textcolor);
 
  if($status==\"Online\") {
  imagestring($im, 5, 5, 20, $status, $green);
  imagestring($im, 5, 5, 35, \"$clients clients is connected\", $textcolor);
  imagestring($im, 5, 5, 50, \"The world is $world\", $textcolor);
  } else {
  imagestring($im, 5, 5, 20, $status, $red);
  }
 
  //And add the ad
  imagestring($im, 5, 5, 65, $comments[rand(0,(count($comments)-1))], $colors[rand(0,(count($colors)-1))]);
  imagestring($im, 5, 510, 80, \"Made by Androgos\", $red);
 
  // output the image
  header(\"Content-type: image/jpg\");
  imagejpeg($im,\"\",80);
 

?>
« Last Edit: January 13, 2004, 09:52:19 pm by Commando »
Commando R-I-P

Commando

  • Hydlaa Citizen
  • *
  • Posts: 221
    • View Profile
(No subject)
« Reply #1 on: January 13, 2004, 09:50:13 pm »
Sorry that i didn\'t comment the code..
Commando R-I-P

acraig

  • Administrator
  • Veteran
  • *
  • Posts: 1562
    • View Profile
(No subject)
« Reply #2 on: January 13, 2004, 10:07:36 pm »
You could probably use the query string ( planeshift.fragnetics.com/query.php ) instead, since that is easier then trying to pick the data out of the main fragnetics site.
----------
Andrew
"For all I know, she's lying, everyone's lying; welcome to the Internet"

Uyaem

  • Hydlaa Notable
  • *
  • Posts: 747
    • View Profile
(No subject)
« Reply #3 on: January 13, 2004, 11:43:19 pm »
could any1 please copy/paste the php connection string here?
It\'s not visible from query.php (being a client of course, opening the page in a web browser)
The internet is "the terrorists'" most important weapon, they say.
Wrong.
Fear is their most important weapon.
Ours is our freedom.

Commando

  • Hydlaa Citizen
  • *
  • Posts: 221
    • View Profile
(No subject)
« Reply #4 on: January 14, 2004, 06:58:04 pm »
Quote
Originally posted by acraig
You could probably use the query string ( planeshift.fragnetics.com/query.php ) instead, since that is easier then trying to pick the data out of the main fragnetics site.


Ahh, thanks acraig.. But it was invented after my sign i think..
Commando R-I-P