Trying to make Random POTD. Trying to make Random POTD.
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Trying to make Random POTD.

Started by MonkeyManx, April 26, 2005, 12:43:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MonkeyManx

Hello, I am trying to create a random Pic of the day script. I started by Modifying the POTD script that Casper wrote. Eventually I am going to try and make it so I can force images to be the pic of the day. Any ways here is what I have so far. My php skills are very rusty.
define('POTD_PHP', true);
define('IN_COPPERMINE', true);

global $prefix, $dbi, $lang_meta_album_names;

starttable("100%", "{$lang_meta_album_names['potd']}");

{
   

$today = date("Ymd");
$result = db_query("SELECT pid, aid, filepath, filename, owner_name, owner_id  from

{$CONFIG['TABLE_PICTURES']} WHERE potd_date='$today'", $dbi);
$picture = mysql_fetch_array($result);
 
  $img = "<img src=\"albums/{$picture['filepath']}thumb_{$picture['filename']}\"  border=\"0\">";
$content .= "<center><tr><td><center><a

href=\"displayimage.php?pos=-{$picture['pid']}\">$img</a><br /><br

/><big>{$lang_meta_album_names['potd']}</big><br><small>by</small><b> <a

href=\"thumbnails.php?album=lastupby&uid={$picture['owner_id']}\">{$picture['owner_name']}</a></b>

<br />
<a href=\"thumbnails.php?album=potdarch\">{$lang_meta_album_names['potdarch']}</a>
</center></td></tr>";
 

 
if (!$result) {
$result = db_query("SELECT * from {$CONFIG['TABLE_PICTURES']}", $dbi);
$num_rows = mysql_num_rows($result);
$result = db_query("UPDATE " . $CONFIG['TABLE_PICTURES'] . ", SET potd_date = '$today', WHERE pid

= '$num_rows'", $dbi);
if (!$result)
{
die('Could not update the POTD');
}
}

}


print $content;

endtable();


It isn't working yet, and I am not sure why. Could someone please look at it to see what I am doing wrong? Thanks.

OmegaGOD

I'm not really sure what you are trying to do. Casper's script needs no modification to work as POTD. See the tread regarding POTD http://forum.coppermine-gallery.net/index.php?topic=14600.0
Please do not PM me with support questions. Please read the manual and then if posting questions please place them in the proper sub-boards.

MonkeyManx

Im trying to modify caspers script so that it checks to see if there is a POTD for today, if there is then it displays it, and if there isnt then it makes a random pic to be the potd.... The thing I dont like about caspers script is that every day you must move the current potd to the archive.