function cpgUserLastComment($uid) { global $CONFIG, $FORBIDDEN_SET; $result = cpg_db_query("SELECT COUNT(*), MAX(msg_id) FROM {$CONFIG['TABLE_COMMENTS']} AS c INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.pid = c.pid WHERE approval = 'YES' AND author_id = '{$uid}' {$FORBIDDEN_SET}"); list($comment_count, $lastcom_id) = mysql_fetch_row($result); mysql_free_result($result); $lastComArray = array('count' => 0); if ($comment_count) { $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight, msg_author, UNIX_TIMESTAMP(msg_date) as msg_date, msg_body FROM {$CONFIG['TABLE_COMMENTS']} AS c INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.pid = c.pid WHERE msg_id = {$lastcom_id}"; $result = cpg_db_query($sql); if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); $pic_url = get_pic_url($row, 'thumb'); if (!is_image($row['filename'])) { $image_info = cpg_getimagesize(urldecode($pic_url)); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); $lastcom = '<img src="' . $pic_url . '" class="image"' . $image_size['geom'] . ' border="0" alt="" />'; $lastComArray = array('thumb' => $lastcom, 'comment' => $row['msg_body'], 'msg_date' => $row['msg_date'], 'count' => $comment_count); } mysql_free_result($result); } return $lastComArray; }
function html_picture() { global $xoopsModuleConfig, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER, $_COOKIE; global $album, $comment_date_fmt; global $xoopsTpl, $myts; $pid = $CURRENT_PIC_DATA['pid']; if (!isset($USER['liv']) || !is_array($USER['liv'])) { $USER['liv'] = array(); } // Add 1 to hit counter if ($album != "topn" && $album != "lasthits" && !in_array($pid, $USER['liv']) && isset($_COOKIE[$xoopsModuleConfig['cookie_name'] . '_data'])) { add_hit($pid); if (count($USER['liv']) > 4) { array_shift($USER['liv']); } array_push($USER['liv'], $pid); } if ($xoopsModuleConfig['make_intermediate'] && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $xoopsModuleConfig['picture_width']) { $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal'); } else { $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize'); } $image_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $xoopsModuleConfig['picture_width']); $xoopsTpl->assign('pid', $pid); $xoopsTpl->assign('picture_url', $picture_url); $xoopsTpl->assign('image_size', $image_size['geom']); if (is_image($CURRENT_PIC_DATA['filename'])) { $xoopsTpl->assign('file_type', 'image'); if (isset($image_size['reduced'])) { $winsizeX = $CURRENT_PIC_DATA['pwidth'] + 16; $winsizeY = $CURRENT_PIC_DATA['pheight'] + 16; $xoopsTpl->assign('reduced', 1); $xoopsTpl->assign('winsizeX', $winsizeX); $xoopsTpl->assign('winsizeY', $winsizeY); $xoopsTpl->assign('uniqid_rand', uniqid(rand())); $xoopsTpl->assign('lang_view_fs', _MD_DIS_FULL); } else { $xoopsTpl->assign('reduced', 0); } } else { if (is_movie($CURRENT_PIC_DATA['filename'])) { $xoopsTpl->assign('file_type', 'movie'); } } if ($CURRENT_PIC_DATA['title']) { $xoopsTpl->assign('pic_title', $myts->makeTboxData4Show($CURRENT_PIC_DATA['title'])); } else { $xoopsTpl->assign('pic_title', ''); } if ($CURRENT_PIC_DATA['caption']) { $xoopsTpl->assign('pic_caption', $myts->makeTareaData4Show($CURRENT_PIC_DATA['caption'], 0)); } else { $xoopsTpl->assign('pic_caption', ''); } if (USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID || GALLERY_ADMIN_MODE) { $xoopsTpl->assign('lang_confirm_del', _MD_DIS_CONF_DEL); $xoopsTpl->assign('lang_del_pic', _MD_DIS_DEL_PIC); } else { $xoopsTpl->assign('lang_del_pic', ''); } if (!USER_CAN_SEE_FULL) { $xoopsTpl->assign('lang_no_full', 'Full-size images are available only for registered users!'); } else { $xoopsTpl->assign('lang_no_full', ''); } }
/** * list_cat_albums() * * This has been added to list the albums in a category, used for showing first level albums, largely a repetition of code elsewhere * Redone for a cleaner approach * @param integer $cat Category id for which albums are needed */ function list_cat_albums($cat, $catdata) { global $CONFIG, $lang_date, $FORBIDDEN_SET_DATA; global $lang_list_albums; $PAGE = 1; if ($cat == 0) { return ''; } $cat_owner_id = $cat > 10000 ? 10000 - $cat : 10001; $cpg_nopic_data = cpg_get_system_thumb('nopic.jpg', $cat_owner_id); $cpg_privatepic_data = cpg_get_system_thumb('private.jpg', $cat_owner_id); $alb_per_page = $CONFIG['albums_per_page']; //unused code {SaWey} /*$maxTab = $CONFIG['max_tabs']; $album_filter = ''; $pic_filter = ''; if (!empty($FORBIDDEN_SET) && !$cpg_show_private_album) { $album_filter = ' and ' . str_replace('p.', 'a.', $FORBIDDEN_SET); $pic_filter = ' and ' . $FORBIDDEN_SET; }*/ $nbAlb = $catdata['details']['alb_count']; if ($nbAlb == 0) { return; } $totalPages = ceil($nbAlb / $alb_per_page); $alb_list = array(); $approved = ' AND approved=\'YES\''; $forbidden_set_string = count($FORBIDDEN_SET_DATA) > 0 ? ' AND aid NOT IN (' . implode(', ', $FORBIDDEN_SET_DATA) . ')' : ''; $last_pids = array(); $last_pid_data = array(); foreach ($catdata['subalbums'] as $aid => $album) { if ($CONFIG['link_pic_count'] == 1 || $album['pic_count'] == 0) { if (!empty($album['keyword'])) { $keyword = $album['keyword'] ? "AND (keywords like '%" . addslashes($album['keyword']) . "%' {$forbidden_set_string})" : ''; $query = "SELECT count(pid) AS link_pic_count, max(pid) AS link_last_pid, max(ctime) AS link_last_upload " . " FROM {$CONFIG['TABLE_PICTURES']} " . " WHERE ((aid != '{$aid}' {$forbidden_set_string}) {$keyword}) {$approved}"; $result = cpg_db_query($query); $link_stat = $result->fetchAssoc(true); $catdata['subalbums'][$aid]['link_pic_count'] = $link_stat['link_pic_count']; $catdata['subalbums'][$aid]['last_pid'] = !empty($album['last_pid']) && $album['last_pid'] > $link_stat['link_last_pid'] ? $album['last_pid'] : $link_stat['link_last_pid']; if ($CONFIG['link_last_upload'] && $link_stat['link_pic_count'] > 0) { $catdata['subalbums'][$aid]['last_upload'] = $album['last_upload'] > $link_stat['link_last_upload'] ? $album['last_upload'] : $link_stat['link_last_upload']; } } } if ($catdata['subalbums'][$aid]['last_pid']) { $last_pids[] = $catdata['subalbums'][$aid]['last_pid']; } if ($album['thumb'] > 0) { $last_pids[] = $album['thumb']; } } if (count($last_pids)) { $result = cpg_db_query("SELECT pid, filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']} WHERE pid IN (" . implode(',', $last_pids) . ")"); while ($row = $result->fetchAssoc()) { $last_pid_data[$row['pid']] = $row; unset($last_pid_data[$row['pid']]['pid']); } $result->free(); } unset($last_pids); foreach ($catdata['subalbums'] as $aid => $album) { // Inserts a thumbnail if the album contains 1 or more images //unused code {SaWey} //$visibility = $album['visibility']; $keyword = $album['keyword'] ? "OR (keywords like '%" . addslashes($album['keyword']) . "%' {$forbidden_set_string})" : ''; if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) { //test for visibility if ($album['pic_count'] > 0 || !empty($album['link_pic_count'])) { if (!empty($last_pid_data[$album['thumb']]['filename'])) { $picture = $last_pid_data[$album['thumb']]; } elseif ($album['thumb'] < 0) { $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} WHERE ((aid = '{$aid}' {$forbidden_set_string}) {$keyword}) {$approved} " . "ORDER BY RAND() LIMIT 0,1"; $result = cpg_db_query($sql); $picture = $result->fetchAssoc(true); } else { $picture = $last_pid_data[$album['last_pid']]; } $pic_url = get_pic_url($picture, 'thumb'); if (!is_image($picture['filename'])) { $image_info = cpg_getimagesize(urldecode($pic_url)); $picture['pwidth'] = $image_info[0]; $picture['pheight'] = $image_info[1]; } //thumb cropping if (array_key_exists('system_icon', $picture) && $picture['system_icon'] == true) { $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size'], true, 'cat_thumb'); } else { $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size'], false, 'cat_thumb'); } $alb_list[$aid]['thumb_pic'] = "<img src=\"" . $pic_url . "\" class=\"image thumbnail\" {$image_size['geom']} border=\"0\" alt=\"{$picture['filename']}\" />"; } else { // Inserts an empty thumbnail if the album contains 0 images // $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']); $alb_list[$aid]['thumb_pic'] = '<img src="' . $cpg_nopic_data['thumb'] . '" ' . $cpg_nopic_data['whole'] . ' class="image thumbnail" border="0" alt="" />'; } } elseif ($CONFIG['show_private']) { // $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']); $alb_list[$aid]['thumb_pic'] = '<img src="' . $cpg_privatepic_data['thumb'] . '" ' . $cpg_privatepic_data['whole'] . ' class="image thumbnail" border="0" alt="" />'; } // Prepare everything if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) { $link_pic_count = !empty($album['link_pic_count']) ? $album['link_pic_count'] : 0; $last_upload_date = $album['pic_count'] || $CONFIG['link_pic_count'] && $link_pic_count > 0 ? localised_date($album['last_upload'], $lang_date['lastup']) : ''; $alb_list[$aid]['aid'] = $aid; $alb_list[$aid]['album_title'] = $album['title']; $alb_list[$aid]['album_desc'] = bb_decode($album['description']); $alb_list[$aid]['pic_count'] = $album['pic_count']; $alb_list[$aid]['last_upl'] = $last_upload_date; $alb_list[$aid]['alb_hits'] = sprintf($lang_list_albums['alb_hits'], $album['alb_hits']); $alb_list[$aid]['album_info'] = theme_album_info($album['pic_count'], $link_pic_count, $last_upload_date); $alb_list[$aid]['album_adm_menu'] = album_adm_menu($aid, $cat, $album['owner']); } elseif ($CONFIG['show_private']) { // show private album description $link_pic_count = !empty($album['link_pic_count']) ? $album['link_pic_count'] : 0; $last_upload_date = $album['pic_count'] || $CONFIG['link_pic_count'] && $link_pic_count > 0 ? localised_date($album['last_upload'], $lang_date['lastup']) : ''; $alb_list[$aid]['aid'] = $aid; $alb_list[$aid]['album_title'] = $album['title']; $alb_list[$aid]['album_desc'] = bb_decode($album['description']); $alb_list[$aid]['pic_count'] = $album['pic_count']; $alb_list[$aid]['last_upl'] = $last_upload_date; $alb_list[$aid]['alb_hits'] = sprintf($lang_list_albums['alb_hits'], $album['alb_hits']); $alb_list[$aid]['album_info'] = theme_album_info($album['pic_count'], $link_pic_count, $last_upload_date); $alb_list[$aid]['album_adm_menu'] = album_adm_menu($aid, $cat, $album['owner']); } } ob_start(); theme_display_album_list_cat($alb_list, $nbAlb, $cat, $PAGE, $totalPages); $cat_albums = ob_get_contents(); ob_end_clean(); return $cat_albums; }
function theme_html_picture() { global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER; global $album, $comment_date_fmt, $template_display_media; global $lang_display_image_php, $lang_picinfo; $pid = $CURRENT_PIC_DATA['pid']; $pic_title = ''; if (!isset($USER['liv']) || !is_array($USER['liv'])) { $USER['liv'] = array(); } // Add 1 to hit counter if (!USER_IS_ADMIN && !in_array($pid, $USER['liv']) && isset($_COOKIE[$CONFIG['cookie_name'] . '_data'])) { add_hit($pid); if (count($USER['liv']) > 4) { array_shift($USER['liv']); } array_push($USER['liv'], $pid); } if ($CONFIG['thumb_use'] == 'ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width']) { // The wierd comparision is because only picture_width is stored $condition = true; } elseif ($CONFIG['thumb_use'] == 'wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']) { $condition = true; } elseif ($CONFIG['thumb_use'] == 'any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']) { $condition = true; //thumb cropping } elseif ($CONFIG['thumb_use'] == 'ex' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']) { $condition = true; } else { $condition = false; } if ($CURRENT_PIC_DATA['title'] != '') { $pic_title .= $CURRENT_PIC_DATA['title'] . "\n"; } if ($CURRENT_PIC_DATA['caption'] != '') { $pic_title .= $CURRENT_PIC_DATA['caption'] . "\n"; } if ($CURRENT_PIC_DATA['keywords'] != '') { $pic_title .= $lang_picinfo['Keywords'] . ": " . $CURRENT_PIC_DATA['keywords']; } if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) { template_extract_block($template_display_media, 'img_desc'); } else { if (!$CURRENT_PIC_DATA['title']) { template_extract_block($template_display_media, 'title'); } if (!$CURRENT_PIC_DATA['caption']) { template_extract_block($template_display_media, 'caption'); } } $CURRENT_PIC_DATA['menu'] = html_picture_menu(); //((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || ($CONFIG['users_can_edit_pics'] && $CURRENT_PIC_DATA['owner_id'] == USER_ID && USER_ID != 0) || GALLERY_ADMIN_MODE) ? html_picture_menu($pid) : ''; if ($CONFIG['make_intermediate'] && $condition) { $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal'); } else { $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize'); } //thumb cropping $image_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $CONFIG['picture_width'], 'normal'); $pic_title = ''; $mime_content = cpg_get_type($CURRENT_PIC_DATA['filename']); if ($mime_content['content'] == 'movie' || $mime_content['content'] == 'audio') { if ($CURRENT_PIC_DATA['pwidth'] == 0 || $CURRENT_PIC_DATA['pheight'] == 0) { $CURRENT_PIC_DATA['pwidth'] = 320; // Default width // Set default height; if file is a movie if ($mime_content['content'] == 'movie') { $CURRENT_PIC_DATA['pheight'] = 240; // Default height } } $ctrl_offset['mov'] = 15; $ctrl_offset['wmv'] = 45; $ctrl_offset['swf'] = 0; $ctrl_offset['rm'] = 0; $ctrl_offset_default = 45; $ctrl_height = isset($ctrl_offset[$mime_content['extension']]) ? $ctrl_offset[$mime_content['extension']] : $ctrl_offset_default; $image_size['whole'] = 'width="' . $CURRENT_PIC_DATA['pwidth'] . '" height="' . ($CURRENT_PIC_DATA['pheight'] + $ctrl_height) . '"'; } if ($mime_content['content'] == 'image') { if (isset($image_size['reduced'])) { $imginfo = getimagesize($picture_url); $winsizeX = $CURRENT_PIC_DATA['pwidth'] + $CONFIG['fullsize_padding_x']; //the +'s are the mysterious FF and IE paddings $winsizeY = $CURRENT_PIC_DATA['pheight'] + $CONFIG['fullsize_padding_y']; //the +'s are the mysterious FF and IE paddings if ($CONFIG['transparent_overlay'] == 1) { $pic_html = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td background=\"" . $picture_url . "\" width=\"{$imginfo[0]}\" height=\"{$imginfo[1]}\" class=\"image\">"; $pic_html .= "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid={$pid}&fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width={$winsizeX},height={$winsizeY}')\">"; $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title; $pic_html .= "<img src=\"images/image.gif?id=" . floor(rand() * 1000 + rand()) . "\" width={$imginfo[0]} height={$imginfo[1]} border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />"; $pic_html .= "</a>\n </td></tr></table>"; } else { $pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid={$pid}&fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width={$winsizeX},height={$winsizeY}')\">"; $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title; $pic_html .= "<img src=\"" . $picture_url . "\" class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />"; $pic_html .= "</a>\n"; } } else { if ($CONFIG['transparent_overlay'] == 1) { $pic_html = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td background=\"" . $picture_url . "\" width=\"{$CURRENT_PIC_DATA['pwidth']}\" height=\"{$CURRENT_PIC_DATA['pheight']}\" class=\"image\">"; $pic_html .= "<img src=\"images/image.gif?id=" . floor(rand() * 1000 + rand()) . "\" width={$CURRENT_PIC_DATA['pwidth']} height={$CURRENT_PIC_DATA['pheight']} border=\"0\" alt=\"\" /><br />\n"; $pic_html .= "</td></tr></table>"; } else { $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n"; } } } elseif ($mime_content['content'] == 'document') { $pic_thumb_url = get_pic_url($CURRENT_PIC_DATA, 'thumb'); $pic_html = "<a href=\"{$picture_url}\" target=\"_blank\" class=\"document_link\"><img src=\"" . $pic_thumb_url . "\" border=\"0\" class=\"image\" /></a>\n<br />"; } else { $autostart = $CONFIG['media_autostart'] ? 'true' : 'false'; $players['WMP'] = array('id' => 'MediaPlayer', 'clsid' => 'classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" ', 'codebase' => 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ', 'mime' => 'type="application/x-mplayer2" '); $players['RMP'] = array('id' => 'RealPlayer', 'clsid' => 'classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" ', 'codebase' => '', 'mime' => 'type="audio/x-pn-realaudio-plugin" '); $players['QT'] = array('id' => 'QuickTime', 'clsid' => 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ', 'codebase' => 'codebase="http://www.apple.com/qtactivex/qtplugin.cab" ', 'mime' => 'type="video/x-quicktime" '); $players['SWF'] = array('id' => 'SWFlash', 'clsid' => ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ', 'codebase' => 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ', 'mime' => 'type="application/x-shockwave-flash" '); $players['UNK'] = array('id' => 'DefaultPlayer', 'clsid' => '', 'codebase' => '', 'mime' => ''); if (isset($_COOKIE[$CONFIG['cookie_name'] . '_' . $mime_content['extension'] . 'player'])) { $user_player = $_COOKIE[$CONFIG['cookie_name'] . '_' . $mime_content['extension'] . 'player']; } else { $user_player = $mime_content['player']; } // There isn't a player selected or user wants client-side control if (!$user_player) { $user_player = 'UNK'; } $player = $players[$user_player]; $pic_html = '<object id="' . $player['id'] . '" ' . $player['classid'] . $player['codebase'] . $player['mime'] . $image_size['whole'] . '>'; $pic_html .= "<param name=\"autostart\" value=\"{$autostart}\" /><param name=\"src\" value=\"" . $picture_url . "\" />"; $pic_html .= '<embed ' . $image_size['whole'] . ' src="' . $picture_url . '" autostart="' . $autostart . '" ' . $player['mime'] . '></embed>'; $pic_html .= "</object><br />\n"; } $CURRENT_PIC_DATA['html'] = $pic_html; $CURRENT_PIC_DATA['header'] = ''; $CURRENT_PIC_DATA['footer'] = ''; $CURRENT_PIC_DATA = CPGPluginAPI::filter('file_data', $CURRENT_PIC_DATA); $params = array('{CELL_HEIGHT}' => '100', '{IMAGE}' => $CURRENT_PIC_DATA['header'] . $CURRENT_PIC_DATA['html'] . $CURRENT_PIC_DATA['footer'], '{ADMIN_MENU}' => $CURRENT_PIC_DATA['menu'], '{TITLE}' => bb_decode($CURRENT_PIC_DATA['title']), '{CAPTION}' => bb_decode($CURRENT_PIC_DATA['caption'])); return template_eval($template_display_media, $params); }
/** * picrow() * * return the HTML code for a row to be displayed for an image * the row contains a checkbox, the image name, a thumbnail * * @param $picfile the full path of the file that contains the picture * @param $picid the name of the check box * @return the HTML code */ function picrow($picfile, $picid, $albid) { global $CONFIG, $expic_array; $encoded_picfile = base64_encode($picfile); $picname = $CONFIG['fullpath'] . $picfile; $pic_url = urlencode($picfile); $pic_fname = basename($picfile); $pic_dirname = dirname($picname); $thumb_file = dirname($picname) . '/' . $CONFIG['thumb_pfx'] . $pic_fname; if (file_exists($thumb_file)) { $thumb_info = getimagesize($picname); $thumb_size = compute_img_size($thumb_info[0], $thumb_info[1], 48); $img = '<img src="' . path2url($thumb_file) . '" ' . $thumb_size['geom'] . ' class="thumbnail" border="0" alt="" />'; } elseif (is_image($picname)) { $img = '<img src="showthumb.php?picfile=' . $pic_url . '&size=48" class="thumbnail" border="0" alt="" />'; } else { $file['filepath'] = $pic_dirname . '/'; //substr($picname,0,strrpos($picname,'/')) $file['filename'] = $pic_fname; $filepathname = get_pic_url($file, 'thumb'); //$mime_content = cpg_get_type($picname); //$extension = file_exists("images/thumb_{$mime_content['extension']}.jpg") ? $mime_content['extension']:$mime_content['content']; //$img = '<img src="images/thumb_'.$extension.'.jpg" class="thumbnail" width="48" border="0" alt="" />'; $img = '<img src="' . $filepathname . '" class="thumbnail" width="48" border="0" alt="" />'; } if (filesize($picname) && is_readable($picname)) { //$fullimagesize = getimagesize($picname); COMMENTED OUT FOR VIDEO SUPPORT $winsizeX = $fullimagesize[0] + 16; $winsizeY = $fullimagesize[1] + 16; //$checked = isset($expic_array[$picfile]) || !$fullimagesize ? '' : 'checked'; $checked = isset($expic_array[$picfile]) ? '' : 'checked'; return <<<EOT <tr> <td class="tableb" valign="middle"> <input name="pics[]" id="picselector" type="checkbox" value="{$picid}" {$checked} /> <input name="album_lb_id_{$picid}" type="hidden" value="{$albid}" /> <input name="picfile_{$picid}" type="hidden" value="{$encoded_picfile}" /> </td> <td class="tableb" valign="middle" width="100%"> <a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')">{$pic_fname}</a> </td> <td class="tableb" valign="middle" align="center"> <a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')"><img src="images/spacer.gif" width="1" height="48" border="0" alt="" />{$img}<br /></a> </td> </tr> EOT; } else { $winsizeX = 300; $winsizeY = 300; return <<<EOT <tr> <td class="tableb" valign="middle"> </td> <td class="tableb" valign="middle" width="100%"> <i>{$pic_fname}</i> </td> <td class="tableb" valign="middle" align="center"> <a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')"><img src="showthumb.php?picfile={$pic_url}&size=48" class="thumbnail" border="0" alt="" /><br /></a> </td> </tr> EOT; } }
function display_film_strip($album, $cat, $pos) { global $CONFIG, $AUTHORIZED, $HTTP_GET_VARS; global $album_date_fmt, $lang_display_thumbnails, $lang_errors, $lang_byte_units; $max_item = $CONFIG['max_film_strip_items']; //$thumb_per_page = $pos+$CONFIG['max_film_strip_items']; $thumb_per_page = $max_item * 2; $l_limit = max(0, $pos - $CONFIG['max_film_strip_items']); $new_pos = max(0, $pos - $l_limit); $pic_data = get_pic_data($album, $thumb_count, $album_name, $l_limit, $thumb_per_page); if (count($pic_data) < $max_item) { $max_item = count($pic_data); } $lower_limit = 3; if (!isset($pic_data[$new_pos + 1])) { $lower_limit = $new_pos - $max_item + 1; } else { if (!isset($pic_data[$new_pos + 2])) { $lower_limit = $new_pos - $max_item + 2; } else { if (!isset($pic_data[$new_pos - 1])) { $lower_limit = $new_pos; } else { $hf = $max_item / 2; $ihf = (int) ($max_item / 2); if ($new_pos > $hf) { $lower_limit = $new_pos - $ihf; } elseif ($new_pos < $hf) { $lower_limit = 0; } } } } $pic_data = array_slice($pic_data, $lower_limit, $max_item); $i = $l_limit; if (count($pic_data) > 0) { foreach ($pic_data as $key => $row) { $hi = $pos == $i + $lower_limit ? '1' : ''; $i++; $pic_title = $lang_display_thumbnails['filename'] . $row['filename'] . "\n" . $lang_display_thumbnails['filesize'] . ($row['filesize'] >> 10) . $lang_byte_units[1] . "\n" . $lang_display_thumbnails['dimensions'] . $row['pwidth'] . "x" . $row['pheight'] . "\n" . $lang_display_thumbnails['date_added'] . localised_date($row['ctime'], $album_date_fmt); $pic_url = get_pic_url($row, 'thumb'); if (!is_image($row['filename'])) { $image_info = getimagesize($pic_url); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); $p = $i - 1 + $lower_limit; $p = $p < 0 ? 0 : $p; $thumb_list[$i]['pos'] = $key < 0 ? $key : $p; $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"{$pic_title}\">"; $thumb_list[$i]['caption'] = $row['caption_text']; $thumb_list[$i]['admin_menu'] = ''; } return theme_display_film_strip($thumb_list, $thumb_count, $album_name, $album, $cat, $pos, is_numeric($album)); } else { theme_no_img_to_display($album_name); } }
$pic_caption = $row['caption']; if (!is_image($row['filename'])) { if (!is_flash($row['filename'])) { // The file is neither image nor flash if ($CONFIG['ecard_flash'] != 0) { cpg_die(ERROR, $lang_ecard_php['error_not_image_flash'], __FILE__, __LINE__); } else { cpg_die(ERROR, $lang_ecard_php['error_not_image'], __FILE__, __LINE__); } } elseif ($CONFIG['ecard_flash'] == 0) { // The file IS flash, but flash ecards are not enabled cpg_die(ERROR, $lang_ecard_php['error_not_image'], __FILE__, __LINE__); } } $gallery_url_prefix = $CONFIG['ecards_more_pic_target'] . (substr($CONFIG['ecards_more_pic_target'], -1) == '/' ? '' : '/'); $thumb_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); if (is_flash($row['filename'])) { $markup_picname = get_pic_url($row, 'fullsize'); if (!stristr($markup_picname, 'http:')) { $markup_picname = $gallery_url_prefix . $markup_picname; } $pic_markup = <<<EOT <object id="SWFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" type="application/x-shockwave-flash" width="{$thumb_size['width']}" height="{$thumb_size['height']}"> <param name="autostart" value="true" /> <param name="src" value="{$markup_picname}" /> </object> EOT; } else { if (!stristr($normal_pic_url, 'http:')) { $normal_pic_url = $gallery_url_prefix . $normal_pic_url; }
function list_cat_albums($cat = 0) { global $CONFIG, $USER, $lastup_date_fmt, $HTTP_GET_VARS, $USER_DATA, $FORBIDDEN_SET; global $lang_list_albums, $lang_errors, $cpg_show_private_album; $PAGE = 1; if ($cat == 0) { return ''; } $alb_per_page = $CONFIG['albums_per_page']; $maxTab = $CONFIG['max_tabs']; $album_filter = ''; $pic_filter = ''; if (!empty($FORBIDDEN_SET) && !$cpg_show_private_album) { $album_filter = ' and ' . str_replace('p.', 'a.', $FORBIDDEN_SET); $pic_filter = ' and ' . $FORBIDDEN_SET; } $sql = "SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE category = '{$cat}'" . $album_filter; $result = db_query($sql); $nbEnr = mysql_fetch_array($result); $nbAlb = $nbEnr[0]; mysql_free_result($result); if ($nbAlb == 0) { return; } $totalPages = ceil($nbAlb / $alb_per_page); if ($PAGE > $totalPages) { $PAGE = 1; } $lower_limit = ($PAGE - 1) * $alb_per_page; $upper_limit = min($nbAlb, $PAGE * $alb_per_page); $limit = "LIMIT " . $lower_limit . "," . ($upper_limit - $lower_limit); /* $sql = "SELECT a.aid, a.title, a.description, visibility, filepath, ". "filename, url_prefix, pwidth, pheight ". "FROM {$CONFIG['TABLE_ALBUMS']} as a ". "LEFT JOIN {$CONFIG['TABLE_PICTURES']} as p ON thumb=pid ". "WHERE category = $cat ORDER BY a.pos ".$limit; */ $sql = 'SELECT a.aid, a.title, a.description, visibility, filepath, ' . 'filename, url_prefix, pwidth, pheight ' . 'FROM ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'LEFT JOIN ' . $CONFIG['TABLE_PICTURES'] . ' as p ' . 'ON a.thumb=p.pid ' . 'WHERE category=' . $cat . $album_filter . ' ORDER BY a.pos ' . $limit; $alb_thumbs_q = db_query($sql); $alb_thumbs = db_fetch_rowset($alb_thumbs_q); mysql_free_result($alb_thumbs_q); $disp_album_count = count($alb_thumbs); $album_set = ''; foreach ($alb_thumbs as $value) { $album_set .= $value['aid'] . ', '; } $album_set = '(' . substr($album_set, 0, -2) . ')'; $sql = "SELECT aid, count(pid) as pic_count, max(pid) as last_pid, max(ctime) as last_upload " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE aid IN {$album_set} AND approved = 'YES' " . "GROUP BY aid"; $alb_stats_q = db_query($sql); $alb_stats = db_fetch_rowset($alb_stats_q); mysql_free_result($alb_stats_q); foreach ($alb_stats as $key => $value) { $cross_ref[$value['aid']] =& $alb_stats[$key]; } for ($alb_idx = 0; $alb_idx < $disp_album_count; $alb_idx++) { $alb_thumb =& $alb_thumbs[$alb_idx]; $aid = $alb_thumb['aid']; if (isset($cross_ref[$aid])) { $alb_stat = $cross_ref[$aid]; $count = $alb_stat['pic_count']; } else { $alb_stat = array(); $count = 0; } // Inserts a thumbnail if the album contains 1 or more images $visibility = $alb_thumb['visibility']; if ($visibility == '0' || $visibility == FIRST_USER_CAT + USER_ID || in_array($visibility, $USER_DATA['groups']) || $USER_DATA['can_see_all_albums'] || $CONFIG['allow_private_albums'] == 0) { // test for visibility if ($count > 0) { // Inserts a thumbnail if the album contains 1 or more images if ($alb_thumb['filename']) { $picture =& $alb_thumb; } else { $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='{$alb_stat['last_pid']}'"; $result = db_query($sql); $picture = mysql_fetch_array($result); mysql_free_result($result); } $pic_url = get_pic_url($picture, 'thumb'); if (!is_image($picture['filename'])) { $image_info = getimagesize($pic_url); $picture['pwidth'] = $image_info[0]; $picture['pheight'] = $image_info[1]; } $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$picture['filename']}\">"; } else { // Inserts an empty thumbnail if the album contains 0 images $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"images/nopic.jpg\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />"; } } elseif ($CONFIG['show_private']) { $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"images/private.jpg\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />"; } // Prepare everything if ($visibility == '0' || $visibility == FIRST_USER_CAT + USER_ID || in_array($visibility, $USER_DATA['groups']) || $USER_DATA['can_see_all_albums']) { $last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : ''; $alb_list[$alb_idx]['aid'] = $alb_thumb['aid']; $alb_list[$alb_idx]['album_title'] = $alb_thumb['title']; $alb_list[$alb_idx]['album_desc'] = bb_decode($alb_thumb['description']); $alb_list[$alb_idx]['pic_count'] = $count; $alb_list[$alb_idx]['last_upl'] = $last_upload_date; $alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : ""); $alb_list[$alb_idx]['album_adm_menu'] = GALLERY_ADMIN_MODE || USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT ? html_albummenu($alb_thumb['aid']) : ''; } elseif ($CONFIG['show_private']) { // uncomment this else block to show private album description $last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : ''; $alb_list[$alb_idx]['aid'] = $alb_thumb['aid']; $alb_list[$alb_idx]['album_title'] = $alb_thumb['title']; $alb_list[$alb_idx]['album_desc'] = bb_decode($alb_thumb['description']); $alb_list[$alb_idx]['pic_count'] = $count; $alb_list[$alb_idx]['last_upl'] = $last_upload_date; $alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : ""); $alb_list[$alb_idx]['album_adm_menu'] = GALLERY_ADMIN_MODE || USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT ? html_albummenu($alb_thumb['aid']) : ''; } } ob_start(); theme_display_album_list_cat($alb_list, $nbAlb, $cat, $PAGE, $totalPages); $cat_albums = ob_get_contents(); ob_end_clean(); return $cat_albums; }
function slider_mainpage() { global $CONFIG, $lang_plugin_slider, $FORBIDDEN_SET, $SLIDERSET, $lang_meta_album_names, $META_ALBUM_SET, $CPG_PHP_SELF, $matches; // only insert stuff if we're on album list page require './plugins/slider/include/init.inc.php'; require './plugins/slider/include/load_sliderset.php'; $slider_pages_array = array('index.php'); if (in_array($CPG_PHP_SELF, $slider_pages_array) == TRUE) { if ($matches[1] != 'slider') { return $matches; } $cpgslideplug_align = $SLIDERSET['slider_align']; if ($SLIDERSET['slider_autowidth']) { $cpgslideplug_align = "left"; } echo "<!-- Start Slider PlugIn " . $lang_plugin_slider['version'] . " Table-->\n"; $slider_icon = array('topn' => 'most_viewed', 'lastup' => 'last_uploads', 'toprated' => 'top_rated', 'random' => 'random'); starttable("100%", cpg_fetch_icon($slider_icon[$SLIDERSET['slider_album']], 0, $lang_meta_album_names[$SLIDERSET['slider_album']]) . $lang_meta_album_names[$SLIDERSET['slider_album']]); ?> <tr> <td align="<?php echo $cpgslideplug_align; ?> "> <table border="0" <?php if ($SLIDERSET['slider_autowidth']) { echo "width=\"100%\" "; } ?> id="slidergetwidth" cellspacing="0" cellpadding="0"> <tr> <td align="left"> <?php // maximum pics to show $sliderlimit = $SLIDERSET['slider_numberofpics']; // request of your database $slider_pics = ''; $slider_pics2 = ''; $slider_pics3 = ''; $slider_FORBIDDEN_SET = ""; //if ($FORBIDDEN_SET != "") $slider_FORBIDDEN_SET = $FORBIDDEN_SET; if ($FORBIDDEN_SET != "") { $slider_FORBIDDEN_SET = "{$FORBIDDEN_SET}"; } // request string for meta album toprated if ($SLIDERSET['slider_album'] == "toprated") { $slider_query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE filename like '%.jpg' AND filename not like 'youtube_%' {$slider_FORBIDDEN_SET} AND votes >= '{$CONFIG['min_votes_for_rating']}' {$META_ALBUM_SET} ORDER BY pic_rating DESC, votes DESC, pid DESC LIMIT {$sliderlimit}"; } else { if ($SLIDERSET['slider_album'] == "topn") { $slider_query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE filename like '%.jpg' AND filename not like 'youtube_%' {$slider_FORBIDDEN_SET} AND hits > 0 {$META_ALBUM_SET} ORDER BY hits DESC, filename LIMIT {$sliderlimit}"; } else { if ($SLIDERSET['slider_album'] == "lastup") { $slider_query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE filename like '%.jpg' AND filename not like 'youtube_%' {$slider_FORBIDDEN_SET} {$META_ALBUM_SET} ORDER BY pid DESC LIMIT {$sliderlimit}"; } else { $slider_query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE filename like '%.jpg' AND filename not like 'youtube_%' {$slider_FORBIDDEN_SET} {$META_ALBUM_SET} ORDER BY RAND() LIMIT {$sliderlimit}"; } } } // For reading result $slider_rowset = array(); // Index of tab $i = 0; // max height : will be 75px or 100px $max_height = 0; // For each pic.....building javascript in php if ($SLIDERSET['slider_autowidth']) { $slider_minpics = 15; } else { $slider_minpics = 10; } // result of request $slider_result = cpg_db_query($slider_query); while ($slider_row = mysql_fetch_array($slider_result)) { if (!$SLIDERSET['slider_skipportrait'] || $slider_row['pwidth'] > $slider_row['pheight']) { // reading pid of pic $slider_key = $slider_row['pid']; // reading height of pic $slider_image_size = compute_img_size($slider_row['pwidth'], $slider_row['pheight'], $CONFIG['thumb_width']); // Calcul de la hauteur maxi de la zone déroulante (par défaut = 75px) if ($slider_image_size['height'] > $max_height) { $max_height = $slider_image_size['height']; } // path of pic $slider_file = get_pic_url($slider_row, 'thumb'); $slider_imgfile = get_pic_url($slider_row, $SLIDERSET['slider_pictype']); if ($slider_imgfile == "images/thumbs/thumb_nopic.png") { $slider_imgfile = get_pic_url($slider_row, 'fullsize'); } $slider_pictitle = $slider_row['title']; // link of pic if ($SLIDERSET['slider_useenlarge'] == 1) { $slider_lien = "<img src=\"" . $slider_file . "\" onclick=\"enlarge(this);\" longdesc=\"" . $slider_imgfile . "\" border=\"0\" name=\"" . $slider_row['pid'] . "\" class=\"sliderimg\" alt=\"" . $slider_pictitle . "\" style=\"cursor: pointer;\" />"; $slider_lien2 = "<img src=\"" . $slider_file . "\" onclick=\"enlarge(this);\" longdesc=\"" . $slider_imgfile . "\" border=\"0\" name=\"" . $slider_row['pid'] . "\" class=\"sliderimg\" alt=\"" . $slider_pictitle . "\" style=\"cursor: pointer;\" />"; $slider_lien3 = "<img src=\"" . $slider_file . "\" onclick=\"enlarge(this);\" longdesc=\"" . $slider_imgfile . "\" border=\"0\" name=\"" . $slider_row['pid'] . "\" class=\"sliderimg\" alt=\"" . $slider_pictitle . "\" style=\"cursor: pointer;\" />"; } else { $slider_lien = "<a href=\"displayimage.php?pid={$slider_key}\"><img src=\"" . $slider_file . "\" border=\"0\" onclick=\"copyspeed=0;\" alt=\"" . $slider_pictitle . "\" /></a>"; $slider_lien2 = "<a href=\"displayimage.php?pid={$slider_key}\"><img src=\"" . $slider_file . "\" border=\"0\" onclick=\"copyspeed=0;\" alt=\"" . $slider_pictitle . "\" /></a>"; $slider_lien3 = "<a href=\"displayimage.php?pid={$slider_key}\"><img src=\"" . $slider_file . "\" border=\"0\" onclick=\"copyspeed=0;\" alt=\"" . $slider_pictitle . "\" /></a>"; } // building javascript code $slider_pics .= $slider_lien . " "; $slider_pics2 .= $slider_lien2 . " "; $slider_pics3 .= $slider_lien3 . " "; $i = $i + 1; } } // free memory mysql_free_result($slider_result); if ($i > 0) { while ($i < $slider_minpics) { $i = $i * 2; $slider_pics .= str_replace('id="slider', 'id="slider1', $slider_pics); $slider_pics2 .= str_replace('id="slider', 'id="slider1', $slider_pics2); $slider_pics3 .= str_replace('id="slider', 'id="slider1', $slider_pics3); } } //Max height of pics fixed $cpgslideplug_sliderheight = $max_height . "px"; ?> <span id="slider_temp" style="visibility:visible;position:absolute;top:-100px;white-space:nowrap;left:-9000px;"><?php echo $slider_pics; ?> </span> <div id="slider_autow1" style="position:relative<?php if (!$SLIDERSET['slider_autowidth']) { echo ';width:' . $SLIDERSET['slider_width'] . "px"; } ?> ;height:<?php echo $cpgslideplug_sliderheight; ?> ;overflow:hidden;white-space:nowrap;"> <div id="slider_autow2" style="white-space:nowrap;position:absolute<?php if (!$SLIDERSET['slider_autowidth']) { echo ';width:' . $SLIDERSET['slider_width'] . "px"; } ?> ;height:<?php echo $cpgslideplug_sliderheight; ?> ;<?php if ($SLIDERSET['slider_bgcolor']) { echo "background-color:" . $SLIDERSET['slider_bgcolor'] . ";"; } ?> "> <div id="slider_test2" style="visibility:hidden;position:absolute;left:0px;top:0px;white-space:nowrap;"><?php echo $slider_pics2; ?> </div> <div id="slider_test3" style="visibility:hidden;position:absolute;left:-2000px;top:0px;white-space:nowrap;"><?php echo $slider_pics3; ?> </div> </div> </div> </td> </tr> </table> </td> </tr> <?php endtable(); echo "<!-- End Slider PlugIn Table-->\n"; } }
/** * picrow() * * return the HTML code for a row to be displayed for an image * the row contains a checkbox, the image name, a thumbnail * * @param $picfile the full path of the file that contains the picture * @param $picid the name of the check box * @return the HTML code **/ function picrow($picfile, $picid, $albid) { global $xoopsModuleConfig, $expic_array; $encoded_picfile = base64_encode($picfile); $picname = XOOPS_ROOT_PATH . "/modules/xcgal/" . $xoopsModuleConfig['fullpath'] . $picfile; $pic_url = urlencode($picfile); $picpath = XOOPS_URL . "/modules/xcgal/" . $xoopsModuleConfig['fullpath'] . $picfile; $pic_fname = basename($picfile); $thumb_file = dirname($picname) . '/' . $xoopsModuleConfig['thumb_pfx'] . $pic_fname; if (file_exists($thumb_file)) { $thumb_info = getimagesize($picname); $thumb_size = compute_img_size($thumb_info[0], $thumb_info[1], 48); $img = '<img src="' . $picpath . '" ' . $thumb_size['geom'] . ' class="thumbnail" border="0">'; } else { $img = '<img src="../showthumb.php?picfile=' . $pic_url . '&size=48" class="thumbnail" border="0">'; } if (filesize($picname) && is_readable($picname)) { $fullimagesize = getimagesize($picname); $winsizeX = $fullimagesize[0] + 16; $winsizeY = $fullimagesize[1] + 16; $checked = isset($expic_array[$picfile]) || !$fullimagesize ? '' : 'checked="checked"'; if ($checked == '' && $xoopsModuleConfig['batch_all'] == 0) { /* return <<<EOT <tr> <td class='odd' valign='middle'> <input name='pics[]' type='checkbox' value='$picid' $checked> <input name='album_lb_id_$picid' type='hidden' value="$albid"> <input name="picfile_$picid" type="hidden" value="$encoded_picfile"> </td> <td class="even" valign="middle" width="100%"> <a href="javascript:;" onClick= "MM_openBrWindow('../displayimage.php?&fullsize=1&picfile=$pic_url', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width=$winsizeX, height=$winsizeY')">$pic_fname</a> </td> <td class="odd" valign="middle" align="center"> <a href="javascript:;" onClick= "MM_openBrWindow('../displayimage.php?&fullsize=1&picfile=$pic_url', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width=$winsizeX, height=$winsizeY')">$img<br /></a> </td> </tr> EOT; */ } elseif ($xoopsModuleConfig['batch_all'] == 1) { return <<<EOT <tr> <td class='odd' valign='middle'> <input name='pics[]' type='checkbox' value='{$picid}' {$checked}> <input name='album_lb_id_{$picid}' type='hidden' value="{$albid}"> <input name="picfile_{$picid}" type="hidden" value="{$encoded_picfile}"> </td> <td class="even" valign="middle" width="100%"> <a href="javascript:;" onClick= "MM_openBrWindow('../displayimage.php?&fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')">{$pic_fname}</a> </td> <td class="odd" valign="middle" align="center"> <a href="javascript:;" onClick= "MM_openBrWindow('../displayimage.php?&fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')">{$img}<br /></a> </td> </tr> EOT; } } else { $winsizeX = 300; $winsizeY = 300; return <<<EOT <tr> <td class="odd" valign="middle"> </td> <td class="even" valign="middle" width="100%"> <i>{$pic_fname}</i> </td> <td class="odd" valign="middle" align="center"> <a href="javascript:;" onClick= "MM_openBrWindow('displayimage.php?&fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')"><img src="showthumb.php?picfile={$pic_url}&size=48" class="thumbnail" border="0"><br /></a> </td> </tr> EOT; } }
/** * display_film_strip() * * gets data for thumbnails in an album for the film strip * * @param integer $album * @param integer $cat * @param integer $pos **/ function display_film_strip($album, $cat, $pos, $ajax_call) { // print $pos; global $CONFIG, $AUTHORIZED; global $album_date_fmt, $lang_display_thumbnails, $lang_errors, $lang_byte_units, $lang_common, $pic_count, $ajax_call, $pos; $superCage = Inspekt::makeSuperCage(); $max_item = $CONFIG['max_film_strip_items']; if ($CONFIG['max_film_strip_items'] % 2 == 0) { $max_item = $CONFIG['max_film_strip_items'] + 1; } //print $max_item; $max_item_real = $max_item; /**check the thumb_per_page variable valid to query database*/ if ($pic_count < $max_item_real) { $max_item_real = $pic_count; } //pass the max_items to the dispalyimage.js file set_js_var('max_item', $max_item_real); $max_item_to_set_width = $CONFIG['max_film_strip_items']; //$thumb_per_page = $pos+$CONFIG['max_film_strip_items']; $thumb_per_page = $max_item_real; //assign the varible $l_limit diffen $l_limit = (int) ($max_item_real / 2); $l_limit = max(0, $pos - $l_limit); //set $l_limit to last images if ($l_limit > $pic_count - $max_item_real) { $l_limit = $pic_count - $max_item_real; } $pic_data = get_pic_data($album, $thumb_count, $album_name, $l_limit, $thumb_per_page); if (count($pic_data) < $max_item) { $max_item = count($pic_data); } $lower_limit = 0; if ($ajax_call == 2) { $lower_limit = $max_item_real - 1; $max_item = 1; } if ($ajax_call == 1) { $lower_limit = 0; $max_item = 1; } $pic_data = array_slice($pic_data, $lower_limit, $max_item); $i = $l_limit; //set javascript count variable:: added by Nuwan Sameera Hettiarachchi set_js_var('count', $pic_count); $cat_link = is_numeric($album) ? '' : '&cat=' . $cat; $date_link = $date == '' ? '' : '&date=' . $date; if ($superCage->get->getInt('uid')) { $uid_link = '&uid=' . $superCage->get->getInt('uid'); } else { $uid_link = ''; } if (count($pic_data) > 0) { foreach ($pic_data as $key => $row) { $hi = $pos == $i + $lower_limit ? '1' : ''; $i++; $pic_title = $lang_common['filename'] . '=' . $row['filename'] . "\n" . $lang_common['filesize'] . '=' . ($row['filesize'] >> 10) . $lang_byte_units[1] . "\n" . $lang_display_thumbnails['dimensions'] . $row['pwidth'] . "x" . $row['pheight'] . "\n" . $lang_display_thumbnails['date_added'] . localised_date($row['ctime'], $album_date_fmt); $pic_url = get_pic_url($row, 'thumb'); //print $pic_url; if (!is_image($row['filename'])) { $image_info = cpg_getimagesize(urldecode($pic_url)); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } //thumb cropping if ($row['system_icon'] == 'true') { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width'], true); } else { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); } $p = $i - 1 + $lower_limit; $p = $p < 0 ? 0 : $p; $thumb_list[$i]['pos'] = $key < 0 ? $key : $p; $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"strip_image\" border=\"0\" alt=\"{$row['filename']}\" title=\"{$pic_title}\" />"; $thumb_list[$i]['caption'] = $CONFIG['display_film_strip_filename'] ? '<span class="thumb_filename">' . $row['filename'] . '</span>' : ''; $thumb_list[$i]['admin_menu'] = ''; ######### Added by Abbas ############# $thumb_list[$i]['pid'] = $row['pid']; ###################################### $target = "displayimage.php?album={$album}{$cat_link}{$date_link}&pid={$row['pid']}{$uid_link}"; } // Get the pos for next and prev links in filmstrip navigation $filmstrip_next_pos = $pos + 1; $filmstrip_prev_pos = $pos - 1; // If next pos is greater then total pics then make it pic_count - 1 $filmstrip_next_pos = $filmstrip_next_pos >= $pic_count ? $pic_count - 1 : $filmstrip_next_pos; // If prev pos is less than 0 then make it 0 $filmstrip_prev_pos = $filmstrip_prev_pos < 0 ? 0 : $filmstrip_prev_pos; //Using getRaw(). The date is sanitized in the called function. $date = $superCage->get->keyExists('date') ? cpgValidateDate($superCage->get->getRaw('date')) : null; if ($ajax_call == 2 || $ajax_call == 1) { $a = array('url' => $pic_url, 'target' => $target); $a_jons = json_encode($a); echo $a_jons; } else { // print $thumb_count; return theme_display_film_strip($thumb_list, $thumb_count, $album_name, $album, $cat, $pos, is_numeric($album), 'thumb', $date, $filmstrip_prev_pos, $filmstrip_next_pos, $max_item_to_set_width); } } else { theme_no_img_to_display($album_name); } }
function slider_mainpage($matches) { global $CONFIG, $lang_plugin_slider, $FORBIDDEN_SET, $SLIDERSET, $lang_meta_album_names, $META_ALBUM_SET; if ($matches[1] != 'slider') { return $matches; } $cpgslideplug_sliderwidth = $SLIDERSET['slider_width'] . "px"; $cpgslideplug_sliderheight = $SLIDERSET['slider_height'] . "px"; $cpgslideplug_slidespeed = $SLIDERSET['slider_speed']; $cpgslideplug_slidebgcolor = $SLIDERSET['slider_bgcolor']; $cpgslideplug_align = $SLIDERSET['slider_align']; if ($SLIDERSET['slider_autowidth']) { $cpgslideplug_align = "left"; } echo "<!-- Start Slider PlugIn Table-->\n"; starttable("100%", $lang_meta_album_names[$SLIDERSET['slider_album']]); ?> <tr> <td align="<?php echo $cpgslideplug_align; ?> "> <table border="0" <?php if ($SLIDERSET['slider_autowidth']) { echo "width=\"100%\" "; } ?> id="slidergetwidth" cellspacing="0" cellpadding="0"> <tr> <td align="left"> <script type="text/javascript"> var slideshowgap=2; var copyspeed=<?php echo $cpgslideplug_slidespeed; ?> ; var realcopyspeed=<?php echo $cpgslideplug_slidespeed; ?> ; var cpgslid_brwsx,cpgslid_brwsy,cpgslid_oldbrwsx,cpgslid_oldbrwsy; <?php // maximum pics to show $sliderlimit = $SLIDERSET['slider_numberofpics']; // request of your database $slider_pics = ''; $slider_pics2 = ''; $slider_pics3 = ''; $slider_FORBIDDEN_SET = ""; if ($FORBIDDEN_SET != "") { $slider_FORBIDDEN_SET = "AND {$FORBIDDEN_SET}"; } // request string for meta album toprated if ($SLIDERSET['slider_album'] == "toprated") { $slider_query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE filename like '%.jpg' AND filename not like 'youtube_%' approved = 'YES' {$slider_FORBIDDEN_SET} AND votes >= '{$CONFIG['min_votes_for_rating']}' {$META_ALBUM_SET} ORDER BY pic_rating DESC, votes DESC, pid DESC LIMIT {$sliderlimit}"; } else { if ($SLIDERSET['slider_album'] == "topn") { $slider_query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE filename like '%.jpg' AND filename not like 'youtube_%' AND approved = 'YES' {$slider_FORBIDDEN_SET} AND hits > 0 {$META_ALBUM_SET} ORDER BY hits DESC, filename LIMIT {$sliderlimit}"; } else { if ($SLIDERSET['slider_album'] == "lastup") { $slider_query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE filename like '%.jpg' AND filename not like 'youtube_%' AND approved = 'YES' {$slider_FORBIDDEN_SET} {$META_ALBUM_SET} ORDER BY pid DESC LIMIT {$sliderlimit}"; } else { $slider_query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE filename like '%.jpg' AND filename not like 'youtube_%' AND approved = 'YES' {$slider_FORBIDDEN_SET} {$META_ALBUM_SET} ORDER BY RAND() LIMIT {$sliderlimit}"; } } } // For reading result $slider_rowset = array(); // Index of tab $i = 0; // max height : will be 75px or 100px $max_height = 0; // For each pic.....building javascript in php if ($SLIDERSET['slider_autowidth']) { $slider_minpics = 15; } else { $slider_minpics = 10; } // result of request $slider_result = cpg_db_query($slider_query); while ($slider_row = mysql_fetch_array($slider_result)) { if (!$SLIDERSET['slider_skipportrait'] || $slider_row['pwidth'] > $slider_row['pheight']) { // reading pid of pic $slider_key = $slider_row['pid']; // reading height of pic $slider_image_size = compute_img_size($slider_row['pwidth'], $slider_row['pheight'], $CONFIG['thumb_width']); // Calcul de la hauteur maxi de la zone déroulante (par défaut = 75px) if ($slider_image_size['height'] > $max_height) { $max_height = $slider_image_size['height']; } // path of pic $slider_file = get_pic_url($slider_row, 'thumb'); $slider_imgfile = get_pic_url($slider_row, $SLIDERSET['slider_pictype']); if (!slider_is_file($slider_imgfile)) { $slider_imgfile = get_pic_url($slider_row, 'fullsize'); } $slider_pictitle = $slider_row['title']; // link of pic if ($SLIDERSET['slider_useenlarge'] == 1) { $slider_lien = "<img src=\"" . $slider_file . "\" onclick=\"enlarge(this);\" longdesc=\"" . $slider_imgfile . "\" border=\"0\" name=\"" . $slider_row['pid'] . "\" class=\"sliderimg\" alt=\"" . $slider_pictitle . "\" />"; $slider_lien2 = "<img src=\"" . $slider_file . "\" onclick=\"enlarge(this);\" longdesc=\"" . $slider_imgfile . "\" border=\"0\" name=\"" . $slider_row['pid'] . "\" class=\"sliderimg\" alt=\"" . $slider_pictitle . "\" />"; $slider_lien3 = "<img src=\"" . $slider_file . "\" onclick=\"enlarge(this);\" longdesc=\"" . $slider_imgfile . "\" border=\"0\" name=\"" . $slider_row['pid'] . "\" class=\"sliderimg\" alt=\"" . $slider_pictitle . "\" />"; } else { $slider_lien = "<a href=\"displayimage.php?album=random&cat=0&pos=-{$slider_key}\"><img src=\"" . $slider_file . "\" border=\"0\" alt=\"" . $slider_pictitle . "\" /></a>"; $slider_lien2 = "<a href=\"displayimage.php?album=random&cat=0&pos=-{$slider_key}\"><img src=\"" . $slider_file . "\" border=\"0\" alt=\"" . $slider_pictitle . "\" /></a>"; $slider_lien3 = "<a href=\"displayimage.php?album=random&cat=0&pos=-{$slider_key}\"><img src=\"" . $slider_file . "\" border=\"0\" alt=\"" . $slider_pictitle . "\" /></a>"; } // building javascript code $slider_pics .= $slider_lien . " "; $slider_pics2 .= $slider_lien2 . " "; $slider_pics3 .= $slider_lien3 . " "; $i = $i + 1; } } // free memory mysql_free_result($slider_result); if ($i > 0) { while ($i < $slider_minpics) { $i = $i * 2; $slider_pics .= str_replace('id="slider', 'id="slider1', $slider_pics); $slider_pics2 .= str_replace('id="slider', 'id="slider1', $slider_pics2); $slider_pics3 .= str_replace('id="slider', 'id="slider1', $slider_pics3); } } //Max height of pics fixed $cpgslideplug_sliderheight = $max_height . "px"; ?> var actualwidth=''; var cross_slide; var cross_slide2; var slider_autowidth; <?php if ($SLIDERSET['slider_autowidth']) { echo "var autowidth=1;"; } else { echo "var autowidth=0;"; } ?> slid_addLoad(cpgslideplug_fillup); </script> <span id="slider_temp" style="visibility:visible;position:absolute;top:-100px;white-space:nowrap;left:-9000px;"><?php echo $slider_pics; ?> </span> <div id="slider_autow1" style="position:relative<?php if (!$SLIDERSET['slider_autowidth']) { echo ';width:' . $cpgslideplug_sliderwidth; } ?> ;height:<?php echo $cpgslideplug_sliderheight; ?> ;overflow:hidden;white-space:nowrap;"> <div id="slider_autow2" style="white-space:nowrap;position:absolute<?php if (!$SLIDERSET['slider_autowidth']) { echo ';width:' . $cpgslideplug_sliderwidth; } ?> ;height:<?php echo $cpgslideplug_sliderheight; ?> ;<?php if ($cpgslideplug_slidebgcolor) { echo "background-color:" . $cpgslideplug_slidebgcolor . ";"; } ?> "> <div id="slider_test2" style="visibility:hidden;position:absolute;left:0px;top:0px;white-space:nowrap;"><?php echo $slider_pics2; ?> </div> <div id="slider_test3" style="visibility:hidden;position:absolute;left:-2000px;top:0px;white-space:nowrap;"><?php echo $slider_pics3; ?> </div> </div> </div> </td> </tr> </table> </td> </tr> <?php endtable(); echo "<!-- End Slider PlugIn Table-->\n"; }
function cpgUserLastComment($uid) { global $CONFIG; $result = cpg_db_query("SELECT count(*), MAX(msg_id) FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE c.pid = p.pid AND approval='YES' AND author_id = '{$uid}' {$FORBIDDEN_SET}"); $nbEnr = mysql_fetch_array($result); $comment_count = $nbEnr[0]; $lastcom_id = $nbEnr[1]; mysql_free_result($result); $lastcom = ''; if ($comment_count) { $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight, msg_author, UNIX_TIMESTAMP(msg_date) as msg_date, msg_body, approval " . "FROM {$CONFIG['TABLE_COMMENTS']} AS c, {$CONFIG['TABLE_PICTURES']} AS p " . "WHERE msg_id='" . $lastcom_id . "' AND approval = 'YES' AND c.pid = p.pid"; $result = cpg_db_query($sql); if (mysql_num_rows($result)) { $row = mysql_fetch_array($result); mysql_free_result($result); $pic_url = get_pic_url($row, 'thumb'); if (!is_image($row['filename'])) { $image_info = cpg_getimagesize(urldecode($pic_url)); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); $mime_content = cpg_get_type($row['filename']); $lastcom = '<img src="' . $pic_url . '" class="image"' . $image_size['geom'] . ' border="0" alt="" />'; } } $lastComArray = array(); $lastComArray['thumb'] = $lastcom; $lastComArray['comment'] = $row['msg_body']; $lastComArray['msg_date'] = $row['msg_date']; $lastComArray['count'] = $comment_count; return $lastComArray; }
/** * picrow() * * return the HTML code for a row to be displayed for an image * the row contains a checkbox, the image name, a thumbnail * * @param $picfile the full path of the file that contains the picture * @param $picid the name of the check box * @return the HTML code */ function picrow($picfile, $picid, $albid) { global $db, $CONFIG, $expic_array, $module_name; $encoded_picfile = base64_encode($picfile); $picname = $CONFIG['fullpath'] . $picfile; $pic_url = urlencode($picfile); $pic_fname = basename($picfile); $pic_dname = substr($picname, 0, -strlen($pic_fname)); if ($CONFIG['samename'] == 1) { $sql = "SELECT * FROM " . $CONFIG['TABLE_PICTURES'] . " WHERE filename='" . Fix_Quotes($pic_fname) . "' AND filepath='{$pic_dname}'"; } else { $sql = "SELECT * FROM " . $CONFIG['TABLE_PICTURES'] . " WHERE filename ='" . Fix_Quotes($pic_fname) . "'"; } $result = $db->sql_query($sql); $exists = $db->sql_numrows($result); while ($exists <= 0) { $thumb_file = dirname($picname) . '/' . $CONFIG['thumb_pfx'] . $pic_fname; if (file_exists($thumb_file)) { $thumb_info = getimagesize($picname); $thumb_size = compute_img_size($thumb_info[0], $thumb_info[1], 48); $img = '<img src="' . path2url($picname) . '" ' . $thumb_size['geom'] . ' class="thumbnail" border="0" alt="" />'; } else { $img = '<img src="' . URL::index($module_name . '&file=showthumbbatch&picfile=' . $pic_url . '&size=48', 0) . '" class="thumbnail" border="0" alt="" />'; } $piclink = URL::index("&file=displayimagepopup&fullsize=1&picfile={$pic_url}"); if (filesize($picname) && is_readable($picname)) { $fullimagesize = getimagesize($picname); $winsizeX = $fullimagesize[0] + 16; $winsizeY = $fullimagesize[1] + 16; $checked = isset($expic_array[$picfile]) || !$fullimagesize ? '' : 'checked'; return <<<EOT \t\t<tr> \t\t\t\t<td class="tableb" valign="middle"> \t\t\t\t\t\t<input name="pics[]" type="checkbox" value="{$picid}" {$checked} /> \t\t\t\t\t\t<input name="album_lb_id_{$picid}" type="hidden" value="{$albid}" /> \t\t\t\t\t\t<input name="picfile_{$picid}" type="hidden" value="{$encoded_picfile}" /> \t\t\t\t</td> \t\t\t\t<td class="tableb" valign="middle" width="100%"> \t\t\t\t\t\t<a href="javascript:;" onclick= "MM_openBrWindow('{$piclink}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, scrollbars=yes, width={$winsizeX}, height={$winsizeY}')">{$pic_fname}</a> \t\t\t\t</td> \t\t\t\t<td class="tableb" valign="middle" align="center"> \t\t\t\t\t\t<a href="javascript:;" onclick= "MM_openBrWindow('{$piclink}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, scrollbars=yes, width={$winsizeX}, height={$winsizeY}')">{$img}<br /></a> \t\t\t\t</td> \t\t</tr> EOT; } else { $winsizeX = 300; $winsizeY = 300; return <<<EOT \t\t<tr> \t\t\t\t<td class="tableb" valign="middle"> \t\t\t\t\t\t \t\t\t\t</td> \t\t\t\t<td class="tableb" valign="middle" width="100%"> \t\t\t\t\t\t<i>{$pic_fname}</i> \t\t\t\t</td> \t\t\t\t<td class="tableb" valign="middle" align="center"> \t\t\t\t\t\t<a href="javascript:;" onclick= "MM_openBrWindow('{$piclink}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, scrollbars=yes, width={$winsizeX}, height={$winsizeY}')"><img src="'.URL::index(&file=showthumbbatch&picfile={$pic_url}&size=48).'" class="thumbnail" border="0" alt="" /><br /></a> \t\t\t\t</td> \t\t</tr> EOT; } } }
/** * display_film_strip() * * gets data for thumbnails in an album for the film strip * * @param integer $album * @param integer $cat * @param integer $pos **/ function display_film_strip($album, $cat, $pos) { global $CONFIG, $AUTHORIZED; global $album_date_fmt, $lang_display_thumbnails, $lang_errors, $lang_byte_units, $lang_common; $max_item = $CONFIG['max_film_strip_items']; //$thumb_per_page = $pos+$CONFIG['max_film_strip_items']; $thumb_per_page = $max_item * 2; $l_limit = max(0, $pos - $CONFIG['max_film_strip_items']); $new_pos = max(0, $pos - $l_limit); $pic_data = get_pic_data($album, $thumb_count, $album_name, $l_limit, $thumb_per_page); if (count($pic_data) < $max_item) { $max_item = count($pic_data); } $lower_limit = 3; if (!isset($pic_data[$new_pos + 1])) { $lower_limit = $new_pos - $max_item + 1; } else { if (!isset($pic_data[$new_pos + 2])) { $lower_limit = $new_pos - $max_item + 2; } else { if (!isset($pic_data[$new_pos - 1])) { $lower_limit = $new_pos; } else { $hf = $max_item / 2; $ihf = (int) ($max_item / 2); if ($new_pos > $hf) { $lower_limit = $new_pos - $ihf; } elseif ($new_pos <= $hf) { $lower_limit = 0; } } } } $pic_data = array_slice($pic_data, $lower_limit, $max_item); $i = $l_limit; if (count($pic_data) > 0) { foreach ($pic_data as $key => $row) { $hi = $pos == $i + $lower_limit ? '1' : ''; $i++; $pic_title = $lang_common['filename'] . '=' . $row['filename'] . "\n" . $lang_common['filesize'] . '=' . ($row['filesize'] >> 10) . $lang_byte_units[1] . "\n" . $lang_display_thumbnails['dimensions'] . $row['pwidth'] . "x" . $row['pheight'] . "\n" . $lang_display_thumbnails['date_added'] . localised_date($row['ctime'], $album_date_fmt); $pic_url = get_pic_url($row, 'thumb'); if (!is_image($row['filename'])) { $image_info = getimagesize(urldecode($pic_url)); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } //thumb cropping if ($row['system_icon'] == 'true') { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width'], true); } else { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); } $p = $i - 1 + $lower_limit; $p = $p < 0 ? 0 : $p; $thumb_list[$i]['pos'] = $key < 0 ? $key : $p; $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"{$pic_title}\" />"; $thumb_list[$i]['caption'] = $CONFIG['display_film_strip_filename'] ? '<span class="thumb_filename">' . $row['filename'] . '</span>' : ''; $thumb_list[$i]['admin_menu'] = ''; ######### Added by Abbas ############# $thumb_list[$i]['pid'] = $row['pid']; ###################################### } $date = isset($_GET['date']) ? cpgValidateDate($_GET['date']) : null; return theme_display_film_strip($thumb_list, $thumb_count, $album_name, $album, $cat, $pos, is_numeric($album), 'thumb', $date); } else { theme_no_img_to_display($album_name); } }
function html_picture() { global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER, $HTTP_COOKIE_VARS; global $album, $comment_date_fmt, $template_display_picture; global $lang_display_image_php, $lang_picinfo; $pid = $CURRENT_PIC_DATA['pid']; if (!isset($USER['liv']) || !is_array($USER['liv'])) { $USER['liv'] = array(); } // Add 1 to hit counter // if ($album != "lasthits" && !in_array($pid, $USER['liv']) && isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_data'])) { if ($album != "lasthits" && !in_array($pid, $USER['liv'])) { add_hit($pid); if (count($USER['liv']) > 4) { array_shift($USER['liv']); } array_push($USER['liv'], $pid); } if ($CONFIG['thumb_use'] == 'ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width']) { // The wierd comparision is because only picture_width is stored $condition = true; } elseif ($CONFIG['thumb_use'] == 'wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']) { $condition = true; } elseif ($CONFIG['thumb_use'] == 'any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']) { $condition = true; } else { $condition = false; } if ($CONFIG['make_intermediate'] && $condition) { $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal'); } else { $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize'); } $pic_thumb_url = get_pic_url($CURRENT_PIC_DATA, 'thumb'); $picture_menu = USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID || GALLERY_ADMIN_MODE ? html_picture_menu($pid) : ''; $image_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $CONFIG['picture_width']); $pic_title = ''; $mime_content = get_type($CURRENT_PIC_DATA['filename']); if ($CURRENT_PIC_DATA['title'] != '') { $pic_title .= $CURRENT_PIC_DATA['title'] . "\n"; } if ($CURRENT_PIC_DATA['caption'] != '') { $pic_title .= $CURRENT_PIC_DATA['caption'] . "\n"; } if ($CURRENT_PIC_DATA['keywords'] != '') { $pic_title .= $lang_picinfo['Keywords'] . ": " . $CURRENT_PIC_DATA['keywords']; } if ($CURRENT_PIC_DATA['pwidth'] == 0 || $CURRENT_PIC_DATA['pheight'] == 0) { $image_size['geom'] = ''; $image_size['whole'] = ''; } elseif ($mime_content['content'] == 'movie' || $mime_content['content'] == 'audio') { $ctrl_offset['mov'] = 15; $ctrl_offset['wmv'] = 45; $ctrl_offset['swf'] = 0; $ctrl_offset['rm'] = 0; $ctrl_offset_default = 45; $ctrl_height = isset($ctrl_offset[$mime_content['extension']]) ? $ctrl_offset[$mime_content['extension']] : $ctrl_offset_default; $image_size['whole'] = 'width="' . $CURRENT_PIC_DATA['pwidth'] . '" height="' . ($CURRENT_PIC_DATA['pheight'] + $ctrl_height) . '"'; } if ($mime_content['content'] == 'image') { if (isset($image_size['reduced'])) { $winsizeX = $CURRENT_PIC_DATA['pwidth'] + 16; $winsizeY = $CURRENT_PIC_DATA['pheight'] + 16; $pic_html = "<a href=\"javascript:;\" onClick=\"MM_openBrWindow('displayimage.php?pid={$pid}&fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=yes,status=yes,resizable=yes,width={$winsizeX},height={$winsizeY}')\">"; $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title; $pic_html .= "<img src=\"" . $picture_url . "\" class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />"; $pic_html .= "</a>\n"; } else { $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" /><br />\n"; } } elseif ($mime_content['content'] == 'document') { $pic_html = "<a href=\"{$picture_url}\" target=\"_blank\" class=\"document_link\"><img src=\"" . $pic_thumb_url . "\" border=\"0\" class=\"image\" /></a>\n<br />"; } else { $pic_html = "<object {$image_size['whole']}><param name=\"autostart\" value=\"true\"><param name=\"src\" value=\"" . $picture_url . "\"><embed {$image_size['whole']} src=\"" . $picture_url . "\" autostart=\"true\"></embed></object><br />\n"; } if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) { template_extract_block($template_display_picture, 'img_desc'); } else { if (!$CURRENT_PIC_DATA['title']) { template_extract_block($template_display_picture, 'title'); } if (!$CURRENT_PIC_DATA['caption']) { template_extract_block($template_display_picture, 'caption'); } } $params = array('{CELL_HEIGHT}' => '100', '{IMAGE}' => $pic_html, '{ADMIN_MENU}' => $picture_menu, '{TITLE}' => $CURRENT_PIC_DATA['title'], '{CAPTION}' => bb_decode($CURRENT_PIC_DATA['caption'])); return template_eval($template_display_picture, $params); }
EOT; $i = 100; $lb = ''; $j = 1; if (count($rowset) > 0) { foreach ($rowset as $picture) { $get_photo_name = $picture['title']; $picname = $CONFIG['fullpath'] . $picture['filepath'] . $picture['filename']; $pic_url = urlencode($picture['filename']); $pic_fname = basename($picture['filename']); $pic_dirname = dirname($picname); $thumb_file = dirname($picname) . '/' . $CONFIG['thumb_pfx'] . $pic_fname; $img = ''; if (file_exists($thumb_file)) { $thumb_info = cpg_getimagesize($picname); $thumb_size = compute_img_size($thumb_info[0], $thumb_info[1], 48); $img = '<img src="' . path2url($thumb_file) . '" ' . $thumb_size['geom'] . ' class="thumbnail" border="0" alt="" title="' . $get_photo_name . '" />'; } elseif (is_image($picname)) { $img = '<img src="showthumb.php?picfile=' . $pic_url . '&size=48" class="thumbnail" border="0" alt="" title="' . $get_photo_name . '" />'; } else { $file['filepath'] = $pic_dirname . '/'; $file['filename'] = $pic_fname; $filepathname = get_pic_url($file, 'thumb'); $img = '<img src="' . $filepathname . '" class="thumbnail" width="48" border="0" alt="" title="' . $get_photo_name . '" />'; } $unique_id = uniqid(rand()); $pic_title = $picture['title'] ? "<strong>{$picture['title']}</strong><br />\n" : ''; $lb .= <<<EOT <tr id="sort-{$picture['pid']}"> <td class="dragHandle"></td> <td valign="middle">
/** * display_thumbnails() * * Generates data to display thumbnails of pictures in an album * * @param mixed $album Either the album ID or the meta album name * @param integer $cat Either the category ID or album ID if negative * @param integer $page Page number to display * @param integer $thumbcols * @param integer $thumbrows * @param boolean $display_tabs **/ function fetchcontent_display_thumbnails($album, $cat, $page, $thumbcols, $thumbrows, $display_tabs) { global $CONFIG, $USER, $LINEBREAK; global $lang_date, $lang_display_thumbnails, $lang_byte_units, $lang_common; $superCage = Inspekt::makeSuperCage(); $thumb_per_page = $thumbcols * $thumbrows; $lower_limit = ($page - 1) * $thumb_per_page; $pic_data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page); $total_pages = ceil($thumb_count / $thumb_per_page); $i = 0; if (count($pic_data) > 0) { foreach ($pic_data as $key => $row) { $i++; $pic_title = $lang_common['filename'] . '=' . $row['filename'] . $LINEBREAK . $lang_common['filesize'] . '=' . ($row['filesize'] >> 10) . $lang_byte_units[1] . $LINEBREAK . $lang_display_thumbnails['dimensions'] . $row['pwidth'] . "x" . $row['pheight'] . $LINEBREAK . $lang_display_thumbnails['date_added'] . localised_date($row['ctime'], $lang_date['album']); $pic_url = get_pic_url($row, 'thumb'); if (!is_image($row['filename'])) { $image_info = cpg_getimagesize(urldecode($pic_url)); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } // thumb cropping - if we display a system thumb we calculate the dimension by any and not ex if (array_key_exists('system_icon', $row) && $row['system_icon'] == true) { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width'], true); } else { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); } $thumb_list[$i]['pos'] = $key < 0 ? $key : $i - 1 + $lower_limit; $thumb_list[$i]['pid'] = $row['pid']; // $thumb_list[$i]['image'] = '<img src="' . $pic_url . '" class="image" ' . $image_size['geom'] . ' border="0" alt="' . $row['filename'] . '" title="' . $pic_title . '" />'; // commented out for fetchcontent $thumb_list[$i]['thumbpath'] = $pic_url; // Added for fetchcontent $thumb_list[$i]['thumbsize'] = $image_size['geom']; // Added for fetchcontent $thumb_list[$i]['caption'] = bb_decode($row['caption_text']); $thumb_list[$i]['admin_menu'] = ''; $thumb_list[$i]['aid'] = $row['aid']; $thumb_list[$i]['pwidth'] = $row['pwidth']; $thumb_list[$i]['pheight'] = $row['pheight']; // cpg1.5: new thumb fields below $thumb_list[$i]['title'] = $row['title']; $thumb_list[$i]['description'] = $row['caption']; $thumb_list[$i]['filepath'] = $row['filepath']; $thumb_list[$i]['filename'] = $row['filename']; $thumb_list[$i]['filesize'] = $row['filesize']; $thumb_list[$i]['msg_id'] = isset($row['msg_id']) ? $row['msg_id'] : ''; // needed for get_pic_pos() } // Add a hit to album counter if it is a numeric album if (is_numeric($album)) { // Create an array to hold the album id for hits (if not created) if (!isset($USER['liv_a']) || !is_array($USER['liv_a'])) { $USER['liv_a'] = array(); } // Add 1 to album hit counter if ((!USER_IS_ADMIN && $CONFIG['count_admin_hits'] == 0 || $CONFIG['count_admin_hits'] == 1) && !in_array($album, $USER['liv_a']) && $superCage->cookie->keyExists($CONFIG['cookie_name'] . '_data')) { add_album_hit($album); if (count($USER['liv_a']) > 4) { array_shift($USER['liv_a']); } array_push($USER['liv_a'], $album); user_save_profile(); } } //Using getRaw(). The date is sanitized in the called function. $date = $superCage->get->keyExists('date') ? cpgValidateDate($superCage->get->getRaw('date')) : null; // This is the difference to the original function taken from Coppermine's core: we don't process the data further, but put it into an array and return it $return = array('thumb_list' => $thumb_list, 'thumb_count' => $thumb_count, 'album_name' => $album_name, 'aid' => $album, 'cat' => $cat, 'page' => $page, 'total_pages' => $total_pages, 'sort_options' => is_numeric($album), 'display_tabs' => $display_tabs, 'mode' => 'thumb', 'date' => $date); } elseif (is_numeric($album)) { $return = array('album_name' => $album_name); } return $return; }
} } $user_thumb = ''; if ($picture_count) { $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='" . $thumb_pid . "'"; $result = db_query($sql); if (mysql_num_rows($result)) { $picture = mysql_fetch_array($result); mysql_free_result($result); $pic_url = get_pic_url($picture, 'thumb'); if (!is_image($picture['filename'])) { $image_info = getimagesize($pic_url); $picture['pwidth'] = $image_info[0]; $picture['pheight'] = $image_info[1]; } $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['thumb_width']); $mime_content = get_type($picture['filename']); $user_thumb = '<img src="' . $pic_url . '" class="image"' . $image_size['geom'] . ' border="0" alt="">'; $user_thumb = '<td width="50%" valign="top" align="center">' . '<a href="thumbnails.php?album=lastupby&uid=' . $uid . '">' . $user_thumb . '</a></td>'; } } $quick_jump = $user_thumb . $lastcom ? '<table width="100%" border="0" cellspacing="5"><tr>' . $user_thumb . $lastcom . '</tr></table>' : ''; $form_data = array('username' => $user_data['user_name'], 'reg_date' => localised_date($user_data['user_regdate'], $register_date_fmt), 'group' => $user_data['group_name'], 'location' => $user_data['user_location'], 'interests' => $user_data['user_interests'], 'website' => make_clickable($user_data['user_website']), 'occupation' => $user_data['user_occupation'], 'user_thumb' => $quick_jump); $title = sprintf($lang_register_php['x_s_profile'], $user_data['user_name']); pageheader($title); starttable(-1, $title, 2); make_form($display_profile_form_param, $form_data); endtable(); pagefooter(); ob_end_flush(); break;
function list_cat_albums($cat = 0, $buffer = true) { global $db, $CONFIG, $USER, $PAGE, $USER_DATA, $CPG_M_DIR; if ($cat == 0 && $buffer) { return ''; } $cat = intval($cat); $alb_per_page = $CONFIG['albums_per_page']; $maxTab = $CONFIG['max_tabs']; $visible = ''; if (!USER_IS_ADMIN && !$CONFIG['show_private']) { $visible = "AND " . VIS_GROUPS; // NEW gtroll $tmpvis = explode(',', USER_IN_GROUPS); $vis[0] = 0; foreach ($tmpvis as $dummy => $group) { $vis[$group] = $group; } unset($tmpvis); } /* $result = $db->sql_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = $cat $visible",false,__FILE__,__LINE__); $nbEnr = $db->sql_fetchrow($result); $nbAlb = $nbEnr[0]; $db->sql_freeresult($result); */ //$nbAlb = cpg_tablecount($CONFIG['TABLE_ALBUMS']." WHERE category = $cat $visible", 'count(*)',__FILE__, __LINE__); $nbAlb = 0; foreach (get_albums_data() as $row) { if ($row['category'] != $cat) { continue; } if (isset($vis) && !isset($vis[$row['visibility']])) { continue; } $nbAlb++; } if (!$nbAlb) { return ''; } $totalPages = ceil($nbAlb / $alb_per_page); if (isset($_GET['page'])) { $PAGE = max(intval($_GET['page']), 1); } //if ($PAGE > $totalPages || $cat != $_GET['cat']) $PAGE = 1; if ($PAGE > $totalPages) { $PAGE = 1; } $lower_limit = ($PAGE - 1) * $alb_per_page; $upper_limit = min($nbAlb, $PAGE * $alb_per_page); $sql = "SELECT a.aid, a.title, a.description, visibility, filepath, " . "filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_ALBUMS']} as a " . "LEFT JOIN {$CONFIG['TABLE_PICTURES']} as p ON thumb=pid " . "WHERE category = '{$cat}' {$visible} ORDER BY pos " . "LIMIT " . ($upper_limit - $lower_limit) . " OFFSET " . $lower_limit; $alb_thumbs = $db->sql_ufetchrowset($sql, SQL_BOTH, __FILE__, __LINE__); $disp_album_count = count($alb_thumbs); $album_set = ''; foreach ($alb_thumbs as $value) { $album_set .= $value['aid'] . ', '; } $album_set = '(' . substr($album_set, 0, -2) . ')'; $sql = "SELECT aid, count(pid) as pic_count, max(pid) as last_pid, max(ctime) as last_upload " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE aid IN {$album_set} AND approved = '1' " . "GROUP BY aid"; if ($alb_stats = $db->sql_ufetchrowset($sql, SQL_BOTH)) { foreach ($alb_stats as $key => $value) { $cross_ref[$value['aid']] =& $alb_stats[$key]; } } for ($alb_idx = 0; $alb_idx < $disp_album_count; $alb_idx++) { $alb_thumb =& $alb_thumbs[$alb_idx]; $aid = $alb_thumb['aid']; if (isset($cross_ref[$aid])) { $alb_stat = $cross_ref[$aid]; $count = $alb_stat['pic_count']; } else { $alb_stat = array(); $count = 0; } // Inserts a thumbnail if the album contains 1 or more images $visibility = $alb_thumb['visibility']; if ($visibility == '0' || $visibility == FIRST_USER_CAT + USER_ID || $visibility == $USER_DATA['group_id'] || USER_IS_ADMIN || user_ingroup($visibility, $USER_DATA['user_group_list_cp'])) { if ($count > 0) { // Inserts a thumbnail if the album contains 1 or more images if ($alb_thumb['filename']) { $picture =& $alb_thumb; } else { $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='{$alb_stat['last_pid']}'"; $result = $db->sql_query($sql, false, __FILE__, __LINE__); $picture = $db->sql_fetchrow($result); $db->sql_freeresult($result); } $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . get_pic_url($picture, 'thumb') . "\" {$image_size['geom']} title=\"" . $alb_thumb['title'] . "\" alt=\"" . $alb_thumb['title'] . "\" border=\"0\" class=\"image\" />"; } else { // Inserts an empty thumbnail if the album contains 0 images $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"{$CPG_M_DIR}/images/nopic.jpg\" {$image_size['geom']} alt=\"" . NO_IMG_TO_DISPLAY . "\" title=\"" . NO_IMG_TO_DISPLAY . "\" border=\"0\" class=\"image\" />"; } } elseif ($CONFIG['show_private']) { $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"{$CPG_M_DIR}/images/private.jpg\" {$image_size['geom']} alt=\"" . MEMBERS_ONLY . "\" title=\"" . MEMBERS_ONLY . "\" border=\"0\" class=\"image\" />"; } // Prepare everything $last_upload_date = $count ? localised_date($alb_stat['last_upload'], LASTUP_DATE_FMT) : ''; $alb_list[$alb_idx]['aid'] = $alb_thumb['aid']; $alb_list[$alb_idx]['album_title'] = $alb_thumb['title']; $alb_list[$alb_idx]['album_desc'] = decode_bbcode($alb_thumb['description']); $alb_list[$alb_idx]['pic_count'] = $count; $alb_list[$alb_idx]['last_upl'] = $last_upload_date; $alb_list[$alb_idx]['album_info'] = sprintf(N_PICTURES, $count) . ($count ? sprintf(LAST_ADDED, $last_upload_date) : ""); $alb_list[$alb_idx]['album_adm_menu'] = GALLERY_ADMIN_MODE || USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT ? html_albummenu($alb_thumb['aid']) : ''; } if ($buffer) { ob_start(); theme_display_album_list_cat($alb_list, $nbAlb, $cat, $PAGE, $totalPages); $cat_albums = ob_get_contents(); ob_end_clean(); return $cat_albums; } else { theme_display_album_list($alb_list, $nbAlb, $cat, $PAGE, $totalPages); } }
/** * picrow() * * return the HTML code for a row to be displayed for an image * the row contains a checkbox, the image name, a thumbnail * * @param $picfile the full path of the file that contains the picture * @param $picid the name of the check box * @return the HTML code */ function picrow($picfile, $picid, $albid) { global $CONFIG, $expic_array, $picrowCounter; $encoded_picfile = urlencode(base64_encode($picfile)); $picname = $CONFIG['fullpath'] . $picfile; $pic_url = urlencode($picfile); $pic_fname = basename($picfile); $pic_dirname = dirname($picname); $thumb_file = dirname($picname) . '/' . $CONFIG['thumb_pfx'] . $pic_fname; if ($CONFIG['display_thumbs_batch_add'] == 1) { if (file_exists($thumb_file)) { $thumb_info = cpg_getimagesize($picname); $thumb_size = compute_img_size($thumb_info[0], $thumb_info[1], 48); $img = '<img src="' . path2url($thumb_file) . '" ' . $thumb_size['geom'] . ' class="thumbnail" border="0" alt="" />'; } elseif (is_image($picname)) { $img = '<img src="showthumb.php?picfile=' . $pic_url . '&size=48" class="thumbnail" border="0" alt="" />'; } else { $file['filepath'] = $pic_dirname . '/'; $file['filename'] = $pic_fname; $filepathname = get_pic_url($file, 'thumb'); $img = '<img src="' . $filepathname . '" class="thumbnail" width="48" border="0" alt="" />'; } } else { $img = ''; } if (filesize($picname) && is_readable($picname)) { // for video support, maybe check: http://www.getid3.org/ // for now, hack in something that works (don't check !$fullimagesize) $fullimagesize = cpg_getimagesize($picname); $winsizeX = $fullimagesize[0] + 16; $winsizeY = $fullimagesize[1] + 16; // $checked = isset($expic_array[$picfile]) || !$fullimagesize ? '' : 'checked'; $picfile_replaced_forbidden = dirname($picfile) . '/' . replace_forbidden(basename($picfile)); if ($CONFIG['batch_add_hide_existing_files'] && isset($expic_array[$picfile_replaced_forbidden])) { return; } if ($picrowCounter++ % 2) { $rowStyle = 'tableb'; } else { $rowStyle = 'tableb tableb_alternate'; } $checked = isset($expic_array[$picfile_replaced_forbidden]) || !is_known_filetype($pic_fname) ? '' : 'checked="checked"'; $return = <<<EOT <tr> <td class="{$rowStyle}" valign="middle" width="30"> <input name="pics[]" id="checkbox_p_{$picid}" type="checkbox" value="{$picid}" {$checked} /> <input name="album_lb_id_{$picid}" type="hidden" value="{$albid}" /> <input name="picfile_{$picid}" type="hidden" value="{$encoded_picfile}" /> </td> EOT; // if $fullimagesize is not null, then assume it's an image if ($fullimagesize) { $return .= <<<EOT <td class="{$rowStyle}" valign="middle"> <a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')">{$pic_fname}</a> </td> <td class="{$rowStyle}" valign="middle" align="center"> <a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')"> EOT; } else { // assume it's not an image so hope that browser can display/play it with a helper app $nonpic_url = rawurldecode($pic_url); $return .= <<<EOT <td class="{$rowStyle}" valign="middle"> <a href="javascript:;" onclick= "MM_openBrWindow('{$CONFIG['fullpath']}{$nonpic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')">{$pic_fname}</a> </td> <td class="{$rowStyle}" valign="middle" align="center"> <a href="javascript:;" onclick= "MM_openBrWindow('{$CONFIG['fullpath']}{$nonpic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')"> EOT; } if ($CONFIG['display_thumbs_batch_add'] == 1) { $return .= <<<EOT <img src="images/spacer.gif" width="1" height="48" border="0" alt="" /> EOT; } $return .= <<<EOT {$img}</a><br /> </td> <td class="{$rowStyle}" valign="middle" width="100" height="40"> <p id="p_{$picid}" name="addpic.php?pic_file={$encoded_picfile}"></p> </td> </tr> EOT; return $return; } else { $winsizeX = 300; $winsizeY = 300; $return = <<<EOT <tr> <td class="{$rowStyle}" valign="middle"> </td> <td class="{$rowStyle}" valign="middle"> <i>{$pic_fname}</i> </td> <td class="{$rowStyle}" valign="middle" align="center"> <a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')"> EOT; if ($CONFIG['display_thumbs_batch_add'] == 1) { $return .= <<<EOT <img src="showthumb.php?picfile={$pic_url}&size=48" class="thumbnail" border="0" alt="" /> EOT; } $return .= <<<EOT </a> </td> </tr> EOT; return $return; } }
function display_thumbnails($album, $cat, $page, $thumbcols, $thumbrows, $display_tabs) { global $xoopsModuleConfig, $xoopsTpl; $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object $thumb_per_page = $thumbcols * $thumbrows; $lower_limit = ($page - 1) * $thumb_per_page; $pic_data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page); $total_pages = ceil($thumb_count / $thumb_per_page); $i = 0; if (count($pic_data) > 0) { foreach ($pic_data as $key => $row) { $i++; $image_size = compute_img_size($row['pwidth'], $row['pheight'], $xoopsModuleConfig['thumb_width']); $pic_title = _MD_FUNC_FNAME . $myts->makeTBoxData4Show($row['filename']) . "\n" . _MD_FUNC_FSIZE . ($row['filesize'] >> 10) . _MD_KB . "\n" . _MD_FUNC_DIM . $row['pwidth'] . "x" . $row['pheight'] . "\n" . _MD_FUNC_DATE . formatTimestamp($row['ctime'], 'm'); $thumb_list[$i]['pos'] = $key < 0 ? $key : $i - 1 + $lower_limit; $thumb_list[$i]['image'] = "<img src=\"" . get_pic_url($row, 'thumb') . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"{$pic_title}\" />"; # deleted </a> at end mcleines $thumb_list[$i]['caption'] = $row['caption_text']; $thumb_list[$i]['admin_menu'] = ''; $thumb_list[$i]['pid'] = $row['pid']; } $xoopsTpl->assign('no_img', 0); theme_display_thumbnails($thumb_list, $thumb_count, $album_name, $album, $cat, $page, $total_pages, is_numeric($album), $display_tabs); } else { $xoopsTpl->assign('no_img', 1); $xoopsTpl->assign('lang_no_img', _MD_NO_IMG_TO_DISPLAY); $xoopsTpl->assign('album_name', $myts->makeTBoxData4Show($album_name)); } }
function html_picture() { global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER, $CPG_M_DIR; global $album, $template_display_picture; $pid = $CURRENT_PIC_DATA['pid']; // $ina is where the Registered Only picture is $ina = "{$CPG_M_DIR}/images/ina.jpg"; // Check for anon picture viewing - only for registered user, admin, or if admin allows anon access to full size images if (USER_ID > 1 or $CONFIG['allow_anon_fullsize'] or USER_IS_ADMIN) { // Add 1 to hit counter unless the user reloaded the page if (!isset($USER['liv']) || !is_array($USER['liv'])) { $USER['liv'] = array(); } // Add 1 to hit counter if ($album != "lasthits" && !in_array($pid, $USER['liv']) && isset($_COOKIE[$CONFIG['cookie_name'] . '_data'])) { add_hit($pid); if (count($USER['liv']) > 4) { array_shift($USER['liv']); } //pass by ref depreciated in 4.3.9 array_push($USER['liv'], $pid); $USER['liv'][] = $pid; } if ($CONFIG['make_intermediate'] && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']) { $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal'); } else { $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize'); } $picture_menu = USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID || GALLERY_ADMIN_MODE || $CURRENT_PIC_DATA['owner_id'] == USER_ID ? html_picture_menu($pid) : ''; $image_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $CONFIG['picture_width']); $pic_title = ''; if ($CURRENT_PIC_DATA['title'] != '') { $pic_title .= $CURRENT_PIC_DATA['title'] . "\n"; } if ($CURRENT_PIC_DATA['caption'] != '') { $pic_title .= $CURRENT_PIC_DATA['caption'] . "\n"; } if ($CURRENT_PIC_DATA['keywords'] != '') { $pic_title .= KEYWORDS . ": " . $CURRENT_PIC_DATA['keywords']; } if (isset($image_size['reduced'])) { $CONFIG['justso'] = 0; if ($CONFIG['justso']) { //require_once('jspw.js'); $winsizeX = $CURRENT_PIC_DATA['pwidth'] + 16; $winsizeY = $CURRENT_PIC_DATA['pheight'] + 16; $hug = 'hug image'; $hugwidth = '4'; $bgclr = '#000000'; $alt = CLICK_TO_CLOSE; // $lang_fullsize_popup[1]; $pic_html = '<a href="' . URL::index("&file=justsofullsize&pid={$pid}", false, true) . '" target="' . uniqid(rand()) . "\" onclick=\"JustSoPicWindow('" . URL::index("&file=justsofullsize&pid={$pid}", false, true) . "','{$winsizeX}','{$winsizeY}','{$alt}','{$bgclr}','{$hug}','{$hugwidth}');return false\">"; } else { $winsizeX = $CURRENT_PIC_DATA['pwidth'] + 16; $winsizeY = $CURRENT_PIC_DATA['pheight'] + 16; $pic_html = '<a href="' . URL::index("&file=displayimagepopup&pid={$pid}&fullsize=1", true, true) . '" target="' . uniqid(rand()) . "\" onclick=\"imgpop('" . URL::index("&file=displayimagepopup&pid={$pid}&fullsize=1", true, true) . "','" . uniqid(rand()) . "','resizable=yes,scrollbars=yes,width={$winsizeX},height={$winsizeY},left=0,top=0');return false\">"; //toolbar=yes,status=yes, $pic_title = VIEW_FS . "\n ============== \n" . $pic_title; //added by gaugau } $pic_html .= "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"{$pic_title}\" title=\"{$pic_title}\" /><br />"; $pic_html .= "</a>\n"; } else { $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} alt=\"{$pic_title}\" title=\"{$pic_title}\" class=\"image\" border=\"0\" /><br />\n"; } if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) { template_extract_block($template_display_picture, 'img_desc'); } else { if (!$CURRENT_PIC_DATA['title']) { template_extract_block($template_display_picture, 'title'); } if (!$CURRENT_PIC_DATA['caption']) { template_extract_block($template_display_picture, 'caption'); } } } else { $imagesize = getimagesize($ina); $image_size = compute_img_size($imagesize[0], $imagesize[1], $CONFIG['picture_width']); $pic_html = '<a href="' . NEWUSER_URL . '">'; $pic_html .= "<img src=\"" . $ina . "\" {$image_size['geom']} alt=\"Click to register\" title=\"Click to register\" class=\"image\" border=\"0\" /></a><br />"; $picture_menu = ""; $CURRENT_PIC_DATA['title'] = MEMBERS_ONLY; $CURRENT_PIC_DATA['caption'] = ''; } $params = array('{CELL_HEIGHT}' => '100', '{IMAGE}' => $pic_html, '{ADMIN_MENU}' => $picture_menu, '{TITLE}' => $CURRENT_PIC_DATA['title'], '{CAPTION}' => decode_bbcode($CURRENT_PIC_DATA['caption'])); return template_eval($template_display_picture, $params); }
function list_albums() { global $xoopsModuleConfig, $USER, $PAGE, $lastup_date_fmt, $_GET, $USER_DATA; global $xoopsDB; $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object $cat = isset($_GET['cat']) ? $_GET['cat'] : 0; $alb_per_page = $xoopsModuleConfig['albums_per_page']; $maxTab = $xoopsModuleConfig['max_tabs']; $result = $xoopsDB->query("SELECT count(*) FROM " . $xoopsDB->prefix("xcgal_albums") . " WHERE category = '{$cat}'"); $nbEnr = $xoopsDB->fetchArray($result); $nbAlb = $nbEnr['count(*)']; $xoopsDB->freeRecordSet($result); if ($nbAlb == 0) { return; } $totalPages = ceil($nbAlb / $alb_per_page); if ($PAGE > $totalPages) { $PAGE = 1; } $lower_limit = ($PAGE - 1) * $alb_per_page; $upper_limit = min($nbAlb, $PAGE * $alb_per_page); $limit = "LIMIT " . $lower_limit . "," . ($upper_limit - $lower_limit); $sql = "SELECT a.aid, a.title, description, visibility, filepath, " . " filename, url_prefix, pwidth, pheight " . "FROM " . $xoopsDB->prefix("xcgal_albums") . " as a " . "LEFT JOIN " . $xoopsDB->prefix("xcgal_pictures") . " as p ON thumb=pid " . "WHERE category = '{$cat}' ORDER BY pos " . "{$limit}"; $alb_thumbs_q = $xoopsDB->query($sql); $alb_thumbs = db_fetch_rowset($alb_thumbs_q); $xoopsDB->freeRecordSet($alb_thumbs_q); $disp_album_count = count($alb_thumbs); $album_set = ''; foreach ($alb_thumbs as $value) { $album_set .= $value['aid'] . ', '; } $album_set = '(' . substr($album_set, 0, -2) . ')'; $sql = "SELECT aid, count(pid) as pic_count, max(pid) as last_pid, max(ctime) as last_upload " . "FROM " . $xoopsDB->prefix("xcgal_pictures") . " " . "WHERE aid IN {$album_set} AND approved = 'YES' " . "GROUP BY aid"; $alb_stats_q = $xoopsDB->query($sql); $alb_stats = db_fetch_rowset($alb_stats_q); $xoopsDB->freeRecordSet($alb_stats_q); foreach ($alb_stats as $key => $value) { $cross_ref[$value['aid']] =& $alb_stats[$key]; } for ($alb_idx = 0; $alb_idx < $disp_album_count; $alb_idx++) { $alb_thumb =& $alb_thumbs[$alb_idx]; $aid = $alb_thumb['aid']; if (isset($cross_ref[$aid])) { $alb_stat = $cross_ref[$aid]; $count = $alb_stat['pic_count']; } else { $alb_stat = array(); $count = 0; } // Inserts a thumbnail if the album contains 1 or more images if ($count > 0) { $visibility = $alb_thumb['visibility']; if ($visibility == '0' || $visibility == FIRST_USER_CAT + USER_ID || is_array($USER_DATA['group_id']) && in_array($visibility, $USER_DATA['group_id'])) { if ($alb_thumb['filename']) { $picture =& $alb_thumb; } else { $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM " . $xoopsDB->prefix("xcgal_pictures") . " " . "WHERE pid='{$alb_stat['last_pid']}'"; $result = $xoopsDB->query($sql); $picture = $xoopsDB->fetchArray($result); $xoopsDB->freeRecordSet($result); } $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $xoopsModuleConfig['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . get_pic_url($picture, 'thumb') . "\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />"; } else { $image_size = compute_img_size(100, 75, $xoopsModuleConfig['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"images/private.jpg\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />"; } } else { $image_size = compute_img_size(100, 75, $xoopsModuleConfig['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"images/nopic.jpg\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />"; } // Prepare everything $last_upload_date = $count ? formatTimestamp($alb_stat['last_upload'], 'm') : ''; $alb_list[$alb_idx]['aid'] = $alb_thumb['aid']; $alb_list[$alb_idx]['album_title'] = $myts->makeTboxData4Show($alb_thumb['title']); $alb_list[$alb_idx]['album_desc'] = $myts->makeTareaData4Show($alb_thumb['description'], 1); $alb_list[$alb_idx]['pic_count'] = $count; $alb_list[$alb_idx]['last_upl'] = $last_upload_date; # $alb_list[$alb_idx]['album_info'] = sprintf(_MD_NPICS, $count).($count ? sprintf(_MD_INDEX_LASTADD, $last_upload_date) : "" ); $alb_list[$alb_idx]['album_info'] = sprintf(_MD_NPICS, $count); $alb_list[$alb_idx]['album_adm_menu'] = GALLERY_ADMIN_MODE || USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT ? html_albummenu($alb_thumb['aid']) : ''; } theme_display_album_list($alb_list, $nbAlb, $cat, $PAGE, $totalPages); }
$CLEAN['data'] = @unserialize(@base64_decode($row['link'])); } mysql_free_result($result); } if (is_array($CLEAN['data'])) { // Remove HTML tags as we can't trust what we receive //foreach($CLEAN['data'] as $key => $value) $CLEAN['data'][$key] = html_entity_decode(strtr($value, $HTML_SUBST)); // get the dimensions $result = cpg_db_query("SELECT pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']} WHERE pid = '{$CLEAN['data']['pid']}'"); if (!mysql_num_rows($result)) { cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__); } $row = mysql_fetch_assoc($result); mysql_free_result($result); if ($row['pwidth'] != 0 && $row['pheight'] != 0) { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['picture_width'], 'normal'); $dimensions = $image_size['geom']; } else { $dimensions = ''; } if (is_flash($CLEAN['data']['p'])) { $pic_markup = <<<EOT <object id="SWFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" type="application/x-shockwave-flash" {$dimensions}> <param name="autostart" value="true" /> <param name="src" value="{$CLEAN['data']['p']}" /> </object> EOT; } else { $pic_markup = '<img src="' . $CLEAN['data']['p'] . '" ' . $dimensions . ' alt="" vspace="8" border="0" class="image" />'; } // Load template parameters
/** * cpg_get_system_thumb() * * Gets data for system thumbs * * @param string $filename * @param integer $user * @return array **/ function &cpg_get_system_thumb($filename, $user = 10001) { global $CONFIG; // Correct user_id if ($user < 10000) { $user += 10000; } if ($user == 10000) { $user = 10001; } // Get image data for thumb $picdata = array('filename' => $filename, 'filepath' => $CONFIG['userpics'] . $user . '/', 'url_prefix' => 0); $pic_url = get_pic_url($picdata, 'thumb', true); $picdata['thumb'] = $pic_url; $image_info = cpg_getimagesize(urldecode($pic_url)); $picdata['pwidth'] = $image_info[0]; $picdata['pheight'] = $image_info[1]; $image_size = compute_img_size($picdata['pwidth'], $picdata['pheight'], $CONFIG['alb_list_thumb_size']); $picdata['whole'] = $image_size['whole']; $picdata['reduced'] = isset($image_size['reduced']) && $image_size['reduced']; return $picdata; }
} if ($superCage->get->keyExists('category_title')) { $category_query = "SELECT cid, name FROM `{$CONFIG['TABLE_CATEGORIES']}` WHERE (`name` " . implode(" {$type} `name` ", $albcat_terms) . ')'; $result = cpg_db_query($category_query); if (mysql_num_rows($result) > 0) { starttable('100%', $lang_meta_album_names['category_search'], 2); while ($cat = mysql_fetch_array($result, MYSQL_ASSOC)) { $album_q = "SELECT aid, title FROM `{$CONFIG['TABLE_ALBUMS']}` AS p WHERE (`category` = '{$cat['cid']}') {$FORBIDDEN_SET} ORDER BY `aid` DESC LIMIT 1"; $album_r = cpg_db_query($album_q); $album = mysql_fetch_array($album_r); // TODO: This is weird. It seems to pull in the largest aid's thumb for the category image? $thumb_query = "SELECT filepath, filename, url_prefix, pwidth, pheight " . " FROM `{$CONFIG['TABLE_PICTURES']}` " . " WHERE (`aid` = '{$album['aid']}') " . " AND approved = 'YES' " . " ORDER BY `pid` DESC"; $thumb_result = cpg_db_query($thumb_query); $thumb = mysql_fetch_assoc($thumb_result); $thumb_url = get_pic_url($thumb, 'thumb'); $thumb_size = compute_img_size($thumb['pwidth'], $thumb['pheight'], $CONFIG['alb_list_thumb_size'], true, 'cat_thumb'); ?> <tr> <td colspan="3" height="1" valign="top" class="tableh2"> <span class="alblink"><a href="<?php printf("index.php?cat=%u", $cat['cid']); ?> "><?php echo $cat['name']; ?> </a></span> </td> </tr> <tr> <td colspan="3"> <img src="images/spacer.gif" width="1" height="1" border="0" alt="" /><br />
/** * list_cat_albums() * * This has been added to list the albums in a category, used for showing first level albumslargely a repetition of code elsewhere * Redone for a cleaner approach * @param integer $cat Category id for which albums are needed */ function list_cat_albums($cat = 0) { global $CONFIG, $USER, $lastup_date_fmt, $USER_DATA, $FORBIDDEN_SET, $FORBIDDEN_SET_DATA, $cpg_show_private_album; global $lang_list_albums, $lang_errors; $PAGE = 1; if ($cat == 0) { return ''; } $cat_owner_id = $cat > 10000 ? 10000 - $cat : 10001; $cpg_nopic_data = cpg_get_system_thumb('nopic.jpg', $cat_owner_id); $cpg_privatepic_data = cpg_get_system_thumb('private.jpg', $cat_owner_id); $alb_per_page = $CONFIG['albums_per_page']; $maxTab = $CONFIG['max_tabs']; $album_filter = ''; $pic_filter = ''; if (!empty($FORBIDDEN_SET) && !$cpg_show_private_album) { $album_filter = ' and ' . str_replace('p.', 'a.', $FORBIDDEN_SET); $pic_filter = ' and ' . $FORBIDDEN_SET; } $sql = "SELECT count(aid) FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE category = '{$cat}'" . $album_filter; $result = cpg_db_query($sql); $nbEnr = mysql_fetch_array($result); $nbAlb = $nbEnr[0]; mysql_free_result($result); if ($nbAlb == 0) { return; } $totalPages = ceil($nbAlb / $alb_per_page); if ($PAGE > $totalPages) { $PAGE = 1; } $lower_limit = ($PAGE - 1) * $alb_per_page; $upper_limit = min($nbAlb, $PAGE * $alb_per_page); $limit = "LIMIT " . $lower_limit . "," . ($upper_limit - $lower_limit); $sql = 'SELECT a.aid, a.title, a.description, a.thumb, visibility, filepath, ' . 'filename, url_prefix, pwidth, pheight ' . 'FROM ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'LEFT JOIN ' . $CONFIG['TABLE_PICTURES'] . ' as p ' . 'ON a.thumb=p.pid ' . 'WHERE category=' . $cat . $album_filter . ' ORDER BY a.pos ' . $limit; $alb_thumbs_q = cpg_db_query($sql); $alb_thumbs = cpg_db_fetch_rowset($alb_thumbs_q); mysql_free_result($alb_thumbs_q); $disp_album_count = count($alb_thumbs); $album_set = ''; foreach ($alb_thumbs as $value) { $album_set .= $value['aid'] . ', '; } $album_set = '(' . substr($album_set, 0, -2) . ')'; /*$sql = "SELECT aid, count(pid) as pic_count, max(pid) as last_pid, max(ctime) as last_upload " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE aid IN $album_set AND approved = 'YES' " . "GROUP BY aid"; $alb_stats_q = cpg_db_query($sql); $alb_stats = cpg_db_fetch_rowset($alb_stats_q); mysql_free_result($alb_stats_q);*/ //This query will fetch album stats and keyword for the albums $sql = "SELECT a.aid, count( p.pid ) AS pic_count, max( p.pid ) AS last_pid, max( p.ctime ) AS last_upload, a.keyword, a.alb_hits" . " FROM {$CONFIG['TABLE_ALBUMS']} AS a " . " LEFT JOIN {$CONFIG['TABLE_PICTURES']} AS p ON a.aid = p.aid AND p.approved = 'YES' " . "WHERE a.aid IN {$album_set}" . "GROUP BY a.aid"; $alb_stats_q = cpg_db_query($sql); $alb_stats = cpg_db_fetch_rowset($alb_stats_q); mysql_free_result($alb_stats_q); foreach ($alb_stats as $key => $value) { $cross_ref[$value['aid']] =& $alb_stats[$key]; if ($CONFIG['link_pic_count'] == 1) { if (!empty($value['keyword'])) { $query = "SELECT count(pid) AS link_pic_count\n FROM {$CONFIG['TABLE_PICTURES']}\n WHERE aid != {$value['aid']} AND\n keywords LIKE '%{$value['keyword']}%' AND\n approved = 'YES'"; $result = cpg_db_query($query); $link_stat = mysql_fetch_array($result); mysql_free_result($result); $alb_stats[$key]['link_pic_count'] = $link_stat['link_pic_count']; } } } for ($alb_idx = 0; $alb_idx < $disp_album_count; $alb_idx++) { $alb_thumb =& $alb_thumbs[$alb_idx]; $aid = $alb_thumb['aid']; if (isset($cross_ref[$aid])) { $alb_stat = $cross_ref[$aid]; $count = $alb_stat['pic_count']; $alb_hits = $alb_stat['alb_hits']; } else { $alb_stat = array(); $count = 0; $alb_hits = 0; } // Inserts a thumbnail if the album contains 1 or more images $visibility = $alb_thumb['visibility']; if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) { //test for visibility if ($count > 0) { // Inserts a thumbnail if the album contains 1 or more images if ($alb_thumb['filename']) { $picture =& $alb_thumb; } elseif ($alb_thumb['thumb'] < 0) { $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = '{$alb_thumb['aid']}' ORDER BY RAND() LIMIT 0,1"; $result = cpg_db_query($sql); $picture = mysql_fetch_array($result); mysql_free_result($result); } else { $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='{$alb_stat['last_pid']}'"; $result = cpg_db_query($sql); $picture = mysql_fetch_array($result); mysql_free_result($result); } $pic_url = get_pic_url($picture, 'thumb'); if (!is_image($picture['filename'])) { $image_info = cpg_getimagesize(urldecode($pic_url)); $picture['pwidth'] = $image_info[0]; $picture['pheight'] = $image_info[1]; } //thumb cropping if ($picture['system_icon'] == 'true') { $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size'], true, 'cat_thumb'); } else { $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size'], false, 'cat_thumb'); } $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$picture['filename']}\" />"; } else { // Inserts an empty thumbnail if the album contains 0 images // $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = '<img src="' . $cpg_nopic_data['thumb'] . '" ' . $cpg_nopic_data['whole'] . ' class="image" border="0" alt="" />'; } } elseif ($CONFIG['show_private']) { // $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = '<img src="' . $cpg_privatepic_data['thumb'] . '" ' . $cpg_privatepic_data['whole'] . ' class="image" border="0" alt="" />'; } // Prepare everything if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) { $last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : ''; $link_pic_count = !empty($alb_stat['link_pic_count']) ? $alb_stat['link_pic_count'] : 0; $alb_list[$alb_idx]['aid'] = $alb_thumb['aid']; $alb_list[$alb_idx]['album_title'] = $alb_thumb['title']; $alb_list[$alb_idx]['album_desc'] = bb_decode($alb_thumb['description']); $alb_list[$alb_idx]['pic_count'] = $count; $alb_list[$alb_idx]['last_upl'] = $last_upload_date; $alb_list[$alb_idx]['alb_hits'] = sprintf($lang_list_albums['alb_hits'], $alb_hits); $alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "") . ($CONFIG['link_pic_count'] && $link_pic_count > 0 ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $count + $link_pic_count) : ""); $alb_list[$alb_idx]['album_adm_menu'] = album_adm_menu($alb_thumb['aid'], $cat); } elseif ($CONFIG['show_private']) { // uncomment this else block to show private album description $last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : ''; $link_pic_count = !empty($alb_stat['link_pic_count']) ? $alb_stat['link_pic_count'] : 0; $alb_list[$alb_idx]['aid'] = $alb_thumb['aid']; $alb_list[$alb_idx]['album_title'] = $alb_thumb['title']; $alb_list[$alb_idx]['album_desc'] = bb_decode($alb_thumb['description']); $alb_list[$alb_idx]['pic_count'] = $count; $alb_list[$alb_idx]['last_upl'] = $last_upload_date; $alb_list[$alb_idx]['alb_hits'] = sprintf($lang_list_albums['alb_hits'], $alb_hits); $alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "") . ($CONFIG['link_pic_count'] && $link_pic_count > 0 ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $count + $link_pic_count) : ""); $alb_list[$alb_idx]['album_adm_menu'] = album_adm_menu($alb_thumb['aid'], $cat); } } ob_start(); theme_display_album_list_cat($alb_list, $nbAlb, $cat, $PAGE, $totalPages); $cat_albums = ob_get_contents(); ob_end_clean(); return $cat_albums; }
</td> </tr> EOT; $sort_codes = array('name_a' => 'msg_author ASC', 'name_d' => 'msg_author DESC', 'date_a' => 'msg_id ASC', 'date_d' => 'msg_id DESC', 'comment_a' => 'msg_body ASC', 'comment_d' => 'msg_body DESC', 'file_a' => 'pid ASC', 'file_d' => 'pid DESC'); $sort = !isset($_GET['sort']) || !isset($sort_codes[$_GET['sort']]) ? 'date_d' : $_GET['sort']; $result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, {$CONFIG['TABLE_COMMENTS']}.pid as pid, aid, filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']} WHERE {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid ORDER BY {$sort_codes[$sort]} LIMIT {$start}, {$count}"); $rowcounter = 0; while ($row = mysql_fetch_array($result)) { $thumb_url = get_pic_url($row, 'thumb'); if (!is_image($row['filename'])) { $image_info = getimagesize($thumb_url); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['alb_list_thumb_size']); $thumb_link = 'displayimage.php?pos=' . -$row['pid']; $msg_date = localised_date($row['msg_date'], $comment_date_fmt); $msg_body = bb_decode(process_smilies($row['msg_body'])); $rowcounter++; if ($rowcounter >= 2) { //let the row colors alternate, for now they are the same $rowcounter = 0; $tableclass = 'tableb'; // change to "tableh2_compact" or similar for alternation } else { $tableclass = 'tableb'; } // build a link to the author's profile if applicable if ($row['author_id'] != 0) { $profile_link_start = '<a href="profile.php?uid=' . $row['author_id'] . '">';
function thumb_rotate_thumb_display($params) { global $CONFIG; if ($CONFIG['plugin_thumb_rotate_admin_only'] == 1 && !GALLERY_ADMIN_MODE) { return $params; } $gd_extension_array = array('jpg', 'jpeg', 'gif', 'png'); // Create the super cage $superCage = Inspekt::makeSuperCage(); // Extract the needed information from the thumbnail params array $link_target_array = parse_url(str_replace('&', '&', $params['{LINK_TGT}'])); parse_str($link_target_array['query'], $link_target_param_array); unset($link_target_array); $pid = $link_target_param_array['pid']; $pos = $link_target_param_array['pos']; $album = $link_target_param_array['album']; unset($link_target_param_array); if (!$album) { // Try to extract the album from the URL param if ($superCage->get->keyExists('album') == TRUE) { $album = $superCage->get->getAlnum('album'); } } if (is_int($album) != TRUE) { unset($album); } // Extract the needed information about the individual pic using the built-in methods of coppermine (code taken from displayimage.php) if ($pos < 0 && !$pid) { $pid = -$pos; } if (!$album) { $result = cpg_db_query("SELECT aid FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE pid='{$pid}' {$FORBIDDEN_SET} LIMIT 1"); if (mysql_num_rows($result) == 0) { cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__); } $row = mysql_fetch_assoc($result); mysql_free_result($result); $album = $row['aid']; } if (!$pos) { $pos = get_pic_pos($album, $pid); } $pic_data = get_pic_data($album, $pic_count, $album_name, $pos, 1, false); $CURRENT_PIC_DATA = $pic_data[0]; $CURRENT_PIC_DATA['extension'] = ltrim(substr($CURRENT_PIC_DATA['filename'], strrpos($CURRENT_PIC_DATA['filename'], '.')), '.'); $CURRENT_PIC_DATA['filename_without_extension'] = str_replace('.' . $CURRENT_PIC_DATA['extension'], '', $CURRENT_PIC_DATA['filename']); if ($CONFIG['thumb_use'] == 'any' || $CONFIG['thumb_use'] == 'ex') { $CURRENT_PIC_DATA['maxthumb'] = max($CONFIG['thumb_width'], $CONFIG['thumb_height']); } elseif ($CONFIG['thumb_use'] == 'ht') { $CURRENT_PIC_DATA['maxthumb'] = $CONFIG['thumb_height']; } else { $CURRENT_PIC_DATA['maxthumb'] = $CONFIG['thumb_width']; } $thumb_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $CURRENT_PIC_DATA['maxthumb']); $CURRENT_PIC_DATA['twidth'] = $thumb_size['width']; $CURRENT_PIC_DATA['theight'] = $thumb_size['height']; // End Extract - we now have all needed data concerning the individual pic // Let's determine if the file is cached already $rotate_image_create_file = 0; $rotate_image_create_dbrecord = 0; $result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PREFIX']}plugin_thumb_rotate WHERE pid = '{$pid}'"); if (!mysql_num_rows($result)) { // There is NO cached record in the database --- start mysql_free_result($result); $rotate_image_create_file = 1; $rotate_image_create_dbrecord = 1; // There is NO cached record in the database --- end } else { // There IS a cached record in the database --- start $row = mysql_fetch_array($result); $rotate_image_create_dbrecord = 0; if (file_exists($CONFIG['fullpath'] . $row['filepath'])) { $rotate_image_create_file = 0; } else { $rotate_image_create_file = 1; } mysql_free_result($result); // There IS a cached record in the database --- end } // Apply the delay --- start if ($CONFIG['plugin_thumb_rotate_timelimit'] > 0) { if (time() - $CONFIG['plugin_thumb_rotate_timestamp'] > $CONFIG['plugin_thumb_rotate_timelimit']) { // The time stamp difference is greater than the set config parameter, so we can proceed with thumbnail creation } else { // The time stamp difference is smaller - don't process the thumb to save resources $rotate_image_create_file = 0; $rotate_image_create_dbrecord = 0; } } // Apply the delay --- end if ($rotate_image_create_file == 1) { $created_image_array = thumb_rotate_image_create($CURRENT_PIC_DATA); if ($CONFIG['plugin_thumb_rotate_timelimit'] > 0) { // Write the current time stamp to the db $time = time(); cpg_db_query("UPDATE {$CONFIG['TABLE_CONFIG']} SET value='{$time}' WHERE name='plugin_thumb_rotate_timestamp'"); } } if ($rotate_image_create_dbrecord == 1 && $created_image_array['path'] != '') { $result = cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_PREFIX']}plugin_thumb_rotate ( `pid` , `filepath`, `width`, `height` ) VALUES ('{$pid}', '{$created_image_array['path']}', '{$created_image_array['width']}', '{$created_image_array['height']}');"); } if (!isset($created_image_array)) { $created_image_array['width'] = $row['width']; $created_image_array['height'] = $row['height']; } // Finally, let's manipulate the thumbnail HTML if (file_exists($CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CONFIG['plugin_thumb_rotate_thumb_pfx'] . $CURRENT_PIC_DATA['filename_without_extension'] . '.' . $CONFIG['plugin_thumb_rotate_filetype'])) { if (in_array(strtolower($CURRENT_PIC_DATA['extension']), $gd_extension_array)) { $params['{THUMB}'] = str_replace($CURRENT_PIC_DATA['filepath'] . $CONFIG['thumb_pfx'] . $CURRENT_PIC_DATA['filename'], $CURRENT_PIC_DATA['filepath'] . $CONFIG['plugin_thumb_rotate_thumb_pfx'] . $CURRENT_PIC_DATA['filename_without_extension'] . '.' . $CONFIG['plugin_thumb_rotate_filetype'], $params['{THUMB}']); $params['{THUMB}'] = str_replace('width="' . $thumb_size['width'] . '"', 'width="' . $created_image_array['width'] . '"', $params['{THUMB}']); // Replace the existing width attributes $params['{THUMB}'] = str_replace('height="' . $thumb_size['height'] . '"', 'height="' . $created_image_array['height'] . '"', $params['{THUMB}']); // Replace the existing height attributes } else { $params['{THUMB}'] = str_replace($THEME_DIR . 'images/thumbs/thumb_' . $CURRENT_PIC_DATA['extension'] . '.png', $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CONFIG['plugin_thumb_rotate_thumb_pfx'] . $CURRENT_PIC_DATA['filename_without_extension'] . '.' . $CONFIG['plugin_thumb_rotate_filetype'], $params['{THUMB}']); $params['{THUMB}'] = str_replace('images/thumbs/thumb_' . $CURRENT_PIC_DATA['extension'] . '.png', $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CONFIG['plugin_thumb_rotate_thumb_pfx'] . $CURRENT_PIC_DATA['filename_without_extension'] . '.' . $CONFIG['plugin_thumb_rotate_filetype'], $params['{THUMB}']); } $params['{THUMB}'] = str_replace('class="image"', 'class="image" style="border:none;"', $params['{THUMB}']); // Remove border CSS } //$params['{THUMB}'] .= $created_image_array['height']; return $params; }