 |
|
| Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more. |
|
 |
|

02-04-2004, 09:30 PM
|
 |
Senior Member
Latest Blog: None
|
|
Join Date: 10-09-03
Posts: 4,284
|
|
|
Coding a php Link Button
I am wanting to know what I would need to do to program a php Link button image... something that I can put in footers of phpBB or any php site that will pull an image from the php file. (might even work in html... I don't know)
I know that I once had a rotating image script that you used a php file instead of a gif or jpg and it randomly pulled an image from a directory assigned in the php file.
I want to do something like that, but I guess it would need to be an includes tag in php only, because I want to be able to change the image, the link on it, and the alt text on the image...
I want to include this in phpBB forum skins I work on and be able to update them all by changing one file on my servers.
I guess I kind of answered my own question here... just put in an includes file... and write the html there...
but is there another way that I am missing? maybe something that can work out of a img tag or something else?
just want to make sure I'm not missing something better, before I start something that I want to change later.
thanks for any info.
|

02-05-2004, 03:42 AM
|
|
Contributing Member
|
|
Join Date: 10-12-03
Location: Cranberry Township
Posts: 224
|
|
Juggo, everything that I see that you are trying to do can be done with javascript, unless you need the image to be generated. Anytime that you can do something just as well client side, that is probably the better solution, because you are not running up the server memory.
Of course, it's a little after 6am here, so I might be missing the big piece of the puzzle
|

02-05-2004, 06:59 AM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 10-13-03
Location: UK
Posts: 2,469
|
|
No I think Juggo had the right idea...
He wants many pages on other people's sites to retirieve his latest button graphic, link URL and image ALT text from Juggo's own server.
So a basic php include() should be fine, but, you could lighten the load on your server Juggo, by using an intermediate script...
basically the intermediate script checks how long since it last checked your server, and either goes to grab the (new) images ond code and remembers it for use for 1 month for example, or just uses the code it has already remmebered.
On your clietns page, include(getButton.php)
getButton.php checks the local file button.txt...
(button.txt has 2 lines, 1 is a time stamp, and 2 is the HTML code for the button.)
... getButton.php reads the timestamp, and decides whether it's been a long time since the last update. If YES, it retrieves the new HTML from your server and OVERWRITEs it to button.txt with a new time stamp; if NO it just prints the button HTML from the existing button.txt.
it might all be totally unnecessary, if the code retrieved from your server is not going to be processed (just printed into the page once it gets to your client's servers), and button is small, it probably will have very little impact on your server. Your logs wold even give an idea of how popular your clients' forums are!
|

02-05-2004, 01:11 PM
|
 |
Senior Member
Latest Blog: None
|
|
Join Date: 10-09-03
Posts: 4,284
|
|
that's sound good...
This came about because I have links to juggopop from that say "artist communy" (years old)... and it would be nice to change them without having to actually talk to the owner. As well as a button that I had deleted not realizing that it was still being pulled somewhere... they had like 50% of my 404 errors. so I went and made a new image and put it in the right path... and then I came up with the idea above.
|

02-05-2004, 02:11 PM
|
|
Banned
Latest Blog: None
|
|
Join Date: 01-23-04
Posts: 1,098
|
|
|
wouldnt you need the people who are linking to you to include the php file, or you going to do something like < img src='echo po2.net/image.php ?
|

02-05-2004, 02:51 PM
|
 |
Senior Member
Latest Blog: None
|
|
Join Date: 10-09-03
Posts: 4,284
|
|
|
I was thinking of the php being on their servers, but that file requesting information from mine... (I could be wrong)
|

02-05-2004, 02:54 PM
|
 |
v7n Mentor
|
|
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 2,527
|
|
|
yes thats possible... <?php @include("http://www.juggopop.com/getlink.php"); ?> is what the person would have to put on the site.. and the getlink.php on your site would just tell them the link.. youd have to have the trust of the other guy that you wouldnt change it and pot malicious code in.. like redirects.. popups.. he could do <pre></pre> and then fopen your script and only get 1st line.. if you want that script just tell me. dont feel like typing it out now
|

02-05-2004, 03:28 PM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 10-13-03
Location: UK
Posts: 2,469
|
|
|
[code:1:dc48b68b5e]<?php echo include("http://www.juggopop.com/button.txt"); ?>[/code:1:dc48b68b5e]
*edit* sorry not "echo include()" just "include()" !!!!
|

02-05-2004, 03:31 PM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 10-13-03
Location: UK
Posts: 2,469
|
|
and on your web space u but u're button code in a text file such as the real file here: http://dev.jdenny.co.uk/button.txt
|

02-05-2004, 03:34 PM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 10-13-03
Location: UK
Posts: 2,469
|
|
|
sorry not "echo include()" just include() !!!!
lol witht he echo it put a 1 in there too - the success flag returned from include()
|

02-05-2004, 03:46 PM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 10-13-03
Location: UK
Posts: 2,469
|
|
I'm not sure if the include() fucntion will always work when you pass it a URL, it may depend on your clients' PHP configuration.
But anyway here's a file on my web space so you can try includ()ing an external file with your script...
http://dev.jdenny.co.uk/button.txt
|

02-05-2004, 03:59 PM
|
|
Banned
Latest Blog: None
|
|
Join Date: 01-23-04
Posts: 1,098
|
|
|
You want them to run a php file on there server just for one link to you? I wouldnt do it. Besides, what about people who dont have php on there servers.
|

02-05-2004, 04:15 PM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 10-13-03
Location: UK
Posts: 2,469
|
|
We are talking about the difference between a link, and a link that can be updated in one palce and automatically cascade the update to all other sites.
It's one of the core functions the Web was designed for...
- yeah Sim - let's not bother u must be right and Tim Berners-Lee is a crack-pot !
|

02-05-2004, 04:45 PM
|
 |
v7n Mentor
|
|
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 2,527
|
|
|
you definitely want to use @include.. otherwise if your webserver was down they would get a stupid error.. the @ suppresses the error.
|

02-05-2004, 04:47 PM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 10-13-03
Location: UK
Posts: 2,469
|
|
oooh that's what it is, i rmember now! 
thanks for the tip!
|

02-05-2004, 04:50 PM
|
 |
v7n Mentor
|
|
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 2,527
|
|
no problem.. im not coder of the month for nothing
|

02-05-2004, 04:57 PM
|
 |
Senior Member
Latest Blog: None
|
|
Join Date: 10-09-03
Posts: 4,284
|
|
lol... Wish I knew more about this stuff.
The whole point in this is that if I make a phpBB skin (which would be running on php) I could add that to the overall footer... and if I needed to change the link to my site I could... it's to keep the link updated as needed... otherwise they get a broken link and/or image in their footer. (which some people don't know enough about phpBB to actually remove the broken junk.
so now that you all have posted stuff...
can you explain a little more about the echo, and @ and what I really need to do here?
thanks.
|

02-05-2004, 05:00 PM
|
 |
v7n Mentor
|
|
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 2,527
|
|
|
well.. if you just make it do like
[code:1:c165ad3a1b]<?php @include("http://www.juggopop.com/getinfo.php"); ?[/code:1:c165ad3a1b]
and on your getinfo.php page you just have [code:1:c165ad3a1b]<a href="http://www.juggopop.com/">JuggoPop</a>[/code:1:c165ad3a1b]
then all would be fine.. the @ supresses any error msg (if ur site is down) .. no need for any echo.. unless you wanted to PHP script the getinfo.php page..
|

02-05-2004, 05:38 PM
|
|
Contributing Member
|
|
Join Date: 10-12-03
Location: Cranberry Township
Posts: 224
|
|
|
@include will work, but it will only surpress the error after the timeout, which could be a problem depending if your server goes down. You will definately want to test the socket first, IMO and die a little more gracifully if it is not there. I still would caution you on this, as this should be a client side function, IMO, unless I am missing the fact that you are generating the image on the fly.
|

02-05-2004, 06:23 PM
|
 |
v7n Mentor
|
|
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 2,527
|
|
|
oh yeah.. i think a public mysql server would be best.. where it connects to mysql to retrieve the line.. i just came in late and @include is to be used instead of include for offsite scripts/data
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 07:36 PM.
Powered by vBulletin Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP
|
|
|