Jump to content


Random Image Block v1.1


  • You cannot reply to this topic
No replies to this topic

#1 SolidSnke

    Newbie

  • Members
  • Pip
  • 5 posts
  • Gender:Male

Posted 09 October 2009 - 07:19 AM

OK so after trying allot of code here for the random image block on my IPB3 board I could not get any to work. So here is what I did, I wrote my own. Now don't be flamin me saying it poor code and its not efficient. I am not a programmer by heart it is something that I just do from now and then. But it works for me. If you have any questions please feel free to email me at me@solidsnke.com or come by the website and post on the forums your questions. Also this is just version one and I know it does not do a few things, like it bypass's whether the gallery is private or public, but I am working on it. So stay tuned.

<?php

  // Random Gallery Image Block by SolidSnke at www.SolidSnke.com - version 1.1 - me@solidsnke.com
  //
  // This will take the pictures from your IP.Gallery mod and create a thumbnail and post it
  // into a block or whatever your using. I use Unreal Portal and IP.CCS
  // Thanks goes to Pascal Naidon for the vignette.php that makes the thumbnail possible.
  //
  // ** Disclaimer ** I suck at coding so if there is a better way, and I am sure there is
  //                  please dont complain to me. I know this works for me, and as my little brain gets 
  //                  bigger maybe I will update this script.
  //
  //  Installing: upload the vignette.php file to where you want, I put mine in the root folder
  //              to make things simple. If you do put it somewhere else then you will need to 
  //              edit the echo like with the correct web address. Do not change what is after the
  //              ?f= part. That is it, if you should have questions please visit my website 
  //              at http://www.solidsnke.com and check out the forums for help or to ask a question.
  //
  //  Update 1.1: I made some changes to the PHP/mySQL coding and it appears to have fixed the imaging problems
  //              I was having where it was not showing all the pictures and galleries, and its a bit faster.
  //
  //  Copyrights: all copyrights are held by there respectful owners, this script is my intellectual property
  //              but anyone is allowed to use and modify it as they see fit, but it cannot be sold without
  //              direct permission from the creator, which is me.
  //
  // dbConnect string (Server, username to db, userpassword to db)
  $con = mysql_connect("localhost","root_username","root_password");
  if (!$con) {
    die('Could not connect: ' . mysql_error());
  }
  // Selecting the database to connect to
  mysql_select_db("database", $con);
  // this is the mySQL string used to pull from gallery_images (table name)
  
  $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM gallery_images ");
  $offset_row = mysql_fetch_object( $offset_result ); 
  $offset = $offset_row->offset;
  $result = mysql_query( " SELECT * FROM gallery_images LIMIT $offset, 1 " );
  
    while ($row = mysql_fetch_array($result)) {
      // this is the string that will display the thumbnail picture into the block, using the vignette.php.
	  echo "<center><img src='http://www.yourwebsite.com/vignette.php?f=ipb/uploads/".$row['directory']."/".$row['masked_file_name']."'></center>";
    }
  
  mysql_close($con);
?>


Well I cannot upload a file here so if you want the vignette.php file you can hop over and pull it off my board at ==> http://solidsnke.com...om-image-block/

Posted Image

Cheers





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users