Tortuga Software - web development (programming) with PHP / MySQL / Apache
Useful PHP-classes, scripts, manuals, articles, tutorials
E-mail: info@usefulclasses.com ICQ: 749345 GTalk: varenich@gmail.com
Let Visitors Enjoy Your Site!
   

  Save To del.icio.us Digg this Post Save To Slashdot Bookmarks Save To FURL Save To Newsvine Save to Yahoo! My Web 2.0 Save To Reddit Save To Simpy Save To Shadows

Picture of The Day Pro


Picture of The Day Script Instruction Manual


The biggest Pictod library advantage is the ability to display images on your site according to the various and almost arbitrary rules.

You can change

Configuration

Let assume that you need to display two images on a page:



As you see, one of the images has "imageID=a1" identifier. This is made to be able to distinguish the images on the page and to set own extraction sequence and change periodicity for each of them.

Your page can be as follows:

<html>
<img src="show_image.php"> <br />
<img src="show_image.php?imageID=a1"> <br />
<img src="show_image.php?imageID=a2"> <br />
...
</html>


The first image doesn’t have identifier and is specified in the configuration as “default”. The others have identifiers a1 and a2, respectively. You can display unlimited number of images on your page.

You can change the sequence and periodicity either of the images in the “show_image.php” file.

The configuration example from the “show image.php” file:

$conf = array(
          //------------------------------------------------------------------------
          // Configuring cache
          'pictod_Cache' => array(
                      'contName' => 'simple',
                      'contConf' => array(
                              'cacheDir' => './cache',
                              ),
                      ),
          //------------------------------------------------------------------------
          // Configuring rules of displaying
          'pictod_Ruler' => array(
                      'contName' => 'always',
                      'contConf' => array(
                              'cronstring' => array (
                                'default' => '10-12 1,2,3 * * *',
                                'a1' => '* * * * *',
                                ),
                              'cacheDir' => './cache',
                              ),
                      ),
          //------------------------------------------------------------------------
          // Configuring image container
          'pictod_ImageContainer' => array(
                           'contName' => 'ordered_pict_list',
                           'contConf' => array(
                                   'cacheDir' => './cache',
                                   'images' => array(
                                             'default' => array('./images1/Asteroids_illusions_1024.jpg','./images1/little_supernova_1024.jpg'), // For image without
identifier
                                             'a1' => array('./images2/Wolfgang_hijacking_1024.jpg'), // For image with identifier imageID=a1
                                             ),
                                   ),
                           ),
          //------------------------------------------------------------------------
);


At first the configuration seems to be complex, but it is not so hard to work with it as one may think because it is logically split into three parts which are responsible for the display sequence and periodicity and also for the images caching method, respectively (split in the config by the long horizontal lines).

Each of the parts can be changed independently. This conclude the power itself of the library. I.e you can change the sequence and periodicity independently without any efforts.

For example, you decided to take the images from the directory randomly. At the same time you can set different periodicity of their display: once per day, once per hour (and so on) or select the periodicity which fits you the most using “cronstring”.

Or otherwise, you decide that the images on your page will change once a day but at the same time you change their display sequence from a random image to a specified list.

All possible configuration parameters of each of the systems are shown below.

Image Display Sequence

Images can be chosen:


The display method is chosen using so called Container. In the configuration it is specified by the “contName” variable in the "pictod_ImageContainer" category, for example:

// Configuring image container
          'pictod_ImageContainer' => array(
                           'contName' => '
ordered_pict_list',
                            ...


At the same time each container has its own configuration parameters which are set in the "contConf" variable of the "pictod_ImageContainer" category, for example:


 //------------------------------------------------------------------------
// Configuring image container
          'pictod_ImageContainer' => array(
                            ...
                            'contConf' => array(
                                   'cacheDir' => './cache',
                                   'images' => array(
                                             'default' => array(  './images1/Asteroids_illusions_1024.jpg',  './images1/little_supernova_1024.jpg' ),
                                             'a1' => array(  './images2/Wolfgang_hijacking_1024.jpg'  ),
                                             ),
                                   ),

                                ...
//------------------------------------------------------------------------


All the images display methods (containers) and their configurational parameters are presented in details below.

simple – Random Image From The Directory

Simple” container randomly chooses the images from the directories specified by you.

For example, let take a simple page with two images on it:

<html>

<!-- For image without identifier -->
<img src="show_image.php"> <br />
<!-- /For image without identifier -->

<!-- For image with identifier imageID=a1 -->
<img src="show_image.php?imageID=a1"> <br />
<!-- /For image with identifier imageID=a1 -->

</html>


For each image define its own directory set, which the images will be chosen from.

Indicate them in the “show_image.php” file:

//------------------------------------------------------------------------
// Configuring image container
          'pictod_ImageContainer' => array(
                           'contName' => 'simple',
                           'contConf' => array(
                                   'images' => array(
                                             'default' => array('./images1','./images2'), // For image without identifier
                                             'a1' => array('./images2'), // For image with identifier imageID=a1
                                             ),
                                   ),
                           ),

//------------------------------------------------------------------------

Ordered_directory – All The Images From The Directory In Turn, Then Again Repeatedly

"ordered_directory" container takes in turn all the images from the directories specified by you. When the list is ended, images display begins again.

For example, let take a page with two images on it:

<html>
<img src="show_image.php?imageID=a1"> <br />
<img src="show_image.php?imageID=a2"> <br />
</html>


Specify its own directory set for each image:

//------------------------------------------------------------------------
// Configuring image container
          'pictod_ImageContainer' => array(

                           'contName' => 'ordered_directory',
                           'contConf' => array(
                                   'cacheDir' => './cache',
                                   'images' => array(

                                            'a1' => array('./images1,'./images2'),
                                            'a2' => array('./images3'),
                                             ),
                                   ),
                            ),
//------------------------------------------------------------------------

Container should store the information about the last displayed image on the hard disk, that is why it needs a directory specified in the "cacheDir" parameter (the rights on record for a web-server should be set on this directory).

Order_pict_list – According To The Specified Images List, Then Again Repeatedly

If the sequence of the images display is controlled by the computer by the same way as, for example, the “simple” and “ordered_directory” containers are then there are no guarantees that the computer will display the images in the needed sequence.

For example, if you need to display portraits of radio station DJs then it is important that they are displayed in a specified sequence depending on day time. In this case you should specify an accurate portrait list and the system will display them directly in the defined sequence.

In the example the two space images are sequentially displayed directly in the sequence specified in the list:

//------------------------------------------------------------------------
// Configuring image container
          'pictod_ImageContainer' => array(

                           'contName' => 'ordered_pict_list',
                           'contConf' => array(
                                   'cacheDir' => './cache',
                                   'images' => array(
                                            
'default' => array(  './images1/Asteroids_illusions_1024.jpg',  './images1/little_supernova_1024.jpg'  ),
                                             ),
                                   ),
                            ...
//------------------------------------------------------------------------


When the system comes to the end of your specified list, images display starts again from the first image.


Container should save the information about the last displayed image on the hard disk that is why it needs a directory specified in the "cacheDir" parameter (the rights on record for a web-server should be set on this directory).


Its own sequence of the images can be specified for each image on your page.



For example, let take a simple page with two images on it:

<html>
<img src="show_image.php?imageID=a1"> <br />
<img src="show_image.php?imageID=a2"> <br />
</html>


Specify its own display sequence for each image in the “show_image.php” file:

//------------------------------------------------------------------------
// Configuring image container
          'pictod_ImageContainer' => array(

                           'contName' => 'ordered_pict_list',
                           'contConf' => array(
                                   'cacheDir' => './cache',
                                   'images' => array(

                                            'a1' => array('./images1/Asteroids_illusions_1024.jpg','./images1/little_supernova_1024.jpg'),
                                            'a2' => array('./images2/Wolfgang_hijacking_1024.jpg'),
                                             ),
                                   ),
                            ),
//------------------------------------------------------------------------

Images Change Periodicity

Images change periodicity is set using the Rule.

In the current script version the following rules are realized:


Display periodicity is specified using the Rule. In the configuration it is specified by the “contName” variable in the “pictod_Ruler” category, for example:

// Configuring Rules
          'pictod_Ruler' => array(
                           'contName' => '
daily',
                            ...

At the same time each container has its own configurational parameters, which are set in the "contConf" variable of the "pictod_Ruler” category. All the configuration parameters for each rule are explained in details below.

Daily – Change Of An Image Once A Day

The rule is used for all your images.

No special configuration parameters are needed for the Rule.

//------------------------------------------------------------------------
// Configuring rules of displaying
          'pictod_Ruler' => array(
                      'contName' => 'daily',
                      'contConf' => array(

                              ),
                      ),

//------------------------------------------------------------------------

1min – Change Of An Image Once Per Minute

The rule is used for all your images.

No special configuration parameters are needed for the Rule.

//------------------------------------------------------------------------
// Configuring rules of displaying
          'pictod_Ruler' => array(
                      'contName' => '1min',
                      'contConf' => array(

                              ),
                      ),

//------------------------------------------------------------------------

always – Change Of An Image During Each Access Of Visitors To A Site Page

The rule is used for all your images.

No special configuration parameters are needed for the Rule.

//------------------------------------------------------------------------
// Configuring rules of displaying
          'pictod_Ruler' => array(
                      'contName' => 'always',
                      'contConf' => array(
                              ),
                      ),

//------------------------------------------------------------------------

Cronstring – Change Of An Image According To Your Own Rules

A very convenient rule which allows to set its images change periodicity for each of your images. At the same time the periodicity can be absolutely different: You can set the image change periodicity accurate within a minute, specify any week days and months.

The rules for each image are set in a line form.

The line has five fields which determine the date and the time of the image change. The image changes when a minute, hour and month of a year coincide with the current time and when minimum one of two fields (a day of a month or a day of a week) coincide with the current time.

The Rule works only when visitors access the page of your site.

The date and time fields are as follows:

field          allowed values

------         ---------------

minute         0-59

hour           0-23

day of a month 1-31

month          1-12

day of a week  0-7


There can be a mark (*) in the field, which always means "from the first till the last".

Number ranges are allowed. The range consists of two numbers separated by a hyphen (-). Numbers are included into the range. For example, 8-11 in the Hour field means the change of the image at 8,9,10 and 11 o’clock.

Lists are allowed. List is a number set (or ranges set) separated by commas. For example: "1,2,5,9", "0-4,8-12".

In order to work, the rule needs to store the last launch time on the hard disk. That is why it is necessary to have “cacheDir” directory in the configuration.

This is how the rules will look like in the configurational file:

//------------------------------------------------------------------------
// Configuring rules of displaying
     'pictod_Ruler' => array(
     'contName' => 'cronstring',
     'contConf' => array(
         'images' => array(
             'default' => '* * * * *', // Image without identifier changes once per minute
             'a1' => '0 0-4,8-12 1,2,5,9 * *', //
Image with identifier a1 changes on 1,2,5 and 9 day of each month at 0,1,2,3,4 and 8,9,10,11,12 hrs 0 min.
         ),
     'cacheDir' => './cache',
     ),
),
//------------------------------------------------------------------------

Data Caching Method

simple – Simple Caching In The Directory

Only one type of caching is realized in the current version, videlicet, in the directory of the hard disk specified by you.

//------------------------------------------------------------------------
         // Configuring cache
          'pictod_Cache' => array(
                      'contName' => 'simple',
                      'contConf' => array(
                              'cacheDir' => './cache',
                              ),
                      ),

//------------------------------------------------------------------------

The record rights for the web server should be set up upon the “cacheDir” directory. No other specific actions are needed.

 

Useful PHP scripts   Home

   Log In


Our PHP-it! Blog

Interesting PHP Articles

Interesting PHP Resources

 



 
Do You Have a Question? We'll Be Glad to Answer You
Your name: Message text:  
E-mail:
 
 
 
 
Contacts
E-mail: info@usefulclasses.com
ICQ: 749345
GTalk: varenich@gmail.com
  Creative Commons License

Text of this work is licensed under a Creative Commons Attribution-NoDerivs 2.5 License.
To use this work, please specify a hyperlink to this site: http://www.usefulclasses.com

Import Export Trade Leads Portal. Submit for Free.

Luxury Bathroom Remodeling . United States Map