shuffle.cgi Utility Script

Introduction

A commonly requested feature was the ability to mix up the gallery database so that galleries from the same sponsor were not all lumped together with each other. When galleries are imported into the database, they are imported in order from the text file or data that you provide. If you do an import that has galleries all from the same sponsor, they will be lumped together in the database with ascending ID numbers. Many of the MySQL algorithms are optimized to pull galleries from the database in the order they were inserted. This shuffling script will randomize your database of galleries to provide a more random selection of galleries.

Before you Shuffle

The shuffle.cgi utility script is currently experimental, and therefore it is highly recommended that you make a backup of your gallery database and preview thumbnails before you run this script. You can backup your gallery database and thumbnails using the software's built in database backup utility.

Running the Shuffle Script

The shuffle.cgi script must be run from the command line of your server, it cannot be accessed through a browser. You will need SSH or telnet access to your server in order to use this script. The first step is to upload the shuffle.cgi script to your server. It should be uploaded in ASCII mode to the same directory as the tgpr.pl file. Once uploaded, set it's permissions to 755.

You can now login to the server through telnet or SSH and change into the directory where the shuffle.cgi script is located. Make sure that no other software functions are running (page rebuilding, gallery scanner, etc). The shuffle script must be executed while no other scripts have an open connection to the database. It is also recommended that you run the shuffle script during a period of low server load, as it can cause a temporary spike in the CPU usage. Execute the following command to begin the shuffling process:

perl shuffle.cgi

On some servers you may need to specify the full path to perl, which might look like this (where /usr/local/bin is the directory where perl is located):

/usr/local/bin/perl shuffle.cgi

When you execute this command, the shuffle script will output some text to let you know that it is running. You should allow several minutes for the shuffle process to be completed, depending on how many galleries you have in the database. When the script is done it will print "The shuffling process has been completed." to the screen. You can now login to the TGP Rotator control panel and use the Display Galleries interface to view the galleries and make sure they are showing up properly.

Starting the Shuffle Script Through Control Panel

The shuffle script can also be started through the control panel by clicking on the Shuffle Gallery Database link in the control panel menu. Running the shuffle script through the control panel is more of a risk because there could be timeout values configured for your webserver which prevent it from running to completion. You should only start the shuffle script through the control panel if you are certain that you are allowed to run background processes on your server and that there are no time, CPU, or memory limits placed on background processes started through your webserver.