PHP Classes

File: show_image.php

Recommend this page to a friend!
  Classes of Eugene Panin   Picture of the Day   show_image.php   Download  
File: show_image.php
Role: Example script
Content type: text/plain
Description: Displays images to user's page. Configuration is placed here
Class: Picture of the Day
Show a different picture every day from a list
Author: By
Last change:
Date: 17 years ago
Size: 1,423 bytes
 

Contents

Class file image Download
<?php
require_once('pictod/pictod_ShowImageHandler.php');

$sih = new pictod_ShowImageHandler();

$conf = array(
   
// Configuration of cache
   
'pictod_Cache' => array(
       
'contName' => 'simple',
       
'contConf' => array(
           
'cacheDir' => './cache',
            ),
    ),

   
// Configuration of Rules of displaying images
   
    // У каждой картинки могут быть свои правила!
   
   
'pictod_Ruler' => array(
       
'contName' => 'daily',
       
'contConf' => array(
           
'cacheDir' => './cache',
            ),
    ),
   
   
// Configuration of image container
   
'pictod_ImageContainer' => array(
       
'contName' => 'simple',
       
'contConf' => array(
           
'images' => array(
               
// If no imageID given, 'default' is used
                // For each imageID indicate the list of directories where images stored
               
                // Блокировать кэш при записи. Ждать пока не освободится!
               
               
'default' => array('./images1','./images2'),
               
'a1' => array('./images3'),
                ),
            ),
    ),

);
$err = $sih->initialize($conf);

$imageID = @$_REQUEST['imageID'];
$image = $sih->getImage($imageID);
if (
PEAR::isError($image)) {
   
var_dump($image);
    exit;
}

header("Expires: Mon, 26 Jul 1990 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: no-store");
header('Pragma: no-cache');
header('Content-type: image/'.$image['type']);
echo
$image['data'];
exit;
?>