PDA

View Full Version : how do you include php in your sig?


Hooje
19th May 2003, 21:46
i've seen you guys do it..


and yes i've read the posts and searched.


all is well.


but i cannot find a way to add it to my signature!?

here's the url..

http://www.lovetheweekend.com/shoutbox.php (HERE)

but i cant figure it!

is it using the 'includes' feature or somethin? :igor:

matt2kjones
19th May 2003, 21:51
hmmmm its probably only mods that can do this as php could be used to 'harm' the way the forums work

maybe im wrong tho, or maybe if you post your script to the mods they will allow it

im not sure, but i doubt anyone other than mods can use php in their sigs, but you may want to double check that

Jay
19th May 2003, 21:54
you misunderstand matt2kjones he is talking about an image not php.

Just use image tags to encapsulate the url to your php generated image.

you don't need to be a mod to have this capability.

Hooje
19th May 2003, 21:56
but the thing is..

with the script i've shown..

url -

http://www.lovetheweekend.com/shoutbox.php

(ignore the name of shoutbox lol)

its still a php when you right click on it.

here's the code..


(another user compiled it)






<?php
// This image you can call immediately from an html file in the image tag
// (i.e. <image src="black.php">) easy huh?

Header("Content-type: image/png");

// Fill in your own server information here:
$host = "66.227.96.165";
$port = "8024";
$listenlink = 'http://66.227.96.165:8024/listen.pls'; //make link to stream

$fp = fsockopen("$host", $port, &$errno, &$errstr, 30); //open connection
if(!$fp) {
$success=2; //se-t if no connection
}
if($success!=2){ //if connection
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); //get 7.html
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
fclose($fp); //close connection
$page = ereg_replace(".*<body>", "", $page); //extract data
$page = ereg_replace("</body>.*", ",", $page); //extract data
$numbers = explode(",",$page); //extract data
$currentlisteners=$numbers[0]; //set variable
$connected=$numbers[1]; //set variable

if($connected==1) //if DSP is connected
$wordconnected="yes"; //set variable
else //if no DSP connection
$wordconnected="no"; //set variable
$peaklisteners=$numbers[2]; //set variable
$maxlisteners=$numbers[3]; //set variable
$reportedlisteners=$numbers[4]; //set variable
}

// Image size can be changed here: (x, y)
$im = ImageCreate(200,60);

// Background color in R(ed)G(reen)B(lue) below
$background_color = ImageColorAllocate($im,0,0,0);

// text colors also in RGB
$text_color1 = ImageColorAllocate($im,0,204,255);
$text_color2 = ImageColorAllocate($im,0,204,51);

if($success!=2 && $connected==1){

// song information is splitted in artist - title:
// This requires consistent artist & title format (no ' - ' in title/artist)
// else you can use $numbers[6] as current song info below
$song=explode(" - ",$numbers[6]);

// strings can of course be replaced with your own bla
$string1= "ONLINE! Mixing it up LIVE! CLick to listen";
$string2= $song[0];
$string3= $song[1];
$string4= "[$currentlisteners/$maxlisteners users]";
}
else {
$string1= "No DJ is mixing live at the moment";
$string2= "OFFLINE.";
$string3= "Please return later.";
$string4= ":::";
}

// positioning below
$px = (imagesx($im)-5*strlen($string1))/2;
ImageString($im,1,$px,5,$string1,$text_color1);
// (image,font (from 1 to 5),starting x position, y position,line of text,color)
$px = (imagesx($im)-5*strlen($string2))/2;
ImageString($im,1,$px,20,$string2,$text_color2);
$px = (imagesx($im)-5*strlen($string3))/2;
ImageString($im,1,$px,30,$string3,$text_color2);
$px = (imagesx($im)-5*strlen($string4))/2;
ImageString($im,1,$px,45,$string4,$text_color1);
ImagePng($im);
// In response to KXRM's reaction:
// if you want to cache the picture, you should place this script in
// your internetpage, remove line 5 (Header-call)
// and use ImagePng($im, "filename.png");
// NB: filename.png must have the right permission settings
// (CHMOD 777 does it)
//
// Then you can place filename.png in the same html-file.
ImageDestroy($im);
?>

Jay
19th May 2003, 21:58
but to the forum it's just an image. trust me, put an [IMG] tag around the url and you will see.

Hooje
19th May 2003, 22:00
Originally posted by KXRM
you misunderstand matt2kjones he is talking about an image not php.

Just use image tags to encapsulate the url to your php generated image.

you don't need to be a mod to have this capability.

i've checked the radio toolbox code also..

<?php
include("includes.php");
header("Content-Type: image/png");
$im = imagecreatefrompng("songband1.png");

if ($im)
{
ImageString($im, 1, 17, 4, "Playing: ".$current_song, 2);
ImageString($im, 1, 17, 17, "There are ".$listeners, 2);

ImagePNG($im);
}
?>


i didnt really get it, because i dont see how it connects to your server (as there arent any fields for stream IP/port etc)

thanks for putting up with my arrogance!

Hooje
19th May 2003, 22:01
http://www.lovetheweekend.com/shoutbox.php

Jay
19th May 2003, 22:02
Originally posted by Hooje
i've checked the radio toolbox code also..

<?php
include("includes.php");
header("Content-Type: image/png");
$im = imagecreatefrompng("songband1.png");

if ($im)
{
ImageString($im, 1, 17, 4, "Playing: ".$current_song, 2);
ImageString($im, 1, 17, 17, "There are ".$listeners, 2);

ImagePNG($im);
}
?>


i didnt really get it, because i dont see how it connects to your server (as there arent any fields for stream IP/port etc)

thanks for putting up with my arrogance! hmmm you're not being arrogant, did you mean ignorant?

you are simply making this more complicated then it is. read my post above.

lookie
http://www.lovetheweekend.com/shoutbox.php << magic

Hooje
19th May 2003, 22:04
doh!!!

lol!

I've just tried adding it to my sig in the invisionboard. It doesnt allow it.

Do you know of any sneaky tricks to allow it?

Jay
19th May 2003, 22:06
no if the board doesn't allow graphics then there is a reason for this, contact the developer of the board, or contact the owner of the server it's installed on and ask them why they don't allow images in sigs, there is probably a reason behind it.

Hooje
19th May 2003, 22:29
thanks alot for the help :up: :up:

Psythik
20th May 2003, 01:21
I seem to be having problems also. Here's what I've got:

<?php
// This image you can call immediately from an html file in the image tag
// (i.e. <image src="black.php">) easy huh?

Header("Content-type: image/png");

// Fill in your own server information here:
$host = "68.3.55.67";
$port = "7000";
$listenlink = 'http://68.3.55.67:7000/listen.pls'; //make link to stream

$fp = fsockopen("$host", $port, &$errno, &$errstr, 30); //open connection
if(!$fp) {
$success=2; //se-t if no connection
}
if($success!=2){ //if connection
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); //get 7.html
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
fclose($fp); //close connection
$page = ereg_replace(".*<body>", "", $page); //extract data
$page = ereg_replace("</body>.*", ",", $page); //extract data
$numbers = explode(",",$page); //extract data
$currentlisteners=$numbers[0]; //set variable
$connected=$numbers[1]; //set variable

if($connected==1) //if DSP is connected
$wordconnected="yes"; //set variable
else //if no DSP connection
$wordconnected="no"; //set variable
$peaklisteners=$numbers[2]; //set variable
$maxlisteners=$numbers[3]; //set variable
$reportedlisteners=$numbers[4]; //set variable
}

// Image size can be changed here: (x, y)
$im = ImageCreate(200,60);

// Background color in R(ed)G(reen)B(lue) below
$background_color = ImageColorAllocate($im,0,0,0);

// text colors also in RGB
$text_color1 = ImageColorAllocate($im,0,204,255);
$text_color2 = ImageColorAllocate($im,0,204,51);

if($success!=2 && $connected==1){

// song information is splitted in artist - title:
// This requires consistent artist & title format (no ' - ' in title/artist)
// else you can use $numbers[6] as current song info below
$song=explode(" - ",$numbers[6]);

// strings can of course be replaced with your own bla
$string1= "Now playing on Remix 101";
$string2= $song[0];
$string3= $song[1];
$string4= "[$currentlisteners/$maxlisteners users]";
}
else {
$string1= "Remix 101 is currently";
$string2= "offline.";
$string3= "Try tuning-in around 3pm MST.";
$string4= ":::";
}

// positioning below
$px = (imagesx($im)-5*strlen($string1))/2;
ImageString($im,1,$px,5,$string1,$text_color1);
// (image,font (from 1 to 5),starting x position, y position,line of text,color)
$px = (imagesx($im)-5*strlen($string2))/2;
ImageString($im,1,$px,20,$string2,$text_color2);
$px = (imagesx($im)-5*strlen($string3))/2;
ImageString($im,1,$px,30,$string3,$text_color2);
$px = (imagesx($im)-5*strlen($string4))/2;
ImageString($im,1,$px,45,$string4,$text_color1);
ImagePng($im);
// In response to KXRM's reaction:
// if you want to cache the picture, you should place this script in
// your internetpage, remove line 5 (Header-call)
// and use ImagePng($im, "filename.png");
// NB: filename.png must have the right permission settings
// (CHMOD 777 does it)
//
// Then you can place filename.png in the same html-file.
ImageDestroy($im);
?>

I have it currently saved as a .php file. Am I supposed to change it to a .png? As you can see, I'm new to PHP and have not much of a clue to what I am doing. And yes, my webhost supports PHP, and no, I do not know what CHMOD is or how to do it, so could someone please help me?

drivehell
20th May 2003, 03:04
All you need to change is the config..

Tom
20th May 2003, 03:43
Originally posted by Hooje

Do you know of any sneaky tricks to allow it?

Some boards require it to end with a valid image extension. If this is the case try something like:
http://www.some_server.com/image.php?.jpg

Tom

Psythik
20th May 2003, 23:29
Originally posted by drivehell
All you need to change is the config..

As you can see, I already did. More detailed help please!

Jay
20th May 2003, 23:34
it's dynamic it won't need to be a png file, just call the script in your browser and that url is all you'll need to include in image tags.

Psythik
20th May 2003, 23:48
I have already tried that, but I still get an [x]. Could you double-check what I've done to see where my mistakes are?

Jay
20th May 2003, 23:52
well giving the script a php rather then png extention would be a good start

Psythik
20th May 2003, 23:56
already done.
still having trouble.

Psythik
20th May 2003, 23:59
Stupid webhost. I'll have to check with them to see if I really do have PHP.

Psythik
8th June 2003, 00:05
Ok, I've confirmed that they have PHP due to the fact that I've successfully installed phpBB there, but still no luck with putting in the currently playing PHP sig. What's up with that?

Psythik
8th June 2003, 00:26
Ok now when attempting to run the image, I get
Fatal error: Call to undefined function: imagecreate() in /data/hosted/djscyth/nowplaying.php on line 38

Maybe that is an answer for you guys to help me with?

FesterHead
8th June 2003, 02:18
Ask Google (http://www.google.com) about 'Call to undefined function: imagecreate()'.

Jay
8th June 2003, 09:45
just means your PHP installation is without GD support

Either the webhost removed it from the *nix install or they are using windows. From this point you need to take it up with them and ask them why the hell they don't support image creation in PHP.

Psythik
13th June 2003, 16:39
Ok, now I've switched hosts, but now I get this error

Warning: fsockopen() [function.fsockopen]: php_hostconnect: connect failed in /home/s5299839/public_html/djscythforum/nowplaying.php on line 12

Warning: fsockopen() [function.fsockopen]: unable to connect to 68.3.55.67:7000 in /home/s5299839/public_html/djscythforum/nowplaying.php on line 12


Why Is it so easy for everyone else but me!?

Psythik
13th June 2003, 17:06
BTW, this is what's on line 12:

$fp = fsockopen("$host", $port, &$errno, &$errstr, 30); //open connection

Tom
13th June 2003, 17:58
What is $host and $port set to?

Tom

FesterHead
13th June 2003, 19:56
Both the original (copied from above) and the below work for me.


// Fill in your own server information here:
$host = "68.3.55.67";
$port = "7000";
$fp = fsockopen("$host", $port, &$errno, &$errstr, 30); //open connection
Whack the "'s in "$host"
$fp = fsockopen($host, $port, &$errno, &$errstr, 30); //open connection

Psythik
15th June 2003, 15:13
No luck, same error:

Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/s5299839/public_html/djscyth/radio/nowplaying.php on line 12

Warning: fsockopen() [function.fsockopen]: unable to connect to http://68.3.55.67:7000 in /home/s5299839/public_html/djscyth/radio/nowplaying.php on line 12

Tom
15th June 2003, 17:09
Originally posted by Tom
What is $host and $port set to?

Tom

Psythik
17th June 2003, 02:19
I don't know. How do I find-out?

Psythik
17th June 2003, 02:20
Wait, do you mean this?


// Fill in your own server information here:
$host = "68.3.55.67";
$port = "7000";

Tom
17th June 2003, 03:08
Is your server online when you get this error?

Change:
$fp = fsockopen("$host", $port, &$errno, &$errstr, 30); //open connection

To:
$fp = @fsockopen("$host", $port, &$errno, &$errstr, 5); //open connection

Tom

Psythik
18th June 2003, 02:28
It turns out that the PHP would'nt reconize my station when I broadcasted using port 7000. Also, it had to be online to work. Thanks for the help guys.

Tom
18th June 2003, 04:12
The change I suggested should allow the image to be generated when you're offline since it will suppress the errors associated with fsockopen. It should also decrease the timeout time when trying to connect to a dead server.

Tom

Pixelcraft
18th June 2003, 21:53
ah, lo.

:winamp: