forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: JohnM-UK on September 06, 2006, 09:37:24 pm

Title: anycontent - random images
Post by: JohnM-UK on September 06, 2006, 09:37:24 pm
I've inserted 'anycontent at the bottom of my main page, and I'm trying to test a banner rotation.

Quote
'anycontent': inserts php-generated custom content that YOU have coded into the file 'anycontent.php' and displays the content on the index page. It can be used to include banner-rotation scripts, welcome scripts, or similar. Where it appears in the index page is determined by it's placement in the string example below.


I have this code for random images:

Code: [Select]
<?php 
header
("Content-Type: image/jpg"); 
$sigs = array(); 

$sigs[] = "http://www.oneuk.f2s.com/images/rand/test1.jpg"
$sigs[] = "http://www.oneuk.f2s.com/images/rand/test2.jpg"
$sigs[] = "http://www.oneuk.f2s.com/images/rand/test3.jpg"

mt_srand((double)microtime()*1000000); 
$sig $sigs[mt_rand(0count($sigs)-1)]; 

readfile($sig); 

?>

How would I insert this code? Somewhere in anycontent.php?...

Code: [Select]
<?php

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

starttable("100%""Welcome");

?>

<tr><td class="tableb" >
This is for any content block - just a test - Edit the file "anycontent.php" to change what is shown here
</td></tr>
<?php
endtable
();

?>


Title: Re: anycontent - random images
Post by: Nibbler on September 06, 2006, 09:40:24 pm
That code is not designed to be used in this way. It is intended to be called as an image, so call it using an img tag.
Title: Re: anycontent - random images
Post by: JohnM-UK on September 06, 2006, 10:10:38 pm
OK, just one thing I used the original code for the script I got, and it worked:

Code: [Select]
<?php 
header
("Content-Type: image/jpg"); 
$sigs = array(); 

$sigs[] = "http://uberhost.com/siggy.jpg"
$sigs[] = "http://uberhost.com/mysig.gif"
$sigs[] = "http://freehost.net/somegig.png"
$sigs[] = "http://http://img222.exs.cx/img225/3973/milf324f.jpg"

mt_srand((double)microtime()*1000000); 
$sig $sigs[mt_rand(0count($sigs)-1)]; 

readfile($sig); 

?>

But obviously I don't want them ads on my page.

Sorry if I'm asking a daft question here. "so call it using an img tag". How would I do this?

Just trying something else aswell at the mo.
Title: Re: anycontent - random images
Post by: Nibbler on September 06, 2006, 10:21:40 pm
<img src="whateveryoucalledthatscript.php" alt="banner" />
Title: Re: anycontent - random images
Post by: JohnM-UK on September 07, 2006, 12:06:22 am
Well I fixed it with a completely different script someone came up with for me  :)

Code: [Select]
<?php

$banners 
= array(=> 'test1.jpg'=> 'test2.jpg'=> 'test3.jpg');

$random rand(1,3);

$banner "http://www.oneuk.f2s.com/images/rand/" $banners[$random];

echo 
"<p style='text-align: center'><img src='" $banner "' alt='' /></p>";

?>
Title: Re: anycontent - random images
Post by: wfs on October 17, 2006, 08:12:28 am
Hi,

using John's random image script, how do you link the image when it comes up to another page?
pse help - I don't know enough of PHP to amend the script - I tried but nothing works.

thanks.
Title: Re: anycontent - random images
Post by: wfs on October 17, 2006, 08:15:34 am
Hi again,

I got it working after trying again,
just use <a href="http://yoursite.com/yourpage.php"> in front of the image or the image block.

thanks.