HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Random Image Help

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#1186 (In Topic #291)

Fan in action

Random Image Help

I downloaded a "source code" for a random image php script and I can't seem to get it to work. I'm pretty sure im not specifying the right spot. But I don't know what the setting should be :(

For example: $folder = '/user/me/example.com/images/';

When I get in WS FTP Pro, It only shows me /public_html/ and it's parent directory, / ……..

Would like to submit one "banner" to a website instead of a dozen  :lol:  ;)

I don't suppose there's a simpler way to display random banners easily?

I've attached the downloaded script source.

ocProducts :wub: :wub:

Click here to drop by my website!
Back to the top
 
Posted
Rating:
#1187
Avatar

The default '.' would work fine. You didn't say if it gave any error messages.

If you look at the ocportal info.php it will tell you the ocportal file path, you can use that as a point of comparison to work out what that scripts file path would be. But its not necessary.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#1192

Fan in action

Ok. I've made $folder be exactly (with an ending slash) like the info.php says. Now it gives me this odd error and some weird characters…

I've also dumped the animated .gif banners in the /public_html/ folder  :blink:

Originally posted by Error+–></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Error)</td></tr><tr><td id='QUOTE'>Warning: Cannot modify header information - headers already sent by (output started at /home/defender/public_html/mrdefbanner.php:11) in /home/defender/public_html/mrdefbanner.php on line 107

What headers?

These characters go down a bit on the page.

Originally posted by Wierd Characters+–></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Wierd Characters)</td></tr><tr><td id='QUOTE'>GIF89a"<€£ ?€žTh6*A>%3j]5š]R?ƒ?b[:yoJ!"P@&½'i6. N,!UN5ŠZK€špD®žb318k]Y"€žTè⦸£p'ro 96"RAAFNM,2POQlf9<@J*#*€{S?¢j"€š~]A7êŠb
€"sI@-'`ljL8&gJ<&&-t^8ääå~'€žif[¡€"\²q\CAFS\]ŠF.RG*6
7FM¢ŽŠ]H4úce?º¥€?'€Ž€šjæCE€8€€™n?uT¬
¯€€oã¼€^¶'+,2àŽp¾¾€"»€ç?"²²µIOVhL
DsaGsUN€}fîš "´€šhhl~€šŽ|Yv>*ªŽg¥|Z€žb>…?zvB"*kba
´v`]VW?¦¤x{}Ž^R4€~š"ýó´†ifL2)tvy,Šf®šf¾ª
€žbR^b2€™bNA>5qfH69Eüå¨!ÿ NETSCAPE2.0!ù ÿ,"<ÿô'RE€A8*\¨a€*wZmpà €" Rhceceâ€F=n|€™ãG(TyòdŸ€"}û,TceH/ I`,Lò2I/@à$g&Š€O?ª"ùp©'$0z=":µá'©N«?JU%
K€"

<!–QuoteBegin-Line 107@
header ($contentType);
<!–QuoteBegin-Line 106
$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];

I only modified $folder so the attached file mentioned above would be a good reference.

ocProducts :wub: :wub:

Click here to drop by my website!
Back to the top
 
Posted
Rating:
#1193
Avatar

If any output is sent from a script, default headers get sent saying its outputting an html page. For this script to work, it has to output image headers then output image data. I can't tell you whats causing the problem because clearly the php file you are using is modified from what you uploaded. Something on or near line 11. Blank lines outside <?php ?> count as output and thus headers will be output for them.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#1194

Fan in action

Well. Was unable to find a simpler script, but not so bad. While searching I remembered I had a downloaded manual for php :lol:

Looked inside and did some searches for 'random'

Code

&#60;?php
&#036;image = mt_rand&#40;1,2&#41;;

if &#40;&#036;image == 1&#41; { echo &#34;&#60;img src=&#39;banners/starwars01.gif&#39; alt=&#39;Are you a Star Wars Movie and/or Game Fan? Drop by Defender&#39;s forum and share your interest with other fans.&#39;&#62;&#34;; }

?&#62;

:)

Obviously need to add more banners, but it works so far. :thumbsup: :)

ocProducts :wub: :wub:

Click here to drop by my website!
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: