Page 1 of 1

Getting image url and highlighting it

Posted: Wed Jan 12, 2005 6:54 pm
by SMR
The title doesnt really explain much and didnt know how to word it correctly.

What I need/want to do is add code to an exsisting php file.
What I need done is to have the the image url in a selection box in bbcode.
Confusing I know.Best way to explain is by looking here
Click on a smilie and at the top,the bbcode is inserted.

I have a banner generator that when you click CREATE,you go to /banner.php and it has the generated image.The image is clickable to get the full path so that it can be hotlinked.
What I would like to do is on banner.php ,add code that will grab the image path and have it as in the link above.
Here is my file banner.php

Code: Select all

<?php

$fontpath = "$DOCUMENT_ROOT/banner3/fonts/";

$titlefont = "$fontpath/$titlef";

$tagfont = "$fontpath/$tagf";





if ((isset($titletext) || $titletext > "")

		and (isset($tagtext) || $tagtext > "")) {

	$titlecolor = substr($titlecolor, -6);

	$r1 = hexdec(substr($titlecolor, 0, 2));

	$g1 = hexdec(substr($titlecolor, 2, 2));

	$b1 = hexdec(substr($titlecolor, 4, 2));

	$tagcolor = substr($tagcolor, -6);

	$r2 = hexdec(substr($tagcolor, 0, 2));

	$g2 = hexdec(substr($tagcolor, 2, 2));

	$b2 = hexdec(substr($tagcolor, 4, 2));

	$titletext2 = stripslashes($titletext);

	$tagtext2 = stripslashes($tagtext);

	$image = imagecreatefrompng("banner/$select_banner");

	$titlecolor = imagecolorallocate($image, $r1, $g1, $b1);

	$tagcolor = imagecolorallocate($image, $r2, $g2, $b2);

	$shadow = imagecolorallocate($image, 153, 153, 153);

	if ($titleshadow == "yes"){

	ImageTTFText($image, $titlesize, 0, $titlex+1, $titley+1, $shadow, $titlefont, $titletext2);

	}

	if ($tagshadow == "yes"){

	ImageTTFText($image, $tagsize, 0, $tagx+1, $tagy+1, $shadow, $tagfont, $tagtext2);

	}

	ImageTTFText($image, $titlesize, 0, $titlex, $titley, $titlecolor, $titlefont, $titletext2);

	ImageTTFText($image, $tagsize, 0, $tagx, $tagy, $tagcolor, $tagfont, $tagtext2);

	$counterval = 0;

	$filename = "banners/counter.txt";

	$fp = fopen($filename, "r");

	$counterval = fread($fp, 26);

	fclose($fp);

	$counterval = (integer)$counterval + 1;

	$fp = fopen($filename, "w+");

	fwrite($fp, $counterval, 26);

	fclose($fp);

	$newbanner = 'banners/' . $counterval . '.png';

	ImagePNG($image, $newbanner);

	include("header.inc");

	echo "\n";

	echo "<a href="$newbanner"><img src="$newbanner" width="468" height="60" alt="Your Generated Banner" border="0"></a>\n";

	echo "<font color="#990000">Click on the image to get the full path.You will use this path to hotlink your image to your BlogCP</font>";

	echo "\n\n";

	include("footer.inc");

}  



?>
Can I add code to have the bbcode of the image so can just be copy/paste as in above link?This way people dont have to click the image to see the full url path,or right click/properties to see full path.
Would like to just have:

Code: Select all

їimg]http://www.host.com/generator/banners/01.pngї/img]
Then peope can just right click/copy
The folder BANNERS is where all the generated images get saved to.

I hope this didnt sound confusing,couldnt think of a way to explain it.

btw........what happened to the tag?

Posted: Wed Jan 12, 2005 7:03 pm
by feyd
why not echo out $newbanner into the page?

Posted: Wed Jan 12, 2005 7:04 pm
by SMR
How do you mean?
Still learning :oops:

Posted: Wed Jan 12, 2005 7:11 pm
by feyd
you have this line in your code:

Code: Select all

echo "<a href="$newbanner"><img src="$newbanner" width="468" height="60" alt="Your Generated Banner" border="0"></a>\n";
If you want to show people the bbcode or whatever they should use to hotlink it, you can just echo out the $newbanner variable, as it would be the link they are going to.

Posted: Wed Jan 12, 2005 7:26 pm
by SMR
I see what your saying.
I'll give it a try as soon as I can find what to use.Need to read on echo a bit and see how to grad this.
Wish I had a whole day to read php man,this gets frustrating :?

Posted: Wed Jan 12, 2005 8:23 pm
by SMR
Only thing I can think of is using ?????

Code: Select all

echo "$newbanner";
But how is that going to grab the url?
Should,or rather,do I need to add something else?

Code: Select all

echo "$newbanner" <url src="$newbanner"</a>;
?

Posted: Wed Jan 12, 2005 8:25 pm
by feyd
$newbanner is the url.

Posted: Thu Jan 13, 2005 12:21 am
by SMR
I figured that out,,,retarded sometimes :roll:

Thing is though,would like to have it produce an input box with the image url already in it,like in the link above.Thats where Im really lost.

But thanks for the help,always appreciate it :wink:

Posted: Thu Jan 13, 2005 12:24 am
by feyd

Code: Select all

echo "<input name="something" value="&#123;$newbanner&#125;" />";

Posted: Thu Jan 13, 2005 12:35 am
by SMR
WOW!
Thats was fast,thank you!
Almost had that.......came up with

Code: Select all

echo "<input name="something" value="&#123;$newbanner&#125;" />";
without { } and "something" was going to be

Code: Select all

echo "<input name="$newbanner" value="&#123;$newbanner&#125;" />";
Thank you for all your help. :D

Posted: Fri Jan 14, 2005 2:41 pm
by SMR
Thanks for the help,I finally got it to work as I wanted.
I ended up with:

Code: Select all

echo "<input name="code" value=http://www.host.net/banner3/&#123;$newbanner&#125; size="42" />\n";
And:

Code: Select all

echo "<input name="bbcode" value=&#1111;img]http://www.host.net/banner3/&#123;$newbanner&#125;&#1111;/img] size="52" />\n";
The results are:

Code: Select all

http://www.host.net/banner3/banners/1.png
&#1111;img]http://www.host.net/banner3/banners/1.png&#1111;/img]
This gave me 2 means of links,one for normal image posting,the other as bbcode for forums.

The only thing left to get is for the 2 link codes to be auto hi-lighted so no need to manually hi-light.
Iv tried a few,but nothing works yet.

Thanks for all the help Feyd :wink:

Posted: Fri Jan 14, 2005 2:47 pm
by feyd
eek.. should really quote the attribute:

Code: Select all

echo "<input name="bbcode" value="&#1111;img]http://www.host.net/banner3/&#123;$newbanner&#125;&#1111;/img]" size="52" />\n";

Posted: Fri Jan 14, 2005 2:54 pm
by SMR
8O
How did I miss that!
It was there,but through all the changing,must have removed it and forgot it.
Thanks for noticing!!

Had to use

Code: Select all

value="&#1111;img]http://www.host.net/banner3/&#123;$newbanner&#125;&#1111;/img]"
Without \ mark before " ,I get an error.

Posted: Fri Jan 14, 2005 10:14 pm
by SMR
Still cant find a way to have the textarea highlighted.Not by clicking a button,but already highlighted,if possible.
Here is the entire code:

Code: Select all

echo "<input name="code" value="http://www.host.net/banner3/&#123;$newbanner&#125;" size="42" />\n";

echo "<font color="#990000">use text url to link image</font>";
Im trying to have the text in the textarea highlighted.
Iv used

Code: Select all

<form name="hilite">
<input type=button value="Highlight" onClick="document.formName.formElement.focus();document.formName.formElement.select();"></form>
Parts anyway,but not getting anything but errors.