Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

71 users online



Help me with PHP PLZ!!

Help me with PHP PLZ!!

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
eskiehax

eskiehax

Neverside Newbie
Status: Offline!

Help me with PHP PLZ!!

what does it mean by

Quote:


playing.jpg

CODE
<?php
Header ('Content-type: image/jpeg');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
Header('Pragma: no-cache');

// Set the dimensions

$img_width = 468;
$img_height = 50;

// Create the image

$image = imagecreate(468, 50);

// Set the colours

$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
$red = imagecolorallocate($image, 255, 0, 0);
$grey = imagecolorallocate($image, 204, 204, 204);
$green = imagecolorallocate($image, 128, 220, 0);

// set the bg colour and border

imagefilledrectangle($image, 0, 0, $img_width, $img_height, $white);
imageline($image, 0, 0, 0, $img_height, $black); // left border
imageline($image, 0, 0, $img_width, 0, $black); // top border
imageline($image, 0, $img_height - 1, $img_width, $img_height - 1, $black); // bottom border
imageline($image, $img_width - 1, 0, $img_width - 1, $img_height - 1, $black); // right border

// Get song info from the text file

$song_info = file("info.txt");
$main_info = explode(" - ", $song_info[0]);
$artist = trim($main_info[0]);
$title = trim($main_info[1]);
$real_length = $song_info[1];

$for = time() - $song_info[2];
$total = trim($song_info[4]);

$minutes = $for / 60;
$break = explode(".", $minutes);

$current_secs = $for % 60;
$current_mins = $break[0];

$length = $song_info[4];
$totalmins = $current_mins * 60;
$totalsecs = $current_secs + $totalmins;
$percent = $totalsecs / $length * 100;
$percent = round($percent, 0);

$font = '/path/to/uploaded/font.ttf';

if ($for <= $total)
{
ImageTTFText ($image, 8, 0, 10, 17, $black, $font, "/me is listening to ".$artist." - ".$title);

// progress bar

$width = $percent * 3;
$width = round($width, 0);

imagefilledrectangle($image, 11, 22, $width, 40, $red);

imageline($image, 10, 21, 310, 21, $black); // top border
imageline($image, 10, 21, 10, 41, $black); // left border
imageline($image, 10, 41, 310, 41, $black); // bottom border
imageline($image, 310, 21, 310, 41, $black); // right border

if ($current_secs <= 9)
{
$current_secs = "0" . $current_secs;
}

ImageTTFText ($image, 11, 0, $width - 7, 37, $black, $font, $percent . "%");
ImageTTFText ($image, 11, 0, 315, 37, $black, $font, $current_mins .":".$current_secs."/".$real_length);
}
else
{
ImageTTFText ($image, 8, 0, 10, 27, $black, $font, "I am currently not listening to any music");
}

// output and destroy

imagepng($image);
imagedestroy($image);

?>

how do i put that in to a JPG? or am i ment to create a txt file called playing.jpg with that inside it?

___________________

:: Feed The EsK!e Inside ::

eskiehax

eskiehax

Neverside Newbie
Status: Offline!

:confused:

___________________

:: Feed The EsK!e Inside ::

angelessme

angelessme

Neversidian
Status: Offline!

Create a .php file with that inside it, upload it to your webserver, and then try look at it with your browser. Assuming you have GD enabled on your host, you'll see an image

___________________

angelessme, antagonising neverside members, staff and administration since 2001.

eskiehax

eskiehax

Neverside Newbie
Status: Offline!

still dont make sense 2 me ... :confused:

___________________

:: Feed The EsK!e Inside ::

angelessme

angelessme

Neversidian
Status: Offline!

Copy that code to your clipboard.

Paste it into a .txt file.

Rename the .txt file to a .php file.

Upload that file to your webserver.

Look at the file in your browser.

___________________

angelessme, antagonising neverside members, staff and administration since 2001.

eskiehax

eskiehax

Neverside Newbie
Status: Offline!

do i have to upload a font in there aswell?

___________________

:: Feed The EsK!e Inside ::

Last edited by eskiehax, December 6th, 2003 08:01 PM (Edited 1 times)

angelessme

angelessme

Neversidian
Status: Offline!

This script most likely came with instructions. Use them.

You need an info.txt to hold your song details, aswell as a font.ttf for the font that GD wants to use.

___________________

angelessme, antagonising neverside members, staff and administration since 2001.

eskiehax

eskiehax

Neverside Newbie
Status: Offline!

forget it , i cant be bothered 2 go thru all the hassle for a sig that tells u wats playing in winamp :s , thanks any way angelessme

___________________

:: Feed The EsK!e Inside ::

dafrabbit

dafrabbit

Neverside Newbie
Status: Offline!

It really is no hassle, just read the documentation (probably doesn't even take up more than one page). Besides, what are you going to do on a Saturday night anyways?

angelessme

angelessme

Neversidian
Status: Offline!

Go out, get pissed, do naughty things to inebriated women.. the mind boggles at the possibilities .. too bad its sunday morning for me.. Tongue

___________________

angelessme, antagonising neverside members, staff and administration since 2001.

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0086 seconds.