[Comoblog-commit] modules/mod_randomthumb/include mod_randomthumb.inc.php,NONE,1.1
Status: Inactive
Brought to you by:
markwallis
|
From: iamdecal <iam...@us...> - 2005-11-27 19:31:31
|
Update of /cvsroot/comoblog/modules/mod_randomthumb/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5426/mod_randomthumb/include Added Files: mod_randomthumb.inc.php Log Message: initial add, just to make sure ive got the hang of it. mod_randomthumb displays a random thumbmail image and links it to the relevant post. had loads of trouble getting this to commit, so i still need to double check its all here --- NEW FILE: mod_randomthumb.inc.php --- <?php function mod_randomthumb() { if (CFG_USE_PATH_INFO == 'no') $iisbug = '?'; else $iisbug = ''; $query = " select img_id, img_extension, i.post_id , p.post_mail_subject , img_thumb , img_display from ".CFG_MYSQL_TABPREFIX."images i, ".CFG_MYSQL_TABPREFIX."posts p where i.post_id = p.post_id and i.post_id > 0 order by rand() limit 1; "; $res = mysql_query($query); if (!$res || !mysql_num_rows($res)){ return (false); } $items = array(); while ($row = mysql_fetch_assoc($res)) { if ($row['img_thumb'] == 'Y') { $isthumb = '_thumb'; } else { $isthumb = ''; } $row['imageurl'] = "img/posts/" . $row['img_id'] . $isthumb . "." . $row['img_extension']; $row['postlink'] = CFG_SITE_URL ."post.php".$iisbug."/".$row['post_id']; $row['postalt'] = $row['post_mail_subject']; $row['imagewidth'] = CFG_MOD_RANDOMTHUMB_IMG_WIDTH; $row['mod_randomthumb_title'] = CFG_MOD_RANDOMTHUMB_TITLE; $items[] = $row; } return ($items); } ?> |