1<?php 2/** 3 * @package tikiwiki 4 */ 5// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 6// 7// All Rights Reserved. See copyright.txt for details and a complete list of authors. 8// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 9// $Id$ 10 11$fontfile = "/usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf"; 12if (! isset($_REQUEST['view'])) { 13 if (isset($_REQUEST['id'])) { 14 $ex = "&id=" . urlencode($_REQUEST['id']); 15 } else { 16 $ex = ''; 17 } 18 echo "<html><frameset rows='30,*' border='0'><frame src='tiki-show_all_images.php?view=nav$ex'><frame name='meat' src='tiki-show_all_images.php?view=image$ex'></frameset></html>"; 19} elseif ($_REQUEST['view'] == 'nav') { 20 include_once("tiki-setup.php"); 21 echo "<html><body><form target='meat'>"; 22 if (isset($_REQUEST['id'])) { 23 echo "<a href='tiki-browse_gallery.php?galleryId=" . urlencode($_REQUEST['id']) . "' target='_top'>Gallery " . $_REQUEST['id'] . "</a> "; 24 $id = $_REQUEST['id']; 25 } else { 26 echo "<a href='tiki-galleries.php' target='_top'>list</a> "; 27 $id = null; 28 } 29 echo "<input type='hidden' name='view' value='image' />"; 30 echo "<select name='id'>"; 31 $query = "select `galleryId`,`name` from `tiki_galleries` order by created desc"; 32 $res = $tikilib->query($query, []); 33 while ($r = $res->fetchRow()) { 34 echo "<option value='" . $r['galleryId'] . "'"; 35 if ($r['galleryId'] == $id) { 36 echo " selected='selected'"; 37 } 38 echo ">" . $r['name'] . "</option>"; 39 } 40 echo "</select>"; 41 echo "<input type='submit' value='view' />"; 42 echo "</form></body>"; 43 die; 44} elseif ($_REQUEST['view'] == 'image') { 45 include_once("tiki-setup.php"); 46 $imagegallib = TikiLib::lib('imagegal'); 47 if ($prefs['feature_galleries'] != 'y') { 48 header("HTTP/1.0 404 Not Found"); 49 die; 50 } 51 if ($tiki_p_admin_galleries != 'y') { 52 header("HTTP/1.0 404 Not Found"); 53 die; 54 } 55 if (! $_REQUEST['id']) { 56 header("HTTP/1.0 404 Not Found"); 57 die; 58 } 59 $galleryId = $_REQUEST['id']; 60 $itype = 't'; 61 $scalesize = 0; 62 $query = "select `imageId` from `tiki_images` where `galleryId`=?"; 63 $res = $tikilib->query($query, [(int)$galleryId]); 64 $numrows = $res->numRows(); 65 $numcols = 10; 66 $gap = 4; 67 $heading = 30; 68 $square = 80; 69 $width = $numcols * $square + ($numcols + 1) * $gap; 70 $height = ((ceil($numrows / $numcols)) * ($square + $gap)) + $heading; 71 72 $im = imagecreatetruecolor($width, $height); 73 $text_color = imagecolorallocate($im, 0, 0, 0); 74 $wh_color = imagecolorallocate($im, 255, 255, 255); 75 $bg_color = imagecolorallocate($im, 235, 235, 235); 76 $frame_color = imagecolorallocate($im, 0, 0, 0); 77 $frame_color_soft = imagecolorallocate($im, 200, 200, 200); 78 imagefill($im, 0, 0, $bg_color); 79 imagettftext($im, 16, 0, $gap, $gap + 16, $frame_color_soft, "/usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf", "All images in /gal$galleryId"); 80 $position_x = $gap; 81 $position_y = $heading; 82 while ($r = $res->fetchRow()) { 83 $id = $r['imageId']; 84 $imagegallib->get_image($id, $itype, $scalesize); 85 $type = $imagegallib->filetype; 86 $thatim = imagecreatefromstring($imagegallib->image); 87 $x = $position_x + floor($square - $imagegallib->xsize); 88 $y = $position_y; 89 imagefilledrectangle($im, $position_x, $position_y, $position_x + $square, $position_y + $square, $wh_color); 90 imagecopy($im, $thatim, $x, $y, 0, 0, $imagegallib->xsize, $imagegallib->ysize); 91 imagerectangle($im, $position_x, $position_y, $position_x + $square, $position_y + $square, $frame_color_soft); 92 imagerectangle($im, $x, $y, $x + $imagegallib->xsize, $y + $imagegallib->ysize, $frame_color); 93 if ($x == $position_x) { 94 imagestring($im, 2, $x + 4, $y + $imagegallib->ysize + 4, "$id", $text_color); 95 } else { 96 imagestringup($im, 2, $position_x + 4, $y + $square - 4, "$id", $text_color); 97 } 98 if (($position_x + $square + $gap) > $width) { 99 $position_x = $gap; 100 $position_y = $position_y + $square + $gap; 101 } else { 102 $position_x = $position_x + $square + $gap; 103 } 104 imagedestroy($thatim); 105 } 106 session_write_close(); 107 header("Content-type: image/png"); 108 header("Content-Disposition: inline; filename=\"allimages_$galleryId.png\""); 109 imagepng($im); 110 imagedestroy($im); 111} else { 112 echo "wrong."; 113} 114