Esempio n. 1
0
function send_file($gallery, $dirkey, $filekey, $mode)
{
    // Send a file using it's own mime type, useful for sending image files
    // without using the resampling code, or sending movie or other files.
    // Set the mode to "Attach" to tell the browser to download rather than open the file
    include "set_paths.php";
    include "{$imagedata}/{$gallery}";
    include_once 'generate_filelist.php';
    $filelist = generate_filelist($gallery, $dirkey);
    $file = $filelist[$filekey];
    $mimetype = mime_content_type($file);
    header('Content-Type: ' . $mimetype);
    if ($mode == 'attach') {
        header('Content-disposition: attachment; filename="' . basename($file) . '"');
    }
    readfile($dirs[$dirkey] . "/{$file}");
}
Esempio n. 2
0
function write_caption($gallery, $dirkey, $filekey, $caption)
{
    include "set_paths.php";
    include "{$imagedata}/{$gallery}";
    $filelist = generate_filelist($gallery, $dirkey);
    $imagefile = $dirs[$dirkey] . "/" . $filelist[$filekey];
    // Security check that this user is permitted to write to this file's caption
    // uid should be held in session
    #authorise_user("write_caption", $imagefile);
    $captionfile = $imagefile . ".caption";
    #  if (is_writeable($captionfile)){
    #    // Caption file already exists and is writeable.
    #
    #  }
    #  elseif ( ! file_exists($captionfile) && is_writeable(dirname($captionfile)) ){
    #    // Caption file does not exist but can be created in dir with image file
    #
    #  }
    #  elseif ( file_exists($captionfile) && ! is_writeable($captionfile) ){
    #    // Caption file exists but cannot be written to - do not allow overwrite
    #    print "<span class='error' >Caption file exists but cannot be written to $captionfile</span>";
    #    return false;
    #  }
    #  elseif ( ! is_writeable(dirname($captionfile)) ){
    #    // Caption file cannot be written in image dir so
    // Write to $imagedata dir
    $captionfile = "{$imagedata}/captions/{$captionfile}";
    if (!file_exists(dirname($captionfile))) {
        mkdir(dirname($captionfile), 0754, 'true');
    }
    if (file_exists($captionfile) && !is_writeable($captionfile)) {
        print "<span class='error' >Caption file cannot be created {$captionfile}</span>";
        return false;
    }
    #  }
    if (!($fp = fopen($captionfile, 'w'))) {
        print "<span class='error'>Error opening {$captionfile}</span><br>\n";
        return;
    }
    if (!fwrite($fp, $caption)) {
        print "<span class='error'>Error writing to {$captionfile}</span><br>\n";
        return;
    }
    fclose($fp);
}
Esempio n. 3
0
function generate_gallery($gallery, $dirkey)
{
    include "set_paths.php";
    include "{$imagedata}/{$gallery}";
    $basedir = $dirs[$dirkey];
    #print "DEBUG: $gallery, $dirkey, $basedir <br/>";
    //Get list of files for this gallery
    $filelist = generate_filelist($gallery, $dirkey);
    // and export it
    $_SESSION['filelist'] = $filelist;
    // Process filename list
    foreach (array_keys($filelist) as $filekey) {
        $file = $filelist[$filekey];
        if (preg_match("/\\.(jpg|jpeg|png)\$/i", $file)) {
            JPEG_Thumbnail($filelist, $gallery, $dirkey, $filekey, $basedir);
        } elseif (preg_match("/\\.(mov|mpeg|mpg|avi|mp4)\$/i", $file)) {
            Movie_thumbnail($filelist, $gallery, $dirkey, $filekey, $basedir);
        }
    }
}
Esempio n. 4
0
$basedir = $_SESSION['basedir'];
$src_imgfile = $filelist[$filekey];
$src_imgfile = "{$basedir}/{$src_imgfile}";
// Override session vars if Gets are provided
if (isset($_GET['filekey'])) {
    $gallery = $_GET['gallery'];
    if (isset($_GET['dirkey'])) {
        $dirkey = $_GET['dirkey'];
    }
    $filekey = $_GET['filekey'];
    include dirname(__FILE__) . "/imagedata/{$gallery}";
    if ($filekey == "default") {
        $src_imgfile = $default_image;
    } else {
        include_once "generate_filelist.php";
        $filelist = generate_filelist($gallery, $dirkey);
        $basedir = $dirs[$dirkey];
        $src_imgfile = $filelist[$filekey];
        $src_imgfile = "{$basedir}/{$src_imgfile}";
    }
}
// End if
if (isset($_GET['size'])) {
    $size = $_GET['size'];
}
if (isset($_GET['xsize'])) {
    $xsize = $_GET['xsize'];
    unset($size);
}
if (isset($_GET['ysize'])) {
    $ysize = $_GET['ysize'];
Esempio n. 5
0
function display_image_section($gallery, $dirkey, $filekey, $size, $xsize, $ysize)
{
    include "set_paths.php";
    include "{$imagedata}/{$gallery}";
    if (!isset($_GLOBAL['filelist'])) {
        include_once "generate_filelist.php";
        $filelist = generate_filelist($gallery, $dirkey);
    } else {
        $filelist = $_GLOBAL['filelist'];
    }
    $numfiles = count($filelist);
    #$imagecache=dirname(__FILE__)."/imagecache";
    $basedir = $dirs[$dirkey];
    if (preg_match("/\\.(mov|mpg|mpeg|avi|mp4)\$/i", $filelist[$filekey])) {
        $type = "movie";
    }
    // Create next image href
    #$nexttag = "<span class='nav_inactive' >Next&gt;&gt;</span>";
    if ($filekey + 1 >= $numfiles) {
        $nextfile = $filelist[0];
        $nextfile = "{$basedir}/{$nextfile}";
        $nexttag = "<a class='prevnext_active' href='gallery.php?filekey=0&size=700&action=display_image'>|&lt;&lt;Back to start</a>";
    } else {
        $nextkey = $filekey + 1;
        $nextfile = $filelist[$nextkey];
        $nextfile = "{$basedir}/{$nextfile}";
        $nexttag = "<a class='prevnext_active' href='gallery.php?filekey={$nextkey}&size=700&action=display_image'>Next&gt;&gt;</a>";
    }
    // Create href to previous image
    if ($filekey == 0) {
        # We are at first image so don't show next link - just inactive.
        $prevtag = "<span class='prevnext_inactive' >&lt;&lt;Previous</span>";
    } else {
        $prevkey = $filekey - 1;
        $prevfile = $filelist[$prevkey];
        $prevfile = "{$basedir}/{$prevfile}";
        $prevtag = "<a class='prevnext_active' href='gallery.php?&filekey={$prevkey}&size=700&action=display_image'>&lt;&lt;Previous</a>";
    }
    // Use random number so that browser cache does not mistake this for the same picture each time
    $random = rand(1000, 9999);
    #$imagefile=$_SESSION['imagefile'];
    $imagefile = "{$basedir}/" . $filelist[$filekey];
    $_GLOBAL['caption'] = get_caption($imagefile);
    $caption = $_GLOBAL['caption'];
    // Menu line
    if ($type != "movie") {
        ?>
 <div class="imagenavigate" > <?php 
        include "resize_menu.php";
        print "\n<span id='resize_menu'>\n";
        display_resize_menu($filekey);
        print "</span>\n";
    } else {
        //Display fake resize menu as placeholder
        print "\n<ul class='nav' ><li> </li></ul>\n";
    }
    print <<<EOH
        <span class="prevnext" >
          {$prevtag} &nbsp; &nbsp; &nbsp; {$nexttag} 
        </span>
EOH;
    if ($_SESSION['edit']) {
        print <<<EOH
    <span id="edit_caption_link" >
     <a href="?gallery={$gallery}&action=edit_caption&filekey={$filekey}&dirkey={$dirkey}&size={$size}" >
      Edit Caption
     </a>
    </span>
    </div><br/>

EOH;
    }
    #if ( $_SESSION['action'] != 'edit_caption' && authorise_user('edit_caption') ){
    if ($_SESSION['action'] != 'edit_caption') {
        // display caption
        print <<<EOH
\t<br/>
    <span id="caption" >{$caption}</span>
EOH;
        print "\n<br/>\n";
    } elseif ($_SESSION['action'] == 'edit_caption') {
        // display caption in an editable text box
        $filepath = $dirs[$dirkey] . "/" . $filelist[$filekey];
        caption_edit_form($filepath, $gallery, $dirkey, $filekey);
        print "<br/>\n";
    } else {
        // no edit functions requested, just write the caption
        print <<<EOH
      <span id="caption" >{$caption}</span><br/>
EOH;
    }
    // Display image
    if (preg_match_all("/\\.(mov|mpg|mpeg|avi|mp4)\$/i", $filelist[$filekey], $matches)) {
        $mimetype = mime_content_type($dirs[$dirkey] . "/" . $filelist[$filekey]);
        $parts = $matches[0];
        $type = $parts[0];
        #$filename="$basedir/${filelist[$filekey]}";
        #<embed type="video/x-msvideo" src='send_file.php?mode=stream&gallery=$gallery&dirkey=$dirkey&filekey=$filekey' width=640 height=480 >
        #<object type="video/avi" data='send_file.php?mode=stream&gallery=$gallery&dirkey=$dirkey&filekey=$filekey' width=640 height=480 >
        echo <<<HTMLEND
  <span class="center" >This file "{$filelist[$filekey]}" is a "{$mimetype}" movie file.<br/>
  <a href='send_file.php?mode=stream&gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}' type='{$mimetype}' >Click here to play it</a>
  <br/>
  <a href='send_file.php?mode=attach&gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}'>
  <b>Click here to download it.</b></a></span><br>
HTMLEND;
    } else {
        #if ( $_SESSION['size'] == "full" ) {
        if ($size == "full") {
            $filekey = $_SESSION['filekey'];
            $filelist = $_SESSION['filelist'];
            $basedir = $_SESSION['basedir'];
            $filename = $filelist[$filekey];
            $src_imgfile = "{$basedir}/{$filename}";
            if (!isset($caption) || $caption == "") {
                $caption = $filename;
            }
            echo <<<HTMLEND
\t<img src="send_file.php?mode=stream&gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}" title="{$caption}" >
HTMLEND;
        } else {
            if (!isset($caption) || $caption == "") {
                $caption = basename($imagefile);
            }
            if ($size > 10) {
                $urlsize = "size={$size}";
            } else {
                $urlsize = "xsize={$xsize}&ysize={$ysize}";
            }
            $filekey = $_SESSION['filekey'];
            $dirkey = $_SESSION['dirkey'];
            echo <<<HTMLEND
\t<img src="image_resample.php?gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}&{$urlsize}&xxx={$random}"  title="{$caption}">
HTMLEND;
        }
        print "\n\n<br/>\n\n";
        show_exif_button();
        display_exif("{$basedir}/" . $filelist[$filekey]);
    }
}