source: extensions/BatchDownloader/main.inc.php @ 23167

Last change on this file since 23167 was 23167, checked in by mistic100, 11 years ago

replace readfile by readlargefile, add advanced parameter to use http redirection instead of php download

File size: 3.5 KB
Line 
1<?php 
2/*
3Plugin Name: Batch Downloader
4Version: auto
5Description: Allows users to download pictures sets in ZIP. Compatible with User Collections.
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=616
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11/*
12 * advanced config:
13 * $conf['batch_download_max_elements']  max value of the elements slider (default 1000)
14 * $conf['batch_download_max_size']      max value of the size slider (default 500)
15 * $conf['batch_download_force_pclzip']  if true, force the usage of PclZip instead of ZipArchive
16 * $conf['batch_download_direct']        if true, the download script will redirect to the zip instead of deliver it through PHP
17 */
18
19defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
20
21global $conf, $prefixeTable;
22
23defined('BATCH_DOWNLOAD_ID') or define('BATCH_DOWNLOAD_ID', basename(dirname(__FILE__)));
24define('BATCH_DOWNLOAD_PATH',    PHPWG_PLUGINS_PATH . BATCH_DOWNLOAD_ID . '/');
25define('BATCH_DOWNLOAD_TSETS',   $prefixeTable . 'download_sets');
26define('BATCH_DOWNLOAD_TIMAGES', $prefixeTable . 'download_sets_images');
27define('BATCH_DOWNLOAD_LOCAL',   PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/');
28define('BATCH_DOWNLOAD_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . BATCH_DOWNLOAD_ID);
29define('BATCH_DOWNLOAD_PUBLIC',  get_absolute_root_url() . make_index_url(array('section' => 'download')) . '/');
30define('BATCH_DOWNLOAD_VERSION', 'auto');
31
32
33add_event_handler('init', 'batch_download_init');
34
35if (defined('IN_ADMIN'))
36{
37  add_event_handler('get_admin_plugin_menu_links', 'batch_download_admin_menu');
38}
39else
40{
41  add_event_handler('loc_end_section_init', 'batch_download_section_init');
42  add_event_handler('loc_end_index', 'batch_download_page');
43
44  add_event_handler('loc_end_index', 'batch_download_clean');
45
46  add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
47
48  add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock');
49  add_event_handler('blockmanager_apply', 'batch_download_applymenu');
50}
51
52
53include_once(BATCH_DOWNLOAD_PATH . 'include/BatchDownloader.class.php');
54include_once(BATCH_DOWNLOAD_PATH . 'include/functions.inc.php');
55include_once(BATCH_DOWNLOAD_PATH . 'include/events.inc.php');
56
57
58
59/**
60 * update plugin & unserialize conf & load language
61 */
62function batch_download_init()
63{
64  global $conf, $pwg_loaded_plugins;
65 
66  if (
67    BATCH_DOWNLOAD_VERSION == 'auto' or
68    $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] == 'auto' or
69    version_compare($pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'], BATCH_DOWNLOAD_VERSION, '<')
70  )
71  {
72    include_once(BATCH_DOWNLOAD_PATH . 'include/install.inc.php');
73    batch_download_install();
74   
75    if ( $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] != 'auto' and BATCH_DOWNLOAD_VERSION != 'auto' )
76    {
77      $query = '
78UPDATE '. PLUGINS_TABLE .'
79SET version = "'. BATCH_DOWNLOAD_VERSION .'"
80WHERE id = "'. BATCH_DOWNLOAD_ID .'"';
81      pwg_query($query);
82     
83      $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] = BATCH_DOWNLOAD_VERSION;
84     
85      if (defined('IN_ADMIN'))
86      {
87        $_SESSION['page_infos'][] = 'BatchDownloader updated to version '. BATCH_DOWNLOAD_VERSION;
88      }
89    }
90  }
91 
92  $conf['batch_download'] = unserialize($conf['batch_download']);
93  load_language('plugin.lang', BATCH_DOWNLOAD_PATH);
94}
95
96/**
97 * admin plugins menu
98 */
99function batch_download_admin_menu($menu) 
100{
101  array_push($menu, array(
102    'NAME' => 'Batch Downloader',
103    'URL' => BATCH_DOWNLOAD_ADMIN,
104  ));
105  return $menu;
106}
107
108?>
Note: See TracBrowser for help on using the repository browser.