forum.coppermine-gallery.net

Support => Older/other versions => cpg1.1.X Support (standalone) => Topic started by: Pady on October 09, 2003, 11:57:10 pm

Title: Calling random picure on forum home page
Post by: Pady on October 09, 2003, 11:57:10 pm
Does anyone know how I would go about adding random pictures from the gallery onto my vbulletin forum homepage?

I would love to get this kind of integration into the forums so that it becomes more than just a button link.

thanks in advance

Pady
Title: Calling random picure on forum home page
Post by: Joachim Müller on October 10, 2003, 02:12:17 am
take a look at the cpg-thumb mod (ssi.php) - maybe this'll help: http://prdownloads.sourceforge.net/coppermine/ssi.zip?download

GauGau
Title: Calling random picure on forum home page
Post by: jasendorf on October 10, 2003, 03:59:47 am
Here's something simple I did using ADObd for PHP (http://php.weblogs.com/ADOdb).

Code: [Select]

        $connection = &ADONewConnection("mysql");
        $connection->PConnect( 'localhost' , 'EDITdbUSER' , 'EDITpasswordEDIT' , 'EDITCPGdatabaseEDIT' );
   
    $rs=$connection->Execute("SELECT aid, filepath, filename, caption FROM cpg11d_pictures WHERE aid = 2 OR aid = 6"); //edit to include those albums you wish to include
        if (!$last_row) {
                echo $connection->ErrorMsg();
   }
   $total_matches=$rs->RecordCount();
   
        //seed the random number generator
        mt_srand((double)microtime()*1000000);
   
        $rand_max = $total_matches;
        $rand_max--;
   
        //get a random number
        $rand_image = mt_rand(0 , $rand_max);

        //match random number with a URL and assign it a string value
    $rs->Move($rand_image);

        //use results to create a image URL string
        $rand_image_url = "photo_gallery/albums/" . $rs->fields[1] . "normal_" . $rs->fields[2];
   
    $caption = $rs->fields[3];
    $alt_text = $caption;

?>
<p align="center"><a href="photo_gallery" border=0><img src="<?PHP echo $rand_image_url;?>" alt="<?PHP echo $alt_text;?>.
Click here to view more images." border="0"></a><br><b><font size=-2><?PHP echo $alt_text;?></font></b></p>
Title: Calling random picure on forum home page
Post by: Pady on October 10, 2003, 10:15:30 am
thanks guys, I will give it a go when i back this at the end of the weekend