plugins/Gallery.php
author Dan
Wed, 26 Aug 2009 23:21:56 -0400
changeset 37 3afbd6374442
parent 29 205d0534a0f2
child 39 e9a7e37bdadd
permissions -rw-r--r--
Fixed some 1.1.7 PHP warnings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
     1
<?php
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
     2
/*
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
     3
Plugin Name: Snapr
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
     4
Plugin URI: http://enanocms.org/plugin/snapr
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
     5
Description: Provides an intuitive image gallery system with a browser, viewer for individual images, upload interface, and comment system integration.
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
     6
Author: Dan Fuhry
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
     7
Version: 0.1 beta 3
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
     8
Author URI: http://enanocms.org/
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
     9
*/
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    10
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    11
global $db, $session, $paths, $template, $plugins; // Common objects
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    12
18
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents: 9
diff changeset
    13
define('GALLERY_VERSION', '0.1b2');
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    14
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    15
if ( !defined('ENANO_ATLEAST_1_1') )
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    16
{
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    17
  $fn = basename(__FILE__);
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    18
  setConfig("plugin_$fn", '0');
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    19
  die_semicritical('Snapr can\'t load on this site', '<p>This version of Snapr requires Enano 1.1.6 or later.</p>');
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    20
}
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    21
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    22
$magick_path = getConfig('imagemagick_path');
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    23
if ( !file_exists($magick_path) || !is_executable($magick_path) )
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    24
{
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    25
  $fn = basename(__FILE__);
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    26
  // set disabled flag with new plugin system
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    27
  if ( defined('ENANO_ATLEAST_1_1') && defined('PLUGIN_DISABLED') )
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    28
  {
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    29
    $q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_flags = plugin_flags | " . PLUGIN_DISABLED . " WHERE plugin_filename = 'Gallery.php';");
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    30
    if ( !$q )
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    31
      $db->_die();
37
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    32
	  
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    33
    // kill off cache
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    34
    global $cache;
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    35
    $cache->purge('plugins');
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    36
  }
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    37
  else
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    38
  {
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    39
    // old plugin system
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    40
    setConfig("plugin_$fn", '0');
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    41
  }
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    42
  
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    43
  die_semicritical('Snapr can\'t load on this site', '<p>You must have ImageMagick installed and working to use this plugin. The plugin has been disabled, please setup ImageMagick and then re-enable it.</p>');
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    44
}
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    45
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    46
if ( !getConfig('gallery_version') )
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    47
{
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    48
  $q = $db->sql_query('CREATE TABLE '.table_prefix.'gallery(
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    49
                        img_id int(12) NOT NULL auto_increment,
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    50
                        is_folder tinyint(1) NOT NULL DEFAULT 0,
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    51
                        folder_parent int(12) DEFAULT NULL,
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    52
                        img_title varchar(255) NOT NULL DEFAULT \'\',
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    53
                        img_desc longtext NOT NULL DEFAULT \'\',
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    54
                        print_sizes longtext NOT NULL DEFAULT \'\',
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    55
                        img_filename varchar(255) NOT NULL,
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    56
                        img_time_upload int(12) NOT NULL DEFAULT 0,
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    57
                        img_time_mod int(12) NOT NULL DEFAULT 0,
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    58
                        img_tags longtext,
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    59
                        PRIMARY KEY ( img_id )
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    60
                      );');
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents: 0
diff changeset
    61
  
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    62
  if ( !$q )
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    63
    $db->_die();
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    64
  
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents: 0
diff changeset
    65
  $q = $db->sql_query('CREATE FULLTEXT INDEX '.table_prefix.'gal_idx ON '.table_prefix.'gallery(img_title, img_desc);');
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents: 0
diff changeset
    66
  
8
8490ce0cdd8c Added sample image (Snapr logo) to the gallery on a clean installation
Dan
parents: 5
diff changeset
    67
  if ( !$q )
8490ce0cdd8c Added sample image (Snapr logo) to the gallery on a clean installation
Dan
parents: 5
diff changeset
    68
    $db->_die();
8490ce0cdd8c Added sample image (Snapr logo) to the gallery on a clean installation
Dan
parents: 5
diff changeset
    69
  
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    70
  $q = $db->sql_query('INSERT INTO '.table_prefix.'gallery(img_title,img_desc,img_filename,img_time_upload,img_time_mod,img_tags) VALUES(\'Welcome to Snapr!\', \'You\'\'re past the hard part - Snapr is set up and working on your server. What you\'\'re looking at now is what most users will see when they look at an image in your gallery. The next step is to [[Special:GalleryUpload|upload some images]]. After that, make your gallery publicly accessible by adding a link to the [[Special:Gallery|browser]], if you haven\'\'t already done so. See the README file included with Snapr for more information.\', \'snapr-logo.png\', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), \'[]\');');
8
8490ce0cdd8c Added sample image (Snapr logo) to the gallery on a clean installation
Dan
parents: 5
diff changeset
    71
  
8490ce0cdd8c Added sample image (Snapr logo) to the gallery on a clean installation
Dan
parents: 5
diff changeset
    72
  if ( !$q )
8490ce0cdd8c Added sample image (Snapr logo) to the gallery on a clean installation
Dan
parents: 5
diff changeset
    73
    $db->_die();
8490ce0cdd8c Added sample image (Snapr logo) to the gallery on a clean installation
Dan
parents: 5
diff changeset
    74
  
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    75
  setConfig('gallery_version', GALLERY_VERSION);
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    76
}
18
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents: 9
diff changeset
    77
if ( getConfig('gallery_version') == '0.1b1' )
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents: 9
diff changeset
    78
{
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    79
  $q = $db->sql_query('ALTER TABLE ' . table_prefix . 'gallery ADD COLUMN img_tags longtext;');
18
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents: 9
diff changeset
    80
  if ( !$q )
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents: 9
diff changeset
    81
    $db->_die();
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents: 9
diff changeset
    82
  setConfig('gallery_version', '0.1b2');
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents: 9
diff changeset
    83
}
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    84
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    85
require( ENANO_ROOT . '/plugins/gallery/functions.php' );
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    86
require( ENANO_ROOT . '/plugins/gallery/nssetup.php' );
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    87
require( ENANO_ROOT . '/plugins/gallery/viewimage.php' );
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    88
require( ENANO_ROOT . '/plugins/gallery/browser.php' );
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    89
require( ENANO_ROOT . '/plugins/gallery/upload.php' );
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    90
require( ENANO_ROOT . '/plugins/gallery/fetcher.php' );
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents: 0
diff changeset
    91
require( ENANO_ROOT . '/plugins/gallery/search.php' );
5
c0c324f0eeb5 Added the Random Image sidebar block
Dan
parents: 2
diff changeset
    92
require( ENANO_ROOT . '/plugins/gallery/sidebar.php' );
26
023a21c8f47c Added support for embedding Snapr images as wikitext code into regular pages
Dan
parents: 18
diff changeset
    93
require( ENANO_ROOT . '/plugins/gallery/imagetag.php' );
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    94
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    95
?>